arrow_back_ios
diff --git a/front/src/app/scene/video/video.ts b/front/src/app/scene/video/video.ts
index 7e0f432..177eb94 100644
--- a/front/src/app/scene/video/video.ts
+++ b/front/src/app/scene/video/video.ts
@@ -11,6 +11,7 @@ import { VideoService } from '../../service/video';
import { SeriesService } from '../../service/series';
import { SeasonService } from '../../service/season';
import { ArianeService } from '../../service/ariane';
+import { isNullOrUndefined } from '../..//utils';
@Component({
selector: 'app-video',
@@ -249,7 +250,7 @@ export class VideoScene implements OnInit {
self.haveNext = null;
self.havePrevious = null;
for(let iii = 0; iii < response6.length; iii++) {
- if(response6[iii].episode === undefined || response6[iii].episode === null) {
+ if(isNullOrUndefined(response6[iii].episode)) {
continue;
}
if(response6[iii].episode < self.episode) {
diff --git a/front/src/app/service/auth.ts b/front/src/app/service/auth.ts
deleted file mode 100644
index 94afcbe..0000000
--- a/front/src/app/service/auth.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-/** @file
- * @author Edouard DUPIN
- * @copyright 2018, Edouard DUPIN, all right reserved
- * @license PROPRIETARY (see license file)
- */
-
-import { Injectable } from '@angular/core';
-
-@Injectable()
-export class AuthService {
- constructor() {
-
- }
-}
-
diff --git a/front/src/app/service/bdd.ts b/front/src/app/service/bdd.ts
index 296850f..1f37e07 100644
--- a/front/src/app/service/bdd.ts
+++ b/front/src/app/service/bdd.ts
@@ -6,7 +6,7 @@
import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper';
-import { DataInterface, MediaSmall } from './dataInterface';
+import { DataInterface } from '../utils/dataInterface';
@Injectable()
diff --git a/front/src/app/service/cookies.ts b/front/src/app/service/cookies.ts
index 89b3a17..74feed9 100644
--- a/front/src/app/service/cookies.ts
+++ b/front/src/app/service/cookies.ts
@@ -4,15 +4,16 @@
* @license PROPRIETARY (see license file)
*/
-import { Injectable } from '@angular/core';
+ import { Injectable } from '@angular/core';
-@Injectable()
-export class CookiesService {
- constructor() {
-
- }
-
- set(cname, cvalue, exdays) {
+ @Injectable()
+ export class CookiesService {
+
+ constructor() {
+
+ }
+
+ set(cname: string, cvalue: string, exdays: number): void {
if(this.get(cname) !== '') {
// reset previous cookies...
document.cookie = `${cname }=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`;
@@ -22,12 +23,12 @@ export class CookiesService {
let expires = `expires=${ddd.toUTCString()}`;
document.cookie = `${cname }=${ cvalue };${ expires };path=/`;
}
-
- remove(cname) {
+
+ remove(cname: string) : void {
this.set(cname, '', 0);
- }
-
- get(cname) {
+ }
+
+ get(cname: string) : string | undefined {
let name = `${cname }=`;
let coolies = document.cookie.split(';');
for(let iii = 0; iii < coolies.length; iii++) {
@@ -41,5 +42,6 @@ export class CookiesService {
}
return '';
}
-}
-
+ }
+
+
diff --git a/front/src/app/service/http-wrapper.ts b/front/src/app/service/http-wrapper.ts
index 6d14c55..a7486c2 100644
--- a/front/src/app/service/http-wrapper.ts
+++ b/front/src/app/service/http-wrapper.ts
@@ -10,6 +10,7 @@ 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",
@@ -33,22 +34,13 @@ export interface HTTPRequest {
requestType: HTTPRequestModel ;
accept: HTTPMimeType;
contentType: HTTPMimeType;
- params?: any;
+ params?: object;
body?: any;
authorization?: string; // c'est un hook de merde ...
disableTocken?:boolean;
}
-/*
-{
- endPoint: ,
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.ALL,
- contentType: HTTPMimeType.JSON,
- params?: ,
- body?: ,
-}
-*/
-export interface ModelResponseHttp{
+
+export interface ModelResponseHttp {
status: number,
data: any,
}
@@ -67,7 +59,7 @@ export class HttpWrapperService {
addTokenIfNeeded(headerOption:any): any {
if(this.session.sessionData !== null) {
if(headerOption.Authorization === undefined) {
- headerOption.Authorization = `Yota ${ this.session.sessionData.userId }:${ this.session.sessionData.token}`;
+ headerOption.Authorization = `Yota ${this.session.getToken()}`;
}
}
return headerOption;
@@ -79,7 +71,8 @@ export class HttpWrapperService {
let connectionAdresse = this.createRESTCall2({
server: properties.server,
- api: properties.endPoint
+ api: properties.endPoint,
+ inputOptions: properties.params,
});
let headers: any = {
'Accept': properties.accept,
@@ -163,28 +156,33 @@ export class HttpWrapperService {
}
- createRESTCall2({ api, server, inputOptions, addURLToken }: { server?: string; api: string; inputOptions?: any[]; addURLToken?:boolean }) {
- let basePage = environment.apiUrl;
- if (server === "karauth") {
- basePage = environment.apiOAuthUrl;
+ 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(options === undefined) {
- options = [];
+ if(isNullOrUndefined(options)) {
+ options = {};
}
let out = addressServerRest + api;
let first = true;
- for(let iii = 0; iii < options.length; iii++) {
+ 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 + options[iii];
+ out = out + keys[iii];
+ if (options[keys[iii]] != null) {
+ out = out + "=" + options[keys[iii]];
+ }
}
- if(this.session.sessionData !== null) {
+ if (!isNullOrUndefined(this.session.sessionData)) {
if (addURLToken !== undefined && addURLToken === true) {
if(first === false) {
out = `${out }&`;
@@ -199,7 +197,7 @@ export class HttpWrapperService {
// Deprecated ...
createRESTCall(api: string, inputOptions?: any) {
- let basePage = environment.apiUrl;
+ let basePage = environment.server[environment.defaultServer];
let addressServerRest = `${basePage }/`;
let options = inputOptions;
if(options === undefined) {
diff --git a/front/src/app/service/index.ts b/front/src/app/service/index.ts
new file mode 100644
index 0000000..034201f
--- /dev/null
+++ b/front/src/app/service/index.ts
@@ -0,0 +1,41 @@
+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";
+
+
+
+export {
+ CookiesService,
+ HttpWrapperService,
+ ModelResponseHttp,
+ HTTPRequest,
+ HTTPMimeType,
+ HTTPRequestModel,
+ StorageService,
+ PopInService,
+ SessionService,
+ UserService,
+ SSOService,
+ ArianeService,
+ BddService,
+ DataService,
+ SeasonService,
+ SeriesService,
+ TypeService,
+ UniverseService,
+ VideoService,
+};
+
+
diff --git a/front/src/app/service/local-storage.ts b/front/src/app/service/local-storage.ts
new file mode 100644
index 0000000..30d034e
--- /dev/null
+++ b/front/src/app/service/local-storage.ts
@@ -0,0 +1,54 @@
+/** @file
+ * @author Edouard DUPIN
+ * @copyright 2018, Edouard DUPIN, all right reserved
+ * @license PROPRIETARY (see license file)
+ */
+
+ import { Injectable } from '@angular/core';
+import { environment } from '../../environments/environment';
+
+ @Injectable()
+ export class StorageService {
+ private baseLocalStorageName = environment.applName + '_';
+
+ constructor() {
+
+ }
+
+ set(cname: string, cvalue: string): void {
+ console.error(`storage set: ${cname} : ${cvalue}`);
+ localStorage.setItem(this.baseLocalStorageName + cname, cvalue);
+ }
+ // limit at the current session ...
+ setSession(cname: string, cvalue: string): void {
+ sessionStorage.setItem(this.baseLocalStorageName + cname, cvalue);
+ }
+
+ remove(cname: string) : void {
+ console.error(`storage remove: ${cname}`);
+ localStorage.removeItem(this.baseLocalStorageName + cname);
+ }
+ removeSession(cname: string) : void {
+ sessionStorage.removeItem(this.baseLocalStorageName + cname);
+ }
+
+ get(cname: string) : string | undefined {
+ console.error(`storage get: ${cname}`);
+ // TODO check expire day...
+ const data = localStorage.getItem(this.baseLocalStorageName + cname);
+ console.log(`get value form the storage (1): ${data}`)
+ if (data === null || data === undefined) {
+ return undefined;
+ }
+ return data;
+ }
+ getSession(cname: string) : string | undefined {
+ const data = sessionStorage.getItem(this.baseLocalStorageName + cname);
+ if (data === null || data === undefined) {
+ return undefined;
+ }
+ return data;
+ }
+ }
+
+
\ No newline at end of file
diff --git a/front/src/app/service/season.ts b/front/src/app/service/season.ts
index 684277e..82c2165 100644
--- a/front/src/app/service/season.ts
+++ b/front/src/app/service/season.ts
@@ -7,13 +7,12 @@
import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper';
-import { DataInterface } from './dataInterface';
+import { DataInterface } from '../utils';
import { BddService } from './bdd';
+import { TypeCheck } from '../utils/dataInterface';
@Injectable()
export class SeasonService {
- // 0: Not hide password; 1 hide password;
- private identificationVersion: number = 1;
private serviceName:string = 'season';
constructor(private http: HttpWrapperService,
@@ -50,7 +49,14 @@ export class SeasonService {
self.bdd.getVideo()
.then((response: DataInterface) => {
// let data = response.getsWhere([["==", "seasonId", id]], ["id", "name", "episode"], ["episode", "name"])
- let data = response.getsWhere([ [ '==', 'seasonId', id ] ], undefined, [ 'episode', 'name' ]);
+ let data = response.getsWhere([
+ {
+ check: TypeCheck.EQUAL,
+ key: 'seasonId',
+ value: id,
+ },
+ ],
+ [ 'episode', 'name' ]);
resolve(data);
}).catch((response) => {
reject(response);
@@ -69,7 +75,12 @@ export class SeasonService {
self.bdd.getVideo()
.then((response: DataInterface) => {
// let data = response.getsWhere([["==", "seasonId", _id]], ["id", "name", "episode"], ["episode", "name"])
- let data = response.getsWhere([ [ '==', 'seasonId', id ] ], undefined, [ 'episode', 'name' ]);
+ let data = response.getsWhere([
+ {
+ check: TypeCheck.EQUAL,
+ key: 'seasonId',
+ value: id,
+ } ] );
resolve(data.length);
}).catch((response) => {
reject(response);
diff --git a/front/src/app/service/series.ts b/front/src/app/service/series.ts
index 6dc0bc5..7669c03 100644
--- a/front/src/app/service/series.ts
+++ b/front/src/app/service/series.ts
@@ -7,14 +7,14 @@
import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper';
-import { DataInterface } from './dataInterface';
+import { DataInterface, TypeCheck } from '../utils/dataInterface';
import { BddService } from './bdd';
+import { isNodeData, NodeData } from '../model';
+import { isArrayOf, isNullOrUndefined } from '../utils';
@Injectable()
export class SeriesService {
- // 0: Not hide password; 1 hide password;
- private identificationVersion: number = 1;
private serviceName:string = 'series';
constructor(private http: HttpWrapperService,
@@ -22,13 +22,13 @@ export class SeriesService {
console.log('Start SeriesService');
}
- get(id:number):any {
+ get(id:number): Promise
{
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getSeries()
.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;
}
@@ -40,7 +40,7 @@ export class SeriesService {
});
}
- getData():any {
+ getData(): Promise {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getSeries()
@@ -54,13 +54,23 @@ export class SeriesService {
});
}
- getOrder():any {
+ getOrder(): Promise {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getSeries()
- .then((response:DataInterface) => {
- let data = response.getsWhere([ [ '!=', 'id', null ] ], [ 'id', 'name' ], [ 'name', 'id' ]);
- resolve(data);
+ .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);
@@ -68,28 +78,41 @@ export class SeriesService {
});
}
- getVideoAll(id:number):any {
- // this.checkLocalBdd();
- }
-
- getVideo(id:number):any {
+ getVideo(id:number):Promise {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
.then((response:DataInterface) => {
- let data = response.getsWhere([ [ '==', 'seriesId', id ], [ '==', 'seasonId', null ] ], undefined, [ 'episode', 'name' ]);
+ 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):any {
+ countVideo(id:number): Promise {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
.then((response:DataInterface) => {
- let data = response.getsWhere([ [ '==', 'seriesId', id ] ], undefined, undefined);
+ let data = response.getsWhere([
+ {
+ check: TypeCheck.EQUAL,
+ key: 'seriesId',
+ value: id,
+ },
+ ]);
resolve(data.length);
}).catch((response) => {
reject(response);
@@ -100,26 +123,21 @@ export class SeriesService {
/**
* Get all the season of a specific series
* @param id - ID of the series
- * @param select - Selection filter
* @returns the required List.
*/
- getSeason(id:number, select:string[] = []):any {
+ getSeason(id:number): Promise {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getSeason()
.then((response:DataInterface) => {
- let data = response.getsWhere([ [ '==', 'parentId', id ] ], [ 'id' ], [ 'number' ]);
- if(select.length === 0) {
- resolve(data);
- return;
- }
- if(select[0] === '*') {
- let data2 = response.getsWhere([ [ '==', 'id', data ] ], undefined, [ 'number' ]);
- resolve(data2);
- return;
- }
- let data3 = response.getsWhere([ [ '==', 'id', data ] ], select, [ 'number' ]);
- resolve(data3);
+ let data = response.getsWhere([
+ {
+ check: TypeCheck.EQUAL,
+ key: 'parentId',
+ value: id,
+ },
+ ], [ 'id' ]);
+ resolve(data);
return;
}).catch((response) => {
reject(response);
diff --git a/front/src/app/service/session.ts b/front/src/app/service/session.ts
index 7fa476a..64336da 100644
--- a/front/src/app/service/session.ts
+++ b/front/src/app/service/session.ts
@@ -14,12 +14,13 @@ export enum UserRoles222 {
@Injectable()
export class SessionService {
+ private tokenJwt = null;
public sessionData = null;
public userLogin = null;
public userAdmin = null;
public userEMail = null;
public userAvatar = null;
- // public tocken = null;
+ public userId = null;
@Output() change: EventEmitter = new EventEmitter();
@@ -31,18 +32,22 @@ export class SessionService {
* @brief Create a new session.
*
* @param sessionData -
+ * @param userId -
* @param userLogin -
* @param userEMail -
* @param userAdmin -
* @param userAvatar -
*/
create(sessionData,
+ userId: string,
userLogin: string,
userEMail: string,
userAdmin: boolean,
userAvatar: string) {
- console.log('Session Create');
+ console.log(`Session Create: userId=${userId} userLogin=${userLogin} userEMail=${userEMail} userAdmin=${userAdmin} userAvatar=${userAvatar} `);
+ this.tokenJwt = undefined;
this.sessionData = sessionData;
+ this.userId = userId;
this.userLogin = userLogin;
this.userAdmin = userAdmin;
this.userEMail = userEMail;
@@ -55,16 +60,22 @@ export class SessionService {
*/
destroy() {
console.log('Session REMOVE');
- // Cookies.remove("yota-login");
- // Cookies.remove("yota-password");
let last = this.sessionData;
this.sessionData = null;
+ this.tokenJwt = undefined;
+ this.userId = null;
this.userLogin = null;
this.userAdmin = null;
this.userEMail = null;
this.userAvatar = null;
this.change.emit(false);
}
+ setToken(jwt: string) {
+ this.tokenJwt = jwt;
+ }
+ getToken(): string | undefined {
+ return this.tokenJwt;
+ }
islogged() {
return this.sessionData !== null;
}
@@ -90,9 +101,9 @@ export class SessionService {
return this.userLogin;
}
getAvatar() {
- if(this.userAvatar === '') {
+ if(this.userAvatar === false) {
return 'assets/images/avatar_generic.svg';
}
- return this.userAvatar;
+ return this.userId;
}
}
diff --git a/front/src/app/service/sso.ts b/front/src/app/service/sso.ts
new file mode 100644
index 0000000..ad83da5
--- /dev/null
+++ b/front/src/app/service/sso.ts
@@ -0,0 +1,60 @@
+/** @file
+ * @author Edouard DUPIN
+ * @copyright 2018, Edouard DUPIN, all right reserved
+ * @license PROPRIETARY (see license file)
+ */
+
+import { Injectable } from '@angular/core';
+import { environment } from '../../environments/environment';
+
+@Injectable()
+export class SSOService {
+
+ constructor() {
+ console.log('Start SSOService');
+ }
+ utf8_to_b64( str:string ): string {
+ return window.btoa(unescape(encodeURIComponent( str ))).replace("=", "");
+ }
+
+ b64_to_utf8( str:string ): string {
+ return decodeURIComponent(escape(window.atob( str )));
+ }
+ /**
+ * Request SSO connection
+ */
+ hashLocalData(data?: string): string {
+ if (data != undefined) {
+ return this.utf8_to_b64(data);
+ }
+ return this.utf8_to_b64('home');
+ }
+ /**
+ * Request SSO connection
+ */
+ unHashLocalData(data: string): string {
+ return this.b64_to_utf8(data);
+ }
+ /**
+ * Request SSO connection
+ */
+ requestSignIn(name?: string): void {
+ window.location.href = environment.ssoSignIn + this.hashLocalData(name);
+ }
+ /**
+ * Request SSO Disconnect
+ */
+ requestSignOut(name?: string): void {
+ if (name === undefined) {
+ name = 'home';
+ }
+ window.location.href = environment.ssoSignOut + this.hashLocalData(name);
+ }
+ /**
+ * Request SSO signUp
+ */
+ requestSignUp(name?: string): void {
+ window.location.href = environment.ssoSignUp + this.hashLocalData(name);
+ }
+}
+
diff --git a/front/src/app/service/type.ts b/front/src/app/service/type.ts
index 560efaf..0087176 100644
--- a/front/src/app/service/type.ts
+++ b/front/src/app/service/type.ts
@@ -8,8 +8,9 @@ import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper';
import { BddService } from './bdd';
-import { DataInterface } from './dataInterface';
-
+import { DataInterface, isNullOrUndefined } from '../utils';
+import { NodeData } from '../model';
+import { TypeCheck } from '../utils/dataInterface';
export interface MessageLogIn {
id: number;
@@ -17,14 +18,8 @@ export interface MessageLogIn {
description: string;
}
-declare function SHA512(param1: any): any;
-declare function dateFormat(param1: any, param2: any): any;
-
@Injectable()
export class TypeService {
- // 0: Not hide password; 1 hide password;
- private identificationVersion: number = 1;
- private serviceName:string = 'type';
constructor(private http: HttpWrapperService,
private bdd: BddService) {
@@ -32,7 +27,7 @@ export class TypeService {
}
- getData():any {
+ getData(): Promise {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getType()
@@ -46,13 +41,13 @@ export class TypeService {
});
}
- get(_id:number):any {
+ get(_id:number): Promise {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getType()
.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;
}
@@ -63,12 +58,17 @@ export class TypeService {
});
}
- countVideo(_id:number):any {
+ countVideo(id:number): Promise {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
.then((response: DataInterface) => {
- let data = response.getsWhere([ [ '==', 'typeId', _id ] ], undefined, undefined);
+ let data = response.getsWhere([
+ {
+ check: TypeCheck.EQUAL,
+ key: 'typeId',
+ value: id,
+ } ] );
resolve(data.length);
}).catch((response) => {
reject(response);
@@ -76,64 +76,45 @@ export class TypeService {
});
}
- getSubVideo(_id:number, _select:Array = []):any {
+ getSubVideo(id:number): Promise {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
.then((response: DataInterface) => {
- if(_select.length === 0) {
- let data = response.getsWhere([ [ '==', 'typeId', _id ], [ '==', 'seriesId', null ], [ '==', 'universeId', null ] ], undefined, [ 'name' ]);
- resolve(data);
- return;
- }
- if(_select[0] === '*') {
- let data = response.getsWhere([ [ '==', 'typeId', _id ], [ '==', 'seriesId', null ], [ '==', 'universeId', null ] ], undefined, [ 'name' ]);
- resolve(data);
- return;
- }
- let data = response.getsWhere([ [ '==', 'typeId', _id ], [ '==', 'seriesId', null ], [ '==', 'universeId', null ] ], _select, [ 'name' ]);
+ let data = response.getsWhere([
+ {
+ check: TypeCheck.EQUAL,
+ key: 'typeId',
+ value: id,
+ }, {
+ check: TypeCheck.EQUAL,
+ key: 'seriesId',
+ value: undefined,
+ }, {
+ check: TypeCheck.EQUAL,
+ key: 'universeId',
+ value: undefined,
+ },
+ ], [ 'name' ] );
resolve(data);
- return;
}).catch((response) => {
reject(response);
});
});
}
- getSubSeries(id:number, select:string[] = []):any {
+ getSubSeries(id:number): Promise {
let self = this;
-
- /*
- return new Promise((resolve, reject) => {
- self.bdd.getVideo()
- .then(function(response: DataInterface) {
- let data = response.getsWhere([["==", "typeId", _id], ["!=", "seriesId", null], ["==", "universeId", null]], ["seriesId"], ["name"]);
- if (_select.length == 0) {
- resolve(data);
- return;
- }
- self.bdd.getSeries()
- .then(function(response2: DataInterface) {
- if (_select[0] == "*") {
- let data2 = response2.getsWhere([["==", "id", data]], undefined, ["name"]);
- resolve(data2);
- return;
- }
- let data3 = response2.getsWhere([["==", "id", data]], _select, ["name"]);
- resolve(data3);
- return;
- }).catch(function(response2) {
- reject(response2);
- });
- }).catch(function(response) {
- reject(response);
- });
- });
- */
return new Promise((resolve, reject) => {
self.bdd.getSeries()
.then((response: DataInterface) => {
- let data = response.getsWhere([ [ '==', 'parentId', id ] ], undefined, [ 'name' ]);
+ let data = response.getsWhere([
+ {
+ check: TypeCheck.EQUAL,
+ key: 'parentId',
+ value: id,
+ } ],
+ [ 'name' ]);
resolve(data);
}).catch((response) => {
reject(response);
@@ -141,42 +122,42 @@ export class TypeService {
});
}
- getSubUniverse(id:number, select:string[] = []):any {
+ getSubUniverse(id:number): Promise {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
.then((response: DataInterface) => {
- let data = response.getsWhere([ [ '==', 'typeId', id ], [ '==', 'seriesId', null ], [ '==', 'universeId', null ] ], [ 'universId' ], [ 'name' ]);
- if(select.length === 0) {
- resolve(data);
- return;
- }
- self.bdd.getUniverse()
- .then((response2: DataInterface) => {
- if(select[0] === '*') {
- let data2 = response2.getsWhere([ [ '==', 'id', data ] ], undefined, [ 'name' ]);
- resolve(data2);
- return;
- }
- let data3 = response2.getsWhere([ [ '==', 'id', data ] ], select, [ 'name' ]);
- resolve(data3);
- return;
- }).catch((response2) => {
- reject(response2);
- });
+ let data = response.getsWhere([
+ {
+ check: TypeCheck.EQUAL,
+ key: 'typeId',
+ value: id,
+ }, {
+ check: TypeCheck.EQUAL,
+ key: 'seriesId',
+ value: [undefined, null],
+ }, {
+ check: TypeCheck.NOT_EQUAL,
+ key: 'universeId',
+ value: undefined,
+ },
+ ]);
+ //, [ 'universId' ]);
+ resolve(data);
+ return;
}).catch((response: any) => {
reject(response);
});
});
}
- getCoverUrl(coverId:number):any {
+ getCoverUrl(coverId:number): string {
return this.http.createRESTCall2({
api: `data/${coverId}`,
addURLToken: true,
});
}
- getCoverThumbnailUrl(coverId:number):any {
+ getCoverThumbnailUrl(coverId:number): string {
return this.http.createRESTCall2({
api: `data/thumbnail/${coverId}`,
addURLToken: true,
diff --git a/front/src/app/service/user.ts b/front/src/app/service/user.ts
index b58fcfc..a40b59c 100644
--- a/front/src/app/service/user.ts
+++ b/front/src/app/service/user.ts
@@ -5,8 +5,12 @@
*/
import { Injectable } from '@angular/core';
+import { environment } from '../../environments/environment';
import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from './http-wrapper';
+import { StorageService } from './local-storage';
+import { SessionService } from './session';
+import { SSOService } from './sso';
interface MessageLogIn {
login: string;
@@ -24,87 +28,105 @@ interface MessageAnswer_USER_CONNECT {
}
declare function SHA512(param1: any): any;
-declare function dateFormat(param1: any, param2: any): any;
@Injectable()
export class UserService {
// 0: Not hide password; 1 hide password;
private identificationVersion: number = 1;
+ private cookiesRememberMe = 'karauth-remember-me';
+ private cookiesToken = 'karauth-token';
- constructor(private http: HttpWrapperService) {
+ constructor(
+ private storageService: StorageService,
+ private http: HttpWrapperService,
+ private sessionService: SessionService,
+ private ssoService: SSOService) {
console.log('Start UserService');
}
- login(_login: string, _password: string):any {
- return this.loginSha(_login, SHA512(_password));
+ /**
+ * Disconnect the user from the current session ==> this remove the curreent Token
+ */
+ logOut(): void {
+ this.removeSession();
+ this.ssoService.requestSignOut("home");
+
}
- loginSha(login: string, password: string):any {
+ removeSession(): void {
+ this.storageService.remove(this.cookiesRememberMe);
+ this.storageService.removeSession(this.cookiesToken);
+ this.sessionService.destroy();
+ }
+
+ private isTokenUpToDate(token: string): boolean {
+ if (token === null || token === undefined || token.length < 25) {
+ return false;
+ }
+ // Separate the Data:
+ const elems = token.split('.');
+ 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 parsedData = JSON.parse(tokenData);
+ 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();
+ return expireIn > nowTime;
+ }
+ /**
+ * Check if the system can be connected
+ */
+ checkAutoConnect(): Promise {
+ let self = this;
+ return new Promise((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/")) {
+ reject();
+ return;
+ }
+ 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(() => {
+ resolve();
+ })
+ } else {
+ console.log(`Get previous connection ... `);
+ if(rememberMe) {
+ // just to the sso !!!
+ self.ssoService.requestSignIn();
+ reject();
+ }
+ }
+ });
+ }
+
+ startSession(token : string, rememberMe: boolean): Promise {
let self = this;
return new Promise((resolve, reject) => {
- self.getTocken(login, password).then(
- (value: any) => {
- console.log('Get token ...');
- self.loginWithToken(value.userId, value.token).then(
- (value2: any) => {
- // transfer the session token property
- value2.session = {
- userId: value.userId,
- token: value.token,
- endValidityTime: value.endValidityTime
- };
- resolve(value2);
- }, (value2) => {
- reject('sdfsdfsdf');
- });
- }, (value) => {
- console.log('User NOT created');
- reject('rrfrrrrr');
+ self.retreiveMe(token).then(
+ (value2: boolean) => {
+ if(rememberMe === true) {
+ self.storageService.set(self.cookiesRememberMe, rememberMe?"true":"false");
+ }
+ // transfer the session token property
+ self.sessionService.setToken(token);
+ self.storageService.setSession(self.cookiesToken, token);
+ resolve(self.sessionService.getLogin());
+ }).catch(() => {
+ reject('sdfsdfsdf');
});
});
}
-
- getTocken(login : string, password : string) : Promise {
- console.log(`AuthService.getToken ... '${ login }':'${ password }'`);
- let currentDate:number = dateFormat(new Date(), 'm-d-Y h:i:s ms');
- let data:MessageLogIn;
- // create request:
- if(this.identificationVersion === 1) {
- data = {
- login: login,
- method: 'v1',
- time: currentDate,
- // we mix the password to be sure that it can not be used an other time ...
- password: SHA512(`login='${ login }';pass='${ password }';date='${ currentDate }'`)
- };
- } else {
- console.log('AuthService.login ... Wrong method ...');
- }
-
- console.log(`call users/connect data=${ JSON.stringify(data, null, 2)}`);
-
- return new Promise((resolve, reject) => {
- this.http.requestJson({
- server: 'karauth',
- endPoint: 'users/get_token',
- requestType: HTTPRequestModel.POST,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- body: data,
- disableTocken: true,
- }).then((response: ModelResponseHttp) =>{
- console.log(`Data token: id=${ response.data.id}`);
- console.log(`Data token: userId=${ response.data.userId}`);
- console.log(`Data token: token=${ response.data.token}`);
- console.log(`Data token: createTime=${ response.data.createTime}`);
- console.log(`Data token: endValidityTime=${ response.data.endValidityTime}`);
- resolve(response.data);
- }).catch((error:any) => {
- reject(`return ERROR ${ JSON.stringify(error, null, 2)}`);
- });
- });
- }
- loginWithToken(userId : string, token : string) {
- console.log(`AuthService.loginWithToken ... '${ userId }':'${ token }'`);
+ retreiveMe(token : string): Promise {
+ console.log(`AuthService.loginWithToken ... '${ token }'`);
+ let self = this;
return new Promise((resolve, reject) => {
this.http.requestJson({
//server: 'karauth',
@@ -112,53 +134,22 @@ export class UserService {
requestType: HTTPRequestModel.GET,
accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON,
- authorization: `Yota ${userId}:${token}`, // special case, the token is set after this request...
+ authorization: `Yota ${token}`, // special case, the token is set after this request...
}).then((response: ModelResponseHttp) =>{
// TODO: check type ...
console.log(`loginWithToken : get some data to check: ${JSON.stringify(response.data)}`)
- resolve(response.data);
+ self.sessionService.create(
+ response.data.sessionId,
+ response.data.id,
+ response.data.login,
+ response.data.email,
+ response.data.role,
+ response.data.avatar);
+ resolve(true);
}).catch((error:any) => {
reject(`return ERROR ${ JSON.stringify(error, null, 2)}`);
});
});
-
- /*
- console.log("AuthService.login ... '" + _login + "':'" + _password + "'");
- let currentDate:number = dateFormat(new Date(), 'm-d-Y h:i:s ms');
- let data:MessageLogIn;
- // create request:
- if (this.identificationVersion == 1) {
- data = {
- login: _login,
- method: "v1",
- time: currentDate,
- // we mix the password to be sure that it can not be used an other time ...
- password: SHA512("login='" + _login + "';pass='" + _password + "';date='" + currentDate + "'")
- };
- } else {
- console.log("AuthService.login ... Wrong method ...");
- }
-
- const httpOption = { 'Content-Type': 'application/json' };
- console.log("call users/connect data=" + JSON.stringify(data, null, 2));
-
- return new Promise((resolve, reject) => {
- this.httpOAuth.post("users/connect", httpOption, data)
- .then(function(response: any) {
- if (response.status == 200) {
- resolve(response.data);
- return;
- }
- reject("An error occured");
- }, function(response: any) {
- if (typeof response.data === 'undefined') {
- reject("return ERROR undefined");
- } else {
- reject("return ERROR " + JSON.stringify(response.data, null, 2));
- }
- });
- });
- */
}
create(login : string, email : string, password : string) {
@@ -210,50 +201,5 @@ export class UserService {
*/
return false;
}
-
- checkLogin(login: string) {
- let params = {
- login: login
- };
- return new Promise((resolve, reject) => {
- this.http.requestJson({
- server: 'karauth',
- endPoint: 'users/check_login',
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- params,
- }).then((response: ModelResponseHttp) =>{
- // TODO: check type ...
- console.log(`createSha : get some data to check: ${JSON.stringify(response.data)}`)
- resolve(response.data);
- }).catch((error:any) => {
- reject(`return ERROR ${ JSON.stringify(error, null, 2)}`);
- });
- });
-
- }
-
- checkEMail(email: string) {
- let params = {
- email: email
- };
- return new Promise((resolve, reject) => {
- this.http.requestJson({
- server: 'karauth',
- endPoint: 'users/check_email',
- requestType: HTTPRequestModel.GET,
- accept: HTTPMimeType.JSON,
- contentType: HTTPMimeType.JSON,
- params,
- }).then((response: ModelResponseHttp) =>{
- // TODO: check type ...
- console.log(`createSha : get some data to check: ${JSON.stringify(response.data)}`)
- resolve(response.data);
- }).catch((error:any) => {
- reject(`return ERROR ${ JSON.stringify(error, null, 2)}`);
- });
- });
- }
}
diff --git a/front/src/app/service/video.ts b/front/src/app/service/video.ts
index d45e2d0..bbe7213 100644
--- a/front/src/app/service/video.ts
+++ b/front/src/app/service/video.ts
@@ -8,7 +8,7 @@ import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper';
import { BddService } from './bdd';
-import { DataInterface } from './dataInterface';
+import { DataInterface } from '../utils/dataInterface';
@Injectable()
export class VideoService {
diff --git a/front/src/app/service/dataInterface.ts b/front/src/app/utils/dataInterface.ts
similarity index 54%
rename from front/src/app/service/dataInterface.ts
rename to front/src/app/utils/dataInterface.ts
index 2bcc136..e398b32 100644
--- a/front/src/app/service/dataInterface.ts
+++ b/front/src/app/utils/dataInterface.ts
@@ -4,21 +4,26 @@
* @license PROPRIETARY (see license file)
*/
- export interface MediaSmall {
- id: number;
- name: string;
- description?: string;
- dataId?: number;
- typeId?: number;
- universeId?: number;
- seriesId?: number;
- seasonId?: number;
- episode?: number;
- date?: number;
- time?: number;
- ageLimit?: string;
- covers: number[];
- };
+import { NodeData } from "../model";
+import { isArray, isNullOrUndefined, isUndefined } from "./validator";
+
+export enum TypeCheck {
+ EQUAL = '==',
+ NOT_EQUAL = '!=',
+ LESS = '<',
+ LESS_EQUAL = '<=',
+ GREATER = '>',
+ GREATER_EQUAL = '>=',
+}
+
+export interface SelectModel {
+ check: TypeCheck;
+ key: string;
+ value?: number|string|boolean|number[]|string[];
+}
+/*
+{ check: TypeCheck.EQUAL, key: sss, value: null}
+*/
/**
* @breif Generic interface to access to the BDD (no BDD, direct file IO)
@@ -26,7 +31,7 @@
export class DataInterface {
constructor(
private name: string,
- private bdd: MediaSmall[] ) {
+ private bdd: NodeData[] ) {
}
public getTableIndex(id: number) {
@@ -38,22 +43,19 @@ export class DataInterface {
return undefined;
}
- public gets(filter?: any) {
+ public gets(): NodeData[] {
console.log(`[I] gets ${ this.name}`);
- if(filter === undefined) {
- return this.bdd;
- }
- return this.filterObjectValues(this.bdd, filter);
+ return this.bdd;
}
- public getsWhere(select, filter?: string[], orderBy?: string[]) {
+ public getsWhere(select: SelectModel[], orderBy?: string[]): NodeData[] {
// console.log("[I] gets_where " + this.name + " select " + _select);
let tmpList = this.getSubList(this.bdd, select);
tmpList = this.orderBy(tmpList, orderBy);
- return this.filterObjectValues(tmpList, filter);
+ return tmpList;
}
- public get(id: number) {
+ public get(id: number): NodeData {
// console.log("[I] get " + this.name + " " + _id);
for(let iii = 0; iii < this.bdd.length; iii++) {
if(this.bdd[iii].id === id) {
@@ -64,7 +66,7 @@ export class DataInterface {
return undefined;
}
- public getNameLikeAll(name: string) {
+ public getNameLikeAll(name: string): NodeData[] {
let out = undefined;
let nameLower = name.toLowerCase();
for(let iii = 0; iii < this.bdd.length; iii++) {
@@ -77,7 +79,7 @@ export class DataInterface {
}
return out;
}
- public getNameLike(name: string): any[] {
+ public getNameLike(name: string): NodeData[] {
let out = [];
let nameLower = name.toLowerCase();
for(let iii = 0; iii < this.bdd.length; iii++) {
@@ -89,7 +91,7 @@ export class DataInterface {
return out;
}
- public set(id: number, value: any): void {
+ public set(id: number, value: NodeData): void {
console.log(`[I] Set ${ this.name } ${ id}`);
for(let iii = 0; iii < this.bdd.length; iii++) {
console.log(` check: ${ this.bdd[iii].id}`);
@@ -109,7 +111,7 @@ export class DataInterface {
}
}
- public find(listToken, values) {
+ public find(listToken, values): NodeData[] {
let out = [];
for(let iii = 0; iii < this.bdd.length; iii++) {
let find = true;
@@ -126,15 +128,15 @@ export class DataInterface {
return out;
}
- public count(select = undefined) {
- if(select === undefined) {
+ public count(select?: SelectModel[]) {
+ if(isNullOrUndefined(select)) {
return this.bdd.length;
}
let tmp = this.getSubList(this.bdd, select);
return tmp.length;
}
- public existIn(value: any, listValues: any) {
+ public existIn(value, listValues: number[]|string[]): boolean {
for(let iii = 0; iii < listValues.length; iii++) {
if(value === listValues[iii]) {
return true;
@@ -143,8 +145,8 @@ export class DataInterface {
return false;
}
- public getSubList(values: MediaSmall[], select: any[][] ) {
- let out = [];
+ public getSubList(values: NodeData[], select?: SelectModel[] ): NodeData[] {
+ let out = [] as NodeData[];
for(let iiiElem = 0; iiiElem < values.length; iiiElem++) {
let find = true;
if(select.length === 0) {
@@ -152,74 +154,58 @@ export class DataInterface {
}
// console.log("Check : " + JSON.stringify(_values[iii_elem], null, 2));
for(let iiiSelect = 0; iiiSelect < select.length; iiiSelect++) {
- if(select[iiiSelect].length !== 3) {
- console.log('[E] Internal Server Error: wrong select definition ...');
- return undefined;
- }
- let typeCheck = select[iiiSelect][0];
- let token = select[iiiSelect][1];
- let value = select[iiiSelect][2];
- if(Array.isArray(value)) {
- if(values[iiiElem][token] !== undefined) {
- if(typeCheck === '==') {
- if(this.existIn(values[iiiElem][token], value) === false) {
- find = false;
- break;
- }
- } else if(typeCheck === '!=') {
- if(this.existIn(values[iiiElem][token], value) === false) {
- find = false;
- break;
- }
- } else {
- console.log('[ERROR] Internal Server Error{ unknow comparing type ...');
- return undefined;
+ let control = select[iiiSelect];
+ let valueElement = values[iiiElem][control.key]
+ if(isArray(control.value)) {
+ if(control.check === TypeCheck.EQUAL) {
+ if(this.existIn(valueElement, control.value) === false) {
+ find = false;
+ break;
+ }
+ } else if(control.check === TypeCheck.NOT_EQUAL) {
+ if(this.existIn(valueElement, control.value) === false) {
+ find = false;
+ break;
}
} else {
- find = false;
- break;
+ console.log('[ERROR] Internal Server Error{ unknow comparing type ...');
+ return undefined;
}
} else {
- // console.log(" [" + token + "] = " + values[iii_elem][token]);
- if(values[iiiElem][token] !== undefined) {
- // console.log(" '" + type_check + "' " + value);
- if(typeCheck === '==') {
- if(values[iiiElem][token] !== value) {
- find = false;
- break;
- }
- } else if(typeCheck === '!=') {
- if(values[iiiElem][token] === value) {
- find = false;
- break;
- }
- } else if(typeCheck === '<') {
- if(values[iiiElem][token] >= value) {
- find = false;
- break;
- }
- } else if(typeCheck === '<=') {
- if(values[iiiElem][token] > value) {
- find = false;
- break;
- }
- } else if(typeCheck === '>') {
- if(values[iiiElem][token] <= value) {
- find = false;
- break;
- }
- } else if(typeCheck === '>=') {
- if(values[iiiElem][token] < value) {
- find = false;
- break;
- }
- } else {
- console.log('[ERROR] Internal Server Error{ unknow comparing type ...');
- return undefined;
+ //console.log(" [" + control.key + "] = " + valueElement);
+ if(control.check === TypeCheck.EQUAL) {
+ if(valueElement !== control.value) {
+ find = false;
+ break;
+ }
+ } else if(control.check === TypeCheck.NOT_EQUAL) {
+ if(valueElement === control.value) {
+ find = false;
+ break;
+ }
+ } else if(control.check === TypeCheck.LESS) {
+ if(valueElement >= control.value) {
+ find = false;
+ break;
+ }
+ } else if(control.check === TypeCheck.LESS_EQUAL) {
+ if(valueElement > control.value) {
+ find = false;
+ break;
+ }
+ } else if(control.check === TypeCheck.GREATER) {
+ if(valueElement <= control.value) {
+ find = false;
+ break;
+ }
+ } else if(control.check === TypeCheck.GREATER_EQUAL) {
+ if(valueElement < control.value) {
+ find = false;
+ break;
}
} else {
- find = false;
- break;
+ console.log('[ERROR] Internal Server Error{ unknow comparing type ...');
+ return undefined;
}
}
}
@@ -233,8 +219,8 @@ export class DataInterface {
return out;
}
- public orderBy(values: any[], order: string[]): any[] {
- if(order === undefined) {
+ public orderBy(values: NodeData[], order: string[]): NodeData[] {
+ if(isNullOrUndefined(order)) {
return values;
}
if(order.length === 0) {
@@ -287,35 +273,5 @@ export class DataInterface {
}
return out;
}
-
- public filterObjectValues(values: MediaSmall[], filter: string[]): any[] {
- let out: MediaSmall[] = [];
- if(filter === undefined) {
- return values;
- }
- if(filter.length === 1) {
- let token = filter[0];
- for(let iii = 0; iii < values.length; iii++) {
- if(values[iii][token] === undefined) {
- continue;
- }
- if(this.existIn(values[iii][token], out) === false) {
- out.push(values[iii][token]);
- }
- }
- return out;
- }
- for(let iii = 0; iii < values.length; iii++) {
- let elementOut: any = {};
- for(let jjj = 0; jjj < filter.length; jjj++) {
- if(values[iii][filter[jjj]] === undefined) {
- continue;
- }
- elementOut[filter[jjj]] = values[iii][filter[jjj]];
- }
- out.push(elementOut);
- }
- return out;
- }
}
diff --git a/front/src/app/utils/index.ts b/front/src/app/utils/index.ts
new file mode 100644
index 0000000..d6422a3
--- /dev/null
+++ b/front/src/app/utils/index.ts
@@ -0,0 +1,21 @@
+
+
+import { DataInterface } from "./dataInterface";
+import { isArray, isArrayOf, isBoolean, isNull, isNullOrUndefined, isNumber, isNumberFinite, isObject, isOptionalOf, isOptionalArrayOf, isString, isUndefined } from "./validator";
+
+export {
+ isNumber,
+ isNumberFinite,
+ isBoolean,
+ isString,
+ isArray,
+ isNull,
+ isUndefined,
+ isNullOrUndefined,
+ isObject,
+ isArrayOf,
+ isOptionalOf,
+ isOptionalArrayOf,
+ DataInterface,
+}
+
diff --git a/front/src/app/utils/validator.ts b/front/src/app/utils/validator.ts
new file mode 100644
index 0000000..1b9d103
--- /dev/null
+++ b/front/src/app/utils/validator.ts
@@ -0,0 +1,52 @@
+
+export function isNumber(data: any): data is number {
+ return typeof data === "number";
+}
+export function isNumberFinite(data: any): data is number {
+ return isNumber(data) && isFinite(data);
+}
+export function isBoolean(data: any): data is boolean {
+ return typeof data === "boolean";
+}
+export function isString(data: any): data is string {
+ return typeof data === "string";
+}
+export function isArray(data: any): data is any[] {
+ return Array.isArray(data);
+}
+export function isNull(data: any): data is null {
+ return data === null;
+}
+export function isUndefined(data: any): data is undefined {
+ return data === undefined;
+}
+export function isNullOrUndefined(data: any): data is undefined | null {
+ return data === undefined || data === null;
+}
+export function isObject(data: any): data is any {
+ return !isNullOrUndefined(data)
+ && typeof data === 'object'
+ && !isArray(data);
+}
+
+export function isArrayOf(data: any, typeChecker: (subData: any) => subData is TYPE, length?: number): data is TYPE[] {
+ if (!isArray(data)) {
+ return false;
+ }
+ if (!data.every(typeChecker)) {
+ return false;
+ }
+ if (!isUndefined(length) && data.length != length) {
+ return false;
+ }
+ return true;
+}
+
+export function isOptionalOf(data: any, typeChecker: (subData: any) => subData is TYPE): data is TYPE | undefined {
+ return isUndefined(data) || typeChecker(data);
+}
+
+export function isOptionalArrayOf(data: any, typeChecker: (subData: any) => subData is TYPE): data is TYPE[] | undefined {
+ return isUndefined(data) || isArrayOf(data, typeChecker);
+}
+
diff --git a/front/src/assets/aaa_interfaceCloud.js b/front/src/assets/aaa_interfaceCloud.js
deleted file mode 100644
index f7e0760..0000000
--- a/front/src/assets/aaa_interfaceCloud.js
+++ /dev/null
@@ -1,24 +0,0 @@
-
-/**
- * @brief create the rest call element of the link
- */
-let createRESTCall = function(api, options) {
- // http://localhost/exercice
- let basePage = "" + window.location;
- if (basePage.endsWith("index.xhtml") == true) {
- basePage = basePage.substring(0, basePage.length - 11);
- }
- if (basePage.endsWith("index.php") == true) {
- basePage = basePage.substring(0, basePage.length - 10);
- }
- let addressServerRest =basePage + "/api/v1/index.php";
- if (typeof options === 'undefined') {
- options = [];
- }
- let out = addressServerRest + "?REST=" + api;
- for (let iii=0; iii
+ viewBox="0 0 499 498"
+ version="1.1"
+ id="svg10"
+ sodipodi:docname="avatar_generic.svg"
+ inkscape:version="1.1.2 (0a00cf5339, 2022-02-04, custom)"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg">
+
+
+ y="-1.9999847"
+ id="rect2" />
+ style="fill:#4e4e4d;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
+ d="m 198.78572,292.40268 -11.97951,28.10434 -7.03868,-39.62542 -32.77188,20.51375 14.30166,-59.1095 -47.70972,20.8692 30.95257,-58.44261 -40.08325,-11.9709 50.99682,-31.08004 -30.32488,-33.92052 41.38608,6.88643 c 0,0 -27.42157,-58.130582 -26.08007,-58.130582 1.34149,0 54.85161,37.962212 54.85161,37.962212 l 6.10019,-52.959427 22.55992,46.026947 33.20732,-51.718401 8.75817,54.113371 53.78031,-55.134502 -14.88381,76.635492 112.00146,-17.67965 -84.26404,54.10353 65.61018,10.26713 -53.91421,37.51917 40.05564,55.00796 -51.48529,-23.57551 7.49544,56.99322 -27.79947,-24.64556 -3.80452,36.62241 -23.37869,-22.14564 -5.89389,23.82189 -20.64297,-29.48769 -15.46209,46.92367 -7.2608,-54.46889 -21.32424,51.07849 z"
+ id="path3162"
+ sodipodi:nodetypes="cccccccccccsccccccccccccccccccccccc" />
+ style="fill:#fbd0a6;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 126.90172,351.92657 55.90379,145.23242 168.77912,0.48055 8.10502,-147.83696 -56.19339,-10.73582 -9.91368,3.09728 -8.25753,-48.27446 -8.77147,-41.82541 -73.97306,-0.86753 -4.65072,84.85557 z"
+ id="path3467"
+ sodipodi:nodetypes="ccccccccccc" />
+ style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 45.319305,524.24985 50.878125,-168.64351 91.02866,-21.85078 124.81002,189.43887 15.4976,-12.33208 -130.63444,-191.36234 -9.67318,14.25555 124.81002,189.43887"
+ id="path275"
+ sodipodi:nodetypes="cccccccc" />
+
+
diff --git a/front/src/environments/environment.prod.ts b/front/src/environments/environment.prod.ts
index 444be63..3e4fab7 100644
--- a/front/src/environments/environment.prod.ts
+++ b/front/src/environments/environment.prod.ts
@@ -4,12 +4,17 @@
// The list of which env maps to which file can be found in `.angular-cli.json`.
export const environment = {
- production: true,
+ production: false,
// URL of development API
- apiUrl: 'http://192.168.1.156/karideo/api',
- apiOAuthUrl: 'http://192.168.1.156/karauth/api',
- frontBaseUrl: 'karideo',
- apiMode: 'QUERRY',
- // apiMode: "REWRITE",
- localBdd: true
-};
+ applName: "karideo",
+ defaultServer: "karideo",
+ server: {
+ karideo: 'http://192.168.1.156/karideo/api',
+ karauth: 'http://192.168.1.156/karauth/api',
+ },
+ ssoSignIn: 'http://192.168.1.156/karso/signin/karideo/',
+ ssoSignUp: 'http://192.168.1.156/karso/signup/karideo/',
+ ssoSignOut: 'http://192.168.1.156/karso/signout/karideo/',
+ frontBaseUrl: '',
+ apiMode: 'REWRITE'
+};
\ No newline at end of file
diff --git a/front/src/environments/environment.ts b/front/src/environments/environment.ts
index 033fad7..cc50b57 100644
--- a/front/src/environments/environment.ts
+++ b/front/src/environments/environment.ts
@@ -6,12 +6,31 @@
export const environment = {
production: false,
// URL of development API
- // apiUrl: 'http://localhost:15080',
- // apiUrl: 'http://localhost:18080/karideo/api',
- apiUrl: 'http://192.168.1.156/karideo/api',
- // apiOAuthUrl: 'http://localhost:17080/karauth/api',
- apiOAuthUrl: 'http://192.168.1.156/karauth/api',
+ applName: "karideo",
+ defaultServer: "karideo",
+ server: {
+ karideo: 'http://localhost:18080/karideo/api',
+ karauth: 'http://192.168.1.156/karauth/api',
+ },
+ ssoSignIn: 'http://192.168.1.156/karso/signin/karideo-dev/',
+ ssoSignUp: 'http://192.168.1.156/karso/signup/karideo-dev/',
+ ssoSignOut: 'http://192.168.1.156/karso/signout/karideo-dev/',
+ frontBaseUrl: '',
+ apiMode: 'REWRITE'
+};
+
+export const environment_kjlkjlkjlkj = {
+ production: false,
+ // URL of development API
+ applName: "karideo",
+ defaultServer: "karideo",
+ server: {
+ karideo: 'http://192.168.1.156/karideo/api',
+ karauth: 'http://192.168.1.156/karauth/api',
+ },
+ ssoSignIn: 'http://localhost:4200/signin/karideo-dev/',
+ ssoSignUp: 'http://localhost:4200/signup/karideo-dev/',
+ ssoSignOut: 'http://localhost:4200/signout/karideo-dev/',
frontBaseUrl: '',
- // apiMode: "QUERRY"
apiMode: 'REWRITE'
};
diff --git a/front/src/index.html b/front/src/index.html
index be02f80..8ef0cdc 100644
--- a/front/src/index.html
+++ b/front/src/index.html
@@ -22,10 +22,6 @@
-
-
-
-
diff --git a/front/tsconfig.json b/front/tsconfig.json
index d6c60a1..d3a8194 100644
--- a/front/tsconfig.json
+++ b/front/tsconfig.json
@@ -9,12 +9,12 @@
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
- "target": "es2015",
+ "target": "es2018",
"typeRoots": [
"node_modules/@types"
],
"lib": [
- "es2017",
+ "es2018",
"dom"
],
"module": "es2020",