From d8086452c37f2175f8183aa5aed03237ab04ff41 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 13 Jun 2022 14:09:59 +0200 Subject: [PATCH] [DEV] may reworks: simplify, create common-part, many small clean --- front/src/app/app.component.ts | 2 +- front/src/app/app.module.ts | 3 +- .../app/component/data-image/data-image.ts | 4 +- .../element-season/element-season.html | 6 +- .../element-season/element-season.ts | 52 ++++------ .../element-series/element-series.html | 6 +- .../element-series/element-series.ts | 46 +++------ .../component/element-type/element-type.html | 2 +- .../component/element-type/element-type.ts | 29 +++--- .../element-video/element-video.html | 11 ++- .../component/element-video/element-video.ts | 99 +++++-------------- front/src/app/component/popin/popin.ts | 2 +- front/src/app/component/top-menu/top-menu.ts | 2 +- front/src/app/model/index.ts | 3 - front/src/app/model/media.ts | 4 +- .../src/app/popin/create-type/create-type.ts | 2 +- .../popin/delete-confirm/delete-confirm.ts | 2 +- .../popin/upload-progress/upload-progress.ts | 2 +- .../app/scene/error-viewer/error-viewer.ts | 2 +- front/src/app/scene/help/help.ts | 2 +- front/src/app/scene/home/home.ts | 4 +- .../src/app/scene/season-edit/season-edit.ts | 4 +- front/src/app/scene/season/season.html | 2 +- front/src/app/scene/season/season.ts | 2 +- .../src/app/scene/series-edit/series-edit.ts | 4 +- front/src/app/scene/series/series.html | 4 +- front/src/app/scene/series/series.ts | 4 +- front/src/app/scene/settings/settings.ts | 2 +- front/src/app/scene/sso/sso.ts | 2 +- front/src/app/scene/type/type.html | 6 +- front/src/app/scene/type/type.ts | 8 +- front/src/app/scene/universe/universe.html | 2 +- front/src/app/scene/universe/universe.ts | 4 +- front/src/app/scene/upload/upload.ts | 10 +- front/src/app/scene/video-edit/video-edit.ts | 6 +- front/src/app/scene/video/video.html | 11 ++- front/src/app/scene/video/video.less | 9 ++ front/src/app/scene/video/video.ts | 19 ++-- front/src/app/service/ariane.ts | 4 +- front/src/app/service/bdd.ts | 2 +- front/src/app/service/data.ts | 46 ++++++++- front/src/app/service/http-wrapper.ts | 4 +- front/src/app/service/index.ts | 4 - front/src/app/service/season.ts | 4 +- front/src/app/service/series.ts | 6 +- front/src/app/service/sso.ts | 2 +- front/src/app/service/type.ts | 6 +- front/src/app/service/user.ts | 4 +- front/src/app/service/video.ts | 5 +- front/src/common/model/index.ts | 6 ++ front/src/{app => common}/model/node.ts | 2 +- front/src/{app => common}/service/cookies.ts | 0 front/src/common/service/index.ts | 9 ++ .../{app => common}/service/local-storage.ts | 2 +- .../{app => common}/utils/dataInterface.ts | 2 +- front/src/{app => common}/utils/index.ts | 0 front/src/{app => common}/utils/validator.ts | 0 front/src/environments/environment.ts | 2 +- front/tsconfig.json | 6 +- 59 files changed, 236 insertions(+), 264 deletions(-) create mode 100644 front/src/common/model/index.ts rename front/src/{app => common}/model/node.ts (93%) rename front/src/{app => common}/service/cookies.ts (100%) create mode 100644 front/src/common/service/index.ts rename front/src/{app => common}/service/local-storage.ts (95%) rename front/src/{app => common}/utils/dataInterface.ts (98%) rename front/src/{app => common}/utils/index.ts (100%) rename front/src/{app => common}/utils/validator.ts (100%) diff --git a/front/src/app/app.component.ts b/front/src/app/app.component.ts index dfe55e7..57095eb 100644 --- a/front/src/app/app.component.ts +++ b/front/src/app/app.component.ts @@ -5,7 +5,7 @@ */ import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; +import { Router } from '@angular/router'; import { UserService, SessionService } from './service'; @Component({ diff --git a/front/src/app/app.module.ts b/front/src/app/app.module.ts index 4cf059e..f4d1c04 100644 --- a/front/src/app/app.module.ts +++ b/front/src/app/app.module.ts @@ -28,8 +28,9 @@ import { AppComponent } from './app.component'; import { ErrorComponent } from './error/error'; import { HomeScene, ErrorViewerScene, HelpScene, SsoScene, TypeScene, UniverseScene, SeriesScene, SeasonScene, VideoScene, SettingsScene, VideoEditScene, SeasonEditScene, SeriesEditScene, UploadScene } from './scene'; -import { PopInService, HttpWrapperService, SessionService, CookiesService, StorageService, UserService, SSOService, BddService, TypeService, +import { PopInService, HttpWrapperService, SessionService, UserService, SSOService, BddService, TypeService, DataService, UniverseService, SeriesService, SeasonService, VideoService, ArianeService } from './service'; +import { CookiesService, StorageService } from 'common/service'; @NgModule({ declarations: [ diff --git a/front/src/app/component/data-image/data-image.ts b/front/src/app/component/data-image/data-image.ts index ade78b1..fc82933 100644 --- a/front/src/app/component/data-image/data-image.ts +++ b/front/src/app/component/data-image/data-image.ts @@ -4,8 +4,8 @@ * @license PROPRIETARY (see license file) */ import { Component, OnInit, Input } from '@angular/core'; -import { ModelResponseHttp } from '../../service/http-wrapper'; -import { DataService } from '../../service/data'; +//import { ModelResponseHttp } from '@app/service/http-wrapper'; +import { DataService } from 'app/service/data'; @Component({ selector: 'data-image', diff --git a/front/src/app/component/element-season/element-season.html b/front/src/app/component/element-season/element-season.html index 34952f7..5adee20 100644 --- a/front/src/app/component/element-season/element-season.html +++ b/front/src/app/component/element-season/element-season.html @@ -1,10 +1,10 @@
-
+
- +
-
+
diff --git a/front/src/app/component/element-season/element-season.ts b/front/src/app/component/element-season/element-season.ts index aa1fd09..9977e38 100644 --- a/front/src/app/component/element-season/element-season.ts +++ b/front/src/app/component/element-season/element-season.ts @@ -5,7 +5,9 @@ */ import {Component, OnInit, Input } from '@angular/core'; -import { SeasonService, DataService } from '../../service'; +import { SeasonService, DataService } from 'app/service'; +import { NodeData } from 'common/model'; +import { isNullOrUndefined } from 'common/utils'; @Component({ selector: 'app-element-season', @@ -14,14 +16,12 @@ import { SeasonService, DataService } from '../../service'; }) export class ElementSeasonComponent implements OnInit { // input parameters - @Input() idSeason:number = -1; - - error:string = ''; - numberSeason:number = -1; - count:number = 0; - cover:string = ''; - covers:Array = []; - description:string = ''; + @Input() element:NodeData; + + numberSeason: number; + count: number; + covers: string[]; + description: string; constructor( private seasonService: SeasonService, @@ -29,34 +29,20 @@ export class ElementSeasonComponent implements OnInit { } ngOnInit() { + if (isNullOrUndefined(this.element)) { + this.numberSeason = undefined; + this.covers = undefined; + this.description = undefined; + } + this.numberSeason = this.element.id; + this.description = this.element.description; + this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers); let self = this; - console.log(`get season properties id: ${ this.idSeason}`); - this.seasonService.get(this.idSeason) - .then((response) => { - self.error = ''; - self.numberSeason = response.name; - self.description = response.description; - if(response.covers === undefined || response.covers === null || response.covers.length === 0) { - self.cover = null; - // self.covers = []; - } else { - self.cover = self.dataService.getCoverThumbnailUrl(response.covers[0]); - for(let iii = 0; iii < response.covers.length; iii++) { - self.covers.push(self.dataService.getCoverThumbnailUrl(response.covers[iii])); - } - } - }).catch((response) => { - self.error = 'Can not get the data'; - self.numberSeason = -1; - self.cover = null; - self.covers = []; - self.description = ''; - }); - this.seasonService.countVideo(this.idSeason) + this.seasonService.countVideo(this.element.id) .then((response) => { self.count = response; }).catch((response) => { self.count = null; }); } -} +} \ No newline at end of file diff --git a/front/src/app/component/element-series/element-series.html b/front/src/app/component/element-series/element-series.html index a565a9d..2a88afd 100644 --- a/front/src/app/component/element-series/element-series.html +++ b/front/src/app/component/element-series/element-series.html @@ -5,11 +5,11 @@
-
+
- +
-
+
diff --git a/front/src/app/component/element-series/element-series.ts b/front/src/app/component/element-series/element-series.ts index 8be09df..0727922 100644 --- a/front/src/app/component/element-series/element-series.ts +++ b/front/src/app/component/element-series/element-series.ts @@ -4,8 +4,10 @@ * @license PROPRIETARY (see license file) */ import { Component, OnInit, Input } from '@angular/core'; +import { NodeData } from 'common/model'; +import { isNullOrUndefined } from 'common/utils'; -import { SeriesService, DataService } from '../../service'; +import { SeriesService, DataService } from 'app/service'; @Component({ selector: 'app-element-series', @@ -14,17 +16,13 @@ import { SeriesService, DataService } from '../../service'; }) export class ElementSeriesComponent implements OnInit { // input parameters - @Input() idSeries:number = -1; - @Input() idType:number = -1; - - error:string = ''; + @Input() element:NodeData; + name:string = 'plouf'; description:string = ''; countvideo:number = null; - imageSource:string = null; - cover:string = ''; - covers:Array = []; + covers:string[]; constructor( private seriesService: SeriesService, @@ -32,29 +30,17 @@ export class ElementSeriesComponent implements OnInit { } ngOnInit() { - this.name = `ll ${ this.idType }+${ this.idSeries}`; + if (isNullOrUndefined(this.element)) { + this.name = '!!ERROR!!'; + this.description = undefined; + return; + } let self = this; - console.log(`get parameter id: ${ this.idType}`); - this.seriesService.get(this.idSeries) - .then((response) => { - self.error = ''; - self.name = response.name; - if(response.covers === undefined || response.covers === null || response.covers.length === 0) { - self.cover = null; - // self.covers = []; - } else { - self.cover = self.dataService.getCoverThumbnailUrl(response.covers[0]); - for(let iii = 0; iii < response.covers.length; iii++) { - self.covers.push(self.dataService.getCoverThumbnailUrl(response.covers[iii])); - } - } - }).catch((response) => { - self.error = 'Can not get the data'; - self.name = ''; - self.cover = null; - self.covers = []; - }); - this.seriesService.countVideo(this.idSeries) + self.name = this.element.name; + self.description = this.element.description; + self.covers = self.dataService.getCoverListThumbnailUrl(this.element.covers); + + this.seriesService.countVideo(this.element.id) .then((response) => { self.countvideo = response; }).catch((response) => { diff --git a/front/src/app/component/element-type/element-type.html b/front/src/app/component/element-type/element-type.html index f395770..bef78ec 100644 --- a/front/src/app/component/element-type/element-type.html +++ b/front/src/app/component/element-type/element-type.html @@ -6,7 +6,7 @@
- type image +
diff --git a/front/src/app/component/element-type/element-type.ts b/front/src/app/component/element-type/element-type.ts index 65ba278..6db6d46 100644 --- a/front/src/app/component/element-type/element-type.ts +++ b/front/src/app/component/element-type/element-type.ts @@ -4,10 +4,10 @@ * @license PROPRIETARY (see license file) */ import { Component, OnInit, Input } from '@angular/core'; -import { isArrayOf, isNumberFinite } from '../../utils'; +import { isArrayOf, isNullOrUndefined, isNumberFinite } from 'common/utils'; +import { NodeData } from 'common/model'; -import { TypeService, DataService } from '../../service'; -import { NodeData } from '../../model'; +import { TypeService, DataService } from 'app/service'; @Component({ selector: 'app-element-type', @@ -19,11 +19,9 @@ export class ElementTypeComponent implements OnInit { @Input() element:NodeData; public name: string = 'rr'; - public description: string = 'sdqdfqsd'; + public description: string; - public imageSource:string; // TODO: remove this ... public countvideo:number; - public countserie:number; public covers: string[]; @@ -33,22 +31,23 @@ export class ElementTypeComponent implements OnInit { } ngOnInit() { + if (isNullOrUndefined(this.element)) { + this.name = 'Not a media'; + this.description = undefined; + this.countvideo = undefined; + this.covers = undefined; + return; + } let self = this; console.log(" ??? Get element ! " + JSON.stringify(this.element)); self.name = this.element.name; self.description = this.element.description; - if(!isArrayOf(this.element.covers, isNumberFinite) || this.element.covers.length === 0) { - self.covers = undefined; - } else { - self.covers = []; - for(let iii = 0; iii < this.element.covers.length; iii++) { - self.covers.push(self.dataService.getCoverThumbnailUrl(this.element.covers[iii])); - } - } + self.covers = self.dataService.getCoverListThumbnailUrl(this.element.covers); + this.typeService.countVideo(this.element.id) .then((response: number) => { self.countvideo = response; - }).catch((response) => { + }).catch(() => { self.countvideo = 0; }); } diff --git a/front/src/app/component/element-video/element-video.html b/front/src/app/component/element-video/element-video.html index f4b01de..718c465 100644 --- a/front/src/app/component/element-video/element-video.html +++ b/front/src/app/component/element-video/element-video.html @@ -1,16 +1,19 @@
-
+
- +
-
+
-
+
{{episodeDisplay}} {{name}}
+
+ Error meda: {{element?.id}} +