Series: |
diff --git a/front/src/app/scene/upload/upload.less b/front/src/app/scene/upload/upload.less
index 59ffd2f..b9618a5 100644
--- a/front/src/app/scene/upload/upload.less
+++ b/front/src/app/scene/upload/upload.less
@@ -44,9 +44,6 @@
border: 0px;
}
}
- .tool-colomn {
-
- }
}
.error {
border-color: rgba(200,0,0,1.0);
diff --git a/front/src/app/scene/upload/upload.ts b/front/src/app/scene/upload/upload.ts
index 3c85ab9..7d6b71c 100644
--- a/front/src/app/scene/upload/upload.ts
+++ b/front/src/app/scene/upload/upload.ts
@@ -7,7 +7,7 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
-import { TypeService, UniverseService, SeriesService, VideoService, ArianeService, SeasonService } from 'app/service';
+import { TypeService, SeriesService, VideoService, ArianeService, SeasonService } from 'app/service';
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
import { PopInService } from 'common/service';
@@ -24,7 +24,6 @@ export class FileParsedElement {
public episodeDetected: boolean = false;
constructor(
public file: File,
- public universe: string,
public series: string,
public season: number,
public episode: number,
@@ -65,9 +64,6 @@ export class UploadScene implements OnInit {
listType: ElementList[] = [
{ value: null, label: '---' },
];
- listUniverse: ElementList[] = [
- { value: null, label: '---' },
- ];
listSeries: ElementList[] = [
{ value: null, label: '---' },
];
@@ -95,16 +91,12 @@ export class UploadScene implements OnInit {
listSeason: ElementList[] = [
{ value: null, label: '---' },
];
- globalUniverse: string = '';
globalSeries: string = '';
globalSeason: number = null;
- constructor(private route: ActivatedRoute,
- private typeService: TypeService,
- private universeService: UniverseService,
+ constructor(private typeService: TypeService,
private seriesService: SeriesService,
private seasonService: SeasonService,
private videoService: VideoService,
- private arianeService: ArianeService,
private popInService: PopInService) {
// nothing to do.
}
@@ -127,20 +119,10 @@ export class UploadScene implements OnInit {
}
ngOnInit() {
- 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()
- .then((response2) => {
- for(let iii = 0; iii < response2.length; iii++) {
- self.listUniverse.push({ value: response2[iii].id, label: response2[iii].name });
- }
- }).catch((response2) => {
- console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
- });
this.typeService.getData()
.then((response2) => {
for(let iii = 0; iii < response2.length; iii++) {
@@ -216,11 +198,6 @@ export class UploadScene implements OnInit {
this.updateNeedSend();
}
- onUniverse(value: any): void {
- this.globalUniverse = value;
- this.updateNeedSend();
- }
-
onEpisode(data: FileParsedElement, value: any): void {
data.episode = value;
// console.log("change episode ID: " + value + " ==> " + this.parseEpisode.toString());
@@ -253,7 +230,6 @@ export class UploadScene implements OnInit {
clearData() {
- this.globalUniverse = '';
this.globalSeries = '';
this.globalSeason = null;
this.parsedElement = [];
@@ -269,7 +245,6 @@ export class UploadScene implements OnInit {
addFileWithMetaData(file: File) {
// parsedElement: FileParsedElement[] = [];
- let universe: string = null;
let series: string = null;
let season: number | null = null;
let episode: number | null = null;
@@ -311,13 +286,7 @@ export class UploadScene implements OnInit {
}
}
if(find === false) {
- if(season === null && episode === null) {
- if(universe === '') {
- universe = element;
- } else {
- universe = `${universe }-${ element}`;
- }
- } else if(title === '') {
+ if(title === '') {
title = element;
} else {
title = `${title }-${ element}`;
@@ -335,7 +304,7 @@ export class UploadScene implements OnInit {
}
// 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, series, season, episode, title);
console.log(`==>${ JSON.stringify(tmp)}`);
// add it in the list.
this.parsedElement.push(tmp);
@@ -355,17 +324,6 @@ export class UploadScene implements OnInit {
this.updateNeedSend();
return;
}
- // 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 }'`);
- this.parsedElement.splice(iii, 1);
- iii--;
- }
- }
// clean different series:
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 }'`);
@@ -387,7 +345,6 @@ export class UploadScene implements OnInit {
}
}
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;
@@ -442,10 +399,6 @@ 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 series
if(self.globalSeries !== null) {
if(self.upload.labelMediaTitle.length !== 0) {
@@ -474,7 +427,6 @@ 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,
@@ -609,10 +561,6 @@ export class UploadScene implements OnInit {
console.log(`GET event: ${ event}`);
this.popInService.close('popin-new-type');
}
- eventPopUpUniverse(event: string): void {
- console.log(`GET event: ${ event}`);
- this.popInService.close('popin-new-universe');
- }
newSeason(): void {
console.log('Request new Season...');
@@ -626,8 +574,4 @@ export class UploadScene implements OnInit {
console.log('Request new Type...');
this.popInService.open('popin-create-type');
}
- newUniverse() {
- console.log('Request new Universe...');
- this.popInService.open('popin-new-universe');
- }
}
diff --git a/front/src/app/scene/video-edit/video-edit.html b/front/src/app/scene/video-edit/video-edit.html
index 40da9d3..68f4b14 100644
--- a/front/src/app/scene/video-edit/video-edit.html
+++ b/front/src/app/scene/video-edit/video-edit.html
@@ -78,22 +78,6 @@
-
-
- Universe:
-
-
-
-
-
-
-
-
Series:
@@ -244,16 +228,3 @@
-
-
-
- Name:
-
-
-
diff --git a/front/src/app/scene/video-edit/video-edit.ts b/front/src/app/scene/video-edit/video-edit.ts
index 891fdf0..fc9834a 100644
--- a/front/src/app/scene/video-edit/video-edit.ts
+++ b/front/src/app/scene/video-edit/video-edit.ts
@@ -8,7 +8,7 @@ import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
-import { DataService, TypeService, UniverseService, SeriesService, VideoService, ArianeService } from 'app/service';
+import { DataService, TypeService, SeriesService, VideoService, ArianeService } from 'app/service';
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
import { NodeData } from 'common/model';
import { PopInService } from 'common/service';
@@ -24,7 +24,6 @@ class DataToSend {
name:string = '';
description:string = '';
episode?:number;
- universeId:number = null;
seriesId:number = null;
seasonId:number = null;
dataId:number = -1;
@@ -37,7 +36,6 @@ 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.dataId = this.dataId;
@@ -113,7 +111,6 @@ export class VideoEditScene implements OnInit {
constructor(
private route: ActivatedRoute,
private typeService: TypeService,
- private universeService: UniverseService,
private seriesService: SeriesService,
private videoService: VideoService,
private arianeService: ArianeService,
@@ -139,9 +136,6 @@ export class VideoEditScene implements OnInit {
if(this.data.typeId !== this.dataOri.typeId) {
this.needSend = true;
}
- if(this.data.universeId !== this.dataOri.universeId) {
- this.needSend = true;
- }
if(this.data.seriesId !== this.dataOri.seriesId) {
this.needSend = true;
}
@@ -167,21 +161,12 @@ export class VideoEditScene implements OnInit {
}
}
ngOnInit() {
- this.arianeService.updateManual(this.route.snapshot.paramMap);
this.idVideo = this.arianeService.getVideoId();
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()
- .then((response2) => {
- for(let iii = 0; iii < response2.length; iii++) {
- self.listUniverse.push({ value: response2[iii].id, label: response2[iii].name });
- }
- }).catch((response2) => {
- console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
- });
this.typeService.getData()
.then((response2) => {
for(let iii = 0; iii < response2.length; iii++) {
@@ -206,10 +191,6 @@ export class VideoEditScene implements OnInit {
self.data.name = response.name;
self.data.description = response.description;
self.data.episode = response.episode;
- self.data.universeId = response.universeId;
- if(self.data.universeId === undefined) {
- self.data.universeId = null;
- }
self.data.dataId = response.dataId;
self.data.time = response.time;
self.data.generatedName = "????????? TODO ????????? "; // response.generatedName;
@@ -259,11 +240,6 @@ export class VideoEditScene implements OnInit {
}
}
- onChangeUniverse(value:any):void {
- this.data.universeId = value;
- this.updateNeedSend();
- }
-
onChangeSeries(value:any):void {
this.data.seriesId = value;
if(this.data.seriesId === undefined) {
@@ -349,13 +325,6 @@ 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;
- } else {
- data.universeId = this.data.universeId;
- }
- }
if(this.data.seriesId !== this.dataOri.seriesId) {
if(this.data.seriesId === undefined) {
data.seriesId = null;
@@ -486,10 +455,6 @@ export class VideoEditScene implements OnInit {
console.log(`GET event: ${ event}`);
this.popInService.close('popin-new-type');
}
- eventPopUpUniverse(event: string): void {
- console.log(`GET event: ${ event}`);
- this.popInService.close('popin-new-universe');
- }
newSeason(): void {
console.log('Request new Season...');
@@ -503,10 +468,6 @@ export class VideoEditScene implements OnInit {
console.log('Request new Type...');
this.popInService.open('popin-create-type');
}
- newUniverse() {
- console.log('Request new Universe...');
- this.popInService.open('popin-new-universe');
- }
}
diff --git a/front/src/app/scene/video/video.ts b/front/src/app/scene/video/video.ts
index d59c8a7..2234e57 100644
--- a/front/src/app/scene/video/video.ts
+++ b/front/src/app/scene/video/video.ts
@@ -73,8 +73,7 @@ export class VideoScene implements OnInit {
displayNeedHide:boolean = false;
timeLeft: number = 10;
interval = null;
- constructor(private route: ActivatedRoute,
- private videoService: VideoService,
+ constructor(private videoService: VideoService,
private seriesService: SeriesService,
private seasonService: SeasonService,
private httpService: HttpWrapperService,
@@ -182,7 +181,6 @@ export class VideoScene implements OnInit {
ngOnInit() {
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}`);
diff --git a/front/src/app/service/GenericInterfaceModelDB.ts b/front/src/app/service/GenericInterfaceModelDB.ts
index c3515b9..9e93dd3 100644
--- a/front/src/app/service/GenericInterfaceModelDB.ts
+++ b/front/src/app/service/GenericInterfaceModelDB.ts
@@ -1,6 +1,6 @@
-import { NodeData } from "common/model";
+import { isNodeData, NodeData } from "common/model";
import { HttpWrapperService, BddService } from "common/service";
-import { DataInterface, isNullOrUndefined } from "common/utils";
+import { DataInterface, isArrayOf, isNullOrUndefined, TypeCheck } from "common/utils";
export class GenericInterfaceModelDB {
constructor(
@@ -10,6 +10,65 @@ export class GenericInterfaceModelDB {
// nothing to do ...
}
+ gets(): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ self.bdd.get(self.serviceName)
+ .then((response: DataInterface) => {
+ let data = response.gets();
+ if(isNullOrUndefined(data)) {
+ reject('Data does not exist in the local BDD');
+ return;
+ }
+ resolve(data);
+ return;
+ }).catch((response) => {
+ reject(response);
+ });
+ });
+ }
+
+ getLike(nameArtist:string):any {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ self.bdd.get(self.serviceName)
+ .then((response:DataInterface) => {
+ let data = response.getNameLike(nameArtist);
+ if(data === null || data === undefined || data.length === 0) {
+ reject('Data does not exist in the local BDD');
+ return;
+ }
+ resolve(data);
+ return;
+ }).catch((response) => {
+ reject(response);
+ });
+ });
+ }
+ getOrder(): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ self.bdd.get(self.serviceName)
+ .then((response: DataInterface) => {
+ let data = response.getsWhere([
+ {
+ check: TypeCheck.NOT_EQUAL,
+ key: 'id',
+ value: [undefined, null],
+ },
+ ],
+ [ 'name', 'id' ]);
+ //data = response.gets();
+ if (isArrayOf(data, isNodeData)) {
+ resolve(data);
+ }
+ reject("The model is wrong ...");
+ }).catch((response) => {
+ console.log(`[E] ${ self.constructor.name }: can not retrive BDD values`);
+ reject(response);
+ });
+ });
+ }
get(id:number): Promise {
let self = this;
return new Promise((resolve, reject) => {
@@ -27,6 +86,26 @@ export class GenericInterfaceModelDB {
});
});
}
+ getAll(ids: number[]): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ self.bdd.get(self.serviceName)
+ .then((response: DataInterface) => {
+ let data = response.getsWhere([
+ {
+ check: TypeCheck.EQUAL,
+ key: 'id',
+ value: ids,
+ },
+ ],
+ [ 'name', 'id' ]);
+ resolve(data);
+ return;
+ }).catch((response) => {
+ reject(response);
+ });
+ });
+ }
getData(): Promise {
let self = this;
@@ -42,6 +121,11 @@ export class GenericInterfaceModelDB {
});
}
+ insert(data: any): any {
+ let ret = this.http.postSpecific([this.serviceName], data);
+ return this.bdd.addAfterPost(this.serviceName, ret);
+
+ }
put(id:number, data:any):any {
let ret = this.http.putSpecific([this.serviceName, id], data);
return this.bdd.setAfterPut(this.serviceName, id, ret);
@@ -93,4 +177,4 @@ export class GenericInterfaceModelDB {
});
}
-}
\ No newline at end of file
+}
diff --git a/front/src/app/service/ariane.ts b/front/src/app/service/ariane.ts
index 8281cee..a6ef875 100644
--- a/front/src/app/service/ariane.ts
+++ b/front/src/app/service/ariane.ts
@@ -6,53 +6,71 @@
import { Injectable, Output, EventEmitter } from '@angular/core';
-import { Router } from '@angular/router';
+import { NavigationEnd, NavigationError, NavigationStart, 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 { NodeData } from 'common/model';
+import { isNullOrUndefined, isStringNullOrUndefined, isUndefined } from 'common/utils';
export class InputOrders {
- public typeId: number = null;
- public universeId: number = null;
- public seriesId: number = null;
- public seasonId: number = null;
- public videoId: number = null;
+ public typeId: number = undefined;
+ public seriesId: number = undefined;
+ public seasonId: number = undefined;
+ public videoId: number = undefined;
}
@Injectable()
export class ArianeService {
- public typeId: number = null;
- public typeName: string = null;
+ public typeId: number = undefined;
+ public typeName: string = undefined;
@Output() typeChange: EventEmitter = new EventEmitter();
- public universeId: number = null;
- public universeName: string = null;
- @Output() universeChange: EventEmitter = new EventEmitter();
-
- public seriesId: number = null;
- public seriesName: string = null;
+ public seriesId: number = undefined;
+ public seriesName: string = undefined;
@Output() seriesChange: EventEmitter = new EventEmitter();
- public seasonId: number = null;
- public seasonName: string = null;
+ public seasonId: number = undefined;
+ public seasonName: string = undefined;
@Output() seasonChange: EventEmitter = new EventEmitter();
- public videoId: number = null;
- public videoName: string = null;
+ public videoId: number = undefined;
+ public videoName: string = undefined;
@Output() videoChange: EventEmitter = new EventEmitter();
+ public segment: string = "";
+ @Output() segmentChange: EventEmitter = 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');
+ let self = this;
+ this.router.events.subscribe((event: any) => {
+ if (event instanceof NavigationStart) {
+ // Show progress spinner or progress bar
+ //console.log('>>>>>>>>>>>>>> Route change detected');
+ }
+
+ if (event instanceof NavigationEnd) {
+ // Hide progress spinner or progress bar
+ //this.currentRoute = event.url;
+ //console.log(`>>>>>>>>>>>> ${event}`);
+ self.updateProperties();
+ }
+
+ if (event instanceof NavigationError) {
+ // Hide progress spinner or progress bar
+
+ // Present error to user
+ //console.log(`<<<<<<<<<<<<< ${event.error}`);
+ }
+
+ });
}
updateParams(params) {
console.log(`sparams ${ params}`);
@@ -60,72 +78,71 @@ export class ArianeService {
if(params.typeId) {
this.setType(params.typeId);
} else {
- this.setType(null);
+ this.setType(undefined);
}
}
+ getCurrrentSegment(): string|undefined {
+ return this.segment;
+ }
- updateManual(params) {
- let typeId = params.get('typeId');
- if(typeId === null || typeId === undefined || typeId === 'null' || typeId === 'NULL' || typeId === '') {
- typeId = null;
- } else {
- typeId = parseInt(typeId, 10);
+ getIsParam(params: any, name: string): undefined|number {
+ let valueStr = params.get(name);
+ if(isNullOrUndefined(valueStr) || isStringNullOrUndefined(valueStr)) {
+ return undefined;
}
- console.log(`typeId = ${ typeId } ${ params.get('typeId')}`);
+ return parseInt(valueStr, 10);
- let universeId = params.get('universeId');
- if(universeId === null || universeId === undefined || universeId === 'null' || universeId === 'NULL' || universeId === '') {
- universeId = null;
- } else {
- universeId = parseInt(universeId, 10);
- }
- console.log(`universeId = ${ universeId } ${ params.get('universId')}`);
+ }
- let seriesId = params.get('seriesId');
- if(seriesId === null || seriesId === undefined || seriesId === 'null' || seriesId === 'NULL' || seriesId === '') {
- seriesId = null;
- } else {
- seriesId = parseInt(seriesId, 10);
- }
- console.log(`seriesId = ${ seriesId } ${ params.get('seriesId')}`);
+ updateProperties() {
+ let elem = this.router.routerState.root;
+ while (!isNullOrUndefined(elem.firstChild)) {
+ elem = elem.firstChild;
+ }
+ //console.log(`!!!!!!!!!!!!!!!!!!!!!!!!!! ${JSON.stringify(elem.snapshot.paramMap)}`);
+ let params = elem.snapshot.paramMap;
+ let segment: string[] = location.pathname.split("/");
+ while (segment.length > 1 && (segment[0] === "" || segment[0] === environment.applName)) {
+ segment = segment.slice(1);
+ }
+ if (segment.length > 0) {
+ if (this.segment !== segment[0]) {
+ this.segment = segment[0];
+ this.segmentChange.emit(this.segment)
+ }
+ } else {
+ if (this.segment !== "") {
+ this.segment = "";
+ this.segmentChange.emit(this.segment)
+ }
+ }
+ console.log(`segment: ${JSON.stringify(this.segment)}`);
+ console.log(`params: ${JSON.stringify(params)}`);
- let seasonId = params.get('seasonId');
- if(seasonId === null || seasonId === undefined || seasonId === 'null' || seasonId === 'NULL' || seasonId === '') {
- seasonId = null;
- } else {
- seasonId = parseInt(seasonId, 10);
- }
- console.log(`seasonId = ${ seasonId } ${ params.get('seasonId')}`);
- let videoId = params.get('videoId');
- if(videoId === null || videoId === undefined || videoId === 'null' || videoId === 'NULL' || videoId === '') {
- videoId = null;
- } else {
- videoId = parseInt(videoId, 10);
- }
- console.log(`videoId = ${ videoId } ${ params.get('videoId')}`);
+
+ let typeId = this.getIsParam(params, 'typeId');
+ let seriesId = this.getIsParam(params, 'seriesId');
+ let seasonId = this.getIsParam(params, 'seasonId');
+ let videoId = this.getIsParam(params, 'videoId');
this.setType(typeId);
- this.setUniverse(universeId);
this.setSeries(seriesId);
this.setSeason(seasonId);
this.setVideo(videoId);
}
reset():void {
- this.typeId = null;
- this.typeName = null;
+ this.typeId = undefined;
+ this.typeName = undefined;
this.typeChange.emit(this.typeId);
- this.universeId = null;
- this.universeName = null;
- this.universeChange.emit(this.universeId);
- this.seriesId = null;
- this.seriesName = null;
+ this.seriesId = undefined;
+ this.seriesName = undefined;
this.seriesChange.emit(this.seriesId);
- this.seasonId = null;
- this.seasonName = null;
+ this.seasonId = undefined;
+ this.seasonName = undefined;
this.seasonChange.emit(this.seasonId);
- this.videoId = null;
- this.videoName = null;
+ this.videoId = undefined;
+ this.videoName = undefined;
this.videoChange.emit(this.videoId);
}
@@ -136,10 +153,6 @@ export class ArianeService {
if (out.typeId === 0){
out.typeId = undefined;
}
- out.universeId = parseInt(this.route.snapshot.paramMap.get('universId'));
- if (out.universeId === 0){
- out.universeId = undefined;
- }
out.seriesId = parseInt(this.route.snapshot.paramMap.get('seriesId'));
if (out.seriesId === 0){
out.seriesId = undefined;
@@ -166,12 +179,9 @@ export class ArianeService {
if(this.typeId === id) {
return;
}
- if(id === undefined) {
- return;
- }
this.typeId = id;
this.typeName = '??--??';
- if(this.typeId === null) {
+ if(isUndefined(this.typeId)) {
this.typeChange.emit(this.typeId);
return;
}
@@ -184,52 +194,20 @@ export class ArianeService {
self.typeChange.emit(self.typeId);
});
}
- getTypeId():number {
+ getTypeId():number|undefined {
return this.typeId;
}
- getTypeName():string {
+ getTypeName():string|undefined {
return this.typeName;
}
- setUniverse(id:number) {
- if(this.universeId === id) {
- return;
- }
- if(id === undefined) {
- return;
- }
- this.universeId = id;
- this.universeName = '??--??';
- if(this.universeId === null) {
- this.universeChange.emit(this.universeId);
- return;
- }
- let self = this;
- this.universeService.get(id)
- .then((response: NodeData) => {
- self.universeName = response.name;
- self.universeChange.emit(self.universeId);
- }).catch((response) => {
- self.universeChange.emit(self.universeId);
- });
- }
- getUniverseId():number {
- return this.universeId;
- }
- getUniverseName():string {
- return this.universeName;
- }
-
- setSeries(id:number):void {
+ setSeries(id:number|undefined):void {
if(this.seriesId === id) {
return;
}
- if(id === undefined) {
- return;
- }
this.seriesId = id;
this.seriesName = '??--??';
- if(this.seriesId === null) {
+ if(isUndefined(this.seriesId)) {
this.seriesChange.emit(this.seriesId);
return;
}
@@ -249,16 +227,13 @@ export class ArianeService {
return this.seriesName;
}
- setSeason(id:number):void {
+ setSeason(id:number|undefined):void {
if(this.seasonId === id) {
return;
}
- if(id === undefined) {
- return;
- }
this.seasonId = id;
this.seasonName = '??--??';
- if(this.seasonId === null) {
+ if(isUndefined(this.seasonId)) {
this.seasonChange.emit(this.seasonId);
return;
}
@@ -279,16 +254,13 @@ export class ArianeService {
return this.seasonName;
}
- setVideo(id:number):void {
+ setVideo(id:number|undefined):void {
if(this.videoId === id) {
return;
}
- if(id === undefined) {
- return;
- }
this.videoId = id;
this.videoName = '??--??';
- if(this.videoId === null) {
+ if(isUndefined(this.videoId)) {
this.videoChange.emit(this.videoId);
return;
}
@@ -313,7 +285,6 @@ export class ArianeService {
/**
* 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
@@ -323,16 +294,15 @@ export class ArianeService {
*/
genericNavigate(
destination:string,
- universeId:number,
typeId:number,
seriesId:number,
seasonId:number,
videoId:number,
newWindows:boolean = false,
replaceCurrentPage: boolean = false): void {
- let addressOffset = `${destination }/${ universeId }/${ typeId }/${ seriesId }/${ seasonId }/${ videoId}`;
+ let addressOffset = `${ destination }/${ typeId }/${ seriesId }/${ seasonId }/${ videoId }`;
if(newWindows === true) {
- if(environment.frontBaseUrl === undefined || environment.frontBaseUrl === null || environment.frontBaseUrl === '') {
+ if(!isNullOrUndefined(environment.frontBaseUrl) || environment.frontBaseUrl === '') {
window.open(`/${ addressOffset}`);
} else {
window.open(`/${ environment.frontBaseUrl }/${ addressOffset}`);
@@ -342,50 +312,44 @@ export class ArianeService {
}
}
- navigateUniverse(id:number, newWindows:boolean):void {
- this.genericNavigate('universe', id, this.typeId, null, null, null, newWindows);
- }
- navigateUniverseEdit(id:number, newWindows:boolean):void {
- this.genericNavigate('universe-edit', id, this.typeId, 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', 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', id, null, null, null, newWindows);
}
navigateSeries(id:number, newWindows:boolean, ctrl:boolean = false):void {
if(ctrl === true) {
this.navigateSeriesEdit(id, newWindows);
return;
}
- this.genericNavigate('series', this.universeId, this.typeId, id, null, null, newWindows);
+ this.genericNavigate('series', this.typeId, id, null, null, newWindows);
}
navigateSeriesEdit(id:number, newWindows:boolean):void {
- this.genericNavigate('series-edit', this.universeId, this.typeId, id, null, null, newWindows);
+ this.genericNavigate('series-edit', this.typeId, id, null, null, newWindows);
}
navigateSeason(id:number, newWindows:boolean, ctrl:boolean = false, replaceCurrentPage: boolean = false):void {
if(ctrl === true) {
this.navigateSeasonEdit(id, newWindows);
return;
}
- this.genericNavigate('season', this.universeId, this.typeId, this.seriesId, id, null, newWindows, replaceCurrentPage);
+ this.genericNavigate('season', this.typeId, this.seriesId, id, null, newWindows, replaceCurrentPage);
}
navigateSeasonEdit(id:number, newWindows:boolean):void {
- this.genericNavigate('season-edit', this.universeId, this.typeId, this.seriesId, id, null, newWindows);
+ this.genericNavigate('season-edit', this.typeId, this.seriesId, id, null, newWindows);
}
navigateVideo(id:number, newWindows:boolean, ctrl:boolean = false):void {
if(ctrl === true) {
this.navigateVideoEdit(id, newWindows);
return;
}
- this.genericNavigate('video', this.universeId, this.typeId, this.seriesId, this.seasonId, id, newWindows);
+ this.genericNavigate('video', this.typeId, this.seriesId, this.seasonId, id, newWindows);
}
navigateVideoEdit(id:number, newWindows:boolean):void {
- this.genericNavigate('video-edit', this.universeId, this.typeId, this.seriesId, this.seasonId, id, newWindows);
+ this.genericNavigate('video-edit', this.typeId, this.seriesId, this.seasonId, id, newWindows);
}
}
diff --git a/front/src/app/service/index.ts b/front/src/app/service/index.ts
index 149f6b6..ac3717d 100644
--- a/front/src/app/service/index.ts
+++ b/front/src/app/service/index.ts
@@ -3,7 +3,6 @@ import { DataService } from "./data";
import { SeasonService } from "./season";
import { SeriesService } from "./series";
import { TypeService } from "./type";
-import { UniverseService } from "./universe";
import { VideoService } from "./video";
@@ -14,7 +13,6 @@ export {
SeasonService,
SeriesService,
TypeService,
- UniverseService,
VideoService,
};
diff --git a/front/src/app/service/universe.ts b/front/src/app/service/universe.ts
deleted file mode 100644
index f3f8a85..0000000
--- a/front/src/app/service/universe.ts
+++ /dev/null
@@ -1,29 +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, BddService } from 'common/service';
-import { GenericInterfaceModelDB } from './GenericInterfaceModelDB';
-
-@Injectable()
-export class UniverseService extends GenericInterfaceModelDB {
-
- constructor(http: HttpWrapperService,
- bdd: BddService) {
- super('universe', http, bdd);
- }
-
- getSubSeries(id:number, select:Array = []):any {
- // this.checkLocalBdd();
- }
-
- getSubVideo(id:number, select:Array = []):any {
- // this.checkLocalBdd();
- }
-
-}
-
diff --git a/front/src/app/service/video.ts b/front/src/app/service/video.ts
index 1027b77..4a565ab 100644
--- a/front/src/app/service/video.ts
+++ b/front/src/app/service/video.ts
@@ -50,7 +50,6 @@ export class VideoService extends GenericInterfaceModelDB {
}
uploadFile(file:File,
- universe?:string,
series?:string,
seriesId?:number,
season?:number,
@@ -62,7 +61,6 @@ export class VideoService extends GenericInterfaceModelDB {
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 {
diff --git a/front/src/common/error/error.html b/front/src/common/component/error/error.html
similarity index 100%
rename from front/src/common/error/error.html
rename to front/src/common/component/error/error.html
diff --git a/front/src/common/error/error.less b/front/src/common/component/error/error.less
similarity index 100%
rename from front/src/common/error/error.less
rename to front/src/common/component/error/error.less
diff --git a/front/src/common/error/error.ts b/front/src/common/component/error/error.ts
similarity index 100%
rename from front/src/common/error/error.ts
rename to front/src/common/component/error/error.ts
diff --git a/front/src/common/component/index.ts b/front/src/common/component/index.ts
new file mode 100644
index 0000000..c207617
--- /dev/null
+++ b/front/src/common/component/index.ts
@@ -0,0 +1,14 @@
+import { ErrorComponent } from "./error/error";
+import { PopInComponent } from "./popin/popin";
+import { TopMenuComponent } from "./top-menu/top-menu";
+import { UploadFileComponent } from "./upload-file/upload-file";
+
+
+export {
+ PopInComponent,
+ TopMenuComponent,
+ UploadFileComponent,
+ ErrorComponent,
+};
+
+
diff --git a/front/src/common/component/popin/popin.ts b/front/src/common/component/popin/popin.ts
index bee86b4..efd2d15 100644
--- a/front/src/common/component/popin/popin.ts
+++ b/front/src/common/component/popin/popin.ts
@@ -49,8 +49,9 @@ export class PopInComponent implements OnInit, OnDestroy {
}
// open popIn
open(): void {
+ //console.log(`open pop-in: ${this.id}`);
this.displayPopIn = true;
- // this.element.show();
+ //this.element.show();
}
// close popin
close(): void {
diff --git a/front/src/common/component/top-menu/top-menu.html b/front/src/common/component/top-menu/top-menu.html
new file mode 100644
index 0000000..fd3469c
--- /dev/null
+++ b/front/src/common/component/top-menu/top-menu.html
@@ -0,0 +1,88 @@
+
+
+
+
+
+ {{data.icon}} {{data.title}}
+
+
+ {{data.icon}}
+
+
+ {{data.title}}
+
+
+
+
+
+
+
+
+
diff --git a/front/src/app/component/top-menu/top-menu.less b/front/src/common/component/top-menu/top-menu.less
similarity index 82%
rename from front/src/app/component/top-menu/top-menu.less
rename to front/src/common/component/top-menu/top-menu.less
index 8b9dfea..5f37a8e 100644
--- a/front/src/app/component/top-menu/top-menu.less
+++ b/front/src/common/component/top-menu/top-menu.less
@@ -1,4 +1,27 @@
+
+.element-pos-left {
+ z-index: 5;
+ float: left;
+}
+.element-pos-right {
+ z-index: 5;
+ float: right;
+}
+.element-pos-center {
+ z-index: 5;
+ float: none;
+}
+
+.model_happy {
+ color:yellow;
+}
+.model_disable {
+ color:rgb(100, 100, 100);
+}
+.model_error {
+ color:darkred;
+}
.top {
.sub-menu {
@@ -59,18 +82,14 @@
}
}
- .user-menu {
+ .menu-left {
+ top:75px;
+ left:15px;
+ }
+ .menu-right {
top:75px;
right:15px;
}
- .edit-menu {
- top:75px;
- right:200px;
- }
- .edit-menu-mob {
- top:75px;
- right:25px;
- }
.fill-all {
position: absolute;
@@ -125,8 +144,21 @@
visibility: "visible";
}
}
+
}
+ .inert_element {
+ display:block;
+ float: left;
+ line-height: 56px;
+ z-index: 4;
+ margin: 0 3px 0 3px;
+ border: 0;
+ //text-transform: uppercase;
+ font-weight: bold;
+ font-size: 17px;
+ }
+
.ariane {
display:block;
float: left;
@@ -138,17 +170,6 @@
text-transform: uppercase;
font-weight: bold;
font-size: 15px;
- .item_ariane_separator {
- display:block;
- float: left;
- line-height: 56px;
- z-index: 4;
- margin: 0 3px 0 3px;
- border: 0;
- text-transform: uppercase;
- font-weight: bold;
- font-size: 30px;
- }
}
.material-icons {
diff --git a/front/src/common/component/top-menu/top-menu.ts b/front/src/common/component/top-menu/top-menu.ts
new file mode 100644
index 0000000..5661034
--- /dev/null
+++ b/front/src/common/component/top-menu/top-menu.ts
@@ -0,0 +1,109 @@
+/** @file
+ * @author Edouard DUPIN
+ * @copyright 2018, Edouard DUPIN, all right reserved
+ * @license PROPRIETARY (see license file)
+ */
+import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
+
+import { Router } from '@angular/router';
+import { isNullOrUndefined } from 'common/utils';
+import { MenuItem } from 'common/model/menu-item';
+
+
+
+export interface EventOnMenu {
+ menu: MenuItem;
+ newWindows: boolean;
+ ctrl: boolean;
+}
+
+@Component({
+ selector: 'app-top-menu',
+ templateUrl: './top-menu.html',
+ styleUrls: [ './top-menu.less' ]
+})
+export class TopMenuComponent implements OnInit {
+ @Input() menu: MenuItem[];
+ subMenu: MenuItem[] = undefined;
+ subMenuPosition: String = undefined;
+ @Output() callback: EventEmitter = new EventEmitter();
+
+ constructor(private router: Router) {
+
+ }
+
+ isNotButton(data: MenuItem) {
+ return isNullOrUndefined(data.navigateTo)
+ && (isNullOrUndefined(data.callback) || data.callback === false)
+ && isNullOrUndefined(data.subMenu);
+ }
+ isEnable(data: MenuItem) {
+ if (!isNullOrUndefined(data) && !isNullOrUndefined(data.enable) && data.enable === false) {
+ return false;
+ }
+ return true;
+ }
+
+ getPosition(data: string) : string {
+ return `float: ${data}`;
+ }
+
+ ngOnInit() {
+
+ }
+ onOutUserProperty(): void {
+ //console.log('onOutUserProperty ==> event...');
+ this.subMenu = undefined;
+ }
+ getClassMenuPosition(): string {
+ if (isNullOrUndefined(this.subMenuPosition)) {
+ return "menu-left";
+ }
+ return 'menu-' + this.subMenuPosition;
+ }
+ getClassModel(data?:string): string {
+ if (isNullOrUndefined(data)) {
+ return "";
+ }
+ return 'model_' + data;
+ }
+
+ onGeneric(data: MenuItem, event: any): void {
+ //console.log(`onGeneric()`);
+ // check if we need to navigate
+ if (!isNullOrUndefined(data.navigateTo)) {
+ // remove in every case the subMenu:
+ this.subMenu = undefined
+ this.subMenuPosition = undefined;
+ this.router.navigate([ data.navigateTo ]);
+ return;
+ }
+ if (!isNullOrUndefined(data.callback) && data.callback === true) {
+ //console.log(`Emit message on ${JSON.stringify(data)}`);
+ this.callback.emit({
+ menu: data,
+ newWindows: event.which === 2,
+ ctrl: event.ctrlKey,
+ });
+ return;
+ }
+ // check if we need to display a submenu
+ if (isNullOrUndefined(data.subMenu)) {
+ //just a toggle mode:
+ data.subMenu = undefined;
+ this.subMenuPosition = undefined;
+ return;
+ }
+ if (this.subMenu === data.subMenu) {
+ //just a toggle mode:
+ this.subMenu = undefined;
+ this.subMenuPosition = undefined;
+ return;
+ }
+ //console.log(`Set Menu: ${JSON.stringify(data.subMenu)}`);
+ // set the requested menu
+ this.subMenu = data.subMenu;
+ this.subMenuPosition = data.position;
+ }
+
+}
diff --git a/front/src/common/model/index.ts b/front/src/common/model/index.ts
index af5aba0..9c10c56 100644
--- a/front/src/common/model/index.ts
+++ b/front/src/common/model/index.ts
@@ -1,6 +1,8 @@
+import { isMenuItem, isMenuPosition, MenuItem, MenuPosition } from "./menu-item";
import { NodeData, isNodeData } from "./node";
export {
NodeData, isNodeData,
-}
\ No newline at end of file
+ MenuPosition, isMenuPosition, MenuItem, isMenuItem,
+}
diff --git a/front/src/common/model/menu-item.ts b/front/src/common/model/menu-item.ts
new file mode 100644
index 0000000..6ada30b
--- /dev/null
+++ b/front/src/common/model/menu-item.ts
@@ -0,0 +1,71 @@
+import { isObject, isOptionalOf, isString, isNullOrUndefined, isOptionalArrayOf } from "common/utils";
+
+export enum MenuPosition {
+ LEFT = "left",
+ RIGHT = "right",
+ CENTER = "none",
+}
+
+export function isMenuPosition(data: any): data is MenuPosition {
+ return data === "left"
+ || data === "right"
+ || data === "none";
+
+}
+
+export interface MenuItem {
+ // Position of the menue element
+ position: MenuPosition;
+ // Hover help
+ hover?: string;
+ // Icon of the menue (need to be a meterial-icon name
+ icon?: string;
+ // If we want to display an image instead of an icon
+ image?: string;
+ // Displayed Title
+ title: string;
+ // Jump Link (If undefined: it is considered as text and not a button)
+ model?: string;
+ // Jump Link (If undefined: it is considered as text and not a button)
+ navigateTo?: string;
+ // if it request a callbak with the curent element: (not compatible with the previous)
+ callback?: boolean;
+ // Other data that want to be set by the user
+ otherData?: any;
+ // Enable or not the elemnt
+ enable?: boolean;
+ // Menu model For a subList of elements
+ subMenu?: MenuItem[];
+};
+
+
+export function isMenuItem(data: any): data is MenuItem {
+ if (isNullOrUndefined(data)) {
+ return false;
+ }
+ if (!isObject(data)) {
+ return false;
+ }
+ if (!isMenuPosition(data.position)) {
+ return false;
+ }
+ if (!isOptionalOf(data.hover, isString)) {
+ return false;
+ }
+ if (!isOptionalOf(data.icon, isString)) {
+ return false;
+ }
+ if (!isOptionalOf(data.image, isString)) {
+ return false;
+ }
+ if (!isString(data.title)) {
+ return false;
+ }
+ if (!isOptionalOf(data.navigateTo, isString)) {
+ return false;
+ }
+ if (!isOptionalArrayOf(data.subMenu, isMenuItem)) {
+ return false;
+ }
+ return true;
+}
diff --git a/front/src/common/popin/index.ts b/front/src/common/popin/index.ts
new file mode 100644
index 0000000..ba9ced4
--- /dev/null
+++ b/front/src/common/popin/index.ts
@@ -0,0 +1,8 @@
+import { PopInDeleteConfirm } from "./delete-confirm/delete-confirm";
+import { PopInUploadProgress } from "./upload-progress/upload-progress";
+
+
+export {
+ PopInDeleteConfirm,
+ PopInUploadProgress,
+}
\ No newline at end of file
diff --git a/front/src/common/popin/upload-progress/upload-progress.ts b/front/src/common/popin/upload-progress/upload-progress.ts
index 216298a..18da1d8 100644
--- a/front/src/common/popin/upload-progress/upload-progress.ts
+++ b/front/src/common/popin/upload-progress/upload-progress.ts
@@ -86,6 +86,7 @@ export class PopInUploadProgress implements OnInit {
}
ngOnChanges(changes: SimpleChanges) {
+ //console.log(`Upload progress event : ${JSON.stringify(changes)}`);
this.progress = Math.trunc(this.mediaUploaded * 100 / this.mediaSize);
this.uploadDisplay = this.convertInHuman(this.mediaUploaded);
this.sizeDisplay = this.convertInHuman(this.mediaSize);
diff --git a/front/src/common/scene/404/404.html b/front/src/common/scene/404/404.html
new file mode 100644
index 0000000..aabf82e
--- /dev/null
+++ b/front/src/common/scene/404/404.html
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/front/src/common/scene/404/404.less b/front/src/common/scene/404/404.less
new file mode 100644
index 0000000..6e566e1
--- /dev/null
+++ b/front/src/common/scene/404/404.less
@@ -0,0 +1,50 @@
+
+.full-mode{
+ width:100%;
+ height:100%;
+ top:0;
+ left:0;
+ margin:0;
+ padding:0;
+ border:0;
+ float:left;
+ display:block;
+}
+
+.centered {
+ position:relative;
+ max-width:75%;
+ padding: 16px 32px 16px 32px;
+
+ top: 50%;
+ transform: ~"translate(0, -50%)";
+ font-size: 30px;
+
+ font-weight: 600;
+ text-align: center;
+ line-height: 200%;
+}
+
+.error {
+ font-size: 55px;
+ background-size: 45px;
+ /*background-attachment: fixed;*/
+ background-position: 0% 50%;
+ padding: 0 0 0 58px;
+ margin: 17px 0 17px 0;
+ text-shadow:0px 0px 4px #000000;
+ color: rgb(160, 44, 44);
+ i {
+ font-size: 55px;
+ }
+}
+
+.comment {
+ background-size: 45px;
+ /*background-attachment: fixed;*/
+ background-position: 0% 50%;
+ padding: 0 0 0 58px;
+ margin: 17px 0 17px 0;
+ text-shadow:0px 0px 4px #07213a;
+ color: white;
+}
diff --git a/front/src/common/scene/404/404.ts b/front/src/common/scene/404/404.ts
new file mode 100644
index 0000000..601f188
--- /dev/null
+++ b/front/src/common/scene/404/404.ts
@@ -0,0 +1,16 @@
+/** @file
+ * @author Edouard DUPIN
+ * @copyright 2018, Edouard DUPIN, all right reserved
+ * @license PROPRIETARY (see license file)
+ */
+
+import { Component } from '@angular/core';
+
+@Component({
+ selector: 'app-404-not-found',
+ templateUrl: './404.html',
+ styleUrls: [ './404.less' ]
+})
+export class NotFound404Scene {
+ constructor() { }
+}
diff --git a/front/src/common/scene/error-viewer/error-viewer.ts b/front/src/common/scene/error-viewer/error-viewer.ts
index 4970b65..e798a66 100644
--- a/front/src/common/scene/error-viewer/error-viewer.ts
+++ b/front/src/common/scene/error-viewer/error-viewer.ts
@@ -6,7 +6,6 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
-import { ArianeService } from 'app/service/ariane';
@Component({
selector: 'app-error-viewer',
@@ -14,11 +13,10 @@ import { ArianeService } from 'app/service/ariane';
styleUrls: [ './error-viewer.less' ]
})
export class ErrorViewerScene implements OnInit {
- constructor(private route: ActivatedRoute,
- private arianeService: ArianeService) { }
+ constructor(private route: ActivatedRoute) { }
ngOnInit() {
- this.arianeService.updateManual(this.route.snapshot.paramMap);
+
}
}
diff --git a/front/src/common/scene/forbidden/forbidden.html b/front/src/common/scene/forbidden/forbidden.html
new file mode 100644
index 0000000..f0ad92f
--- /dev/null
+++ b/front/src/common/scene/forbidden/forbidden.html
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/front/src/common/scene/forbidden/forbidden.less b/front/src/common/scene/forbidden/forbidden.less
new file mode 100644
index 0000000..9a6a44f
--- /dev/null
+++ b/front/src/common/scene/forbidden/forbidden.less
@@ -0,0 +1,51 @@
+
+.full-mode{
+ width:100%;
+ height:100%;
+ top:0;
+ left:0;
+ margin:0;
+ padding:0;
+ border:0;
+ float:left;
+ display:block;
+}
+
+.centered {
+ position:relative;
+ max-width:500px;
+ padding: 16px 32px 16px 32px;
+
+ top: 50%;
+ left: 50%;
+ transform: ~"translate(-50%, -50%)";
+ font-size: 30px;
+
+ font-weight: 600;
+ text-align: left;
+ line-height: 200%;
+}
+
+.error {
+ font-size: 55px;
+ background-size: 45px;
+ /*background-attachment: fixed;*/
+ background-position: 0% 50%;
+ padding: 0 0 0 58px;
+ margin: 17px 0 17px 0;
+ text-shadow:0px 0px 4px #000000;
+ color: rgb(160, 44, 44);
+ i {
+ font-size: 55px;
+ }
+}
+
+.comment {
+ background-size: 45px;
+ /*background-attachment: fixed;*/
+ background-position: 0% 50%;
+ padding: 0 0 0 58px;
+ margin: 17px 0 17px 0;
+ text-shadow:0px 0px 4px #07213a;
+ color: white;
+}
diff --git a/front/src/common/scene/forbidden/forbidden.ts b/front/src/common/scene/forbidden/forbidden.ts
new file mode 100644
index 0000000..67b3b57
--- /dev/null
+++ b/front/src/common/scene/forbidden/forbidden.ts
@@ -0,0 +1,16 @@
+/** @file
+ * @author Edouard DUPIN
+ * @copyright 2018, Edouard DUPIN, all right reserved
+ * @license PROPRIETARY (see license file)
+ */
+
+import { Component } from '@angular/core';
+
+@Component({
+ selector: 'app-forbidden',
+ templateUrl: './forbidden.html',
+ styleUrls: [ './forbidden.less' ]
+})
+export class ForbiddenScene {
+ constructor() { }
+}
diff --git a/front/src/common/scene/home-out/home-out.html b/front/src/common/scene/home-out/home-out.html
new file mode 100644
index 0000000..8be721f
--- /dev/null
+++ b/front/src/common/scene/home-out/home-out.html
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/front/src/common/scene/home-out/home-out.less b/front/src/common/scene/home-out/home-out.less
new file mode 100644
index 0000000..6e566e1
--- /dev/null
+++ b/front/src/common/scene/home-out/home-out.less
@@ -0,0 +1,50 @@
+
+.full-mode{
+ width:100%;
+ height:100%;
+ top:0;
+ left:0;
+ margin:0;
+ padding:0;
+ border:0;
+ float:left;
+ display:block;
+}
+
+.centered {
+ position:relative;
+ max-width:75%;
+ padding: 16px 32px 16px 32px;
+
+ top: 50%;
+ transform: ~"translate(0, -50%)";
+ font-size: 30px;
+
+ font-weight: 600;
+ text-align: center;
+ line-height: 200%;
+}
+
+.error {
+ font-size: 55px;
+ background-size: 45px;
+ /*background-attachment: fixed;*/
+ background-position: 0% 50%;
+ padding: 0 0 0 58px;
+ margin: 17px 0 17px 0;
+ text-shadow:0px 0px 4px #000000;
+ color: rgb(160, 44, 44);
+ i {
+ font-size: 55px;
+ }
+}
+
+.comment {
+ background-size: 45px;
+ /*background-attachment: fixed;*/
+ background-position: 0% 50%;
+ padding: 0 0 0 58px;
+ margin: 17px 0 17px 0;
+ text-shadow:0px 0px 4px #07213a;
+ color: white;
+}
diff --git a/front/src/common/scene/home-out/home-out.ts b/front/src/common/scene/home-out/home-out.ts
new file mode 100644
index 0000000..40367f2
--- /dev/null
+++ b/front/src/common/scene/home-out/home-out.ts
@@ -0,0 +1,16 @@
+/** @file
+ * @author Edouard DUPIN
+ * @copyright 2018, Edouard DUPIN, all right reserved
+ * @license PROPRIETARY (see license file)
+ */
+
+import { Component } from '@angular/core';
+
+@Component({
+ selector: 'app-home-out',
+ templateUrl: './home-out.html',
+ styleUrls: [ './home-out.less' ]
+})
+export class HomeOutScene {
+ constructor() { }
+}
diff --git a/front/src/common/scene/index.ts b/front/src/common/scene/index.ts
index 74f0187..0421ef5 100644
--- a/front/src/common/scene/index.ts
+++ b/front/src/common/scene/index.ts
@@ -1,11 +1,17 @@
import { ErrorViewerScene } from "./error-viewer/error-viewer";
+import { ForbiddenScene } from "./forbidden/forbidden";
import { SsoScene } from "./sso/sso";
-import { UploadScene } from "../../app/scene/upload/upload";
+//import { UploadScene } from "../../app/scene/upload/upload";
+import { HomeOutScene } from "./home-out/home-out";
+import { NotFound404Scene } from "./404/404";
export {
ErrorViewerScene,
SsoScene,
- UploadScene,
+ //UploadScene,
+ ForbiddenScene,
+ HomeOutScene,
+ NotFound404Scene,
};
diff --git a/front/src/common/scene/sso/sso.ts b/front/src/common/scene/sso/sso.ts
index 691b2f6..3bca6f3 100644
--- a/front/src/common/scene/sso/sso.ts
+++ b/front/src/common/scene/sso/sso.ts
@@ -29,7 +29,7 @@ export class SsoScene implements OnInit {
ngOnInit() {
let self = this;
- console.error("retreive data after SSO back");
+ console.log(`call after SSO back: ${window.location.href}`);
const ssoData = this.route.snapshot.paramMap.get('data');
if (ssoData == null) {
this.ssoData = undefined;
@@ -48,20 +48,19 @@ export class SsoScene implements OnInit {
} else {
this.keepConnected = keepConnected === 'true';
}
- console.error(`ssoData: '${ssoData}'`);
- console.error(`token: '${token}'`);
- console.error(`keepConnected: '${keepConnected}'`);
+ console.log(`ssoData: '${ssoData}'`);
+ console.log(`token: '${token}'`);
+ console.log(`keepConnected: '${keepConnected}'`);
if (this.token !== '__CANCEL__' && this.token !== '__FAIL__' && this.token !== '__LOGOUT__') {
const destination = (this.ssoData);
- console.error(`ssoData (decoded): '${destination}'`);
- // sample : ZZ**DST:home
+ console.log(`ssoData (decoded): '${destination}'`);
const realDst = this.ssoService.unHashLocalData(destination);
- console.error(`realDst: '${realDst}'`);
+ console.log(`realDst: '${realDst}'`);
this.userService.startSession(this.token, this.keepConnected).then((userName: string) => {
self.userName = userName;
setTimeout(function(){
self.router.navigate([ realDst ], { replaceUrl:true });
- }, 2000); // 2 seconds
+ }, 500); // 2 seconds
}).catch(() => {
this.token = "ERROR_ME";
})
@@ -74,7 +73,7 @@ export class SsoScene implements OnInit {
console.error(`realDst: '${realDst}'`);
setTimeout(function(){
self.router.navigate([ realDst ], { replaceUrl:true });
- }, 2000); // 2 seconds
+ }, 500); // 2 seconds
} else {
this.userService.removeSession();
}
diff --git a/front/src/common/service/bdd.ts b/front/src/common/service/bdd.ts
index 78a3f3f..b28add6 100644
--- a/front/src/common/service/bdd.ts
+++ b/front/src/common/service/bdd.ts
@@ -21,6 +21,24 @@ export class BddService {
console.log('Start BddService');
}
+ addAfterPost(name: string, ret: any) {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ self.get(name)
+ .then((response:DataInterface) => {
+ let responseTmp = response;
+ ret.then((response2) => {
+ responseTmp.add(response2);
+ resolve(response2);
+ }).catch((response2) => {
+ reject(response2);
+ });
+ }).catch((response) => {
+ reject(response);
+ });
+ });
+ }
+
setAfterPut(name: string, id: number, ret: any) {
let self = this;
return new Promise((resolve, reject) => {
@@ -68,13 +86,13 @@ export class BddService {
get(name: string): Promise {
let self = this;
- console.log(`Try to get DB '${ name }'`);
+ //console.log(`Try to get DB '${ name }'`);
if( !isNullOrUndefined(this.bdd[name]) ) {
return new Promise((resolve, reject) => {
resolve(self.bdd[name]);
});
}
- console.log(`get DB: ?? ${ name } ??`);
+ //console.log(`get DB: ?? ${ name } ??`);
if(isNullOrUndefined(this.bddPomise[name])) {
this.bddPomise[name] = [];
// Try to load Local Data (storage)
@@ -83,31 +101,31 @@ export class BddService {
localStorage.getItem(this.baseLocalStorageName + name);
}
if(retriveBDDString !== null) {
- console.log(`retrive local bdd string (${ name })= ${ retriveBDDString}`);
+ //console.log(`retrive local bdd string (${ name })= ${ retriveBDDString}`);
let retriveBDD = JSON.parse(retriveBDDString);
- console.log(`retrive local bdd (${ name })= ${ retriveBDD}`);
+ //console.log(`retrive local bdd (${ name })= ${ retriveBDD}`);
let retriveBDDTmp = new DataInterface(name, retriveBDD);
self.bdd[name] = retriveBDDTmp;
for(let iii = 0; iii < self.bddPomise[name].length; iii++) {
self.bddPomise[name][iii].resolve(self.bdd[name]);
}
// brut force update of the BDD : TODO optimise it later ...
- console.log(`Update BDD (${ name })`);
+ //console.log(`Update BDD (${ name })`);
self.http.getSpecific(name)
.then((response) => {
- console.log(`end download DB: ==> ${ name } ${ response.length}`);
+ //console.log(`end download DB: ==> ${ name } ${ response.length}`);
self.bdd[name] = new DataInterface(name, response);
localStorage.setItem(self.baseLocalStorageName + name, JSON.stringify(self.bdd[name].bdd));
}).catch((response) => {
console.log(`[E] ${ self.constructor.name }: cant not get data from remote server: ${ name}`);
});
} else {
- console.log(`Download BDD (${ name })`);
+ //console.log(`Download BDD (${ name })`);
return new Promise((resolve, reject) => {
self.http.getSpecific(name)
.then((response) => {
- console.log(`end download DB: ==> ${ name } ${ response.length}`);// + " " + JSON.stringify(response).length);
+ //console.log(`end download DB: ==> ${ name } ${ response.length}`);// + " " + JSON.stringify(response).length);
self.bdd[name] = new DataInterface(name, response);
if(self.useLocalStorage === true) {
localStorage.setItem(self.baseLocalStorageName + name, JSON.stringify(self.bdd[name].bdd));
diff --git a/front/src/common/service/http-wrapper.ts b/front/src/common/service/http-wrapper.ts
index 2701004..f9515bc 100644
--- a/front/src/common/service/http-wrapper.ts
+++ b/front/src/common/service/http-wrapper.ts
@@ -62,9 +62,10 @@ export class HttpWrapperService {
}
addTokenIfNeeded(headerOption:any): any {
- if(!isNullOrUndefined(this.session.getToken())) {
+ const token = this.session.getToken();
+ if(!isNullOrUndefined(token)) {
if(headerOption.Authorization === undefined) {
- headerOption.Authorization = `Yota ${this.session.getToken()}`;
+ headerOption.Authorization = `Yota ${token}`;
}
}
return headerOption;
@@ -72,7 +73,7 @@ export class HttpWrapperService {
request(properties: HTTPRequest) : Promise {
//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)}`);
+ //console.log(`-------------------------------------------------------\nHTTP-wrapper GET '${ properties.endPoint }'\n\t\tparams=${ JSON.stringify(properties, null, 2)}`);
let connectionAdresse = this.createRESTCall2({
server: properties.server,
@@ -89,11 +90,11 @@ export class HttpWrapperService {
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) {
+ //console.log(`disble tocken : ${JSON.stringify(properties)} properties.disableTocken=${properties.disableTocken}`);
+ if (properties.disableTocken === undefined || properties.disableTocken === null || properties.disableTocken === false) {
headers = this.addTokenIfNeeded(headers);
}
- console.log(`header: ${JSON.stringify(headers)}`);
+ //console.log(`header: ${JSON.stringify(headers)}`);
let body = properties.body;
if (properties.contentType === HTTPMimeType.JSON) {
body = JSON.stringify(properties.body);
@@ -195,7 +196,7 @@ export class HttpWrapperService {
out = out + "=" + options[keys[iii]];
}
}
- console.log(`try to get session : ${this.session.getToken()}`);
+ //console.log(`try to get session : ${this.session.getToken()}`);
if (!isNullOrUndefined(this.session.getToken())) {
if (addURLToken !== undefined && addURLToken === true) {
if(first === false) {
@@ -232,7 +233,7 @@ export class HttpWrapperService {
}
// 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)}`);
+ //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, {});
@@ -251,33 +252,33 @@ export class HttpWrapperService {
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) {
+ 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}`);
- }
+ } 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) {
@@ -290,7 +291,7 @@ export class HttpWrapperService {
}
// Deprecated ... old model stream
uploadMultipart(base:string, multipart:FormData, progress: ProgressCallback): any {
- console.log(`Upload multipart to ${ base}`);
+ //console.log(`Upload multipart to ${ base}`);
let url = base;
let self = this;
@@ -301,7 +302,7 @@ export class HttpWrapperService {
self.post(url, headers, multipart, progress)
.then((response: any) => {
- console.log(`URL: ${ url }\nRespond(${ response.status }): ${ JSON.stringify(response.data, null, 2)}`);
+ //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;
diff --git a/front/src/common/service/index.ts b/front/src/common/service/index.ts
index 14c9d04..87020ac 100644
--- a/front/src/common/service/index.ts
+++ b/front/src/common/service/index.ts
@@ -3,7 +3,7 @@ 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 { OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome, SessionService } from "./session";
import { SSOService } from "./sso";
import { UserService } from "./user";
@@ -20,6 +20,10 @@ export {
SessionService,
UserService,
SSOService,
+ OnlyUsersGuard,
+ OnlyUsersGuardHome,
+ OnlyUnregisteredGuardHome,
+ OnlyAdminGuard,
};
diff --git a/front/src/common/service/local-storage.ts b/front/src/common/service/local-storage.ts
index 45eb232..4b0a2b2 100644
--- a/front/src/common/service/local-storage.ts
+++ b/front/src/common/service/local-storage.ts
@@ -16,7 +16,7 @@ import { environment } from 'environments/environment';
}
set(cname: string, cvalue: string): void {
- console.error(`storage set: ${cname} : ${cvalue}`);
+ //console.debug(`storage set: ${cname} : ${cvalue}`);
localStorage.setItem(this.baseLocalStorageName + cname, cvalue);
}
// limit at the current session ...
@@ -25,7 +25,7 @@ import { environment } from 'environments/environment';
}
remove(cname: string) : void {
- console.error(`storage remove: ${cname}`);
+ //console.debug(`storage remove: ${cname}`);
localStorage.removeItem(this.baseLocalStorageName + cname);
}
removeSession(cname: string) : void {
@@ -33,10 +33,10 @@ import { environment } from 'environments/environment';
}
get(cname: string) : string | undefined {
- console.error(`storage get: ${cname}`);
+ //console.debug(`storage get: ${cname}`);
// TODO check expire day...
const data = localStorage.getItem(this.baseLocalStorageName + cname);
- console.log(`get value form the storage (1): ${data}`)
+ //console.debug(`get value form the storage (1): ${data}`)
if (data === null || data === undefined) {
return undefined;
}
@@ -51,4 +51,4 @@ import { environment } from 'environments/environment';
}
}
-
\ No newline at end of file
+
diff --git a/front/src/common/service/session.ts b/front/src/common/service/session.ts
index 4fef44d..31a61a5 100644
--- a/front/src/common/service/session.ts
+++ b/front/src/common/service/session.ts
@@ -5,6 +5,7 @@
*/
import { Injectable, Output, EventEmitter } from '@angular/core';
+import { CanActivate, Router } from '@angular/router';
export enum UserRoles222 {
admin = 10000,
@@ -38,14 +39,19 @@ export class SessionService {
* @param userAdmin -
* @param userAvatar -
*/
- 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} sessionId = ${sessionId}`);
- this.tokenJwt = undefined;
+ create({ sessionId, userId, userLogin, userEMail, userAdmin, userAvatar, tokenJwt }: {
+ sessionId;
+ userId: string;
+ userLogin: string;
+ userEMail: string;
+ userAdmin: boolean;
+ userBlocked: boolean;
+ userRemoved: boolean;
+ userAvatar: string;
+ tokenJwt?: string;
+ }) {
+ console.log(`Session Create: userId=${userId} userLogin=${userLogin} userEMail=${userEMail} userAdmin=${userAdmin} userAvatar=${userAvatar} sessionId = ${sessionId} tokenJwt = ${tokenJwt}`);
+ this.tokenJwt = tokenJwt;
this.sessionId = sessionId;
this.userId = userId;
this.userLogin = userLogin;
@@ -110,3 +116,65 @@ export class SessionService {
*/
}
}
+
+@Injectable()
+export class OnlyUsersGuard implements CanActivate {
+ constructor(private sessionService: SessionService,
+ private router: Router) {};
+
+ canActivate() {
+ console.log("OnlyLoggedInUsers");
+ if (this.sessionService.hasRight(UserRoles222.user) || this.sessionService.hasRight(UserRoles222.admin) ) {
+ return true;
+ } else {
+ this.router.navigateByUrl('/forbidden');
+ return false;
+ }
+ }
+}
+
+@Injectable()
+export class OnlyUsersGuardHome implements CanActivate {
+ constructor(private sessionService: SessionService,
+ private router: Router) {};
+
+ canActivate() {
+ console.log("OnlyLoggedInUsers");
+ if (this.sessionService.hasRight(UserRoles222.user) || this.sessionService.hasRight(UserRoles222.admin) ) {
+ return true;
+ } else {
+ this.router.navigateByUrl('/unregistered');
+ return false;
+ }
+ }
+}
+@Injectable()
+export class OnlyUnregisteredGuardHome implements CanActivate {
+ constructor(private sessionService: SessionService,
+ private router: Router) {};
+
+ canActivate() {
+ if (!this.sessionService.islogged() ) {
+ return true;
+ } else {
+ this.router.navigateByUrl('/home');
+ return false;
+ }
+ }
+}
+
+@Injectable()
+export class OnlyAdminGuard implements CanActivate {
+ constructor(private sessionService: SessionService,
+ private router: Router) {};
+
+ canActivate() {
+ console.log("OnlyLoggedInUsers");
+ if (this.sessionService.hasRight(UserRoles222.user)) {
+ return true;
+ } else {
+ this.router.navigateByUrl('/forbidden');
+ return false;
+ }
+ }
+}
diff --git a/front/src/common/service/sso.ts b/front/src/common/service/sso.ts
index a097c2e..bcbd72a 100644
--- a/front/src/common/service/sso.ts
+++ b/front/src/common/service/sso.ts
@@ -6,26 +6,31 @@
import { Injectable } from '@angular/core';
import { environment } from 'environments/environment';
+import { isInArray, isNullOrUndefined } from 'common/utils';
+import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from 'common/service';
@Injectable()
export class SSOService {
+ signUpEnable: boolean = undefined;
- constructor() {
+ constructor(
+ private http: HttpWrapperService,
+ ) {
console.log('Start SSOService');
}
utf8_to_b64( str:string ): string {
// remove unneeded "=" padding
- return window.btoa(unescape(encodeURIComponent( str ))).replace("=", "");
+ return window.btoa(encodeURIComponent( str )).replace("=", "");
}
b64_to_utf8( str:string ): string {
- return decodeURIComponent(escape(window.atob( str )));
+ return decodeURIComponent(window.atob( str ));
}
/**
* Request SSO connection
*/
hashLocalData(data?: string): string {
- if (data != undefined) {
+ if (!isNullOrUndefined(data) && !isInArray(data, ["", "null", "NULL", "undefined", "---"])) {
return this.utf8_to_b64(data);
}
let pathName = window.location.pathname;
@@ -48,8 +53,17 @@ export class SSOService {
/**
* Request SSO connection
*/
- unHashLocalData(data: string): string {
- return this.b64_to_utf8(data);
+ unHashLocalData(data: string): string | undefined {
+ if (isNullOrUndefined(data) || isInArray(data, ["", "null", "NULL", "undefined", "---"])) {
+ return undefined;
+ }
+ try {
+ return this.b64_to_utf8(data);
+ }
+ catch (ex) {
+ console.error(`Can not convert the data: ${data}`);
+ }
+ return undefined;
}
/**
* Request SSO connection
@@ -61,9 +75,6 @@ export class SSOService {
* Request SSO Disconnect
*/
requestSignOut(name?: string): void {
- if (name === undefined) {
- name = 'home';
- }
window.location.href = environment.ssoSignOut + this.hashLocalData(name);
}
/**
@@ -72,5 +83,32 @@ export class SSOService {
requestSignUp(name?: string): void {
window.location.href = environment.ssoSignUp + this.hashLocalData(name);
}
+ /**
+ * Checo if the signUp is authorized (generate by te SSO)
+ * @returns a promise of the State for sign-up
+ */
+ checkSignUpEnable(): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ if (isNullOrUndefined(self.signUpEnable)) {
+ this.http.requestJson({
+ server: 'karauth',
+ endPoint: 'system_config/is_sign_up_availlable',
+ requestType: HTTPRequestModel.GET,
+ accept: HTTPMimeType.JSON,
+ contentType: HTTPMimeType.JSON,
+ }).then((response: ModelResponseHttp) =>{
+ self.signUpEnable = response.data.signup;
+ resolve(self.signUpEnable);
+ }).catch((error:any) => {
+ reject(`return ERROR ${ JSON.stringify(error, null, 2)}`);
+ });
+ return;
+ }
+ resolve(self.signUpEnable);
+ });
+
+ }
+
}
diff --git a/front/src/common/service/user.ts b/front/src/common/service/user.ts
index 7a19551..8ba92a0 100644
--- a/front/src/common/service/user.ts
+++ b/front/src/common/service/user.ts
@@ -11,6 +11,7 @@ import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp }
import { StorageService } from 'common/service/local-storage';
import { SessionService } from './session';
import { SSOService } from './sso';
+import { isNullOrUndefined } from 'common/utils';
interface MessageLogIn {
login: string;
@@ -55,6 +56,7 @@ export class UserService {
removeSession(): void {
this.storageService.remove(this.cookiesRememberMe);
this.storageService.removeSession(this.cookiesToken);
+ this.storageService.remove(this.cookiesToken);
this.sessionService.destroy();
}
@@ -67,11 +69,11 @@ export class UserService {
if (elems.length !== 3 ) {
return false;
}
- const tokenHeader = decodeURIComponent(escape(window.atob( elems[0] )));
- const tokenData = decodeURIComponent(escape(window.atob( elems[1] )));
- console.error(`Retreive local token: \nheader=${tokenHeader} \ndata=${tokenData}`);
+ //const tokenHeader = decodeURIComponent(window.atob( elems[0] ));
+ const tokenData = decodeURIComponent(window.atob( elems[1] ));
+ //console.error(`Retreive local token: \nheader=${tokenHeader} \ndata=${tokenData}`);
const parsedData = JSON.parse(tokenData);
- console.error(`Retreive exp data=${new Date(parsedData.exp*1000).toISOString()} < ${new Date().toISOString()}`);
+ console.debug(`Retreive token 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...
@@ -96,11 +98,17 @@ export class UserService {
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);
+ let token = null;
+ if (isNullOrUndefined(environment.tokenStoredInPermanentStorage) || environment.tokenStoredInPermanentStorage !== true) {
+ token = self.storageService.getSession(self.cookiesToken);
+ } else {
+ token = self.storageService.get(self.cookiesToken);
+ }
// TODO: check validity of th eToken:
if (self.isTokenUpToDate(token)) {
// remove in case of fail !!!
this.storageService.removeSession(this.cookiesToken);
+ this.storageService.remove(this.cookiesToken);
self.startSession(token, rememberMe).then(() => {
resolve();
}).catch(() => {
@@ -108,6 +116,7 @@ export class UserService {
if(rememberMe) {
// jump to the sso !!! (remove local data to prevent login loop)
this.storageService.remove(this.cookiesRememberMe);
+ this.storageService.remove(this.cookiesToken);
this.storageService.removeSession(this.cookiesToken);
self.ssoService.requestSignIn();
reject();
@@ -119,6 +128,7 @@ export class UserService {
if(rememberMe) {
// jump to the sso !!! (remove local data to prevent login loop)
this.storageService.remove(this.cookiesRememberMe);
+ this.storageService.remove(this.cookiesToken);
this.storageService.removeSession(this.cookiesToken);
self.ssoService.requestSignIn();
reject();
@@ -138,7 +148,11 @@ export class UserService {
}
// transfer the session token property
self.sessionService.setToken(token);
- self.storageService.setSession(self.cookiesToken, token);
+ if (isNullOrUndefined(environment.tokenStoredInPermanentStorage) || environment.tokenStoredInPermanentStorage !== true) {
+ self.storageService.setSession(self.cookiesToken, token);
+ } else {
+ self.storageService.set(self.cookiesToken, token);
+ }
resolve(self.sessionService.getLogin());
}).catch(() => {
reject('sdfsdfsdf');
@@ -160,12 +174,16 @@ export class UserService {
// TODO: check type ...
console.log(`loginWithToken : get some data to check: ${JSON.stringify(response.data)}`)
self.sessionService.create(
- response.data.sessionId,
- response.data.id,
- response.data.login,
- response.data.email,
- response.data.role,
- response.data.avatar);
+ {
+ sessionId: response.data.sessionId,
+ userId: response.data.id,
+ userLogin: response.data.login,
+ userEMail: response.data.email,
+ userAdmin: response.data.admin,
+ userBlocked: response.data.blocked,
+ userRemoved: response.data.removed,
+ userAvatar: response.data.avatar
+ });
resolve(true);
}).catch((error:any) => {
reject(`return ERROR ${ JSON.stringify(error, null, 2)}`);
diff --git a/front/src/common/utils/dataInterface.ts b/front/src/common/utils/dataInterface.ts
index f97c4c9..636d402 100644
--- a/front/src/common/utils/dataInterface.ts
+++ b/front/src/common/utils/dataInterface.ts
@@ -8,6 +8,7 @@ import { NodeData } from "../model";
import { isArray, isNullOrUndefined } from "./validator";
export enum TypeCheck {
+ CONTAINS = 'C',
EQUAL = '==',
NOT_EQUAL = '!=',
LESS = '<',
@@ -29,6 +30,27 @@ export interface SelectModel {
* @breif Generic interface to access to the BDD (no BDD, direct file IO)
*/
export class DataInterface {
+ static extractLimitOne(data: NodeData[], key: string): any[] {
+ const out = [];
+ for (let iii=0; iii(data: any, typeChecker: (subData: any) => subData is TYPE, length?: number): data is TYPE[] {
if (!isArray(data)) {
diff --git a/front/src/environments/environment.prod.ts b/front/src/environments/environment.prod.ts
index c84a689..44c6b47 100644
--- a/front/src/environments/environment.prod.ts
+++ b/front/src/environments/environment.prod.ts
@@ -16,6 +16,7 @@ export const environment = {
ssoSignUp: `${location.origin}/karso/signup/karideo/`,
ssoSignOut: `${location.origin}/karso/signout/karideo/`,
frontBaseUrl: '',
+ tokenStoredInPermanentStorage: false,
apiMode: 'REWRITE'
};
diff --git a/front/src/environments/environment.ts b/front/src/environments/environment.ts
index 5cd2b92..ed34bb0 100644
--- a/front/src/environments/environment.ts
+++ b/front/src/environments/environment.ts
@@ -16,6 +16,7 @@ const environment_back_prod = {
ssoSignUp: 'http://192.168.1.156/karso/signup/karideo-dev/',
ssoSignOut: 'http://192.168.1.156/karso/signout/karideo-dev/',
frontBaseUrl: '',
+ tokenStoredInPermanentStorage: false,
//apiMode: 'REWRITE'
};
@@ -32,6 +33,7 @@ const environment_local = {
ssoSignUp: 'http://192.168.1.156/karso/signup/karideo-dev/',
ssoSignOut: 'http://192.168.1.156/karso/signout/karideo-dev/',
frontBaseUrl: '',
+ tokenStoredInPermanentStorage: false,
//apiMode: 'REWRITE'
};
@@ -48,9 +50,10 @@ const environment_hybrid = {
ssoSignUp: 'http://192.168.1.156/karso/signup/karideo-dev/',
ssoSignOut: 'http://192.168.1.156/karso/signout/karideo-dev/',
frontBaseUrl: '',
+ tokenStoredInPermanentStorage: false,
apiMode: 'REWRITE'
};
-export const environment = environment_back_prod;
+export const environment = environment_local;
diff --git a/front/src/generic_page.less b/front/src/generic_page.less
index f847a4c..390daa9 100644
--- a/front/src/generic_page.less
+++ b/front/src/generic_page.less
@@ -7,6 +7,12 @@
float: left;
width: 100%;
}
+ .clear-end {
+ display: block;
+ float: left;
+ width: 100%;
+ height: 250px;
+ }
.generic-page {
.fill-title {
display:block;
@@ -282,6 +288,11 @@
text-align: center;
}
+ .clear-end {
+ clear: both;
+ text-align: center;
+ height: 250px;
+ }
.generic-page {
.fill-title {
display:block;
@@ -694,4 +705,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/front/src/typings.d.ts b/front/src/typings.d.ts
deleted file mode 100644
index d3a1a83..0000000
--- a/front/src/typings.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/* SystemJS module definition */
-interface NodeModule {
- id: string;
-}
-
-
-declare let module: NodeModule;
|