diff --git a/front/src/app/app.component.ts b/front/src/app/app.component.ts
index 0ce76ce..ef96ca2 100644
--- a/front/src/app/app.component.ts
+++ b/front/src/app/app.component.ts
@@ -5,12 +5,8 @@
*/
import { Component, OnInit } from '@angular/core';
-import { EventOnMenu } from 'common/component/top-menu/top-menu';
-import { MenuItem, MenuPosition } from 'common/model';
-import { UserService, SessionService, SSOService } from 'common/service';
-import { isNullOrUndefined } from 'common/utils';
-import { ArianeService } from './service';
-import { UserRoles222 } from 'common/service/session';
+import { ArianeService, MediaService, SeasonService, SeriesService, TypeService } from './service';
+import { EventOnMenu, MenuItem, MenuPosition, SSOService, SessionService, UserRoles222, UserService, isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
enum MenuEventType {
SSO_LOGIN = "SSO_CALL_LOGIN",
@@ -38,6 +34,11 @@ export class AppComponent implements OnInit {
location: string = "home";
constructor(
+ private mediaService: MediaService,
+ private seasonService: SeasonService,
+ private seriesService: SeriesService,
+ private typeService: TypeService,
+
private userService: UserService,
private sessionService: SessionService,
private ssoService: SSOService,
@@ -67,13 +68,13 @@ export class AppComponent implements OnInit {
});
this.userService.checkAutoConnect().then(() => {
- console.log(` ==>>>>> Autoconnect THEN !!!`);
+ console.log(` ==>>>>> Auto-connect THEN !!!`);
self.autoConnectedDone = true;
}).catch(() => {
- console.log(` ==>>>>> Autoconnect CATCH !!!`);
+ console.log(` ==>>>>> Auto-connect CATCH !!!`);
self.autoConnectedDone = true;
}).finally(() => {
- console.log(` ==>>>>> Autoconnect FINALLY !!!`);
+ console.log(` ==>>>>> Auto-connect FINALLY !!!`);
self.autoConnectedDone = true;
});
this.arianeService.segmentChange.subscribe((_segmentName: string) => {
diff --git a/front/src/app/app.module.ts b/front/src/app/app.module.ts
index 79b52b2..b23ccb2 100644
--- a/front/src/app/app.module.ts
+++ b/front/src/app/app.module.ts
@@ -22,9 +22,18 @@ import {
HomeScene, HelpScene, TypeScene, SeriesScene, SeasonScene, VideoScene, SettingsScene,
VideoEditScene, SeasonEditScene, SeriesEditScene
} from './scene';
-import { TypeService, DataService, SeriesService, SeasonService, VideoService, ArianeService, AdvancementService } from './service';
+import {
+ DataService,
+ AdvancementService,
+ MediaService,
+ SeasonService,
+ SeriesService,
+ TypeService,
+ ArianeService,
+} from './service';
import { UploadScene } from './scene/upload/upload';
-import { common_module_declarations, common_module_imports, common_module_providers, common_module_exports } from 'common/module';
+import { KarCWModule } from '@kangaroo-and-rabbit/kar-cw';
+import { environment } from 'environments/environment';
@NgModule({
declarations: [
@@ -46,25 +55,24 @@ import { common_module_declarations, common_module_imports, common_module_provid
VideoEditScene,
SeasonEditScene,
SeriesEditScene,
- UploadScene,
- ...common_module_declarations,
+ UploadScene
],
imports: [
BrowserModule,
RouterModule,
AppRoutingModule,
HttpClientModule,
- ...common_module_imports,
+ KarCWModule,
],
providers: [
- TypeService,
+ { provide: 'ENVIRONMENT', useValue: environment },
DataService,
- SeriesService,
- SeasonService,
- VideoService,
- ArianeService,
AdvancementService,
- ...common_module_providers,
+ MediaService,
+ SeasonService,
+ SeriesService,
+ TypeService,
+ ArianeService,
],
exports: [
AppComponent,
@@ -72,8 +80,7 @@ import { common_module_declarations, common_module_imports, common_module_provid
ElementSeriesComponent,
ElementSeasonComponent,
ElementVideoComponent,
- PopInCreateType,
- ...common_module_exports,
+ PopInCreateType
],
bootstrap: [
AppComponent
diff --git a/front/src/app/back-api/data-resource.ts b/front/src/app/back-api/data-resource.ts
new file mode 100644
index 0000000..f895c15
--- /dev/null
+++ b/front/src/app/back-api/data-resource.ts
@@ -0,0 +1,104 @@
+/**
+ * API of the server (auto-generated code)
+ */
+import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
+import {UUID, } from "./model"
+export namespace DataResource {
+
+ /**
+ * Insert a new data in the data environment
+ */
+ export function uploadFile({ restConfig, data, }: {
+ restConfig: RESTConfig,
+ data: {
+ file: File,
+ },
+ }): Promise
{
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/data//upload/",
+ requestType: HTTPRequestModel.POST,
+ contentType: HTTPMimeType.MULTIPART,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ data,
+ });
+ };
+ /**
+ * Get a thumbnail of from the data environment (if resize is possible)
+ */
+ // TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
+ export function retrieveDataThumbnailId({ restConfig, queries, params, data, }: {
+ restConfig: RESTConfig,
+ queries: {
+ Authorization: string,
+ },
+ params: {
+ id: UUID,
+ },
+ data: string,
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/data/thumbnail/{id}",
+ requestType: HTTPRequestModel.GET,
+ },
+ restConfig,
+ params,
+ queries,
+ data,
+ });
+ };
+ /**
+ * Get back some data from the data environment (with a beautiful name (permit download with basic name)
+ */
+ // TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
+ export function retrieveDataFull({ restConfig, queries, params, data, }: {
+ restConfig: RESTConfig,
+ queries: {
+ Authorization: string,
+ },
+ params: {
+ name: string,
+ id: UUID,
+ },
+ data: string,
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/data/{id}/{name}",
+ requestType: HTTPRequestModel.GET,
+ },
+ restConfig,
+ params,
+ queries,
+ data,
+ });
+ };
+ /**
+ * Get back some data from the data environment
+ */
+ // TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
+ export function retrieveDataId({ restConfig, queries, params, data, }: {
+ restConfig: RESTConfig,
+ queries: {
+ Authorization: string,
+ },
+ params: {
+ id: UUID,
+ },
+ data: string,
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/data/{id}",
+ requestType: HTTPRequestModel.GET,
+ },
+ restConfig,
+ params,
+ queries,
+ data,
+ });
+ };
+}
diff --git a/front/src/app/back-api/front.ts b/front/src/app/back-api/front.ts
new file mode 100644
index 0000000..f80b090
--- /dev/null
+++ b/front/src/app/back-api/front.ts
@@ -0,0 +1,8 @@
+/**
+ * API of the server (auto-generated code)
+ */
+import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
+import {} from "./model"
+export namespace Front {
+
+}
diff --git a/front/src/app/back-api/health-check.ts b/front/src/app/back-api/health-check.ts
new file mode 100644
index 0000000..85ed269
--- /dev/null
+++ b/front/src/app/back-api/health-check.ts
@@ -0,0 +1,23 @@
+/**
+ * API of the server (auto-generated code)
+ */
+import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
+import {HealthResult, isHealthResult, } from "./model"
+export namespace HealthCheck {
+
+ /**
+ * Get the server state (health)
+ */
+ export function getHealth({ restConfig, }: {
+ restConfig: RESTConfig,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/health_check",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ }, isHealthResult);
+ };
+}
diff --git a/front/src/app/back-api/index.ts b/front/src/app/back-api/index.ts
new file mode 100644
index 0000000..56eb8eb
--- /dev/null
+++ b/front/src/app/back-api/index.ts
@@ -0,0 +1,13 @@
+/**
+ * Global import of the package
+ */
+export * from "./model";
+export * from "./front";
+export * from "./health-check";
+export * from "./season-resource";
+export * from "./series-resource";
+export * from "./type-resource";
+export * from "./user-media-advancement-resource";
+export * from "./user-resource";
+export * from "./media-resource";
+export * from "./data-resource";
diff --git a/front/src/app/back-api/media-resource.ts b/front/src/app/back-api/media-resource.ts
new file mode 100644
index 0000000..fa6c8ea
--- /dev/null
+++ b/front/src/app/back-api/media-resource.ts
@@ -0,0 +1,157 @@
+/**
+ * API of the server (auto-generated code)
+ */
+import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
+import {Long, Media, UUID, isMedia, } from "./model"
+export namespace MediaResource {
+
+ /**
+ * Remove a specific Media
+ */
+ export function remove({ restConfig, params, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/video/{id}",
+ requestType: HTTPRequestModel.DELETE,
+ contentType: HTTPMimeType.TEXT_PLAIN,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ });
+ };
+ /**
+ * Get a specific Media with his ID
+ */
+ export function get({ restConfig, params, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/video/{id}",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, isMedia);
+ };
+ /**
+ * Modify a specific Media
+ */
+ export function patch({ restConfig, params, data, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ data: Media,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/video/{id}",
+ requestType: HTTPRequestModel.PATCH,
+ contentType: HTTPMimeType.JSON,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ data,
+ }, isMedia);
+ };
+ /**
+ * Create a new Media
+ */
+ export function uploadFile({ restConfig, data, }: {
+ restConfig: RESTConfig,
+ data: {
+ fileName: string,
+ file: File,
+ series: string,
+ universe: string,
+ season: string,
+ episode: string,
+ typeId: string,
+ title: string,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/video",
+ requestType: HTTPRequestModel.POST,
+ contentType: HTTPMimeType.MULTIPART,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ data,
+ }, isMedia);
+ };
+ /**
+ * Upload a new season cover media
+ */
+ export function uploadCover({ restConfig, params, data, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ data: {
+ fileName: string,
+ file: File,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/video/{id}/cover",
+ requestType: HTTPRequestModel.POST,
+ contentType: HTTPMimeType.MULTIPART,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ data,
+ }, isMedia);
+ };
+ /**
+ * Remove a specific cover of a media
+ */
+ export function removeCover({ restConfig, params, }: {
+ restConfig: RESTConfig,
+ params: {
+ coverId: UUID,
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/video/{id}/cover/{coverId}",
+ requestType: HTTPRequestModel.DELETE,
+ contentType: HTTPMimeType.TEXT_PLAIN,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, isMedia);
+ };
+ /**
+ * Get all Media
+ */
+ export function gets({ restConfig, }: {
+ restConfig: RESTConfig,
+ }): Promise {
+ return RESTRequestJsonArray({
+ restModel: {
+ endPoint: "/video",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ }, isMedia);
+ };
+}
diff --git a/front/src/app/back-api/model.ts b/front/src/app/back-api/model.ts
new file mode 100644
index 0000000..04c2ee8
--- /dev/null
+++ b/front/src/app/back-api/model.ts
@@ -0,0 +1,435 @@
+/**
+ * Interface of the server (auto-generated code)
+ */
+import { z as zod } from "zod";
+
+export const ZodUUID = zod.string().uuid();
+export type UUID = zod.infer;
+export function isUUID(data: any): data is UUID {
+ try {
+ ZodUUID.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodLong = zod.number();
+export type Long = zod.infer;
+export function isLong(data: any): data is Long {
+ try {
+ ZodLong.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodInteger = zod.number().safe();
+export type Integer = zod.infer;
+export function isInteger(data: any): data is Integer {
+ try {
+ ZodInteger.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodFloat = zod.number();
+export type Float = zod.infer;
+export function isFloat(data: any): data is Float {
+ try {
+ ZodFloat.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodInstant = zod.string();
+export type Instant = zod.infer;
+export function isInstant(data: any): data is Instant {
+ try {
+ ZodInstant.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodDate = zod.date();
+export type Date = zod.infer;
+export function isDate(data: any): data is Date {
+ try {
+ ZodDate.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodTimestamp = zod.date();
+export type Timestamp = zod.infer;
+export function isTimestamp(data: any): data is Timestamp {
+ try {
+ ZodTimestamp.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodLocalDate = zod.date();
+export type LocalDate = zod.infer;
+export function isLocalDate(data: any): data is LocalDate {
+ try {
+ ZodLocalDate.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodLocalTime = zod.date();
+export type LocalTime = zod.infer;
+export function isLocalTime(data: any): data is LocalTime {
+ try {
+ ZodLocalTime.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodRestErrorResponse = zod.object({
+ uuid: ZodUUID.optional(),
+ time: zod.string().max(255).optional(),
+ error: zod.string().max(255).optional(),
+ message: zod.string().max(255).optional(),
+ status: ZodInteger,
+ statusMessage: zod.string().max(255).optional()
+});
+export type RestErrorResponse = zod.infer;
+export function isRestErrorResponse(data: any): data is RestErrorResponse {
+ try {
+ ZodRestErrorResponse.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodHealthResult = zod.object({
+});
+export type HealthResult = zod.infer;
+export function isHealthResult(data: any): data is HealthResult {
+ try {
+ ZodHealthResult.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodGenericTiming = zod.object({
+ // Create time of the object
+ createdAt: ZodDate.readonly().optional(),
+ // When update the object
+ updatedAt: ZodDate.readonly().optional()
+});
+export type GenericTiming = zod.infer;
+export function isGenericTiming(data: any): data is GenericTiming {
+ try {
+ ZodGenericTiming.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodGenericData = ZodGenericTiming.extend({
+ // Unique Id of the object
+ id: ZodLong.readonly().optional()
+});
+export type GenericData = zod.infer;
+export function isGenericData(data: any): data is GenericData {
+ try {
+ ZodGenericData.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodGenericDataSoftDelete = ZodGenericData.extend({
+ // Deleted state
+ deleted: zod.boolean().readonly().optional()
+});
+export type GenericDataSoftDelete = zod.infer;
+export function isGenericDataSoftDelete(data: any): data is GenericDataSoftDelete {
+ try {
+ ZodGenericDataSoftDelete.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodSeason = ZodGenericDataSoftDelete.extend({
+ // Name of the media (this represent the title)
+ name: zod.string().optional(),
+ // Description of the media
+ description: zod.string().optional(),
+ // series parent ID
+ parentId: ZodLong.optional(),
+ // List of Id of the specific covers
+ covers: zod.array(ZodUUID).optional()
+});
+export type Season = zod.infer;
+export function isSeason(data: any): data is Season {
+ try {
+ ZodSeason.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodSeries = ZodGenericDataSoftDelete.extend({
+ // Name of the media (this represent the title)
+ name: zod.string().optional(),
+ // Description of the media
+ description: zod.string().optional(),
+ // series parent ID
+ parentId: ZodLong.optional(),
+ // List of Id of the specific covers
+ covers: zod.array(ZodUUID).optional()
+});
+export type Series = zod.infer;
+export function isSeries(data: any): data is Series {
+ try {
+ ZodSeries.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodType = ZodGenericDataSoftDelete.extend({
+ // Name of the media (this represent the title)
+ name: zod.string().optional(),
+ // Description of the media
+ description: zod.string().optional(),
+ // List of Id of the specific covers
+ covers: zod.array(ZodUUID).optional()
+});
+export type Type = zod.infer;
+export function isType(data: any): data is Type {
+ try {
+ ZodType.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodUserMediaAdvancement = ZodGenericDataSoftDelete.extend({
+ // Foreign Key Id of the user
+ userId: ZodLong,
+ // Id of the media
+ mediaId: ZodLong,
+ // Percent of advancement in the media
+ percent: ZodFloat,
+ // Number of second of advancement in the media
+ time: ZodInteger,
+ // Number of time this media has been read
+ count: ZodInteger
+});
+export type UserMediaAdvancement = zod.infer;
+export function isUserMediaAdvancement(data: any): data is UserMediaAdvancement {
+ try {
+ ZodUserMediaAdvancement.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodMediaInformationsDelta = zod.object({
+});
+export type MediaInformationsDelta = zod.infer;
+export function isMediaInformationsDelta(data: any): data is MediaInformationsDelta {
+ try {
+ ZodMediaInformationsDelta.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodUser = ZodGenericDataSoftDelete.extend({
+ login: zod.string().max(128).optional(),
+ lastConnection: ZodTimestamp.optional(),
+ admin: zod.boolean(),
+ blocked: zod.boolean(),
+ removed: zod.boolean(),
+ covers: zod.array(ZodLong).optional()
+});
+export type User = zod.infer;
+export function isUser(data: any): data is User {
+ try {
+ ZodUser.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodUserKarideo = ZodUser.extend({
+});
+export type UserKarideo = zod.infer;
+export function isUserKarideo(data: any): data is UserKarideo {
+ try {
+ ZodUserKarideo.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodUserOut = zod.object({
+ id: ZodLong,
+ login: zod.string().max(255).optional()
+});
+export type UserOut = zod.infer;
+export function isUserOut(data: any): data is UserOut {
+ try {
+ ZodUserOut.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodMedia = ZodGenericDataSoftDelete.extend({
+ name: zod.string().optional(),
+ description: zod.string().optional(),
+ dataId: ZodUUID.optional(),
+ typeId: ZodLong.optional(),
+ seriesId: ZodLong.optional(),
+ seasonId: ZodLong.optional(),
+ episode: ZodInteger.optional(),
+ date: ZodInteger.optional(),
+ time: ZodInteger.optional(),
+ ageLimit: ZodInteger.optional(),
+ covers: zod.array(ZodUUID).optional()
+});
+export type Media = zod.infer;
+export function isMedia(data: any): data is Media {
+ try {
+ ZodMedia.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodUUIDGenericData = ZodGenericTiming.extend({
+ // Unique UUID of the object
+ id: ZodUUID.readonly().optional()
+});
+export type UUIDGenericData = zod.infer;
+export function isUUIDGenericData(data: any): data is UUIDGenericData {
+ try {
+ ZodUUIDGenericData.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodUUIDGenericDataSoftDelete = ZodUUIDGenericData.extend({
+ // Deleted state
+ deleted: zod.boolean().readonly().optional()
+});
+export type UUIDGenericDataSoftDelete = zod.infer;
+export function isUUIDGenericDataSoftDelete(data: any): data is UUIDGenericDataSoftDelete {
+ try {
+ ZodUUIDGenericDataSoftDelete.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
+export const ZodData = ZodUUIDGenericDataSoftDelete.extend({
+ // Sha512 of the data
+ sha512: zod.string().max(128).optional(),
+ // Mime -type of the media
+ mimeType: zod.string().max(128).optional(),
+ // Size in Byte of the data
+ size: ZodLong.optional()
+});
+export type Data = zod.infer;
+export function isData(data: any): data is Data {
+ try {
+ ZodData.parse(data);
+ return true;
+ } catch (e: any) {
+ console.log(`Fail to parse data ${e}`);
+ return false;
+ }
+}
+
+
diff --git a/front/src/app/back-api/rest-tools.ts b/front/src/app/back-api/rest-tools.ts
new file mode 100644
index 0000000..0879a22
--- /dev/null
+++ b/front/src/app/back-api/rest-tools.ts
@@ -0,0 +1,246 @@
+/** @file
+ * @author Edouard DUPIN
+ * @copyright 2024, Edouard DUPIN, all right reserved
+ * @license MPL-2
+ */
+
+import { RestErrorResponse } from "./model"
+
+export enum HTTPRequestModel {
+ DELETE = 'DELETE',
+ GET = 'GET',
+ PATCH = 'PATCH',
+ POST = 'POST',
+ PUT = 'PUT',
+}
+export enum HTTPMimeType {
+ ALL = '*/*',
+ CSV = 'text/csv',
+ IMAGE = 'image/*',
+ IMAGE_JPEG = 'image/jpeg',
+ IMAGE_PNG = 'image/png',
+ JSON = 'application/json',
+ MULTIPART = 'multipart/form-data',
+ OCTET_STREAM = 'application/octet-stream',
+ TEXT_PLAIN = 'text/plain',
+}
+
+export interface RESTConfig {
+ // base of the server: http(s)://my.server.org/plop/api/
+ server: string;
+ // Token to access of the data.
+ token?: string;
+}
+
+export interface RESTModel {
+ // base of the local API request: "sheep/{id}".
+ endPoint: string;
+ // Type of the request.
+ requestType?: HTTPRequestModel;
+ // Input type requested.
+ accept?: HTTPMimeType;
+ // Content of the local data.
+ contentType?: HTTPMimeType;
+ // Mode of the TOKEN in urk or Header
+ tokenInUrl?: boolean;
+}
+
+export interface ModelResponseHttp {
+ status: number;
+ data: any;
+}
+
+export function isArrayOf(
+ data: any,
+ typeChecker: (subData: any) => subData is TYPE,
+ length?: number
+): data is TYPE[] {
+ if (!Array.isArray(data)) {
+ return false;
+ }
+ if (!data.every(typeChecker)) {
+ return false;
+ }
+ if (length !== undefined && data.length != length) {
+ return false;
+ }
+ return true;
+}
+
+export type RESTRequestType = {
+ restModel: RESTModel,
+ restConfig: RESTConfig,
+ data?: any,
+ params?: object,
+ queries?: object,
+};
+
+function removeTrailingSlashes(input: string): string {
+ return input.replace(/\/+$/, '');
+}
+function removeLeadingSlashes(input: string): string {
+ return input.replace(/^\/+/, '');
+}
+
+export function RESTUrl({ restModel, restConfig, data, params, queries }: RESTRequestType): string {
+ // Create the URL PATH:
+ let generateUrl = `${removeTrailingSlashes(restConfig.server)}/${removeLeadingSlashes(restModel.endPoint)}`;
+ if (params !== undefined) {
+ for (let key of Object.keys(params)) {
+ generateUrl = generateUrl.replaceAll(`{${key}}`, `${params[key]}`);
+ }
+ }
+ if (queries === undefined && (restConfig.token === undefined || restModel.tokenInUrl !== true)) {
+ return generateUrl;
+ }
+ const searchParams = new URLSearchParams();
+ if (queries !== undefined) {
+ for (let key of Object.keys(queries)) {
+ const value = queries[key];
+ if (Array.isArray(value)) {
+ for (let iii = 0; iii < value.length; iii++) {
+ searchParams.append(`${key}`, `${value[iii]}`);
+ }
+ } else {
+ searchParams.append(`${key}`, `${value}`);
+ }
+ }
+ }
+ if (restConfig.token !== undefined && restModel.tokenInUrl === true) {
+ searchParams.append('Authorization', `Bearer ${restConfig.token}`);
+ }
+ return generateUrl + "?" + searchParams.toString();
+}
+
+export function RESTRequest({ restModel, restConfig, data, params, queries }: RESTRequestType): Promise {
+ // Create the URL PATH:
+ let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
+ let headers: any = {};
+ if (restConfig.token !== undefined && restModel.tokenInUrl !== true) {
+ headers['Authorization'] = `Bearer ${restConfig.token}`;
+ }
+ if (restModel.accept !== undefined) {
+ headers['Accept'] = restModel.accept;
+ }
+ if (restModel.requestType !== HTTPRequestModel.GET) {
+ // if Get we have not a content type, the body is empty
+ if (restModel.contentType !== HTTPMimeType.MULTIPART) {
+ // special case of multi-part ==> no content type otherwise the browser does not set the ";bundary=--****"
+ headers['Content-Type'] = restModel.contentType;
+ }
+ }
+ let body = data;
+ if (restModel.contentType === HTTPMimeType.JSON) {
+ body = JSON.stringify(data);
+ } else if (restModel.contentType === HTTPMimeType.MULTIPART) {
+ const formData = new FormData();
+ for (const name in data) {
+ formData.append(name, data[name]);
+ }
+ body = formData
+ }
+ console.log(`Call ${generateUrl}`)
+ return new Promise((resolve, reject) => {
+ fetch(generateUrl, {
+ method: restModel.requestType,
+ headers,
+ body,
+ }).then((response: Response) => {
+ if (response.status >= 200 && response.status <= 299) {
+ const contentType = response.headers.get('Content-Type');
+ if (restModel.accept !== contentType) {
+ reject({
+ time: Date().toString(),
+ status: 901,
+ error: `REST check wrong type: ${restModel.accept} != ${contentType}`,
+ statusMessage: "Fetch error",
+ message: "rest-tools.ts Wrong type in the message return type"
+ } as RestErrorResponse);
+ } else if (contentType === HTTPMimeType.JSON) {
+ response
+ .json()
+ .then((value: any) => {
+ //console.log(`RECEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
+ resolve({ status: response.status, data: value });
+ })
+ .catch((reason: any) => {
+ reject({
+ time: Date().toString(),
+ status: 902,
+ error: `REST parse json fail: ${reason}`,
+ statusMessage: "Fetch parse error",
+ message: "rest-tools.ts Wrong message model to parse"
+ } as RestErrorResponse);
+ });
+ } else {
+ resolve({ status: response.status, data: response.body });
+ }
+ } else {
+ reject({
+ time: Date().toString(),
+ status: response.status,
+ error: `${response.body}`,
+ statusMessage: "Fetch code error",
+ message: "rest-tools.ts Wrong return code"
+ } as RestErrorResponse);
+ }
+ }).catch((error: any) => {
+ reject({
+ time: Date(),
+ status: 999,
+ error: error,
+ statusMessage: "Fetch catch error",
+ message: "http-wrapper.ts detect an error in the fetch request"
+ });
+ });
+ });
+}
+
+export function RESTRequestJson(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise {
+ return new Promise((resolve, reject) => {
+ RESTRequest(request).then((value: ModelResponseHttp) => {
+ if (checker(value.data)) {
+ resolve(value.data);
+ } else {
+ reject({
+ time: Date().toString(),
+ status: 950,
+ error: "REST Fail to verify the data",
+ statusMessage: "API cast ERROR",
+ message: "api.ts Check type as fail"
+ } as RestErrorResponse);
+ }
+ }).catch((reason: RestErrorResponse) => {
+ reject(reason);
+ });
+ });
+}
+export function RESTRequestJsonArray(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise {
+ return new Promise((resolve, reject) => {
+ RESTRequest(request).then((value: ModelResponseHttp) => {
+ if (isArrayOf(value.data, checker)) {
+ resolve(value.data);
+ } else {
+ reject({
+ time: Date().toString(),
+ status: 950,
+ error: "REST Fail to verify the data",
+ statusMessage: "API cast ERROR",
+ message: "api.ts Check type as fail"
+ } as RestErrorResponse);
+ }
+ }).catch((reason: RestErrorResponse) => {
+ reject(reason);
+ });
+ });
+}
+
+export function RESTRequestVoid(request: RESTRequestType): Promise {
+ return new Promise((resolve, reject) => {
+ RESTRequest(request).then((value: ModelResponseHttp) => {
+ resolve();
+ }).catch((reason: RestErrorResponse) => {
+ reject(reason);
+ });
+ });
+}
diff --git a/front/src/app/back-api/season-resource.ts b/front/src/app/back-api/season-resource.ts
new file mode 100644
index 0000000..4e70cb5
--- /dev/null
+++ b/front/src/app/back-api/season-resource.ts
@@ -0,0 +1,149 @@
+/**
+ * API of the server (auto-generated code)
+ */
+import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
+import {Long, Season, UUID, isSeason, } from "./model"
+export namespace SeasonResource {
+
+ /**
+ * Remove a specific season
+ */
+ export function remove({ restConfig, params, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/season/{id}",
+ requestType: HTTPRequestModel.DELETE,
+ contentType: HTTPMimeType.TEXT_PLAIN,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ });
+ };
+ /**
+ * Get all season
+ */
+ export function get({ restConfig, params, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/season/{id}",
+ requestType: HTTPRequestModel.GET,
+ contentType: HTTPMimeType.JSON,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, isSeason);
+ };
+ /**
+ * Modify a specific season
+ */
+ export function patch({ restConfig, params, data, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ data: Season,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/season/{id}",
+ requestType: HTTPRequestModel.PATCH,
+ contentType: HTTPMimeType.JSON,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ data,
+ }, isSeason);
+ };
+ /**
+ * Create a new season
+ */
+ export function post({ restConfig, data, }: {
+ restConfig: RESTConfig,
+ data: Season,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/season",
+ requestType: HTTPRequestModel.POST,
+ contentType: HTTPMimeType.JSON,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ data,
+ }, isSeason);
+ };
+ /**
+ * Upload a new season cover season
+ */
+ export function uploadCover({ restConfig, params, data, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ data: {
+ fileName: string,
+ file: File,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/season/{id}/add_cover",
+ requestType: HTTPRequestModel.POST,
+ contentType: HTTPMimeType.MULTIPART,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ data,
+ }, isSeason);
+ };
+ /**
+ * Remove a specific cover of a season
+ */
+ export function removeCover({ restConfig, params, }: {
+ restConfig: RESTConfig,
+ params: {
+ coverId: UUID,
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/season/{id}/cover/{coverId}",
+ requestType: HTTPRequestModel.DELETE,
+ contentType: HTTPMimeType.TEXT_PLAIN,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, isSeason);
+ };
+ /**
+ * Get a specific Season with his ID
+ */
+ export function gets({ restConfig, }: {
+ restConfig: RESTConfig,
+ }): Promise {
+ return RESTRequestJsonArray({
+ restModel: {
+ endPoint: "/season",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ }, isSeason);
+ };
+}
diff --git a/front/src/app/back-api/series-resource.ts b/front/src/app/back-api/series-resource.ts
new file mode 100644
index 0000000..46dfd45
--- /dev/null
+++ b/front/src/app/back-api/series-resource.ts
@@ -0,0 +1,149 @@
+/**
+ * API of the server (auto-generated code)
+ */
+import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
+import {Series, Long, UUID, isSeries, } from "./model"
+export namespace SeriesResource {
+
+ /**
+ * Remove a specific Series
+ */
+ export function remove({ restConfig, params, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/series/{id}",
+ requestType: HTTPRequestModel.DELETE,
+ contentType: HTTPMimeType.TEXT_PLAIN,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ });
+ };
+ /**
+ * Get a specific Series with his ID
+ */
+ export function get({ restConfig, params, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/series/{id}",
+ requestType: HTTPRequestModel.GET,
+ contentType: HTTPMimeType.JSON,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, isSeries);
+ };
+ /**
+ * Modify a specific Series
+ */
+ export function patch({ restConfig, params, data, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ data: Series,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/series/{id}",
+ requestType: HTTPRequestModel.PATCH,
+ contentType: HTTPMimeType.JSON,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ data,
+ }, isSeries);
+ };
+ /**
+ * Create a new Series
+ */
+ export function post({ restConfig, data, }: {
+ restConfig: RESTConfig,
+ data: Series,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/series",
+ requestType: HTTPRequestModel.POST,
+ contentType: HTTPMimeType.JSON,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ data,
+ }, isSeries);
+ };
+ /**
+ * Upload a new season cover Series
+ */
+ export function uploadCover({ restConfig, params, data, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ data: {
+ fileName: string,
+ file: File,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/series/{id}/cover",
+ requestType: HTTPRequestModel.POST,
+ contentType: HTTPMimeType.MULTIPART,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ data,
+ }, isSeries);
+ };
+ /**
+ * Remove a specific Series of a season
+ */
+ export function removeCover({ restConfig, params, }: {
+ restConfig: RESTConfig,
+ params: {
+ coverId: UUID,
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/series/{id}/cover/{coverId}",
+ requestType: HTTPRequestModel.DELETE,
+ contentType: HTTPMimeType.TEXT_PLAIN,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, isSeries);
+ };
+ /**
+ * Get all Series
+ */
+ export function gets({ restConfig, }: {
+ restConfig: RESTConfig,
+ }): Promise {
+ return RESTRequestJsonArray({
+ restModel: {
+ endPoint: "/series",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ }, isSeries);
+ };
+}
diff --git a/front/src/app/back-api/type-resource.ts b/front/src/app/back-api/type-resource.ts
new file mode 100644
index 0000000..9ec81e1
--- /dev/null
+++ b/front/src/app/back-api/type-resource.ts
@@ -0,0 +1,149 @@
+/**
+ * API of the server (auto-generated code)
+ */
+import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
+import {Long, Type, UUID, isType, } from "./model"
+export namespace TypeResource {
+
+ /**
+ * Remove a specific Type
+ */
+ export function remove({ restConfig, params, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/type/{id}",
+ requestType: HTTPRequestModel.DELETE,
+ contentType: HTTPMimeType.TEXT_PLAIN,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ });
+ };
+ /**
+ * Get a specific Type with his ID
+ */
+ export function get({ restConfig, params, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/type/{id}",
+ requestType: HTTPRequestModel.GET,
+ contentType: HTTPMimeType.JSON,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, isType);
+ };
+ /**
+ * Modify a specific Type
+ */
+ export function patch({ restConfig, params, data, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ data: Type,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/type/{id}",
+ requestType: HTTPRequestModel.PATCH,
+ contentType: HTTPMimeType.JSON,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ data,
+ }, isType);
+ };
+ /**
+ * Create a new Type
+ */
+ export function post({ restConfig, data, }: {
+ restConfig: RESTConfig,
+ data: Type,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/type",
+ requestType: HTTPRequestModel.POST,
+ contentType: HTTPMimeType.JSON,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ data,
+ }, isType);
+ };
+ /**
+ * Upload a new season cover Type
+ */
+ export function uploadCover({ restConfig, params, data, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ data: {
+ fileName: string,
+ file: File,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/type/{id}/cover",
+ requestType: HTTPRequestModel.POST,
+ contentType: HTTPMimeType.MULTIPART,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ data,
+ }, isType);
+ };
+ /**
+ * Remove a specific cover of a type
+ */
+ export function removeCover({ restConfig, params, }: {
+ restConfig: RESTConfig,
+ params: {
+ coverId: UUID,
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/type/{id}/cover/{coverId}",
+ requestType: HTTPRequestModel.DELETE,
+ contentType: HTTPMimeType.TEXT_PLAIN,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, isType);
+ };
+ /**
+ * Get all Type
+ */
+ export function gets({ restConfig, }: {
+ restConfig: RESTConfig,
+ }): Promise {
+ return RESTRequestJsonArray({
+ restModel: {
+ endPoint: "/type",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ }, isType);
+ };
+}
diff --git a/front/src/app/back-api/user-media-advancement-resource.ts b/front/src/app/back-api/user-media-advancement-resource.ts
new file mode 100644
index 0000000..15e44d2
--- /dev/null
+++ b/front/src/app/back-api/user-media-advancement-resource.ts
@@ -0,0 +1,84 @@
+/**
+ * API of the server (auto-generated code)
+ */
+import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
+import {MediaInformationsDelta, Long, UserMediaAdvancement, isUserMediaAdvancement, } from "./model"
+export namespace UserMediaAdvancementResource {
+
+ /**
+ * Remove a specific user advancement
+ */
+ export function remove({ restConfig, params, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestVoid({
+ restModel: {
+ endPoint: "/advancement/{id}",
+ requestType: HTTPRequestModel.DELETE,
+ contentType: HTTPMimeType.TEXT_PLAIN,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ });
+ };
+ /**
+ * Get a specific user advancement with his ID
+ */
+ export function get({ restConfig, params, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/advancement/{id}",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, isUserMediaAdvancement);
+ };
+ /**
+ * Modify a user advancement
+ */
+ export function patch({ restConfig, params, data, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ data: MediaInformationsDelta,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/advancement/{id}",
+ requestType: HTTPRequestModel.PATCH,
+ contentType: HTTPMimeType.JSON,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ data,
+ }, isUserMediaAdvancement);
+ };
+ /**
+ * Get all user advancement
+ */
+ export function gets({ restConfig, }: {
+ restConfig: RESTConfig,
+ }): Promise {
+ return RESTRequestJsonArray({
+ restModel: {
+ endPoint: "/advancement",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ }, isUserMediaAdvancement);
+ };
+}
diff --git a/front/src/app/back-api/user-resource.ts b/front/src/app/back-api/user-resource.ts
new file mode 100644
index 0000000..5be35de
--- /dev/null
+++ b/front/src/app/back-api/user-resource.ts
@@ -0,0 +1,57 @@
+/**
+ * API of the server (auto-generated code)
+ */
+import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
+import {UserOut, Long, UserKarideo, isUserOut, isUserKarideo, } from "./model"
+export namespace UserResource {
+
+ /**
+ * Get a specific user data
+ */
+ export function get({ restConfig, params, }: {
+ restConfig: RESTConfig,
+ params: {
+ id: Long,
+ },
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/users/{id}",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ params,
+ }, isUserKarideo);
+ };
+ /**
+ * Get the user personal data
+ */
+ export function getMe({ restConfig, }: {
+ restConfig: RESTConfig,
+ }): Promise {
+ return RESTRequestJson({
+ restModel: {
+ endPoint: "/users/me",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ }, isUserOut);
+ };
+ /**
+ * Get all the users
+ */
+ export function gets({ restConfig, }: {
+ restConfig: RESTConfig,
+ }): Promise {
+ return RESTRequestJsonArray({
+ restModel: {
+ endPoint: "/users",
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ },
+ restConfig,
+ }, isUserKarideo);
+ };
+}
diff --git a/front/src/app/component/data-image/data-image.ts b/front/src/app/component/data-image/data-image.ts
index fc82933..77c8479 100644
--- a/front/src/app/component/data-image/data-image.ts
+++ b/front/src/app/component/data-image/data-image.ts
@@ -4,32 +4,33 @@
* @license PROPRIETARY (see license file)
*/
import { Component, OnInit, Input } from '@angular/core';
+import { UUID } from 'app/back-api';
//import { ModelResponseHttp } from '@app/service/http-wrapper';
import { DataService } from 'app/service/data';
@Component({
selector: 'data-image',
templateUrl: './data-image.html',
- styleUrls: [ './data-image.less' ]
+ styleUrls: ['./data-image.less']
})
export class ElementDataImageComponent implements OnInit {
// input parameters
- @Input() id:number = -1;
+ @Input() id?: UUID;
cover: string = '';
-/*
- imageCanvas:any;
- @ViewChild('imageCanvas')
- set mainDivEl(el: ElementRef) {
- if(el !== null && el !== undefined) {
- this.imageCanvas = el.nativeElement;
+ /*
+ imageCanvas:any;
+ @ViewChild('imageCanvas')
+ set mainDivEl(el: ElementRef) {
+ if(el !== null && el !== undefined) {
+ this.imageCanvas = el.nativeElement;
+ }
}
- }
-*/
+ */
constructor(private dataService: DataService) {
}
ngOnInit() {
- this.cover = this.dataService.getCoverThumbnailUrl(this.id);
+ this.cover = this.dataService.getThumbnailUrl(this.id);
/*
let canvas = this.imageCanvas.nativeElement;
let ctx = canvas.getContext("2d");
diff --git a/front/src/app/component/element-season/element-season.ts b/front/src/app/component/element-season/element-season.ts
index ae96243..c9c1d38 100644
--- a/front/src/app/component/element-season/element-season.ts
+++ b/front/src/app/component/element-season/element-season.ts
@@ -3,29 +3,30 @@
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
-import {Component, OnInit, Input } from '@angular/core';
+import { Component, OnInit, Input } from '@angular/core';
+import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
+import { Season } from 'app/back-api';
import { SeasonService, DataService } from 'app/service';
-import { NodeData } from 'common/model';
-import { isNullOrUndefined } from 'common/utils';
@Component({
selector: 'app-element-season',
templateUrl: './element-season.html',
- styleUrls: [ './element-season.less' ]
+ styleUrls: ['./element-season.less']
})
export class ElementSeasonComponent implements OnInit {
// input parameters
- @Input() element:NodeData;
-
+ @Input() element: Season;
+
numberSeason: string;
count: number;
covers: string[];
description: string;
constructor(
+ private dataService: DataService,
private seasonService: SeasonService,
- private dataService: DataService) {
+ ) {
}
ngOnInit() {
@@ -36,7 +37,7 @@ export class ElementSeasonComponent implements OnInit {
}
this.numberSeason = this.element.name;
this.description = this.element.description;
- this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers);
+ this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
let self = this;
this.seasonService.countVideo(this.element.id)
.then((response) => {
diff --git a/front/src/app/component/element-series/element-series.ts b/front/src/app/component/element-series/element-series.ts
index 0727922..b9b4474 100644
--- a/front/src/app/component/element-series/element-series.ts
+++ b/front/src/app/component/element-series/element-series.ts
@@ -4,29 +4,30 @@
* @license PROPRIETARY (see license file)
*/
import { Component, OnInit, Input } from '@angular/core';
-import { NodeData } from 'common/model';
-import { isNullOrUndefined } from 'common/utils';
+import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
+import { Series } from 'app/back-api';
import { SeriesService, DataService } from 'app/service';
@Component({
selector: 'app-element-series',
templateUrl: './element-series.html',
- styleUrls: [ './element-series.less' ]
+ styleUrls: ['./element-series.less']
})
export class ElementSeriesComponent implements OnInit {
// input parameters
- @Input() element:NodeData;
-
- name:string = 'plouf';
- description:string = '';
- countvideo:number = null;
+ @Input() element: Series;
- covers:string[];
+ name: string = 'plouf';
+ description: string = '';
+ countvideo: number = null;
+
+ covers: string[];
constructor(
+ private dataService: DataService,
private seriesService: SeriesService,
- private dataService: DataService) {
+ ) {
}
ngOnInit() {
@@ -38,7 +39,7 @@ export class ElementSeriesComponent implements OnInit {
let self = this;
self.name = this.element.name;
self.description = this.element.description;
- self.covers = self.dataService.getCoverListThumbnailUrl(this.element.covers);
+ self.covers = self.dataService.getListThumbnailUrl(this.element.covers);
this.seriesService.countVideo(this.element.id)
.then((response) => {
diff --git a/front/src/app/component/element-type/element-type.ts b/front/src/app/component/element-type/element-type.ts
index 6db6d46..e2fb446 100644
--- a/front/src/app/component/element-type/element-type.ts
+++ b/front/src/app/component/element-type/element-type.ts
@@ -4,37 +4,38 @@
* @license PROPRIETARY (see license file)
*/
import { Component, OnInit, Input } from '@angular/core';
-import { isArrayOf, isNullOrUndefined, isNumberFinite } from 'common/utils';
-import { NodeData } from 'common/model';
+import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
+import { Type } from 'app/back-api';
import { TypeService, DataService } from 'app/service';
@Component({
selector: 'app-element-type',
templateUrl: './element-type.html',
- styleUrls: [ './element-type.less' ]
+ styleUrls: ['./element-type.less']
})
export class ElementTypeComponent implements OnInit {
// input parameters
- @Input() element:NodeData;
+ @Input() element: Type;
public name: string = 'rr';
public description: string;
- public countvideo:number;
+ public countVideo: number;
public covers: string[];
constructor(
+ private dataService: DataService,
private typeService: TypeService,
- private dataService: DataService) {
+ ) {
}
ngOnInit() {
if (isNullOrUndefined(this.element)) {
this.name = 'Not a media';
this.description = undefined;
- this.countvideo = undefined;
+ this.countVideo = undefined;
this.covers = undefined;
return;
}
@@ -42,13 +43,13 @@ export class ElementTypeComponent implements OnInit {
console.log(" ??? Get element ! " + JSON.stringify(this.element));
self.name = this.element.name;
self.description = this.element.description;
- self.covers = self.dataService.getCoverListThumbnailUrl(this.element.covers);
-
+ self.covers = self.dataService.getListThumbnailUrl(this.element.covers);
+
this.typeService.countVideo(this.element.id)
.then((response: number) => {
- self.countvideo = response;
+ self.countVideo = response;
}).catch(() => {
- self.countvideo = 0;
+ self.countVideo = 0;
});
}
}
diff --git a/front/src/app/component/element-video/element-video.ts b/front/src/app/component/element-video/element-video.ts
index 9655bff..50622ac 100644
--- a/front/src/app/component/element-video/element-video.ts
+++ b/front/src/app/component/element-video/element-video.ts
@@ -4,12 +4,10 @@
* @license PROPRIETARY (see license file)
*/
import { Injectable, Component, OnInit, Input } from '@angular/core';
-import { isMedia, Media } from 'app/model';
-import { UserMediaAdvancement } from 'app/model/user-media-advancement';
+import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
+import { Media, UserMediaAdvancement } from 'app/back-api';
import { AdvancementService, DataService } from 'app/service';
-import { NodeData } from 'common/model';
-import { isNullOrUndefined } from 'common/utils';
@Component({
selector: 'app-element-video',
@@ -20,7 +18,7 @@ import { isNullOrUndefined } from 'common/utils';
@Injectable()
export class ElementVideoComponent implements OnInit {
// input parameters
- @Input() element: NodeData;
+ @Input() element: Media;
data: Media;
name: string = '';
@@ -38,12 +36,6 @@ export class ElementVideoComponent implements OnInit {
// nothing to do.
}
ngOnInit() {
- if (!isMedia(this.element)) {
- this.data = undefined;
- this.name = 'Not a media';
- this.description = undefined;
- return;
- }
this.data = this.element;
this.name = this.element.name;
this.description = this.element.description;
@@ -52,7 +44,7 @@ export class ElementVideoComponent implements OnInit {
} else {
this.episodeDisplay = `${this.element.episode} - `;
}
- this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers);
+ this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
this.advancementService.get(this.element.id)
.then((response: UserMediaAdvancement) => {
diff --git a/front/src/app/model/index.ts b/front/src/app/model/index.ts
deleted file mode 100644
index b76f59c..0000000
--- a/front/src/app/model/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-
-export * from "./server-karideo-api.ts";
diff --git a/front/src/app/model/server-karideo-api.ts b/front/src/app/model/server-karideo-api.ts
deleted file mode 100644
index fc2f9d5..0000000
--- a/front/src/app/model/server-karideo-api.ts
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * Interface of the server (auto-generated code)
- */
-import { z as zod } from "zod";
-
-export const GenericTiming = zod.object({
- // Create time of the object
- createdAt: zod.date().readonly().optional(),
- // When update the object
- updatedAt: zod.date().readonly().optional()
-});
-
-export const UUIDGenericData = GenericTiming.extend({
- // Unique UUID of the object
- id: zod.string().uuid().readonly().optional()
-});
-
-export const UUIDGenericDataSoftDelete = UUIDGenericData.extend({
- // Deleted state
- deleted: zod.boolean().readonly().optional()
-});
-
-export const Data = UUIDGenericDataSoftDelete.extend({
- // Sha512 of the data
- sha512: zod.string().max(128).optional(),
- // Mime -type of the media
- mimeType: zod.string().max(128).optional(),
- // Size in Byte of the data
- size: zod.bigint().optional()
-});
-
-export const GenericData = GenericTiming.extend({
- // Unique Id of the object
- id: zod.bigint().readonly().optional()
-});
-
-export const GenericDataSoftDelete = GenericData.extend({
- // Deleted state
- deleted: zod.boolean().readonly().optional()
-});
-
-export const Media = GenericDataSoftDelete.extend({
- name: zod.string().optional(),
- description: zod.string().optional(),
- dataId: zod.string().uuid().optional(),
- typeId: zod.bigint().optional(),
- seriesId: zod.bigint().optional(),
- seasonId: zod.bigint().optional(),
- episode: zod.number().safe().optional(),
- date: zod.number().safe().optional(),
- time: zod.number().safe().optional(),
- ageLimit: zod.number().safe().optional(),
- covers: zod.array(zod.string().uuid()).optional()
-});
-
-export const Type = GenericDataSoftDelete.extend({
- // Name of the media (this represent the title)
- name: zod.string().optional(),
- // Description of the media
- description: zod.string().optional(),
- // List of Id of the specific covers
- covers: zod.array(zod.string().uuid()).optional()
-});
-
-export const Series = GenericDataSoftDelete.extend({
- // Name of the media (this represent the title)
- name: zod.string().optional(),
- // Description of the media
- description: zod.string().optional(),
- // series parent ID
- parentId: zod.bigint().optional(),
- // List of Id of the specific covers
- covers: zod.array(zod.string().uuid()).optional()
-});
-
-export const Season = GenericDataSoftDelete.extend({
- // Name of the media (this represent the title)
- name: zod.string().optional(),
- // Description of the media
- description: zod.string().optional(),
- // series parent ID
- parentId: zod.bigint().optional(),
- // List of Id of the specific covers
- covers: zod.array(zod.string().uuid()).optional()
-});
-
-export const User = GenericDataSoftDelete.extend({
- login: zod.string().max(128).optional(),
- lastConnection: zod.date().optional(),
- admin: zod.boolean(),
- blocked: zod.boolean(),
- removed: zod.boolean(),
- covers: zod.array(zod.bigint()).optional()
-});
-
-export const UserMediaAdvancement = GenericDataSoftDelete.extend({
- // Foreign Key Id of the user
- userId: zod.bigint(),
- // Id of the media
- mediaId: zod.bigint(),
- // Percent of advancement in the media
- percent: zod.number(),
- // Number of second of advancement in the media
- time: zod.number().safe(),
- // Number of time this media has been read
- count: zod.number().safe()
-});
-
diff --git a/front/src/app/popin/create-type/create-type.ts b/front/src/app/popin/create-type/create-type.ts
index 66cf025..f922045 100644
--- a/front/src/app/popin/create-type/create-type.ts
+++ b/front/src/app/popin/create-type/create-type.ts
@@ -4,13 +4,12 @@
* @license PROPRIETARY (see license file)
*/
import { Component, OnInit } from '@angular/core';
-
-import { PopInService } from 'common/service/popin';
+import { PopInService } from '@kangaroo-and-rabbit/kar-cw';
@Component({
selector: 'create-type',
templateUrl: './create-type.html',
- styleUrls: [ './create-type.less' ]
+ styleUrls: ['./create-type.less']
})
export class PopInCreateType implements OnInit {
name: string = '';
@@ -26,14 +25,14 @@ export class PopInCreateType implements OnInit {
}
eventPopUp(event: string): void {
- console.log(`GET event: ${ event}`);
+ console.log(`GET event: ${event}`);
this.popInService.close('popin-create-type');
}
- updateNeedSend():void {
+ updateNeedSend(): void {
}
- onName(value:any):void {
- if(value.length === 0) {
+ onName(value: any): void {
+ if (value.length === 0) {
this.name = '';
} else {
this.name = value;
@@ -41,8 +40,8 @@ export class PopInCreateType implements OnInit {
this.updateNeedSend();
}
- onDescription(value:any):void {
- if(value.length === 0) {
+ onDescription(value: any): void {
+ if (value.length === 0) {
this.description = '';
} else {
this.description = value;
diff --git a/front/src/app/scene/home/home.ts b/front/src/app/scene/home/home.ts
index bef85a6..c118691 100644
--- a/front/src/app/scene/home/home.ts
+++ b/front/src/app/scene/home/home.ts
@@ -12,31 +12,31 @@ import { ArianeService } from 'app/service/ariane';
@Component({
selector: 'app-home',
templateUrl: './home.html',
- styleUrls: [ './home.less' ]
+ styleUrls: ['./home.less']
})
export class HomeScene implements OnInit {
dataList = [];
error = '';
constructor(private typeService: TypeService,
- private arianeService: ArianeService) {
+ private arianeService: ArianeService) {
}
ngOnInit() {
let self = this;
- this.typeService.getData()
+ this.typeService.gets()
.then((response) => {
self.error = '';
self.dataList = response;
- console.log(`Get response: ${ JSON.stringify(response, null, 2)}`);
+ console.log(`Get response: ${JSON.stringify(response, null, 2)}`);
}).catch((response) => {
self.error = 'Wrong e-mail/login or password';
- console.log(`[E] ${ self.constructor.name }: Does not get a correct response from the server ...`);
+ console.log(`[E] ${self.constructor.name}: Does not get a correct response from the server ...`);
self.dataList = [];
});
this.arianeService.reset();
}
- onSelectType(_event: any, _idSelected: number):void {
+ onSelectType(_event: any, _idSelected: number): void {
this.arianeService.navigateType(_idSelected, _event.which === 2);
}
}
diff --git a/front/src/app/scene/season-edit/season-edit.ts b/front/src/app/scene/season-edit/season-edit.ts
index 7d04092..412e842 100644
--- a/front/src/app/scene/season-edit/season-edit.ts
+++ b/front/src/app/scene/season-edit/season-edit.ts
@@ -5,13 +5,10 @@
*/
import { Component, OnInit } from '@angular/core';
+import { PopInService, UploadProgress, isNumberFinite } from '@kangaroo-and-rabbit/kar-cw';
+import { Season, UUID } from 'app/back-api';
import { SeasonService, ArianeService, DataService } from 'app/service';
-import { NodeData } from 'common/model';
-
-import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
-import { PopInService } from 'common/service';
-import { isNumberFinite } from 'common/utils';
export interface ElementList {
value: number;
@@ -46,7 +43,7 @@ export class SeasonEditScene implements OnInit {
// --------------- confirm section ------------------
public confirmDeleteComment: string = null;
public confirmDeleteImageUrl: string = null;
- private deleteCoverId: number = null;
+ private deleteCoverId: UUID = null;
private deleteItemId: number = null;
deleteConfirmed() {
if (this.deleteCoverId !== null) {
@@ -67,10 +64,11 @@ export class SeasonEditScene implements OnInit {
constructor(
+ private dataService: DataService,
private seasonService: SeasonService,
private arianeService: ArianeService,
private popInService: PopInService,
- private dataService: DataService) {
+ ) {
}
@@ -78,7 +76,7 @@ export class SeasonEditScene implements OnInit {
this.idSeason = this.arianeService.getSeasonId();
let self = this;
this.seasonService.get(this.idSeason)
- .then((response: NodeData) => {
+ .then((response: Season) => {
console.log(`get response of season : ${JSON.stringify(response, null, 2)}`);
if (isNumberFinite(response.name)) {
self.numberVal = response.name;
@@ -108,7 +106,7 @@ export class SeasonEditScene implements OnInit {
for (let iii = 0; iii < covers.length; iii++) {
this.coversDisplay.push({
id: covers[iii],
- url: this.dataService.getCoverThumbnailUrl(covers[iii])
+ url: this.dataService.getThumbnailUrl(covers[iii])
});
}
} else {
@@ -126,7 +124,7 @@ export class SeasonEditScene implements OnInit {
sendValues(): void {
console.log('send new values....');
let data = {
- name: this.numberVal,
+ name: `${this.numberVal}`,
description: this.description
};
if (this.description === undefined) {
@@ -168,7 +166,7 @@ export class SeasonEditScene implements OnInit {
this.upload.clear();
// display the upload pop-in
this.popInService.open('popin-upload-progress');
- this.seasonService.uploadCover(file, this.idSeason, (count, total) => {
+ this.seasonService.uploadCover(this.idSeason, file, (count, total) => {
self.upload.mediaSendSize = count;
self.upload.mediaSize = total;
})
@@ -182,14 +180,14 @@ export class SeasonEditScene implements OnInit {
});
}
- removeCover(id: number) {
+ removeCover(id: UUID) {
this.cleanConfirm();
this.confirmDeleteComment = `Delete the cover ID: ${id}`;
- this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id);
+ this.confirmDeleteImageUrl = this.dataService.getThumbnailUrl(id);
this.deleteCoverId = id;
this.popInService.open('popin-delete-confirm');
}
- removeCoverAfterConfirm(id: number) {
+ removeCoverAfterConfirm(id: UUID) {
console.log(`Request remove cover: ${id}`);
let self = this;
this.seasonService.deleteCover(this.idSeason, id)
diff --git a/front/src/app/scene/season/season.ts b/front/src/app/scene/season/season.ts
index 46a1875..323b91e 100644
--- a/front/src/app/scene/season/season.ts
+++ b/front/src/app/scene/season/season.ts
@@ -24,11 +24,12 @@ export class SeasonScene implements OnInit {
videosError = '';
videos = [];
constructor(
+ private advancementService: AdvancementService,
+ private dataService: DataService,
private seasonService: SeasonService,
private seriesService: SeriesService,
private arianeService: ArianeService,
- private dataService: DataService,
- private advancementService: AdvancementService) {
+ ) {
}
@@ -46,9 +47,9 @@ export class SeasonScene implements OnInit {
self.cover = null;
self.covers = [];
} else {
- self.cover = self.dataService.getCoverUrl(response.covers[0]);
+ self.cover = self.dataService.getThumbnailUrl(response.covers[0]);
for (let iii = 0; iii < response.covers.length; iii++) {
- self.covers.push(self.dataService.getCoverUrl(response.covers[iii]));
+ self.covers.push(self.dataService.getThumbnailUrl(response.covers[iii]));
}
}
self.seriesService.get(self.seriesId)
diff --git a/front/src/app/scene/series-edit/series-edit.ts b/front/src/app/scene/series-edit/series-edit.ts
index ed3850b..32aeaf5 100644
--- a/front/src/app/scene/series-edit/series-edit.ts
+++ b/front/src/app/scene/series-edit/series-edit.ts
@@ -5,10 +5,10 @@
*/
import { Component, OnInit } from '@angular/core';
+import { PopInService, UploadProgress } from '@kangaroo-and-rabbit/kar-cw';
+import { UUID } from 'app/back-api';
import { SeriesService, DataService, TypeService, ArianeService } from 'app/service';
-import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
-import { PopInService } from 'common/service';
export class ElementList {
constructor(
@@ -53,7 +53,7 @@ export class SeriesEditScene implements OnInit {
// --------------- confirm section ------------------
public confirmDeleteComment: string = null;
public confirmDeleteImageUrl: string = null;
- private deleteCoverId: number = null;
+ private deleteCoverId: UUID = null;
private deleteItemId: number = null;
deleteConfirmed() {
if (this.deleteCoverId !== null) {
@@ -73,11 +73,13 @@ export class SeriesEditScene implements OnInit {
}
- constructor(private dataService: DataService,
- private typeService: TypeService,
+ constructor(
+ private dataService: DataService,
private seriesService: SeriesService,
+ private typeService: TypeService,
private arianeService: ArianeService,
- private popInService: PopInService) {
+ private popInService: PopInService,
+ ) {
}
@@ -86,7 +88,7 @@ export class SeriesEditScene implements OnInit {
let self = this;
this.listType = [{ value: null, label: '---' }];
- this.typeService.getData()
+ this.typeService.gets()
.then((response2) => {
for (let iii = 0; iii < response2.length; iii++) {
self.listType.push({ value: response2[iii].id, label: response2[iii].name });
@@ -133,7 +135,7 @@ export class SeriesEditScene implements OnInit {
for (let iii = 0; iii < covers.length; iii++) {
this.coversDisplay.push({
id: covers[iii],
- url: this.dataService.getCoverThumbnailUrl(covers[iii])
+ url: this.dataService.getThumbnailUrl(covers[iii])
});
}
} else {
@@ -203,7 +205,7 @@ export class SeriesEditScene implements OnInit {
this.upload.clear();
// display the upload pop-in
this.popInService.open('popin-upload-progress');
- this.seriesService.uploadCover(file, this.idSeries, (count, total) => {
+ this.seriesService.uploadCover(this.idSeries, file, (count, total) => {
self.upload.mediaSendSize = count;
self.upload.mediaSize = total;
})
@@ -216,14 +218,14 @@ export class SeriesEditScene implements OnInit {
console.log('Can not add the cover in the video...');
});
}
- removeCover(id: number) {
+ removeCover(id: UUID) {
this.cleanConfirm();
this.confirmDeleteComment = `Delete the cover ID: ${id}`;
- this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id);
+ this.confirmDeleteImageUrl = this.dataService.getThumbnailUrl(id);
this.deleteCoverId = id;
this.popInService.open('popin-delete-confirm');
}
- removeCoverAfterConfirm(id: number) {
+ removeCoverAfterConfirm(id: UUID) {
console.log(`Request remove cover: ${id}`);
let self = this;
this.seriesService.deleteCover(this.idSeries, id)
diff --git a/front/src/app/scene/series/series.ts b/front/src/app/scene/series/series.ts
index dd4be09..8f5704f 100644
--- a/front/src/app/scene/series/series.ts
+++ b/front/src/app/scene/series/series.ts
@@ -5,9 +5,9 @@
*/
import { Component, OnInit } from '@angular/core';
+import { Season } from 'app/back-api';
import { SeriesService, DataService, ArianeService, AdvancementService } from 'app/service';
-import { NodeData } from 'common/model';
@Component({
selector: 'app-series',
@@ -22,14 +22,15 @@ export class SeriesScene implements OnInit {
cover: string = '';
covers: Array = [];
seasonsError: string = '';
- seasons: NodeData[] = [];
+ seasons: Season[] = [];
videosError: string = '';
videos: Array = [];
constructor(
+ private advancementService: AdvancementService,
+ private dataService: DataService,
private seriesService: SeriesService,
private arianeService: ArianeService,
- private dataService: DataService,
- private advancementService: AdvancementService) {
+ ) {
}
@@ -51,9 +52,9 @@ export class SeriesScene implements OnInit {
self.cover = null;
self.covers = [];
} else {
- self.cover = self.dataService.getCoverUrl(response.covers[0]);
+ self.cover = self.dataService.getThumbnailUrl(response.covers[0]);
for (let iii = 0; iii < response.covers.length; iii++) {
- self.covers.push(self.dataService.getCoverUrl(response.covers[iii]));
+ self.covers.push(self.dataService.getThumbnailUrl(response.covers[iii]));
}
}
updateEnded.seriesMetadata = true;
@@ -67,7 +68,7 @@ export class SeriesScene implements OnInit {
});
//console.log(`get parameter id: ${ this.idSeries}`);
this.seriesService.getSeason(this.idSeries)
- .then((response: NodeData[]) => {
+ .then((response: Season[]) => {
//console.log(`>>>> get season : ${JSON.stringify(response)}`)
self.seasonsError = '';
self.seasons = response;
@@ -80,7 +81,7 @@ export class SeriesScene implements OnInit {
self.checkIfJumpIsNeeded(updateEnded);
});
this.seriesService.getVideo(this.idSeries)
- .then((response: NodeData[]) => {
+ .then((response: Season[]) => {
//console.log(`>>>> get video : ${JSON.stringify(response)}`)
self.videosError = '';
self.videos = response;
diff --git a/front/src/app/scene/type/type.ts b/front/src/app/scene/type/type.ts
index 24beef3..fb82be4 100644
--- a/front/src/app/scene/type/type.ts
+++ b/front/src/app/scene/type/type.ts
@@ -5,7 +5,6 @@
*/
import { Component, OnInit } from '@angular/core';
-import { ActivatedRoute } from '@angular/router';
import { TypeService, DataService, ArianeService, AdvancementService } from 'app/service';
@@ -26,9 +25,9 @@ export class TypeScene implements OnInit {
videosError = '';
videos = [];
constructor(
+ private dataService: DataService,
private typeService: TypeService,
private arianeService: ArianeService,
- private dateService: DataService,
private advancementService: AdvancementService) {
/*
@@ -54,9 +53,9 @@ export class TypeScene implements OnInit {
self.cover = null;
self.covers = [];
} else {
- self.cover = self.dateService.getCoverUrl(response.covers[0]);
+ self.cover = self.dataService.getThumbnailUrl(response.covers[0]);
for (let iii = 0; iii < response.covers.length; iii++) {
- self.covers.push(self.dateService.getCoverUrl(response.covers[iii]));
+ self.covers.push(self.dataService.getThumbnailUrl(response.covers[iii]));
}
}
}).catch((response) => {
diff --git a/front/src/app/scene/upload/upload.ts b/front/src/app/scene/upload/upload.ts
index 5cb7c6a..6257534 100644
--- a/front/src/app/scene/upload/upload.ts
+++ b/front/src/app/scene/upload/upload.ts
@@ -5,11 +5,9 @@
*/
import { Component, OnInit } from '@angular/core';
-import { ActivatedRoute } from '@angular/router';
+import { PopInService, UploadProgress } from '@kangaroo-and-rabbit/kar-cw';
-import { TypeService, SeriesService, VideoService, ArianeService, SeasonService } from 'app/service';
-import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
-import { PopInService } from 'common/service';
+import { TypeService, SeriesService, MediaService, SeasonService } from 'app/service';
export class ElementList {
constructor(
@@ -23,7 +21,6 @@ export class FileParsedElement {
public nameDetected: boolean = false;
public episodeDetected: boolean = false;
constructor(
- public id: number,
public file: File,
public series: string,
public season: number,
@@ -79,7 +76,7 @@ export class UploadScene implements OnInit {
*/
config = {
displayKey: 'description', // if objects array passed which key to be displayed defaults to description
- search: true, // true/false for the search functionlity defaults to false,
+ search: true, // true/false for the search functionality defaults to false,
height: 'auto', // height of the list so that if there are more no of items it can show a scroll defaults to auto. With auto height scroll will never appear
placeholder: 'Select', // text to be displayed when no item is selected defaults to Select,
customComparator: () => { }, // a custom function using which user wants to sort the items. default is undefined and Array.sort() will be used in that case,
@@ -94,10 +91,11 @@ export class UploadScene implements OnInit {
];
globalSeries: string = '';
globalSeason: number = null;
- constructor(private typeService: TypeService,
- private seriesService: SeriesService,
+ constructor(
+ private MediaService: MediaService,
private seasonService: SeasonService,
- private videoService: VideoService,
+ private seriesService: SeriesService,
+ private typeService: TypeService,
private popInService: PopInService) {
// nothing to do.
}
@@ -124,7 +122,7 @@ export class UploadScene implements OnInit {
this.listType = [{ value: null, label: '---' }];
this.listSeries = [{ value: null, label: '---' }];
this.listSeason = [{ value: null, label: '---' }];
- this.typeService.getData()
+ this.typeService.gets()
.then((response2) => {
for (let iii = 0; iii < response2.length; iii++) {
self.listType.push({ value: response2[iii].id, label: response2[iii].name });
@@ -305,7 +303,7 @@ export class UploadScene implements OnInit {
}
// remove extention
title = title.replace(new RegExp('\\.(mkv|MKV|Mkv|webm|WEBM|Webm|mp4)'), '');
- let tmp = new FileParsedElement(this.parsedElement.length, file, series, season, episode, title);
+ let tmp = new FileParsedElement(file, series, season, episode, title);
console.log(`==>${JSON.stringify(tmp)}`);
// add it in the list.
this.parsedElement.push(tmp);
@@ -427,7 +425,7 @@ export class UploadScene implements OnInit {
}
self.upload.labelMediaTitle = `[${id + 1}/${total}]${self.upload.labelMediaTitle}${eleemnent.title}`;
- self.videoService.uploadFile(eleemnent.file,
+ self.MediaService.uploadFile(eleemnent.file,
self.globalSeries,
self.seriesId,
self.globalSeason,
diff --git a/front/src/app/scene/video-edit/video-edit.ts b/front/src/app/scene/video-edit/video-edit.ts
index 00505f8..465933e 100644
--- a/front/src/app/scene/video-edit/video-edit.ts
+++ b/front/src/app/scene/video-edit/video-edit.ts
@@ -5,14 +5,10 @@
*/
import { Component, OnInit } from '@angular/core';
-import { ActivatedRoute } from '@angular/router';
-
-import { DataService, TypeService, SeriesService, VideoService, ArianeService } from 'app/service';
-import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
-import { NodeData } from 'common/model';
-import { PopInService } from 'common/service';
-import { Media } from 'app/model';
+import { DataService, TypeService, SeriesService, MediaService, ArianeService } from 'app/service';
+import { PopInService, UploadProgress } from '@kangaroo-and-rabbit/kar-cw';
+import { Media, Season, Series, UUID } from 'app/back-api';
export interface ElementList {
value?: number;
@@ -24,27 +20,13 @@ class DataToSend {
name: string = '';
description: string = '';
episode?: number;
- seriesId: number = null;
- seasonId: number = null;
- dataId: number = -1;
+ seriesId?: number;
+ seasonId?: number;
+ dataId?: UUID;
time?: number;
- typeId: number = null;
+ typeId?: number;
covers: number[] = [];
generatedName: string = '';
- clone() {
- let tmp = new DataToSend();
- tmp.name = this.name;
- tmp.description = this.description;
- tmp.episode = this.episode;
- tmp.seriesId = this.seriesId;
- tmp.seasonId = this.seasonId;
- tmp.dataId = this.dataId;
- tmp.time = this.time;
- tmp.typeId = this.typeId;
- tmp.covers = this.covers;
- tmp.generatedName = this.generatedName;
- return tmp;
- }
}
@Component({
@@ -74,7 +56,7 @@ export class VideoEditScene implements OnInit {
// --------------- confirm section ------------------
public confirmDeleteComment: string = null;
public confirmDeleteImageUrl: string = null;
- private deleteCoverId: number = null;
+ private deleteCoverId: UUID = null;
private deleteMediaId: number = null;
deleteConfirmed() {
if (this.deleteCoverId !== null) {
@@ -109,12 +91,13 @@ export class VideoEditScene implements OnInit {
{ value: undefined, label: '---' },
];
constructor(
- private typeService: TypeService,
+ private dataService: DataService,
+ private MediaService: MediaService,
private seriesService: SeriesService,
- private videoService: VideoService,
+ private typeService: TypeService,
private arianeService: ArianeService,
private popInService: PopInService,
- private dataService: DataService) {
+ ) {
}
@@ -152,7 +135,7 @@ export class VideoEditScene implements OnInit {
this.data.covers.push(covers[iii]);
this.coversDisplay.push({
id: covers[iii],
- url: this.dataService.getCoverThumbnailUrl(covers[iii])
+ url: this.dataService.getThumbnailUrl(covers[iii])
});
}
} else {
@@ -166,7 +149,7 @@ export class VideoEditScene implements OnInit {
this.listUniverse = [{ value: null, label: '---' }];
this.listSeries = [{ value: null, label: '---' }];
this.listSeason = [{ value: null, label: '---' }];
- this.typeService.getData()
+ this.typeService.gets()
.then((response2) => {
for (let iii = 0; iii < response2.length; iii++) {
self.listType.push({ value: response2[iii].id, label: response2[iii].name });
@@ -175,7 +158,7 @@ export class VideoEditScene implements OnInit {
console.log(`get response22 : ${JSON.stringify(response2, null, 2)}`);
});
// this.seriesService.getOrder()
- this.seriesService.getData()
+ this.seriesService.gets()
.then((response3) => {
for (let iii = 0; iii < response3.length; iii++) {
self.listSeries.push({ value: response3[iii].id, label: response3[iii].name });
@@ -184,7 +167,7 @@ export class VideoEditScene implements OnInit {
}).catch((response3) => {
console.log(`get response3 : ${JSON.stringify(response3, null, 2)}`);
});
- this.videoService.get(this.idVideo)
+ this.MediaService.get(this.idVideo)
.then((response: Media) => {
console.log(`get response of video : ${JSON.stringify(response, null, 2)}`);
self.data.name = response.name;
@@ -199,7 +182,7 @@ export class VideoEditScene implements OnInit {
if (self.data.seasonId === undefined) {
self.data.seasonId = null;
}
- self.dataOri = self.data.clone();
+ self.dataOri = { ...self.data };
self.updateCoverList(response.covers);
self.updateNeedSend();
console.log(`coversList : ${JSON.stringify(self.coversDisplay, null, 2)}`);
@@ -208,7 +191,7 @@ export class VideoEditScene implements OnInit {
self.error = 'Can not get the data';
self.data = new DataToSend();
self.coversDisplay = [];
- self.dataOri = self.data.clone();
+ self.dataOri = { ...self.data };
self.updateNeedSend();
self.itemIsNotFound = true;
self.itemIsLoading = false;
@@ -229,7 +212,7 @@ export class VideoEditScene implements OnInit {
this.updateNeedSend();
if (this.data.typeId !== undefined) {
self.typeService.getSubSeries(this.data.typeId)
- .then((response2: NodeData[]) => {
+ .then((response2: Series[]) => {
for (let iii = 0; iii < response2.length; iii++) {
self.listSeries.push({ value: response2[iii].id, label: response2[iii].name });
}
@@ -249,7 +232,7 @@ export class VideoEditScene implements OnInit {
let self = this;
if (this.data.seriesId !== undefined) {
self.seriesService.getSeason(this.data.seriesId)
- .then((response3: NodeData[]) => {
+ .then((response3: Season[]) => {
for (let iii = 0; iii < response3.length; iii++) {
self.listSeason.push({ value: response3[iii].id, label: `season ${response3[iii].name}` });
}
@@ -338,9 +321,9 @@ export class VideoEditScene implements OnInit {
data.seasonId = this.data.seasonId;
}
}
- let tmpp = this.data.clone();
+ const tmpp = { ...this.data };
let self = this;
- this.videoService.patch(this.idVideo, data)
+ this.MediaService.patch(this.idVideo, data)
.then((response3) => {
self.dataOri = tmpp;
self.updateNeedSend();
@@ -385,14 +368,14 @@ export class VideoEditScene implements OnInit {
this.upload.clear();
// display the upload pop-in
this.popInService.open('popin-upload-progress');
- this.videoService.uploadCover(file, this.idVideo, (count, total) => {
+ this.MediaService.uploadCover(this.idVideo, file, (count, total) => {
self.upload.mediaSendSize = count;
self.upload.mediaSize = total;
})
.then((response: any) => {
console.log(`get response of cover : ${JSON.stringify(response, null, 2)}`);
self.upload.result = 'Cover added done';
- // we retrive the whiole media ==> update data ...
+ // we retrieve the while media ==> update data ...
self.updateCoverList(response.covers);
}).catch((response: any) => {
// self.error = "Can not get the data";
@@ -401,21 +384,21 @@ export class VideoEditScene implements OnInit {
});
}
- removeCover(id: number) {
+ removeCover(id: UUID) {
this.cleanConfirm();
this.confirmDeleteComment = `Delete the cover ID: ${id}`;
- this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id);
+ this.confirmDeleteImageUrl = this.dataService.getThumbnailUrl(id);
this.deleteCoverId = id;
this.popInService.open('popin-delete-confirm');
}
- removeCoverAfterConfirm(id: number) {
+ removeCoverAfterConfirm(id: UUID) {
console.log(`Request remove cover: ${id}`);
let self = this;
- this.videoService.deleteCover(this.idVideo, id)
+ this.MediaService.deleteCover(this.idVideo, id)
.then((response: any) => {
console.log(`get response of remove cover : ${JSON.stringify(response, null, 2)}`);
self.upload.result = 'Cover remove done';
- // we retrive the whiole media ==> update data ...
+ // we retrieve the while media ==> update data ...
self.updateCoverList(response.covers);
}).catch((response: any) => {
// self.error = "Can not get the data";
@@ -432,7 +415,7 @@ export class VideoEditScene implements OnInit {
}
removeItemAfterConfirm(id: number) {
let self = this;
- this.videoService.delete(id)
+ this.MediaService.delete(id)
.then((response3) => {
// self.dataOri = tmpp;
// self.updateNeedSend();
diff --git a/front/src/app/scene/video/video.ts b/front/src/app/scene/video/video.ts
index 32a0ec7..e8adab2 100644
--- a/front/src/app/scene/video/video.ts
+++ b/front/src/app/scene/video/video.ts
@@ -5,10 +5,10 @@
*/
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
-import { UserMediaAdvancement } from 'app/model/user-media-advancement';
-import { DataService, VideoService, SeriesService, SeasonService, ArianeService, AdvancementService } from 'app/service';
-import { HttpWrapperService } from 'common/service';
-import { isNullOrUndefined } from 'common/utils';
+import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
+import { UUID, UserMediaAdvancement } from 'app/back-api';
+import { DataService, MediaService, SeriesService, SeasonService, ArianeService, AdvancementService } from 'app/service';
+
@Component({
selector: 'app-video',
@@ -53,7 +53,7 @@ export class VideoScene implements OnInit {
seriesName: string = undefined;
seasonId: number = undefined;
seasonName: string = undefined;
- dataId: number = -1;
+ dataId: UUID;
time: number = undefined;
typeId: number = undefined;
generatedName: string = '';
@@ -74,7 +74,7 @@ export class VideoScene implements OnInit {
timeLeft: number = 10;
interval = null;
- userMetaData: UserMediaAdvancement & { percentDisplay?: number } = undefined
+ userMetaData: UserMediaAdvancement & { percentDisplay: number } = undefined
previousTime: number = 0;
startPlayingTime: number = undefined;
@@ -88,13 +88,13 @@ export class VideoScene implements OnInit {
registered: false
};
- constructor(private videoService: VideoService,
- private seriesService: SeriesService,
- private seasonService: SeasonService,
- private httpService: HttpWrapperService,
- private arianeService: ArianeService,
+ constructor(
private dataService: DataService,
- private advancementService: AdvancementService) {
+ private advancementService: AdvancementService,
+ private MediaService: MediaService,
+ private seasonService: SeasonService,
+ private seriesService: SeriesService,
+ private arianeService: ArianeService,) {
}
@@ -154,10 +154,10 @@ export class VideoScene implements OnInit {
this.generatedName = this.generatedName.replace(new RegExp('&', 'g'), '_');
this.generatedName = this.generatedName.replace(new RegExp('/', 'g'), '_');
// update the path of the uri request
- this.videoSource = this.httpService.createRESTCall2({
- api: `data/${this.dataId}/${this.generatedName}`,
- addURLToken: true,
- });
+ this.videoSource = this.dataService.getUrl(
+ this.dataId,
+ this.generatedName,
+ );
}
myPeriodicCheckFunction() {
@@ -209,7 +209,7 @@ export class VideoScene implements OnInit {
let self = this;
self.haveNext = null;
self.havePrevious = null;
- this.videoService.get(this.idVideo)
+ this.MediaService.get(this.idVideo)
.then((response) => {
console.log(`get response of video : ${JSON.stringify(response, null, 2)}`);
self.error = '';
@@ -221,15 +221,12 @@ export class VideoScene implements OnInit {
self.dataId = response.dataId;
self.time = response.time;
self.generatedName = "????????? TODO: ???????" //response.generatedName;
- if (self.dataId !== -1) {
- self.videoSource = self.httpService.createRESTCall2({
- api: `data/${self.dataId}/${self.generatedName}`,
- addURLToken: true,
- });
+ if (!isNullOrUndefined(self.dataId)) {
+ self.videoSource = self.dataService.getUrl(self.dataId, self.generatedName);
} else {
self.videoSource = '';
}
- self.covers = self.dataService.getCoverListUrl(response.covers);
+ self.covers = self.dataService.getListThumbnailUrl(response.covers);
self.generateName();
if (self.seriesId !== undefined && self.seriesId !== null) {
@@ -271,7 +268,7 @@ export class VideoScene implements OnInit {
self.haveNext = response6[iii];
}
}
- //self.covers.push(self.dataService.getCoverUrl(response6[iii]));
+ //self.covers.push(self.dataService.getThumbnailUrl(response6[iii]));
}
}).catch((response7: any) => {
@@ -287,7 +284,7 @@ export class VideoScene implements OnInit {
self.episode = undefined;
self.seriesId = undefined;
self.seasonId = undefined;
- self.dataId = -1;
+ self.dataId = undefined;
self.time = undefined;
self.generatedName = '';
self.videoSource = '';
@@ -324,6 +321,12 @@ export class VideoScene implements OnInit {
this.startHideTimer();
this.playVideo = false;
this.displayVolumeMenu = false;
+
+ /*
+ if(this.isFullScreen === true) {
+ this.isFullScreen = false;
+ }
+ */
}
changeStateToPlay() {
@@ -451,8 +454,7 @@ export class VideoScene implements OnInit {
onStop() {
console.log('stop');
this.startHideTimer();
- if (this.videoPlayer === null ||
- this.videoPlayer === undefined) {
+ if (isNullOrUndefined(this.videoPlayer)) {
console.log(`error element: ${this.videoPlayer}`);
return;
}
@@ -473,8 +475,7 @@ export class VideoScene implements OnInit {
seek(newValue: any) {
console.log(`seek ${newValue.value}`);
this.startHideTimer();
- if (this.videoPlayer === null ||
- this.videoPlayer === undefined) {
+ if (isNullOrUndefined(this.videoPlayer)) {
console.log(`error element: ${this.videoPlayer}`);
return;
}
@@ -484,8 +485,7 @@ export class VideoScene implements OnInit {
onRewind() {
console.log('rewind');
this.startHideTimer();
- if (this.videoPlayer === null ||
- this.videoPlayer === undefined) {
+ if (isNullOrUndefined(this.videoPlayer)) {
console.log(`error element: ${this.videoPlayer}`);
return;
}
@@ -495,8 +495,7 @@ export class VideoScene implements OnInit {
onForward() {
console.log('forward');
this.startHideTimer();
- if (this.videoPlayer === null ||
- this.videoPlayer === undefined) {
+ if (isNullOrUndefined(this.videoPlayer)) {
console.log(`error element: ${this.videoPlayer}`);
return;
}
@@ -506,8 +505,7 @@ export class VideoScene implements OnInit {
onMore() {
console.log('more');
this.startHideTimer();
- if (this.videoPlayer === null ||
- this.videoPlayer === undefined) {
+ if (isNullOrUndefined(this.videoPlayer)) {
console.log(`error element: ${this.videoPlayer}`);
return;
}
@@ -515,8 +513,7 @@ export class VideoScene implements OnInit {
onFullscreen() {
console.log('fullscreen');
this.startHideTimer();
- if (this.videoGlobal === null ||
- this.videoGlobal === undefined) {
+ if (isNullOrUndefined(this.videoGlobal)) {
console.log(`error element: ${this.videoGlobal}`);
return;
}
@@ -537,8 +534,7 @@ export class VideoScene implements OnInit {
onFullscreenExit22(docc: any) {
console.log('fullscreen EXIT');
this.startHideTimer();
- if (this.videoGlobal === null ||
- this.videoGlobal === undefined) {
+ if (isNullOrUndefined(this.videoGlobal)) {
console.log(`error element: ${this.videoGlobal}`);
return;
}
@@ -614,17 +610,18 @@ export class VideoScene implements OnInit {
// canvas.crossorigin="anonymous"
// convert it and send it to the server
let self = this;
-
+ /*
this.videoCanva.toBlob((blob) => {
- self.videoService.uploadCoverBlob(blob, this.idVideo);
+ self.MediaService.uploadCoverBlob(blob, this.idVideo);
}, 'image/jpeg', 0.95);
-
+ */
+ console.log("not implement upload as row data...");
/*
let tmpUrl = this.videoCanva.toDataURL('image/jpeg', 0.95);
fetch(tmpUrl)
.then(res => res.blob()) // Gets the response and returns it as a blob
.then(blob => {
- self.videoService.uploadCoverBlob(blob, this.idVideo);
+ self.MediaService.uploadCoverBlob(blob, this.idVideo);
});
*/
}
diff --git a/front/src/app/service/GenericDataService.ts b/front/src/app/service/GenericDataService.ts
new file mode 100644
index 0000000..d69ffb7
--- /dev/null
+++ b/front/src/app/service/GenericDataService.ts
@@ -0,0 +1,123 @@
+import { DataStore, DataTools, TypeCheck, isNullOrUndefined } from "@kangaroo-and-rabbit/kar-cw";
+import { SelectModel } from "@kangaroo-and-rabbit/kar-cw/utils/data-tools";
+
+export class GenericDataService {
+ protected dataStore: DataStore;
+
+ setStore(dataStore: DataStore) {
+ this.dataStore = dataStore;
+ }
+
+
+ gets(): Promise {
+ return this.dataStore.getData();
+ }
+
+ get(id: number): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ self.gets()
+ .then((response: TYPE[]) => {
+ let data = DataTools.get(response, id);
+ if (isNullOrUndefined(data)) {
+ reject('Data does not exist in the local BDD');
+ return;
+ }
+ resolve(data);
+ return;
+ }).catch((response) => {
+ reject(response);
+ });
+ });
+ }
+
+ getAll(ids: number[]): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ self.gets()
+ .then((response: TYPE[]) => {
+ let data = DataTools.getsWhere(response,
+ [
+ {
+ check: TypeCheck.EQUAL,
+ key: 'id',
+ value: ids,
+ },
+ ]);
+ resolve(data);
+ return;
+ }).catch((response) => {
+ reject(response);
+ });
+ });
+ }
+
+ getFilter(filter: (subData: any) => boolean): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ self.gets()
+ .then((data: TYPE[]) => {
+ if (isNullOrUndefined(data)) {
+ reject('Data does not exist in the local BDD');
+ return;
+ }
+ let out: TYPE[] = [];
+ for (const elem of data) {
+ if (filter(elem)) {
+ out.push(elem);
+ }
+ }
+ resolve(out);
+ return;
+ }).catch((response) => {
+ reject(response);
+ });
+ });
+ }
+
+ getLike(value: string): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ self.gets()
+ .then((response: TYPE[]) => {
+ let data = DataTools.getNameLike(response, value);
+ if (isNullOrUndefined(data) || data.length === 0) {
+ reject('Data does not exist in the local BDD');
+ return;
+ }
+ resolve(data);
+ return;
+ }).catch((response) => {
+ reject(response);
+ });
+ });
+ }
+
+ getOrder(): Promise {
+ return this.getsWhere(
+ [
+ {
+ check: TypeCheck.NOT_EQUAL,
+ key: 'id',
+ value: [undefined, null],
+ },
+ ],
+ ["name", "id"],
+ );
+ }
+
+ getsWhere(select: SelectModel[], orderByData?: string[]): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ self.gets()
+ .then((response: TYPE[]) => {
+ let data = DataTools.getsWhere(response, select, orderByData);
+ resolve(data);
+ }).catch((response) => {
+ console.log(`[E] ${self.constructor.name}: can not retrieve BDD values`);
+ reject(response);
+ });
+ });
+ }
+
+}
\ No newline at end of file
diff --git a/front/src/app/service/GenericInterfaceModelDB.ts b/front/src/app/service/GenericInterfaceModelDB.ts
deleted file mode 100644
index a79af24..0000000
--- a/front/src/app/service/GenericInterfaceModelDB.ts
+++ /dev/null
@@ -1,180 +0,0 @@
-import { isNodeData, NodeData } from "common/model";
-import { HttpWrapperService, BddService } from "common/service";
-import { DataInterface, isArrayOf, isNullOrUndefined, TypeCheck } from "common/utils";
-
-export class GenericInterfaceModelDB {
- constructor(
- protected serviceName: string,
- protected http: HttpWrapperService,
- protected bdd: BddService) {
- // nothing to do ...
- }
-
- gets(): Promise {
- let self = this;
- return new Promise((resolve, reject) => {
- self.bdd.get(self.serviceName)
- .then((response: DataInterface) => {
- let data = response.gets();
- if (isNullOrUndefined(data)) {
- reject('Data does not exist in the local BDD');
- return;
- }
- resolve(data);
- return;
- }).catch((response) => {
- reject(response);
- });
- });
- }
-
- getLike(nameArtist: string): any {
- let self = this;
- return new Promise((resolve, reject) => {
- self.bdd.get(self.serviceName)
- .then((response: DataInterface) => {
- let data = response.getNameLike(nameArtist);
- if (data === null || data === undefined || data.length === 0) {
- reject('Data does not exist in the local BDD');
- return;
- }
- resolve(data);
- return;
- }).catch((response) => {
- reject(response);
- });
- });
- }
- getOrder(): Promise {
- let self = this;
- return new Promise((resolve, reject) => {
- self.bdd.get(self.serviceName)
- .then((response: DataInterface) => {
- let data = response.getsWhere([
- {
- check: TypeCheck.NOT_EQUAL,
- key: 'id',
- value: [undefined, null],
- },
- ],
- ['name', 'id']);
- //data = response.gets();
- if (isArrayOf(data, isNodeData)) {
- resolve(data);
- }
- reject("The model is wrong ...");
- }).catch((response) => {
- console.log(`[E] ${self.constructor.name}: can not retrive BDD values`);
- reject(response);
- });
- });
- }
- get(id: number): Promise {
- let self = this;
- return new Promise((resolve, reject) => {
- self.bdd.get(self.serviceName)
- .then((response: DataInterface) => {
- let data = response.get(id);
- if (isNullOrUndefined(data)) {
- reject('Data does not exist in the local BDD');
- return;
- }
- resolve(data);
- return;
- }).catch((response) => {
- reject(response);
- });
- });
- }
- getAll(ids: number[]): Promise {
- let self = this;
- return new Promise((resolve, reject) => {
- self.bdd.get(self.serviceName)
- .then((response: DataInterface) => {
- let data = response.getsWhere([
- {
- check: TypeCheck.EQUAL,
- key: 'id',
- value: ids,
- },
- ],
- ['name', 'id']);
- resolve(data);
- return;
- }).catch((response) => {
- reject(response);
- });
- });
- }
-
- getData(): Promise {
- let self = this;
- return new Promise((resolve, reject) => {
- self.bdd.get(self.serviceName)
- .then((response: DataInterface) => {
- let data = response.gets();
- resolve(data);
- }).catch((response) => {
- console.log(`[E] ${self.constructor.name}: can not retrive BDD values`);
- reject(response);
- });
- });
- }
-
- insert(data: any): any {
- let ret = this.http.postSpecific([this.serviceName], data);
- return this.bdd.addAfterPost(this.serviceName, ret);
-
- }
- patch(id: number, data: any): any {
- let ret = this.http.patchSpecific([this.serviceName, id], data);
- return this.bdd.setAfterPut(this.serviceName, id, ret);
- }
-
- delete(id: number): any {
- let ret = this.http.deleteSpecific([this.serviceName, id]);
- return this.bdd.delete(this.serviceName, id, ret);
- }
-
- deleteCover(nodeId: number, coverId: number) {
- let self = this;
- return new Promise((resolve, reject) => {
- self.http.getSpecific([this.serviceName, nodeId, 'rm_cover', coverId])
- .then((response) => {
- let data = response;
- if (data === null || data === undefined) {
- reject('error retrive data from server');
- return;
- }
- self.bdd.asyncSetInDB(self.serviceName, nodeId, data);
- resolve(data);
- }).catch((response) => {
- reject(response);
- });
- });
- }
- uploadCover(file: File,
- nodeId: number,
- progress: any = null) {
- const formData = new FormData();
- formData.append('fileName', file.name);
- formData.append('id', nodeId.toString());
- formData.append('file', file);
- let self = this;
- return new Promise((resolve, reject) => {
- self.http.uploadMultipart(`${this.serviceName}/${nodeId}/add_cover/`, formData, progress)
- .then((response) => {
- let data = response;
- if (data === null || data === undefined) {
- reject('error retrive data from server');
- return;
- }
- self.bdd.asyncSetInDB(self.serviceName, nodeId, data);
- resolve(data);
- }).catch((response) => {
- reject(response);
- });
- });
- }
-
-}
diff --git a/front/src/app/service/GenericInterfaceModelDBv2.ts b/front/src/app/service/GenericInterfaceModelDBv2.ts
deleted file mode 100644
index 77e3dd8..0000000
--- a/front/src/app/service/GenericInterfaceModelDBv2.ts
+++ /dev/null
@@ -1,96 +0,0 @@
-import { isNodeData, NodeData } from "common/model";
-import { HttpWrapperService, BddService } from "common/service";
-import { DataInterface, isArrayOf, isNullOrUndefined, TypeCheck } from "common/utils";
-
-export class GenericInterfaceModelDBv2 {
- constructor(
- protected serviceName: string,
- protected http: HttpWrapperService,
- protected bdd: BddService,
- protected checker: (subData: any) => subData is TYPE) {
- // nothing to do ...
- }
-
- gets(): Promise {
- let self = this;
- return new Promise((resolve, reject) => {
- self.bdd.get(self.serviceName)
- .then((response: DataInterface) => {
- let data = response.gets();
- if (isNullOrUndefined(data)) {
- reject('Data does not exist in the local BDD');
- return;
- }
- if (isArrayOf(data, this.checker)) {
- resolve(data);
- } else {
- reject("The data is not an array of the correct type ...");
- }
- return;
- }).catch((response) => {
- reject(response);
- });
- });
- }
- get(id: number): Promise {
- let self = this;
- return new Promise((resolve, reject) => {
- self.bdd.get(self.serviceName)
- .then((response: DataInterface) => {
- let data = response.get(id);
- if (isNullOrUndefined(data)) {
- reject('Data does not exist in the local BDD');
- return;
- }
- if (this.checker(data)) {
- resolve(data);
- } else {
- reject("The data is not an array of the correct type ...");
- }
- return;
- }).catch((response) => {
- reject(response);
- });
- });
- }
-
- getFilter(filter: (subData: any) => boolean): Promise {
- let self = this;
- return new Promise((resolve, reject) => {
- self.bdd.get(self.serviceName)
- .then((response: DataInterface) => {
- let data = response.gets();
- if (isNullOrUndefined(data)) {
- reject('Data does not exist in the local BDD');
- return;
- }
- let out = [];
- for (const elem of data) {
- if (filter(elem)) {
- out.push(elem);
- }
- }
- resolve(out as TYPE[]);
- return;
- }).catch((response) => {
- reject(response);
- });
- });
- }
-
- insert(data: object): TYPE {
- let ret = this.http.postSpecific([this.serviceName], data);
- return this.bdd.addAfterPost(this.serviceName, ret) as TYPE;
-
- }
- patch(id: number, data: object): TYPE {
- let ret = this.http.patchSpecific([this.serviceName, id], data);
- return this.bdd.setAfterPut(this.serviceName, id, ret) as TYPE;
- }
-
- delete(id: number): TYPE {
- let ret = this.http.deleteSpecific([this.serviceName, id]);
- return this.bdd.delete(this.serviceName, id, ret) as TYPE;
- }
-
-}
diff --git a/front/src/app/service/advancement.ts b/front/src/app/service/advancement.ts
index bd701a7..497e088 100644
--- a/front/src/app/service/advancement.ts
+++ b/front/src/app/service/advancement.ts
@@ -6,16 +6,30 @@
import { Injectable } from '@angular/core';
-import { HttpWrapperService, BddService } from 'common/service';
-import { isUserMediaAdvancement, UserMediaAdvancement } from 'app/model/user-media-advancement';
-import { GenericInterfaceModelDBv2 } from './GenericInterfaceModelDBv2';
+import { GenericDataService } from './GenericDataService';
+import { environment } from 'environments/environment';
+import { RESTConfig } from 'app/back-api/rest-tools';
+import { UserMediaAdvancement, UserMediaAdvancementResource } from 'app/back-api';
+import { DataStore, SessionService } from '@kangaroo-and-rabbit/kar-cw';
@Injectable()
-export class AdvancementService extends GenericInterfaceModelDBv2 {
+export class AdvancementService extends GenericDataService {
- constructor(http: HttpWrapperService,
- bdd: BddService) {
- super('advancement', http, bdd, isUserMediaAdvancement);
+ getRestConfig(): RESTConfig {
+ return {
+ server: environment.server.karideo,
+ token: this.session.getToken()
+ }
+ }
+ private lambdaGets(): Promise {
+ return UserMediaAdvancementResource.gets({ restConfig: this.getRestConfig() });
+ }
+
+ constructor(private session: SessionService) {
+ super();
+ console.log('Start ArtistService');
+ const self = this;
+ this.setStore(new DataStore(() => self.lambdaGets()));
}
get(id: number): Promise {
return new Promise((resolve, reject) => {
@@ -28,10 +42,25 @@ export class AdvancementService extends GenericInterfaceModelDBv2 {
+ UserMediaAdvancementResource.patch({
+ restConfig: this.getRestConfig(),
+ params: {
+ id
+ },
+ data
+ }).then((value: UserMediaAdvancement) => {
+ self.dataStore.updateValue(value);
+ resolve(value);
+ }).catch((error) => {
+ reject(error);
+ });
});
}
diff --git a/front/src/app/service/ariane.ts b/front/src/app/service/ariane.ts
index 7e56068..a48e5d3 100644
--- a/front/src/app/service/ariane.ts
+++ b/front/src/app/service/ariane.ts
@@ -11,10 +11,10 @@ import { NavigationEnd, NavigationError, NavigationStart, Router } from '@angula
import { TypeService } from './type';
import { SeriesService } from './series';
import { SeasonService } from './season';
-import { VideoService } from './video';
+import { MediaService } from './media';
import { environment } from 'environments/environment';
-import { NodeData } from 'common/model';
-import { isNullOrUndefined, isStringNullOrUndefined, isUndefined } from 'common/utils';
+import { isNullOrUndefined, isStringNullOrUndefined, isUndefined } from '@kangaroo-and-rabbit/kar-cw';
+import { Season } from 'app/back-api';
export class InputOrders {
public typeId: number = undefined;
@@ -27,74 +27,76 @@ export class InputOrders {
export class ArianeService {
public typeId: number = undefined;
public typeName: string = undefined;
- @Output() typeChange: EventEmitter = new EventEmitter();
+ @Output() typeChange: EventEmitter = new EventEmitter();
- public seriesId: number = undefined;
- public seriesName: string = undefined;
- @Output() seriesChange: EventEmitter = new EventEmitter();
+ public seriesId: number = undefined;
+ public seriesName: string = undefined;
+ @Output() seriesChange: EventEmitter = new EventEmitter();
- public seasonId: number = undefined;
- public seasonName: string = undefined;
- @Output() seasonChange: EventEmitter = new EventEmitter();
+ public seasonId: number = undefined;
+ public seasonName: string = undefined;
+ @Output() seasonChange: EventEmitter = new EventEmitter();
- public videoId: number = undefined;
- public videoName: string = undefined;
- @Output() videoChange: EventEmitter = new EventEmitter();
+ public videoId: number = undefined;
+ public videoName: string = undefined;
+ @Output() videoChange: EventEmitter = new EventEmitter();
public segment: string = "";
- @Output() segmentChange: EventEmitter = new EventEmitter();
+ @Output() segmentChange: EventEmitter = new EventEmitter();
- constructor(private router: Router,
- private typeService: TypeService,
- private seriesService: SeriesService,
- private seasonService: SeasonService,
- private videoService: VideoService) {
- let self = this;
- this.router.events.subscribe((event: any) => {
- if (event instanceof NavigationStart) {
- // Show progress spinner or progress bar
- //console.log('>>>>>>>>>>>>>> Route change detected');
- }
+ constructor(
+ private router: Router,
+ private MediaService: MediaService,
+ private seasonService: SeasonService,
+ private seriesService: SeriesService,
+ private typeService: TypeService,
+ ) {
+ let self = this;
+ this.router.events.subscribe((event: any) => {
+ if (event instanceof NavigationStart) {
+ // Show progress spinner or progress bar
+ //console.log('>>>>>>>>>>>>>> Route change detected');
+ }
- if (event instanceof NavigationEnd) {
- // Hide progress spinner or progress bar
- //this.currentRoute = event.url;
- //console.log(`>>>>>>>>>>>> ${event}`);
- self.updateProperties();
- }
+ if (event instanceof NavigationEnd) {
+ // Hide progress spinner or progress bar
+ //this.currentRoute = event.url;
+ //console.log(`>>>>>>>>>>>> ${event}`);
+ self.updateProperties();
+ }
- if (event instanceof NavigationError) {
- // Hide progress spinner or progress bar
+ if (event instanceof NavigationError) {
+ // Hide progress spinner or progress bar
- // Present error to user
- //console.log(`<<<<<<<<<<<<< ${event.error}`);
- }
-
- });
- }
- updateParams(params) {
- console.log(`sparams ${ params}`);
- console.log(`sparams['typeId'] ${ params.typeId}`);
- if(params.typeId) {
- this.setType(params.typeId);
- } else {
- this.setType(undefined);
- }
- }
- getCurrrentSegment(): string|undefined {
+ // Present error to user
+ //console.log(`<<<<<<<<<<<<< ${event.error}`);
+ }
+
+ });
+ }
+ updateParams(params) {
+ console.log(`sparams ${params}`);
+ console.log(`sparams['typeId'] ${params.typeId}`);
+ if (params.typeId) {
+ this.setType(params.typeId);
+ } else {
+ this.setType(undefined);
+ }
+ }
+ getCurrrentSegment(): string | undefined {
return this.segment;
}
- getIsParam(params: any, name: string): undefined|number {
- let valueStr = params.get(name);
- if(isNullOrUndefined(valueStr) || isStringNullOrUndefined(valueStr)) {
- return undefined;
- }
- return parseInt(valueStr, 10);
+ getIsParam(params: any, name: string): undefined | number {
+ let valueStr = params.get(name);
+ if (isNullOrUndefined(valueStr) || isStringNullOrUndefined(valueStr)) {
+ return undefined;
+ }
+ return parseInt(valueStr, 10);
}
- updateProperties() {
+ updateProperties() {
let elem = this.router.routerState.root;
while (!isNullOrUndefined(elem.firstChild)) {
elem = elem.firstChild;
@@ -121,231 +123,231 @@ export class ArianeService {
- let typeId = this.getIsParam(params, 'typeId');
- let seriesId = this.getIsParam(params, 'seriesId');
- let seasonId = this.getIsParam(params, 'seasonId');
- let videoId = this.getIsParam(params, 'videoId');
+ let typeId = this.getIsParam(params, 'typeId');
+ let seriesId = this.getIsParam(params, 'seriesId');
+ let seasonId = this.getIsParam(params, 'seasonId');
+ let videoId = this.getIsParam(params, 'videoId');
- this.setType(typeId);
- this.setSeries(seriesId);
- this.setSeason(seasonId);
- this.setVideo(videoId);
- }
- reset():void {
- this.typeId = undefined;
- this.typeName = undefined;
- this.typeChange.emit(this.typeId);
- this.seriesId = undefined;
- this.seriesName = undefined;
- this.seriesChange.emit(this.seriesId);
- this.seasonId = undefined;
- this.seasonName = undefined;
- this.seasonChange.emit(this.seasonId);
- this.videoId = undefined;
- this.videoName = undefined;
- this.videoChange.emit(this.videoId);
- }
+ this.setType(typeId);
+ this.setSeries(seriesId);
+ this.setSeason(seasonId);
+ this.setVideo(videoId);
+ }
+ reset(): void {
+ this.typeId = undefined;
+ this.typeName = undefined;
+ this.typeChange.emit(this.typeId);
+ this.seriesId = undefined;
+ this.seriesName = undefined;
+ this.seriesChange.emit(this.seriesId);
+ this.seasonId = undefined;
+ this.seasonName = undefined;
+ this.seasonChange.emit(this.seasonId);
+ this.videoId = undefined;
+ this.videoName = undefined;
+ this.videoChange.emit(this.videoId);
+ }
- /*
- getCurrentRoute():InputOrders {
- let out = new InputOrders()
- out.typeId = parseInt(this.route.snapshot.paramMap.get('typeId'));
- if (out.typeId === 0){
- out.typeId = undefined;
- }
- out.seriesId = parseInt(this.route.snapshot.paramMap.get('seriesId'));
- if (out.seriesId === 0){
- out.seriesId = undefined;
- }
- out.seasonId = parseInt(this.route.snapshot.paramMap.get('seasonId'));
- if (out.seasonId === 0){
- out.seasonId = undefined;
- }
- out.videoId = parseInt(this.route.snapshot.paramMap.get('videoId'));
- if (out.videoId === 0){
- out.videoId = undefined;
- }
- return out;
- }
+ /*
+ getCurrentRoute():InputOrders {
+ let out = new InputOrders()
+ out.typeId = parseInt(this.route.snapshot.paramMap.get('typeId'));
+ if (out.typeId === 0){
+ out.typeId = undefined;
+ }
+ out.seriesId = parseInt(this.route.snapshot.paramMap.get('seriesId'));
+ if (out.seriesId === 0){
+ out.seriesId = undefined;
+ }
+ out.seasonId = parseInt(this.route.snapshot.paramMap.get('seasonId'));
+ if (out.seasonId === 0){
+ out.seasonId = undefined;
+ }
+ out.videoId = parseInt(this.route.snapshot.paramMap.get('videoId'));
+ if (out.videoId === 0){
+ out.videoId = undefined;
+ }
+ return out;
+ }
- routeTo(data:InputOrders, destination:string = null) {
- routeTo = ""
- //if (
- this.router.navigate(['/type/' + this.typeId + '/series/' + this.idSeries + '/season/' + IdSelected ]);
- }
- */
+ routeTo(data:InputOrders, destination:string = null) {
+ routeTo = ""
+ //if (
+ this.router.navigate(['/type/' + this.typeId + '/series/' + this.idSeries + '/season/' + IdSelected ]);
+ }
+ */
- setType(id:number):void {
- if(this.typeId === id) {
- return;
- }
- this.typeId = id;
- this.typeName = '??--??';
- if(isUndefined(this.typeId)) {
- this.typeChange.emit(this.typeId);
- return;
- }
- let self = this;
- this.typeService.get(id)
- .then((response) => {
- self.typeName = response.name;
- self.typeChange.emit(self.typeId);
- }).catch((response) => {
- self.typeChange.emit(self.typeId);
- });
- }
- getTypeId():number|undefined {
- return this.typeId;
- }
- getTypeName():string|undefined {
- return this.typeName;
- }
+ setType(id: number): void {
+ if (this.typeId === id) {
+ return;
+ }
+ this.typeId = id;
+ this.typeName = '??--??';
+ if (isUndefined(this.typeId)) {
+ this.typeChange.emit(this.typeId);
+ return;
+ }
+ let self = this;
+ this.typeService.get(id)
+ .then((response) => {
+ self.typeName = response.name;
+ self.typeChange.emit(self.typeId);
+ }).catch((response) => {
+ self.typeChange.emit(self.typeId);
+ });
+ }
+ getTypeId(): number | undefined {
+ return this.typeId;
+ }
+ getTypeName(): string | undefined {
+ return this.typeName;
+ }
- setSeries(id:number|undefined):void {
- if(this.seriesId === id) {
- return;
- }
- this.seriesId = id;
- this.seriesName = '??--??';
- if(isUndefined(this.seriesId)) {
- this.seriesChange.emit(this.seriesId);
- return;
- }
- let self = this;
- this.seriesService.get(id)
- .then((response: NodeData) => {
- self.seriesName = response.name;
- self.seriesChange.emit(self.seriesId);
- }).catch((response) => {
- self.seriesChange.emit(self.seriesId);
- });
- }
- getSeriesId():number {
- return this.seriesId;
- }
- getSeriesName():string {
- return this.seriesName;
- }
+ setSeries(id: number | undefined): void {
+ if (this.seriesId === id) {
+ return;
+ }
+ this.seriesId = id;
+ this.seriesName = '??--??';
+ if (isUndefined(this.seriesId)) {
+ this.seriesChange.emit(this.seriesId);
+ return;
+ }
+ let self = this;
+ this.seriesService.get(id)
+ .then((response: Season) => {
+ self.seriesName = response.name;
+ self.seriesChange.emit(self.seriesId);
+ }).catch((response) => {
+ self.seriesChange.emit(self.seriesId);
+ });
+ }
+ getSeriesId(): number {
+ return this.seriesId;
+ }
+ getSeriesName(): string {
+ return this.seriesName;
+ }
- setSeason(id:number|undefined):void {
- if(this.seasonId === id) {
- return;
- }
- this.seasonId = id;
- this.seasonName = '??--??';
- if(isUndefined(this.seasonId)) {
- this.seasonChange.emit(this.seasonId);
- return;
- }
- let self = this;
- this.seasonService.get(id)
- .then((response: NodeData) => {
- // self.setSeries(response.seriesId);
- self.seasonName = response.name;
- self.seasonChange.emit(self.seasonId);
- }).catch((response) => {
- self.seasonChange.emit(self.seasonId);
- });
- }
- getSeasonId():number {
- return this.seasonId;
- }
- getSeasonName():string {
- return this.seasonName;
- }
+ setSeason(id: number | undefined): void {
+ if (this.seasonId === id) {
+ return;
+ }
+ this.seasonId = id;
+ this.seasonName = '??--??';
+ if (isUndefined(this.seasonId)) {
+ this.seasonChange.emit(this.seasonId);
+ return;
+ }
+ let self = this;
+ this.seasonService.get(id)
+ .then((response: Season) => {
+ // self.setSeries(response.seriesId);
+ self.seasonName = response.name;
+ self.seasonChange.emit(self.seasonId);
+ }).catch((response) => {
+ self.seasonChange.emit(self.seasonId);
+ });
+ }
+ getSeasonId(): number {
+ return this.seasonId;
+ }
+ getSeasonName(): string {
+ return this.seasonName;
+ }
- setVideo(id:number|undefined):void {
- if(this.videoId === id) {
- return;
- }
- this.videoId = id;
- this.videoName = '??--??';
- if(isUndefined(this.videoId)) {
- this.videoChange.emit(this.videoId);
- return;
- }
- let self = this;
- this.videoService.get(id)
- .then((response) => {
- // self.setSeason(response.seasonId);
- // self.setSeries(response.seriesId);
- self.videoName = response.name;
- self.videoChange.emit(self.videoId);
- }).catch((response) => {
- self.videoChange.emit(self.videoId);
- });
- }
- getVideoId():number {
- return this.videoId;
- }
- getVideoName():string {
- return this.videoName;
- }
+ setVideo(id: number | undefined): void {
+ if (this.videoId === id) {
+ return;
+ }
+ this.videoId = id;
+ this.videoName = '??--??';
+ if (isUndefined(this.videoId)) {
+ this.videoChange.emit(this.videoId);
+ return;
+ }
+ let self = this;
+ this.MediaService.get(id)
+ .then((response) => {
+ // self.setSeason(response.seasonId);
+ // self.setSeries(response.seriesId);
+ self.videoName = response.name;
+ self.videoChange.emit(self.videoId);
+ }).catch((response) => {
+ self.videoChange.emit(self.videoId);
+ });
+ }
+ getVideoId(): number {
+ return this.videoId;
+ }
+ getVideoName(): string {
+ return this.videoName;
+ }
- /**
- * Generic navigation on the browser.
- * @param destination - new destination url
- * @param typeId - type IF
- * @param seriesId - series real ID
- * @param seasonId - season ID
- * @param videoId - Video ID
- * @param newWindows - open in a new windows
- * @param replaceCurrentPage - consider the curent page is removed from history
- */
- genericNavigate(
- destination:string,
- typeId:number,
- seriesId:number,
- seasonId:number,
- videoId:number,
- newWindows:boolean = false,
- replaceCurrentPage: boolean = false): void {
- let addressOffset = `${ destination }/${ typeId }/${ seriesId }/${ seasonId }/${ videoId }`;
- if(newWindows === true) {
- window.open(`/${ addressOffset}`);
- } else {
- this.router.navigate([ addressOffset ], { replaceUrl: replaceCurrentPage });
- }
- }
+ /**
+ * Generic navigation on the browser.
+ * @param destination - new destination url
+ * @param typeId - type IF
+ * @param seriesId - series real ID
+ * @param seasonId - season ID
+ * @param videoId - Video ID
+ * @param newWindows - open in a new windows
+ * @param replaceCurrentPage - consider the curent page is removed from history
+ */
+ genericNavigate(
+ destination: string,
+ typeId: number,
+ seriesId: number,
+ seasonId: number,
+ videoId: number,
+ newWindows: boolean = false,
+ replaceCurrentPage: boolean = false): void {
+ let addressOffset = `${destination}/${typeId}/${seriesId}/${seasonId}/${videoId}`;
+ if (newWindows === true) {
+ window.open(`/${addressOffset}`);
+ } else {
+ this.router.navigate([addressOffset], { replaceUrl: replaceCurrentPage });
+ }
+ }
- navigateType(id:number, newWindows:boolean, ctrl:boolean = false):void {
- if(ctrl === true) {
- this.navigateTypeEdit(id, newWindows);
- return;
- }
- this.genericNavigate('type', id, null, null, null, newWindows);
- }
- navigateTypeEdit(id:number, newWindows:boolean):void {
- this.genericNavigate('type-edit', id, null, null, null, newWindows);
- }
- navigateSeries(id:number, newWindows:boolean, ctrl:boolean = false):void {
- if(ctrl === true) {
- this.navigateSeriesEdit(id, newWindows);
- return;
- }
- this.genericNavigate('series', this.typeId, id, null, null, newWindows);
- }
- navigateSeriesEdit(id:number, newWindows:boolean):void {
- this.genericNavigate('series-edit', this.typeId, id, null, null, newWindows);
- }
- navigateSeason(id:number, newWindows:boolean, ctrl:boolean = false, replaceCurrentPage: boolean = false):void {
- if(ctrl === true) {
- this.navigateSeasonEdit(id, newWindows);
- return;
- }
- this.genericNavigate('season', this.typeId, this.seriesId, id, null, newWindows, replaceCurrentPage);
- }
- navigateSeasonEdit(id:number, newWindows:boolean):void {
- this.genericNavigate('season-edit', this.typeId, this.seriesId, id, null, newWindows);
- }
- navigateVideo(id:number, newWindows:boolean, ctrl:boolean = false):void {
- if(ctrl === true) {
- this.navigateVideoEdit(id, newWindows);
- return;
- }
- this.genericNavigate('video', this.typeId, this.seriesId, this.seasonId, id, newWindows);
- }
- navigateVideoEdit(id:number, newWindows:boolean):void {
- this.genericNavigate('video-edit', this.typeId, this.seriesId, this.seasonId, id, newWindows);
- }
+ navigateType(id: number, newWindows: boolean, ctrl: boolean = false): void {
+ if (ctrl === true) {
+ this.navigateTypeEdit(id, newWindows);
+ return;
+ }
+ this.genericNavigate('type', id, null, null, null, newWindows);
+ }
+ navigateTypeEdit(id: number, newWindows: boolean): void {
+ this.genericNavigate('type-edit', id, null, null, null, newWindows);
+ }
+ navigateSeries(id: number, newWindows: boolean, ctrl: boolean = false): void {
+ if (ctrl === true) {
+ this.navigateSeriesEdit(id, newWindows);
+ return;
+ }
+ this.genericNavigate('series', this.typeId, id, null, null, newWindows);
+ }
+ navigateSeriesEdit(id: number, newWindows: boolean): void {
+ this.genericNavigate('series-edit', this.typeId, id, null, null, newWindows);
+ }
+ navigateSeason(id: number, newWindows: boolean, ctrl: boolean = false, replaceCurrentPage: boolean = false): void {
+ if (ctrl === true) {
+ this.navigateSeasonEdit(id, newWindows);
+ return;
+ }
+ this.genericNavigate('season', this.typeId, this.seriesId, id, null, newWindows, replaceCurrentPage);
+ }
+ navigateSeasonEdit(id: number, newWindows: boolean): void {
+ this.genericNavigate('season-edit', this.typeId, this.seriesId, id, null, newWindows);
+ }
+ navigateVideo(id: number, newWindows: boolean, ctrl: boolean = false): void {
+ if (ctrl === true) {
+ this.navigateVideoEdit(id, newWindows);
+ return;
+ }
+ this.genericNavigate('video', this.typeId, this.seriesId, this.seasonId, id, newWindows);
+ }
+ navigateVideoEdit(id: number, newWindows: boolean): void {
+ this.genericNavigate('video-edit', this.typeId, this.seriesId, this.seasonId, id, newWindows);
+ }
}
diff --git a/front/src/app/service/data.ts b/front/src/app/service/data.ts
index 56fe496..2976af3 100644
--- a/front/src/app/service/data.ts
+++ b/front/src/app/service/data.ts
@@ -5,97 +5,112 @@
*/
import { Injectable } from '@angular/core';
-import { isArrayOf, isNumberFinite } from 'common/utils';
-
-import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from '../../common/service/http-wrapper';
+import { SessionService, isArrayOf, isNullOrUndefined, isString } from '@kangaroo-and-rabbit/kar-cw';
+import { UUID } from 'app/back-api';
+import { RESTConfig, RESTUrl } from 'app/back-api/rest-tools';
+import { environment } from 'environments/environment';
@Injectable()
export class DataService {
- // 0: Not hide password; 1 hide password;
- private serviceName:string = 'data';
- constructor(private http: HttpWrapperService) {
+ getRestConfig(): RESTConfig {
+ return {
+ server: environment.server.karideo,
+ token: this.session.getToken()
+ }
+ }
+
+ constructor(private session: SessionService) {
console.log('Start DataService');
}
- getData():any {
- return this.http.getSpecific(this.serviceName);
- }
-
- get(_id:number):any {
- return this.http.getSpecific([this.serviceName, _id]);
- }
-
- uploadFile(_form:FormData, _progress:any = null) {
- // return this.http.uploadFileMultipart(this.serviceName, null, _file);
- return this.http.uploadMultipart(`${this.serviceName }/upload/`, _form, _progress);
- }
-
- getImage(_id:number) : Promise {
- return this.http.requestImage({
- endPoint: this.serviceName,
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.IMAGE,
- contentType: HTTPMimeType.JSON,
- });
- }
- getImageThumbnail(_id:number) : Promise {
- return this.http.requestImage({
- endPoint: this.serviceName + "/thumbnail/" + _id,
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.ALL,//IMAGE,
- contentType: HTTPMimeType.JSON,
- });
- }
/**
- * Retreive the Cover URL of a specific data id
+ * Retrieve the Cover URL of a specific data id
* @param coverId Id of te cover
* @returns the url of the cover
*/
- getCoverUrl(coverId: number): string {
- return this.http.createRESTCall2({
- api: `data/${coverId}`,
- addURLToken: true,
+ getUrl(dataId: UUID, optionalName?: string): string {
+ if (isNullOrUndefined(optionalName)) {
+ const url = RESTUrl({
+ restModel: {
+ endPoint: "data/{dataId}",
+ tokenInUrl: true,
+ },
+ restConfig: this.getRestConfig(),
+ params: {
+ dataId
+ }
+ });
+ console.log(`get URL = ${url}`);
+ if (environment?.replaceDataToRealServer === true) {
+ return url.replace("http://localhost:18080", "https://atria-soft.org");
+ }
+ return url;
+ }
+ const url = RESTUrl({
+ restModel: {
+ endPoint: "data/{dataId}/{optionalName}",
+ tokenInUrl: true,
+ },
+ restConfig: this.getRestConfig(),
+ params: {
+ dataId,
+ optionalName
+ }
});
+ if (environment?.replaceDataToRealServer === true) {
+ return url.replace("http://localhost:18080", "https://atria-soft.org");
+ }
+ return url;
}
/**
- * Retreive the list Cover URL of a specific data id
+ * Retrieve the list Cover URL of a specific data id
* @param coverId Id of te cover
* @returns the url of the cover
*/
- getCoverListUrl(coverIds?: number[]): string[] | undefined {
- if(!isArrayOf(coverIds, isNumberFinite) || coverIds.length === 0) {
+ getListUrl(dataIds?: UUID[]): string[] | undefined {
+ if (!isArrayOf(dataIds, isString) || dataIds.length === 0) {
return undefined;
}
- let covers = [] as string[];
- for(let iii = 0; iii < coverIds.length; iii++) {
- covers.push(this.getCoverUrl(coverIds[iii]));
+ let covers: string[] = [];
+ for (let iii = 0; iii < dataIds.length; iii++) {
+ covers.push(this.getUrl(dataIds[iii]));
}
return covers;
}
/**
- * Retreive the thumbnail cover URL of a specific data id
+ * Retrieve the thumbnail cover URL of a specific data id
* @param coverId Id of te cover
* @returns the url of the cover
*/
- getCoverThumbnailUrl(coverId: number): string {
- return this.http.createRESTCall2({
- api: `data/thumbnail/${coverId}`,
- addURLToken: true,
+ getThumbnailUrl(coverId: UUID): string {
+ const url = RESTUrl({
+ restModel: {
+ endPoint: "data/thumbnail/{coverId}",
+ tokenInUrl: true,
+ },
+ restConfig: this.getRestConfig(),
+ params: {
+ coverId
+ }
});
+ if (environment?.replaceDataToRealServer === true) {
+ return url.replace("http://localhost:18080", "https://atria-soft.org");
+ }
+ return url;
}
/**
- * Retreive the list thumbnail cover URL of a specific data id
+ * Retrieve the list thumbnail cover URL of a specific data id
* @param coverId Id of te cover
* @returns the url of the cover
*/
- getCoverListThumbnailUrl(coverIds?: number[]): string[] | undefined {
- if(!isArrayOf(coverIds, isNumberFinite) || coverIds.length === 0) {
+ getListThumbnailUrl(dataIds?: UUID[]): string[] | undefined {
+ if (!isArrayOf(dataIds, isString) || dataIds.length === 0) {
return undefined;
}
- let covers = [] as string[];
- for(let iii = 0; iii < coverIds.length; iii++) {
- covers.push(this.getCoverThumbnailUrl(coverIds[iii]));
+ let covers: string[] = [];
+ for (let iii = 0; iii < dataIds.length; iii++) {
+ covers.push(this.getThumbnailUrl(dataIds[iii]));
}
return covers;
}
diff --git a/front/src/app/service/index.ts b/front/src/app/service/index.ts
index dc021e5..2aea358 100644
--- a/front/src/app/service/index.ts
+++ b/front/src/app/service/index.ts
@@ -4,18 +4,18 @@ import { DataService } from "./data";
import { SeasonService } from "./season";
import { SeriesService } from "./series";
import { TypeService } from "./type";
-import { VideoService } from "./video";
+import { MediaService } from "./media";
export {
- ArianeService,
DataService,
+ AdvancementService,
+ MediaService,
SeasonService,
SeriesService,
TypeService,
- VideoService,
- AdvancementService
+ ArianeService,
};
diff --git a/front/src/app/service/media.ts b/front/src/app/service/media.ts
new file mode 100644
index 0000000..f6f3367
--- /dev/null
+++ b/front/src/app/service/media.ts
@@ -0,0 +1,135 @@
+/** @file
+ * @author Edouard DUPIN
+ * @copyright 2018, Edouard DUPIN, all right reserved
+ * @license PROPRIETARY (see license file)
+ */
+
+import { Injectable } from '@angular/core';
+import { SessionService, DataStore } from '@kangaroo-and-rabbit/kar-cw';
+import { Media, MediaResource, UUID } from 'app/back-api';
+import { RESTConfig } from 'app/back-api/rest-tools';
+import { environment } from 'environments/environment';
+import { GenericDataService } from './GenericDataService';
+
+@Injectable()
+export class MediaService extends GenericDataService {
+ getRestConfig(): RESTConfig {
+ return {
+ server: environment.server.karideo,
+ token: this.session.getToken()
+ }
+ }
+ private lambdaGets(): Promise {
+ return MediaResource.gets({ restConfig: this.getRestConfig() });
+ }
+
+ constructor(private session: SessionService) {
+ super();
+ console.log('Start MediaService');
+ const self = this;
+ this.setStore(new DataStore(() => self.lambdaGets()));
+ }
+
+ uploadFile(file: File,
+ series?: string,
+ seriesId?: number,
+ season?: number,
+ episode?: number,
+ title?: string,
+ typeId?: number,
+ progress: any = null) {
+ const formData = {
+ fileName: file.name,
+ file,
+ seriesId: seriesId !== null ? seriesId.toString() : null,
+ series: series ?? null,
+ season: season !== null ? season.toString() : null,
+ episode: episode !== null ? episode.toString() : null,
+ title: title ?? null,
+ typeId: typeId !== null ? typeId.toString() : null,
+ universe: null,
+ };
+ return MediaResource.uploadFile({
+ restConfig: this.getRestConfig(),
+ data: formData,
+ //progress
+ });
+ }
+
+ patch(id: number, data: Media): Promise {
+ const self = this;
+ return new Promise((resolve, reject) => {
+ MediaResource.patch({
+ restConfig: this.getRestConfig(),
+ params: {
+ id
+ },
+ data
+ }).then((value: Media) => {
+ self.dataStore.updateValue(value);
+ resolve(value);
+ }).catch((error) => {
+ reject(error);
+ });
+ });
+ }
+
+ delete(id: number): Promise {
+ const self = this;
+ return new Promise((resolve, reject) => {
+ MediaResource.remove({
+ restConfig: this.getRestConfig(),
+ params: {
+ id
+ }
+ }).then(() => {
+ self.dataStore.delete(id);
+ resolve();
+ }).catch((error) => {
+ reject(error);
+ });
+ });
+ }
+
+ deleteCover(id: number, coverId: UUID): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ MediaResource.removeCover({
+ restConfig: this.getRestConfig(),
+ params: {
+ id,
+ coverId
+ }
+ }).then((value) => {
+ self.dataStore.updateValue(value);
+ resolve(value);
+ }).catch((error) => {
+ reject(error);
+ });
+ });
+ }
+ uploadCover(id: number,
+ file: File,
+ progress: any = null): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ MediaResource.uploadCover({
+ restConfig: this.getRestConfig(),
+ params: {
+ id,
+ },
+ data: {
+ file,
+ fileName: file.name
+ },
+ //progress
+ }).then((value) => {
+ self.dataStore.updateValue(value);
+ resolve(value);
+ }).catch((error) => {
+ reject(error);
+ });
+ });
+ }
+}
+
diff --git a/front/src/app/service/season.ts b/front/src/app/service/season.ts
index 17a9adc..33695bd 100644
--- a/front/src/app/service/season.ts
+++ b/front/src/app/service/season.ts
@@ -5,67 +5,161 @@
*/
import { Injectable } from '@angular/core';
-import { NodeData } from 'common/model';
+import { DataStore, SessionService, TypeCheck } from '@kangaroo-and-rabbit/kar-cw';
+import { Media, Season, SeasonResource, UUID } from 'app/back-api';
+import { RESTConfig } from 'app/back-api/rest-tools';
+import { environment } from 'environments/environment';
+import { GenericDataService } from './GenericDataService';
+import { MediaService } from './media';
-import { HttpWrapperService, BddService } from 'common/service';
-import { DataInterface, TypeCheck } from 'common/utils';
-import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
@Injectable()
-export class SeasonService extends GenericInterfaceModelDB {
-
- constructor(http: HttpWrapperService,
- bdd: BddService) {
- super('season', http, bdd);
+export class SeasonService extends GenericDataService {
+
+
+ getRestConfig(): RESTConfig {
+ return {
+ server: environment.server.karusic,
+ token: this.session.getToken()
+ }
+ }
+ private lambdaGets(): Promise {
+ return SeasonResource.gets({ restConfig: this.getRestConfig() });
}
+ constructor(
+ private session: SessionService,
+ private MediaService: MediaService,
+ ) {
+ super();
+ console.log('Start SeasonService');
+ const self = this;
+ this.setStore(new DataStore(() => self.lambdaGets()));
+ }
/**
* Get all the video for a specific season
* @param id - Id of the season.
* @returns a promise on the list of video elements
*/
- getVideo(id:number): Promise {
+ getVideo(id: number): Promise {
let self = this;
return new Promise((resolve, reject) => {
- self.bdd.get('video')
- .then((response: DataInterface) => {
- let data = response.getsWhere([
- {
- check: TypeCheck.EQUAL,
- key: 'seasonId',
- value: id,
- },
- ],
- [ 'episode', 'name' ]);
+ self.MediaService.getsWhere(
+ [
+ {
+ check: TypeCheck.EQUAL,
+ key: 'seasonId',
+ value: id,
+ },
+ ],
+ ['episode', 'name'])
+ .then((data: Media[]) => {
resolve(data);
- }).catch((response) => {
+ })
+ .catch((response) => {
reject(response);
});
});
}
/**
- * Get the number of video in this saison ID
+ * Get the number of video in this season ID
* @param id - Id of the season.
- * @returns The number of element present in this saison
+ * @returns The number of element present in this season
*/
- countVideo(id:number): Promise {
+ countVideo(id: number): Promise {
let self = this;
return new Promise((resolve, reject) => {
- self.bdd.get('video')
- .then((response: DataInterface) => {
- let data = response.getsWhere([
- {
- check: TypeCheck.EQUAL,
- key: 'seasonId',
- value: id,
- },
- ]);
+ self.MediaService.getsWhere([
+ {
+ check: TypeCheck.EQUAL,
+ key: 'seasonId',
+ value: id,
+ },
+ ])
+ .then((data: Media[]) => {
resolve(data.length);
- }).catch((response) => {
+ })
+ .catch((response) => {
reject(response);
});
});
}
-}
+
+ patch(id: number, data: Season): Promise {
+ const self = this;
+ return new Promise((resolve, reject) => {
+ SeasonResource.patch({
+ restConfig: this.getRestConfig(),
+ params: {
+ id
+ },
+ data
+ }).then((value: Media) => {
+ self.dataStore.updateValue(value);
+ resolve(value);
+ }).catch((error) => {
+ reject(error);
+ });
+ });
+ }
+
+ delete(id: number): Promise {
+ const self = this;
+ return new Promise((resolve, reject) => {
+ SeasonResource.remove({
+ restConfig: this.getRestConfig(),
+ params: {
+ id
+ }
+ }).then(() => {
+ self.dataStore.delete(id);
+ resolve();
+ }).catch((error) => {
+ reject(error);
+ });
+ });
+ }
+
+ deleteCover(id: number, coverId: UUID): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ SeasonResource.removeCover({
+ restConfig: this.getRestConfig(),
+ params: {
+ id,
+ coverId
+ }
+ }).then((value) => {
+ self.dataStore.updateValue(value);
+ resolve(value);
+ }).catch((error) => {
+ reject(error);
+ });
+ });
+ }
+ uploadCover(id: number,
+ file: File,
+ progress: any = null): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ SeasonResource.uploadCover({
+ restConfig: this.getRestConfig(),
+ params: {
+ id,
+ },
+ data: {
+ file,
+ fileName: file.name
+ },
+ //progress
+ }).then((value) => {
+ self.dataStore.updateValue(value);
+ resolve(value);
+ }).catch((error) => {
+ reject(error);
+ });
+ });
+ }
+}
diff --git a/front/src/app/service/series.ts b/front/src/app/service/series.ts
index b6b8420..7e5eb59 100644
--- a/front/src/app/service/series.ts
+++ b/front/src/app/service/series.ts
@@ -6,43 +6,36 @@
import { Injectable } from '@angular/core';
-import { HttpWrapperService, BddService } from 'common/service';
-import { DataInterface, TypeCheck, isArrayOf } from 'common/utils';
-import { isNodeData, NodeData } from 'common/model';
-import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
+import { SessionService, DataStore, TypeCheck } from '@kangaroo-and-rabbit/kar-cw';
+import { Media, Season, Series, SeriesResource, UUID } from 'app/back-api';
+import { RESTConfig } from 'app/back-api/rest-tools';
+import { environment } from 'environments/environment';
+import { GenericDataService } from './GenericDataService';
+import { SeasonService, MediaService } from '.';
@Injectable()
-export class SeriesService extends GenericInterfaceModelDB {
-
- constructor(http: HttpWrapperService,
- bdd: BddService) {
- super('series', http, bdd);
+export class SeriesService extends GenericDataService {
+ getRestConfig(): RESTConfig {
+ return {
+ server: environment.server.karideo,
+ token: this.session.getToken()
+ }
+ }
+ private lambdaGets(): Promise {
+ return SeriesResource.gets({ restConfig: this.getRestConfig() });
}
- getOrder(): Promise {
- let self = this;
- return new Promise((resolve, reject) => {
- self.bdd.get(self.serviceName)
- .then((response: DataInterface) => {
- let data = response.getsWhere([
- {
- check: TypeCheck.NOT_EQUAL,
- key: 'id',
- value: [undefined, null],
- },
- ],
- [ 'name', 'id' ]);
- if (isArrayOf(data, isNodeData)) {
- resolve(data);
- }
- reject("The model is wrong ...");
- }).catch((response) => {
- console.log(`[E] ${ self.constructor.name }: can not retrive BDD values`);
- reject(response);
- });
- });
+ constructor(
+ private session: SessionService,
+ private MediaService: MediaService,
+ private seasonService: SeasonService,
+ ) {
+ super();
+ console.log('Start SeriesService');
+ const self = this;
+ this.setStore(new DataStore(() => self.lambdaGets()));
}
/**
@@ -50,23 +43,23 @@ export class SeriesService extends GenericInterfaceModelDB {
* @param id - Id of the series.
* @returns a promise on the list of video elements
*/
- getVideo(id:number): Promise {
+ getVideo(id: number): Promise {
let self = this;
return new Promise((resolve, reject) => {
- self.bdd.get('video')
- .then((response: DataInterface) => {
- let data = response.getsWhere([
- {
- check: TypeCheck.EQUAL,
- key: 'seriesId',
- value: id,
- }, {
- check: TypeCheck.EQUAL,
- key: 'seasonId',
- value: undefined,
- },
- ],
- [ 'episode', 'name' ]);
+ self.MediaService.getsWhere(
+ [
+ {
+ check: TypeCheck.EQUAL,
+ key: 'seriesId',
+ value: id,
+ }, {
+ check: TypeCheck.EQUAL,
+ key: 'seasonId',
+ value: undefined,
+ },
+ ],
+ ['episode', 'name'])
+ .then((data: Media[]) => {
resolve(data);
}).catch((response) => {
reject(response);
@@ -79,20 +72,21 @@ export class SeriesService extends GenericInterfaceModelDB {
* @param id - Id of the series.
* @returns The number of video present in this series
*/
- countVideo(id:number): Promise {
+ countVideo(id: number): Promise {
let self = this;
return new Promise((resolve, reject) => {
- self.bdd.get('video')
- .then((response:DataInterface) => {
- let data = response.getsWhere([
- {
- check: TypeCheck.EQUAL,
- key: 'seriesId',
- value: id,
- },
- ]);
+ self.MediaService.getsWhere(
+ [
+ {
+ check: TypeCheck.EQUAL,
+ key: 'seriesId',
+ value: id,
+ },
+ ])
+ .then((data: Media[]) => {
resolve(data.length);
- }).catch((response) => {
+ })
+ .catch((response) => {
reject(response);
});
});
@@ -103,42 +97,109 @@ export class SeriesService extends GenericInterfaceModelDB {
* @param id - ID of the series
* @returns the required List.
*/
- getSeason(id:number): Promise {
+ getSeason(id: number): Promise {
let self = this;
return new Promise((resolve, reject) => {
- self.bdd.get('season')
- .then((response:DataInterface) => {
- let data = response.getsWhere([
- {
- check: TypeCheck.EQUAL,
- key: 'parentId',
- value: id,
- },
- ], [ 'id' ]);
+ self.seasonService.getsWhere(
+ [
+ {
+ check: TypeCheck.EQUAL,
+ key: 'parentId',
+ value: id,
+ },
+ ], ['id'])
+ .then((data: Season[]) => {
resolve(data);
- return;
- }).catch((response) => {
+ })
+ .catch((response) => {
reject(response);
});
});
}
- getLike(nameSeries:string):any {
- let self = this;
+
+ patch(id: number, data: Series): Promise {
+ const self = this;
return new Promise((resolve, reject) => {
- self.bdd.get('series')
- .then((response:DataInterface) => {
- let data = response.getNameLike(nameSeries);
- if(data === null || data === undefined || data.length === 0) {
- reject('Data does not exist in the local BDD');
- return;
- }
- resolve(data);
- return;
- }).catch((response) => {
- reject(response);
+ SeriesResource.patch(
+ {
+ restConfig: this.getRestConfig(),
+ params: {
+ id
+ },
+ data
+ })
+ .then((value: Media) => {
+ self.dataStore.updateValue(value);
+ resolve(value);
+ })
+ .catch((error) => {
+ reject(error);
});
});
}
+
+ delete(id: number): Promise {
+ const self = this;
+ return new Promise((resolve, reject) => {
+ SeriesResource.remove(
+ {
+ restConfig: this.getRestConfig(),
+ params: {
+ id
+ }
+ })
+ .then(() => {
+ self.dataStore.delete(id);
+ resolve();
+ })
+ .catch((error) => {
+ reject(error);
+ });
+ });
+ }
+
+ deleteCover(id: number, coverId: UUID): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ SeriesResource.removeCover({
+ restConfig: this.getRestConfig(),
+ params: {
+ id,
+ coverId
+ }
+ }).then((value) => {
+ self.dataStore.updateValue(value);
+ resolve(value);
+ }).catch((error) => {
+ reject(error);
+ });
+ });
+ }
+ uploadCover(id: number,
+ file: File,
+ progress: any = null): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ SeriesResource.uploadCover({
+ restConfig: this.getRestConfig(),
+ params: {
+ id,
+ },
+ data: {
+ file,
+ fileName: file.name
+ },
+ //progress
+ }).then((value) => {
+ self.dataStore.updateValue(value);
+ resolve(value);
+ }).catch((error) => {
+ reject(error);
+ });
+ });
+ }
+
+
}
diff --git a/front/src/app/service/type.ts b/front/src/app/service/type.ts
index dda0228..f4c85c5 100644
--- a/front/src/app/service/type.ts
+++ b/front/src/app/service/type.ts
@@ -6,10 +6,13 @@
import { Injectable } from '@angular/core';
-import { HttpWrapperService, BddService } from 'common/service';
-import { DataInterface, isNullOrUndefined, TypeCheck } from 'common/utils';
-import { NodeData } from 'common/model';
-import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
+import { Media, Series, Type, TypeResource } from 'app/back-api';
+import { SessionService, DataStore, TypeCheck } from '@kangaroo-and-rabbit/kar-cw';
+import { RESTConfig } from 'app/back-api/rest-tools';
+import { environment } from 'environments/environment';
+import { GenericDataService } from './GenericDataService';
+import { MediaService } from './media';
+import { SeriesService } from './series';
export interface MessageLogIn {
id: number;
@@ -18,88 +21,65 @@ export interface MessageLogIn {
}
@Injectable()
-export class TypeService extends GenericInterfaceModelDB {
+export class TypeService extends GenericDataService {
+ getRestConfig(): RESTConfig {
+ return {
+ server: environment.server.karideo,
+ token: this.session.getToken()
+ }
+ }
+ private lambdaGets(): Promise {
+ return TypeResource.gets({ restConfig: this.getRestConfig() });
+ }
- constructor(http: HttpWrapperService,
- bdd: BddService) {
- super('type', http, bdd);
+ constructor(private session: SessionService,
+ private MediaService: MediaService,
+ private seriesService: SeriesService,
+ ) {
+ super();
+ console.log('Start TypeService');
+ const self = this;
+ this.setStore(new DataStore(() => self.lambdaGets()));
}
- get(id:number): Promise {
+ countVideo(id: number): Promise {
let self = this;
return new Promise((resolve, reject) => {
- self.bdd.get(self.serviceName)
- .then((response: DataInterface) => {
- let data = response.get(id);
- if(isNullOrUndefined(data)) {
- reject('Data does not exist in the local BDD');
- return;
- }
- resolve(data);
- }).catch((response) => {
- reject(response);
- });
- });
- }
-
- getData(): Promise {
- let self = this;
- return new Promise((resolve, reject) => {
- self.bdd.get(self.serviceName)
- .then((response: DataInterface) => {
- let data = response.gets();
- resolve(data);
- }).catch((response) => {
- console.log(`[E] ${ self.constructor.name }: can not retrive BDD values`);
- reject(response);
- });
- });
- }
-
-
-
-
-
-
- countVideo(id:number): Promise {
- let self = this;
- return new Promise((resolve, reject) => {
- self.bdd.get('video')
- .then((response: DataInterface) => {
- let data = response.getsWhere([
- {
- check: TypeCheck.EQUAL,
- key: 'typeId',
- value: id,
- } ] );
+ self.MediaService.getsWhere([
+ {
+ check: TypeCheck.EQUAL,
+ key: 'typeId',
+ value: id,
+ }])
+ .then((data: Media[]) => {
resolve(data.length);
- }).catch((response) => {
+ })
+ .catch((response) => {
reject(response);
});
});
}
- getSubVideo(id:number): Promise {
+ getSubVideo(id: number): Promise {
let self = this;
return new Promise((resolve, reject) => {
- self.bdd.get('video')
- .then((response: DataInterface) => {
- let data = response.getsWhere([
- {
- check: TypeCheck.EQUAL,
- key: 'typeId',
- value: id,
- }, {
- check: TypeCheck.EQUAL,
- key: 'seriesId',
- value: undefined,
- }, {
- check: TypeCheck.EQUAL,
- key: 'universeId',
- value: undefined,
- },
- ], [ 'name' ] );
+ self.MediaService.getsWhere([
+ {
+ check: TypeCheck.EQUAL,
+ key: 'typeId',
+ value: id,
+ }, {
+ check: TypeCheck.EQUAL,
+ key: 'seriesId',
+ value: undefined,
+ }, {
+ check: TypeCheck.EQUAL,
+ key: 'universeId',
+ value: undefined,
+ },
+ ], ['name'])
+ .then((data: Media[]) => {
resolve(data);
}).catch((response) => {
reject(response);
@@ -107,48 +87,49 @@ export class TypeService extends GenericInterfaceModelDB {
});
}
- getSubSeries(id:number): Promise {
+ getSubSeries(id: number): Promise {
let self = this;
return new Promise((resolve, reject) => {
- self.bdd.get('series')
- .then((response: DataInterface) => {
- let data = response.getsWhere([
- {
- check: TypeCheck.EQUAL,
- key: 'parentId',
- value: id,
- } ],
- [ 'name' ]);
+ resolve([]);
+ /*
+ self.seriesService.getsWhere([
+ {
+ check: TypeCheck.EQUAL,
+ key: 'parentId',
+ value: id,
+ }],
+ ['name'])
+ .then((data: Series[]) => {
resolve(data);
- }).catch((response) => {
+ })
+ .catch((response) => {
reject(response);
});
+ */
});
}
- getSubUniverse(id:number): Promise {
+ getSubUniverse(id: number): Promise {
let self = this;
return new Promise((resolve, reject) => {
- self.bdd.get('video')
- .then((response: DataInterface) => {
- let data = response.getsWhere([
- {
- check: TypeCheck.EQUAL,
- key: 'typeId',
- value: id,
- }, {
- check: TypeCheck.EQUAL,
- key: 'seriesId',
- value: [undefined, null],
- }, {
- check: TypeCheck.NOT_EQUAL,
- key: 'universeId',
- value: undefined,
- },
- ]);
- //, [ 'universId' ]);
+ self.MediaService.getsWhere(
+ [
+ {
+ check: TypeCheck.EQUAL,
+ key: 'typeId',
+ value: id,
+ }, {
+ check: TypeCheck.EQUAL,
+ key: 'seriesId',
+ value: [undefined, null],
+ }, {
+ check: TypeCheck.NOT_EQUAL,
+ key: 'universeId',
+ value: undefined,
+ },
+ ])
+ .then((data: Media[]) => {
resolve(data);
- return;
}).catch((response: any) => {
reject(response);
});
diff --git a/front/src/app/service/video.ts b/front/src/app/service/video.ts
deleted file mode 100644
index 4a565ab..0000000
--- a/front/src/app/service/video.ts
+++ /dev/null
@@ -1,115 +0,0 @@
-/** @file
- * @author Edouard DUPIN
- * @copyright 2018, Edouard DUPIN, all right reserved
- * @license PROPRIETARY (see license file)
- */
-
-import { Injectable } from '@angular/core';
-import { isMedia, Media } from 'app/model';
-import { NodeData } from 'common/model';
-
-import { HttpWrapperService, BddService } from 'common/service';
-import { isArrayOf } from 'common/utils';
-import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
-
-@Injectable()
-export class VideoService extends GenericInterfaceModelDB {
-
- constructor(http: HttpWrapperService,
- bdd: BddService) {
- super('video', http, bdd);
- }
- get(id:number): Promise {
- return new Promise((resolve, reject) => {
- super.get(id).then((data: NodeData) => {
- if (isMedia(data)) {
- resolve(data);
- return;
- }
- reject("model is wrong !!!")
- return
- }).catch((reason:any) => {
- reject(reason);
- });
- });
- }
-
- getData(): Promise {
- return new Promise((resolve, reject) => {
- super.getData().then((data: NodeData[]) => {
- if (isArrayOf(data, isMedia)) {
- resolve(data);
- return;
- }
- reject("model is wrong !!!")
- return
- }).catch((reason:any) => {
- reject(reason);
- });
- });
- }
-
- uploadFile(file:File,
- series?:string,
- seriesId?:number,
- season?:number,
- episode?:number,
- title?:string,
- typeId?:number,
- progress:any = null) {
- const formData = new FormData();
- formData.append('fileName', file.name);
- // set the file at hte begining it will permit to abort the transmission
- formData.append('file', file?? null);
- if(seriesId !== null) {
- formData.append('seriesId', seriesId.toString());
- } else {
- formData.append('seriesId', null);
- }
- formData.append('series', series?? null);
- if(season !== null) {
- formData.append('season', season.toString());
- } else {
- formData.append('season', null);
- }
-
- if(episode !== null) {
- formData.append('episode', episode.toString());
- } else {
- formData.append('episode', null);
- }
- formData.append('title', title?? null);
-
- if(typeId !== null) {
- formData.append('typeId', typeId.toString());
- } else {
- formData.append('typeId', null);
- }
- return this.http.uploadMultipart(`${this.serviceName }/upload/`, formData, progress);
- }
-
- uploadCoverBlob(blob:Blob,
- mediaId:number,
- progress:any = null) {
- const formData = new FormData();
- formData.append('fileName', 'take_screenshoot');
- formData.append('typeId', mediaId.toString());
- formData.append('file', blob);
- let self = this;
- return new Promise((resolve, reject) => {
- self.http.uploadMultipart(`${this.serviceName }/${ mediaId }/add_cover/`, formData, progress)
- .then((response) => {
- let data = response;
- if(data === null || data === undefined) {
- reject('error retrive data from server');
- return;
- }
- self.bdd.asyncSetInDB(self.serviceName, mediaId, data);
- resolve(data);
- }).catch((response) => {
- reject(response);
- });
- });
- }
-}
-
diff --git a/front/src/common b/front/src/common
deleted file mode 160000
index 147a955..0000000
--- a/front/src/common
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 147a955b195eb7c90e445d404f043d9a363087ca
diff --git a/front/src/environments/environment.prod.ts b/front/src/environments/environment.prod.ts
index 5029f37..cfafa19 100644
--- a/front/src/environments/environment.prod.ts
+++ b/front/src/environments/environment.prod.ts
@@ -3,7 +3,9 @@
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`.
-export const environment = {
+import { Environment } from "@kangaroo-and-rabbit/kar-cw";
+
+export const environment: Environment = {
production: true,
// URL of development API
applName: "karideo",
diff --git a/front/src/environments/environment.ts b/front/src/environments/environment.ts
index 2644d89..2f66446 100644
--- a/front/src/environments/environment.ts
+++ b/front/src/environments/environment.ts
@@ -3,9 +3,11 @@
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`.
+import { Environment } from "@kangaroo-and-rabbit/kar-cw";
+
const serverSSOAddress = 'http://atria-soft.org'
-const environment_back_prod = {
+const environment_back_prod: Environment = {
production: false,
// URL of development API
applName: "karideo",
@@ -21,7 +23,7 @@ const environment_back_prod = {
tokenStoredInPermanentStorage: false,
};
-const environment_local = {
+const environment_local: Environment = {
production: false,
// URL of development API
applName: "karideo",
@@ -37,7 +39,7 @@ const environment_local = {
tokenStoredInPermanentStorage: false,
};
-const environment_hybrid = {
+const environment_hybrid: Environment = {
production: false,
// URL of development API
applName: "karideo",
diff --git a/front/src/polyfills.ts b/front/src/polyfills.ts
deleted file mode 100644
index a461342..0000000
--- a/front/src/polyfills.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-/**
- * Required to support Web Animations `@angular/platform-browser/animations`.
- * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
- **/
-// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
-
-/**
- * By default, zone.js will patch all possible macroTask and DomEvents
- * user can disable parts of macroTask/DomEvents patch by setting following flags
- */
-
-// (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
-// (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
-// (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
-
-/*
- * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
- * with the following flag, it will bypass `zone.js` patch for IE/Edge
- */
-// (window as any).__Zone_enable_cross_context_check = true;
-
-/** *************************************************************************************************
- * Zone JS is required by default for Angular itself.
- */
-import 'zone.js/dist/zone'; // Included with Angular CLI.
-
-
-/** *************************************************************************************************
- * APPLICATION IMPORTS
- */
diff --git a/front/tsconfig.json b/front/tsconfig.json
index d13f202..68f0fd8 100644
--- a/front/tsconfig.json
+++ b/front/tsconfig.json
@@ -9,19 +9,23 @@
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
- "target": "es2018",
+ "target": "es2022",
"typeRoots": [
"node_modules/@types"
],
"lib": [
- "es2018",
+ "ES2022",
"dom"
],
- "module": "es2020",
+ "module": "es2022",
"baseUrl": "./src",
"paths": {
- "@app/*": ["./src/app/*"],
- "@common/*": ["./src/common/*"]
+ "@app/*": [
+ "./src/app/*"
+ ],
+ "@common/*": [
+ "./src/common/*"
+ ]
}
}
-}
\ No newline at end of file
+}