[DEV] update the new data from karideo and basi c modification to start front

This commit is contained in:
Edouard DUPIN 2022-06-28 00:45:51 +02:00
parent 9f262679b9
commit 574197870e
103 changed files with 4611 additions and 5632 deletions

View File

@ -19,7 +19,7 @@ public class ConfigVariable {
}
public static String getFrontFolder() {
String out = System.getenv("ORG_KARIDEO_FRONT_FOLDER");
String out = System.getenv("ORG_KARUSIC_FRONT_FOLDER");
if (out == null) {
return "/application/karusic";
}
@ -28,7 +28,7 @@ public class ConfigVariable {
public static String getDBHost() {
String out = System.getenv("ORG_KARIDEO_DB_HOST");
String out = System.getenv("ORG_KARUSIC_DB_HOST");
if (out == null) {
return "localhost";
}
@ -36,7 +36,7 @@ public class ConfigVariable {
}
public static String getDBPort() {
String out = System.getenv("ORG_KARIDEO_DB_PORT");
String out = System.getenv("ORG_KARUSIC_DB_PORT");
if (out == null) {
return "17036";
}
@ -44,7 +44,7 @@ public class ConfigVariable {
}
public static String getDBLogin() {
String out = System.getenv("ORG_KARIDEO_DB_LOGIN");
String out = System.getenv("ORG_KARUSIC_DB_LOGIN");
if (out == null) {
return "root";
}
@ -68,9 +68,9 @@ public class ConfigVariable {
}
public static String getlocalAddress() {
String out = System.getenv("ORG_KARIDEO_ADDRESS");
String out = System.getenv("ORG_KARUSIC_ADDRESS");
if (out == null) {
return "http://0.0.0.0:18080/karusic/api/";
return "http://0.0.0.0:19080/karusic/api/";
}
return out;
}

4855
front/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,7 @@
"jquery": "^3.6.0",
"rxjs": "^7.5.4",
"tslib": "^2.3.1",
"videogular": "^2.2.1",
"videogular": "^1.4.4",
"zone.js": "^0.11.5"
},
"devDependencies": {
@ -45,7 +45,7 @@
"@types/node": "^17.0.21",
"@typescript-eslint/eslint-plugin": "^5.17.0",
"@typescript-eslint/parser": "^5.17.0",
"codelyzer": "^6.0.2",
"codelyzer": "^0.0.28",
"eslint": "^8.12.0",
"eslint-config-google": "^0.14.0",
"jasmine-core": "^4.0.1",

View File

@ -6,8 +6,10 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'; // CLI imports router
import { SsoScene } from 'common/scene';
import { HelpScene, HomeScene, SeasonEditScene, SeasonScene, SeriesEditScene, SeriesScene, SettingsScene, SsoScene, TypeScene, UniverseScene, UploadScene, VideoEditScene, VideoScene } from './scene';
import { HelpScene, HomeScene, AlbumEditScene, AlbumScene, ArtistEditScene, ArtistScene, SettingsScene, TypeScene, PlaylistScene, TrackEditScene, TrackScene } from './scene';
import { UploadScene } from './scene/upload/upload';
// import { HelpComponent } from './help/help.component';
// see https://angular.io/guide/router
@ -17,18 +19,18 @@ const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: 'home', component: HomeScene },
{ path: 'upload', component: UploadScene },
{ path: 'type/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: TypeScene },
{ path: 'gender/:genderId/:artistId/:albumId/:trackId', component: TypeScene },
{ path: 'universe/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: UniverseScene },
{ path: 'playlist/:playlistId', component: PlaylistScene },
{ path: 'series/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: SeriesScene },
{ path: 'series-edit/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: SeriesEditScene },
{ path: 'artist/:genderId/:artistId/:albumId/:trackId', component: ArtistScene },
{ path: 'artist-edit/:genderId/:artistId/:albumId/:trackId', component: ArtistEditScene },
{ path: 'season/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: SeasonScene },
{ path: 'season-edit/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: SeasonEditScene },
{ path: 'album/:genderId/:artistId/:albumId/:trackId', component: AlbumScene },
{ path: 'album-edit/:genderId/:artistId/:albumId/:trackId', component: AlbumEditScene },
{ path: 'video/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: VideoScene },
{ path: 'video-edit/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: VideoEditScene },
{ path: 'track/:genderId/:artistId/:albumId/:trackId', component: TrackScene },
{ path: 'track-edit/:genderId/:artistId/:albumId/:trackId', component: TrackEditScene },
{ path: 'sso/:data/:keepConnected/:token', component: SsoScene },
{ path: 'sso', component: SsoScene },

View File

@ -7,4 +7,10 @@
-->
<div class="main-content">
<router-outlet *ngIf="autoConnectedDone"></router-outlet>
<div class="generic-page" *ngIf="!isConnected">
<div class="fill-all colomn_mutiple">
<b style="color:red;">You Must be connected to access @Karusic...</b>
<div class="clear"></div>
</div>
</div>
</div>

View File

@ -5,8 +5,8 @@
*/
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { UserService, SessionService } from './service';
import { Router } from '@angular/router';
import { UserService, SessionService } from 'common/service';
@Component({
selector: 'app-root',
@ -37,7 +37,14 @@ export class AppComponent implements OnInit {
self.autoConnectedDone = true;
});
this.userService.checkAutoConnect().finally(() => {
this.userService.checkAutoConnect().then(() => {
console.log(` ==>>>>> Autoconnect THEN !!!`);
self.autoConnectedDone = true;
}).catch(() => {
console.log(` ==>>>>> Autoconnect CATCH !!!`);
self.autoConnectedDone = true;
}).finally(() => {
console.log(` ==>>>>> Autoconnect FINALLY !!!`);
self.autoConnectedDone = true;
});
}

View File

@ -11,25 +11,27 @@ import { HttpClientModule } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; // this is needed for dynamic selection of the select
import { AppRoutingModule } from './app-routing.module';
import { UploadFileComponent } from './component/upload-file/upload-file';
import { UploadFileComponent } from '../common/component/upload-file/upload-file';
import { TopMenuComponent } from './component/top-menu/top-menu';
import { ElementDataImageComponent } from './component/data-image/data-image';
import { ElementTypeComponent } from './component/element-type/element-type';
import { ElementSeriesComponent } from './component/element-series/element-series';
import { ElementSeasonComponent } from './component/element-season/element-season';
import { ElementVideoComponent } from './component/element-video/element-video';
import { PopInComponent } from './component/popin/popin';
import { PopInComponent } from '../common/component/popin/popin';
import { PopInCreateType } from './popin/create-type/create-type';
import { PopInUploadProgress } from './popin/upload-progress/upload-progress';
import { PopInDeleteConfirm } from './popin/delete-confirm/delete-confirm';
import { PopInUploadProgress } from '../common/popin/upload-progress/upload-progress';
import { PopInDeleteConfirm } from '../common/popin/delete-confirm/delete-confirm';
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,
DataService, UniverseService, SeriesService, SeasonService, VideoService, ArianeService } from './service';
import { ErrorComponent } from '../common/error/error';
import { HomeScene, HelpScene, TypeScene, PlaylistScene, ArtistScene, AlbumScene, TrackScene, SettingsScene,
TrackEditScene, AlbumEditScene, ArtistEditScene } from './scene';
import { GenderService, DataService, PlaylistService, ArtistService, AlbumService, TrackService, ArianeService } from './service';
import { BddService, CookiesService, HttpWrapperService, PopInService, SessionService, SSOService, StorageService, UserService } from 'common/service';
import { ErrorViewerScene, SsoScene } from 'common/scene';
import { UploadScene } from './scene/upload/upload';
import { ElementSeriesComponent } from './component/element-series/element-series';
import { ElementVideoComponent } from './component/element-video/element-video';
import { ElementSeasonComponent } from './component/element-season/element-season';
@NgModule({
declarations: [
@ -53,14 +55,14 @@ import { PopInService, HttpWrapperService, SessionService, CookiesService, Stora
HelpScene,
SsoScene,
TypeScene,
UniverseScene,
SeriesScene,
SeasonScene,
VideoScene,
PlaylistScene,
ArtistScene,
AlbumScene,
TrackScene,
SettingsScene,
VideoEditScene,
SeasonEditScene,
SeriesEditScene,
TrackEditScene,
AlbumEditScene,
ArtistEditScene,
UploadScene,
],
imports: [
@ -80,12 +82,12 @@ import { PopInService, HttpWrapperService, SessionService, CookiesService, Stora
UserService,
SSOService,
BddService,
TypeService,
GenderService,
DataService,
UniverseService,
SeriesService,
SeasonService,
VideoService,
PlaylistService,
ArtistService,
AlbumService,
TrackService,
ArianeService
],
exports: [

View File

@ -3,16 +3,15 @@
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Injectable, Component, OnInit, Input } from '@angular/core';
import { ModelResponseHttp } from '../../service/http-wrapper';
import { DataService } from '../../service/data';
import { Component, OnInit, Input } from '@angular/core';
//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' ]
})
@Injectable()
export class ElementDataImageComponent implements OnInit {
// input parameters
@Input() id:number = -1;

View File

@ -1,15 +1,15 @@
<div class="imgContainer-small">
<div *ngIf="cover">
<div *ngIf="covers">
<!--<data-image id="{{cover}}"></data-image>-->
<img src="{{cover}}"/>
<img src="{{covers[0]}}"/>
</div>
<div *ngIf="!cover" class="noImage">
<div *ngIf="!covers" class="noImage">
</div>
</div>
<div class="season-small">
Season {{numberSeason}}
<div class="album-small">
Album {{numberAlbum}}
</div>
<div class="description-small" *ngIf="count > 1">
{{count}} Episodes

View File

@ -3,60 +3,46 @@
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Injectable, Component, OnInit, Input } from '@angular/core';
import {Component, OnInit, Input } from '@angular/core';
import { SeasonService } from '../../service/season';
import { AlbumService, 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' ]
})
@Injectable()
export class ElementSeasonComponent implements OnInit {
// input parameters
@Input() idSeason:number = -1;
@Input() element:NodeData;
numberAlbum: number;
count: number;
covers: string[];
description: string;
error:string = '';
numberSeason:number = -1;
count:number = 0;
cover:string = '';
covers:Array<string> = [];
description:string = '';
constructor(private seasonService: SeasonService) {
constructor(
private albumService: AlbumService,
private dataService: DataService) {
}
ngOnInit() {
if (isNullOrUndefined(this.element)) {
this.numberAlbum = undefined;
this.covers = undefined;
this.description = undefined;
}
this.numberAlbum = 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 = response.covers[0];//self.seasonService.getCoverThumbnailUrl(response.covers[0]);
for(let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.seasonService.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.albumService.countTrack(this.element.id)
.then((response) => {
self.count = response;
}).catch((response) => {
self.count = null;
});
}
}
}

View File

@ -1,15 +1,15 @@
<div>
<div class="count-base">
<div class="count" *ngIf="countvideo">
{{countvideo}}
<div class="count" *ngIf="counttrack">
{{counttrack}}
</div>
</div>
<div class="imgContainer-small">
<div *ngIf="cover">
<div *ngIf="covers">
<!--<data-image id="{{cover}}"></data-image>-->
<img src="{{cover}}"/>
<img src="{{covers[0]}}"/>
</div>
<div *ngIf="!cover" class="noImage">
<div *ngIf="!covers" class="noImage">
</div>
</div>

View File

@ -3,62 +3,48 @@
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Injectable, Component, OnInit, Input } from '@angular/core';
import { Component, OnInit, Input } from '@angular/core';
import { NodeData } from 'common/model';
import { isNullOrUndefined } from 'common/utils';
import { SeriesService } from '../../service/series';
import { ArtistService, DataService } from 'app/service';
@Component({
selector: 'app-element-series',
templateUrl: './element-series.html',
styleUrls: [ './element-series.less' ]
selector: 'app-element-artist',
templateUrl: './element-artist.html',
styleUrls: [ './element-artist.less' ]
})
@Injectable()
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;
counttrack:number = null;
cover:string = '';
covers:Array<string> = [];
covers:string[];
constructor(private seriesService: SeriesService) {
constructor(
private artistService: ArtistService,
private dataService: DataService) {
}
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)
self.name = this.element.name;
self.description = this.element.description;
self.covers = self.dataService.getCoverListThumbnailUrl(this.element.covers);
this.artistService.countTrack(this.element.id)
.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.seriesService.getCoverThumbnailUrl(response.covers[0]);
for(let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.seriesService.getCoverThumbnailUrl(response.covers[iii]));
}
}
self.counttrack = response;
}).catch((response) => {
self.error = 'Can not get the data';
self.name = '';
self.cover = null;
self.covers = [];
});
this.seriesService.countVideo(this.idSeries)
.then((response) => {
self.countvideo = response;
}).catch((response) => {
self.countvideo = 0;
self.counttrack = 0;
});
}
}

View File

@ -1,12 +1,12 @@
<div>
<div class="count-base">
<span class="count" *ngIf="countvideo">
{{countvideo}}
<span class="count" *ngIf="counttrack">
{{counttrack}}
</span>
</div>
<div class="imgContainer-small">
<div *ngIf="covers">
<img src="{{covers[0]}}" alt="type image" class="miniature-small"/>
<img src="{{covers[0]}}" class="miniature-small"/>
</div>
</div>
<div class="title-small">

View File

@ -3,65 +3,52 @@
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Injectable, Component, OnInit, Input } from '@angular/core';
import { isArrayOf, isNumberFinite } from '../../utils';
import { Component, OnInit, Input } from '@angular/core';
import { isArrayOf, isNullOrUndefined, isNumberFinite } from 'common/utils';
import { NodeData } from 'common/model';
import { TypeService } from '../../service/type';
import { NodeData } from '../..//model';
import { GenderService, DataService } from 'app/service';
@Component({
selector: 'app-element-type',
templateUrl: './element-type.html',
styleUrls: [ './element-type.less' ]
})
//@Injectable()
export class ElementTypeComponent implements OnInit {
// input parameters
@Input() idType:number = -1;
@Input() element:NodeData;
public name: string = 'rr';
public description: string = 'sdqdfqsd';
public description: string;
public imageSource:string; // TODO: remove this ...
public error:string;
public countvideo:number;
public countserie:number;
public counttrack:number;
public covers: string[];
constructor(private typeService: TypeService) {
constructor(
private typeService: GenderService,
private dataService: DataService) {
}
ngOnInit() {
if (isNullOrUndefined(this.element)) {
this.name = 'Not a media';
this.description = undefined;
this.counttrack = undefined;
this.covers = undefined;
return;
}
let self = this;
//console.log(`get parameter id: ${ this.idType}`);
this.typeService.get(this.idType)
.then((response: NodeData) => {
//console.log("Get element ! " + JSON.stringify(response));
self.error = '';
self.name = response.name;
self.description = response.description;
if(!isArrayOf(response.covers, isNumberFinite) || response.covers.length === 0) {
self.covers = undefined;
} else {
self.covers = [];
for(let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.typeService.getCoverThumbnailUrl(response.covers[iii]));
}
}
}).catch((response) => {
self.error = 'Can not get the data';
self.name = undefined;
self.description = undefined;
self.imageSource = undefined;
self.covers = [];
});
this.typeService.countVideo(this.idType)
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);
this.typeService.countTrack(this.element.id)
.then((response: number) => {
self.countvideo = response;
}).catch((response) => {
self.countvideo = 0;
self.counttrack = response;
}).catch(() => {
self.counttrack = 0;
});
}
}

View File

@ -1,16 +1,19 @@
<div>
<div class="videoImgContainer">
<div *ngIf="cover">
<div class="trackImgContainer">
<div *ngIf="covers">
<!--<data-image id="{{cover}}"></data-image>-->
<img src="{{cover}}"/>
<img src="{{covers[0]}}"/>
</div>
<div *ngIf="!cover" class="noImage">
<div *ngIf="!covers" class="noImage">
</div>
</div>
<div class="title-small">
<div class="title-small" *ngIf="data">
{{episodeDisplay}} {{name}}
</div>
<div class="title-small" *ngIf="!data">
Error meda: {{element?.id}}
</div>
<!--
<div class="description-small" *ngIf="description">
{{description}}

View File

@ -4,9 +4,11 @@
* @license PROPRIETARY (see license file)
*/
import { Injectable, Component, OnInit, Input } from '@angular/core';
import { isMedia, Media } from 'app/model';
import { VideoService } from '../../service/video';
import { HttpWrapperService } from '../../service/http-wrapper';
import { DataService } from 'app/service';
import { NodeData } from 'common/model';
import { isNullOrUndefined } from 'common/utils';
@Component({
selector: 'app-element-video',
@ -17,90 +19,35 @@ import { HttpWrapperService } from '../../service/http-wrapper';
@Injectable()
export class ElementVideoComponent implements OnInit {
// input parameters
@Input() idVideo:number = -1;
@Input() displayVideo:boolean = false;
error:string = '';
@Input() element:NodeData;
data:Media;
name:string = '';
description:string = '';
episode:number = undefined;
seriesId:number = undefined;
seasonId:number = undefined;
dataId:number = -1;
time:number = undefined;
typeId:number = undefined;
generatedName:string = '';
videoSource:string = '';
videoEnable:boolean = false;
imageSource:string = null;
episodeDisplay:string = '';
cover:string = '';
covers:string[] = [];
covers:string[];
constructor(private videoService: VideoService,
private httpService: HttpWrapperService) {
}
OnDestroy() {
this.videoSource = '';
this.videoEnable = false;
constructor(
private dataService: DataService) {
// nothing to do.
}
ngOnInit() {
this.name = `ll ${ this.idVideo}`;
let self = this;
// console.log("get video id: " + this.idVideo);
this.videoService.get(this.idVideo)
.then((response) => {
// console.log("get response of video : " + JSON.stringify(response, null, 2));
self.error = '';
self.name = response.name;
self.description = response.description;
self.episode = response.episode;
if(response.episode === undefined || response.episode === null || response.episode === '') {
self.episodeDisplay = '';
} else {
self.episodeDisplay = `${response.episode } - `;
}
self.seriesId = response.seriesId;
self.seasonId = response.seasonId;
self.dataId = response.dataId;
self.time = response.time;
self.generatedName = response.generatedName;
if(self.dataId !== -1) {
self.videoSource = self.httpService.createRESTCall(`data/${ self.dataId}`);
self.videoEnable = true;
} else {
self.videoSource = '';
self.videoEnable = false;
}
if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
self.cover = null;
// self.covers = [];
} else {
self.cover = self.videoService.getCoverThumbnailUrl(response.covers[0]);
for(let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.videoService.getCoverThumbnailUrl(response.covers[iii]));
}
}
// console.log("101010 " + self.videoEnable + " " + self.videoSource);
// console.log("set transformed : " + JSON.stringify(self, null, 2));
}).catch((response) => {
self.error = 'Can not get the data';
self.name = '';
self.description = '';
self.episode = undefined;
self.episodeDisplay = '';
self.seriesId = undefined;
self.seasonId = undefined;
self.dataId = -1;
self.time = undefined;
self.generatedName = '';
self.videoSource = '';
self.videoEnable = false;
self.cover = null;
self.covers = [];
});
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;
if(isNullOrUndefined(this.element.episode)) {
this.episodeDisplay = '';
} else {
this.episodeDisplay = `${this.element.episode } - `;
}
this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers);
}
}

View File

@ -23,40 +23,40 @@
T
</div>
</button>
<div class="item_ariane_separator" *ngIf="arianeUniverseId !== null && arianeTypeId !== null" >/</div>
<div class="item_ariane_separator" *ngIf="arianePlaylistId !== null && arianeTypeId !== null" >/</div>
<button class="item"
*ngIf="arianeUniverseId !== null"
title="Universe"
(click)="onArianeUniverse($event)"
(auxclick)="onArianeUniverse($event)">
*ngIf="arianePlaylistId !== null"
title="Playlist"
(click)="onArianePlaylist($event)"
(auxclick)="onArianePlaylist($event)">
<div class="xdesktop">
{{arianeUniverseName}}
{{arianePlaylistName}}
</div>
<div class="xmobile">
U
</div>
</button>
<div class="item_ariane_separator" *ngIf="arianeSeriesId !== null && (arianeUniverseId !== null || arianeTypeId !== null)" >/</div>
<div class="item_ariane_separator" *ngIf="arianeArtistId !== null && (arianePlaylistId !== null || arianeTypeId !== null)" >/</div>
<button class="item"
*ngIf="arianeSeriesId !== null"
title="Series"
(click)="onArianeSeries($event)"
(auxclick)="onArianeSeries($event)">
*ngIf="arianeArtistId !== null"
title="Artist"
(click)="onArianeArtist($event)"
(auxclick)="onArianeArtist($event)">
<div class="xdesktop">
{{arianeSeriesName}}
{{arianeArtistName}}
</div>
<div class="xmobile">
G
</div>
</button>
<div class="item_ariane_separator" *ngIf="arianeSeasonId !== null && (arianeSeriesId !== null || arianeUniverseId !== null || arianeTypeId !== null)" >/</div>
<div class="item_ariane_separator" *ngIf="arianeAlbumId !== null && (arianeArtistId !== null || arianePlaylistId !== null || arianeTypeId !== null)" >/</div>
<button class="item"
*ngIf="arianeSeasonId !== null"
title="Season"
(click)="onArianeSeason($event)"
(auxclick)="onArianeSeason($event)">
*ngIf="arianeAlbumId !== null"
title="Album"
(click)="onArianeAlbum($event)"
(auxclick)="onArianeAlbum($event)">
<div class="xdesktop">
{{arianeSeasonName}}
{{arianeAlbumName}}
</div>
<div class="xmobile">
S
@ -64,7 +64,7 @@
</button>
</div>
<button class="item"
*ngIf="login === null"
*ngIf="!login"
style="float:right;"
(click)="onSignUp($event)"
(auxclick)="onSignUp($event)">
@ -76,7 +76,7 @@
</div>
</button>
<button class="item"
*ngIf="login === null"
*ngIf="!login"
style="float:right;"
(click)="onSignIn($event)"
(auxclick)="onSignIn($event)">
@ -88,7 +88,7 @@
</div>
</button>
<button class="item"
*ngIf="login !== null"
*ngIf="login"
style="float:right; height:56px;"
(click)="onAvatar()">
<img class="avatar" src="{{avatar}}"/>
@ -145,29 +145,29 @@
<b>Edit Type</b>
</button>
<button class="item"
*ngIf="arianeUniverseId !== null"
(click)="onSubEditUniverse($event)"
(auxclick)="onSubEditUniverse($event)">
<b>Edit Universe</b>
*ngIf="arianePlaylistId !== null"
(click)="onSubEditPlaylist($event)"
(auxclick)="onSubEditPlaylist($event)">
<b>Edit Playlist</b>
</button>
-->
<button class="item"
*ngIf="arianeSeriesId !== null"
(click)="onSubEditSeries($event)"
(auxclick)="onSubEditSeries($event)">
<b>Edit Series</b>
*ngIf="arianeArtistId !== null"
(click)="onSubEditArtist($event)"
(auxclick)="onSubEditArtist($event)">
<b>Edit Artist</b>
</button>
<button class="item"
*ngIf="arianeSeasonId !== null"
(click)="onSubEditSeason($event)"
(auxclick)="onSubEditSeason($event)">
<b>Edit Season</b>
*ngIf="arianeAlbumId !== null"
(click)="onSubEditAlbum($event)"
(auxclick)="onSubEditAlbum($event)">
<b>Edit Album</b>
</button>
<button class="item"
*ngIf="arianeVideoId !== null"
(click)="onSubEditVideo($event)"
(auxclick)="onSubEditVideo($event)">
<b>Edit Video</b>
*ngIf="arianeTrackId !== null"
(click)="onSubEditTrack($event)"
(auxclick)="onSubEditTrack($event)">
<b>Edit Track</b>
</button>
</div>
</div>
@ -181,29 +181,29 @@
<b>Edit Type</b>
</button>
<button class="item"
*ngIf="arianeUniverseId !== null"
(click)="onSubEditUniverse($event)"
(auxclick)="onSubEditUniverse($event)">
<b>Edit Universe</b>
*ngIf="arianePlaylistId !== null"
(click)="onSubEditPlaylist($event)"
(auxclick)="onSubEditPlaylist($event)">
<b>Edit Playlist</b>
</button>
-->
<button class="item"
*ngIf="arianeSeriesId !== null"
(click)="onSubEditSeries($event)"
(auxclick)="onSubEditSeries($event)">
<b>Edit Series</b>
*ngIf="arianeArtistId !== null"
(click)="onSubEditArtist($event)"
(auxclick)="onSubEditArtist($event)">
<b>Edit Artist</b>
</button>
<button class="item"
*ngIf="arianeSeasonId !== null"
(click)="onSubEditSeason($event)"
(auxclick)="onSubEditSeason($event)">
<b>Edit Season</b>
*ngIf="arianeAlbumId !== null"
(click)="onSubEditAlbum($event)"
(auxclick)="onSubEditAlbum($event)">
<b>Edit Album</b>
</button>
<button class="item"
*ngIf="arianeVideoId !== null"
(click)="onSubEditVideo($event)"
(auxclick)="onSubEditVideo($event)">
<b>Edit Video</b>
*ngIf="arianeTrackId !== null"
(click)="onSubEditTrack($event)"
(auxclick)="onSubEditTrack($event)">
<b>Edit Track</b>
</button>
</div>
</div>

View File

@ -3,39 +3,36 @@
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Injectable, Component, OnInit } from '@angular/core';
// import { AppRoutingModule } from "../app-routing.module";
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { UserService, SessionService, SSOService, ArianeService } from '../../service';
import { UserService, SessionService, SSOService } from 'common/service';
import { ArianeService } from 'app/service';
@Component({
selector: 'app-top-menu',
templateUrl: './top-menu.html',
styleUrls: [ './top-menu.less' ]
})
@Injectable()
export class TopMenuComponent implements OnInit {
public login: string = null;// Session.getLogin();
public avatar: string = null;// Session.getAvatar();
public login: string;// Session.getLogin();
public avatar: string;// Session.getAvatar();
public displayUserMenu: boolean = false;
public displayEditMenu: boolean = false;
public arianeTypeId: number = null;
public arianeTypeName: string = null;
public arianeUniverseId: number = null;
public arianeUniverseName: string = null;
public arianePlaylistId: number = null;
public arianePlaylistName: string = null;
public arianeSeriesId: number = null;
public arianeSeriesName: string = null;
public arianeArtistId: number = null;
public arianeArtistName: string = null;
public arianeSeasonId: number = null;
public arianeSeasonName: string = null;
public arianeAlbumId: number = null;
public arianeAlbumName: string = null;
public arianeVideoId: number = null;
public arianeVideoName: string = null;
public arianeTrackId: number = null;
public arianeTrackName: string = null;
public editShow: boolean = false;
@ -52,8 +49,8 @@ export class TopMenuComponent implements OnInit {
this.sessionService.change.subscribe((isConnected) => {
console.log(`TOP-MENU: receive event from session ...${isConnected}`);
if(isConnected === false) {
self.login = null;
self.avatar = null;
self.login = undefined;
self.avatar = undefined;
self.displayUserMenu = false;
} else {
self.updateIsJusteLogged();
@ -67,24 +64,24 @@ export class TopMenuComponent implements OnInit {
this.arianeTypeName = this.arianeService.getTypeName();
this.updateEditShow();
});
this.arianeService.universeChange.subscribe((universId) => {
this.arianeUniverseId = universId;
this.arianeUniverseName = this.arianeService.getUniverseName();
this.arianeService.playlistChange.subscribe((universId) => {
this.arianePlaylistId = universId;
this.arianePlaylistName = this.arianeService.getPlaylistName();
this.updateEditShow();
});
this.arianeService.seriesChange.subscribe((seriesId) => {
this.arianeSeriesId = seriesId;
this.arianeSeriesName = this.arianeService.getSeriesName();
this.arianeService.artistChange.subscribe((artistId) => {
this.arianeArtistId = artistId;
this.arianeArtistName = this.arianeService.getArtistName();
this.updateEditShow();
});
this.arianeService.seasonChange.subscribe((seasonId) => {
this.arianeSeasonId = seasonId;
this.arianeSeasonName = this.arianeService.getSeasonName();
this.arianeService.albumChange.subscribe((albumId) => {
this.arianeAlbumId = albumId;
this.arianeAlbumName = this.arianeService.getAlbumName();
this.updateEditShow();
});
this.arianeService.videoChange.subscribe((videoId) => {
this.arianeVideoId = videoId;
this.arianeVideoName = this.arianeService.getVideoName();
this.arianeService.trackChange.subscribe((trackId) => {
this.arianeTrackId = trackId;
this.arianeTrackName = this.arianeService.getTrackName();
this.updateEditShow();
});
}
@ -153,56 +150,56 @@ export class TopMenuComponent implements OnInit {
this.arianeService.navigateType(this.arianeTypeId, event.which === 2);
}
onArianeUniverse(event: any): void {
console.log(`onArianeUniverse(${ this.arianeUniverseId })`);
this.arianeService.navigateUniverse(this.arianeUniverseId, event.which === 2);
onArianePlaylist(event: any): void {
console.log(`onArianePlaylist(${ this.arianePlaylistId })`);
this.arianeService.navigatePlaylist(this.arianePlaylistId, event.which === 2);
}
onArianeSeries(event: any): void {
console.log(`onArianeSeries(${ this.arianeSeriesId })`);
this.arianeService.navigateSeries(this.arianeSeriesId, event.which === 2);
onArianeArtist(event: any): void {
console.log(`onArianeArtist(${ this.arianeArtistId })`);
this.arianeService.navigateArtist(this.arianeArtistId, event.which === 2);
}
onArianeSeason(event: any): void {
console.log(`onArianeSeason(${ this.arianeSeasonId })`);
this.arianeService.navigateSeason(this.arianeSeasonId, event.which === 2);
onArianeAlbum(event: any): void {
console.log(`onArianeAlbum(${ this.arianeAlbumId })`);
this.arianeService.navigateAlbum(this.arianeAlbumId, event.which === 2);
}
updateEditShow():void {
this.editShow = /* this.arianeTypeId !== null
|| this.arianeUniverseId !== null
||*/ this.arianeSeriesId !== null ||
this.arianeSeasonId !== null ||
this.arianeVideoId !== null;
|| this.arianePlaylistId !== null
||*/ this.arianeArtistId !== null ||
this.arianeAlbumId !== null ||
this.arianeTrackId !== null;
}
onEdit(): void {
console.log('onEdit()');
this.displayEditMenu = !this.displayEditMenu;
this.displayUserMenu = false;
}
onSubEditVideo(event: any): void {
onSubEditTrack(event: any): void {
console.log('onSubEdit()');
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateVideoEdit(this.arianeVideoId, event.which === 2);
this.arianeService.navigateTrackEdit(this.arianeTrackId, event.which === 2);
}
onSubEditSeason(event: any): void {
onSubEditAlbum(event: any): void {
console.log('onSubEdit()');
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateSeasonEdit(this.arianeSeasonId, event.which === 2);
this.arianeService.navigateAlbumEdit(this.arianeAlbumId, event.which === 2);
}
onSubEditSeries(event: any): void {
onSubEditArtist(event: any): void {
console.log('onSubEdit()');
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateSeriesEdit(this.arianeSeriesId, event.which === 2);
this.arianeService.navigateArtistEdit(this.arianeArtistId, event.which === 2);
}
onSubEditUniverse(event: any): void {
onSubEditPlaylist(event: any): void {
console.log('onSubEdit()');
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateUniverseEdit(this.arianeUniverseId, event.which === 2);
this.arianeService.navigatePlaylistEdit(this.arianePlaylistId, event.which === 2);
}
onSubEditType(event: any): void {
console.log('onSubEditType()');

View File

@ -1,8 +1,5 @@
import { Media, isMedia } from "./media";
import { NodeData, isNodeData } from "./node";
export {
NodeData, isNodeData,
Media, isMedia,
}
}

View File

@ -1,13 +1,13 @@
import { isObject, isNumberFinite, isString, isOptionalOf, isOptionalArrayOf } from "../utils";
import { isNodeData, NodeData } from "./node";
import { isNumberFinite, isString, isOptionalOf } from "common/utils";
import { isNodeData, NodeData } from "common/model/node";
export interface Media extends NodeData {
dataId?: number;
typeId?: number;
universeId?: number;
seriesId?: number;
seasonId?: number;
playlistId?: number;
artistId?: number;
albumId?: number;
episode?: number;
date?: number;
time?: number;
@ -26,13 +26,13 @@ export function isMedia(data: any): data is Media {
if (!isOptionalOf(data.typeId, isNumberFinite)) {
return false;
}
if (!isOptionalOf(data.universeId, isNumberFinite)) {
if (!isOptionalOf(data.playlistId, isNumberFinite)) {
return false;
}
if (!isOptionalOf(data.seriesId, isNumberFinite)) {
if (!isOptionalOf(data.artistId, isNumberFinite)) {
return false;
}
if (!isOptionalOf(data.seasonId, isNumberFinite)) {
if (!isOptionalOf(data.albumId, isNumberFinite)) {
return false;
}
if (!isOptionalOf(data.episode, isNumberFinite)) {

View File

@ -3,17 +3,15 @@
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Injectable, Component, OnInit } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { PopInService } from '../../service/popin';
import { PopInService } from 'common/service/popin';
@Component({
selector: 'create-type',
templateUrl: './create-type.html',
styleUrls: [ './create-type.less' ]
})
@Injectable()
export class PopInCreateType implements OnInit {
name: string = '';
description: string = '';

View File

@ -16,15 +16,15 @@
</div>
<div class="fill-content colomn_mutiple">
<div class="clear"></div>
<div *ngFor="let data of seriess" class="item" (click)="onSelectSeries($event, data.id)" (auxclick)="onSelectSeries($event, data.id)">
<app-element-series [idType]="typeId" [idSeries]="data.id"></app-element-series>
<div *ngFor="let data of artists" class="item" (click)="onSelectArtist($event, data.id)" (auxclick)="onSelectArtist($event, data.id)">
<app-element-artist [element]="data"></app-element-artist>
</div>
</div>
<div class="fill-content colomn_mutiple">
<div class="clear"></div>
<div *ngFor="let data of videos" class="item item-video" (click)="onSelectVideo($event, data.id)" (auxclick)="onSelectVideo($event, data.id)">
<app-element-video [idVideo]="data.id"></app-element-video>
<div *ngFor="let data of tracks" class="item item-track" (click)="onSelectMedia($event, data.id)" (auxclick)="onSelectMedia($event, data.id)">
<app-element-track [element]="data"></app-element-track>
</div>
</div>
<div class="clear"></div>
</div>
</div>

View File

@ -0,0 +1,89 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { GenderService, DataService, ArianeService } from 'app/service';
@Component({
selector: 'app-gender',
templateUrl: './gender.html',
styleUrls: [ './gender.less' ]
})
export class TypeScene implements OnInit {
genderId = -1;
name: string = '';
description: string = '';
cover:string = null;
covers:string[] = [];
artistsError = '';
artists = [];
tracksError = '';
tracks = [];
constructor(
private route: ActivatedRoute,
private genderService: GenderService,
private arianeService: ArianeService,
private dataService: DataService) {
//NOTHING TO DO ...
}
ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap);
this.genderId = this.arianeService.getTypeId();
let self = this;
console.log(`get gender global id: ${ this.genderId}`);
this.genderService.get(this.genderId)
.then((response) => {
self.name = response.name;
self.description = response.description;
console.log(` ==> get answer gender detail: ${JSON.stringify(response)}`);
if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
self.cover = null;
self.covers = [];
} else {
self.cover = self.dataService.getCoverUrl(response.covers[0]);
for(let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.dataService.getCoverUrl(response.covers[iii]));
}
}
}).catch((response) => {
self.name = '???';
self.description = '';
self.covers = [];
self.cover = null;
});
this.genderService.getSubArtist(this.genderId)
.then((response) => {
console.log(` ==> get answer sub-artist: ${JSON.stringify(response)}`);
self.artistsError = '';
self.artists = response;
}).catch((response) => {
console.log(` ==> get answer sub-artist (ERROR): ${JSON.stringify(response)}`);
self.artistsError = 'Wrong e-mail/login or password';
self.artists = [];
});
this.genderService.getSubTrack(this.genderId)
.then((response) => {
console.log(` ==> get answer sub-track: ${JSON.stringify(response)}`);
self.tracksError = '';
self.tracks = response;
}).catch((response) => {
console.log(` ==> get answer sub-track (ERROR): ${JSON.stringify(response)}`);
self.tracksError = 'Wrong e-mail/login or password';
self.tracks = [];
});
}
onSelectArtist(event: any, idSelected: number):void {
this.arianeService.navigateArtist(idSelected, event.which === 2, event.ctrlKey);
}
onSelectTrack(event: any, idSelected: number):void {
this.arianeService.navigateTrack(idSelected, event.which === 2, event.ctrlKey);
}
}

View File

@ -1,6 +1,6 @@
<div class="generic-page">
<div class="title">
Karauth (SSO identity manager) Help area.
Karideo Help
</div>
<div class="fill-all colomn_mutiple">
Help

View File

@ -6,7 +6,7 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ArianeService } from '../../service/ariane';
import { ArianeService } from 'app/service/ariane';
@Component({
selector: 'app-help',

View File

@ -4,7 +4,7 @@
</div>
<div class="fill-all colomn_mutiple">
<div *ngFor="let data of dataList" class="item-home" (click)="onSelectType($event, data.id)" (auxclick)="onSelectType($event, data.id)">
<app-element-type [idType]="data.id"></app-element-type>
<app-element-type [element]="data"></app-element-type>
</div>
<div class="clear"></div>
</div>

View File

@ -7,8 +7,7 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { TypeService } from '../../service/type';
import { ArianeService } from '../../service/ariane';
import { ArianeService, GenderService } from 'app/service';
@Component({
selector: 'app-home',
@ -19,7 +18,7 @@ export class HomeScene implements OnInit {
dataList = [];
error = '';
constructor(private route: ActivatedRoute,
private typeService: TypeService,
private typeService: GenderService,
private arianeService: ArianeService) {
}

View File

@ -1,34 +1,28 @@
import { ErrorViewerScene } from "./error-viewer/error-viewer";
import { TypeScene } from "./gender/gender";
import { HelpScene } from "./help/help";
import { HomeScene } from "./home/home";
import { SeasonEditScene } from "./season-edit/season-edit";
import { SeasonScene } from "./season/season";
import { SeriesEditScene } from "./series-edit/series-edit";
import { SeriesScene } from "./series/series";
import { AlbumEditScene } from "./season-edit/season-edit";
import { AlbumScene } from "./season/season";
import { ArtistEditScene } from "./series-edit/series-edit";
import { ArtistScene } from "./series/series";
import { SettingsScene } from "./settings/settings";
import { SsoScene } from "./sso/sso";
import { TypeScene } from "./type/type";
import { UniverseScene } from "./universe/universe";
import { UploadScene } from "./upload/upload";
import { VideoEditScene } from "./video-edit/video-edit";
import { VideoScene } from "./video/video";
import { PlaylistScene } from "./universe/universe";
import { TrackEditScene } from "./video-edit/video-edit";
import { TrackScene } from "./video/video";
export {
ErrorViewerScene,
HelpScene,
HomeScene,
SsoScene,
SettingsScene,
SeasonScene,
SeasonEditScene,
SeriesScene,
SeriesEditScene,
AlbumScene,
AlbumEditScene,
ArtistScene,
ArtistEditScene,
TypeScene,
UniverseScene,
UploadScene,
VideoScene,
VideoEditScene,
PlaylistScene,
TrackScene,
TrackEditScene,
};

View File

@ -1,18 +1,18 @@
<div class="main-reduce edit-page">
<div class="title">
Edit season
Edit album
</div>
<div class="fill-all" *ngIf="itemIsRemoved">
<div class="message-big">
<br/><br/><br/>
The season has been removed
The album has been removed
<br/><br/><br/>
</div>
</div>
<div class="fill-all" *ngIf="itemIsNotFound">
<div class="message-big">
<br/><br/><br/>
The season does not exist
The album does not exist
<br/><br/><br/>
</div>
</div>
@ -31,7 +31,7 @@
</div>
<div class="input">
<input type="number"
placeholder="Id of the season"
placeholder="Id of the album"
[value]="numberVal"
(input)="onNumber($event.target.value)"
/>
@ -100,16 +100,16 @@
<i class="material-icons">data_usage</i> ID:
</div>
<div class="input">
{{idSeason}}
{{idAlbum}}
</div>
</div>
<div class="clear"></div>
<div class="request_raw">
<div class="label">
Videos:
Tracks:
</div>
<div class="input">
{{videoCount}}
{{trackCount}}
</div>
</div>
<div class="clear"></div>
@ -117,13 +117,13 @@
<div class="label">
<i class="material-icons">delete_forever</i> Trash:
</div>
<div class="input" *ngIf="(videoCount == '0')">
<div class="input" *ngIf="(trackCount == '0')">
<button class="button color-button-cancel color-shadow-black" (click)="removeItem()" type="submit">
<i class="material-icons">delete</i> Remove season
<i class="material-icons">delete</i> Remove album
</button>
</div>
<div class="input" *ngIf="(videoCount != '0')">
<i class="material-icons">new_releases</i> Can not remove season, video depending on it
<div class="input" *ngIf="(trackCount != '0')">
<i class="material-icons">new_releases</i> Can not remove album, track depending on it
</div>
</div>
<div class="clear"></div>

View File

@ -7,10 +7,12 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { SeasonService } from '../../service/season';
import { ArianeService } from '../../service/ariane';
import { UploadProgress } from '../../popin/upload-progress/upload-progress';
import { PopInService } from '../../service/popin';
import { AlbumService , 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;
@ -18,13 +20,13 @@ export interface ElementList {
}
@Component({
selector: 'app-season-edit',
templateUrl: './season-edit.html',
styleUrls: [ './season-edit.less' ]
selector: 'app-album-edit',
templateUrl: './album-edit.html',
styleUrls: [ './album-edit.less' ]
})
export class SeasonEditScene implements OnInit {
idSeason:number = -1;
export class AlbumEditScene implements OnInit {
idAlbum:number = -1;
itemIsRemoved:boolean = false;
itemIsNotFound:boolean = false;
itemIsLoading:boolean = true;
@ -36,7 +38,7 @@ export class SeasonEditScene implements OnInit {
coverFile: File;
uploadFileValue: string = '';
selectedFiles: FileList;
videoCount: string = null;
trackCount: string = null;
coversDisplay: Array<any> = [];
@ -65,21 +67,25 @@ export class SeasonEditScene implements OnInit {
}
constructor(private route: ActivatedRoute,
private seasonService: SeasonService,
private arianeService: ArianeService,
private popInService: PopInService) {
constructor(
private route: ActivatedRoute,
private albumService: AlbumService,
private arianeService: ArianeService,
private popInService: PopInService,
private dataService: DataService) {
}
ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap);
this.idSeason = this.arianeService.getSeasonId();
this.idAlbum = this.arianeService.getAlbumId();
let self = this;
this.seasonService.get(this.idSeason)
.then((response) => {
console.log(`get response of season : ${ JSON.stringify(response, null, 2)}`);
self.numberVal = response.name;
this.albumService.get(this.idAlbum)
.then((response: NodeData) => {
console.log(`get response of album : ${ JSON.stringify(response, null, 2)}`);
if (isNumberFinite(response.name)) {
self.numberVal = response.name;
}
self.description = response.description;
self.updateCoverList(response.covers);
self.itemIsLoading = false;
@ -91,11 +97,11 @@ export class SeasonEditScene implements OnInit {
self.itemIsNotFound = true;
self.itemIsLoading = false;
});
this.seasonService.getVideo(this.idSeason)
this.albumService.getTrack(this.idAlbum)
.then((response:any) => {
self.videoCount = response.length;
self.trackCount = response.length;
}).catch((response:any) => {
self.videoCount = '---';
self.trackCount = '---';
});
}
@ -105,7 +111,7 @@ export class SeasonEditScene implements OnInit {
for(let iii = 0; iii < covers.length; iii++) {
this.coversDisplay.push({
id:covers[iii],
url:this.seasonService.getCoverThumbnailUrl(covers[iii])
url:this.dataService.getCoverThumbnailUrl(covers[iii])
});
}
} else {
@ -129,7 +135,7 @@ export class SeasonEditScene implements OnInit {
if(this.description === undefined) {
data.description = null;
}
this.seasonService.put(this.idSeason, data);
this.albumService.put(this.idAlbum, data);
}
// At the drag drop area
@ -165,7 +171,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.albumService.uploadCover(file, this.idAlbum, (count, total) => {
self.upload.mediaSendSize = count;
self.upload.mediaSize = total;
})
@ -175,41 +181,41 @@ export class SeasonEditScene implements OnInit {
self.updateCoverList(response.covers);
}).catch((response:any) => {
// self.error = "Can not get the data";
console.log('Can not add the cover in the video...');
console.log('Can not add the cover in the track...');
});
}
removeCover(id:number) {
this.cleanConfirm();
this.confirmDeleteComment = `Delete the cover ID: ${ id}`;
this.confirmDeleteImageUrl = this.seasonService.getCoverThumbnailUrl(id);
this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id);
this.deleteCoverId = id;
this.popInService.open('popin-delete-confirm');
}
removeCoverAfterConfirm(id:number) {
console.log(`Request remove cover: ${ id}`);
let self = this;
this.seasonService.deleteCover(this.idSeason, id)
this.albumService.deleteCover(this.idAlbum, id)
.then((response:any) => {
self.upload.result = 'Cover remove done';
// we retrive the whiole media ==> update data ...
self.updateCoverList(response.covers);
}).catch((response:any) => {
// self.error = "Can not get the data";
console.log('Can not remove the cover of the video...');
console.log('Can not remove the cover of the track...');
});
}
removeItem() {
console.log('Request remove Media...');
this.cleanConfirm();
this.confirmDeleteComment = `Delete the Season: ${ this.idSeason}`;
this.deleteItemId = this.idSeason;
this.confirmDeleteComment = `Delete the Album: ${ this.idAlbum}`;
this.deleteItemId = this.idAlbum;
this.popInService.open('popin-delete-confirm');
}
removeItemAfterConfirm(id:number) {
let self = this;
this.seasonService.delete(id)
this.albumService.delete(id)
.then((response3) => {
// self.dataOri = tmpp;
// self.updateNeedSend();

View File

@ -6,11 +6,11 @@
</div>
</div>
<div [className]="cover != null ? 'description-area description-area-cover' : 'description-area description-area-no-cover'">
<div *ngIf="seriesName" class="title">
{{seriesName}}
<div *ngIf="artistName" class="title">
{{artistName}}
</div>
<div class="sub-title-main">
Season {{name}}
Album {{name}}
</div>
<div class="description" *ngIf="description">
{{description}}
@ -19,10 +19,10 @@
</div>
<div class="fill-content colomn_mutiple">
<div class="clear"></div>
<div class="title" *ngIf="videos.length > 1">Videos:</div>
<div class="title" *ngIf="videos.length == 1">Video:</div>
<div *ngFor="let data of videos" class="item item-video" (click)="onSelectVideo($event, data.id)" (auxclick)="onSelectVideo($event, data.id)">
<app-element-video [idVideo]="data.id"></app-element-video>
<div class="title" *ngIf="tracks.length > 1">Tracks:</div>
<div class="title" *ngIf="tracks.length == 1">Track:</div>
<div *ngFor="let data of tracks" class="item item-track" (click)="onSelectTrack($event, data.id)" (auxclick)="onSelectTrack($event, data.id)">
<app-element-track [element]="data"></app-element-track>
</div>
<div class="clear"></div>
</div>

View File

@ -7,79 +7,79 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { SeasonService } from '../../service/season';
import { SeriesService } from '../../service/series';
import { ArianeService } from '../../service/ariane';
import { AlbumService, DataService, ArtistService, ArianeService } from 'app/service';
@Component({
selector: 'app-season',
templateUrl: './season.html',
styleUrls: [ './season.less' ]
selector: 'app-album',
templateUrl: './album.html',
styleUrls: [ './album.less' ]
})
export class SeasonScene implements OnInit {
export class AlbumScene implements OnInit {
name: string = '';
seriesName: string = '';
artistName: string = '';
description: string = '';
seriesId: number = null;
artistId: number = null;
cover: string = '';
covers: Array<string> = [];
idSeason = -1;
videosError = '';
videos = [];
constructor(private route: ActivatedRoute,
private seasonService: SeasonService,
private seriesService: SeriesService,
private arianeService: ArianeService) {
idAlbum = -1;
tracksError = '';
tracks = [];
constructor(
private route: ActivatedRoute,
private albumService: AlbumService,
private artistService: ArtistService,
private arianeService: ArianeService,
private dataService: DataService) {
}
ngOnInit() {
console.log('ngOnInit(SeasonComponent)');
console.log('ngOnInit(AlbumComponent)');
this.arianeService.updateManual(this.route.snapshot.paramMap);
this.idSeason = this.arianeService.getSeasonId();
this.idAlbum = this.arianeService.getAlbumId();
let self = this;
this.seasonService.get(this.idSeason)
this.albumService.get(this.idAlbum)
.then((response:any) => {
console.log("Get element ! " + JSON.stringify(response));
self.name = response.name;
self.seriesId = response.parentId;
self.artistId = response.parentId;
self.description = response.description;
if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
self.cover = null;
self.covers = [];
} else {
self.cover = self.seriesService.getCoverUrl(response.covers[0]);
self.cover = self.dataService.getCoverUrl(response.covers[0]);
for(let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.seriesService.getCoverUrl(response.covers[iii]));
self.covers.push(self.dataService.getCoverUrl(response.covers[iii]));
}
}
self.seriesService.get(self.seriesId)
self.artistService.get(self.artistId)
.then((response2:any) => {
self.seriesName = response2.name;
self.artistName = response2.name;
}).catch((response2:any) => {
self.seriesName = '';
self.artistName = '';
});
}).catch((response3:any) => {
self.description = '';
self.name = '???';
self.seriesName = '';
self.seriesId = null;
self.artistName = '';
self.artistId = null;
self.cover = null;
self.covers = [];
});
console.log(`get parameter id: ${ this.idSeason}`);
this.seasonService.getVideo(this.idSeason)
console.log(`get parameter id: ${ this.idAlbum}`);
this.albumService.getTrack(this.idAlbum)
.then((response4:any) => {
self.videosError = '';
self.videos = response4;
self.tracksError = '';
self.tracks = response4;
}).catch((response5:any) => {
self.videosError = 'Can not get the List of video without season';
self.videos = [];
self.tracksError = 'Can not get the List of track without album';
self.tracks = [];
});
}
onSelectVideo(event: any, idSelected: number):void {
this.arianeService.navigateVideo(idSelected, event.which === 2, event.ctrlKey);
onSelectTrack(event: any, idSelected: number):void {
this.arianeService.navigateTrack(idSelected, event.which === 2, event.ctrlKey);
}
}

View File

@ -1,18 +1,18 @@
<div class="main-reduce edit-page">
<div class="title">
Edit series
Edit artist
</div>
<div class="fill-all" *ngIf="itemIsRemoved">
<div class="message-big">
<br/><br/><br/>
The series has been removed
The artist has been removed
<br/><br/><br/>
</div>
</div>
<div class="fill-all" *ngIf="itemIsNotFound">
<div class="message-big">
<br/><br/><br/>
The series does not exist
The artist does not exist
<br/><br/><br/>
</div>
</div>
@ -42,7 +42,7 @@
</div>
<div class="input">
<input type="text"
placeholder="Name of the Series"
placeholder="Name of the Artist"
[value]="name"
(input)="onName($event.target.value)"
/>
@ -112,25 +112,25 @@
<i class="material-icons">data_usage</i> ID:
</div>
<div class="input">
{{idSeries}}
{{idArtist}}
</div>
</div>
<div class="clear"></div>
<div class="request_raw">
<div class="label">
Seasons:
Albums:
</div>
<div class="input">
{{seasonsCount}}
{{albumsCount}}
</div>
</div>
<div class="clear"></div>
<div class="request_raw">
<div class="label">
Videos:
Tracks:
</div>
<div class="input">
{{videoCount}}
{{trackCount}}
</div>
</div>
<div class="clear"></div>
@ -138,13 +138,13 @@
<div class="label">
<i class="material-icons">delete_forever</i> Trash:
</div>
<div class="input" *ngIf="(videoCount == '0' && seasonsCount == '0')">
<div class="input" *ngIf="(trackCount == '0' && albumsCount == '0')">
<button class="button color-button-cancel color-shadow-black" (click)="removeItem()" type="submit">
<i class="material-icons">delete</i> Remove Series
<i class="material-icons">delete</i> Remove Artist
</button>
</div>
<div class="input" *ngIf="(videoCount != '0' || seasonsCount != '0')">
<i class="material-icons">new_releases</i> Can not remove season or video depending on it
<div class="input" *ngIf="(trackCount != '0' || albumsCount != '0')">
<i class="material-icons">new_releases</i> Can not remove album or track depending on it
</div>
</div>
<div class="clear"></div>

View File

@ -5,33 +5,27 @@
*/
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common';
import { ActivatedRoute } from '@angular/router';
import { SeriesService } from '../../service/series';
import { DataService } from '../../service/data';
import { TypeService } from '../../service/type';
import { ArianeService } from '../../service/ariane';
import { UploadProgress } from '../../popin/upload-progress/upload-progress';
import { PopInService } from '../../service/popin';
import { ArtistService, DataService, GenderService, ArianeService } from 'app/service';
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
import { PopInService } from 'common/service';
export class ElementList {
value: number;
label: string;
constructor(_value: number, _label: string) {
this.value = _value;
this.label = _label;
constructor(
public value: number,
public label: string) {
}
}
@Component({
selector: 'app-series-edit',
templateUrl: './series-edit.html',
styleUrls: [ './series-edit.less' ]
selector: 'app-artist-edit',
templateUrl: './artist-edit.html',
styleUrls: [ './artist-edit.less' ]
})
export class SeriesEditScene implements OnInit {
idSeries:number = -1;
export class ArtistEditScene implements OnInit {
idArtist:number = -1;
itemIsRemoved:boolean = false;
itemIsNotFound:boolean = false;
itemIsLoading:boolean = true;
@ -45,8 +39,8 @@ export class SeriesEditScene implements OnInit {
uploadFileValue:string = '';
selectedFiles:FileList;
seasonsCount: string = null;
videoCount: string = null;
albumsCount: string = null;
trackCount: string = null;
coversDisplay:Array<any> = [];
// section tha define the upload value to display in the pop-in of upload
@ -81,11 +75,9 @@ export class SeriesEditScene implements OnInit {
constructor(private route: ActivatedRoute,
private router: Router,
private locate: Location,
private dataService: DataService,
private typeService: TypeService,
private seriesService: SeriesService,
private typeService: GenderService,
private artistService: ArtistService,
private arianeService: ArianeService,
private popInService: PopInService) {
@ -93,7 +85,7 @@ export class SeriesEditScene implements OnInit {
ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap);
this.idSeries = this.arianeService.getSeriesId();
this.idArtist = this.arianeService.getArtistId();
let self = this;
this.listType = [ { value: null, label: '---' } ];
@ -106,9 +98,9 @@ export class SeriesEditScene implements OnInit {
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
});
this.seriesService.get(this.idSeries)
this.artistService.get(this.idArtist)
.then((response) => {
// console.log("get response of video : " + JSON.stringify(response, null, 2));
// console.log("get response of track : " + JSON.stringify(response, null, 2));
self.name = response.name;
self.typeId = response.parentId;
self.description = response.description;
@ -123,18 +115,18 @@ export class SeriesEditScene implements OnInit {
self.itemIsNotFound = true;
self.itemIsLoading = false;
});
console.log(`get parameter id: ${ this.idSeries}`);
this.seriesService.getSeason(this.idSeries)
console.log(`get parameter id: ${ this.idArtist}`);
this.artistService.getAlbum(this.idArtist)
.then((response) => {
self.seasonsCount = "" + response.length;
self.albumsCount = "" + response.length;
}).catch((response) => {
self.seasonsCount = '---';
self.albumsCount = '---';
});
this.seriesService.getVideo(this.idSeries)
this.artistService.getTrack(this.idArtist)
.then((response) => {
self.videoCount = "" + response.length;
self.trackCount = "" + response.length;
}).catch((response) => {
self.videoCount = '---';
self.trackCount = '---';
});
}
@ -144,7 +136,7 @@ export class SeriesEditScene implements OnInit {
for(let iii = 0; iii < covers.length; iii++) {
this.coversDisplay.push({
id:covers[iii],
url:this.seriesService.getCoverThumbnailUrl(covers[iii])
url:this.dataService.getCoverThumbnailUrl(covers[iii])
});
}
} else {
@ -178,7 +170,7 @@ export class SeriesEditScene implements OnInit {
if(this.description === undefined) {
data.description = null;
}
this.seriesService.put(this.idSeries, data);
this.artistService.put(this.idArtist, data);
}
// At the drag drop area
@ -214,7 +206,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.artistService.uploadCover(file, this.idArtist, (count, total) => {
self.upload.mediaSendSize = count;
self.upload.mediaSize = total;
})
@ -224,39 +216,39 @@ export class SeriesEditScene implements OnInit {
self.updateCoverList(response.covers);
}).catch((response:any) => {
// self.error = "Can not get the data";
console.log('Can not add the cover in the video...');
console.log('Can not add the cover in the track...');
});
}
removeCover(id:number) {
this.cleanConfirm();
this.confirmDeleteComment = `Delete the cover ID: ${ id}`;
this.confirmDeleteImageUrl = this.seriesService.getCoverThumbnailUrl(id);
this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id);
this.deleteCoverId = id;
this.popInService.open('popin-delete-confirm');
}
removeCoverAfterConfirm(id:number) {
console.log(`Request remove cover: ${ id}`);
let self = this;
this.seriesService.deleteCover(this.idSeries, id)
this.artistService.deleteCover(this.idArtist, id)
.then((response:any) => {
self.upload.result = 'Cover remove done';
// we retrive the whiole media ==> update data ...
self.updateCoverList(response.covers);
}).catch((response:any) => {
// self.error = "Can not get the data";
console.log('Can not remove the cover of the video...');
console.log('Can not remove the cover of the track...');
});
}
removeItem() {
console.log('Request remove Media...');
this.cleanConfirm();
this.confirmDeleteComment = `Delete the Series: ${ this.idSeries}`;
this.deleteItemId = this.idSeries;
this.confirmDeleteComment = `Delete the Artist: ${ this.idArtist}`;
this.deleteItemId = this.idArtist;
this.popInService.open('popin-delete-confirm');
}
removeItemAfterConfirm(_id:number) {
let self = this;
this.seriesService.delete(_id)
this.artistService.delete(_id)
.then((response3) => {
// self.data_ori = tmpp;
// self.updateNeedSend();

View File

@ -14,20 +14,20 @@
</div>
</div>
</div>
<div class="fill-content colomn_mutiple" *ngIf="seasons.length != 0">
<div class="fill-content colomn_mutiple" *ngIf="albums.length != 0">
<div class="clear"></div>
<div class="title" *ngIf="seasons.length > 1">Seasons:</div>
<div class="title" *ngIf="seasons.length == 1">Season:</div>
<div *ngFor="let data of seasons" class="item-list" (click)="onSelectSeason($event, data.id)" (auxclick)="onSelectSeason($event, data.id)">
<app-element-season [idSeason]="data.id"></app-element-season>
<div class="title" *ngIf="albums.length > 1">Albums:</div>
<div class="title" *ngIf="albums.length == 1">Album:</div>
<div *ngFor="let data of albums" class="item-list" (click)="onSelectAlbum($event, data.id)" (auxclick)="onSelectAlbum($event, data.id)">
<app-element-season [element]="data"></app-element-season>
</div>
</div>
<div class="fill-content colomn_mutiple" *ngIf="videos.length != 0">
<div class="fill-content colomn_mutiple" *ngIf="tracks.length != 0">
<div class="clear"></div>
<div class="title" *ngIf="videos.length > 1">Videos:</div>
<div class="title" *ngIf="videos.length == 1">Video:</div>
<div *ngFor="let data of videos" class="item item-video" (click)="onSelectVideo($event, data.id)" (auxclick)="onSelectVideo($event, data.id)">
<app-element-video [idVideo]="data.id"></app-element-video>
<div class="title" *ngIf="tracks.length > 1">Tracks:</div>
<div class="title" *ngIf="tracks.length == 1">Track:</div>
<div *ngFor="let data of tracks" class="item item-track" (click)="onSelectTrack($event, data.id)" (auxclick)="onSelectTrack($event, data.id)">
<app-element-track [element]="data"></app-element-track>
</div>
</div>
<div class="clear"></div>

View File

@ -7,44 +7,45 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { SeriesService } from '../../service/series';
import { ArianeService } from '../../service/ariane';
import { NodeData } from '../../model';
import { ArtistService, DataService, ArianeService } from 'app/service';
import { NodeData } from 'common/model';
@Component({
selector: 'app-series',
templateUrl: './series.html',
styleUrls: [ './series.less' ]
selector: 'app-artist',
templateUrl: './artist.html',
styleUrls: [ './artist.less' ]
})
export class SeriesScene implements OnInit {
idSeries = -1;
export class ArtistScene implements OnInit {
idArtist = -1;
name: string = '';
description: string = '';
cover: string = '';
covers: Array<string> = [];
seasonsError: string = '';
seasons: NodeData[] = [];
videosError: string = '';
videos: Array<any> = [];
constructor(private route: ActivatedRoute,
private seriesService: SeriesService,
private arianeService: ArianeService) {
albumsError: string = '';
albums: NodeData[] = [];
tracksError: string = '';
tracks: Array<any> = [];
constructor(
private route: ActivatedRoute,
private artistService: ArtistService,
private arianeService: ArianeService,
private dataService: DataService) {
}
ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap);
// this.idUniverse = parseInt(this.route.snapshot.paramMap.get('universId'));
// this.idPlaylist = parseInt(this.route.snapshot.paramMap.get('universId'));
// this.idType = parseInt(this.route.snapshot.paramMap.get('typeId'));
this.idSeries = this.arianeService.getSeriesId();
this.idArtist = this.arianeService.getArtistId();
let self = this;
let updateEnded = {
seriesMetadata: false,
artistMetadata: false,
subSaison: false,
subVideo: false,
subTrack: false,
};
this.seriesService.get(this.idSeries)
this.artistService.get(this.idArtist)
.then((response) => {
self.name = response.name;
self.description = response.description;
@ -52,69 +53,69 @@ export class SeriesScene implements OnInit {
self.cover = null;
self.covers = [];
} else {
self.cover = self.seriesService.getCoverUrl(response.covers[0]);
self.cover = self.dataService.getCoverUrl(response.covers[0]);
for(let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.seriesService.getCoverUrl(response.covers[iii]));
self.covers.push(self.dataService.getCoverUrl(response.covers[iii]));
}
}
updateEnded.seriesMetadata = true;
updateEnded.artistMetadata = true;
self.checkIfJumpIsNeeded(updateEnded);
}).catch((response) => {
self.description = '';
self.name = '???';
self.cover = null;
self.covers = [];
// no check just ==> an error occured on season
// no check just ==> an error occured on album
});
//console.log(`get parameter id: ${ this.idSeries}`);
this.seriesService.getSeason(this.idSeries)
//console.log(`get parameter id: ${ this.idArtist}`);
this.artistService.getAlbum(this.idArtist)
.then((response: NodeData[]) => {
//console.log(`>>>> get season : ${JSON.stringify(response)}`)
self.seasonsError = '';
self.seasons = response;
//console.log(`>>>> get album : ${JSON.stringify(response)}`)
self.albumsError = '';
self.albums = response;
updateEnded.subSaison = true;
self.checkIfJumpIsNeeded(updateEnded);
}).catch((response) => {
self.seasonsError = 'Can not get the list of season in this series';
self.seasons = [];
self.albumsError = 'Can not get the list of album in this artist';
self.albums = [];
updateEnded.subSaison = true;
self.checkIfJumpIsNeeded(updateEnded);
});
this.seriesService.getVideo(this.idSeries)
this.artistService.getTrack(this.idArtist)
.then((response: NodeData[]) => {
//console.log(`>>>> get video : ${JSON.stringify(response)}`)
self.videosError = '';
self.videos = response;
updateEnded.subVideo = true;
//console.log(`>>>> get track : ${JSON.stringify(response)}`)
self.tracksError = '';
self.tracks = response;
updateEnded.subTrack = true;
self.checkIfJumpIsNeeded(updateEnded);
}).catch((response) => {
self.videosError = 'Can not get the List of video without season';
self.videos = [];
updateEnded.subVideo = true;
self.tracksError = 'Can not get the List of track without album';
self.tracks = [];
updateEnded.subTrack = true;
self.checkIfJumpIsNeeded(updateEnded);
});
}
onSelectSeason(event: any, idSelected: number):void {
this.arianeService.navigateSeason(idSelected, event.which === 2, event.ctrlKey);
onSelectAlbum(event: any, idSelected: number):void {
this.arianeService.navigateAlbum(idSelected, event.which === 2, event.ctrlKey);
}
onSelectVideo(event: any, idSelected: number):void {
this.arianeService.navigateVideo(idSelected, event.which === 2, event.ctrlKey);
onSelectTrack(event: any, idSelected: number):void {
this.arianeService.navigateTrack(idSelected, event.which === 2, event.ctrlKey);
}
checkIfJumpIsNeeded(updateEnded: { seriesMetadata: boolean; subSaison: boolean; subVideo: boolean; }): void {
checkIfJumpIsNeeded(updateEnded: { artistMetadata: boolean; subSaison: boolean; subTrack: boolean; }): void {
// all update is ended
if(updateEnded.seriesMetadata === false || updateEnded.subSaison === false || updateEnded.subVideo === false) {
if(updateEnded.artistMetadata === false || updateEnded.subSaison === false || updateEnded.subTrack === false) {
return;
}
// no local video
if(this.videos.length > 0) {
// no local track
if(this.tracks.length > 0) {
return;
}
// only one season:
if(this.seasons.length !== 1) {
// only one album:
if(this.albums.length !== 1) {
return;
}
this.arianeService.navigateSeason(this.seasons[0].id, false, false, true);
this.arianeService.navigateAlbum(this.albums[0].id, false, false, true);
}
}

View File

@ -1,6 +1,6 @@
<div class="generic-page">
<div class="title">
Karauth (SSO identity manager)
Karideo Settings
</div>
<div class="fill-all colomn_mutiple">
Global settings.

View File

@ -6,7 +6,7 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ArianeService } from '../../service/ariane';
import { ArianeService, DataService } from 'app/service';
@Component({
selector: 'app-settings',
@ -16,8 +16,11 @@ import { ArianeService } from '../../service/ariane';
export class SettingsScene implements OnInit {
page = '';
constructor(private route: ActivatedRoute,
private arianeService: ArianeService) { }
constructor(
private route: ActivatedRoute,
private arianeService: ArianeService) {
// nothing to do.
}
ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap);

View File

@ -1,96 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { TypeService } from '../../service/type';
import { ArianeService } from '../../service/ariane';
@Component({
selector: 'app-type',
templateUrl: './type.html',
styleUrls: [ './type.less' ]
})
export class TypeScene implements OnInit {
typeId = -1;
name: string = '';
description: string = '';
cover:string = null;
covers:string[] = [];
seriessError = '';
seriess = [];
videosError = '';
videos = [];
constructor(private route: ActivatedRoute,
private typeService: TypeService,
private arianeService: ArianeService) {
/*
this.route.params.subscribe(params => {
console.log(params);
if (params["id"]) {
this.doSearch(params["id"]);
}
});
*/
}
ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap);
this.typeId = this.arianeService.getTypeId();
let self = this;
console.log(`get type global id: ${ this.typeId}`);
this.typeService.get(this.typeId)
.then((response) => {
self.name = response.name;
self.description = response.description;
console.log(` ==> get answer type detail: ${JSON.stringify(response)}`);
if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
self.cover = null;
self.covers = [];
} else {
self.cover = self.typeService.getCoverUrl(response.covers[0]);
for(let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.typeService.getCoverUrl(response.covers[iii]));
}
}
}).catch((response) => {
self.name = '???';
self.description = '';
self.covers = [];
self.cover = null;
});
this.typeService.getSubSeries(this.typeId)
.then((response) => {
console.log(` ==> get answer sub-series: ${JSON.stringify(response)}`);
self.seriessError = '';
self.seriess = response;
}).catch((response) => {
console.log(` ==> get answer sub-series (ERROR): ${JSON.stringify(response)}`);
self.seriessError = 'Wrong e-mail/login or password';
self.seriess = [];
});
this.typeService.getSubVideo(this.typeId)
.then((response) => {
console.log(` ==> get answer sub-video: ${JSON.stringify(response)}`);
self.videosError = '';
self.videos = response;
}).catch((response) => {
console.log(` ==> get answer sub-video (ERROR): ${JSON.stringify(response)}`);
self.videosError = 'Wrong e-mail/login or password';
self.videos = [];
});
}
onSelectSeries(event: any, idSelected: number):void {
this.arianeService.navigateSeries(idSelected, event.which === 2, event.ctrlKey);
}
onSelectVideo(event: any, idSelected: number):void {
this.arianeService.navigateVideo(idSelected, event.which === 2, event.ctrlKey);
}
}

View File

@ -1,7 +1,7 @@
<div class="generic-page">
<div class="fill-all colomn_mutiple">
<div *ngFor="let data of videos" class="item item-video" (click)="onSelectVideo($event, data)" (auxclick)="onSelectVideo($event, data)">
<app-element-video [idVideo]="data"></app-element-video>
<div *ngFor="let data of tracks" class="item item-track" (click)="onSelectTrack($event, data)" (auxclick)="onSelectTrack($event, data)">
<app-element-track [element]="data"></app-element-track>
</div>
<div class="clear"></div>
</div>

View File

@ -7,19 +7,19 @@
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { ArianeService } from '../../service/ariane';
import { environment } from '../../../environments/environment';
import { ArianeService } from 'app/service/ariane';
import { environment } from 'environments/environment';
@Component({
selector: 'app-universe',
templateUrl: './universe.html',
styleUrls: [ './universe.less' ]
selector: 'app-playlist',
templateUrl: './playlist.html',
styleUrls: [ './playlist.less' ]
})
export class UniverseScene implements OnInit {
universeId = -1;
videosError = '';
videos = [];
export class PlaylistScene implements OnInit {
playlistId = -1;
tracksError = '';
tracks = [];
constructor(private route: ActivatedRoute,
private router: Router,
private arianeService: ArianeService) {
@ -28,32 +28,32 @@ export class UniverseScene implements OnInit {
ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap);
this.universeId = this.arianeService.getUniverseId();
console.log(`get parameter id: ${ this.universeId}`);
this.playlistId = this.arianeService.getPlaylistId();
console.log(`get parameter id: ${ this.playlistId}`);
/*
let self = this;
this.universeService.getVideo(this.universId)
this.playlistService.getTrack(this.universId)
.then(function(response) {
self.videosError = "";
self.videos = response
self.tracksError = "";
self.tracks = response
}).catch(function(response) {
self.videosError = "Can not get the List of video without season";
self.videos = []
self.tracksError = "Can not get the List of track without album";
self.tracks = []
});
*/
}
onSelectVideo(event: any, idSelected: number):void {
onSelectTrack(event: any, idSelected: number):void {
if(event.which === 2) {
if(environment.frontBaseUrl === undefined || environment.frontBaseUrl === null || environment.frontBaseUrl === '') {
window.open(`/video/${ idSelected}`);
window.open(`/track/${ idSelected}`);
} else {
window.open(`/${ environment.frontBaseUrl }/video/${ idSelected}`);
window.open(`/${ environment.frontBaseUrl }/track/${ idSelected}`);
}
} else {
this.router.navigate([ `video/${ idSelected}` ]);
this.arianeService.setVideo(idSelected);
this.router.navigate([ `track/${ idSelected}` ]);
this.arianeService.setTrack(idSelected);
}
}
}

View File

@ -14,7 +14,7 @@
<td class="left-colomn">format:</td>
<td class="right-colomn">
The format of the media permit to automatic find meta-data:<br/>
Univers:Series name-sXX-eXX-my name of my media.mkv<br/>
Univers:Artist name-sXX-eXX-my name of my media.mkv<br/>
<b>example:</b> Stargate:SG1-s55-e22-Asgard.mkv <br/>
</td>
</tr>
@ -57,49 +57,49 @@
</td>
</tr>
<tr>
<td class="left-colomn">Universe:</td>
<td class="left-colomn">Playlist:</td>
<td class="right-colomn">
<input type="text"
placeholder="Universe of the Media"
[value]="globalUniverse"
(input)="onUniverse($event.target.value)"
placeholder="Playlist of the Media"
[value]="globalPlaylist"
(input)="onPlaylist($event.target.value)"
/>
</td>
</tr>
<tr>
<td class="left-colomn">Series:</td>
<td class="left-colomn">Artist:</td>
<td class="right-colomn">
<input type="text"
placeholder="Series of the Media"
[value]="globalSeries"
(input)="onSeries($event.target.value)"
placeholder="Artist of the Media"
[value]="globalArtist"
(input)="onArtist($event.target.value)"
/>
</td>
</tr>
<tr>
<td class="left-colomn"></td>
<td class="right-colomn">
<select [ngModel]="seriesId"
(ngModelChange)="onChangeSeries($event)">
<option *ngFor="let element of listSeries" [ngValue]="element.value">{{element.label}}</option>
<select [ngModel]="artistId"
(ngModelChange)="onChangeArtist($event)">
<option *ngFor="let element of listArtist" [ngValue]="element.value">{{element.label}}</option>
</select>
</td>
<td class="tool-colomn">
<!--
<button class="button color-button-normal color-shadow-black" (click)="newSeries()" type="submit">
<button class="button color-button-normal color-shadow-black" (click)="newArtist()" type="submit">
<i class="material-icons">add_circle_outline</i>
</button>
-->
</td>
</tr>
<tr>
<td class="left-colomn">Season:</td>
<td class="left-colomn">Album:</td>
<td class="right-colomn">
<input type="number"
pattern="[0-9]{0-4}"
placeholder="season of the Media"
[value]="globalSeason"
(input)="onSeason($event.target.value)"
placeholder="album of the Media"
[value]="globalAlbum"
(input)="onAlbum($event.target.value)"
/>
</td>
</tr>

View File

@ -1,9 +1,17 @@
.title {
width: 90%;
margin: 0 auto;
font-size: 50px;
//background-color: green;
font-size: 45px;
font-weight: bold;
line-height: 60px;
width:100%;
text-align: center;
vertical-align: middle;
margin: 10px 0 10px 0;
text-shadow: 1px 1px 2px white, 0 0 1em white, 0 0 0.2em white;
text-transform: uppercase;
font-family: "Roboto","Helvetica","Arial",sans-serif;
}
.request_raw_table {

View File

@ -7,14 +7,9 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { PopInService } from '../../service/popin';
import { TypeService } from '../../service/type';
import { UniverseService } from '../../service/universe';
import { SeriesService } from '../../service/series';
import { VideoService } from '../../service/video';
import { ArianeService } from '../../service/ariane';
import { UploadProgress } from '../../popin/upload-progress/upload-progress';
import { SeasonService } from '../../service/season';
import { GenderService, PlaylistService, ArtistService, TrackService, ArianeService, AlbumService } from 'app/service';
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
import { PopInService } from 'common/service';
export class ElementList {
constructor(
@ -29,9 +24,9 @@ export class FileParsedElement {
public episodeDetected: boolean = false;
constructor(
public file: File,
public universe: string,
public series: string,
public season: number,
public playlist: string,
public artist: string,
public album: number,
public episode: number,
public title: string) {
// nothiing to do.
@ -46,7 +41,7 @@ export class FileFailParsedElement {
}
@Component({
selector: 'app-video-edit',
selector: 'app-track-edit',
templateUrl: './upload.html',
styleUrls: [ './upload.less' ]
})
@ -57,7 +52,7 @@ export class UploadScene implements OnInit {
uploadFileValue: string = '';
selectedFiles: FileList;
typeId: number = null;
seriesId: number = null;
artistId: number = null;
saisonId: number = null;
needSend: boolean = false;
@ -70,13 +65,13 @@ export class UploadScene implements OnInit {
listType: ElementList[] = [
{ value: null, label: '---' },
];
listUniverse: ElementList[] = [
listPlaylist: ElementList[] = [
{ value: null, label: '---' },
];
listSeries: ElementList[] = [
listArtist: ElementList[] = [
{ value: null, label: '---' },
];
listSeries2 = [ { id: null, description: '---' } ];
listArtist2 = [ { id: null, description: '---' } ];
/*
config = {
@ -97,18 +92,18 @@ export class UploadScene implements OnInit {
searchPlaceholder: 'Search', // label thats displayed in search input,
searchOnKey: 'description', // key on which search should be performed this will be selective search. if undefined this will be extensive search on all keys
};
listSeason: ElementList[] = [
listAlbum: ElementList[] = [
{ value: null, label: '---' },
];
globalUniverse: string = '';
globalSeries: string = '';
globalSeason: number = null;
globalPlaylist: string = '';
globalArtist: string = '';
globalAlbum: number = null;
constructor(private route: ActivatedRoute,
private typeService: TypeService,
private universeService: UniverseService,
private seriesService: SeriesService,
private seasonService: SeasonService,
private videoService: VideoService,
private typeService: GenderService,
private playlistService: PlaylistService,
private artistService: ArtistService,
private albumService: AlbumService,
private trackService: TrackService,
private arianeService: ArianeService,
private popInService: PopInService) {
// nothing to do.
@ -135,13 +130,13 @@ export class UploadScene implements OnInit {
this.arianeService.updateManual(this.route.snapshot.paramMap);
let self = this;
this.listType = [ { value: null, label: '---' } ];
this.listUniverse = [ { value: null, label: '---' } ];
this.listSeries = [ { value: null, label: '---' } ];
this.listSeason = [ { value: null, label: '---' } ];
this.universeService.getData()
this.listPlaylist = [ { value: null, label: '---' } ];
this.listArtist = [ { value: null, label: '---' } ];
this.listAlbum = [ { value: null, label: '---' } ];
this.playlistService.getData()
.then((response2) => {
for(let iii = 0; iii < response2.length; iii++) {
self.listUniverse.push({ value: response2[iii].id, label: response2[iii].name });
self.listPlaylist.push({ value: response2[iii].id, label: response2[iii].name });
}
}).catch((response2) => {
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
@ -158,7 +153,7 @@ export class UploadScene implements OnInit {
}
onChangeType(value: any): void {
this.seriesId = null;
this.artistId = null;
this.updateType(value);
}
@ -168,17 +163,17 @@ export class UploadScene implements OnInit {
return;
}
this.typeId = value;
// this.data.series_id = null;
// this.data.season_id = null;
this.listSeries = [ { value: null, label: '---' } ];
this.listSeason = [ { value: null, label: '---' } ];
// this.data.artist_id = null;
// this.data.album_id = null;
this.listArtist = [ { value: null, label: '---' } ];
this.listAlbum = [ { value: null, label: '---' } ];
let self = this;
this.updateNeedSend();
if(this.typeId !== null) {
self.typeService.getSubSeries(this.typeId)
self.typeService.getSubArtist(this.typeId)
.then((response2) => {
for(let iii = 0; iii < response2.length; iii++) {
self.listSeries.push({ value: response2[iii].id, label: response2[iii].name });
self.listArtist.push({ value: response2[iii].id, label: response2[iii].name });
}
}).catch((response2) => {
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
@ -186,24 +181,24 @@ export class UploadScene implements OnInit {
}
}
onChangeSeries(value: any): void {
this.seriesId = value;
onChangeArtist(value: any): void {
this.artistId = value;
if(!(value === undefined || value === null)) {
for(let iii = 0; iii < this.listSeries.length; iii++) {
if(this.listSeries[iii].value === value) {
this.globalSeries = this.listSeries[iii].label;
for(let iii = 0; iii < this.listArtist.length; iii++) {
if(this.listArtist[iii].value === value) {
this.globalArtist = this.listArtist[iii].label;
break;
}
}
}
this.updateNeedSend();
this.updateListOfVideoToCheck();
this.updateListOfTrackToCheck();
}
onSeason(value: any): void {
this.globalSeason = value;
// console.log("change episode ID: " + value + " ==> " + this.parseSeason.toString());
onAlbum(value: any): void {
this.globalAlbum = value;
// console.log("change episode ID: " + value + " ==> " + this.parseAlbum.toString());
this.updateNeedSend();
this.updateListOfVideoToCheck();
this.updateListOfTrackToCheck();
}
onTitle(data: FileParsedElement, value: any): void {
@ -221,8 +216,8 @@ export class UploadScene implements OnInit {
this.updateNeedSend();
}
onUniverse(value: any): void {
this.globalUniverse = value;
onPlaylist(value: any): void {
this.globalPlaylist = value;
this.updateNeedSend();
}
@ -232,25 +227,25 @@ export class UploadScene implements OnInit {
this.updateNeedSend();
}
onSeries(value: any): void {
this.globalSeries = value;
onArtist(value: any): void {
this.globalArtist = value;
let self = this;
if(this.globalSeries !== '') {
this.seriesService.getLike(this.globalSeries)
if(this.globalArtist !== '') {
this.artistService.getLike(this.globalArtist)
.then((response: any[]) => {
console.log(`find element: ${ response.length}`);
for(let iii = 0; iii < response.length; iii++) {
console.log(` - ${ JSON.stringify(response[iii])}`);
}
if(response.length === 0) {
self.seriesId = null;
self.artistId = null;
} else if(response.length === 1) {
self.seriesId = response[0].id;
self.artistId = response[0].id;
}
self.updateListOfVideoToCheck();
self.updateListOfTrackToCheck();
}).catch((response) => {
console.log('CAN NOT find element: ');
self.seriesId = null;
self.artistId = null;
});
}
this.updateNeedSend();
@ -258,25 +253,25 @@ export class UploadScene implements OnInit {
clearData() {
this.globalUniverse = '';
this.globalSeries = '';
this.globalSeason = null;
this.globalPlaylist = '';
this.globalArtist = '';
this.globalAlbum = null;
this.parsedElement = [];
this.parsedFailedElement = [];
this.listFileInBdd = null;
this.typeId = null;
this.seriesId = null;
this.artistId = null;
this.saisonId = null;
this.listSeries = [ { value: null, label: '---' } ];
this.listSeason = [ { value: null, label: '---' } ];
this.listArtist = [ { value: null, label: '---' } ];
this.listAlbum = [ { value: null, label: '---' } ];
}
addFileWithMetaData(file: File) {
// parsedElement: FileParsedElement[] = [];
let universe: string = null;
let series: string = null;
let season: number | null = null;
let playlist: string = null;
let artist: string = null;
let album: number | null = null;
let episode: number | null = null;
let title: string = '';
@ -292,7 +287,7 @@ export class UploadScene implements OnInit {
title = splitElement[0];
} else {
if(splitElement.length >= 2) {
series = splitElement[0];
artist = splitElement[0];
}
splitElement.splice(0, 1);
if(splitElement.length === 1) {
@ -301,10 +296,10 @@ export class UploadScene implements OnInit {
while(splitElement.length > 0) {
let element = splitElement[0];
let find = false;
if(season === null) {
if(album === null) {
if(element.length >= 1 && (element[0] === 's' || element[0] === 'S')) {
element = element.substring(1);
season = parseInt(element, 10);
album = parseInt(element, 10);
find = true;
}
}
@ -316,11 +311,11 @@ export class UploadScene implements OnInit {
}
}
if(find === false) {
if(season === null && episode === null) {
if(universe === '') {
universe = element;
if(album === null && episode === null) {
if(playlist === '') {
playlist = element;
} else {
universe = `${universe }-${ element}`;
playlist = `${playlist }-${ element}`;
}
} else if(title === '') {
title = element;
@ -335,12 +330,12 @@ export class UploadScene implements OnInit {
if(isNaN(episode)) {
episode = null;
}
if(isNaN(season)) {
season = null;
if(isNaN(album)) {
album = null;
}
// remove extention
title = title.replace(new RegExp('\\.(mkv|MKV|Mkv|webm|WEBM|Webm|mp4)'), '');
let tmp = new FileParsedElement(file, universe, series, season, episode, title);
let tmp = new FileParsedElement(file, playlist, artist, album, episode, title);
console.log(`==>${ JSON.stringify(tmp)}`);
// add it in the list.
this.parsedElement.push(tmp);
@ -363,58 +358,58 @@ export class UploadScene implements OnInit {
// we verify fith the first value to remove all unknown ...
// clean different univers:
for(let iii = 1; iii < this.parsedElement.length; iii++) {
console.log(`check universe [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[0].universe } !== ${ this.parsedElement[iii].universe }'`);
if(this.parsedElement[0].universe !== this.parsedElement[iii].universe) {
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, 'Remove from list due to wrong universe value'));
console.log(`Remove from list (!= universe) : [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[iii].file.name }'`);
console.log(`check playlist [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[0].playlist } !== ${ this.parsedElement[iii].playlist }'`);
if(this.parsedElement[0].playlist !== this.parsedElement[iii].playlist) {
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, 'Remove from list due to wrong playlist value'));
console.log(`Remove from list (!= playlist) : [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[iii].file.name }'`);
this.parsedElement.splice(iii, 1);
iii--;
}
}
// clean different series:
// clean different artist:
for(let iii = 1; iii < this.parsedElement.length; iii++) {
console.log(`check series [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[0].series } !== ${ this.parsedElement[iii].series }'`);
if(this.parsedElement[0].series !== this.parsedElement[iii].series) {
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, 'Remove from list due to wrong series value'));
console.log(`Remove from list (!= series) : [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[iii].file.name }'`);
console.log(`check artist [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[0].artist } !== ${ this.parsedElement[iii].artist }'`);
if(this.parsedElement[0].artist !== this.parsedElement[iii].artist) {
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, 'Remove from list due to wrong artist value'));
console.log(`Remove from list (!= artist) : [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[iii].file.name }'`);
this.parsedElement.splice(iii, 1);
iii--;
}
}
// clean different season:
// clean different album:
for(let iii = 1; iii < this.parsedElement.length; iii++) {
console.log(`check season [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[0].season } !== ${ this.parsedElement[iii].season }'`);
if(this.parsedElement[0].season !== this.parsedElement[iii].season) {
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, 'Remove from list due to wrong season value'));
console.log(`Remove from list (!= season) : [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[iii].file.name }'`);
console.log(`check album [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[0].album } !== ${ this.parsedElement[iii].album }'`);
if(this.parsedElement[0].album !== this.parsedElement[iii].album) {
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, 'Remove from list due to wrong album value'));
console.log(`Remove from list (!= album) : [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[iii].file.name }'`);
this.parsedElement.splice(iii, 1);
iii--;
}
}
console.log(`check : ${JSON.stringify(this.parsedElement[0])}`)
this.globalUniverse = this.parsedElement[0].universe ?? '';
this.globalSeries = this.parsedElement[0].series ?? '';
this.globalSeason = this.parsedElement[0].season ?? null;
this.globalPlaylist = this.parsedElement[0].playlist ?? '';
this.globalArtist = this.parsedElement[0].artist ?? '';
this.globalAlbum = this.parsedElement[0].album ?? null;
this.updateNeedSend();
this.seriesId = null;
this.artistId = null;
this.saisonId = null;
let self = this;
if(this.globalSeries !== '') {
this.seriesService.getLike(this.globalSeries)
if(this.globalArtist !== '') {
this.artistService.getLike(this.globalArtist)
.then((response: any[]) => {
console.log(`find element: ${ response.length}`);
for(let iii = 0; iii < response.length; iii++) {
console.log(` - ${ JSON.stringify(response[iii])}`);
}
if(response.length === 0) {
self.seriesId = null;
self.artistId = null;
} else if(response.length === 1) {
let serieElem = response[0];
self.seriesId = serieElem.id;
self.artistId = serieElem.id;
self.updateType(serieElem.parentId);
}
self.updateListOfVideoToCheck();
self.updateListOfTrackToCheck();
}).catch((response) => {
console.log('CAN NOT find element: ');
});
@ -447,23 +442,23 @@ export class UploadScene implements OnInit {
let self = this;
self.upload.labelMediaTitle = '';
// add universe
if(self.globalUniverse !== null) {
self.upload.labelMediaTitle = self.upload.labelMediaTitle + self.globalUniverse;
// add playlist
if(self.globalPlaylist !== null) {
self.upload.labelMediaTitle = self.upload.labelMediaTitle + self.globalPlaylist;
}
// add series
if(self.globalSeries !== null) {
// add artist
if(self.globalArtist !== null) {
if(self.upload.labelMediaTitle.length !== 0) {
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }:`;
}
self.upload.labelMediaTitle = self.upload.labelMediaTitle + self.globalSeries;
self.upload.labelMediaTitle = self.upload.labelMediaTitle + self.globalArtist;
}
// add season
if(self.globalSeason !== null && self.globalSeason !== undefined && self.globalSeason.toString().length !== 0) {
// add album
if(self.globalAlbum !== null && self.globalAlbum !== undefined && self.globalAlbum.toString().length !== 0) {
if(self.upload.labelMediaTitle.length !== 0) {
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }-`;
}
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }s${ self.globalSeason.toString()}`;
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }s${ self.globalAlbum.toString()}`;
}
// add episode ID
if(eleemnent.episode !== null && eleemnent.episode !== undefined && eleemnent.episode.toString().length !== 0) {
@ -478,11 +473,11 @@ export class UploadScene implements OnInit {
}
self.upload.labelMediaTitle = `[${ id + 1 }/${ total }]${ self.upload.labelMediaTitle }${eleemnent.title}`;
self.videoService.uploadFile(eleemnent.file,
self.globalUniverse,
self.globalSeries,
self.seriesId,
self.globalSeason,
self.trackService.uploadFile(eleemnent.file,
self.globalPlaylist,
self.globalArtist,
self.artistId,
self.globalAlbum,
eleemnent.episode,
eleemnent.title,
self.typeId,
@ -492,7 +487,7 @@ export class UploadScene implements OnInit {
self.upload.mediaSize = totalTmp;
})
.then((response) => {
console.log(`get response of video : ${ JSON.stringify(response, null, 2)}`);
console.log(`get response of track : ${ JSON.stringify(response, null, 2)}`);
sendDone();
}).catch((response) => {
// self.error = "Can not get the data";
@ -548,19 +543,19 @@ export class UploadScene implements OnInit {
}
}
updateListOfVideoToCheck(): void {
// No series ID set ==> nothing to do.
if(this.seriesId === null) {
updateListOfTrackToCheck(): void {
// No artist ID set ==> nothing to do.
if(this.artistId === null) {
this.listFileInBdd = null;
return;
}
let self = this;
// no season check only the series files.
if(this.globalSeason === null) {
self.seriesService.getVideo(self.seriesId)
// no album check only the artist files.
if(this.globalAlbum === null) {
self.artistService.getTrack(self.artistId)
.then((response: any[]) => {
self.listFileInBdd = response;
// console.log("find video: " + response.length);
// console.log("find track: " + response.length);
// for (let iii = 0; iii<response.length; iii++) {
// console.log(" - " + JSON.stringify(response[iii]));
// }
@ -572,13 +567,13 @@ export class UploadScene implements OnInit {
}
self.saisonId = null;
// set 1 find the ID of the season:
this.seriesService.getSeason(this.seriesId)
// set 1 find the ID of the album:
this.artistService.getAlbum(this.artistId)
.then((response: any[]) => {
// console.log("find season: " + response.length);
// console.log("find album: " + response.length);
for(let iii = 0; iii < response.length; iii++) {
// console.log(" - " + JSON.stringify(response[iii]) + 'compare with : ' + JSON.stringify(self.globalSeason));
if(response[iii].name === `${self.globalSeason}`) {
// console.log(" - " + JSON.stringify(response[iii]) + 'compare with : ' + JSON.stringify(self.globalAlbum));
if(response[iii].name === `${self.globalAlbum}`) {
self.saisonId = response[iii].id;
break;
}
@ -586,10 +581,10 @@ export class UploadScene implements OnInit {
if(self.saisonId === null) {
return;
}
self.seasonService.getVideo(self.saisonId)
self.albumService.getTrack(self.saisonId)
.then((response2: any[]) => {
self.listFileInBdd = response2;
// console.log("find video: " + response2.length);
// console.log("find track: " + response2.length);
// for (let iii = 0; iii<response2.length; iii++) {
// console.log(" - " + JSON.stringify(response2[iii]));
// }
@ -602,37 +597,37 @@ export class UploadScene implements OnInit {
});
}
eventPopUpSeason(event: string): void {
eventPopUpAlbum(event: string): void {
console.log(`GET event: ${ event}`);
this.popInService.close('popin-new-season');
this.popInService.close('popin-new-album');
}
eventPopUpSeries(event: string): void {
eventPopUpArtist(event: string): void {
console.log(`GET event: ${ event}`);
this.popInService.close('popin-new-series');
this.popInService.close('popin-new-artist');
}
eventPopUpType(event: string): void {
console.log(`GET event: ${ event}`);
this.popInService.close('popin-new-type');
}
eventPopUpUniverse(event: string): void {
eventPopUpPlaylist(event: string): void {
console.log(`GET event: ${ event}`);
this.popInService.close('popin-new-universe');
this.popInService.close('popin-new-playlist');
}
newSeason(): void {
console.log('Request new Season...');
this.popInService.open('popin-new-season');
newAlbum(): void {
console.log('Request new Album...');
this.popInService.open('popin-new-album');
}
newSeries(): void {
console.log('Request new Series...');
this.popInService.open('popin-new-series');
newArtist(): void {
console.log('Request new Artist...');
this.popInService.open('popin-new-artist');
}
newType(): void {
console.log('Request new Type...');
this.popInService.open('popin-create-type');
}
newUniverse() {
console.log('Request new Universe...');
this.popInService.open('popin-new-universe');
newPlaylist() {
console.log('Request new Playlist...');
this.popInService.open('popin-new-playlist');
}
}

View File

@ -80,48 +80,48 @@
</div>
<div class="request_raw">
<div class="label">
Universe:
Playlist:
</div>
<div class="input">
<select [ngModel]="data.universeId"
(ngModelChange)="onChangeUniverse($event)">
<option *ngFor="let element of listUniverse" [ngValue]="element.value">{{element.label}}</option>
<select [ngModel]="data.playlistId"
(ngModelChange)="onChangePlaylist($event)">
<option *ngFor="let element of listPlaylist" [ngValue]="element.value">{{element.label}}</option>
</select>
</div>
<div class="input_add">
<button class="button color-button-normal color-shadow-black" (click)="newUniverse()" type="submit">
<button class="button color-button-normal color-shadow-black" (click)="newPlaylist()" type="submit">
<i class="material-icons">add_circle_outline</i>
</button>
</div>
</div>
<div class="request_raw">
<div class="label">
Series:
Artist:
</div>
<div class="input">
<select [ngModel]="data.seriesId"
(ngModelChange)="onChangeSeries($event)">
<option *ngFor="let element of listSeries" [ngValue]="element.value">{{element.label}}</option>
<select [ngModel]="data.artistId"
(ngModelChange)="onChangeArtist($event)">
<option *ngFor="let element of listArtist" [ngValue]="element.value">{{element.label}}</option>
</select>
</div>
<div class="input_add">
<button class="button color-button-normal color-shadow-black" (click)="newSeries()" type="submit">
<button class="button color-button-normal color-shadow-black" (click)="newArtist()" type="submit">
<i class="material-icons">add_circle_outline</i>
</button>
</div>
</div>
<div class="request_raw">
<div class="label">
Season:
Album:
</div>
<div class="input">
<select [ngModel]="data.seasonId"
(ngModelChange)="onChangeSeason($event)">
<option *ngFor="let element of listSeason" [ngValue]="element.value">{{element.label}}</option>
<select [ngModel]="data.albumId"
(ngModelChange)="onChangeAlbum($event)">
<option *ngFor="let element of listAlbum" [ngValue]="element.value">{{element.label}}</option>
</select>
</div>
<div class="input_add">
<button class="button color-button-normal color-shadow-black" (click)="newSeason()" type="submit">
<button class="button color-button-normal color-shadow-black" (click)="newAlbum()" type="submit">
<i class="material-icons">add_circle_outline</i>
</button>
</div>
@ -221,37 +221,37 @@
[imageUrl]=confirmDeleteImageUrl
(callback)="deleteConfirmed()"></delete-confirm>
<app-popin id="popin-new-season"
popTitle="Create a new season"
<app-popin id="popin-new-album"
popTitle="Create a new album"
closeTopRight="true"
closeTitle="Cancel"
validateTitle="Create"
(callback)="eventPopUpSeason($event[0])">
(callback)="eventPopUpAlbum($event[0])">
<p>
Name: <!-- <input type="text" [(ngModel)]="bodyText" /> -->
</p>
</app-popin>
<app-popin id="popin-new-series"
<app-popin id="popin-new-artist"
popSize="small"
popTitle="Create a new series"
popTitle="Create a new artist"
closeTopRight="true"
closeTitle="Cancel"
validateTitle="Create"
(callback)="eventPopUpSeries($event[0])">
(callback)="eventPopUpArtist($event[0])">
<p>
Name: <!-- <input type="text" [(ngModel)]="bodyText" /> -->
</p>
</app-popin>
<app-popin id="popin-new-universe"
<app-popin id="popin-new-playlist"
popSize="big"
popTitle="Create a new universe"
popTitle="Create a new playlist"
closeTopRight="true"
closeTitle="Cancel"
validateTitle="Create"
(callback)="eventPopUpUniverse($event[0])">
(callback)="eventPopUpPlaylist($event[0])">
<p>
Name: <!-- <input type="text" [(ngModel)]="bodyText" /> -->
</p>

View File

@ -8,14 +8,11 @@ import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { PopInService } from '../../service/popin';
import { TypeService } from '../../service/type';
import { UniverseService } from '../../service/universe';
import { SeriesService } from '../../service/series';
import { VideoService } from '../../service/video';
import { ArianeService } from '../../service/ariane';
import { UploadProgress } from '../../popin/upload-progress/upload-progress';
import { NodeData } from '../../model';
import { DataService, GenderService, PlaylistService, ArtistService, TrackService, 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';
export interface ElementList {
value?: number;
@ -27,9 +24,9 @@ class DataToSend {
name:string = '';
description:string = '';
episode?:number;
universeId:number = null;
seriesId:number = null;
seasonId:number = null;
playlistId:number = null;
artistId:number = null;
albumId:number = null;
dataId:number = -1;
time?:number;
typeId:number = null;
@ -40,9 +37,9 @@ class DataToSend {
tmp.name = this.name;
tmp.description = this.description;
tmp.episode = this.episode;
tmp.universeId = this.universeId;
tmp.seriesId = this.seriesId;
tmp.seasonId = this.seasonId;
tmp.playlistId = this.playlistId;
tmp.artistId = this.artistId;
tmp.albumId = this.albumId;
tmp.dataId = this.dataId;
tmp.time = this.time;
tmp.typeId = this.typeId;
@ -53,13 +50,13 @@ class DataToSend {
}
@Component({
selector: 'app-video-edit',
templateUrl: './video-edit.html',
styleUrls: [ './video-edit.less' ]
selector: 'app-track-edit',
templateUrl: './track-edit.html',
styleUrls: [ './track-edit.less' ]
})
export class VideoEditScene implements OnInit {
idVideo:number = -1;
export class TrackEditScene implements OnInit {
idTrack:number = -1;
itemIsRemoved:boolean = false;
itemIsNotFound:boolean = false;
itemIsLoading:boolean = true;
@ -103,23 +100,25 @@ export class VideoEditScene implements OnInit {
listType: ElementList[] = [
{ value: undefined, label: '---' },
];
listUniverse: ElementList[] = [
listPlaylist: ElementList[] = [
{ value: undefined, label: '---' },
{ value: null, label: '---' },
];
listSeries: ElementList[] = [
listArtist: ElementList[] = [
{ value: undefined, label: '---' },
];
listSeason: ElementList[] = [
listAlbum: ElementList[] = [
{ value: undefined, label: '---' },
];
constructor(private route: ActivatedRoute,
private typeService: TypeService,
private universeService: UniverseService,
private seriesService: SeriesService,
private videoService: VideoService,
private arianeService: ArianeService,
private popInService: PopInService) {
constructor(
private route: ActivatedRoute,
private typeService: GenderService,
private playlistService: PlaylistService,
private artistService: ArtistService,
private trackService: TrackService,
private arianeService: ArianeService,
private popInService: PopInService,
private dataService: DataService) {
}
@ -140,13 +139,13 @@ export class VideoEditScene implements OnInit {
if(this.data.typeId !== this.dataOri.typeId) {
this.needSend = true;
}
if(this.data.universeId !== this.dataOri.universeId) {
if(this.data.playlistId !== this.dataOri.playlistId) {
this.needSend = true;
}
if(this.data.seriesId !== this.dataOri.seriesId) {
if(this.data.artistId !== this.dataOri.artistId) {
this.needSend = true;
}
if(this.data.seasonId !== this.dataOri.seasonId) {
if(this.data.albumId !== this.dataOri.albumId) {
this.needSend = true;
}
return this.needSend;
@ -160,7 +159,7 @@ export class VideoEditScene implements OnInit {
this.data.covers.push(covers[iii]);
this.coversDisplay.push({
id:covers[iii],
url:this.videoService.getCoverThumbnailUrl(covers[iii])
url:this.dataService.getCoverThumbnailUrl(covers[iii])
});
}
} else {
@ -169,16 +168,16 @@ export class VideoEditScene implements OnInit {
}
ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap);
this.idVideo = this.arianeService.getVideoId();
this.idTrack = this.arianeService.getTrackId();
let self = this;
this.listType = [ { value: null, label: '---' } ];
this.listUniverse = [ { value: null, label: '---' } ];
this.listSeries = [ { value: null, label: '---' } ];
this.listSeason = [ { value: null, label: '---' } ];
this.universeService.getData()
this.listPlaylist = [ { value: null, label: '---' } ];
this.listArtist = [ { value: null, label: '---' } ];
this.listAlbum = [ { value: null, label: '---' } ];
this.playlistService.getData()
.then((response2) => {
for(let iii = 0; iii < response2.length; iii++) {
self.listUniverse.push({ value: response2[iii].id, label: response2[iii].name });
self.listPlaylist.push({ value: response2[iii].id, label: response2[iii].name });
}
}).catch((response2) => {
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
@ -191,34 +190,34 @@ export class VideoEditScene implements OnInit {
}).catch((response2) => {
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
});
// this.seriesService.getOrder()
this.seriesService.getData()
// this.artistService.getOrder()
this.artistService.getData()
.then((response3) => {
for(let iii = 0; iii < response3.length; iii++) {
self.listSeries.push({ value: response3[iii].id, label: response3[iii].name });
console.log(`[${ self.data.dataId }] Get series: ${ response3[iii].id }, label:${ response3[iii].name}`);
self.listArtist.push({ value: response3[iii].id, label: response3[iii].name });
console.log(`[${ self.data.dataId }] Get artist: ${ response3[iii].id }, label:${ response3[iii].name}`);
}
}).catch((response3) => {
console.log(`get response3 : ${ JSON.stringify(response3, null, 2)}`);
});
this.videoService.get(this.idVideo)
.then((response) => {
console.log(`get response of video : ${ JSON.stringify(response, null, 2)}`);
this.trackService.get(this.idTrack)
.then((response: Media) => {
console.log(`get response of track : ${ JSON.stringify(response, null, 2)}`);
self.data.name = response.name;
self.data.description = response.description;
self.data.episode = response.episode;
self.data.universeId = response.universId;
if(self.data.universeId === undefined) {
self.data.universeId = null;
self.data.playlistId = response.playlistId;
if(self.data.playlistId === undefined) {
self.data.playlistId = null;
}
self.data.dataId = response.dataId;
self.data.time = response.time;
self.data.generatedName = response.generatedName;
self.data.generatedName = "????????? TODO ????????? "; // response.generatedName;
self.onChangeType(response.typeId);
self.onChangeSeries(response.seriesId);
self.data.seasonId = response.seasonId;
if(self.data.seasonId === undefined) {
self.data.seasonId = null;
self.onChangeArtist(response.artistId);
self.data.albumId = response.albumId;
if(self.data.albumId === undefined) {
self.data.albumId = null;
}
self.dataOri = self.data.clone();
self.updateCoverList(response.covers);
@ -242,17 +241,17 @@ export class VideoEditScene implements OnInit {
if(this.data.typeId === undefined) {
this.data.typeId = null;
}
this.data.seriesId = null;
this.data.seasonId = null;
this.listSeries = [ { value: undefined, label: '---' } ];
this.listSeason = [ { value: undefined, label: '---' } ];
this.data.artistId = null;
this.data.albumId = null;
this.listArtist = [ { value: undefined, label: '---' } ];
this.listAlbum = [ { value: undefined, label: '---' } ];
let self = this;
this.updateNeedSend();
if(this.data.typeId !== undefined) {
self.typeService.getSubSeries(this.data.typeId)
self.typeService.getSubArtist(this.data.typeId)
.then((response2: NodeData[]) => {
for(let iii = 0; iii < response2.length; iii++) {
self.listSeries.push({ value: response2[iii].id, label: response2[iii].name });
self.listArtist.push({ value: response2[iii].id, label: response2[iii].name });
}
}).catch((response2) => {
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
@ -260,24 +259,24 @@ export class VideoEditScene implements OnInit {
}
}
onChangeUniverse(value:any):void {
this.data.universeId = value;
onChangePlaylist(value:any):void {
this.data.playlistId = value;
this.updateNeedSend();
}
onChangeSeries(value:any):void {
this.data.seriesId = value;
if(this.data.seriesId === undefined) {
this.data.seriesId = null;
onChangeArtist(value:any):void {
this.data.artistId = value;
if(this.data.artistId === undefined) {
this.data.artistId = null;
}
this.data.seasonId = null;
this.listSeason = [ { value: undefined, label: '---' } ];
this.data.albumId = null;
this.listAlbum = [ { value: undefined, label: '---' } ];
let self = this;
if(this.data.seriesId !== undefined) {
self.seriesService.getSeason(this.data.seriesId)
if(this.data.artistId !== undefined) {
self.artistService.getAlbum(this.data.artistId)
.then((response3: NodeData[]) => {
for(let iii = 0; iii < response3.length; iii++) {
self.listSeason.push({ value: response3[iii].id, label: `season ${ response3[iii].name}` });
self.listAlbum.push({ value: response3[iii].id, label: `album ${ response3[iii].name}` });
}
}).catch((response3) => {
console.log(`get response22 : ${ JSON.stringify(response3, null, 2)}`);
@ -285,8 +284,8 @@ export class VideoEditScene implements OnInit {
}
this.updateNeedSend();
}
onChangeSeason(value:any):void {
this.data.seasonId = value;
onChangeAlbum(value:any):void {
this.data.albumId = value;
this.updateNeedSend();
}
@ -350,30 +349,30 @@ export class VideoEditScene implements OnInit {
data.typeId = this.data.typeId;
}
}
if(this.data.universeId !== this.dataOri.universeId) {
if(this.data.universeId === undefined) {
data.universeId = null;
if(this.data.playlistId !== this.dataOri.playlistId) {
if(this.data.playlistId === undefined) {
data.playlistId = null;
} else {
data.universeId = this.data.universeId;
data.playlistId = this.data.playlistId;
}
}
if(this.data.seriesId !== this.dataOri.seriesId) {
if(this.data.seriesId === undefined) {
data.seriesId = null;
if(this.data.artistId !== this.dataOri.artistId) {
if(this.data.artistId === undefined) {
data.artistId = null;
} else {
data.seriesId = this.data.seriesId;
data.artistId = this.data.artistId;
}
}
if(this.data.seasonId !== this.dataOri.seasonId) {
if(this.data.seasonId === undefined) {
data.seasonId = null;
if(this.data.albumId !== this.dataOri.albumId) {
if(this.data.albumId === undefined) {
data.albumId = null;
} else {
data.seasonId = this.data.seasonId;
data.albumId = this.data.albumId;
}
}
let tmpp = this.data.clone();
let self = this;
this.videoService.put(this.idVideo, data)
this.trackService.put(this.idTrack, data)
.then((response3) => {
self.dataOri = tmpp;
self.updateNeedSend();
@ -418,7 +417,7 @@ 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.trackService.uploadCover(file, this.idTrack, (count, total) => {
self.upload.mediaSendSize = count;
self.upload.mediaSize = total;
})
@ -429,7 +428,7 @@ export class VideoEditScene implements OnInit {
self.updateCoverList(response.covers);
}).catch((response:any) => {
// self.error = "Can not get the data";
console.log('Can not add the cover in the video...');
console.log('Can not add the cover in the track...');
self.upload.error = `Error in the upload of the cover...${ JSON.stringify(response, null, 2)}`;
});
}
@ -437,14 +436,14 @@ export class VideoEditScene implements OnInit {
removeCover(id:number) {
this.cleanConfirm();
this.confirmDeleteComment = `Delete the cover ID: ${ id}`;
this.confirmDeleteImageUrl = this.seriesService.getCoverThumbnailUrl(id);
this.confirmDeleteImageUrl = this.dataService.getCoverThumbnailUrl(id);
this.deleteCoverId = id;
this.popInService.open('popin-delete-confirm');
}
removeCoverAfterConfirm(id:number) {
console.log(`Request remove cover: ${ id}`);
let self = this;
this.videoService.deleteCover(this.idVideo, id)
this.trackService.deleteCover(this.idTrack, id)
.then((response:any) => {
console.log(`get response of remove cover : ${ JSON.stringify(response, null, 2)}`);
self.upload.result = 'Cover remove done';
@ -452,20 +451,20 @@ export class VideoEditScene implements OnInit {
self.updateCoverList(response.covers);
}).catch((response:any) => {
// self.error = "Can not get the data";
console.log('Can not remove the cover of the video...');
console.log('Can not remove the cover of the track...');
self.upload.error = `Error in the upload of the cover...${ JSON.stringify(response, null, 2)}`;
});
}
removeItem() {
console.log('Request remove Media...');
this.cleanConfirm();
this.confirmDeleteComment = `Delete the Media: ${ this.idVideo}`;
this.deleteMediaId = this.idVideo;
this.confirmDeleteComment = `Delete the Media: ${ this.idTrack}`;
this.deleteMediaId = this.idTrack;
this.popInService.open('popin-delete-confirm');
}
removeItemAfterConfirm(id:number) {
let self = this;
this.videoService.delete(id)
this.trackService.delete(id)
.then((response3) => {
// self.dataOri = tmpp;
// self.updateNeedSend();
@ -475,38 +474,38 @@ export class VideoEditScene implements OnInit {
});
}
eventPopUpSeason(event: string): void {
eventPopUpAlbum(event: string): void {
console.log(`GET event: ${ event}`);
this.popInService.close('popin-new-season');
this.popInService.close('popin-new-album');
}
eventPopUpSeries(event: string): void {
eventPopUpArtist(event: string): void {
console.log(`GET event: ${ event}`);
this.popInService.close('popin-new-series');
this.popInService.close('popin-new-artist');
}
eventPopUpType(event: string): void {
console.log(`GET event: ${ event}`);
this.popInService.close('popin-new-type');
}
eventPopUpUniverse(event: string): void {
eventPopUpPlaylist(event: string): void {
console.log(`GET event: ${ event}`);
this.popInService.close('popin-new-universe');
this.popInService.close('popin-new-playlist');
}
newSeason(): void {
console.log('Request new Season...');
this.popInService.open('popin-new-season');
newAlbum(): void {
console.log('Request new Album...');
this.popInService.open('popin-new-album');
}
newSeries(): void {
console.log('Request new Series...');
this.popInService.open('popin-new-series');
newArtist(): void {
console.log('Request new Artist...');
this.popInService.open('popin-new-artist');
}
newType(): void {
console.log('Request new Type...');
this.popInService.open('popin-create-type');
}
newUniverse() {
console.log('Request new Universe...');
this.popInService.open('popin-new-universe');
newPlaylist() {
console.log('Request new Playlist...');
this.popInService.open('popin-new-playlist');
}
}

View File

@ -13,16 +13,16 @@
</div>
</div>
<div class="fill-all" *ngIf="!mediaIsNotFound && !mediaIsLoading && !playVideo">
<div class="fill-all" *ngIf="!mediaIsNotFound && !mediaIsLoading && !playTrack">
<div class="title">
{{name}}
</div>
<div class="cover-full">
<div class="cover">
<div class="cover-image" *ngIf="cover !== null">
<img src="{{cover}}"/>
<div class="cover-image" *ngIf="covers">
<img src="{{covers[0]}}"/>
</div>
<div class="cover-no-image" *ngIf="cover == null"></div>
<div class="cover-no-image" *ngIf="covers"></div>
<div class="cover-button">
<button (click)="onRequirePlay()">
<i class="material-icons big-button">play_circle_outline</i>
@ -41,11 +41,11 @@
</div>
</div>
<div class="clear"></div>
<div class="episode" *ngIf="seriesName!=null">
<b>Series:</b> {{seriesName}}
<div class="episode" *ngIf="artistName!=null">
<b>Artist:</b> {{artistName}}
</div>
<div class="episode" *ngIf="seasonName!=null">
<b>Season:</b> {{seasonName}}
<div class="episode" *ngIf="albumName!=null">
<b>Album:</b> {{albumName}}
</div>
<div class="episode" *ngIf="episode!=null">
<b>Episode:</b> {{episode}}
@ -57,14 +57,14 @@
{{description}}
</div>
</div>
<div class="fill-all bg-black" *ngIf="playVideo">
<div class="video"
<div class="fill-all bg-black" *ngIf="playTrack">
<div class="track"
#globalVideoElement
(mousemove)="startHideTimer()"
(fullscreenchange)="onFullscreenChange($event)">
<div class="video-elem">
<video src="{{videoSource}}"
#videoPlayer
<div class="track-elem">
<track src="{{trackSource}}"
#trackPlayer
preload
(play)="changeStateToPlay()"
(pause)="changeStateToPause()"
@ -73,10 +73,10 @@
(loadedmetadata)="changeMetadata()"
(audioTracks)="audioTracks($event)"
autoplay
(ended)="onVideoEnded()"
(ended)="onTrackEnded()"
><!-- controls > --> <!--preload="none"-->
<!--<p>Your browser does not support HTML5 video player. download video: <a href="{{videoSource}}>link here</a>.</p>-->
</video>
<!--<p>Your browser does not support HTML5 track player. download track: <a href="{{trackSource}}>link here</a>.</p>-->
</track>
</div>
<div class="controls" *ngIf="!displayNeedHide || !isPlaying">
<button (click)="onPlay()" *ngIf="!isPlaying" ><i class="material-icons">play_arrow</i></button>
@ -108,7 +108,10 @@
<button class="bigForward" (click)="onForward()"><i *ngIf="!isPlaying" class="material-icons">fast_forward</i></button>
</div>
<div class="video-button" *ngIf="!isFullScreen || !isPlaying">
<div class="title-inline" *ngIf="!isFullScreen || !isPlaying">
{{generatedName}}
</div>
<div class="track-button" *ngIf="!isFullScreen || !isPlaying">
<button (click)="onRequireStop()">
<i class="material-icons big-button">highlight_off</i>
</button>
@ -120,8 +123,8 @@
[value]="volumeValue"
(input)="onVolume($event.target)">
</div>
<button (click)="onVolumeMute()" *ngIf="!videoPlayer.muted"><i class="material-icons">volume_mute</i></button>
<button (click)="onVolumeUnMute()" *ngIf="videoPlayer.muted"><i class="material-icons">volume_off</i></button>
<button (click)="onVolumeMute()" *ngIf="!trackPlayer.muted"><i class="material-icons">volume_mute</i></button>
<button (click)="onVolumeUnMute()" *ngIf="trackPlayer.muted"><i class="material-icons">volume_off</i></button>
</div>
</div>
</div>

View File

@ -127,6 +127,15 @@
color: #F00000;
};
};
.title-inline {
position: absolute;
top: 20px;
left:20px;
margin: 0 auto;
font-size: 25px;
color: #888;
//text-align: center;
};
video {

View File

@ -6,44 +6,41 @@
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { HttpWrapperService } from '../../service/http-wrapper';
import { VideoService } from '../../service/video';
import { SeriesService } from '../../service/series';
import { SeasonService } from '../../service/season';
import { ArianeService } from '../../service/ariane';
import { isNullOrUndefined } from '../..//utils';
import { DataService, TrackService, ArtistService, AlbumService, ArianeService } from 'app/service';
import { HttpWrapperService } from 'common/service';
import { isNullOrUndefined } from 'common/utils';
@Component({
selector: 'app-video',
templateUrl: './video.html',
styleUrls: [ './video.less' ]
selector: 'app-track',
templateUrl: './track.html',
styleUrls: [ './track.less' ]
})
export class VideoScene implements OnInit {
videoGlobal:any;
@ViewChild('globalVideoElement')
export class TrackScene implements OnInit {
trackGlobal:any;
@ViewChild('globalTrackElement')
set mainDivEl(el: ElementRef) {
if(el !== null && el !== undefined) {
this.videoGlobal = el.nativeElement;
this.trackGlobal = el.nativeElement;
}
}
videoPlayer: HTMLVideoElement;
}
trackPlayer: HTMLVideoElement;
@ViewChild('videoPlayer')
set mainVideoEl(el: ElementRef) {
set mainTrackEl(el: ElementRef) {
if(el !== null && el !== undefined) {
this.videoPlayer = el.nativeElement;
this.trackPlayer = el.nativeElement;
}
}
}
videoCanva: any;
@ViewChild('canvascreenshoot')
set mainCanvaEl(el: ElementRef) {
if(el !== null && el !== undefined) {
this.videoCanva = el.nativeElement;
}
}
}
haveNext = null;
havePrevious = null;
idVideo:number = -1;
idTrack:number = -1;
mediaIsNotFound:boolean = false;
mediaIsLoading:boolean = true;
@ -52,19 +49,18 @@ export class VideoScene implements OnInit {
name:string = '';
description:string = '';
episode:number = undefined;
seriesId:number = undefined;
seriesName:string = undefined;
seasonId:number = undefined;
seasonName:string = undefined;
artistId:number = undefined;
artistName:string = undefined;
albumId:number = undefined;
albumName:string = undefined;
dataId:number = -1;
time:number = undefined;
typeId:number = undefined;
generatedName:string = '';
videoSource:string = '';
cover:string = null;
covers:Array<string> = [];
trackSource:string = '';
covers: string[];
playVideo:boolean = false;
playTrack:boolean = false;
displayVolumeMenu:boolean = false;
isPlaying:boolean = false;
isFullScreen:boolean = false;
@ -78,11 +74,12 @@ export class VideoScene implements OnInit {
timeLeft: number = 10;
interval = null;
constructor(private route: ActivatedRoute,
private videoService: VideoService,
private seriesService: SeriesService,
private seasonService: SeasonService,
private trackService: TrackService,
private artistService: ArtistService,
private albumService: AlbumService,
private httpService: HttpWrapperService,
private arianeService: ArianeService) {
private arianeService: ArianeService,
private dataService: DataService) {
}
@ -111,24 +108,24 @@ export class VideoScene implements OnInit {
}
onRequireNext(event: any) {
console.log(`generate next : ${ this.haveNext.id}`);
this.arianeService.navigateVideo(this.haveNext.id, event.which === 2, event.ctrlKey);
this.arianeService.setVideo(this.haveNext.id);
this.arianeService.navigateTrack(this.haveNext.id, event.which === 2, event.ctrlKey);
this.arianeService.setTrack(this.haveNext.id);
}
onRequirePrevious(event: any) {
console.log(`generate previous : ${ this.havePrevious.id}`);
this.arianeService.navigateVideo(this.havePrevious.id, event.which === 2, event.ctrlKey);
this.arianeService.setVideo(this.havePrevious.id);
this.arianeService.navigateTrack(this.havePrevious.id, event.which === 2, event.ctrlKey);
this.arianeService.setTrack(this.havePrevious.id);
}
generateName() {
this.generatedName = '';
if(this.seriesName !== undefined) {
this.generatedName = `${this.generatedName }${this.seriesName }-`;
if(this.artistName !== undefined) {
this.generatedName = `${this.generatedName }${this.artistName }-`;
}
if(this.seasonName !== undefined) {
if(this.seasonName.length < 2) {
this.generatedName = `${this.generatedName }s0${ this.seasonName }-`;
if(this.albumName !== undefined) {
if(this.albumName.length < 2) {
this.generatedName = `${this.generatedName }s0${ this.albumName }-`;
} else {
this.generatedName = `${this.generatedName }s${ this.seasonName }-`;
this.generatedName = `${this.generatedName }s${ this.albumName }-`;
}
}
if(this.episode !== undefined) {
@ -142,7 +139,7 @@ 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({
this.trackSource = this.httpService.createRESTCall2({
api: `data/${ this.dataId}/${this.generatedName}`,
addURLToken: true,
});
@ -155,7 +152,7 @@ export class VideoScene implements OnInit {
console.log('list of the stream:');
/*
let captureStream = this.videoPlayer.audioTracks;
let captureStream = this.trackPlayer.audioTracks;
for (let iii=0; iii < captureStream.length; iii++) {
console.log(" - " + captureStream[iii].language);
if (captureStream[iii].language.substring(0,2) === "fr") {
@ -170,7 +167,7 @@ export class VideoScene implements OnInit {
console.log(`list of the stream:${ event}`);
/*
let captureStream = this.videoPlayer.audioTracks;
let captureStream = this.trackPlayer.audioTracks;
for (let iii=0; iii < captureStream.length; iii++) {
console.log(" - " + captureStream[iii].language);
if (captureStream[iii].language.substring(0,2) === "fr") {
@ -186,10 +183,10 @@ export class VideoScene implements OnInit {
let self = this;
this.startHideTimer();
this.arianeService.updateManual(this.route.snapshot.paramMap);
this.idVideo = this.arianeService.getVideoId();
this.arianeService.videoChange.subscribe((videoId) => {
console.log(`Detect videoId change...${ videoId}`);
self.idVideo = videoId;
this.idTrack = this.arianeService.getTrackId();
this.arianeService.trackChange.subscribe((trackId) => {
console.log(`Detect trackId change...${ trackId}`);
self.idTrack = trackId;
self.updateDisplay();
});
self.updateDisplay();
@ -198,53 +195,47 @@ export class VideoScene implements OnInit {
let self = this;
self.haveNext = null;
self.havePrevious = null;
this.videoService.get(this.idVideo)
this.trackService.get(this.idTrack)
.then((response) => {
console.log(`get response of video : ${ JSON.stringify(response, null, 2)}`);
console.log(`get response of track : ${ JSON.stringify(response, null, 2)}`);
self.error = '';
self.name = response.name;
self.description = response.description;
self.episode = response.episode;
self.seriesId = response.seriesId;
self.seasonId = response.seasonId;
self.artistId = response.artistId;
self.albumId = response.albumId;
self.dataId = response.dataId;
self.time = response.time;
self.generatedName = response.generatedName;
self.generatedName = "????????? TODO: ???????" //response.generatedName;
if(self.dataId !== -1) {
self.videoSource = self.httpService.createRESTCall2({
self.trackSource = self.httpService.createRESTCall2({
api: `data/${ self.dataId}/${self.generatedName}`,
addURLToken: true,
});
} else {
self.videoSource = '';
}
if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
self.cover = null;
} else {
self.cover = self.videoService.getCoverUrl(response.covers[0]);
for(let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.videoService.getCoverUrl(response.covers[iii]));
}
self.trackSource = '';
}
self.covers = self.dataService.getCoverListUrl(response.covers);
self.generateName();
if(self.seriesId !== undefined && self.seriesId !== null) {
self.seriesService.get(self.seriesId)
if(self.artistId !== undefined && self.artistId !== null) {
self.artistService.get(self.artistId)
.then((response2) => {
self.seriesName = response2.name;
self.artistName = response2.name;
self.generateName();
}).catch((response3) => {
// nothing to do ...
});
}
if(self.seasonId !== undefined && self.seasonId !== null) {
self.seasonService.get(self.seasonId)
if(self.albumId !== undefined && self.albumId !== null) {
self.albumService.get(self.albumId)
.then((response4) => {
self.seasonName = response4.name;
self.albumName = response4.name;
self.generateName();
}).catch((response5) => {
// nothing to do ...
});
self.seasonService.getVideo(self.seasonId)
self.albumService.getTrack(self.albumId)
.then((response6:any) => {
// console.log("saison property: " + JSON.stringify(response, null, 2));
self.haveNext = null;
@ -266,46 +257,46 @@ export class VideoScene implements OnInit {
self.haveNext = response6[iii];
}
}
self.covers.push(self.seriesService.getCoverUrl(response6[iii]));
self.covers.push(self.dataService.getCoverUrl(response6[iii]));
}
}).catch((response7:any) => {
});
}
self.mediaIsLoading = false;
// console.log("display source " + self.videoSource);
// console.log("display source " + self.trackSource);
// console.log("set transformed : " + JSON.stringify(self, null, 2));
}).catch((response8) => {
self.error = 'Can not get the data';
self.name = '';
self.description = '';
self.episode = undefined;
self.seriesId = undefined;
self.seasonId = undefined;
self.artistId = undefined;
self.albumId = undefined;
self.dataId = -1;
self.time = undefined;
self.generatedName = '';
self.videoSource = '';
self.cover = null;
self.seriesName = undefined;
self.seasonName = undefined;
self.trackSource = '';
self.covers = undefined;
self.artistName = undefined;
self.albumName = undefined;
self.mediaIsNotFound = true;
self.mediaIsLoading = false;
});
}
onRequirePlay() {
this.startHideTimer();
this.playVideo = true;
this.playTrack = true;
this.displayVolumeMenu = false;
}
onRequireStop() {
this.startHideTimer();
this.playVideo = false;
this.playTrack = false;
this.displayVolumeMenu = false;
}
onVideoEnded() {
onTrackEnded() {
this.startHideTimer();
this.playVideo = false;
this.playTrack = false;
this.displayVolumeMenu = false;
/*
@ -350,39 +341,39 @@ export class VideoScene implements OnInit {
changeTimeupdate(currentTime: any) {
// console.log("time change ");
// console.log(" ==> " + this.videoPlayer.currentTime);
this.currentTime = this.videoPlayer.currentTime;
// console.log(" ==> " + this.trackPlayer.currentTime);
this.currentTime = this.trackPlayer.currentTime;
this.currentTimeDisplay = this.convertIndisplayTime(this.currentTime);
// console.log(" ==> " + this.currentTimeDisplay);
}
changeDurationchange(duration: any) {
console.log('duration change ');
console.log(` ==> ${ this.videoPlayer.duration}`);
this.duration = this.videoPlayer.duration;
console.log(` ==> ${ this.trackPlayer.duration}`);
this.duration = this.trackPlayer.duration;
this.durationDisplay = this.convertIndisplayTime(this.duration);
}
onPlay() {
console.log('play');
this.startHideTimer();
if(this.videoPlayer === null ||
this.videoPlayer === undefined) {
console.log(`error element: ${ this.videoPlayer}`);
if(this.trackPlayer === null ||
this.trackPlayer === undefined) {
console.log(`error element: ${ this.trackPlayer}`);
return;
}
this.videoPlayer.volume = this.volumeValue / 100;
this.videoPlayer.play();
this.trackPlayer.volume = this.volumeValue / 100;
this.trackPlayer.play();
}
onPause() {
console.log('pause');
this.startHideTimer();
if(this.videoPlayer === null ||
this.videoPlayer === undefined) {
console.log(`error element: ${ this.videoPlayer}`);
if(this.trackPlayer === null ||
this.trackPlayer === undefined) {
console.log(`error element: ${ this.trackPlayer}`);
return;
}
this.videoPlayer.pause();
this.trackPlayer.pause();
}
onPauseToggle() {
@ -397,13 +388,13 @@ export class VideoScene implements OnInit {
onStop() {
console.log('stop');
this.startHideTimer();
if(this.videoPlayer === null ||
this.videoPlayer === undefined) {
console.log(`error element: ${ this.videoPlayer}`);
if(this.trackPlayer === null ||
this.trackPlayer === undefined) {
console.log(`error element: ${ this.trackPlayer}`);
return;
}
this.videoPlayer.pause();
this.videoPlayer.currentTime = 0;
this.trackPlayer.pause();
this.trackPlayer.currentTime = 0;
}
onBefore() {
@ -419,61 +410,61 @@ export class VideoScene implements OnInit {
seek(newValue:any) {
console.log(`seek ${ newValue.value}`);
this.startHideTimer();
if(this.videoPlayer === null ||
this.videoPlayer === undefined) {
console.log(`error element: ${ this.videoPlayer}`);
if(this.trackPlayer === null ||
this.trackPlayer === undefined) {
console.log(`error element: ${ this.trackPlayer}`);
return;
}
this.videoPlayer.currentTime = newValue.value;
this.trackPlayer.currentTime = newValue.value;
}
onRewind() {
console.log('rewind');
this.startHideTimer();
if(this.videoPlayer === null ||
this.videoPlayer === undefined) {
console.log(`error element: ${ this.videoPlayer}`);
if(this.trackPlayer === null ||
this.trackPlayer === undefined) {
console.log(`error element: ${ this.trackPlayer}`);
return;
}
this.videoPlayer.currentTime = this.currentTime - 10;
this.trackPlayer.currentTime = this.currentTime - 10;
}
onForward() {
console.log('forward');
this.startHideTimer();
if(this.videoPlayer === null ||
this.videoPlayer === undefined) {
console.log(`error element: ${ this.videoPlayer}`);
if(this.trackPlayer === null ||
this.trackPlayer === undefined) {
console.log(`error element: ${ this.trackPlayer}`);
return;
}
this.videoPlayer.currentTime = this.currentTime + 10;
this.trackPlayer.currentTime = this.currentTime + 10;
}
onMore() {
console.log('more');
this.startHideTimer();
if(this.videoPlayer === null ||
this.videoPlayer === undefined) {
console.log(`error element: ${ this.videoPlayer}`);
if(this.trackPlayer === null ||
this.trackPlayer === undefined) {
console.log(`error element: ${ this.trackPlayer}`);
return;
}
}
onFullscreen() {
console.log('fullscreen');
this.startHideTimer();
if(this.videoGlobal === null ||
this.videoGlobal === undefined) {
console.log(`error element: ${ this.videoGlobal}`);
if(this.trackGlobal === null ||
this.trackGlobal === undefined) {
console.log(`error element: ${ this.trackGlobal}`);
return;
}
if(this.videoGlobal.requestFullscreen) {
this.videoGlobal.requestFullscreen();
} else if(this.videoGlobal.mozRequestFullScreen) {
this.videoGlobal.mozRequestFullScreen();
} else if(this.videoGlobal.webkitRequestFullscreen) {
this.videoGlobal.webkitRequestFullscreen();
} else if(this.videoGlobal.msRequestFullscreen) {
this.videoGlobal.msRequestFullscreen();
if(this.trackGlobal.requestFullscreen) {
this.trackGlobal.requestFullscreen();
} else if(this.trackGlobal.mozRequestFullScreen) {
this.trackGlobal.mozRequestFullScreen();
} else if(this.trackGlobal.webkitRequestFullscreen) {
this.trackGlobal.webkitRequestFullscreen();
} else if(this.trackGlobal.msRequestFullscreen) {
this.trackGlobal.msRequestFullscreen();
}
}
@ -483,9 +474,9 @@ export class VideoScene implements OnInit {
onFullscreenExit22(docc:any) {
console.log('fullscreen EXIT');
this.startHideTimer();
if(this.videoGlobal === null ||
this.videoGlobal === undefined) {
console.log(`error element: ${ this.videoGlobal}`);
if(this.trackGlobal === null ||
this.trackGlobal === undefined) {
console.log(`error element: ${ this.trackGlobal}`);
return;
}
if(docc.exitFullscreen) {
@ -519,50 +510,50 @@ export class VideoScene implements OnInit {
onVolume(newValue:any) {
console.log(`onVolume ${ newValue.value}`);
this.startHideTimer();
if(this.videoPlayer === null ||
this.videoPlayer === undefined) {
console.log(`error element: ${ this.videoPlayer}`);
if(this.trackPlayer === null ||
this.trackPlayer === undefined) {
console.log(`error element: ${ this.trackPlayer}`);
return;
}
this.volumeValue = newValue.value;
this.videoPlayer.volume = this.volumeValue / 100;
this.videoPlayer.muted = false;
this.trackPlayer.volume = this.volumeValue / 100;
this.trackPlayer.muted = false;
}
onVolumeMute() {
this.startHideTimer();
if(this.videoPlayer === null ||
this.videoPlayer === undefined) {
console.log(`error element: ${ this.videoPlayer}`);
if(this.trackPlayer === null ||
this.trackPlayer === undefined) {
console.log(`error element: ${ this.trackPlayer}`);
return;
}
this.videoPlayer.muted = true;
this.trackPlayer.muted = true;
}
onVolumeUnMute() {
this.startHideTimer();
if(this.videoPlayer === null ||
this.videoPlayer === undefined) {
console.log(`error element: ${ this.videoPlayer}`);
if(this.trackPlayer === null ||
this.trackPlayer === undefined) {
console.log(`error element: ${ this.trackPlayer}`);
return;
}
this.videoPlayer.muted = false;
this.trackPlayer.muted = false;
}
onTakeScreenShoot() {
this.startHideTimer();
// const canvas = document.createElement("canvas");
// scale the canvas accordingly
this.videoCanva.width = this.videoPlayer.videoWidth;
this.videoCanva.height = this.videoPlayer.videoHeight;
// draw the video at that frame
this.videoCanva.getContext('2d').drawImage(this.videoPlayer, 0, 0, this.videoCanva.width, this.videoCanva.height);
this.videoCanva.width = this.trackPlayer.videoWidth;
this.videoCanva.height = this.trackPlayer.videoHeight;
// draw the track at that frame
this.videoCanva.getContext('2d').drawImage(this.trackPlayer, 0, 0, this.videoCanva.width, this.videoCanva.height);
// 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.trackService.uploadCoverBlob(blob, this.idTrack);
}, 'image/jpeg', 0.95);
/*
@ -570,7 +561,7 @@ export class VideoScene implements OnInit {
fetch(tmpUrl)
.then(res => res.blob()) // Gets the response and returns it as a blob
.then(blob => {
self.videoService.uploadCoverBlob(blob, this.idVideo);
self.trackService.uploadCoverBlob(blob, this.idTrack);
});
*/
}

View File

@ -1,75 +1,61 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { NodeData } from "common/model";
import { HttpWrapperService, BddService } from "common/service";
import { DataInterface, isNullOrUndefined } from "common/utils";
import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper';
import { BddService } from './bdd';
@Injectable()
export class UniverseService {
// 0: Not hide password; 1 hide password;
private identificationVersion: number = 1;
private serviceName:string = 'universe';
constructor(private http: HttpWrapperService,
private bdd: BddService) {
console.log('Start universeService');
export class GenericInterfaceModelDB {
constructor(
protected serviceName:string,
protected http: HttpWrapperService,
protected bdd: BddService) {
// nothing to do ...
}
getData():any {
get(id:number): Promise<NodeData> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getUniverse()
.then((response) => {
let data = response.gets();
resolve(data);
}).catch((response) => {
reject(response);
});
});
}
get(id:number):any {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getUniverse()
.then((response) => {
self.bdd.get(self.serviceName)
.then((response: DataInterface) => {
let data = response.get(id);
if(data === null || data === undefined) {
if(isNullOrUndefined(data)) {
reject('Data does not exist in the local BDD');
return;
}
resolve(data);
return;
}).catch((response) => {
reject(response);
});
});
}
getSubSeries(id:number, select:Array<string> = []):any {
// this.checkLocalBdd();
}
getSubVideo(id:number, select:Array<string> = []):any {
// this.checkLocalBdd();
getData(): Promise<NodeData[]> {
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);
});
});
}
put(id:number, data:any):any {
let ret = this.http.putSpecific(this.serviceName, id, data);
let ret = this.http.putSpecific([this.serviceName, id], data);
return this.bdd.setAfterPut(this.serviceName, id, ret);
}
getCoverUrl(coverId:number):any {
return this.http.createRESTCall(`data/${ coverId}`);
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;
deleteCover(nodeId:number, coverId:number) {
let self = this;
return new Promise((resolve, reject) => {
self.http.getSpecific(`${this.serviceName }/${ nodeId }/rm_cover`, coverId)
self.http.getSpecific([this.serviceName, nodeId, 'rm_cover', coverId])
.then((response) => {
let data = response;
if(data === null || data === undefined) {
@ -88,11 +74,11 @@ export class UniverseService {
progress:any = null) {
const formData = new FormData();
formData.append('fileName', file.name);
formData.append('nodeId', nodeId.toString());
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)
self.http.uploadMultipart(`${this.serviceName }/${nodeId}/add_cover/`, formData, progress)
.then((response) => {
let data = response;
if(data === null || data === undefined) {
@ -106,5 +92,5 @@ export class UniverseService {
});
});
}
}
}

View File

@ -0,0 +1,71 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Injectable } from '@angular/core';
import { NodeData } from 'common/model';
import { HttpWrapperService, BddService } from 'common/service';
import { DataInterface, TypeCheck } from 'common/utils';
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
@Injectable()
export class AlbumService extends GenericInterfaceModelDB {
constructor(http: HttpWrapperService,
bdd: BddService) {
super('album', http, bdd);
}
/**
* Get all the track for a specific album
* @param id - Id of the album.
* @returns a promise on the list of track elements
*/
getTrack(id:number): Promise<NodeData[]> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.get('track')
.then((response: DataInterface) => {
let data = response.getsWhere([
{
check: TypeCheck.EQUAL,
key: 'albumId',
value: id,
},
],
[ 'episode', 'name' ]);
resolve(data);
}).catch((response) => {
reject(response);
});
});
}
/**
* Get the number of track in this saison ID
* @param id - Id of the album.
* @returns The number of element present in this saison
*/
countTrack(id:number): Promise<number> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.get('track')
.then((response: DataInterface) => {
let data = response.getsWhere([
{
check: TypeCheck.EQUAL,
key: 'albumId',
value: id,
},
]);
resolve(data.length);
}).catch((response) => {
reject(response);
});
});
}
}

View File

@ -6,150 +6,151 @@
import { Injectable, Output, EventEmitter } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { Router } from '@angular/router';
import { TypeService } from './type';
import { UniverseService } from './universe';
import { SeriesService } from './series';
import { SeasonService } from './season';
import { VideoService } from './video';
import { environment } from '../../environments/environment';
import { GenderService } from './gender';
import { PlaylistService } from './playlist';
import { ArtistService } from './artist';
import { AlbumService } from './album';
import { TrackService } from './track';
import { environment } from 'environments/environment';
import { NodeData } from 'common/model';
export class InputOrders {
public typeId: number = null;
public universeId: number = null;
public seriesId: number = null;
public seasonId: number = null;
public videoId: number = null;
public genderId: number = null;
public playlistId: number = null;
public artistId: number = null;
public albumId: number = null;
public trackId: number = null;
}
@Injectable()
export class ArianeService {
public typeId: number = null;
public genderId: number = null;
public typeName: string = null;
@Output() typeChange: EventEmitter<number> = new EventEmitter();
public universeId: number = null;
public universeName: string = null;
@Output() universeChange: EventEmitter<number> = new EventEmitter();
public playlistId: number = null;
public playlistName: string = null;
@Output() playlistChange: EventEmitter<number> = new EventEmitter();
public seriesId: number = null;
public seriesName: string = null;
@Output() seriesChange: EventEmitter<number> = new EventEmitter();
public artistId: number = null;
public artistName: string = null;
@Output() artistChange: EventEmitter<number> = new EventEmitter();
public seasonId: number = null;
public seasonName: string = null;
@Output() seasonChange: EventEmitter<number> = new EventEmitter();
public albumId: number = null;
public albumName: string = null;
@Output() albumChange: EventEmitter<number> = new EventEmitter();
public videoId: number = null;
public videoName: string = null;
@Output() videoChange: EventEmitter<number> = new EventEmitter();
public trackId: number = null;
public trackName: string = null;
@Output() trackChange: EventEmitter<number> = new EventEmitter();
constructor(private router: Router,
private typeService: TypeService,
private universeService: UniverseService,
private seriesService: SeriesService,
private seasonService: SeasonService,
private videoService: VideoService) {
console.log('Start ArianeService');
private typeService: GenderService,
private playlistService: PlaylistService,
private artistService: ArtistService,
private albumService: AlbumService,
private trackService: TrackService) {
//console.log('Start ArianeService');
}
updateParams(params) {
console.log(`sparams ${ params}`);
console.log(`sparams['typeId'] ${ params.typeId}`);
if(params.typeId) {
this.setType(params.typeId);
console.log(`sparams['genderId'] ${ params.genderId}`);
if(params.genderId) {
this.setType(params.genderId);
} else {
this.setType(null);
}
}
updateManual(params) {
let typeId = params.get('typeId');
if(typeId === null || typeId === undefined || typeId === 'null' || typeId === 'NULL' || typeId === '') {
typeId = null;
let genderId = params.get('genderId');
if(genderId === null || genderId === undefined || genderId === 'null' || genderId === 'NULL' || genderId === '') {
genderId = null;
} else {
typeId = parseInt(typeId, 10);
genderId = parseInt(genderId, 10);
}
console.log(`typeId = ${ typeId } ${ params.get('typeId')}`);
console.log(`genderId = ${ genderId } ${ params.get('genderId')}`);
let universeId = params.get('universeId');
if(universeId === null || universeId === undefined || universeId === 'null' || universeId === 'NULL' || universeId === '') {
universeId = null;
let playlistId = params.get('playlistId');
if(playlistId === null || playlistId === undefined || playlistId === 'null' || playlistId === 'NULL' || playlistId === '') {
playlistId = null;
} else {
universeId = parseInt(universeId, 10);
playlistId = parseInt(playlistId, 10);
}
console.log(`universeId = ${ universeId } ${ params.get('universId')}`);
console.log(`playlistId = ${ playlistId } ${ params.get('universId')}`);
let seriesId = params.get('seriesId');
if(seriesId === null || seriesId === undefined || seriesId === 'null' || seriesId === 'NULL' || seriesId === '') {
seriesId = null;
let artistId = params.get('artistId');
if(artistId === null || artistId === undefined || artistId === 'null' || artistId === 'NULL' || artistId === '') {
artistId = null;
} else {
seriesId = parseInt(seriesId, 10);
artistId = parseInt(artistId, 10);
}
console.log(`seriesId = ${ seriesId } ${ params.get('seriesId')}`);
console.log(`artistId = ${ artistId } ${ params.get('artistId')}`);
let seasonId = params.get('seasonId');
if(seasonId === null || seasonId === undefined || seasonId === 'null' || seasonId === 'NULL' || seasonId === '') {
seasonId = null;
let albumId = params.get('albumId');
if(albumId === null || albumId === undefined || albumId === 'null' || albumId === 'NULL' || albumId === '') {
albumId = null;
} else {
seasonId = parseInt(seasonId, 10);
albumId = parseInt(albumId, 10);
}
console.log(`seasonId = ${ seasonId } ${ params.get('seasonId')}`);
console.log(`albumId = ${ albumId } ${ params.get('albumId')}`);
let videoId = params.get('videoId');
if(videoId === null || videoId === undefined || videoId === 'null' || videoId === 'NULL' || videoId === '') {
videoId = null;
let trackId = params.get('trackId');
if(trackId === null || trackId === undefined || trackId === 'null' || trackId === 'NULL' || trackId === '') {
trackId = null;
} else {
videoId = parseInt(videoId, 10);
trackId = parseInt(trackId, 10);
}
console.log(`videoId = ${ videoId } ${ params.get('videoId')}`);
console.log(`trackId = ${ trackId } ${ params.get('trackId')}`);
this.setType(typeId);
this.setUniverse(universeId);
this.setSeries(seriesId);
this.setSeason(seasonId);
this.setVideo(videoId);
this.setType(genderId);
this.setPlaylist(playlistId);
this.setArtist(artistId);
this.setAlbum(albumId);
this.setTrack(trackId);
}
reset():void {
this.typeId = null;
this.genderId = null;
this.typeName = null;
this.typeChange.emit(this.typeId);
this.universeId = null;
this.universeName = null;
this.universeChange.emit(this.universeId);
this.seriesId = null;
this.seriesName = null;
this.seriesChange.emit(this.seriesId);
this.seasonId = null;
this.seasonName = null;
this.seasonChange.emit(this.seasonId);
this.videoId = null;
this.videoName = null;
this.videoChange.emit(this.videoId);
this.typeChange.emit(this.genderId);
this.playlistId = null;
this.playlistName = null;
this.playlistChange.emit(this.playlistId);
this.artistId = null;
this.artistName = null;
this.artistChange.emit(this.artistId);
this.albumId = null;
this.albumName = null;
this.albumChange.emit(this.albumId);
this.trackId = null;
this.trackName = null;
this.trackChange.emit(this.trackId);
}
/*
getCurrentRoute():InputOrders {
let out = new InputOrders()
out.typeId = parseInt(this.route.snapshot.paramMap.get('typeId'));
if (out.typeId === 0){
out.typeId = undefined;
out.genderId = parseInt(this.route.snapshot.paramMap.get('genderId'));
if (out.genderId === 0){
out.genderId = undefined;
}
out.universeId = parseInt(this.route.snapshot.paramMap.get('universId'));
if (out.universeId === 0){
out.universeId = undefined;
out.playlistId = parseInt(this.route.snapshot.paramMap.get('universId'));
if (out.playlistId === 0){
out.playlistId = undefined;
}
out.seriesId = parseInt(this.route.snapshot.paramMap.get('seriesId'));
if (out.seriesId === 0){
out.seriesId = undefined;
out.artistId = parseInt(this.route.snapshot.paramMap.get('artistId'));
if (out.artistId === 0){
out.artistId = undefined;
}
out.seasonId = parseInt(this.route.snapshot.paramMap.get('seasonId'));
if (out.seasonId === 0){
out.seasonId = undefined;
out.albumId = parseInt(this.route.snapshot.paramMap.get('albumId'));
if (out.albumId === 0){
out.albumId = undefined;
}
out.videoId = parseInt(this.route.snapshot.paramMap.get('videoId'));
if (out.videoId === 0){
out.videoId = undefined;
out.trackId = parseInt(this.route.snapshot.paramMap.get('trackId'));
if (out.trackId === 0){
out.trackId = undefined;
}
return out;
}
@ -157,179 +158,179 @@ export class ArianeService {
routeTo(data:InputOrders, destination:string = null) {
routeTo = ""
//if (
this.router.navigate(['/type/' + this.typeId + '/series/' + this.idSeries + '/season/' + IdSelected ]);
this.router.navigate(['/type/' + this.genderId + '/artist/' + this.idArtist + '/album/' + IdSelected ]);
}
*/
setType(id:number):void {
if(this.typeId === id) {
if(this.genderId === id) {
return;
}
if(id === undefined) {
return;
}
this.typeId = id;
this.genderId = id;
this.typeName = '??--??';
if(this.typeId === null) {
this.typeChange.emit(this.typeId);
if(this.genderId === null) {
this.typeChange.emit(this.genderId);
return;
}
let self = this;
this.typeService.get(id)
.then((response) => {
self.typeName = response.name;
self.typeChange.emit(self.typeId);
self.typeChange.emit(self.genderId);
}).catch((response) => {
self.typeChange.emit(self.typeId);
self.typeChange.emit(self.genderId);
});
}
getTypeId():number {
return this.typeId;
return this.genderId;
}
getTypeName():string {
return this.typeName;
}
setUniverse(id:number) {
if(this.universeId === id) {
setPlaylist(id:number) {
if(this.playlistId === id) {
return;
}
if(id === undefined) {
return;
}
this.universeId = id;
this.universeName = '??--??';
if(this.universeId === null) {
this.universeChange.emit(this.universeId);
this.playlistId = id;
this.playlistName = '??--??';
if(this.playlistId === null) {
this.playlistChange.emit(this.playlistId);
return;
}
let self = this;
this.universeService.get(id)
.then((response) => {
self.universeName = response.number;
self.universeChange.emit(self.universeId);
this.playlistService.get(id)
.then((response: NodeData) => {
self.playlistName = response.name;
self.playlistChange.emit(self.playlistId);
}).catch((response) => {
self.universeChange.emit(self.universeId);
self.playlistChange.emit(self.playlistId);
});
}
getUniverseId():number {
return this.universeId;
getPlaylistId():number {
return this.playlistId;
}
getUniverseName():string {
return this.universeName;
getPlaylistName():string {
return this.playlistName;
}
setSeries(id:number):void {
if(this.seriesId === id) {
setArtist(id:number):void {
if(this.artistId === id) {
return;
}
if(id === undefined) {
return;
}
this.seriesId = id;
this.seriesName = '??--??';
if(this.seriesId === null) {
this.seriesChange.emit(this.seriesId);
this.artistId = id;
this.artistName = '??--??';
if(this.artistId === null) {
this.artistChange.emit(this.artistId);
return;
}
let self = this;
this.seriesService.get(id)
.then((response) => {
self.seriesName = response.name;
self.seriesChange.emit(self.seriesId);
this.artistService.get(id)
.then((response: NodeData) => {
self.artistName = response.name;
self.artistChange.emit(self.artistId);
}).catch((response) => {
self.seriesChange.emit(self.seriesId);
self.artistChange.emit(self.artistId);
});
}
getSeriesId():number {
return this.seriesId;
getArtistId():number {
return this.artistId;
}
getSeriesName():string {
return this.seriesName;
getArtistName():string {
return this.artistName;
}
setSeason(id:number):void {
if(this.seasonId === id) {
setAlbum(id:number):void {
if(this.albumId === id) {
return;
}
if(id === undefined) {
return;
}
this.seasonId = id;
this.seasonName = '??--??';
if(this.seasonId === null) {
this.seasonChange.emit(this.seasonId);
this.albumId = id;
this.albumName = '??--??';
if(this.albumId === null) {
this.albumChange.emit(this.albumId);
return;
}
let self = this;
this.seasonService.get(id)
.then((response) => {
// self.setSeries(response.seriesId);
self.seasonName = response.name;
self.seasonChange.emit(self.seasonId);
this.albumService.get(id)
.then((response: NodeData) => {
// self.setArtist(response.artistId);
self.albumName = response.name;
self.albumChange.emit(self.albumId);
}).catch((response) => {
self.seasonChange.emit(self.seasonId);
self.albumChange.emit(self.albumId);
});
}
getSeasonId():number {
return this.seasonId;
getAlbumId():number {
return this.albumId;
}
getSeasonName():string {
return this.seasonName;
getAlbumName():string {
return this.albumName;
}
setVideo(id:number):void {
if(this.videoId === id) {
setTrack(id:number):void {
if(this.trackId === id) {
return;
}
if(id === undefined) {
return;
}
this.videoId = id;
this.videoName = '??--??';
if(this.videoId === null) {
this.videoChange.emit(this.videoId);
this.trackId = id;
this.trackName = '??--??';
if(this.trackId === null) {
this.trackChange.emit(this.trackId);
return;
}
let self = this;
this.videoService.get(id)
this.trackService.get(id)
.then((response) => {
// self.setSeason(response.seasonId);
// self.setSeries(response.seriesId);
self.videoName = response.name;
self.videoChange.emit(self.videoId);
// self.setAlbum(response.albumId);
// self.setArtist(response.artistId);
self.trackName = response.name;
self.trackChange.emit(self.trackId);
}).catch((response) => {
self.videoChange.emit(self.videoId);
self.trackChange.emit(self.trackId);
});
}
getVideoId():number {
return this.videoId;
getTrackId():number {
return this.trackId;
}
getVideoName():string {
return this.videoName;
getTrackName():string {
return this.trackName;
}
/**
* Generic navigation on the browser.
* @param destination - new destination url
* @param universeId - univers ID
* @param typeId - type IF
* @param seriesId - series real ID
* @param seasonId - season ID
* @param videoId - Video ID
* @param playlistId - univers ID
* @param genderId - type IF
* @param artistId - artist real ID
* @param albumId - album ID
* @param trackId - Track ID
* @param newWindows - open in a new windows
* @param replaceCurrentPage - consider the curent page is removed from history
*/
genericNavigate(
destination:string,
universeId:number,
typeId:number,
seriesId:number,
seasonId:number,
videoId:number,
playlistId:number,
genderId:number,
artistId:number,
albumId:number,
trackId:number,
newWindows:boolean = false,
replaceCurrentPage: boolean = false): void {
let addressOffset = `${destination }/${ universeId }/${ typeId }/${ seriesId }/${ seasonId }/${ videoId}`;
let addressOffset = `${destination }/${ playlistId }/${ genderId }/${ artistId }/${ albumId }/${ trackId}`;
if(newWindows === true) {
if(environment.frontBaseUrl === undefined || environment.frontBaseUrl === null || environment.frontBaseUrl === '') {
window.open(`/${ addressOffset}`);
@ -341,50 +342,50 @@ export class ArianeService {
}
}
navigateUniverse(id:number, newWindows:boolean):void {
this.genericNavigate('universe', id, this.typeId, null, null, null, newWindows);
navigatePlaylist(id:number, newWindows:boolean):void {
this.genericNavigate('playlist', id, this.genderId, null, null, null, newWindows);
}
navigateUniverseEdit(id:number, newWindows:boolean):void {
this.genericNavigate('universe-edit', id, this.typeId, null, null, null, newWindows);
navigatePlaylistEdit(id:number, newWindows:boolean):void {
this.genericNavigate('playlist-edit', id, this.genderId, null, null, null, newWindows);
}
navigateType(id:number, newWindows:boolean, ctrl:boolean = false):void {
if(ctrl === true) {
this.navigateTypeEdit(id, newWindows);
return;
}
this.genericNavigate('type', this.universeId, id, null, null, null, newWindows);
this.genericNavigate('type', this.playlistId, id, null, null, null, newWindows);
}
navigateTypeEdit(id:number, newWindows:boolean):void {
this.genericNavigate('type-edit', this.universeId, id, null, null, null, newWindows);
this.genericNavigate('type-edit', this.playlistId, id, null, null, null, newWindows);
}
navigateSeries(id:number, newWindows:boolean, ctrl:boolean = false):void {
navigateArtist(id:number, newWindows:boolean, ctrl:boolean = false):void {
if(ctrl === true) {
this.navigateSeriesEdit(id, newWindows);
this.navigateArtistEdit(id, newWindows);
return;
}
this.genericNavigate('series', this.universeId, this.typeId, id, null, null, newWindows);
this.genericNavigate('artist', this.playlistId, this.genderId, id, null, null, newWindows);
}
navigateSeriesEdit(id:number, newWindows:boolean):void {
this.genericNavigate('series-edit', this.universeId, this.typeId, id, null, null, newWindows);
navigateArtistEdit(id:number, newWindows:boolean):void {
this.genericNavigate('artist-edit', this.playlistId, this.genderId, id, null, null, newWindows);
}
navigateSeason(id:number, newWindows:boolean, ctrl:boolean = false, replaceCurrentPage: boolean = false):void {
navigateAlbum(id:number, newWindows:boolean, ctrl:boolean = false, replaceCurrentPage: boolean = false):void {
if(ctrl === true) {
this.navigateSeasonEdit(id, newWindows);
this.navigateAlbumEdit(id, newWindows);
return;
}
this.genericNavigate('season', this.universeId, this.typeId, this.seriesId, id, null, newWindows, replaceCurrentPage);
this.genericNavigate('album', this.playlistId, this.genderId, this.artistId, id, null, newWindows, replaceCurrentPage);
}
navigateSeasonEdit(id:number, newWindows:boolean):void {
this.genericNavigate('season-edit', this.universeId, this.typeId, this.seriesId, id, null, newWindows);
navigateAlbumEdit(id:number, newWindows:boolean):void {
this.genericNavigate('album-edit', this.playlistId, this.genderId, this.artistId, id, null, newWindows);
}
navigateVideo(id:number, newWindows:boolean, ctrl:boolean = false):void {
navigateTrack(id:number, newWindows:boolean, ctrl:boolean = false):void {
if(ctrl === true) {
this.navigateVideoEdit(id, newWindows);
this.navigateTrackEdit(id, newWindows);
return;
}
this.genericNavigate('video', this.universeId, this.typeId, this.seriesId, this.seasonId, id, newWindows);
this.genericNavigate('track', this.playlistId, this.genderId, this.artistId, this.albumId, id, newWindows);
}
navigateVideoEdit(id:number, newWindows:boolean):void {
this.genericNavigate('video-edit', this.universeId, this.typeId, this.seriesId, this.seasonId, id, newWindows);
navigateTrackEdit(id:number, newWindows:boolean):void {
this.genericNavigate('track-edit', this.playlistId, this.genderId, this.artistId, this.albumId, id, newWindows);
}
}

View File

@ -0,0 +1,144 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
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';
@Injectable()
export class ArtistService extends GenericInterfaceModelDB {
constructor(http: HttpWrapperService,
bdd: BddService) {
super('artist', http, bdd);
}
getOrder(): Promise<NodeData[]> {
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);
});
});
}
/**
* Get all the track for a specific artist
* @param id - Id of the artist.
* @returns a promise on the list of track elements
*/
getTrack(id:number): Promise<NodeData[]> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.get('track')
.then((response: DataInterface) => {
let data = response.getsWhere([
{
check: TypeCheck.EQUAL,
key: 'artistId',
value: id,
}, {
check: TypeCheck.EQUAL,
key: 'albumId',
value: undefined,
},
],
[ 'episode', 'name' ]);
resolve(data);
}).catch((response) => {
reject(response);
});
});
}
/**
* Get the number of track in this artist ID
* @param id - Id of the artist.
* @returns The number of track present in this artist
*/
countTrack(id:number): Promise<number> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.get('track')
.then((response:DataInterface) => {
let data = response.getsWhere([
{
check: TypeCheck.EQUAL,
key: 'artistId',
value: id,
},
]);
resolve(data.length);
}).catch((response) => {
reject(response);
});
});
}
/**
* Get all the album of a specific artist
* @param id - ID of the artist
* @returns the required List.
*/
getAlbum(id:number): Promise<NodeData[]> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.get('album')
.then((response:DataInterface) => {
let data = response.getsWhere([
{
check: TypeCheck.EQUAL,
key: 'parentId',
value: id,
},
], [ 'id' ]);
resolve(data);
return;
}).catch((response) => {
reject(response);
});
});
}
getLike(nameArtist:string):any {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.get('artist')
.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);
});
});
}
}

View File

@ -5,8 +5,9 @@
*/
import { Injectable } from '@angular/core';
import { isArrayOf, isNumberFinite } from 'common/utils';
import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from './http-wrapper';
import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from '../../common/service/http-wrapper';
@Injectable()
export class DataService {
@ -14,7 +15,7 @@ export class DataService {
private serviceName:string = 'data';
constructor(private http: HttpWrapperService) {
console.log('Start TypeService');
console.log('Start GenderService');
}
getData():any {
@ -22,12 +23,7 @@ export class DataService {
}
get(_id:number):any {
return this.http.getSpecific(this.serviceName, _id);
}
sendFile(_file:File) {
// return this.http.uploadFileMultipart(this.serviceName, null, _file);
return this.http.uploadFileBase64(this.serviceName, null, _file);
return this.http.getSpecific([this.serviceName, _id]);
}
uploadFile(_form:FormData, _progress:any = null) {
@ -51,18 +47,57 @@ export class DataService {
contentType: HTTPMimeType.JSON,
});
}
getCoverUrl(coverId: number):any {
/**
* Retreive 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,
});
}
getCoverThumbnailUrl(coverId: number):any {
/**
* Retreive 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) {
return undefined;
}
let covers = [] as string[];
for(let iii = 0; iii < coverIds.length; iii++) {
covers.push(this.getCoverUrl(coverIds[iii]));
}
return covers;
}
/**
* Retreive 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,
});
}
/**
* Retreive 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) {
return undefined;
}
let covers = [] as string[];
for(let iii = 0; iii < coverIds.length; iii++) {
covers.push(this.getCoverThumbnailUrl(coverIds[iii]));
}
return covers;
}
}

View File

@ -6,11 +6,10 @@
import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper';
import { BddService } from './bdd';
import { DataInterface, isNullOrUndefined } from '../utils';
import { NodeData } from '../model';
import { TypeCheck } from '../utils/dataInterface';
import { HttpWrapperService, BddService } from 'common/service';
import { DataInterface, isNullOrUndefined, TypeCheck } from 'common/utils';
import { NodeData } from 'common/model';
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
export interface MessageLogIn {
id: number;
@ -19,34 +18,20 @@ export interface MessageLogIn {
}
@Injectable()
export class TypeService {
export class GenderService extends GenericInterfaceModelDB {
constructor(private http: HttpWrapperService,
private bdd: BddService) {
console.log('Start TypeService');
constructor(http: HttpWrapperService,
bdd: BddService) {
super('gender', http, bdd);
}
getData(): Promise<NodeData[]> {
get(id:number): Promise<NodeData> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getType()
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);
});
});
}
get(_id:number): Promise<NodeData> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getType()
.then((response: DataInterface) => {
let data = response.get(_id);
let data = response.get(id);
if(isNullOrUndefined(data)) {
reject('Data does not exist in the local BDD');
return;
@ -58,10 +43,29 @@ export class TypeService {
});
}
countVideo(id:number): Promise<number> {
getData(): Promise<NodeData[]> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
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);
});
});
}
countTrack(id:number): Promise<number> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.get('track')
.then((response: DataInterface) => {
let data = response.getsWhere([
{
@ -76,10 +80,10 @@ export class TypeService {
});
}
getSubVideo(id:number): Promise<NodeData[]> {
getSubTrack(id:number): Promise<NodeData[]> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
self.bdd.get('track')
.then((response: DataInterface) => {
let data = response.getsWhere([
{
@ -88,11 +92,11 @@ export class TypeService {
value: id,
}, {
check: TypeCheck.EQUAL,
key: 'seriesId',
key: 'artistId',
value: undefined,
}, {
check: TypeCheck.EQUAL,
key: 'universeId',
key: 'playlistId',
value: undefined,
},
], [ 'name' ] );
@ -103,10 +107,10 @@ export class TypeService {
});
}
getSubSeries(id:number): Promise<NodeData[]> {
getSubArtist(id:number): Promise<NodeData[]> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getSeries()
self.bdd.get('artist')
.then((response: DataInterface) => {
let data = response.getsWhere([
{
@ -122,10 +126,10 @@ export class TypeService {
});
}
getSubUniverse(id:number): Promise<NodeData[]> {
getSubPlaylist(id:number): Promise<NodeData[]> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
self.bdd.get('track')
.then((response: DataInterface) => {
let data = response.getsWhere([
{
@ -134,11 +138,11 @@ export class TypeService {
value: id,
}, {
check: TypeCheck.EQUAL,
key: 'seriesId',
key: 'artistId',
value: [undefined, null],
}, {
check: TypeCheck.NOT_EQUAL,
key: 'universeId',
key: 'playlistId',
value: undefined,
},
]);
@ -151,17 +155,5 @@ export class TypeService {
});
}
getCoverUrl(coverId:number): string {
return this.http.createRESTCall2({
api: `data/${coverId}`,
addURLToken: true,
});
}
getCoverThumbnailUrl(coverId:number): string {
return this.http.createRESTCall2({
api: `data/thumbnail/${coverId}`,
addURLToken: true,
});
}
}

View File

@ -1,741 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpEventType } from '@angular/common/http';
import { environment } from '../../environments/environment';
import { SessionService } from './session';
import { isNullOrUndefined } from '../utils';
export enum HTTPRequestModel {
POST = "POST",
GET = "GET",
PUT = "PUT",
DELETE = "DELETE",
PATCH = "PATCH",
}
export enum HTTPMimeType {
ALL = "*/*",
JSON = "application/json",
OCTET_STREAM = "application/octet-stream",
IMAGE = "image/*",
IMAGE_JPEG = "image/jpeg",
IMAGE_PNG = "image/png",
}
export interface HTTPRequest {
server?: string;
endPoint: string;
requestType: HTTPRequestModel ;
accept: HTTPMimeType;
contentType: HTTPMimeType;
params?: object;
body?: any;
authorization?: string; // c'est un hook de merde ...
disableTocken?:boolean;
}
export interface ModelResponseHttp {
status: number,
data: any,
}
/**
* This service permit to add some data like tocken and authorisation.. ir automatically get the token if needed and retake it if expired...
*/
@Injectable()
export class HttpWrapperService {
private displayReturn:boolean = false;
constructor(private http: HttpClient,
private session: SessionService) {
}
addTokenIfNeeded(headerOption:any): any {
if(this.session.sessionData !== null) {
if(headerOption.Authorization === undefined) {
headerOption.Authorization = `Yota ${this.session.getToken()}`;
}
}
return headerOption;
}
request(properties: HTTPRequest) : Promise<Response> {
//uriRest:string, headerOption:any, params:any): Promise<{status:number, data:any}> {
console.log(`-------------------------------------------------------\nHTTP-wrapper GET '${ properties.endPoint }'\n\t\tparams=${ JSON.stringify(properties, null, 2)}`);
let connectionAdresse = this.createRESTCall2({
server: properties.server,
api: properties.endPoint,
inputOptions: properties.params,
});
let headers: any = {
'Accept': properties.accept,
//'Content-Type': properties.contentType,
}
if (properties.authorization !== undefined && properties.authorization !== null) {
headers['Authorization'] = properties.authorization;
}
if (properties.requestType !== HTTPRequestModel.GET) {
headers['Content-Type'] = properties.contentType;
}
console.log(`disble tocken : ${JSON.stringify(properties)} properties.disableTocken=${properties.disableTocken}`);
if (properties.disableTocken === undefined || properties.disableTocken === null || properties.disableTocken === true) {
headers = this.addTokenIfNeeded(headers);
}
console.log(`header: ${JSON.stringify(headers)}`);
let body = properties.body;
if (properties.contentType === HTTPMimeType.JSON) {
body = JSON.stringify(properties.body);
}
const result = fetch(connectionAdresse, {
method: properties.requestType,
headers,
body
})
return result;
};
requestJson(properties: HTTPRequest) : Promise<ModelResponseHttp> {
return new Promise((resolve, reject) => {
this.request(properties).then((response: Response) => {
if(response.status >= 200 && response.status <= 299) {
const contentType = response.headers.get('Content-Type');
if (contentType === HTTPMimeType.JSON) {
response.json().then((value:any) => {
//console.log(`REICEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
resolve({ status:response.status, data:value });
}).catch((reason:any)=> {
reject({ status:999, data:reason });
});
} else {
console.error(`content Type is not Json: ${contentType}`)
reject({ status:999, data:`content Type is not Json: ${contentType}` });
}
} else {
console.error(`wring correct status: ${response.status}`)
reject({ status:900, data: response });
}
}).catch((error: any) => {
reject({ status:error.status, data:error.error });
});
});
};
requestImage(properties: HTTPRequest) : Promise<ModelResponseHttp> {
return new Promise((resolve, reject) => {
this.request(properties).then((response: Response) => {
if(response.status >= 200 && response.status <= 299) {
const contentType = response.headers.get('Content-Type');
//console.log(`REICEIVE ==> ${response.status}`);
resolve({ status:900, data: response });
/*
resolve({ status:response.status, data:value });
}).catch((reason:any)=> {
reject({ status:999, data:reason });
});
} else {
console.error(`content Type is not Json: ${contentType}`)
reject({ status:999, data:`content Type is not Json: ${contentType}` });
}
*/
} else {
console.error(`wring correct status: ${response.status}`)
resolve({ status:900, data: response });
}
}).catch((error: any) => {
reject({ status:error.status, data:error.error });
});
});
}
createRESTCall2({ api, server, inputOptions, addURLToken }: { server?: string; api: string; inputOptions?: object; addURLToken?:boolean }) {
if (isNullOrUndefined(server)) {
server = environment.defaultServer;
}
const basePage = environment.server[server];
let addressServerRest = `${basePage }/`;
let options = inputOptions;
if(isNullOrUndefined(options)) {
options = {};
}
let out = addressServerRest + api;
let first = true;
let keys = Object.keys(options);
for(let iii = 0; iii < keys.length; iii++) {
if(first === false) {
out = `${out }&`;
} else {
out = `${out }?`;
first = false;
}
out = out + keys[iii];
if (options[keys[iii]] != null) {
out = out + "=" + options[keys[iii]];
}
}
if (!isNullOrUndefined(this.session.sessionData)) {
if (addURLToken !== undefined && addURLToken === true) {
if(first === false) {
out = `${out }&`;
} else {
out = `${out }?`;
}
out = out + `Authorization=Yota ${this.session.sessionData.userId}:${this.session.sessionData.token}`;
}
}
return out;
}
// Deprecated ...
createRESTCall(api: string, inputOptions?: any) {
let basePage = environment.server[environment.defaultServer];
let addressServerRest = `${basePage }/`;
let options = inputOptions;
if(options === undefined) {
options = [];
}
let out = addressServerRest + api;
let first = true;
for(let iii = 0; iii < options.length; iii++) {
if(first === false) {
out = `${out }&`;
} else {
out = `${out }?`;
first = false;
}
out = out + options[iii];
}
return out;
}
get(uriRest:string, headerOption:any, params:any): Promise<{status:number, data:any}> {
console.log(`-------------------------------------------------------\nHTTP-wrapper GET '${ uriRest }'\n\t\theaderOption=${ JSON.stringify(headerOption, null, 2)}\n\t\tparams=${ JSON.stringify(params, null, 2)}`);
let connectionAdresse = this.createRESTCall(uriRest, {});
const headers = this.addTokenIfNeeded(headerOption);
let self = this;
return new Promise((resolve, reject) => {
fetch(connectionAdresse, {
method: "GET",
headers,
}).then((response: Response) => {
if(response.status === 200) {
response.json().then((value:any) => {
//console.log(`REICEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
resolve({ status:response.status, data:response.body });
}).catch((reason:any)=> {
reject({ status:999, data:reason });
});
} else {
resolve({ status:900, data:'' });
}
}).catch((error: any) => {
reject({ status:error.status, data:error.error });
});
});
}
post(uriRest:string, headerOption:any, data:any, progress:any = null) {
console.log(`-------------------------------------------------------\nHTTP-wrapper POST '${ uriRest }'\n\t\theaderOption=${ JSON.stringify(headerOption, null, 2)}\n\t\tdata=${ JSON.stringify(data, null, 2)}`);
this.addTokenIfNeeded(headerOption);
let connectionAdresse = this.createRESTCall(uriRest, {});
return new Promise((resolve, reject) => {
if(this.displayReturn === true) {
console.log(`call POST ${ connectionAdresse } data=${ JSON.stringify(data, null, 2)}`);
}
let request = this.http.post(connectionAdresse, data, {
headers: new HttpHeaders(headerOption),
reportProgress: true,
observe: 'events'
});
let self = this;
request.subscribe((res: any) => {
if(self.displayReturn === true) {
console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
}
if(res.type === HttpEventType.Sent) {
/* res.type === 0 */
console.log('post : Sent');
} else if(res.type === HttpEventType.UploadProgress) {
/* res.type === 1 */
// console.log("post : " + res.loaded + " / " + res.total);
progress(res.loaded, res.total);
} else if(res.type === HttpEventType.ResponseHeader) {
/* res.type === 2 */
console.log('post : get header');
} else if(res.type === HttpEventType.DownloadProgress) {
/* res.type === 3 */
console.log(`post : get DownloadProgress ${ res.loaded}`);
} else if(res.type === HttpEventType.Response) {
/* res.type === 4 */
console.log('post : get response');
if(res.httpCode) {
resolve({ status:res.httpCode, data:res });
} else {
resolve({ status:200, data:res });
}
} else if(res.type === HttpEventType.User) {
/* res.type === 5 */
console.log('post : get User');
} else {
console.log(`post : get unknown ... ${ res.type}`);
}
},
(error) => {
if(self.displayReturn === true) {
console.log(`an error occured status: ${ error.status}`);
console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
}
reject({ status:error.status, data:error.error });
});
/*
switch (event.type) {
case HttpEventType.UploadProgress:
const progress = Math.round(100 * event.loaded / event.total);
return { status: 'progress', message: progress };
case HttpEventType.Response:
return event.body;
default:
return `Unhandled event: ${event.type}`;
}
})
);
*/
});
}
put(uriRest:string, headerOption:any, data:any) {
console.log(`-------------------------------------------------------\nHTTP-wrapper PUT '${ uriRest }'\n\t\theaderOption=${ JSON.stringify(headerOption, null, 2)}\n\t\tdata=${ JSON.stringify(data, null, 2)}`);
this.addTokenIfNeeded(headerOption);
let connectionAdresse = this.createRESTCall(uriRest, {});
const httpOption = {
headers: new HttpHeaders(headerOption)
};
return new Promise((resolve, reject) => {
if(this.displayReturn === true) {
console.log(`call POST ${ connectionAdresse } data=${ JSON.stringify(data, null, 2)}`);
}
let request = this.http.put<any>(connectionAdresse, data, httpOption);
let self = this;
request.subscribe((res: any) => {
if(self.displayReturn === true) {
console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
}
if(res) {
if(res.httpCode) {
resolve({ status:res.httpCode, data:res });
} else {
resolve({ status:200, data:res });
}
} else {
resolve({ status:200, data:'' });
}
},
(error) => {
if(self.displayReturn === true) {
console.log(`an error occured status: ${ error.status}`);
console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
}
reject({ status:error.status, data:error.error });
});
});
}
delete(uriRest:string, headerOption:any) {
this.addTokenIfNeeded(headerOption);
let connectionAdresse = this.createRESTCall(uriRest, {});
const httpOption = {
headers: new HttpHeaders(headerOption)
};
return new Promise((resolve, reject) => {
if(this.displayReturn === true) {
console.log(`call POST ${ connectionAdresse}`);
}
let request = this.http.delete<any>(connectionAdresse, httpOption);
let self = this;
request.subscribe((res: any) => {
if(self.displayReturn === true) {
console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
}
if(res) {
if(res.httpCode) {
resolve({ status:res.httpCode, data:res });
} else {
resolve({ status:200, data:res });
}
} else {
resolve({ status:200, data:'' });
}
},
(error) => {
if(self.displayReturn === true) {
console.log(`an error occured status: ${ error.status}`);
console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
}
reject({ status:error.status, data:error.error });
});
});
}
uploadFileMultipart(base:string, id:number, file:File): any {
console.log(`Upload file to ${ base}`);
let url = base;
if(id !== null) {
url = `${url }/${ id}`;
}
let formData = new FormData();
formData.append('upload', file);
let headers = new Headers();
console.log(`upload filename : ${ file.name}`);
let extention = file.name.split('.').pop();
if(extention === 'jpg') {
headers.append('Content-Type', 'image/jpeg');
} else if(extention === 'png') {
headers.append('Content-Type', 'image/png');
} else if(extention === 'mkv') {
headers.append('Content-Type', 'video/x-matroska');
} else if(extention === 'webm') {
headers.append('Content-Type', 'video/webm');
} else {
return null;
}
headers.append('filename', file.name);
const httpOption = {
headers: headers,
reportProgress: true,
};
return new Promise((resolve, reject) => {
this.post(url, httpOption, formData)
.then((response: any) => {
console.log(`URL: ${ url }\nRespond(${ response.status }): ${ JSON.stringify(response.data, null, 2)}`);
if(response.status === 200) {
resolve(response.data);
return;
}
reject('An error occured');
}, (response: any) => {
if(typeof response.data === 'undefined') {
reject('return ERROR undefined');
} else {
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
}
});
});
}
uploadFileBase64(base:string, id:number, file:File): any {
console.log(`Upload file to ${ base}`);
let url = base;
if(id !== null) {
url = `${url }/${ id}`;
}
let self = this;
let reader = new FileReader();
reader.readAsArrayBuffer(file);
return new Promise((resolve, reject) => {
reader.onload = () => {
let headers:any = {};// new Headers();
console.log(`upload filename : ${ file.name}`);
let extention = file.name.split('.').pop();
if(extention === 'jpg') {
// headers.append('Content-Type', "image/jpeg");
headers['Content-Type'] = 'image/jpeg';
headers['mime-type'] = 'image/jpeg';
} else if(extention === 'jpeg') {
// headers.append('Content-Type', "image/jpeg");
headers['Content-Type'] = 'image/jpeg';
headers['mime-type'] = 'image/jpeg';
} else if(extention === 'webp') {
// headers.append('Content-Type', "image/webp");
headers['Content-Type'] = 'image/webp';
headers['mime-type'] = 'image/webp';
} else if(extention === 'png') {
// headers.append('Content-Type', "image/png");
headers['Content-Type'] = 'image/png';
headers['mime-type'] = 'image/png';
} else if(extention === 'mkv') {
headers['Content-Type'] = 'video/x-matroska';
headers['mime-type'] = 'video/x-matroska';
} else if(extention === 'webm') {
headers['Content-Type'] = 'video/webm';
headers['mime-type'] = 'video/webm';
} else {
return null;
}
// headers.append('filename', file.name);
headers.filename = file.name;
self.post(url, headers, reader.result)
.then((response: any) => {
console.log(`URL: ${ url }\nRespond(${ response.status }): ${ JSON.stringify(response.data, null, 2)}`);
if(response.status === 200) {
resolve(response.data);
return;
}
reject('An error occured');
}, (response: any) => {
if(typeof response.data === 'undefined') {
reject('return ERROR undefined');
} else {
reject('return ERROR ...');// + JSON.stringify(response, null, 2));
}
});
};
});
}
uploadFile(base:string, file:File): any {
console.log(`Upload file to ${ base}`);
let url = base;
let self = this;
let reader = new FileReader();
reader.readAsArrayBuffer(file);
return new Promise((resolve, reject) => {
reader.onload = () => {
let headers: any = {};// new Headers();
console.log(`upload filename : ${ file.name}`);
let extention = file.name.split('.').pop();
if(extention === 'jpg') {
// headers.append('Content-Type', "image/jpeg");
headers['Content-Type'] = 'image/jpeg';
headers['mime-type'] = 'image/jpeg';
} else if(extention === 'jpeg') {
// headers.append('Content-Type', "image/jpeg");
headers['Content-Type'] = 'image/jpeg';
headers['mime-type'] = 'image/jpeg';
} else if(extention === 'webp') {
// headers.append('Content-Type', "image/webp");
headers['Content-Type'] = 'image/webp';
headers['mime-type'] = 'image/webp';
} else if(extention === 'png') {
// headers.append('Content-Type', "image/png");
headers['Content-Type'] = 'image/png';
headers['mime-type'] = 'image/png';
} else if(extention === 'mkv') {
headers['Content-Type'] = 'video/x-matroska';
headers['mime-type'] = 'video/x-matroska';
} else if(extention === 'webm') {
headers['Content-Type'] = 'video/webm';
headers['mime-type'] = 'video/webm';
} else {
return null;
}
// headers.append('filename', file.name);
headers.filename = file.name;
self.post(url, headers, reader.result)
.then((response: any) => {
console.log(`URL: ${ url }\nRespond(${ response.status }): ${ JSON.stringify(response.data, null, 2)}`);
if(response.status === 200) {
resolve(response.data);
return;
}
reject('An error occured');
}, (response: any) => {
if(typeof response.data === 'undefined') {
reject('return ERROR undefined');
} else {
reject('return ERROR ...');// + JSON.stringify(response, null, 2));
}
});
};
});
}
uploadMultipart(base:string, multipart:FormData, progress:any): any {
console.log(`Upload multipart to ${ base}`);
let url = base;
let self = this;
return new Promise((resolve, reject) => {
let headers = {
// 'Content-Type': 'multipart/form-data',
};// new Headers();
self.post(url, headers, multipart, progress)
.then((response: any) => {
console.log(`URL: ${ url }\nRespond(${ response.status }): ${ JSON.stringify(response.data, null, 2)}`);
if(response.status >= 200 && response.status <= 299) {
resolve(response.data.body);
return;
}
reject('An error occured');
}, (response: any) => {
if(typeof response.data === 'undefined') {
reject('return ERROR undefined');
} else {
reject('return ERROR ...');// + JSON.stringify(response, null, 2));
}
});
});
}
// Complex wrapper to simplify interaction:
getSpecific(base:string, id:number = null, subElement:string = '', select:string[] = []):any {
//console.log(`Get All data from ${ base}`);
let url = base;
if(id !== null) {
url = `${url}/${id}`;
}
if(subElement !== '') {
url = `${url}/${subElement}`;
}
if(select.length !== 0) {
let newValue = '';
for(let iii = 0; iii < select.length; iii++) {
if(select.length !== 0) {
newValue = `${newValue}&`;
}
newValue = `${newValue}select=${select[iii]}`;
}
url = `${url}?${newValue}`;
}
//console.log("call GET " + url);
return new Promise((resolve, reject) => {
this.requestJson({
endPoint: url,
requestType: HTTPRequestModel.GET,
accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON,
})
.then((response: ModelResponseHttp) => {
//console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
if(response.status === 200) {
resolve(response.data);
return;
}
reject('An error occured');
}, (response: ModelResponseHttp) => {
if(typeof response.data === 'undefined') {
reject('return ERROR undefined');
} else {
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
}
});
});
}
// Complex wrapper to simplify interaction:
deleteSpecific(base:string, id:number, subElement:string = ''):any {
// console.log("delete data to " + base);
const httpOption = { 'Content-Type': 'application/json' };
let url = base;
if(id !== null) {
url = `${url }/${ id}`;
}
if(subElement !== '') {
url = `${url }/${ subElement}`;
}
// console.log("call DELETE: " + url);
// console.log(" data: " + JSON.stringify(data, null, 2));
return new Promise((resolve, reject) => {
this.delete(url, httpOption)
.then((response: any) => {
// console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
if(response.status === 200) {
resolve(response.data);
return;
}
if(response.status === 201) {
resolve(response.data);
return;
}
reject('An error occured');
}, (response: any) => {
if(typeof response.data === 'undefined') {
reject('return ERROR undefined');
} else {
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
}
});
});
}
// Complex wrapper to simplify interaction:
putSpecific(base:string, id:number, data:any, subElement:string = ''):any {
// console.log("put data to " + base);
const httpOption = { 'Content-Type': 'application/json' };
let url = base;
if(id !== null) {
url = `${url }/${ id}`;
}
if(subElement !== '') {
url = `${url }/${ subElement}`;
}
// console.log("call PUT: " + url);
// console.log(" data: " + JSON.stringify(data, null, 2));
return new Promise((resolve, reject) => {
this.put(url, httpOption, data)
.then((response: any) => {
// console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
if(response.status === 200) {
resolve(response.data);
return;
}
if(response.status === 201) {
resolve(response.data);
return;
}
reject('An error occured');
}, (response: any) => {
if(typeof response.data === 'undefined') {
reject('return ERROR undefined');
} else {
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
}
});
});
}
// Complex wrapper to simplify interaction:
postSpecific(base:string, id:number, data:any, subElement:string = ''):any {
// console.log("put data to " + base);
const httpOption = { 'Content-Type': 'application/json' };
let url = base;
if(id !== null) {
url = `${url }/${ id}`;
}
if(subElement !== '') {
url = `${url }/${ subElement}`;
}
// console.log("call PUT: " + url);
// console.log(" data: " + JSON.stringify(data, null, 2));
return new Promise((resolve, reject) => {
this.post(url, httpOption, data)
.then((response: any) => {
// console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
if(response.status === 200) {
resolve(response.data);
return;
}
if(response.status === 201) {
resolve(response.data);
return;
}
reject('An error occured');
}, (response: any) => {
if(typeof response.data === 'undefined') {
reject('return ERROR undefined');
} else {
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
}
});
});
}
}

View File

@ -1,41 +1,22 @@
import { ArianeService } from "./ariane";
import { BddService } from "./bdd";
import { CookiesService } from "./cookies";
import { DataService } from "./data";
import { HttpWrapperService, ModelResponseHttp, HTTPRequest, HTTPMimeType, HTTPRequestModel } from "./http-wrapper";
import { StorageService } from "./local-storage";
import { PopInService } from "./popin";
import { SeasonService } from "./season";
import { SeriesService } from "./series";
import { SessionService } from "./session";
import { SSOService } from "./sso";
import { TypeService } from "./type";
import { UniverseService } from "./universe";
import { UserService } from "./user";
import { VideoService } from "./video";
import { AlbumService } from "./album";
import { ArtistService } from "./artist";
import { GenderService } from "./gender";
import { PlaylistService } from "./playlist";
import { TrackService } from "./track";
export {
CookiesService,
HttpWrapperService,
ModelResponseHttp,
HTTPRequest,
HTTPMimeType,
HTTPRequestModel,
StorageService,
PopInService,
SessionService,
UserService,
SSOService,
ArianeService,
BddService,
DataService,
SeasonService,
SeriesService,
TypeService,
UniverseService,
VideoService,
AlbumService,
ArtistService,
GenderService,
PlaylistService,
TrackService,
};

View File

@ -0,0 +1,29 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Injectable } from '@angular/core';
import { HttpWrapperService, BddService } from 'common/service';
import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
@Injectable()
export class PlaylistService extends GenericInterfaceModelDB {
constructor(http: HttpWrapperService,
bdd: BddService) {
super('playlist', http, bdd);
}
getSubArtist(id:number, select:Array<string> = []):any {
// this.checkLocalBdd();
}
getSubTrack(id:number, select:Array<string> = []):any {
// this.checkLocalBdd();
}
}

View File

@ -1,154 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper';
import { DataInterface } from '../utils';
import { BddService } from './bdd';
import { TypeCheck } from '../utils/dataInterface';
@Injectable()
export class SeasonService {
private serviceName:string = 'season';
constructor(private http: HttpWrapperService,
private bdd: BddService) {
console.log('Start SeasonService');
}
get(id:number):any {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getSeason()
.then((response: DataInterface) => {
let data = response.get(id);
if(data === null || data === undefined) {
reject('Data does not exist in the local BDD');
return;
}
resolve(data);
}).catch((response) => {
reject(response);
});
});
}
/**
* Get all the video for a specific season
* @param id - Id of the season.
* @returns a promise on the list of season elements
*/
getVideo(id:number):any {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
.then((response: DataInterface) => {
// let data = response.getsWhere([["==", "seasonId", id]], ["id", "name", "episode"], ["episode", "name"])
let data = response.getsWhere([
{
check: TypeCheck.EQUAL,
key: 'seasonId',
value: id,
},
],
[ 'episode', 'name' ]);
resolve(data);
}).catch((response) => {
reject(response);
});
});
}
/**
* Get the number of video in this saison ID
* @param id - Id of the season.
* @returns The number of element present in this saison
*/
countVideo(id:number):any {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
.then((response: DataInterface) => {
// let data = response.getsWhere([["==", "seasonId", _id]], ["id", "name", "episode"], ["episode", "name"])
let data = response.getsWhere([
{
check: TypeCheck.EQUAL,
key: 'seasonId',
value: id,
} ] );
resolve(data.length);
}).catch((response) => {
reject(response);
});
});
}
put(id:number, data:any):any {
let ret = this.http.putSpecific(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);
}
// deprecated ???
getCoverUrl(coverId:number):any {
return this.http.createRESTCall2({
api: `data/${coverId}`,
addURLToken: true,
});
}
getCoverThumbnailUrl(coverId:number):any {
return this.http.createRESTCall2({
api: `data/thumbnail/${coverId}`,
addURLToken: true,
});
}
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('nodeId', 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);
});
});
}
}

View File

@ -1,231 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper';
import { DataInterface, TypeCheck } from '../utils/dataInterface';
import { BddService } from './bdd';
import { isNodeData, NodeData } from '../model';
import { isArrayOf, isNullOrUndefined } from '../utils';
@Injectable()
export class SeriesService {
private serviceName:string = 'series';
constructor(private http: HttpWrapperService,
private bdd: BddService) {
console.log('Start SeriesService');
}
get(id:number): Promise<NodeData> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getSeries()
.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);
});
});
}
getData(): Promise<NodeData[]> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getSeries()
.then((response:DataInterface) => {
let data = response.gets();
resolve(data);
}).catch((response) => {
console.log(`[E] ${ self.constructor.name }: can not retrive BDD values`);
reject(response);
});
});
}
getOrder(): Promise<NodeData[]> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getSeries()
.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);
});
});
}
getVideo(id:number):Promise<NodeData[]> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
.then((response:DataInterface) => {
let data = response.getsWhere([
{
check: TypeCheck.EQUAL,
key: 'seriesId',
value: id,
}, {
check: TypeCheck.EQUAL,
key: 'seasonId',
value: undefined,
},
],
[ 'episode', 'name' ]);
resolve(data);
}).catch((response) => {
reject(response);
});
});
}
countVideo(id:number): Promise<number> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
.then((response:DataInterface) => {
let data = response.getsWhere([
{
check: TypeCheck.EQUAL,
key: 'seriesId',
value: id,
},
]);
resolve(data.length);
}).catch((response) => {
reject(response);
});
});
}
/**
* Get all the season of a specific series
* @param id - ID of the series
* @returns the required List.
*/
getSeason(id:number): Promise<NodeData[]> {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getSeason()
.then((response:DataInterface) => {
let data = response.getsWhere([
{
check: TypeCheck.EQUAL,
key: 'parentId',
value: id,
},
], [ 'id' ]);
resolve(data);
return;
}).catch((response) => {
reject(response);
});
});
}
put(id:number, data:any):any {
let ret = this.http.putSpecific(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);
}
getCoverUrl(coverId:number):any {
return this.http.createRESTCall2({
api: `data/${coverId}`,
addURLToken: true,
});
}
getCoverThumbnailUrl(coverId:number):any {
return this.http.createRESTCall2({
api: `data/thumbnail/${coverId}`,
addURLToken: true,
});
}
getLike(nameSeries:string):any {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getSeries()
.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);
});
});
}
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('nodeId', 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);
});
});
}
}

View File

@ -0,0 +1,117 @@
/** @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 TrackService extends GenericInterfaceModelDB {
constructor(http: HttpWrapperService,
bdd: BddService) {
super('track', http, bdd);
}
get(id:number): Promise<Media> {
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<Media[]> {
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,
playlist?:string,
artist?:string,
artistId?:number,
album?: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);
formData.append('playlist', playlist?? null);
if(artistId !== null) {
formData.append('artistId', artistId.toString());
} else {
formData.append('artistId', null);
}
formData.append('artist', artist?? null);
if(album !== null) {
formData.append('album', album.toString());
} else {
formData.append('album', 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);
});
});
}
}

View File

@ -1,169 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper';
import { BddService } from './bdd';
import { DataInterface } from '../utils/dataInterface';
@Injectable()
export class VideoService {
// 0: Not hide password; 1 hide password;
private identificationVersion: number = 1;
private serviceName:string = 'video';
constructor(private http: HttpWrapperService,
private bdd: BddService) {
console.log('Start VideoService');
}
get(id:number):any {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.get(this.serviceName)
.then((response: DataInterface) => {
let data = response.get(id);
if(data === null || data === undefined) {
reject('Data does not exist in the local BDD');
return;
}
resolve(data);
}).catch((response) => {
reject(response);
});
});
}
put(id:number, data:any):any {
let ret = this.http.putSpecific(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);
}
getCoverUrl(coverId:number):any {
return this.http.createRESTCall2({
api: `data/${coverId}`,
addURLToken: true,
});
}
getCoverThumbnailUrl(coverId:number):any {
return this.http.createRESTCall2({
api: `data/thumbnail/${coverId}`,
addURLToken: true,
});
}
uploadFile(file:File,
universe?:string,
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);
formData.append('universe', universe?? 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);
}
deleteCover(mediaId:number,
coverId:number) {
let self = this;
return new Promise((resolve, reject) => {
self.http.getSpecific(`${this.serviceName }/${ mediaId }/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, mediaId, data);
resolve(data);
}).catch((response) => {
reject(response);
});
});
}
uploadCover(file:File,
mediaId:number,
progress:any = null) {
const formData = new FormData();
formData.append('fileName', file.name);
formData.append('id', mediaId.toString());
formData.append('file', file);
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);
});
});
}
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);
});
});
}
}

View File

@ -1,9 +1,27 @@
;function dateFormat(g,c,k){function l(a,b){a.setHours(a.getHours()+parseFloat(b));return a}function m(a,b){var c="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" ");return b?c[a.getDay()].substr(0,3):c[a.getDay()]}function n(a,b){var c="January February March April May June July August September October November December".split(" ");return b?c[a.getMonth()].substr(0,3):c[a.getMonth()]}var d={d:function(){var a=this.getDate();return 9<a?a:"0"+a},D:function(){return m(this,!0)},j:function(){return this.getDate()},
l:function(){return m(this)},N:function(){return this.getDay()+1},S:function(){var a=this.getDate();return/^1[0-9]$/.test(a)?"th":/1$/.test(a)?"st":/2$/.test(a)?"nd":/3$/.test(a)?"rd":"th"},w:function(){return this.getDay()},z:function(){return Math.round(Math.abs((this.getTime()-(new Date("1/1/"+this.getFullYear())).getTime())/864E5))},W:function(){var a=new Date(this.getFullYear(),0,1);return Math.ceil(((this-a)/864E5+a.getDay()+1)/7)},F:function(){return n(this)},m:function(){var a=this.getMonth()+
1;return 9<a?a:"0"+a},M:function(){return n(this,!0)},n:function(){return this.getMonth()+1},t:function(){return(new Date(this.getFullYear(),this.getMonth()+1,0)).getDate()},L:function(){var a=this.getFullYear();return 0==a%4&&0!=a%100||0==a%400},o:function(){return parseInt(this.getFullYear())},Y:function(){return parseInt(this.getFullYear())},y:function(){return parseInt((this.getFullYear()+"").substr(-2))},a:function(){return 12<=this.getHours()?"pm":"am"},A:function(){return 12<=this.getHours()?
"PM":"AM"},B:function(){return"@"+("00"+Math.floor((60*((this.getHours()+1)%24*60+this.getMinutes())+this.getSeconds()+.001*this.getMilliseconds())/86.4)).slice(-3)},g:function(){var a=this.getHours();return 0==a?12:12>=a?a:a-12},G:function(){return this.getHours()},h:function(){var a=this.getHours(),a=12>=a?a:a-12;return 0==a?12:9<a?a:"0"+a},H:function(){var a=this.getHours();return 9<a?a:"0"+a},i:function(){var a=this.getMinutes();return 9<a?a:"0"+a},s:function(){var a=this.getSeconds();return 9<
a?a:"0"+a},u:function(){return this.getMilliseconds()},e:function(){var a=this.toString().match(/ ([A-Z]{3,4})([-|+]?\d{4})/);return 1<a.length?a[1]:""},I:function(){var a=new Date(this.getFullYear(),0,1),b=new Date(this.getFullYear(),6,1),a=Math.max(a.getTimezoneOffset(),b.getTimezoneOffset());return this.getTimezoneOffset()<a?1:0},O:function(){var a=this.toString().match(/ ([A-Z]{3,4})([-|+]?\d{4})/);return 2<a.length?a[2]:""},P:function(){var a=this.toString().match(/ ([A-Z]{3,4})([-|+]?\d{4})/);
return 2<a.length?a[2].substr(0,3)+":"+a[2].substr(3,2):""},T:function(){return this.toLocaleString("en",{timeZoneName:"short"}).split(" ").pop()},Z:function(){return 60*this.getTimezoneOffset()},c:function(){return l(new Date(this),-(this.getTimezoneOffset()/60)).toISOString()},r:function(){return l(new Date(this),-(this.getTimezoneOffset()/60)).toISOString()},U:function(){return this.getTime()/1E3|0}},e={commonLogFormat:"d/M/Y:G:i:s",exif:"Y:m:d G:i:s",isoYearWeek:"Y\\WW",isoYearWeek2:"Y-\\WW",
isoYearWeekDay:"Y\\WWj",isoYearWeekDay2:"Y-\\WW-j",mySQL:"Y-m-d h:i:s",postgreSQL:"Y.z",postgreSQL2:"Yz",soap:"Y-m-d\\TH:i:s.u",soap2:"Y-m-d\\TH:i:s.uP",unixTimestamp:"@U",xmlrpc:"Ymd\\TG:i:s",xmlrpcCompact:"Ymd\\tGis",wddx:"Y-n-j\\TG:i:s"},h={AMERICAN:"F j, Y",AMERICANSHORT:"m/d/Y",AMERICANSHORTWTIME:"m/d/Y h:i:sA",ATOM:"Y-m-d\\TH:i:sP",COOKIE:"l, d-M-Y H:i:s T",EUROPEAN:"j F Y",EUROPEANSHORT:"d.m.Y",EUROPEANSHORTWTIME:"d.m.Y H:i:s",ISO8601:"Y-m-d\\TH:i:sO",LEGAL:"j F Y",RFC822:"D, d M y H:i:s O",
RFC850:"l, d-M-y H:i:s T",RFC1036:"D, d M y H:i:s O",RFC1123:"D, d M Y H:i:s O",RFC2822:"D, d M Y H:i:s O",RFC3339:"Y-m-d\\TH:i:sP",RSS:"D, d M Y H:i:s O",W3C:"Y-m-d\\TH:i:sP"},f={"pretty-a":"g:i.sA l jS \\o\\f F, Y","pretty-b":"g:iA l jS \\o\\f F, Y","pretty-c":"n/d/Y g:iA","pretty-d":"n/d/Y","pretty-e":"F jS - g:ia","pretty-f":"g:iA","pretty-g":"F jS, Y","pretty-h":"F jS, Y g:mA"};if(c){if("compound"==c){if(!1===k)return e;var d={},b;for(b in e)d[b]=dateFormat(g,e[b]);return d}if(e[c])return dateFormat(g,
e[c],k);if("constants"==c){if(!1===k)return h;d={};for(b in h)d[b]=dateFormat(g,h[b]);return d}if(h[c])return dateFormat(g,h[c],k);if("pretty"==c){if(!1===k)return f;d={};for(b in f)d[b]=dateFormat(g,f[b]);return d}if(f[c])return dateFormat(g,f[c],k);e=c.split("");h="";for(b in e)(f=e[b])&&/[a-z]/i.test(f)&&!/\\/.test(h+f)&&(e[b]=d[f]?d[f].apply(g):f),h=e[b];return e.join("").replace(/\\/g,"")}return g};
; function dateFormat(g, c, k) {
function l(a, b) { a.setHours(a.getHours() + parseFloat(b)); return a } function m(a, b) { var c = "Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "); return b ? c[a.getDay()].substr(0, 3) : c[a.getDay()] } function n(a, b) { var c = "January February March April May June July August September October November December".split(" "); return b ? c[a.getMonth()].substr(0, 3) : c[a.getMonth()] } var d = {
d: function () { var a = this.getDate(); return 9 < a ? a : "0" + a }, D: function () { return m(this, !0) }, j: function () { return this.getDate() },
l: function () { return m(this) }, N: function () { return this.getDay() + 1 }, S: function () { var a = this.getDate(); return /^1[0-9]$/.test(a) ? "th" : /1$/.test(a) ? "st" : /2$/.test(a) ? "nd" : /3$/.test(a) ? "rd" : "th" }, w: function () { return this.getDay() }, z: function () { return Math.round(Math.abs((this.getTime() - (new Date("1/1/" + this.getFullYear())).getTime()) / 864E5)) }, W: function () { var a = new Date(this.getFullYear(), 0, 1); return Math.ceil(((this - a) / 864E5 + a.getDay() + 1) / 7) }, F: function () { return n(this) }, m: function () {
var a = this.getMonth() +
1; return 9 < a ? a : "0" + a
}, M: function () { return n(this, !0) }, n: function () { return this.getMonth() + 1 }, t: function () { return (new Date(this.getFullYear(), this.getMonth() + 1, 0)).getDate() }, L: function () { var a = this.getFullYear(); return 0 == a % 4 && 0 != a % 100 || 0 == a % 400 }, o: function () { return parseInt(this.getFullYear()) }, Y: function () { return parseInt(this.getFullYear()) }, y: function () { return parseInt((this.getFullYear() + "").substr(-2)) }, a: function () { return 12 <= this.getHours() ? "pm" : "am" }, A: function () {
return 12 <= this.getHours() ?
"PM" : "AM"
}, B: function () { return "@" + ("00" + Math.floor((60 * ((this.getHours() + 1) % 24 * 60 + this.getMinutes()) + this.getSeconds() + .001 * this.getMilliseconds()) / 86.4)).slice(-3) }, g: function () { var a = this.getHours(); return 0 == a ? 12 : 12 >= a ? a : a - 12 }, G: function () { return this.getHours() }, h: function () { var a = this.getHours(), a = 12 >= a ? a : a - 12; return 0 == a ? 12 : 9 < a ? a : "0" + a }, H: function () { var a = this.getHours(); return 9 < a ? a : "0" + a }, i: function () { var a = this.getMinutes(); return 9 < a ? a : "0" + a }, s: function () {
var a = this.getSeconds(); return 9 <
a ? a : "0" + a
}, u: function () { return this.getMilliseconds() }, e: function () { var a = this.toString().match(/ ([A-Z]{3,4})([-|+]?\d{4})/); return 1 < a.length ? a[1] : "" }, I: function () { var a = new Date(this.getFullYear(), 0, 1), b = new Date(this.getFullYear(), 6, 1), a = Math.max(a.getTimezoneOffset(), b.getTimezoneOffset()); return this.getTimezoneOffset() < a ? 1 : 0 }, O: function () { var a = this.toString().match(/ ([A-Z]{3,4})([-|+]?\d{4})/); return 2 < a.length ? a[2] : "" }, P: function () {
var a = this.toString().match(/ ([A-Z]{3,4})([-|+]?\d{4})/);
return 2 < a.length ? a[2].substr(0, 3) + ":" + a[2].substr(3, 2) : ""
}, T: function () { return this.toLocaleString("en", { timeZoneName: "short" }).split(" ").pop() }, Z: function () { return 60 * this.getTimezoneOffset() }, c: function () { return l(new Date(this), -(this.getTimezoneOffset() / 60)).toISOString() }, r: function () { return l(new Date(this), -(this.getTimezoneOffset() / 60)).toISOString() }, U: function () { return this.getTime() / 1E3 | 0 }
}, e = {
commonLogFormat: "d/M/Y:G:i:s", exif: "Y:m:d G:i:s", isoYearWeek: "Y\\WW", isoYearWeek2: "Y-\\WW",
isoYearWeekDay: "Y\\WWj", isoYearWeekDay2: "Y-\\WW-j", mySQL: "Y-m-d h:i:s", postgreSQL: "Y.z", postgreSQL2: "Yz", soap: "Y-m-d\\TH:i:s.u", soap2: "Y-m-d\\TH:i:s.uP", unixTimestamp: "@U", xmlrpc: "Ymd\\TG:i:s", xmlrpcCompact: "Ymd\\tGis", wddx: "Y-n-j\\TG:i:s"
}, h = {
AMERICAN: "F j, Y", AMERICANSHORT: "m/d/Y", AMERICANSHORTWTIME: "m/d/Y h:i:sA", ATOM: "Y-m-d\\TH:i:sP", COOKIE: "l, d-M-Y H:i:s T", EUROPEAN: "j F Y", EUROPEANSHORT: "d.m.Y", EUROPEANSHORTWTIME: "d.m.Y H:i:s", ISO8601: "Y-m-d\\TH:i:sO", LEGAL: "j F Y", RFC822: "D, d M y H:i:s O",
RFC850: "l, d-M-y H:i:s T", RFC1036: "D, d M y H:i:s O", RFC1123: "D, d M Y H:i:s O", RFC2822: "D, d M Y H:i:s O", RFC3339: "Y-m-d\\TH:i:sP", RSS: "D, d M Y H:i:s O", W3C: "Y-m-d\\TH:i:sP"
}, f = { "pretty-a": "g:i.sA l jS \\o\\f F, Y", "pretty-b": "g:iA l jS \\o\\f F, Y", "pretty-c": "n/d/Y g:iA", "pretty-d": "n/d/Y", "pretty-e": "F jS - g:ia", "pretty-f": "g:iA", "pretty-g": "F jS, Y", "pretty-h": "F jS, Y g:mA" }; if (c) {
if ("compound" == c) { if (!1 === k) return e; var d = {}, b; for (b in e) d[b] = dateFormat(g, e[b]); return d } if (e[c]) return dateFormat(g,
e[c], k); if ("constants" == c) { if (!1 === k) return h; d = {}; for (b in h) d[b] = dateFormat(g, h[b]); return d } if (h[c]) return dateFormat(g, h[c], k); if ("pretty" == c) { if (!1 === k) return f; d = {}; for (b in f) d[b] = dateFormat(g, f[b]); return d } if (f[c]) return dateFormat(g, f[c], k); e = c.split(""); h = ""; for (b in e) (f = e[b]) && /[a-z]/i.test(f) && !/\\/.test(h + f) && (e[b] = d[f] ? d[f].apply(g) : f), h = e[b]; return e.join("").replace(/\\/g, "")
} return g
};

View File

@ -6,7 +6,7 @@
import { Component, Input, Output, OnInit, OnDestroy, EventEmitter } from '@angular/core';
import { PopInService } from '../../service';
import { PopInService } from 'common/service';
@Component({
// moduleId: module.id.toString(),
@ -14,7 +14,6 @@ import { PopInService } from '../../service';
templateUrl: './popin.html',
styleUrls: [ './popin.less' ]
})
export class PopInComponent implements OnInit, OnDestroy {
@Input() id: string;
@Input() popTitle: string = 'No title';

View File

@ -11,7 +11,6 @@ import { Component } from '@angular/core';
templateUrl: './upload-file.html',
styleUrls: [ './upload-file.less' ]
})
export class UploadFileComponent {
files: any = [];
uploadFile(event) {

View File

@ -0,0 +1,6 @@
import { NodeData, isNodeData } from "./node";
export {
NodeData, isNodeData,
}

View File

@ -1,4 +1,4 @@
import { isArrayOf, isNumberFinite, isObject, isOptionalOf, isOptionalArrayOf, isString } from "../utils";
import { isArrayOf, isNumberFinite, isObject, isOptionalOf, isOptionalArrayOf, isString } from "common/utils";

View File

@ -4,17 +4,15 @@
* @license PROPRIETARY (see license file)
*/
import { Injectable, Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { PopInService } from '../../service';
import { PopInService } from 'common/service';
@Component({
selector: 'delete-confirm',
templateUrl: './delete-confirm.html',
styleUrls: [ './delete-confirm.less' ]
})
@Injectable()
export class PopInDeleteConfirm implements OnInit {
@Input() comment: string = null;
@Input() imageUrl: string = null;

View File

@ -4,18 +4,16 @@
* @license PROPRIETARY (see license file)
*/
import { Injectable, Component, OnInit, Input, SimpleChanges } from '@angular/core';
import { Component, OnInit, Input, SimpleChanges } from '@angular/core';
import { Router } from '@angular/router';
import { PopInService } from '../../service';
import { PopInService } from 'common/service';
@Component({
selector: 'upload-progress',
templateUrl: './upload-progress.html',
styleUrls: [ './upload-progress.less' ]
})
@Injectable()
export class PopInUploadProgress implements OnInit {
@Input() mediaTitle: string = '';
@Input() mediaUploaded: number = 0;

View File

@ -0,0 +1,3 @@
<p>
error-viewer works!
</p>

View File

@ -0,0 +1,24 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ArianeService } from 'app/service/ariane';
@Component({
selector: 'app-error-viewer',
templateUrl: './error-viewer.html',
styleUrls: [ './error-viewer.less' ]
})
export class ErrorViewerScene implements OnInit {
constructor(private route: ActivatedRoute,
private arianeService: ArianeService) { }
ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap);
}
}

View File

@ -0,0 +1,11 @@
import { ErrorViewerScene } from "./error-viewer/error-viewer";
import { SsoScene } from "./sso/sso";
import { UploadScene } from "../../app/scene/upload/upload";
export {
ErrorViewerScene,
SsoScene,
UploadScene,
};

View File

@ -6,7 +6,7 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { SSOService, UserService } from '../../service';
import { SSOService, UserService } from 'common/service';
@Component({
selector: 'app-sso',
@ -29,7 +29,7 @@ export class SsoScene implements OnInit {
ngOnInit() {
let self = this;
console.error("retreive data after SSO ng-init");
console.error("retreive data after SSO back");
const ssoData = this.route.snapshot.paramMap.get('data');
if (ssoData == null) {
this.ssoData = undefined;

View File

@ -5,27 +5,16 @@
*/
import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper';
import { DataInterface } from '../utils/dataInterface';
import { HttpWrapperService } from 'common/service/http-wrapper';
import { isNullOrUndefined } from 'common/utils';
import { DataInterface } from 'common/utils/dataInterface';
@Injectable()
export class BddService {
private bdd = {
type: null,
series: null,
season: null,
universe: null,
video: null
};
private bddPomise = {
type: null,
series: null,
season: null,
universe: null,
video: null
};
private baseLocalStorageName = 'yota_karusic_bdd_';
private bdd = {};
private bddPomise = {};
private baseLocalStorageName = 'bdd_';
private useLocalStorage = false; // we exceed the limit of 5MB
constructor(private http: HttpWrapperService) {
@ -80,17 +69,13 @@ export class BddService {
get(name: string): Promise<DataInterface> {
let self = this;
console.log(`Try to get DB '${ name }'`);
if(this.bdd[name] === undefined) {
console.log(`Try to get a non existant DB ... '${ name }'`);
return;
}
if(this.bdd[name] !== null) {
if( !isNullOrUndefined(this.bdd[name]) ) {
return new Promise((resolve, reject) => {
resolve(self.bdd[name]);
});
}
console.log(`get DB: ?? ${ name } ??`);
if(this.bddPomise[name] === null) {
if(isNullOrUndefined(this.bddPomise[name])) {
this.bddPomise[name] = [];
// Try to load Local Data (storage)
let retriveBDDString = null;
@ -142,32 +127,12 @@ export class BddService {
}
}
return new Promise((resolve, reject) => {
if(self.bdd[name] !== null) {
if(!isNullOrUndefined(self.bdd[name])) {
resolve(self.bdd[name]);
return;
}
self.bddPomise[name].push({ resolve: resolve, reject: reject });
});
}
getType(): Promise<DataInterface> {
return this.get('type');
}
getSeries(): Promise<DataInterface> {
return this.get('series');
}
getSeason(): Promise<DataInterface> {
return this.get('season');
}
getUniverse(): Promise<DataInterface> {
return this.get('universe');
}
getVideo(): Promise<DataInterface> {
return this.get('video');
}
}

View File

@ -0,0 +1,439 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpEventType } from '@angular/common/http';
import { environment } from 'environments/environment';
import { SessionService } from './session';
import { isArrayOfs, isBoolean, isNullOrUndefined, isNumber, isString } from 'common/utils';
export enum HTTPRequestModel {
POST = "POST",
GET = "GET",
PUT = "PUT",
DELETE = "DELETE",
PATCH = "PATCH",
}
export enum HTTPMimeType {
ALL = "*/*",
JSON = "application/json",
OCTET_STREAM = "application/octet-stream",
IMAGE = "image/*",
IMAGE_JPEG = "image/jpeg",
IMAGE_PNG = "image/png",
}
export type UrlPath = string | boolean | number | (string|boolean|number)[];
export type ProgressCallback = (count: number, total:number) => void;
export interface HTTPRequest {
server?: string;
endPoint: UrlPath;
requestType: HTTPRequestModel ;
accept: HTTPMimeType;
contentType: HTTPMimeType;
params?: object;
body?: any;
authorization?: string; // c'est un hook de merde ...
disableTocken?: boolean;
// progress interface to notify progression of the streaming.
progress?: ProgressCallback;
}
export interface ModelResponseHttp {
status: number,
data: any,
}
/**
* This service permit to add some data like tocken and authorisation.. ir automatically get the token if needed and retake it if expired...
*/
@Injectable()
export class HttpWrapperService {
private displayReturn:boolean = false;
constructor(private http: HttpClient,
private session: SessionService) {
}
addTokenIfNeeded(headerOption:any): any {
if(!isNullOrUndefined(this.session.getToken())) {
if(headerOption.Authorization === undefined) {
headerOption.Authorization = `Yota ${this.session.getToken()}`;
}
}
return headerOption;
}
request(properties: HTTPRequest) : Promise<Response> {
//uriRest:string, headerOption:any, params:any): Promise<{status:number, data:any}> {
console.log(`-------------------------------------------------------\nHTTP-wrapper GET '${ properties.endPoint }'\n\t\tparams=${ JSON.stringify(properties, null, 2)}`);
let connectionAdresse = this.createRESTCall2({
server: properties.server,
api: properties.endPoint,
inputOptions: properties.params,
});
let headers: any = {
'Accept': properties.accept,
//'Content-Type': properties.contentType,
}
if (properties.authorization !== undefined && properties.authorization !== null) {
headers['Authorization'] = properties.authorization;
}
if (properties.requestType !== HTTPRequestModel.GET) {
headers['Content-Type'] = properties.contentType;
}
console.log(`disble tocken : ${JSON.stringify(properties)} properties.disableTocken=${properties.disableTocken}`);
if (properties.disableTocken === undefined || properties.disableTocken === null || properties.disableTocken === true) {
headers = this.addTokenIfNeeded(headers);
}
console.log(`header: ${JSON.stringify(headers)}`);
let body = properties.body;
if (properties.contentType === HTTPMimeType.JSON) {
body = JSON.stringify(properties.body);
}
const result = fetch(connectionAdresse, {
method: properties.requestType,
headers,
body
})
return result;
};
requestJson(properties: HTTPRequest) : Promise<ModelResponseHttp> {
return new Promise((resolve, reject) => {
this.request(properties).then((response: Response) => {
if(response.status >= 200 && response.status <= 299) {
const contentType = response.headers.get('Content-Type');
if (contentType === HTTPMimeType.JSON) {
response.json().then((value:any) => {
//console.log(`REICEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
resolve({ status:response.status, data:value });
}).catch((reason:any)=> {
reject({ status:999, data:reason });
});
} else {
console.error(`content Type is not Json: ${contentType}`)
reject({ status:999, data:`content Type is not Json: ${contentType}` });
}
} else {
console.error(`wring correct status: ${response.status}`)
reject({ status:900, data: response });
}
}).catch((error: any) => {
reject({ status:error.status, data:error.error });
});
});
};
requestImage(properties: HTTPRequest) : Promise<ModelResponseHttp> {
return new Promise((resolve, reject) => {
this.request(properties).then((response: Response) => {
if(response.status >= 200 && response.status <= 299) {
const contentType = response.headers.get('Content-Type');
//console.log(`REICEIVE ==> ${response.status}`);
resolve({ status:900, data: response });
/*
resolve({ status:response.status, data:value });
}).catch((reason:any)=> {
reject({ status:999, data:reason });
});
} else {
console.error(`content Type is not Json: ${contentType}`)
reject({ status:999, data:`content Type is not Json: ${contentType}` });
}
*/
} else {
console.error(`wring correct status: ${response.status}`)
resolve({ status:900, data: response });
}
}).catch((error: any) => {
reject({ status:error.status, data:error.error });
});
});
}
createRESTCall2({ api, server, inputOptions, addURLToken }: { server?: string; api: UrlPath; inputOptions?: object; addURLToken?:boolean }) {
if (isNullOrUndefined(server)) {
server = environment.defaultServer;
}
const basePage = environment.server[server];
let addressServerRest = `${basePage }/`;
let options = inputOptions;
if(isNullOrUndefined(options)) {
options = {};
}
let out = addressServerRest;
if (isArrayOfs(api, isString, isNumber, isBoolean)) {
for (let iii=0; iii<api.length; iii++) {
let elem = api[iii];
out += `/${elem}`;
}
} else {
out += api;
}
let first = true;
let keys = Object.keys(options);
for(let iii = 0; iii < keys.length; iii++) {
if(first === false) {
out = `${out }&`;
} else {
out = `${out }?`;
first = false;
}
out = out + keys[iii];
if (options[keys[iii]] != null) {
out = out + "=" + options[keys[iii]];
}
}
console.log(`try to get session : ${this.session.getToken()}`);
if (!isNullOrUndefined(this.session.getToken())) {
if (addURLToken !== undefined && addURLToken === true) {
if(first === false) {
out = `${out }&`;
} else {
out = `${out }?`;
}
out = out + `Authorization=Yota ${this.session.getToken()}`;
}
}
return out;
}
// Deprecated ...
createRESTCall(api: string, inputOptions?: any) {
let basePage = environment.server[environment.defaultServer];
let addressServerRest = `${basePage }/`;
let options = inputOptions;
if(options === undefined) {
options = [];
}
let out = addressServerRest + api;
let first = true;
for(let iii = 0; iii < options.length; iii++) {
if(first === false) {
out = `${out }&`;
} else {
out = `${out }?`;
first = false;
}
out = out + options[iii];
}
return out;
}
// Deprecated ... old model stream
post(uriRest:string, headerOption:any, data:any, progress:ProgressCallback = null) {
console.log(`-------------------------------------------------------\nHTTP-wrapper POST '${ uriRest }'\n\t\theaderOption=${ JSON.stringify(headerOption, null, 2)}\n\t\tdata=${ JSON.stringify(data, null, 2)}`);
this.addTokenIfNeeded(headerOption);
let connectionAdresse = this.createRESTCall(uriRest, {});
return new Promise((resolve, reject) => {
if(this.displayReturn === true) {
console.log(`call POST ${ connectionAdresse } data=${ JSON.stringify(data, null, 2)}`);
}
let request = this.http.post(connectionAdresse, data, {
headers: new HttpHeaders(headerOption),
reportProgress: true,
observe: 'events'
});
let self = this;
request.subscribe((res: any) => {
if(self.displayReturn === true) {
console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
}
if(res.type === HttpEventType.Sent) {
/* res.type === 0 */
console.log('post : Sent');
} else if(res.type === HttpEventType.UploadProgress) {
/* res.type === 1 */
// console.log("post : " + res.loaded + " / " + res.total);
progress(res.loaded, res.total);
} else if(res.type === HttpEventType.ResponseHeader) {
/* res.type === 2 */
console.log('post : get header');
} else if(res.type === HttpEventType.DownloadProgress) {
/* res.type === 3 */
console.log(`post : get DownloadProgress ${ res.loaded}`);
} else if(res.type === HttpEventType.Response) {
/* res.type === 4 */
console.log('post : get response');
if(res.httpCode) {
resolve({ status:res.httpCode, data:res });
} else {
resolve({ status:200, data:res });
}
} else if(res.type === HttpEventType.User) {
/* res.type === 5 */
console.log('post : get User');
} else {
console.log(`post : get unknown ... ${ res.type}`);
}
},
(error) => {
if(self.displayReturn === true) {
console.log(`an error occured status: ${ error.status}`);
console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
}
reject({ status:error.status, data:error.error });
});
});
}
// Deprecated ... old model stream
uploadMultipart(base:string, multipart:FormData, progress: ProgressCallback): any {
console.log(`Upload multipart to ${ base}`);
let url = base;
let self = this;
return new Promise((resolve, reject) => {
let headers = {
// 'Content-Type': 'multipart/form-data',
};// new Headers();
self.post(url, headers, multipart, progress)
.then((response: any) => {
console.log(`URL: ${ url }\nRespond(${ response.status }): ${ JSON.stringify(response.data, null, 2)}`);
if(response.status >= 200 && response.status <= 299) {
resolve(response.data.body);
return;
}
reject('An error occured');
}, (response: any) => {
if(typeof response.data === 'undefined') {
reject('return ERROR undefined');
} else {
reject('return ERROR ...');// + JSON.stringify(response, null, 2));
}
});
});
}
// Complex wrapper to simplify interaction:
getSpecific(urlPath: UrlPath):any {
return new Promise((resolve, reject) => {
this.requestJson({
endPoint: urlPath,
requestType: HTTPRequestModel.GET,
accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON,
})
.then((response: ModelResponseHttp) => {
//console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
if(response.status === 200) {
resolve(response.data);
return;
}
reject('An error occured');
}, (response: ModelResponseHttp) => {
if(isNullOrUndefined(response.data)) {
reject('return ERROR undefined');
} else {
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
}
});
});
}
// Complex wrapper to simplify interaction:s
putSpecific(urlPath: UrlPath, data: object):Promise<ModelResponseHttp> {
return new Promise((resolve, reject) => {
this.request({
endPoint: urlPath,
requestType: HTTPRequestModel.PUT,
accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON,
body: data,
}).then((response: Response) => {
if(response.status >= 200 && response.status <= 201) {
const contentType = response.headers.get('Content-Type');
if (contentType === HTTPMimeType.JSON) {
response.json().then((value:any) => {
//console.log(`REICEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
resolve({ status:response.status, data:value });
}).catch((reason:any)=> {
reject({ status:999, data:reason });
});
} else {
console.error(`content Type is not Json: ${contentType}`)
reject({ status: 998, data:`content Type is not Json: ${contentType}` });
}
} else {
console.error(`wrong correct status: ${response.status}`)
reject({ status: 900, data: response });
}
}).catch((error: any) => {
reject({ status:error.status, data:error.error });
});
});
}
postSpecific(urlPath: UrlPath, data: object):Promise<ModelResponseHttp> {
return new Promise((resolve, reject) => {
this.request({
endPoint: urlPath,
requestType: HTTPRequestModel.POST,
accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON,
body: data,
}).then((response: Response) => {
if(response.status >= 200 && response.status <= 201) {
const contentType = response.headers.get('Content-Type');
if (contentType === HTTPMimeType.JSON) {
response.json().then((value:any) => {
//console.log(`REICEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
resolve({ status:response.status, data:value });
}).catch((reason:any)=> {
reject({ status:999, data:reason });
});
} else {
console.error(`content Type is not Json: ${contentType}`)
reject({ status: 998, data:`content Type is not Json: ${contentType}` });
}
} else {
console.error(`wrong correct status: ${response.status}`)
reject({ status: 900, data: response });
}
}).catch((error: any) => {
reject({ status:error.status, data:error.error });
});
});
}
deleteSpecific(urlPath: UrlPath ):Promise<ModelResponseHttp> {
return new Promise((resolve, reject) => {
this.request({
endPoint: urlPath,
requestType: HTTPRequestModel.DELETE,
accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON,
}).then((response: Response) => {
if(response.status >= 200 && response.status <= 201) {
const contentType = response.headers.get('Content-Type');
if (contentType === HTTPMimeType.JSON) {
response.json().then((value:any) => {
//console.log(`REICEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
resolve({ status:response.status, data:value });
}).catch((reason:any)=> {
reject({ status:999, data:reason });
});
} else {
console.error(`content Type is not Json: ${contentType}`)
reject({ status: 998, data:`content Type is not Json: ${contentType}` });
}
} else {
console.error(`wrong correct status: ${response.status}`)
reject({ status: 900, data: response });
}
}).catch((error: any) => {
reject({ status:error.status, data:error.error });
});
});
}
}

View File

@ -0,0 +1,25 @@
import { BddService } from "./bdd";
import { CookiesService } from "./cookies";
import { HttpWrapperService, ModelResponseHttp, HTTPRequest, HTTPMimeType, HTTPRequestModel } from "./http-wrapper";
import { StorageService } from "./local-storage";
import { PopInService } from "./popin";
import { SessionService } from "./session";
import { SSOService } from "./sso";
import { UserService } from "./user";
export {
BddService,
CookiesService,
StorageService,
HttpWrapperService,
ModelResponseHttp,
HTTPRequest,
HTTPMimeType,
HTTPRequestModel,
PopInService,
SessionService,
UserService,
SSOService,
};

View File

@ -5,7 +5,7 @@
*/
import { Injectable } from '@angular/core';
import { environment } from '../../environments/environment';
import { environment } from 'environments/environment';
@Injectable()
export class StorageService {

View File

@ -15,7 +15,7 @@ export enum UserRoles222 {
@Injectable()
export class SessionService {
private tokenJwt = null;
public sessionData = null;
public sessionId = null;
public userLogin = null;
public userAdmin = null;
public userEMail = null;
@ -31,22 +31,22 @@ export class SessionService {
/**
* @brief Create a new session.
*
* @param sessionData -
* @param sessionId -
* @param userId -
* @param userLogin -
* @param userEMail -
* @param userAdmin -
* @param userAvatar -
*/
create(sessionData,
create(sessionId,
userId: string,
userLogin: string,
userEMail: string,
userAdmin: boolean,
userAvatar: string) {
console.log(`Session Create: userId=${userId} userLogin=${userLogin} userEMail=${userEMail} userAdmin=${userAdmin} userAvatar=${userAvatar} `);
console.log(`Session Create: userId=${userId} userLogin=${userLogin} userEMail=${userEMail} userAdmin=${userAdmin} userAvatar=${userAvatar} sessionId = ${sessionId}`);
this.tokenJwt = undefined;
this.sessionData = sessionData;
this.sessionId = sessionId;
this.userId = userId;
this.userLogin = userLogin;
this.userAdmin = userAdmin;
@ -60,8 +60,8 @@ export class SessionService {
*/
destroy() {
console.log('Session REMOVE');
let last = this.sessionData;
this.sessionData = null;
let last = this.sessionId;
this.sessionId = null;
this.tokenJwt = undefined;
this.userId = null;
this.userLogin = null;
@ -77,7 +77,7 @@ export class SessionService {
return this.tokenJwt;
}
islogged() {
return this.sessionData !== null;
return this.sessionId !== null;
}
hasRight(type) {
if(type === UserRoles222.admin) {
@ -86,7 +86,7 @@ export class SessionService {
}
if(type === UserRoles222.user) {
// is connected ==> is user
return this.sessionData !== null;
return this.sessionId !== null;
}
if(type === UserRoles222.guest) {
// all the other ... maybe unneeded
@ -101,9 +101,12 @@ export class SessionService {
return this.userLogin;
}
getAvatar() {
return 'assets/images/avatar_generic.svg';
/* This is not ready :
if(this.userAvatar === false) {
return 'assets/images/avatar_generic.svg';
}
return this.userId;
*/
}
}

View File

@ -5,7 +5,7 @@
*/
import { Injectable } from '@angular/core';
import { environment } from '../../environments/environment';
import { environment } from 'environments/environment';
@Injectable()
export class SSOService {
@ -14,6 +14,7 @@ export class SSOService {
console.log('Start SSOService');
}
utf8_to_b64( str:string ): string {
// remove unneeded "=" padding
return window.btoa(unescape(encodeURIComponent( str ))).replace("=", "");
}
@ -27,7 +28,22 @@ export class SSOService {
if (data != undefined) {
return this.utf8_to_b64(data);
}
return this.utf8_to_b64('home');
let pathName = window.location.pathname;
console.log("start Path-name: '" + pathName + "'");
console.log("check with: '" + environment.applName + "/sso/" + "'");
if (pathName.startsWith("/sso/") || pathName.startsWith(environment.applName + "/sso/")) {
return this.utf8_to_b64('home');
}
if (pathName.startsWith('/' + environment.applName + '/')) {
pathName = pathName.substring(environment.applName.length+2);
} else if (pathName.startsWith('/' + environment.applName)) {
pathName = pathName.substring(environment.applName.length + 1);
} else if (pathName.startsWith(environment.applName + '/')) {
pathName = pathName.substring(environment.applName.length+1);
} else if (pathName.startsWith(environment.applName)) {
pathName = pathName.substring(environment.applName.length);
}
return this.utf8_to_b64(pathName);
}
/**
* Request SSO connection

View File

@ -5,10 +5,10 @@
*/
import { Injectable } from '@angular/core';
import { environment } from '../../environments/environment';
import { environment } from 'environments/environment';
import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from './http-wrapper';
import { StorageService } from './local-storage';
import { StorageService } from 'common/service/local-storage';
import { SessionService } from './session';
import { SSOService } from './sso';
@ -33,8 +33,8 @@ declare function SHA512(param1: any): any;
export class UserService {
// 0: Not hide password; 1 hide password;
private identificationVersion: number = 1;
private cookiesRememberMe = 'karauth-remember-me';
private cookiesToken = 'karauth-token';
private cookiesRememberMe = 'remember-me';
private cookiesToken = 'token';
constructor(
private storageService: StorageService,
@ -74,6 +74,7 @@ export class UserService {
console.error(`Retreive exp data=${new Date(parsedData.exp*1000).toISOString()} < ${new Date().toISOString()}`);
const expireIn = new Date(parsedData.exp*1000);
const nowTime = new Date();
// TODO: set a marging of 2 hours...
return expireIn > nowTime;
}
/**
@ -84,25 +85,45 @@ export class UserService {
return new Promise<void>((resolve, reject) => {
// Need to use the windows global route to prevent the log in cycle ...
// And in the mlain application position, the route does not have curently root the page
if (window.location.pathname.startsWith("/sso/")) {
let pathName = window.location.pathname;
//console.log("start Path-name: '" + pathName + "'");
//console.log("check with: '" + environment.applName + "/sso/" + "'");
if (pathName.startsWith("/sso/") || pathName.startsWith(environment.applName + "/sso/")) {
console.log(" ==> SSo section");
reject();
return;
}
console.log(" ==> Check if need reconnect?");
let rememberMe = self.storageService.get(self.cookiesRememberMe)==="true";
// TODO: in case of jest reload ==> no need to manage the SSO ==> just keep the token ... it in enought...
let token = self.storageService.getSession(self.cookiesToken);
// TODO: check validity of th eToken:
if (self.isTokenUpToDate(token)) {
self.startSession(token, rememberMe).finally(() => {
// remove in case of fail !!!
this.storageService.removeSession(this.cookiesToken);
self.startSession(token, rememberMe).then(() => {
resolve();
})
}).catch(() => {
// jump in the sign-in page (automatically of request remember-me)
if(rememberMe) {
// jump to the sso !!! (remove local data to prevent login loop)
this.storageService.remove(this.cookiesRememberMe);
this.storageService.removeSession(this.cookiesToken);
self.ssoService.requestSignIn();
reject();
}
resolve();
});
} else {
console.log(`Get previous connection ... `);
if(rememberMe) {
// just to the sso !!!
// jump to the sso !!! (remove local data to prevent login loop)
this.storageService.remove(this.cookiesRememberMe);
this.storageService.removeSession(this.cookiesToken);
self.ssoService.requestSignIn();
reject();
}
resolve();
}
});
}

View File

@ -5,7 +5,7 @@
*/
import { NodeData } from "../model";
import { isArray, isNullOrUndefined, isUndefined } from "./validator";
import { isArray, isNullOrUndefined } from "./validator";
export enum TypeCheck {
EQUAL = '==',

View File

@ -1,7 +1,7 @@
import { DataInterface } from "./dataInterface";
import { isArray, isArrayOf, isBoolean, isNull, isNullOrUndefined, isNumber, isNumberFinite, isObject, isOptionalOf, isOptionalArrayOf, isString, isUndefined } from "./validator";
import { DataInterface, TypeCheck } from "./dataInterface";
import { isArray, isArrayOf, isBoolean, isNull, isNullOrUndefined, isNumber, isNumberFinite, isObject, isOptionalOf, isOptionalArrayOf, isString, isUndefined, isArrayOfs } from "./validator";
export {
isNumber,
@ -14,8 +14,10 @@ export {
isNullOrUndefined,
isObject,
isArrayOf,
isArrayOfs,
isOptionalOf,
isOptionalArrayOf,
DataInterface,
TypeCheck,
}

View File

@ -41,6 +41,28 @@ export function isArrayOf<TYPE>(data: any, typeChecker: (subData: any) => subDat
}
return true;
}
export function isArrayOfs<TYPE,TYPE2,TYPE3>(data: any,
typeChecker: (subData: any) => subData is TYPE,
typeChecker2?: (subData: any) => subData is TYPE2,
typeChecker3?: (subData: any) => subData is TYPE3): data is (TYPE|TYPE2|TYPE3)[] {
if (!isArray(data)) {
return false;
}
for (let iii=0; iii<data.length; iii++) {
let elem = data[iii];
if (typeChecker(elem) ) {
continue;
}
if (typeChecker2 != undefined && typeChecker2(elem) ) {
continue;
}
if (typeChecker3 != undefined && typeChecker3(elem) ) {
continue;
}
return false;
}
return true;
}
export function isOptionalOf<TYPE>(data: any, typeChecker: (subData: any) => subData is TYPE): data is TYPE | undefined {
return isUndefined(data) || typeChecker(data);

Some files were not shown because too many files have changed in this diff Show More