[DEV] many transfer in common

This commit is contained in:
Edouard DUPIN 2022-06-13 22:34:45 +02:00
parent d8086452c3
commit ae915b34a6
51 changed files with 237 additions and 230 deletions

View File

@ -6,8 +6,10 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'; // CLI imports router
import { SsoScene } from 'common/scene';
import { HelpScene, HomeScene, SeasonEditScene, SeasonScene, SeriesEditScene, SeriesScene, SettingsScene, SsoScene, TypeScene, UniverseScene, UploadScene, VideoEditScene, VideoScene } from './scene';
import { HelpScene, HomeScene, SeasonEditScene, SeasonScene, SeriesEditScene, SeriesScene, SettingsScene, TypeScene, UniverseScene, VideoEditScene, VideoScene } from './scene';
import { UploadScene } from './scene/upload/upload';
// import { HelpComponent } from './help/help.component';
// see https://angular.io/guide/router

View File

@ -6,7 +6,7 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { UserService, SessionService } from './service';
import { UserService, SessionService } from 'common/service';
@Component({
selector: 'app-root',

View File

@ -11,26 +11,28 @@ import { HttpClientModule } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; // this is needed for dynamic selection of the select
import { AppRoutingModule } from './app-routing.module';
import { UploadFileComponent } from './component/upload-file/upload-file';
import { UploadFileComponent } from '../common/component/upload-file/upload-file';
import { TopMenuComponent } from './component/top-menu/top-menu';
import { ElementDataImageComponent } from './component/data-image/data-image';
import { ElementTypeComponent } from './component/element-type/element-type';
import { ElementSeriesComponent } from './component/element-series/element-series';
import { ElementSeasonComponent } from './component/element-season/element-season';
import { ElementVideoComponent } from './component/element-video/element-video';
import { PopInComponent } from './component/popin/popin';
import { PopInComponent } from '../common/component/popin/popin';
import { PopInCreateType } from './popin/create-type/create-type';
import { PopInUploadProgress } from './popin/upload-progress/upload-progress';
import { PopInDeleteConfirm } from './popin/delete-confirm/delete-confirm';
import { PopInUploadProgress } from '../common/popin/upload-progress/upload-progress';
import { PopInDeleteConfirm } from '../common/popin/delete-confirm/delete-confirm';
import { AppComponent } from './app.component';
import { ErrorComponent } from './error/error';
import { HomeScene, ErrorViewerScene, HelpScene, SsoScene, TypeScene, UniverseScene, SeriesScene, SeasonScene, VideoScene, SettingsScene,
VideoEditScene, SeasonEditScene, SeriesEditScene, UploadScene } from './scene';
import { PopInService, HttpWrapperService, SessionService, UserService, SSOService, BddService, TypeService,
import { ErrorComponent } from '../common/error/error';
import { HomeScene, HelpScene, TypeScene, UniverseScene, SeriesScene, SeasonScene, VideoScene, SettingsScene,
VideoEditScene, SeasonEditScene, SeriesEditScene } from './scene';
import { BddService, TypeService,
DataService, UniverseService, SeriesService, SeasonService, VideoService, ArianeService } from './service';
import { CookiesService, StorageService } from 'common/service';
import { CookiesService, HttpWrapperService, PopInService, SessionService, SSOService, StorageService, UserService } from 'common/service';
import { ErrorViewerScene, SsoScene } from 'common/scene';
import { UploadScene } from './scene/upload/upload';
@NgModule({
declarations: [

View File

@ -6,7 +6,7 @@
import { Injectable, Component, OnInit, Input } from '@angular/core';
import { isMedia, Media } from 'app/model';
import { VideoService, DataService, HttpWrapperService } from 'app/service';
import { DataService } from 'app/service';
import { NodeData } from 'common/model';
import { isNullOrUndefined } from 'common/utils';
@ -31,10 +31,7 @@ export class ElementVideoComponent implements OnInit {
constructor(
private dataService: DataService) {
}
OnDestroy() {
// nothing to do.
}
ngOnInit() {
if (!isMedia(this.element)) {

View File

@ -5,7 +5,8 @@
*/
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { UserService, SessionService, SSOService, ArianeService } from 'app/service';
import { UserService, SessionService, SSOService } from 'common/service';
import { ArianeService } from 'app/service';
@Component({
selector: 'app-top-menu',

View File

@ -5,7 +5,7 @@
*/
import { Component, OnInit } from '@angular/core';
import { PopInService } from 'app/service/popin';
import { PopInService } from 'common/service/popin';
@Component({
selector: 'create-type',

View File

@ -1,4 +1,3 @@
import { ErrorViewerScene } from "./error-viewer/error-viewer";
import { HelpScene } from "./help/help";
import { HomeScene } from "./home/home";
import { SeasonEditScene } from "./season-edit/season-edit";
@ -6,19 +5,15 @@ import { SeasonScene } from "./season/season";
import { SeriesEditScene } from "./series-edit/series-edit";
import { SeriesScene } from "./series/series";
import { SettingsScene } from "./settings/settings";
import { SsoScene } from "./sso/sso";
import { TypeScene } from "./type/type";
import { UniverseScene } from "./universe/universe";
import { UploadScene } from "./upload/upload";
import { VideoEditScene } from "./video-edit/video-edit";
import { VideoScene } from "./video/video";
export {
ErrorViewerScene,
HelpScene,
HomeScene,
SsoScene,
SettingsScene,
SeasonScene,
SeasonEditScene,
@ -26,7 +21,6 @@ export {
SeriesEditScene,
TypeScene,
UniverseScene,
UploadScene,
VideoScene,
VideoEditScene,
};

View File

@ -7,9 +7,10 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { SeasonService , ArianeService, DataService, PopInService} from 'app/service';
import { SeasonService , ArianeService, DataService} from 'app/service';
import { UploadProgress } from 'app/popin/upload-progress/upload-progress';
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
import { PopInService } from 'common/service';
export interface ElementList {
value: number;

View File

@ -7,8 +7,9 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { SeriesService, DataService, TypeService, ArianeService, PopInService } from 'app/service';
import { UploadProgress } from 'app/popin/upload-progress/upload-progress';
import { SeriesService, DataService, TypeService, ArianeService } from 'app/service';
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
import { PopInService } from 'common/service';
export class ElementList {
constructor(

View File

@ -7,8 +7,9 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { PopInService, TypeService, UniverseService, SeriesService, VideoService, ArianeService, SeasonService } from 'app/service';
import { UploadProgress } from 'app/popin/upload-progress/upload-progress';
import { TypeService, UniverseService, SeriesService, VideoService, ArianeService, SeasonService } from 'app/service';
import { UploadProgress } from 'common/popin/upload-progress/upload-progress';
import { PopInService } from 'common/service';
export class ElementList {
constructor(

View File

@ -8,9 +8,10 @@ import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { PopInService, DataService, TypeService, UniverseService, SeriesService, VideoService, ArianeService } from 'app/service';
import { UploadProgress } from 'app/popin/upload-progress/upload-progress';
import { DataService, TypeService, UniverseService, 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';
export interface ElementList {
value?: number;

View File

@ -6,7 +6,8 @@
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { HttpWrapperService, DataService, VideoService, SeriesService, SeasonService, ArianeService } from 'app/service';
import { DataService, VideoService, SeriesService, SeasonService, ArianeService } from 'app/service';
import { HttpWrapperService } from 'common/service';
import { isNullOrUndefined } from 'common/utils';
@Component({

View File

@ -5,7 +5,7 @@
*/
import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper';
import { HttpWrapperService } from 'common/service/http-wrapper';
import { DataInterface } from 'common/utils/dataInterface';

View File

@ -7,7 +7,7 @@
import { Injectable } from '@angular/core';
import { isArrayOf, isNumberFinite } from 'common/utils';
import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from './http-wrapper';
import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from '../../common/service/http-wrapper';
@Injectable()
export class DataService {
@ -23,7 +23,7 @@ export class DataService {
}
get(_id:number):any {
return this.http.getSpecific(this.serviceName, _id);
return this.http.getSpecific([this.serviceName, _id]);
}
sendFile(_file:File) {

View File

@ -1,29 +1,15 @@
import { ArianeService } from "./ariane";
import { BddService } from "./bdd";
import { DataService } from "./data";
import { HttpWrapperService, ModelResponseHttp, HTTPRequest, HTTPMimeType, HTTPRequestModel } from "./http-wrapper";
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 {
HttpWrapperService,
ModelResponseHttp,
HTTPRequest,
HTTPMimeType,
HTTPRequestModel,
PopInService,
SessionService,
UserService,
SSOService,
ArianeService,
BddService,
DataService,

View File

@ -6,7 +6,7 @@
import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper';
import { HttpWrapperService } from '../../common/service/http-wrapper';
import { DataInterface } from 'common/utils';
import { BddService } from './bdd';
import { TypeCheck } from 'common/utils/dataInterface';
@ -88,19 +88,19 @@ export class SeasonService {
});
}
put(id:number, data:any):any {
let ret = this.http.putSpecific(this.serviceName, id, data);
let ret = this.http.putSpecific([this.serviceName, id], data);
return this.bdd.setAfterPut(this.serviceName, id, ret);
}
delete(id:number):any {
let ret = this.http.deleteSpecific(this.serviceName, id);
let ret = this.http.deleteSpecific([this.serviceName, id]);
return this.bdd.delete(this.serviceName, id, ret);
}
deleteCover(nodeId:number,
coverId:number) {
let self = this;
return new Promise((resolve, reject) => {
self.http.getSpecific(`${this.serviceName }/${ nodeId }/rm_cover`, coverId)
self.http.getSpecific([this.serviceName, nodeId, 'rm_cover', coverId])
.then((response) => {
let data = response;
if(data === null || data === undefined) {

View File

@ -6,7 +6,7 @@
import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper';
import { HttpWrapperService } from '../../common/service/http-wrapper';
import { DataInterface, TypeCheck } from 'common/utils/dataInterface';
import { BddService } from './bdd';
import { isNodeData, NodeData } from 'common/model';
@ -146,12 +146,12 @@ export class SeriesService {
}
put(id:number, data:any):any {
let ret = this.http.putSpecific(this.serviceName, id, data);
let ret = this.http.putSpecific([this.serviceName, id], data);
return this.bdd.setAfterPut(this.serviceName, id, ret);
}
delete(id:number):any {
let ret = this.http.deleteSpecific(this.serviceName, id);
let ret = this.http.deleteSpecific([this.serviceName, id]);
return this.bdd.delete(this.serviceName, id, ret);
}
@ -176,7 +176,7 @@ export class SeriesService {
coverId:number) {
let self = this;
return new Promise((resolve, reject) => {
self.http.getSpecific(`${this.serviceName}/${nodeId}/rm_cover`, coverId)
self.http.getSpecific([this.serviceName, nodeId, 'rm_cover', coverId])
.then((response) => {
let data = response;
if(data === null || data === undefined) {

View File

@ -6,7 +6,7 @@
import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper';
import { HttpWrapperService } from '../../common/service/http-wrapper';
import { BddService } from './bdd';
import { DataInterface, isNullOrUndefined } from 'common/utils';
import { NodeData } from 'common/model';

View File

@ -6,7 +6,7 @@
import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper';
import { HttpWrapperService } from '../../common/service/http-wrapper';
import { BddService } from './bdd';
@Injectable()
@ -59,14 +59,14 @@ export class UniverseService {
}
put(id:number, data:any):any {
let ret = this.http.putSpecific(this.serviceName, id, data);
let ret = this.http.putSpecific([this.serviceName, id], data);
return this.bdd.setAfterPut(this.serviceName, id, ret);
}
deleteCover(nodeId:number,
coverId:number) {
let self = this;
return new Promise((resolve, reject) => {
self.http.getSpecific(`${this.serviceName }/${ nodeId }/rm_cover`, coverId)
self.http.getSpecific([this.serviceName, nodeId, 'rm_cover', coverId])
.then((response) => {
let data = response;
if(data === null || data === undefined) {

View File

@ -6,7 +6,7 @@
import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper';
import { HttpWrapperService } from '../../common/service/http-wrapper';
import { BddService } from './bdd';
import { DataInterface } from 'common/utils/dataInterface';
@ -37,11 +37,11 @@ export class VideoService {
}
put(id:number, data:any):any {
let ret = this.http.putSpecific(this.serviceName, id, data);
let ret = this.http.putSpecific([this.serviceName, id], data);
return this.bdd.setAfterPut(this.serviceName, id, ret);
}
delete(id:number):any {
let ret = this.http.deleteSpecific(this.serviceName, id);
let ret = this.http.deleteSpecific([this.serviceName, id]);
return this.bdd.delete(this.serviceName, id, ret);
}
@ -90,7 +90,7 @@ export class VideoService {
coverId:number) {
let self = this;
return new Promise((resolve, reject) => {
self.http.getSpecific(`${this.serviceName }/${ mediaId }/rm_cover`, coverId)
self.http.getSpecific([this.serviceName, mediaId, 'rm_cover', coverId])
.then((response) => {
let data = response;
if(data === null || data === undefined) {

View File

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

View File

@ -6,7 +6,7 @@
import { Component, Input, Output, OnInit, OnDestroy, EventEmitter } from '@angular/core';
import { PopInService } from 'app/service';
import { PopInService } from 'common/service';
@Component({
// moduleId: module.id.toString(),

View File

@ -6,7 +6,7 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { PopInService } from 'app/service';
import { PopInService } from 'common/service';
@Component({
selector: 'delete-confirm',

View File

@ -7,7 +7,7 @@
import { Component, OnInit, Input, SimpleChanges } from '@angular/core';
import { Router } from '@angular/router';
import { PopInService } from 'app/service';
import { PopInService } from 'common/service';
@Component({
selector: 'upload-progress',

View File

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

View File

@ -6,7 +6,7 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { SSOService, UserService } from 'app/service';
import { SSOService, UserService } from 'common/service';
@Component({
selector: 'app-sso',

View File

@ -10,7 +10,7 @@ import { HttpClient, HttpHeaders, HttpEventType } from '@angular/common/http';
import { environment } from 'environments/environment';
import { SessionService } from './session';
import { isNullOrUndefined } from 'common/utils';
import { isArrayOf, isArrayOfs, isBoolean, isNullOrUndefined, isNumber, isString } from 'common/utils';
export enum HTTPRequestModel {
POST = "POST",
@ -28,16 +28,21 @@ export enum HTTPMimeType {
IMAGE_PNG = "image/png",
}
export type UrlPath = string | boolean | number | (string|boolean|number)[];
export type ProgressCallback = (count: number, total:number) => void;
export interface HTTPRequest {
server?: string;
endPoint: string;
endPoint: UrlPath;
requestType: HTTPRequestModel ;
accept: HTTPMimeType;
contentType: HTTPMimeType;
params?: object;
body?: any;
authorization?: string; // c'est un hook de merde ...
disableTocken?:boolean;
disableTocken?: boolean;
// progress interface to notify progression of the streaming.
progress?: ProgressCallback;
}
export interface ModelResponseHttp {
@ -156,7 +161,7 @@ export class HttpWrapperService {
}
createRESTCall2({ api, server, inputOptions, addURLToken }: { server?: string; api: string; inputOptions?: object; addURLToken?:boolean }) {
createRESTCall2({ api, server, inputOptions, addURLToken }: { server?: string; api: UrlPath; inputOptions?: object; addURLToken?:boolean }) {
if (isNullOrUndefined(server)) {
server = environment.defaultServer;
@ -167,7 +172,15 @@ export class HttpWrapperService {
if(isNullOrUndefined(options)) {
options = {};
}
let out = addressServerRest + api;
let out = addressServerRest;
if (isArrayOfs(api, isString, isNumber, isBoolean)) {
for (let iii=0; iii<api.length; iii++) {
let elem = api[iii];
out += `/${elem}`;
}
} else {
out += api;
}
let first = true;
let keys = Object.keys(options);
for(let iii = 0; iii < keys.length; iii++) {
@ -218,34 +231,7 @@ export class HttpWrapperService {
return out;
}
get(uriRest:string, headerOption:any, params:any): Promise<{status:number, data:any}> {
console.log(`-------------------------------------------------------\nHTTP-wrapper GET '${ uriRest }'\n\t\theaderOption=${ JSON.stringify(headerOption, null, 2)}\n\t\tparams=${ JSON.stringify(params, null, 2)}`);
let connectionAdresse = this.createRESTCall(uriRest, {});
const headers = this.addTokenIfNeeded(headerOption);
let self = this;
return new Promise((resolve, reject) => {
fetch(connectionAdresse, {
method: "GET",
headers,
}).then((response: Response) => {
if(response.status === 200) {
response.json().then((value:any) => {
//console.log(`REICEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
resolve({ status:response.status, data:response.body });
}).catch((reason:any)=> {
reject({ status:999, data:reason });
});
} else {
resolve({ status:900, data:'' });
}
}).catch((error: any) => {
reject({ status:error.status, data:error.error });
});
});
}
post(uriRest:string, headerOption:any, data:any, progress:any = null) {
post(uriRest:string, headerOption:any, data:any, progress:ProgressCallback = null) {
console.log(`-------------------------------------------------------\nHTTP-wrapper POST '${ uriRest }'\n\t\theaderOption=${ JSON.stringify(headerOption, null, 2)}\n\t\tdata=${ JSON.stringify(data, null, 2)}`);
this.addTokenIfNeeded(headerOption);
let connectionAdresse = this.createRESTCall(uriRest, {});
@ -319,7 +305,8 @@ export class HttpWrapperService {
*/
});
}
put(uriRest:string, headerOption:any, data:any) {
putwwww(uriRest:string, headerOption:any, data:any) {
console.log(`-------------------------------------------------------\nHTTP-wrapper PUT '${ uriRest }'\n\t\theaderOption=${ JSON.stringify(headerOption, null, 2)}\n\t\tdata=${ JSON.stringify(data, null, 2)}`);
this.addTokenIfNeeded(headerOption);
let connectionAdresse = this.createRESTCall(uriRest, {});
@ -355,6 +342,7 @@ export class HttpWrapperService {
});
});
}
delete(uriRest:string, headerOption:any) {
this.addTokenIfNeeded(headerOption);
let connectionAdresse = this.createRESTCall(uriRest, {});
@ -557,7 +545,7 @@ export class HttpWrapperService {
};
});
}
uploadMultipart(base:string, multipart:FormData, progress:any): any {
uploadMultipart(base:string, multipart:FormData, progress: ProgressCallback): any {
console.log(`Upload multipart to ${ base}`);
let url = base;
@ -586,30 +574,10 @@ export class HttpWrapperService {
}
// Complex wrapper to simplify interaction:
getSpecific(base:string, id:number = null, subElement:string = '', select:string[] = []):any {
//console.log(`Get All data from ${ base}`);
let url = base;
if(id !== null) {
url = `${url}/${id}`;
}
if(subElement !== '') {
url = `${url}/${subElement}`;
}
if(select.length !== 0) {
let newValue = '';
for(let iii = 0; iii < select.length; iii++) {
if(select.length !== 0) {
newValue = `${newValue}&`;
}
newValue = `${newValue}select=${select[iii]}`;
}
url = `${url}?${newValue}`;
}
//console.log("call GET " + url);
getSpecific(urlPath: UrlPath):any {
return new Promise((resolve, reject) => {
this.requestJson({
endPoint: url,
endPoint: urlPath,
requestType: HTTPRequestModel.GET,
accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON,
@ -622,7 +590,7 @@ export class HttpWrapperService {
}
reject('An error occured');
}, (response: ModelResponseHttp) => {
if(typeof response.data === 'undefined') {
if(isNullOrUndefined(response.data)) {
reject('return ERROR undefined');
} else {
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
@ -632,111 +600,97 @@ export class HttpWrapperService {
}
// Complex wrapper to simplify interaction:
deleteSpecific(base:string, id:number, subElement:string = ''):any {
// console.log("delete data to " + base);
const httpOption = { 'Content-Type': 'application/json' };
let url = base;
if(id !== null) {
url = `${url }/${ id}`;
}
if(subElement !== '') {
url = `${url }/${ subElement}`;
}
// console.log("call DELETE: " + url);
// console.log(" data: " + JSON.stringify(data, null, 2));
//// TODO change thje base and ID to manage a single [] ...
putSpecific(urlPath: UrlPath, data: object):Promise<ModelResponseHttp> {
return new Promise((resolve, reject) => {
this.delete(url, httpOption)
.then((response: any) => {
// console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
if(response.status === 200) {
resolve(response.data);
return;
}
if(response.status === 201) {
resolve(response.data);
return;
}
reject('An error occured');
}, (response: any) => {
if(typeof response.data === 'undefined') {
reject('return ERROR undefined');
this.request({
endPoint: urlPath,
requestType: HTTPRequestModel.PUT,
accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON,
body: data,
}).then((response: Response) => {
if(response.status >= 200 && response.status <= 201) {
const contentType = response.headers.get('Content-Type');
if (contentType === HTTPMimeType.JSON) {
response.json().then((value:any) => {
//console.log(`REICEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
resolve({ status:response.status, data:value });
}).catch((reason:any)=> {
reject({ status:999, data:reason });
});
} else {
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
console.error(`content Type is not Json: ${contentType}`)
reject({ status: 998, data:`content Type is not Json: ${contentType}` });
}
});
} else {
console.error(`wrong correct status: ${response.status}`)
reject({ status: 900, data: response });
}
}).catch((error: any) => {
reject({ status:error.status, data:error.error });
});
});
}
// Complex wrapper to simplify interaction:
putSpecific(base:string, id:number, data:any, subElement:string = ''):any {
// console.log("put data to " + base);
const httpOption = { 'Content-Type': 'application/json' };
let url = base;
if(id !== null) {
url = `${url }/${ id}`;
}
if(subElement !== '') {
url = `${url }/${ subElement}`;
}
// console.log("call PUT: " + url);
// console.log(" data: " + JSON.stringify(data, null, 2));
postSpecific(urlPath: UrlPath, data: object):Promise<ModelResponseHttp> {
return new Promise((resolve, reject) => {
this.put(url, httpOption, data)
.then((response: any) => {
// console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
if(response.status === 200) {
resolve(response.data);
return;
}
if(response.status === 201) {
resolve(response.data);
return;
}
reject('An error occured');
}, (response: any) => {
if(typeof response.data === 'undefined') {
reject('return ERROR undefined');
this.request({
endPoint: urlPath,
requestType: HTTPRequestModel.POST,
accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON,
body: data,
}).then((response: Response) => {
if(response.status >= 200 && response.status <= 201) {
const contentType = response.headers.get('Content-Type');
if (contentType === HTTPMimeType.JSON) {
response.json().then((value:any) => {
//console.log(`REICEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
resolve({ status:response.status, data:value });
}).catch((reason:any)=> {
reject({ status:999, data:reason });
});
} else {
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
console.error(`content Type is not Json: ${contentType}`)
reject({ status: 998, data:`content Type is not Json: ${contentType}` });
}
});
} else {
console.error(`wrong correct status: ${response.status}`)
reject({ status: 900, data: response });
}
}).catch((error: any) => {
reject({ status:error.status, data:error.error });
});
});
}
// Complex wrapper to simplify interaction:
postSpecific(base:string, id:number, data:any, subElement:string = ''):any {
// console.log("put data to " + base);
const httpOption = { 'Content-Type': 'application/json' };
let url = base;
if(id !== null) {
url = `${url }/${ id}`;
}
if(subElement !== '') {
url = `${url }/${ subElement}`;
}
// console.log("call PUT: " + url);
// console.log(" data: " + JSON.stringify(data, null, 2));
deleteSpecific(urlPath: UrlPath ):Promise<ModelResponseHttp> {
return new Promise((resolve, reject) => {
this.post(url, httpOption, data)
.then((response: any) => {
// console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
if(response.status === 200) {
resolve(response.data);
return;
}
if(response.status === 201) {
resolve(response.data);
return;
}
reject('An error occured');
}, (response: any) => {
if(typeof response.data === 'undefined') {
reject('return ERROR undefined');
this.request({
endPoint: urlPath,
requestType: HTTPRequestModel.DELETE,
accept: HTTPMimeType.JSON,
contentType: HTTPMimeType.JSON,
}).then((response: Response) => {
if(response.status >= 200 && response.status <= 201) {
const contentType = response.headers.get('Content-Type');
if (contentType === HTTPMimeType.JSON) {
response.json().then((value:any) => {
//console.log(`REICEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
resolve({ status:response.status, data:value });
}).catch((reason:any)=> {
reject({ status:999, data:reason });
});
} else {
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
console.error(`content Type is not Json: ${contentType}`)
reject({ status: 998, data:`content Type is not Json: ${contentType}` });
}
});
} else {
console.error(`wrong correct status: ${response.status}`)
reject({ status: 900, data: response });
}
}).catch((error: any) => {
reject({ status:error.status, data:error.error });
});
});
}
}

View File

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

View File

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

View File

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