[DEV] update the linter

This commit is contained in:
Edouard DUPIN 2022-04-01 01:41:06 +02:00
parent ef1ee8dfae
commit 89cd0263c4
74 changed files with 8249 additions and 4120 deletions

View File

@ -9,7 +9,7 @@ services:
- ./config.env - ./config.env
volumes: volumes:
- /workspace/data/karideo/db:/var/lib/mysql - /workspace/data/karideo/db:/var/lib/mysql
mem_limit: 400m mem_limit: 600m
karideo_adminer_service: karideo_adminer_service:
image: adminer:latest image: adminer:latest

4
front/.eslintignore Normal file
View File

@ -0,0 +1,4 @@
node_modules/*
build/*
out/*
dist/*

225
front/.eslintrc.js Normal file
View File

@ -0,0 +1,225 @@
var OFF = 0, WARN = 1, ERROR = 2;
module.exports = {
'env': {
'browser': true,
'es2021': true,
},
'extends': [
'eslint:recommended',
],
'parser': '@typescript-eslint/parser',
'parserOptions': {
'ecmaVersion': 'latest',
'sourceType': 'module',
},
'plugins': [
'@typescript-eslint',
],
"rules": {
// Possible Errors (overrides from recommended set)
"no-extra-parens": ERROR,
"no-unexpected-multiline": ERROR,
// All JSDoc comments must be valid
"valid-jsdoc": [ OFF, {
"requireReturn": false,
"requireReturnDescription": false,
"requireParamDescription": true,
"prefer": {
"return": "returns"
}
}],
// Best Practices
// Allowed a getter without setter, but all setters require getters
"accessor-pairs": [ OFF, {
"getWithoutSet": false,
"setWithoutGet": true
}],
"block-scoped-var": WARN,
"consistent-return": OFF,
"curly": ERROR,
"default-case": WARN,
// the dot goes with the property when doing multiline
"dot-location": [ WARN, "property" ],
"dot-notation": WARN,
"eqeqeq": [ ERROR, "smart" ],
"guard-for-in": WARN,
"no-alert": ERROR,
"no-caller": ERROR,
"no-case-declarations": WARN,
"no-div-regex": WARN,
"no-else-return": WARN,
"no-empty-pattern": WARN,
"no-eq-null": ERROR,
"no-eval": ERROR,
"no-extend-native": ERROR,
"no-extra-bind": WARN,
"no-floating-decimal": WARN,
"no-implicit-coercion": [ WARN, {
"boolean": true,
"number": true,
"string": true
}],
"no-implied-eval": ERROR,
"no-invalid-this": ERROR,
"no-iterator": ERROR,
"no-labels": WARN,
"no-lone-blocks": WARN,
"no-loop-func": ERROR,
"no-magic-numbers": OFF,
"no-multi-spaces": ERROR,
"no-multi-str": WARN,
"no-native-reassign": ERROR,
"no-new-func": ERROR,
"no-new-wrappers": ERROR,
"no-new": ERROR,
"no-octal-escape": ERROR,
"no-param-reassign": ERROR,
"no-process-env": WARN,
"no-proto": ERROR,
"no-redeclare": ERROR,
"no-return-assign": ERROR,
"no-script-url": ERROR,
"no-self-compare": ERROR,
"no-throw-literal": ERROR,
"no-unused-expressions": ERROR,
"no-useless-call": ERROR,
"no-useless-concat": ERROR,
"no-void": WARN,
// Produce warnings when something is commented as TODO or FIXME
"no-warning-comments": [ WARN, {
"terms": [ "TODO", "FIXME" ],
"location": "start"
}],
"no-with": WARN,
"radix": WARN,
"vars-on-top": ERROR,
// Enforces the style of wrapped functions
"wrap-iife": [ ERROR, "outside" ],
"yoda": ERROR,
// Strict Mode - for ES6, never use strict.
"strict": [ ERROR, "never" ],
// Variables
"init-declarations": [ OFF, "always" ],
"no-catch-shadow": WARN,
"no-delete-var": ERROR,
"no-label-var": ERROR,
"no-shadow-restricted-names": ERROR,
"no-shadow": WARN,
// We require all vars to be initialized (see init-declarations)
// If we NEED a var to be initialized to undefined, it needs to be explicit
"no-undef-init": OFF,
"no-undef": ERROR,
"no-undefined": OFF,
"no-unused-vars": OFF,
// Disallow hoisting - let & const don't allow hoisting anyhow
"no-use-before-define": ERROR,
// Node.js and CommonJS
"callback-return": [ WARN, [ "callback", "next" ]],
"global-require": ERROR,
"handle-callback-err": WARN,
"no-mixed-requires": WARN,
"no-new-require": ERROR,
// Use path.concat instead
"no-path-concat": ERROR,
"no-process-exit": ERROR,
"no-restricted-modules": OFF,
"no-sync": WARN,
// ECMAScript 6 support
"arrow-body-style": [ ERROR, "always" ],
"arrow-parens": [ ERROR, "always" ],
"arrow-spacing": [ ERROR, { "before": true, "after": true }],
"constructor-super": ERROR,
"generator-star-spacing": [ ERROR, "before" ],
"no-confusing-arrow": ERROR,
"no-class-assign": ERROR,
"no-const-assign": ERROR,
"no-dupe-class-members": ERROR,
"no-this-before-super": ERROR,
"no-var": WARN,
"object-shorthand": [ WARN, "never" ],
"prefer-arrow-callback": WARN,
"prefer-spread": WARN,
"prefer-template": WARN,
"require-yield": ERROR,
// Stylistic - everything here is a warning because of style.
"array-bracket-spacing": [ WARN, "always" ],
"block-spacing": [ WARN, "always" ],
"brace-style": [ WARN, "1tbs", { "allowSingleLine": false } ],
"camelcase": WARN,
"comma-spacing": [ WARN, { "before": false, "after": true } ],
"comma-style": [ WARN, "last" ],
"computed-property-spacing": [ WARN, "never" ],
"consistent-this": [ WARN, "self" ],
"eol-last": WARN,
"func-names": WARN,
"func-style": [ WARN, "declaration" ],
"id-length": [ WARN, { "min": 2, "max": 32 } ],
"indent": [ WARN, 'tab' ],
"jsx-quotes": [ WARN, "prefer-double" ],
"linebreak-style": [ WARN, "unix" ],
"lines-around-comment": [ OFF, { "beforeBlockComment": true } ],
"max-depth": [ WARN, 8 ],
"max-len": [ WARN, 182 ],
"max-nested-callbacks": [ WARN, 8 ],
"max-params": [ WARN, 10 ],
"new-cap": OFF,
"new-parens": WARN,
"no-array-constructor": WARN,
"no-bitwise": OFF,
"no-continue": OFF,
"no-inline-comments": OFF,
"no-lonely-if": OFF,
"no-mixed-spaces-and-tabs": OFF,
"no-multiple-empty-lines": WARN,
"no-negated-condition": OFF,
"no-nested-ternary": WARN,
"no-new-object": WARN,
"no-plusplus": OFF,
"no-spaced-func": WARN,
"no-ternary": OFF,
"no-trailing-spaces": WARN,
"no-underscore-dangle": WARN,
"no-unneeded-ternary": WARN,
"object-curly-spacing": [ WARN, "always" ],
"one-var": OFF,
"operator-assignment": [ WARN, "never" ],
"operator-linebreak": [ WARN, "after" ],
"padded-blocks": [ WARN, "never" ],
"quote-props": [ WARN, "consistent-as-needed" ],
"quotes": [ WARN, "single" ],
"require-jsdoc": [ OFF, {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": false
}
}],
"semi-spacing": [ WARN, { "before": false, "after": true }],
"semi": [ ERROR, "always" ],
"sort-vars": OFF,
"keyword-spacing": [WARN, {
"overrides": {
"if": { "after": false },
"for": { "after": false },
"while": { "after": false },
"static": { "after": false },
"as": { "after": false }
}
}],
"space-before-blocks": [ WARN, "always" ],
"space-before-function-paren": [ WARN, "never" ],
"space-in-parens": [ WARN, "never" ],
"space-infix-ops": [ WARN, { "int32Hint": true } ],
"space-unary-ops": ERROR,
"spaced-comment": [ WARN, "always" ],
"wrap-regex": WARN,
},
};

View File

@ -68,6 +68,17 @@
} }
}, },
"lint" : { "lint" : {
"builder" : "@angular-eslint/builder:lint",
"options" : {
"fix": true,
"eslintConfig": ".eslintrc.js",
"lintFilePatterns": [
"src/**/*.spec.ts",
"src/**/*.ts"
]
}
},
"TTTTTTlint" : {
"builder" : "@angular-devkit/build-angular:tslint", "builder" : "@angular-devkit/build-angular:tslint",
"options" : { "options" : {
"tsConfig" : [ "src/tsconfig.app.json", "src/tsconfig.spec.json" ], "tsConfig" : [ "src/tsconfig.app.json", "src/tsconfig.spec.json" ],
@ -96,78 +107,6 @@
} }
} }
} }
},
"__design__" : {
"root" : "",
"sourceRoot" : ".design",
"projectType" : "application",
"architect" : {
"build" : {
"builder" : "@angular-devkit/build-angular:browser",
"options" : {
"outputPath" : "dist",
"index" : ".design/index.html",
"main" : ".design/main.ts",
"tsConfig" : ".design/tsconfig.app.json",
"polyfills" : ".design/polyfills.ts",
"assets" : [ ".design/assets", ".design/favicon.ico" ],
"styles" : [ ".design/styles.less", ".design/generic_page.less", ".design/theme.color.blue.less", ".design/theme.checkbox.less", ".design/theme.modal.less" ],
"scripts" : [ ]
},
"configurations" : {
"production" : {
"optimization" : true,
"outputHashing" : "all",
"sourceMap" : false,
"namedChunks" : false,
"aot" : true,
"extractLicenses" : true,
"vendorChunk" : false,
"buildOptimizer" : true,
"fileReplacements" : [ {
"replace" : ".design/environments/environment.ts",
"with" : ".design/environments/environment.prod.ts"
} ]
}
}
},
"serve" : {
"builder" : "@angular-devkit/build-angular:dev-server",
"options" : {
"browserTarget" : "__design__:build"
},
"configurations" : {
"production" : {
"browserTarget" : "__design__:build:production"
}
}
},
"extract-i18n" : {
"builder" : "@angular-devkit/build-angular:extract-i18n",
"options" : {
"browserTarget" : "__design__:build"
}
},
"test" : {
"builder" : "@angular-devkit/build-angular:karma",
"options" : {
"main" : ".design/test.ts",
"karmaConfig" : "./karma.conf.js",
"polyfills" : ".design/polyfills.ts",
"tsConfig" : ".design/tsconfig.spec.json",
"scripts" : [ ],
"styles" : [ ".design/styles.less", ".design/generic_page.less", ".design/theme.color.blue.less", ".design/theme.checkbox.less", ".design/theme.modal.less" ],
"assets" : [ ".design/assets", ".design/favicon.ico" ]
}
},
"lint" : {
"builder" : "@angular-devkit/build-angular:tslint",
"options" : {
"tsConfig" : [ ".design/tsconfig.app.json", ".design/tsconfig.spec.json" ],
"exclude" : [ "**/node_modules/**" ]
}
}
}
} }
}, },
"schematics" : { "schematics" : {

4137
front/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -32,13 +32,22 @@
}, },
"devDependencies": { "devDependencies": {
"@angular-devkit/build-angular": "^13.2.5", "@angular-devkit/build-angular": "^13.2.5",
"@angular-eslint/builder": "13.1.0",
"@angular-eslint/eslint-plugin": "13.1.0",
"@angular-eslint/eslint-plugin-template": "13.1.0",
"@angular-eslint/schematics": "13.1.0",
"@angular-eslint/template-parser": "13.1.0",
"@angular/cli": "^13.2.5", "@angular/cli": "^13.2.5",
"@angular/compiler-cli": "^13.2.5", "@angular/compiler-cli": "^13.2.5",
"@angular/language-service": "^13.2.5", "@angular/language-service": "^13.2.5",
"@types/jasmine": "^3.10.3", "@types/jasmine": "^3.10.3",
"@types/jasminewd2": "^2.0.10", "@types/jasminewd2": "^2.0.10",
"@types/node": "^17.0.21", "@types/node": "^17.0.21",
"@typescript-eslint/eslint-plugin": "^5.17.0",
"@typescript-eslint/parser": "^5.17.0",
"codelyzer": "^6.0.2", "codelyzer": "^6.0.2",
"eslint": "^8.12.0",
"eslint-config-google": "^0.14.0",
"jasmine-core": "^4.0.1", "jasmine-core": "^4.0.1",
"jasmine-spec-reporter": "^7.0.0", "jasmine-spec-reporter": "^7.0.0",
"karma": "^6.3.17", "karma": "^6.3.17",

View File

@ -23,3 +23,12 @@ plus facilement:
npm install @angular-devkit/build-angular@0.901.9 npm install @angular-devkit/build-angular@0.901.9
npm start npm start
Apply linter:
==============
```
npx ng lint
```

View File

@ -1,16 +1,15 @@
import { trigger, state, animate, transition, style } from '@angular/animations'; import { trigger, animate, transition, style } from '@angular/animations';
export const fadeInAnimation = export const fadeInAnimation =
trigger('fadeInAnimation', [ trigger('fadeInAnimation', [
// route 'enter' transition // route 'enter' transition
transition(':enter', [ transition(':enter', [
// styles at start of transition // styles at start of transition
style({ opacity: 0 }), style({ opacity: 0 }),
// animation and styles at end of transition // animation and styles at end of transition
animate('.5s', style({ opacity: 1 })) animate('.5s', style({ opacity: 1 }))
]), ]),
]); ]);

View File

@ -3,49 +3,49 @@ import { trigger, state, animate, transition, style } from '@angular/animations'
export const slideInOutAnimation = export const slideInOutAnimation =
trigger('slideInOutAnimation', [ trigger('slideInOutAnimation', [
// end state styles for route container (host) // end state styles for route container (host)
state('*', style({ state('*', style({
// the view covers the whole screen with a semi tranparent background // the view covers the whole screen with a semi tranparent background
position: 'fixed', position: 'fixed',
top: 0, top: 0,
left: 0, left: 0,
right: 0, right: 0,
bottom: 0, bottom: 0,
backgroundColor: 'rgba(0, 0, 0, 0.8)' backgroundColor: 'rgba(0, 0, 0, 0.8)'
})), })),
// route 'enter' transition // route 'enter' transition
transition(':enter', [ transition(':enter', [
// styles at start of transition // styles at start of transition
style({ style({
// start with the content positioned off the right of the screen, // start with the content positioned off the right of the screen,
// -400% is required instead of -100% because the negative position adds to the width of the element // -400% is required instead of -100% because the negative position adds to the width of the element
right: '-400%', right: '-400%',
// start with background opacity set to 0 (invisible) // start with background opacity set to 0 (invisible)
backgroundColor: 'rgba(0, 0, 0, 0)' backgroundColor: 'rgba(0, 0, 0, 0)'
}), }),
// animation and styles at end of transition // animation and styles at end of transition
animate('.5s ease-in-out', style({ animate('.5s ease-in-out', style({
// transition the right position to 0 which slides the content into view // transition the right position to 0 which slides the content into view
right: 0, right: 0,
// transition the background opacity to 0.8 to fade it in // transition the background opacity to 0.8 to fade it in
backgroundColor: 'rgba(0, 0, 0, 0.8)' backgroundColor: 'rgba(0, 0, 0, 0.8)'
})) }))
]), ]),
// route 'leave' transition // route 'leave' transition
transition(':leave', [ transition(':leave', [
// animation and styles at end of transition // animation and styles at end of transition
animate('.5s ease-in-out', style({ animate('.5s ease-in-out', style({
// transition the right position to -400% which slides the content out of view // transition the right position to -400% which slides the content out of view
right: '-400%', right: '-400%',
// transition the background opacity to 0 to fade it out // transition the background opacity to 0 to fade it out
backgroundColor: 'rgba(0, 0, 0, 0)' backgroundColor: 'rgba(0, 0, 0, 0)'
})) }))
]) ])
]); ]);

View File

@ -5,7 +5,6 @@
*/ */
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'; // CLI imports router import { Routes, RouterModule } from '@angular/router'; // CLI imports router
import { ModuleWithProviders } from '@angular/core';
import { HomeScene } from './scene/home/home'; import { HomeScene } from './scene/home/home';
import { TypeScene } from './scene/type/type'; import { TypeScene } from './scene/type/type';
@ -20,33 +19,35 @@ import { UploadScene } from './scene/upload/upload';
import { VideoEditScene } from './scene/video-edit/video-edit'; import { VideoEditScene } from './scene/video-edit/video-edit';
import { SeriesEditScene } from './scene/series-edit/series-edit'; import { SeriesEditScene } from './scene/series-edit/series-edit';
import { SeasonEditScene } from './scene/season-edit/season-edit'; import { SeasonEditScene } from './scene/season-edit/season-edit';
//import { HelpComponent } from './help/help.component'; // import { HelpComponent } from './help/help.component';
// see https://angular.io/guide/router // see https://angular.io/guide/router
const routes: Routes = [ const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full'}, { path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: 'home', component: HomeScene }, { path: 'home', component: HomeScene },
{ path: 'upload', component: UploadScene }, { path: 'upload', component: UploadScene },
{ path: 'type/:universe_id/:type_id/:series_id/:season_id/:video_id', component: TypeScene }, { path: 'type/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: TypeScene },
{ path: 'universe/:universe_id/:type_id/:series_id/:season_id/:video_id', component: UniverseScene }, { path: 'universe/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: UniverseScene },
{ path: 'series/:universe_id/:type_id/:series_id/:season_id/:video_id', component: SeriesScene }, { path: 'series/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: SeriesScene },
{ path: 'series-edit/:universe_id/:type_id/:series_id/:season_id/:video_id', component: SeriesEditScene }, { path: 'series-edit/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: SeriesEditScene },
{ path: 'season/:universe_id/:type_id/:series_id/:season_id/:video_id', component: SeasonScene }, { path: 'season/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: SeasonScene },
{ path: 'season-edit/:universe_id/:type_id/:series_id/:season_id/:video_id', component: SeasonEditScene }, { path: 'season-edit/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: SeasonEditScene },
{ path: 'video/:universe_id/:type_id/:series_id/:season_id/:video_id', component: VideoScene }, { path: 'video/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: VideoScene },
{ path: 'video-edit/:universe_id/:type_id/:series_id/:season_id/:video_id', component: VideoEditScene }, { path: 'video-edit/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: VideoEditScene },
{ path: 'login', component: LoginScene }, { path: 'login', component: LoginScene },
{ path: 'signup', component: SignUpScene }, { path: 'signup', component: SignUpScene },
{ path: 'settings', component: SettingsScene }, { path: 'settings', component: SettingsScene },
/*{ path: 'help', component: HelpComponent }*/
/* { path: 'help', component: HelpComponent }*/
]; ];
/* /*
@NgModule({ @NgModule({
imports: [ imports: [
@ -61,10 +62,9 @@ export class AppRoutingModule {}
*/ */
@NgModule({ @NgModule({
imports: [RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy' })], imports: [ RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy' }) ],
exports: [RouterModule] exports: [ RouterModule ]
}) })
export class AppRoutingModule { } export class AppRoutingModule { }
//export const routing: ModuleWithProviders = RouterModule.forRoot(routes); // export const routing: ModuleWithProviders = RouterModule.forRoot(routes);

View File

@ -4,7 +4,7 @@
* @license PROPRIETARY (see license file) * @license PROPRIETARY (see license file)
*/ */
import { Component, OnInit} from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { UserService } from './service/user'; import { UserService } from './service/user';
import { SessionService } from './service/session'; import { SessionService } from './service/session';
import { CookiesService } from './service/cookies'; import { CookiesService } from './service/cookies';
@ -14,7 +14,7 @@ import { CookiesService } from './service/cookies';
templateUrl: './app.component.html', templateUrl: './app.component.html',
styleUrls: [ styleUrls: [
'./app.component.less', './app.component.less',
] ]
}) })
export class AppComponent implements OnInit { export class AppComponent implements OnInit {
title = 'Karideo'; title = 'Karideo';
@ -25,30 +25,28 @@ export class AppComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
let login = this.cookiesService.get("yota-login"); let login = this.cookiesService.get('yota-login');
let password = this.cookiesService.get("yota-password"); let password = this.cookiesService.get('yota-password');
if ( login != "" if(login !== '' &&
&& password != "" password !== '' &&
&& password.length > 40) { password.length > 40) {
console.log("Get previous connection ... " + login + ":xxxxxx"); console.log(`Get previous connection ... ${ login }:xxxxxx`);
let self = this; let self = this;
this.userService.loginSha(login, password) this.userService.loginSha(login, password)
.then(function(response) { .then((response: any) => {
console.log("auto log ==> OK"); console.log('auto log ==> OK');
self.sessionService.create(response['session'], self.sessionService.create(response.session,
response['login'], response.login,
response['email'], response.email,
response['admin'], response.admin,
response['avatar']); response.avatar);
//self.router.navigate(['home']); // self.router.navigate(['home']);
}).catch(function(response) { }).catch((response: any) => {
console.log("auto log ==> Error"); console.log('auto log ==> Error');
self.cookiesService.remove("yota-login"); self.cookiesService.remove('yota-login');
self.cookiesService.remove("yota-password"); self.cookiesService.remove('yota-password');
}); });
} }
} }
} }

View File

@ -92,7 +92,7 @@ import { AppComponent } from './app.component';
SeasonEditScene, SeasonEditScene,
SeriesEditScene, SeriesEditScene,
UploadScene UploadScene
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
RouterModule, RouterModule,
@ -101,7 +101,7 @@ import { AppComponent } from './app.component';
HttpClientModule, HttpClientModule,
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,
], ],
providers: [ providers: [
PopInService, PopInService,
HttpWrapperService, HttpWrapperService,
@ -118,7 +118,7 @@ import { AppComponent } from './app.component';
SeasonService, SeasonService,
VideoService, VideoService,
ArianeService ArianeService
], ],
exports: [ exports: [
AppComponent, AppComponent,
TopMenuComponent, TopMenuComponent,
@ -136,7 +136,7 @@ import { AppComponent } from './app.component';
], ],
bootstrap: [ bootstrap: [
AppComponent AppComponent
], ],
schemas: [ schemas: [
CUSTOM_ELEMENTS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA,
NO_ERRORS_SCHEMA NO_ERRORS_SCHEMA

View File

@ -5,62 +5,57 @@
*/ */
import { Injectable, Component, OnInit, Input } from '@angular/core'; import { Injectable, Component, OnInit, Input } from '@angular/core';
//import { AppRoutingModule } from "../app-routing.module";
import { Router } from "@angular/router";
import { ActivatedRoute, Params } from '@angular/router';
import { SeasonService } from '../../service/season'; import { SeasonService } from '../../service/season';
@Component({ @Component({
selector: 'app-element-season', selector: 'app-element-season',
templateUrl: './element-season.html', templateUrl: './element-season.html',
styleUrls: ['./element-season.less'] styleUrls: [ './element-season.less' ]
}) })
@Injectable() @Injectable()
export class ElementSeasonComponent implements OnInit { export class ElementSeasonComponent implements OnInit {
// input parameters // input parameters
@Input() id_season:number = -1; @Input() idSeason:number = -1;
error:string = ""; error:string = '';
numberSeason:number = -1; numberSeason:number = -1;
count:number = 0; count:number = 0;
cover:string = ""; cover:string = '';
covers:Array<string> = []; covers:Array<string> = [];
description:string = ""; description:string = '';
constructor(private router: Router, constructor(private seasonService: SeasonService) {
private seasonService: SeasonService) {
} }
ngOnInit() { ngOnInit() {
let self = this; let self = this;
console.log("get season properties id: " + this.id_season); console.log(`get season properties id: ${ this.idSeason}`);
this.seasonService.get(this.id_season) this.seasonService.get(this.idSeason)
.then(function(response) { .then((response) => {
self.error = ""; self.error = '';
self.numberSeason = response.name; self.numberSeason = response.name;
self.description = response.description; self.description = response.description;
if (response.covers == undefined || response.covers == null || response.covers.length == 0) { if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
self.cover = null; self.cover = null;
//self.covers = []; // self.covers = [];
} else { } else {
self.cover = self.seasonService.getCoverThumbnailUrl(response.covers[0]); self.cover = self.seasonService.getCoverThumbnailUrl(response.covers[0]);
for (let iii=0; iii<response.covers.length; iii++) { for(let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.seasonService.getCoverThumbnailUrl(response.covers[iii])); self.covers.push(self.seasonService.getCoverThumbnailUrl(response.covers[iii]));
} }
} }
}).catch(function(response) { }).catch((response) => {
self.error = "Can not get the data"; self.error = 'Can not get the data';
self.numberSeason = -1 self.numberSeason = -1;
self.cover = null; self.cover = null;
self.covers = []; self.covers = [];
self.description = ""; self.description = '';
}); });
this.seasonService.countVideo(this.id_season) this.seasonService.countVideo(this.idSeason)
.then(function(response) { .then((response) => {
self.count = response; self.count = response;
}).catch(function(response) { }).catch((response) => {
self.count = null; self.count = null;
}); });
} }

View File

@ -5,64 +5,59 @@
*/ */
import { Injectable, Component, OnInit, Input } from '@angular/core'; import { Injectable, Component, OnInit, Input } from '@angular/core';
//import { AppRoutingModule } from "../app-routing.module";
import { Router } from "@angular/router";
import { ActivatedRoute, Params } from '@angular/router';
import { SeriesService } from '../../service/series'; import { SeriesService } from '../../service/series';
@Component({ @Component({
selector: 'app-element-series', selector: 'app-element-series',
templateUrl: './element-series.html', templateUrl: './element-series.html',
styleUrls: ['./element-series.less'] styleUrls: [ './element-series.less' ]
}) })
@Injectable() @Injectable()
export class ElementSeriesComponent implements OnInit { export class ElementSeriesComponent implements OnInit {
// input parameters // input parameters
@Input() id_series:number = -1; @Input() idSeries:number = -1;
@Input() id_type:number = -1; @Input() idType:number = -1;
error:string = ""; error:string = '';
name:string = "plouf"; name:string = 'plouf';
description:string = ""; description:string = '';
countvideo:number = null; countvideo:number = null;
imageSource:string = null; imageSource:string = null;
cover:string = ""; cover:string = '';
covers:Array<string> = []; covers:Array<string> = [];
constructor(private router: Router, constructor(private seriesService: SeriesService) {
private seriesService: SeriesService) {
} }
ngOnInit() { ngOnInit() {
this.name = "ll " + this.id_type + "+" + this.id_series this.name = `ll ${ this.idType }+${ this.idSeries}`;
let self = this; let self = this;
console.log("get parameter id: " + this.id_type); console.log(`get parameter id: ${ this.idType}`);
this.seriesService.get(this.id_series) this.seriesService.get(this.idSeries)
.then(function(response) { .then((response) => {
self.error = ""; self.error = '';
self.name = response.name self.name = response.name;
if (response.covers == undefined || response.covers == null || response.covers.length == 0) { if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
self.cover = null; self.cover = null;
//self.covers = []; // self.covers = [];
} else { } else {
self.cover = self.seriesService.getCoverThumbnailUrl(response.covers[0]); self.cover = self.seriesService.getCoverThumbnailUrl(response.covers[0]);
for (let iii=0; iii<response.covers.length; iii++) { for(let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.seriesService.getCoverThumbnailUrl(response.covers[iii])); self.covers.push(self.seriesService.getCoverThumbnailUrl(response.covers[iii]));
} }
} }
}).catch(function(response) { }).catch((response) => {
self.error = "Can not get the data"; self.error = 'Can not get the data';
self.name = "" self.name = '';
self.cover = null; self.cover = null;
self.covers = []; self.covers = [];
}); });
this.seriesService.countVideo(this.id_series) this.seriesService.countVideo(this.idSeries)
.then(function(response) { .then((response) => {
self.countvideo = response; self.countvideo = response;
}).catch(function(response) { }).catch((response) => {
self.countvideo = 0; self.countvideo = 0;
}); });
} }

View File

@ -5,100 +5,96 @@
*/ */
import { Injectable, Component, OnInit, Input } from '@angular/core'; import { Injectable, Component, OnInit, Input } from '@angular/core';
//import { AppRoutingModule } from "../app-routing.module";
import { Router } from "@angular/router";
import { ActivatedRoute, Params } from '@angular/router';
import { TypeService } from '../../service/type'; import { TypeService } from '../../service/type';
@Component({ @Component({
selector: 'app-element-type', selector: 'app-element-type',
templateUrl: './element-type.html', templateUrl: './element-type.html',
styleUrls: ['./element-type.less'] styleUrls: [ './element-type.less' ]
}) })
@Injectable() @Injectable()
export class ElementTypeComponent implements OnInit { export class ElementTypeComponent implements OnInit {
// input parameters // input parameters
@Input() id_type:number = -1; @Input() idType:number = -1;
imageSource:string = ""; imageSource:string = '';
name:string = ""; name:string = '';
error:string = ""; error:string = '';
description:string = ""; description:string = '';
countvideo:number = null; countvideo:number = null;
countserie:number = null; countserie:number = null;
cover:string = ""; cover:string = '';
covers:Array<string> = []; covers:Array<string> = [];
constructor(private router: Router, constructor(private typeService: TypeService) {
private typeService: TypeService) {
} }
ngOnInit() { ngOnInit() {
this.name = "ll " + this.id_type this.name = `ll ${ this.idType}`;
let self = this; let self = this;
console.log("get parameter id: " + this.id_type); console.log(`get parameter id: ${ this.idType}`);
this.typeService.get(this.id_type) this.typeService.get(this.idType)
.then(function(response) { .then((response) => {
self.error = ""; self.error = '';
self.name = response.name self.name = response.name;
self.description = response.description self.description = response.description;
if (response.covers == undefined || response.covers == null || response.covers.length == 0) { if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
self.cover = null; self.cover = null;
//self.covers = []; // self.covers = [];
} else { } else {
self.cover = self.typeService.getCoverThumbnailUrl(response.covers[0]); self.cover = self.typeService.getCoverThumbnailUrl(response.covers[0]);
for (let iii=0; iii<response.covers.length; iii++) { for(let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.typeService.getCoverThumbnailUrl(response.covers[iii])); self.covers.push(self.typeService.getCoverThumbnailUrl(response.covers[iii]));
} }
} }
console.log("plouf : '" + self.name + "'");
switch (self.name) { switch (self.name) {
case "Documentary": case 'Documentary':
self.imageSource = "assets/images/type_documentary.svg"; self.imageSource = 'assets/images/type_documentary.svg';
break; break;
case "Movie": case 'Movie':
self.imageSource = "assets/images/type_film.svg"; self.imageSource = 'assets/images/type_film.svg';
break; break;
case "Annimation": case 'Annimation':
self.imageSource = "assets/images/type_annimation.svg"; self.imageSource = 'assets/images/type_annimation.svg';
break; break;
case "Short Films": case 'Short Films':
self.imageSource = "assets/images/type_film-short.svg"; self.imageSource = 'assets/images/type_film-short.svg';
break; break;
case "tv show": case 'tv show':
self.imageSource = "assets/images/type_tv-show.svg"; self.imageSource = 'assets/images/type_tv-show.svg';
break; break;
case "Anniation tv show": case 'Anniation tv show':
self.imageSource = "assets/images/type_tv-show-annimation.svg"; self.imageSource = 'assets/images/type_tv-show-annimation.svg';
break; break;
case "Theater": case 'Theater':
self.imageSource = "assets/images/type_theater.svg"; self.imageSource = 'assets/images/type_theater.svg';
break; break;
case "One man show": case 'One man show':
self.imageSource = "assets/images/type_one-man-show.svg"; self.imageSource = 'assets/images/type_one-man-show.svg';
break; break;
case "Concert": case 'Concert':
self.imageSource = "assets/images/type_concert.svg"; self.imageSource = 'assets/images/type_concert.svg';
break; break;
case "Opera": case 'Opera':
self.imageSource = "assets/images/type_opera.svg"; self.imageSource = 'assets/images/type_opera.svg';
break; break;
default:
break;
} }
}).catch(function(response) { }).catch((response) => {
self.error = "Can not get the data"; self.error = 'Can not get the data';
self.name = ""; self.name = '';
self.description = ""; self.description = '';
self.imageSource = ""; self.imageSource = '';
self.cover = null; self.cover = null;
self.covers = []; self.covers = [];
}); });
this.typeService.countVideo(this.id_type) this.typeService.countVideo(this.idType)
.then(function(response) { .then((response) => {
self.countvideo = response; self.countvideo = response;
}).catch(function(response) { }).catch((response) => {
self.countvideo = 0; self.countvideo = 0;
}); });
} }

View File

@ -8,7 +8,7 @@
</div> </div>
</div> </div>
<div class="title-small"> <div class="title-small">
{{episode_display}} {{name}} {{episodeDisplay}} {{name}}
</div> </div>
<!-- <!--
<div class="description-small" *ngIf="description"> <div class="description-small" *ngIf="description">

View File

@ -5,105 +5,100 @@
*/ */
import { Injectable, Component, OnInit, Input } from '@angular/core'; import { Injectable, Component, OnInit, Input } from '@angular/core';
//import { AppRoutingModule } from "../app-routing.module";
import { Router } from "@angular/router";
import { ActivatedRoute, Params } from '@angular/router';
import { VideoService } from '../../service/video'; import { VideoService } from '../../service/video';
import { HttpWrapperService } from '../../service/http-wrapper'; import { HttpWrapperService } from '../../service/http-wrapper';
@Component({ @Component({
selector: 'app-element-video', selector: 'app-element-video',
templateUrl: './element-video.html', templateUrl: './element-video.html',
styleUrls: ['./element-video.less'] styleUrls: [ './element-video.less' ]
}) })
@Injectable() @Injectable()
export class ElementVideoComponent implements OnInit { export class ElementVideoComponent implements OnInit {
// input parameters // input parameters
@Input() id_video:number = -1; @Input() idVideo:number = -1;
@Input() display_video:boolean = false; @Input() displayVideo:boolean = false;
error:string = ""; error:string = '';
name:string = ""; name:string = '';
description:string = ""; description:string = '';
episode:number = undefined; episode:number = undefined;
series_id:number = undefined; seriesId:number = undefined;
season_id:number = undefined; seasonId:number = undefined;
data_id:number = -1; dataId:number = -1;
time:number = undefined; time:number = undefined;
type_id:number = undefined; typeId:number = undefined;
generated_name:string = ""; generatedName:string = '';
video_source:string = ""; videoSource:string = '';
video_enable:boolean = false; videoEnable:boolean = false;
imageSource:string = null; imageSource:string = null;
episode_display:string = ""; episodeDisplay:string = '';
cover:string = ""; cover:string = '';
covers:Array<string> = []; covers:string[] = [];
constructor(private router: Router, constructor(private videoService: VideoService,
private videoService: VideoService,
private httpService: HttpWrapperService) { private httpService: HttpWrapperService) {
} }
OnDestroy() { OnDestroy() {
this.video_source = ""; this.videoSource = '';
this.video_enable = false; this.videoEnable = false;
} }
ngOnInit() { ngOnInit() {
this.name = "ll " + this.id_video this.name = `ll ${ this.idVideo}`;
let self = this; let self = this;
//console.log("get video id: " + this.id_video); // console.log("get video id: " + this.idVideo);
this.videoService.get(this.id_video) this.videoService.get(this.idVideo)
.then(function(response) { .then((response) => {
//console.log("get response of video : " + JSON.stringify(response, null, 2)); // console.log("get response of video : " + JSON.stringify(response, null, 2));
self.error = ""; self.error = '';
self.name = response.name; self.name = response.name;
self.description = response.description; self.description = response.description;
self.episode = response.episode; self.episode = response.episode;
if (response.episode === undefined || response.episode === null || response.episode == '') { if(response.episode === undefined || response.episode === null || response.episode === '') {
self.episode_display = ""; self.episodeDisplay = '';
} else { } else {
self.episode_display = response.episode + " - "; self.episodeDisplay = `${response.episode } - `;
} }
self.series_id = response.series_id; self.seriesId = response.seriesId;
self.season_id = response.season_id; self.seasonId = response.seasonId;
self.data_id = response.data_id; self.dataId = response.dataId;
self.time = response.time; self.time = response.time;
self.generated_name = response.generated_name; self.generatedName = response.generatedName;
if (self.data_id != -1) { if(self.dataId !== -1) {
self.video_source = self.httpService.createRESTCall("data/" + self.data_id); self.videoSource = self.httpService.createRESTCall(`data/${ self.dataId}`);
self.video_enable = true; self.videoEnable = true;
} else { } else {
self.video_source = ""; self.videoSource = '';
self.video_enable = false; self.videoEnable = false;
} }
if (response.covers == undefined || response.covers == null || response.covers.length == 0) { if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
self.cover = null; self.cover = null;
//self.covers = []; // self.covers = [];
} else { } else {
self.cover = self.videoService.getCoverThumbnailUrl(response.covers[0]); self.cover = self.videoService.getCoverThumbnailUrl(response.covers[0]);
for (let iii=0; iii<response.covers.length; iii++) { for(let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.videoService.getCoverThumbnailUrl(response.covers[iii])); self.covers.push(self.videoService.getCoverThumbnailUrl(response.covers[iii]));
} }
} }
//console.log("101010 " + self.video_enable + " " + self.video_source); // console.log("101010 " + self.videoEnable + " " + self.videoSource);
//console.log("set transformed : " + JSON.stringify(self, null, 2)); // console.log("set transformed : " + JSON.stringify(self, null, 2));
}).catch(function(response) { }).catch((response) => {
self.error = "Can not get the data"; self.error = 'Can not get the data';
self.name = ""; self.name = '';
self.description = ""; self.description = '';
self.episode = undefined; self.episode = undefined;
self.episode_display = ""; self.episodeDisplay = '';
self.series_id = undefined; self.seriesId = undefined;
self.season_id = undefined; self.seasonId = undefined;
self.data_id = -1; self.dataId = -1;
self.time = undefined; self.time = undefined;
self.generated_name = ""; self.generatedName = '';
self.video_source = ""; self.videoSource = '';
self.video_enable = false; self.videoEnable = false;
self.cover = null; self.cover = null;
self.covers = []; self.covers = [];
}); });

View File

@ -4,22 +4,22 @@
* @license MPL-2 (see license file) * @license MPL-2 (see license file)
*/ */
import { Component, Input, Output, OnInit, OnDestroy, EventEmitter} from '@angular/core'; import { Component, Input, Output, OnInit, OnDestroy, EventEmitter } from '@angular/core';
import { PopInService } from '../../service/popin'; import { PopInService } from '../../service/popin';
@Component({ @Component({
//moduleId: module.id.toString(), // moduleId: module.id.toString(),
selector: 'app-popin', selector: 'app-popin',
templateUrl: './popin.html', templateUrl: './popin.html',
styleUrls: ['./popin.less'] styleUrls: [ './popin.less' ]
}) })
export class PopInComponent implements OnInit, OnDestroy { export class PopInComponent implements OnInit, OnDestroy {
@Input() id: string; @Input() id: string;
@Input() popTitle: string = 'No title'; @Input() popTitle: string = 'No title';
@Input() closeTopRight: any = "false"; @Input() closeTopRight: any = 'false';
@Input() popSize: string = "medium"; @Input() popSize: string = 'medium';
@Output() callback: EventEmitter<any> = new EventEmitter(); @Output() callback: EventEmitter<any> = new EventEmitter();
@Input() closeTitle: any = null; @Input() closeTitle: any = null;
@ -34,48 +34,48 @@ export class PopInComponent implements OnInit, OnDestroy {
} }
ngOnInit(): void { ngOnInit(): void {
// ensure id attribute exists // ensure id attribute exists
if (!this.id) { if(!this.id) {
console.error('popin must have an id'); console.error('popin must have an id');
return; return;
} }
// move element to bottom of page (just before </body>) so it can be displayed above everything else // move element to bottom of page (just before </body>) so it can be displayed above everything else
//this.element.appendTo('body'); // this.element.appendTo('body');
this.popInService.add(this); this.popInService.add(this);
//this.element.hide(); // this.element.hide();
} }
// remove self from popIn service when directive is destroyed // remove self from popIn service when directive is destroyed
ngOnDestroy(): void { ngOnDestroy(): void {
this.popInService.remove(this.id); this.popInService.remove(this.id);
//this.element.remove(); // this.element.remove();
} }
// open popIn // open popIn
open(): void { open(): void {
this.displayPopIn = true; this.displayPopIn = true;
//this.element.show(); // this.element.show();
} }
// close popin // close popin
close(): void { close(): void {
this.displayPopIn = false; this.displayPopIn = false;
//this.element.hide(); // this.element.hide();
} }
onCloseTop(): void { onCloseTop(): void {
this.callback.emit(["close-top"]); this.callback.emit([ 'close-top' ]);
} }
onValidate(): void { onValidate(): void {
this.callback.emit(["validate"]); this.callback.emit([ 'validate' ]);
} }
onClose(): void { onClose(): void {
this.callback.emit(["close"]); this.callback.emit([ 'close' ]);
} }
onOther(): void { onOther(): void {
this.callback.emit(["other"]); this.callback.emit([ 'other' ]);
} }
onSave(): void { onSave(): void {
this.callback.emit(["save"]); this.callback.emit([ 'save' ]);
} }
} }

View File

@ -12,51 +12,51 @@
</button> </button>
<div class="ariane"> <div class="ariane">
<button class="item" <button class="item"
*ngIf="ariane_type_id != null" *ngIf="arianeTypeId != null"
title="Uype" title="Uype"
(click)="onArianeType($event)" (click)="onArianeType($event)"
(auxclick)="onArianeType($event)"> (auxclick)="onArianeType($event)">
<div class="xdesktop"> <div class="xdesktop">
{{ariane_type_name}} {{arianeTypeName}}
</div> </div>
<div class="xmobile"> <div class="xmobile">
T T
</div> </div>
</button> </button>
<div class="item_ariane_separator" *ngIf="ariane_universe_id != null && ariane_type_id != null" >/</div> <div class="item_ariane_separator" *ngIf="arianeUniverseId != null && arianeTypeId != null" >/</div>
<button class="item" <button class="item"
*ngIf="ariane_universe_id != null" *ngIf="arianeUniverseId != null"
title="Universe" title="Universe"
(click)="onArianeUniverse($event)" (click)="onArianeUniverse($event)"
(auxclick)="onArianeUniverse($event)"> (auxclick)="onArianeUniverse($event)">
<div class="xdesktop"> <div class="xdesktop">
{{ariane_universe_name}} {{arianeUniverseName}}
</div> </div>
<div class="xmobile"> <div class="xmobile">
U U
</div> </div>
</button> </button>
<div class="item_ariane_separator" *ngIf="ariane_series_id != null && (ariane_universe_id != null || ariane_type_id != null)" >/</div> <div class="item_ariane_separator" *ngIf="arianeSeriesId != null && (arianeUniverseId != null || arianeTypeId != null)" >/</div>
<button class="item" <button class="item"
*ngIf="ariane_series_id != null" *ngIf="arianeSeriesId != null"
title="Series" title="Series"
(click)="onArianeSeries($event)" (click)="onArianeSeries($event)"
(auxclick)="onArianeSeries($event)"> (auxclick)="onArianeSeries($event)">
<div class="xdesktop"> <div class="xdesktop">
{{ariane_series_name}} {{arianeSeriesName}}
</div> </div>
<div class="xmobile"> <div class="xmobile">
G G
</div> </div>
</button> </button>
<div class="item_ariane_separator" *ngIf="ariane_season_id != null && (ariane_series_id != null || ariane_universe_id != null || ariane_type_id != null)" >/</div> <div class="item_ariane_separator" *ngIf="arianeSeasonId != null && (arianeSeriesId != null || arianeUniverseId != null || arianeTypeId != null)" >/</div>
<button class="item" <button class="item"
*ngIf="ariane_season_id != null" *ngIf="arianeSeasonId != null"
title="Season" title="Season"
(click)="onArianeSeason($event)" (click)="onArianeSeason($event)"
(auxclick)="onArianeSeason($event)"> (auxclick)="onArianeSeason($event)">
<div class="xdesktop"> <div class="xdesktop">
{{ariane_season_name}} {{arianeSeasonName}}
</div> </div>
<div class="xmobile"> <div class="xmobile">
S S
@ -94,7 +94,7 @@
<img class="avatar" src="{{avatar}}"/> <img class="avatar" src="{{avatar}}"/>
</button> </button>
<button class="item" <button class="item"
*ngIf="edit_show == true" *ngIf="editShow == true"
style="float:right; height:56px;" style="float:right; height:56px;"
(click)="onEdit()"> (click)="onEdit()">
<div class="xdesktop"> <div class="xdesktop">
@ -139,32 +139,32 @@
<div class="sub-menu edit-menu color-menu-background"> <div class="sub-menu edit-menu color-menu-background">
<!-- <!--
<button class="item" <button class="item"
*ngIf="ariane_type_id != null" *ngIf="arianeTypeId != null"
(click)="onSubEditType($event)" (click)="onSubEditType($event)"
(auxclick)="onSubEditType($event)"> (auxclick)="onSubEditType($event)">
<b>Edit Type</b> <b>Edit Type</b>
</button> </button>
<button class="item" <button class="item"
*ngIf="ariane_universe_id != null" *ngIf="arianeUniverseId != null"
(click)="onSubEditUniverse($event)" (click)="onSubEditUniverse($event)"
(auxclick)="onSubEditUniverse($event)"> (auxclick)="onSubEditUniverse($event)">
<b>Edit Universe</b> <b>Edit Universe</b>
</button> </button>
--> -->
<button class="item" <button class="item"
*ngIf="ariane_series_id != null" *ngIf="arianeSeriesId != null"
(click)="onSubEditSeries($event)" (click)="onSubEditSeries($event)"
(auxclick)="onSubEditSeries($event)"> (auxclick)="onSubEditSeries($event)">
<b>Edit Series</b> <b>Edit Series</b>
</button> </button>
<button class="item" <button class="item"
*ngIf="ariane_season_id != null" *ngIf="arianeSeasonId != null"
(click)="onSubEditSeason($event)" (click)="onSubEditSeason($event)"
(auxclick)="onSubEditSeason($event)"> (auxclick)="onSubEditSeason($event)">
<b>Edit Season</b> <b>Edit Season</b>
</button> </button>
<button class="item" <button class="item"
*ngIf="ariane_video_id != null" *ngIf="arianeVideoId != null"
(click)="onSubEditVideo($event)" (click)="onSubEditVideo($event)"
(auxclick)="onSubEditVideo($event)"> (auxclick)="onSubEditVideo($event)">
<b>Edit Video</b> <b>Edit Video</b>
@ -175,32 +175,32 @@
<div class="sub-menu edit-menu-mob color-menu-background"> <div class="sub-menu edit-menu-mob color-menu-background">
<!-- <!--
<button class="item" <button class="item"
*ngIf="ariane_type_id != null" *ngIf="arianeTypeId != null"
(click)="onSubEditType($event)" (click)="onSubEditType($event)"
(auxclick)="onSubEditType($event)"> (auxclick)="onSubEditType($event)">
<b>Edit Type</b> <b>Edit Type</b>
</button> </button>
<button class="item" <button class="item"
*ngIf="ariane_universe_id != null" *ngIf="arianeUniverseId != null"
(click)="onSubEditUniverse($event)" (click)="onSubEditUniverse($event)"
(auxclick)="onSubEditUniverse($event)"> (auxclick)="onSubEditUniverse($event)">
<b>Edit Universe</b> <b>Edit Universe</b>
</button> </button>
--> -->
<button class="item" <button class="item"
*ngIf="ariane_series_id != null" *ngIf="arianeSeriesId != null"
(click)="onSubEditSeries($event)" (click)="onSubEditSeries($event)"
(auxclick)="onSubEditSeries($event)"> (auxclick)="onSubEditSeries($event)">
<b>Edit Series</b> <b>Edit Series</b>
</button> </button>
<button class="item" <button class="item"
*ngIf="ariane_season_id != null" *ngIf="arianeSeasonId != null"
(click)="onSubEditSeason($event)" (click)="onSubEditSeason($event)"
(auxclick)="onSubEditSeason($event)"> (auxclick)="onSubEditSeason($event)">
<b>Edit Season</b> <b>Edit Season</b>
</button> </button>
<button class="item" <button class="item"
*ngIf="ariane_video_id != null" *ngIf="arianeVideoId != null"
(click)="onSubEditVideo($event)" (click)="onSubEditVideo($event)"
(auxclick)="onSubEditVideo($event)"> (auxclick)="onSubEditVideo($event)">
<b>Edit Video</b> <b>Edit Video</b>

View File

@ -5,277 +5,203 @@
*/ */
import { Injectable, Component, OnInit } from '@angular/core'; import { Injectable, Component, OnInit } from '@angular/core';
//import { AppRoutingModule } from "../app-routing.module"; // import { AppRoutingModule } from "../app-routing.module";
import { Router } from "@angular/router"; import { Router } from '@angular/router';
import { ActivatedRoute, Params } from '@angular/router';
import { SessionService } from '../../service/session'; import { SessionService } from '../../service/session';
import { ArianeService } from '../../service/ariane'; import { ArianeService } from '../../service/ariane';
@Component({ @Component({
selector: 'app-top-menu', selector: 'app-top-menu',
templateUrl: './top-menu.html', templateUrl: './top-menu.html',
styleUrls: ['./top-menu.less'] styleUrls: [ './top-menu.less' ]
}) })
@Injectable() @Injectable()
export class TopMenuComponent implements OnInit { export class TopMenuComponent implements OnInit {
public login: string = null;//Session.getLogin(); public login: string = null;// Session.getLogin();
public avatar: string = null;//Session.getAvatar(); public avatar: string = null;// Session.getAvatar();
public displayUserMenu: boolean = false; public displayUserMenu: boolean = false;
public displayEditMenu: boolean = false; public displayEditMenu: boolean = false;
public ariane_type_id: number = null; public arianeTypeId: number = null;
public ariane_type_name: string = null; public arianeTypeName: string = null;
public ariane_universe_id: number = null; public arianeUniverseId: number = null;
public ariane_universe_name: string = null; public arianeUniverseName: string = null;
public ariane_series_id: number = null; public arianeSeriesId: number = null;
public ariane_series_name: string = null; public arianeSeriesName: string = null;
public ariane_season_id: number = null; public arianeSeasonId: number = null;
public ariane_season_name: string = null; public arianeSeasonName: string = null;
public ariane_video_id: number = null; public arianeVideoId: number = null;
public ariane_video_name: string = null; public arianeVideoName: string = null;
public edit_show: boolean = false; public editShow: boolean = false;
constructor(private router: Router, constructor(private router: Router,
private sessionService: SessionService, private sessionService: SessionService,
private arianeService: ArianeService) { private arianeService: ArianeService) {
}
ngOnInit() {
this.sessionService.change.subscribe(isConnected => {
console.log("receive event from session ..." + isConnected);
if (isConnected == false) {
this.login = null;
this.avatar = null;
this.displayUserMenu = false;
} else {
this.login = this.sessionService.getLogin();
this.avatar = this.sessionService.getAvatar();
this.displayUserMenu = false;
console.log(" login:" + this.sessionService.getLogin());
console.log(" avatar:" + this.avatar);
}
});
this.arianeService.type_change.subscribe(type_id => {
this.ariane_type_id = type_id;
this.ariane_type_name = this.arianeService.getTypeName();
this.updateEditShow();
});
this.arianeService.universe_change.subscribe(univers_id => {
this.ariane_universe_id = univers_id;
this.ariane_universe_name = this.arianeService.getUniverseName();
this.updateEditShow();
});
this.arianeService.series_change.subscribe(series_id => {
this.ariane_series_id = series_id;
this.ariane_series_name = this.arianeService.getSeriesName();
this.updateEditShow();
});
this.arianeService.season_change.subscribe(season_id => {
this.ariane_season_id = season_id;
this.ariane_season_name = this.arianeService.getSeasonName();
this.updateEditShow();
});
this.arianeService.video_change.subscribe(video_id => {
this.ariane_video_id = video_id;
this.ariane_video_name = this.arianeService.getVideoName();
this.updateEditShow();
});
}
updateEditShow():void {
this.edit_show = /* this.ariane_type_id != null
|| this.ariane_universe_id != null
||*/ this.ariane_series_id != null
|| this.ariane_season_id != null
|| this.ariane_video_id != null;
}
onAvatar(): void {
console.log("onAvatar() " + this.displayUserMenu);
this.displayUserMenu = !this.displayUserMenu;
this.displayEditMenu = false;
}
onEdit(): void {
console.log("onEdit()");
this.displayEditMenu = !this.displayEditMenu;
this.displayUserMenu = false;
}
onSubEditVideo(_event: any): void {
console.log("onSubEdit()");
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateVideoEdit(this.ariane_video_id, _event.which==2);
}
onSubEditSeason(_event: any): void {
console.log("onSubEdit()");
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateSeasonEdit(this.ariane_season_id, _event.which==2);
}
onSubEditSeries(_event: any): void {
console.log("onSubEdit()");
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateSeriesEdit(this.ariane_series_id, _event.which==2);
}
onSubEditUniverse(_event: any): void {
console.log("onSubEdit()");
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateUniverseEdit(this.ariane_universe_id, _event.which==2);
}
onSubEditType(_event: any): void {
console.log("onSubEditType()");
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateTypeEdit(this.ariane_type_id, _event.which==2);
}
onHome(_event: any): void {
console.log("onHome()");
this.router.navigate(['home']);
}
onSignIn(_event: any): void {
console.log("onSignIn()");
//Session.destroy();
this.router.navigate(['signup']);
}
onLogin(_event: any): void {
console.log("onLogin()");
//Session.destroy();
this.router.navigate(['login']);
this.displayUserMenu = false;
}
onLogout(_event: any): void {
console.log("onLogout()");
this.sessionService.destroy();
this.router.navigate(['home']);
this.displayUserMenu = false;
} }
onAddMedia(_event: any): void { ngOnInit() {
console.log("onAddMedia()"); this.sessionService.change.subscribe((isConnected) => {
this.router.navigate(['upload']); console.log(`receive event from session ...${ isConnected}`);
this.displayUserMenu = false; if(isConnected === false) {
} this.login = null;
this.avatar = null;
this.displayUserMenu = false;
} else {
this.login = this.sessionService.getLogin();
this.avatar = this.sessionService.getAvatar();
this.displayUserMenu = false;
console.log(` login:${ this.sessionService.getLogin()}`);
console.log(` avatar:${ this.avatar}`);
}
});
this.arianeService.typeChange.subscribe((typeId: number) => {
this.arianeTypeId = typeId;
this.arianeTypeName = this.arianeService.getTypeName();
this.updateEditShow();
});
this.arianeService.universeChange.subscribe((universId) => {
this.arianeUniverseId = universId;
this.arianeUniverseName = this.arianeService.getUniverseName();
this.updateEditShow();
});
this.arianeService.seriesChange.subscribe((seriesId) => {
this.arianeSeriesId = seriesId;
this.arianeSeriesName = this.arianeService.getSeriesName();
this.updateEditShow();
});
this.arianeService.seasonChange.subscribe((seasonId) => {
this.arianeSeasonId = seasonId;
this.arianeSeasonName = this.arianeService.getSeasonName();
this.updateEditShow();
});
this.arianeService.videoChange.subscribe((videoId) => {
this.arianeVideoId = videoId;
this.arianeVideoName = this.arianeService.getVideoName();
this.updateEditShow();
});
}
updateEditShow():void {
this.editShow = /* this.arianeTypeId !== null
|| this.arianeUniverseId !== null
||*/ this.arianeSeriesId !== null ||
this.arianeSeasonId !== null ||
this.arianeVideoId !== null;
}
onAvatar(): void {
console.log(`onAvatar() ${ this.displayUserMenu}`);
this.displayUserMenu = !this.displayUserMenu;
this.displayEditMenu = false;
}
onSetting(_event: any): void { onEdit(): void {
console.log("onSetting()"); console.log('onEdit()');
this.router.navigate(['settings']); this.displayEditMenu = !this.displayEditMenu;
this.displayUserMenu = false; this.displayUserMenu = false;
} }
onSubEditVideo(event: any): void {
console.log('onSubEdit()');
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateVideoEdit(this.arianeVideoId, event.which === 2);
}
onSubEditSeason(event: any): void {
console.log('onSubEdit()');
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateSeasonEdit(this.arianeSeasonId, event.which === 2);
}
onSubEditSeries(event: any): void {
console.log('onSubEdit()');
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateSeriesEdit(this.arianeSeriesId, event.which === 2);
}
onSubEditUniverse(event: any): void {
console.log('onSubEdit()');
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateUniverseEdit(this.arianeUniverseId, event.which === 2);
}
onSubEditType(event: any): void {
console.log('onSubEditType()');
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateTypeEdit(this.arianeTypeId, event.which === 2);
}
onHelp(_event: any): void { onHome(event: any): void {
console.log("onHelp()"); console.log('onHome()');
this.router.navigate(['help']); this.router.navigate([ 'home' ]);
this.displayUserMenu = false; }
}
onOutUserProperty(): void { onSignIn(event: any): void {
console.log("onOutUserProperty ==> event..."); console.log('onSignIn()');
this.displayUserMenu = false; // Session.destroy();
this.displayEditMenu = false; this.router.navigate([ 'signup' ]);
} }
onArianeType(_event: any): void { onLogin(event: any): void {
console.log("onArianeType(" + this.ariane_type_id + ")"); console.log('onLogin()');
this.arianeService.navigateType(this.ariane_type_id, _event.which==2); // Session.destroy();
} this.router.navigate([ 'login' ]);
this.displayUserMenu = false;
}
onArianeUniverse(_event: any): void { onLogout(event: any): void {
console.log("onArianeUniverse(" + this.ariane_universe_id + ")"); console.log('onLogout()');
this.arianeService.navigateUniverse(this.ariane_universe_id, _event.which==2); this.sessionService.destroy();
} this.router.navigate([ 'home' ]);
this.displayUserMenu = false;
}
onArianeSeries(_event: any): void { onAddMedia(event: any): void {
console.log("onArianeSeries(" + this.ariane_series_id + ")"); console.log('onAddMedia()');
this.arianeService.navigateSeries(this.ariane_series_id, _event.which==2); this.router.navigate([ 'upload' ]);
} this.displayUserMenu = false;
}
onArianeSeason(_event: any): void { onSetting(event: any): void {
console.log("onArianeSeason(" + this.ariane_season_id + ")"); console.log('onSetting()');
this.arianeService.navigateSeason(this.ariane_season_id, _event.which==2); this.router.navigate([ 'settings' ]);
} this.displayUserMenu = false;
}
onHelp(event: any): void {
console.log('onHelp()');
this.router.navigate([ 'help' ]);
this.displayUserMenu = false;
}
onOutUserProperty(): void {
console.log('onOutUserProperty ==> event...');
this.displayUserMenu = false;
this.displayEditMenu = false;
}
onArianeType(event: any): void {
console.log(`onArianeType(${ this.arianeTypeId })`);
this.arianeService.navigateType(this.arianeTypeId, event.which === 2);
}
onArianeUniverse(event: any): void {
console.log(`onArianeUniverse(${ this.arianeUniverseId })`);
this.arianeService.navigateUniverse(this.arianeUniverseId, event.which === 2);
}
onArianeSeries(event: any): void {
console.log(`onArianeSeries(${ this.arianeSeriesId })`);
this.arianeService.navigateSeries(this.arianeSeriesId, event.which === 2);
}
onArianeSeason(event: any): void {
console.log(`onArianeSeason(${ this.arianeSeasonId })`);
this.arianeService.navigateSeason(this.arianeSeasonId, event.which === 2);
}
} }
/*
app.controller("controlerTop", function($scope, $rootScope, SESSION_EVENTS, Session, USER_ROLES) {
$rootScope.$on(SESSION_EVENTS.login, function(event) {
console.log("event ... " + SESSION_EVENTS.login);
$scope.login = Session.getLogin();
$scope.avatar = Session.getAvatar();
$scope.displayUserMenu = false;
$rootScope.currentDisplay = "home.html";
$rootScope.currentModal = "";
$rootScope.currentModalCanRemove = false;
});
$rootScope.$on(SESSION_EVENTS.logout, function(event) {
console.log("event ... " + SESSION_EVENTS.login);
$scope.login = Session.getLogin();
$scope.avatar = Session.getAvatar();
$scope.displayUserMenu = false;
$rootScope.currentDisplay = "home.html";
$rootScope.currentModal = "";
$rootScope.currentModalCanRemove = false;
});
$scope.login = Session.getLogin();
$scope.avatar = Session.getAvatar();
$scope.displayUserMenu = false;
$scope.onAvatar = function() {
$scope.displayUserMenu = !$scope.displayUserMenu;
}
$scope.onHome = function() {
$rootScope.currentDisplay = "home.html";
}
$scope.onSignIn = function() {
Session.destroy();
$rootScope.currentDisplay = "signUp.html";
}
$scope.onLogin = function() {
Session.destroy();
$rootScope.currentModal = "login.html";
$scope.displayUserMenu = false;
}
$scope.onLogout = function() {
Session.destroy();
$rootScope.currentDisplay = "home.html";
$scope.displayUserMenu = false;
}
$scope.onSetting = function() {
$rootScope.currentModal = "";
$rootScope.currentDisplay = "setting.html";
$scope.displayUserMenu = false;
}
$scope.onHelp = function() {
$rootScope.currentModal = "";
$rootScope.currentDisplay = "help.html";
$scope.displayUserMenu = false;
}
$scope.onOutUserProperty = function() {
console.log("onOutUserProperty ==> event...");
$rootScope.currentModal = "";
$scope.displayUserMenu = false;
}
});
*/

View File

@ -1,20 +1,20 @@
import { Component} from '@angular/core'; import { Component } from '@angular/core';
@Component({ @Component({
selector: 'app-upload-file', selector: 'app-upload-file',
templateUrl: './upload-file.html', templateUrl: './upload-file.html',
styleUrls: ['./upload-file.less'] styleUrls: [ './upload-file.less' ]
}) })
export class UploadFileComponent { export class UploadFileComponent {
files: any = []; files: any = [];
uploadFile(event) { uploadFile(event) {
for (let index = 0; index < event.length; index++) { for(let index = 0; index < event.length; index++) {
const element = event[index]; const element = event[index];
this.files.push(element.name) this.files.push(element.name);
} }
} }
deleteAttachment(index) { deleteAttachment(index) {
this.files.splice(index, 1) this.files.splice(index, 1);
} }
} }

View File

@ -7,15 +7,13 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
@Component({ @Component({
selector: 'app-error', selector: 'app-error',
templateUrl: './error.html', templateUrl: './error.html',
styleUrls: ['./error.less'] styleUrls: [ './error.less' ]
}) })
export class ErrorComponent implements OnInit { export class ErrorComponent implements OnInit {
constructor() { }
constructor() { } ngOnInit() {
}
ngOnInit() {
}
} }

View File

@ -3,30 +3,22 @@
* @copyright 2018, Edouard DUPIN, all right reserved * @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file) * @license PROPRIETARY (see license file)
*/ */
import { Injectable, Component, OnInit, Input } from '@angular/core'; import { Injectable, Component, OnInit } from '@angular/core';
//import { AppRoutingModule } from "../app-routing.module";
import { Router } from "@angular/router";
import { ActivatedRoute, Params } from '@angular/router';
import { TypeService } from '../../service/type';
import { PopInService } from '../../service/popin'; import { PopInService } from '../../service/popin';
@Component({ @Component({
selector: 'create-type', selector: 'create-type',
templateUrl: './create-type.html', templateUrl: './create-type.html',
styleUrls: ['./create-type.less'] styleUrls: [ './create-type.less' ]
}) })
@Injectable() @Injectable()
export class PopInCreateType implements OnInit { export class PopInCreateType implements OnInit {
name: string = '';
description: string = '';
name: string = ""; constructor(private popInService: PopInService) {
description: string = "";
constructor(private router: Router,
private typeService: TypeService,
private popInService: PopInService) {
} }
OnDestroy() { OnDestroy() {
@ -35,27 +27,27 @@ export class PopInCreateType implements OnInit {
ngOnInit() { ngOnInit() {
} }
eventPopUp(_event: string): void { eventPopUp(event: string): void {
console.log("GET event: " + _event); console.log(`GET event: ${ event}`);
this.popInService.close("popin-create-type"); this.popInService.close('popin-create-type');
} }
updateNeedSend():void { updateNeedSend():void {
} }
onName(_value:any):void { onName(value:any):void {
if (_value.length == 0) { if(value.length === 0) {
this.name = ""; this.name = '';
} else { } else {
this.name = _value; this.name = value;
} }
this.updateNeedSend(); this.updateNeedSend();
} }
onDescription(_value:any):void { onDescription(value:any):void {
if (_value.length == 0) { if(value.length === 0) {
this.description = ""; this.description = '';
} else { } else {
this.description = _value; this.description = value;
} }
this.updateNeedSend(); this.updateNeedSend();
} }

View File

@ -3,11 +3,11 @@
* @copyright 2018, Edouard DUPIN, all right reserved * @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file) * @license PROPRIETARY (see license file)
*/ */
import { Injectable, Component, OnInit, Input, Output, SimpleChanges, EventEmitter} from '@angular/core'; import { Injectable, Component, OnInit, Input, Output, SimpleChanges, EventEmitter } from '@angular/core';
//import { AppRoutingModule } from "../app-routing.module"; // import { AppRoutingModule } from "../app-routing.module";
import { Router } from "@angular/router"; import { Router } from '@angular/router';
import { ActivatedRoute, Params } from '@angular/router'; import { ActivatedRoute, Params } from '@angular/router';
import { TypeService } from '../../service/type'; import { TypeService } from '../../service/type';
import { PopInService } from '../../service/popin'; import { PopInService } from '../../service/popin';
@ -15,18 +15,17 @@ import { PopInService } from '../../service/popin';
@Component({ @Component({
selector: 'delete-confirm', selector: 'delete-confirm',
templateUrl: './delete-confirm.html', templateUrl: './delete-confirm.html',
styleUrls: ['./delete-confirm.less'] styleUrls: [ './delete-confirm.less' ]
}) })
@Injectable() @Injectable()
export class PopInDeleteConfirm implements OnInit { export class PopInDeleteConfirm implements OnInit {
@Input() comment: string = null; @Input() comment: string = null;
@Input() imageUrl: string = null; @Input() imageUrl: string = null;
@Output() callback: EventEmitter<any> = new EventEmitter(); @Output() callback: EventEmitter<any> = new EventEmitter();
public closeButtonTitle: string = "Cancel"; public closeButtonTitle: string = 'Cancel';
public validateButtonTitle: string = "Validate"; public validateButtonTitle: string = 'Validate';
constructor(private router: Router, constructor(private router: Router,
private popInService: PopInService) { private popInService: PopInService) {
@ -42,11 +41,10 @@ export class PopInDeleteConfirm implements OnInit {
} }
eventPopUp(_event: string): void { eventPopUp(_event: string): void {
console.log("GET event: " + _event); console.log(`GET event: ${ _event}`);
this.popInService.close("popin-delete-confirm"); this.popInService.close('popin-delete-confirm');
if (_event == "validate") { if(_event === 'validate') {
this.callback.emit(null); this.callback.emit(null);
} }
} }
} }

View File

@ -1,12 +0,0 @@
.expand {
width: 100%;
input {
width: 100%;
};
textarea {
width: 100%;
};
}

View File

@ -5,9 +5,9 @@
*/ */
import { Injectable, Component, OnInit, Input, SimpleChanges } from '@angular/core'; import { Injectable, Component, OnInit, Input, SimpleChanges } from '@angular/core';
//import { AppRoutingModule } from "../app-routing.module"; // import { AppRoutingModule } from "../app-routing.module";
import { Router } from "@angular/router"; import { Router } from '@angular/router';
import { ActivatedRoute, Params } from '@angular/router'; import { ActivatedRoute, Params } from '@angular/router';
import { TypeService } from '../../service/type'; import { TypeService } from '../../service/type';
import { PopInService } from '../../service/popin'; import { PopInService } from '../../service/popin';
@ -15,22 +15,21 @@ import { PopInService } from '../../service/popin';
@Component({ @Component({
selector: 'upload-progress', selector: 'upload-progress',
templateUrl: './upload-progress.html', templateUrl: './upload-progress.html',
styleUrls: ['./upload-progress.less'] styleUrls: [ './upload-progress.less' ]
}) })
@Injectable() @Injectable()
export class PopInUploadProgress implements OnInit { export class PopInUploadProgress implements OnInit {
@Input() mediaTitle: string = '';
@Input() mediaTitle: string = "";
@Input() mediaUploaded: number = 0; @Input() mediaUploaded: number = 0;
@Input() mediaSize: number = 999999999999; @Input() mediaSize: number = 999999999999;
@Input() result: string = null; @Input() result: string = null;
@Input() error: string = null; @Input() error: string = null;
public closeButtonTitle: string = "Abort"; public closeButtonTitle: string = 'Abort';
public otherButtonTitle: string = null; public otherButtonTitle: string = null;
public validateButtonTitle: string = null; public validateButtonTitle: string = null;
public uploadDisplay: string = ""; public uploadDisplay: string = '';
public sizeDisplay: string = ""; public sizeDisplay: string = '';
public progress: number = 0; public progress: number = 0;
constructor(private router: Router, constructor(private router: Router,
private popInService: PopInService) { private popInService: PopInService) {
@ -43,86 +42,86 @@ export class PopInUploadProgress implements OnInit {
} }
eventPopUp(_event: string): void { eventPopUp(_event: string): void {
console.log("GET event: " + _event); console.log(`GET event: ${ _event}`);
this.popInService.close("popin-upload-progress"); this.popInService.close('popin-upload-progress');
} }
updateNeedSend():void { updateNeedSend():void {
} }
limit3(count:number):string { limit3(count:number):string {
if (count>=1000) { if(count >= 1000) {
return "" + count; return `${ count}`;
} }
if (count>=100) { if(count >= 100) {
return " " + count; return ` ${ count}`;
} }
if (count>=10) { if(count >= 10) {
return " " + count; return ` ${ count}`;
} }
return " " + count; return ` ${ count}`;
} }
convertInHuman(countIn:number):string { convertInHuman(countIn:number):string {
let count = countIn; let count = countIn;
let tera = Math.trunc(count/(1024*1024*1024*1024)); let tera = Math.trunc(count / (1024 * 1024 * 1024 * 1024));
count = count - tera*1024*1024*1024*1024; count = count - tera * 1024 * 1024 * 1024 * 1024;
let giga = Math.trunc(count/(1024*1024*1024)); let giga = Math.trunc(count / (1024 * 1024 * 1024));
count = count - giga*1024*1024*1024; count = count - giga * 1024 * 1024 * 1024;
let mega = Math.trunc(count/(1024*1024)); let mega = Math.trunc(count / (1024 * 1024));
count = count - mega*1024*1024; count = count - mega * 1024 * 1024;
let kilo = Math.trunc(count/1024); let kilo = Math.trunc(count / 1024);
count = count - kilo*1024; count = count - kilo * 1024;
let out = "" let out = '';
if (out.length != 0 || tera != 0) { if(out.length !== 0 || tera !== 0) {
out += " " + this.limit3(tera) + "T"; out = `${out } ${ this.limit3(tera) }T`;
} }
if (out.length != 0 || giga != 0) { if(out.length !== 0 || giga !== 0) {
out += " " + this.limit3(giga) + "G"; out = `${out } ${ this.limit3(giga) }G`;
} }
if (out.length != 0 || mega != 0) { if(out.length !== 0 || mega !== 0) {
out += " " + this.limit3(mega)+ "M"; out = `${out } ${ this.limit3(mega) }M`;
} }
if (out.length != 0 || kilo != 0) { if(out.length !== 0 || kilo !== 0) {
out += " " + this.limit3(kilo) + "k"; out = `${out } ${ this.limit3(kilo) }k`;
} }
if (out.length != 0 || count != 0) { if(out.length !== 0 || count !== 0) {
out += " " + this.limit3(count) + "B"; out = `${out } ${ this.limit3(count) }B`;
} }
return out; return out;
} }
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {
this.progress = Math.trunc(this.mediaUploaded*100/this.mediaSize) this.progress = Math.trunc(this.mediaUploaded * 100 / this.mediaSize);
this.uploadDisplay = this.convertInHuman(this.mediaUploaded); this.uploadDisplay = this.convertInHuman(this.mediaUploaded);
this.sizeDisplay = this.convertInHuman(this.mediaSize); this.sizeDisplay = this.convertInHuman(this.mediaSize);
if ( this.error == null && this.result == null) { if(this.error === null && this.result === null) {
this.closeButtonTitle = "Abort"; this.closeButtonTitle = 'Abort';
this.otherButtonTitle = null; this.otherButtonTitle = null;
this.validateButtonTitle = null; this.validateButtonTitle = null;
} else if (this.result == null) { } else if(this.result === null) {
this.closeButtonTitle = null; this.closeButtonTitle = null;
this.otherButtonTitle = "Close"; this.otherButtonTitle = 'Close';
this.validateButtonTitle = null; this.validateButtonTitle = null;
} else { } else {
this.closeButtonTitle = null; this.closeButtonTitle = null;
this.otherButtonTitle = null; this.otherButtonTitle = null;
this.validateButtonTitle = "Ok"; this.validateButtonTitle = 'Ok';
} }
} }
} }
export class UploadProgress { export class UploadProgress {
labelMediaTitle: string = ""; labelMediaTitle: string = '';
mediaSendSize: number = 0; mediaSendSize: number = 0;
mediaSize: number = 99999999999999; mediaSize: number = 99999999999999;
result: string = null; result: string = null;
error: string = null; error: string = null;
clear() { clear() {
this.labelMediaTitle = ""; this.labelMediaTitle = '';
this.mediaSendSize = 0; this.mediaSendSize = 0;
this.mediaSize = 99999999999999; this.mediaSize = 99999999999999;
this.result = null; this.result = null;
this.error = null; this.error = null;
} }
}; }

View File

@ -9,18 +9,16 @@ import { ActivatedRoute } from '@angular/router';
import { ArianeService } from '../../service/ariane'; import { ArianeService } from '../../service/ariane';
@Component({ @Component({
selector: 'app-error-viewer', selector: 'app-error-viewer',
templateUrl: './error-viewer.html', templateUrl: './error-viewer.html',
styleUrls: ['./error-viewer.less'] styleUrls: [ './error-viewer.less' ]
}) })
export class ErrorViewerScene implements OnInit { export class ErrorViewerScene implements OnInit {
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private arianeService: ArianeService) { } private arianeService: ArianeService) { }
ngOnInit() { ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap); this.arianeService.updateManual(this.route.snapshot.paramMap);
} }
} }

View File

@ -3,17 +3,15 @@ import { ActivatedRoute } from '@angular/router';
import { ArianeService } from '../../service/ariane'; import { ArianeService } from '../../service/ariane';
@Component({ @Component({
selector: 'app-help', selector: 'app-help',
templateUrl: './help.html', templateUrl: './help.html',
styleUrls: ['./help.less'] styleUrls: [ './help.less' ]
}) })
export class HelpScene implements OnInit { export class HelpScene implements OnInit {
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private arianeService: ArianeService) { } private arianeService: ArianeService) { }
ngOnInit() { ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap); this.arianeService.updateManual(this.route.snapshot.paramMap);
} }
} }

View File

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

View File

@ -5,8 +5,7 @@
*/ */
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from "@angular/router"; import { ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common';
import { fadeInAnimation } from '../../_animations/index'; import { fadeInAnimation } from '../../_animations/index';
import { TypeService } from '../../service/type'; import { TypeService } from '../../service/type';
@ -15,16 +14,14 @@ import { ArianeService } from '../../service/ariane';
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
templateUrl: './home.html', templateUrl: './home.html',
styleUrls: ['./home.less'], styleUrls: [ './home.less' ],
animations: [fadeInAnimation], animations: [ fadeInAnimation ],
host: { '[@fadeInAnimation]': '' } host: { '[@fadeInAnimation]': '' }
}) })
export class HomeScene implements OnInit { export class HomeScene implements OnInit {
data_list = []; dataList = [];
error = ""; error = '';
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router,
private locate: Location,
private typeService: TypeService, private typeService: TypeService,
private arianeService: ArianeService) { private arianeService: ArianeService) {
@ -32,21 +29,20 @@ export class HomeScene implements OnInit {
ngOnInit() { ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap); this.arianeService.updateManual(this.route.snapshot.paramMap);
let self = this let self = this;
this.typeService.getData() this.typeService.getData()
.then(function(response) { .then((response) => {
self.error = ""; self.error = '';
self.data_list = response self.dataList = response;
console.log("Get response: " + JSON.stringify(response, null, 2)); console.log(`Get response: ${ JSON.stringify(response, null, 2)}`);
}).catch(function(response) { }).catch((response) => {
self.error = "Wrong e-mail/login or password"; self.error = 'Wrong e-mail/login or password';
console.log("[E] " + self.constructor.name + ": Does not get a correct response from the server ..."); console.log(`[E] ${ self.constructor.name }: Does not get a correct response from the server ...`);
self.data_list = [] self.dataList = [];
}); });
this.arianeService.reset(); this.arianeService.reset();
} }
onSelectType(_event: any, _idSelected: number):void { onSelectType(_event: any, _idSelected: number):void {
this.arianeService.navigateType(_idSelected, _event.which==2); this.arianeService.navigateType(_idSelected, _event.which === 2);
} }
} }

View File

@ -6,7 +6,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Router } from "@angular/router"; import { Router } from '@angular/router';
import { Location } from '@angular/common'; import { Location } from '@angular/common';
import { fadeInAnimation } from '../../_animations/index'; import { fadeInAnimation } from '../../_animations/index';
import { UserService } from '../../service/user'; import { UserService } from '../../service/user';
@ -15,29 +15,29 @@ import { CookiesService } from '../../service/cookies';
import { ArianeService } from '../../service/ariane'; import { ArianeService } from '../../service/ariane';
export let checkLoginValidity = function(_value:string):boolean { export function checkLoginValidity(value:string):boolean {
let regexCheck = new RegExp("^[a-zA-Z0-9_\.-]+$"); let regexCheck = new RegExp('^[a-zA-Z0-9_\\.-]+$');
if (regexCheck.test(_value)) { if(regexCheck.test(value)) {
return true; return true;
} }
return false; return false;
}; }
export let checkEmailValidity = function(_value:string):boolean { export function checkEmailValidity(value:string):boolean {
let regexCheck = new RegExp("^[a-zA-Z0-9_\.@-]+@[a-zA-Z0-9_\.-]+\\.[a-zA-Z]+$"); let regexCheck = new RegExp('^[a-zA-Z0-9_\\.@-]+@[a-zA-Z0-9_\\.-]+\\.[a-zA-Z]+$');
if (regexCheck.test(_value)) { if(regexCheck.test(value)) {
return true; return true;
} }
return false; return false;
}; }
export let checkPasswordValidity = function(_value:string):boolean { export function checkPasswordValidity(value:string):boolean {
let regexCheck = new RegExp("^[a-zA-Z0-9_\.@ %:;,=}{\?\!\*\+\(\)\[\]\|&#%~/\\\<\>-£€]+$"); let regexCheck = new RegExp('^[a-zA-Z0-9_\\.@ %:;,=}{\\?\\!\\*\\+\\(\\)\\[\\]\\|&#%~/\\\\\\<\\>-£€]+$');
if (regexCheck.test(_value)) { if(regexCheck.test(value)) {
return true; return true;
} }
return false; return false;
}; }
declare function SHA512(param1: any): any; declare function SHA512(param1: any): any;
@ -45,20 +45,20 @@ declare function SHA512(param1: any): any;
@Component({ @Component({
selector: 'app-login', selector: 'app-login',
templateUrl: './login.html', templateUrl: './login.html',
styleUrls: ['./login.less'], styleUrls: [ './login.less' ],
animations: [fadeInAnimation], animations: [ fadeInAnimation ],
host: { '[@fadeInAnimation]': '' } host: { '[@fadeInAnimation]': '' }
}) })
export class LoginScene implements OnInit { export class LoginScene implements OnInit {
public loginOK:boolean = false; public loginOK:boolean = false;
public loginHelp:string = ""; public loginHelp:string = '';
public login:string = ""; public login:string = '';
public passOK:boolean = false; public passOK:boolean = false;
public passHelp:string = ""; public passHelp:string = '';
public password:string = ""; public password:string = '';
public loginButtonDisabled:boolean = true; public loginButtonDisabled:boolean = true;
public error:string = ""; public error:string = '';
public loginType:string = "Username/E-mail"; public loginType:string = 'Username/E-mail';
public rememberMe:boolean = true; public rememberMe:boolean = true;
@ -73,50 +73,49 @@ export class LoginScene implements OnInit {
} }
ngOnInit() { ngOnInit() {
// TODO : If already loaded ==> jusp in the home page ... // If already loaded ==> jusp in the home page ...
this.arianeService.updateManual(this.route.snapshot.paramMap); this.arianeService.updateManual(this.route.snapshot.paramMap);
} }
updateButtonVisibility():void { updateButtonVisibility():void {
if ( this.loginOK == true if(this.loginOK === true &&
&& this.passOK == true) { this.passOK === true) {
this.loginButtonDisabled = false; this.loginButtonDisabled = false;
} else { } else {
this.loginButtonDisabled = true; this.loginButtonDisabled = true;
} }
this.error = ""; this.error = '';
} }
/** /**
* Check the login writing rules * Check the login writing rules
*/ */
checkLogin(_newValue:string):void { checkLogin(newValue:string):void {
this.login = _newValue; this.login = newValue;
if (this.login == null) { if(this.login === null) {
this.loginOK = false; this.loginOK = false;
this.loginHelp = ""; this.loginHelp = '';
this.updateButtonVisibility(); this.updateButtonVisibility();
return; return;
} }
if (this.login.length < 6) { if(this.login.length < 6) {
this.loginOK = false; this.loginOK = false;
this.loginHelp = "Need 6 characters"; this.loginHelp = 'Need 6 characters';
this.loginType = "Username/E-mail"; this.loginType = 'Username/E-mail';
this.updateButtonVisibility(); this.updateButtonVisibility();
return; return;
} }
if (checkLoginValidity(this.login) == true) { if(checkLoginValidity(this.login) === true) {
this.loginOK = true; this.loginOK = true;
this.loginHelp = ""; this.loginHelp = '';
this.loginType = "Username"; this.loginType = 'Username';
} else if(checkEmailValidity(this.login) === true) {
this.loginOK = true;
this.loginHelp = '';
this.loginType = 'E-mail';
} else { } else {
if (checkEmailValidity(this.login) == true) { this.loginOK = false;
this.loginOK = true; this.loginHelp = 'Not valid: characters, numbers, "_-." and email format: you@example.com';
this.loginHelp = "";
this.loginType = "E-mail";
} else {
this.loginOK = false;
this.loginHelp = 'Not valid: characters, numbers, "_-." and email format: you@example.com';
}
} }
this.updateButtonVisibility(); this.updateButtonVisibility();
} }
@ -124,50 +123,48 @@ export class LoginScene implements OnInit {
/** /**
* Check the password writing rules * Check the password writing rules
*/ */
checkPassword(_newValue:string):void { checkPassword(newValue:string):void {
this.password = _newValue; this.password = newValue;
if (this.password == null) { if(this.password === null) {
this.passOK = false; this.passOK = false;
this.passHelp = ""; this.passHelp = '';
this.updateButtonVisibility(); this.updateButtonVisibility();
return; return;
} }
if (this.password.length < 6) { if(this.password.length < 6) {
this.passOK = false; this.passOK = false;
this.passHelp = "Need 6 characters"; this.passHelp = 'Need 6 characters';
} else if(checkPasswordValidity(this.password) === true) {
this.passOK = true;
this.passHelp = '';
} else { } else {
if (checkPasswordValidity(this.password) == true) { this.passOK = false;
this.passOK = true; this.passHelp = 'Not valid: characters, numbers and "_-:;.,?!*+=}{([|)]% @&~#/\\<>"';
this.passHelp = "";
} else {
this.passOK = false;
this.passHelp = 'Not valid: characters, numbers and "_-:;.,?!*+=}{([|)]% @&~#/\<>"';
}
} }
this.updateButtonVisibility(); this.updateButtonVisibility();
} }
onLogin():void { onLogin():void {
this.sessionService.destroy(); this.sessionService.destroy();
let self = this let self = this;
this.userService.login(this.login, this.password) this.userService.login(this.login, this.password)
.then(function(response) { .then((response) => {
self.error = "Login ..."; self.error = 'Login ...';
self.sessionService.create(response['sessionId'], self.sessionService.create(response.sessionId,
response['login'], response.login,
response['email'], response.email,
response['role'], response.role,
response['avatar']); response.avatar);
if (self.rememberMe == true) { if(self.rememberMe === true) {
self.cookiesService.set("yota-login", response['login'], 120); self.cookiesService.set('yota-login', response.login, 120);
self.cookiesService.set("yota-password", SHA512(self.password), 60); self.cookiesService.set('yota-password', SHA512(self.password), 60);
} }
self.router.navigate(['home']); self.router.navigate([ 'home' ]);
}).catch(function(response) { }).catch((response) => {
self.error = "Wrong e-mail/login or password"; self.error = 'Wrong e-mail/login or password';
}); });
} }
onCancel():void { onCancel():void {
console.log("onCancel ... '" + this.login + "':'" + this.password + "'"); console.log(`onCancel ... '${ this.login }':'${ this.password }'`);
this.locate.back(); this.locate.back();
} }
} }

View File

@ -67,7 +67,7 @@
</div> </div>
<div class="request_raw"> <div class="request_raw">
<div class="input"> <div class="input">
<div class="cover" *ngFor="let element of covers_display"> <div class="cover" *ngFor="let element of coversDisplay">
<div class="cover-image"> <div class="cover-image">
<img src="{{element.url}}"/> <img src="{{element.url}}"/>
</div> </div>
@ -100,7 +100,7 @@
<i class="material-icons">data_usage</i> ID: <i class="material-icons">data_usage</i> ID:
</div> </div>
<div class="input"> <div class="input">
{{id_season}} {{idSeason}}
</div> </div>
</div> </div>
<div class="clear"></div> <div class="clear"></div>

View File

@ -5,63 +5,57 @@
*/ */
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common';
import { fadeInAnimation } from '../../_animations/index'; import { fadeInAnimation } from '../../_animations/index';
import { SeasonService } from '../../service/season'; import { SeasonService } from '../../service/season';
import { DataService } from '../../service/data';
import { ArianeService } from '../../service/ariane'; import { ArianeService } from '../../service/ariane';
import { UploadProgress } from '../../popin/upload-progress/upload-progress'; import { UploadProgress } from '../../popin/upload-progress/upload-progress';
import { PopInService } from '../../service/popin'; import { PopInService } from '../../service/popin';
export class ElementList { export interface ElementList {
value: number; value: number;
label: string; label: string;
constructor(_value: number, _label: string) {
this.value = _value;
this.label = _label;
}
} }
@Component({ @Component({
selector: 'app-season-edit', selector: 'app-season-edit',
templateUrl: './season-edit.html', templateUrl: './season-edit.html',
styleUrls: ['./season-edit.less'], styleUrls: [ './season-edit.less' ],
animations: [fadeInAnimation], animations: [ fadeInAnimation ],
host: { '[@fadeInAnimation]': '' } host: { '[@fadeInAnimation]': '' }
}) })
export class SeasonEditScene implements OnInit { export class SeasonEditScene implements OnInit {
id_season:number = -1; idSeason:number = -1;
itemIsRemoved:boolean = false; itemIsRemoved:boolean = false;
itemIsNotFound:boolean = false; itemIsNotFound:boolean = false;
itemIsLoading:boolean = true; itemIsLoading:boolean = true;
error:string = ""; error:string = '';
numberVal:number = null; numberVal: number = null;
description:string = ""; description: string = '';
coverFile:File; coverFile: File;
upload_file_value:string = ""; uploadFileValue: string = '';
selectedFiles:FileList; selectedFiles: FileList;
videoCount:string = null; videoCount: string = null;
covers_display:Array<any> = []; coversDisplay: Array<any> = [];
// section tha define the upload value to display in the pop-in of upload // section tha define the upload value to display in the pop-in of upload
public upload:UploadProgress = new UploadProgress(); public upload: UploadProgress = new UploadProgress();
// --------------- confirm section ------------------ // --------------- confirm section ------------------
public confirmDeleteComment:string = null; public confirmDeleteComment: string = null;
public confirmDeleteImageUrl:string = null; public confirmDeleteImageUrl: string = null;
private deleteCoverId:number = null; private deleteCoverId: number = null;
private deleteItemId:number = null; private deleteItemId: number = null;
deleteConfirmed() { deleteConfirmed() {
if (this.deleteCoverId !== null) { if(this.deleteCoverId !== null) {
this.removeCoverAfterConfirm(this.deleteCoverId); this.removeCoverAfterConfirm(this.deleteCoverId);
this.cleanConfirm(); this.cleanConfirm();
} }
if (this.deleteItemId !== null) { if(this.deleteItemId !== null) {
this.removeItemAfterConfirm(this.deleteItemId); this.removeItemAfterConfirm(this.deleteItemId);
this.cleanConfirm(); this.cleanConfirm();
} }
@ -75,9 +69,6 @@ export class SeasonEditScene implements OnInit {
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router,
private locate: Location,
private dataService: DataService,
private seasonService: SeasonService, private seasonService: SeasonService,
private arianeService: ArianeService, private arianeService: ArianeService,
private popInService: PopInService) { private popInService: PopInService) {
@ -86,148 +77,148 @@ export class SeasonEditScene implements OnInit {
ngOnInit() { ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap); this.arianeService.updateManual(this.route.snapshot.paramMap);
this.id_season = this.arianeService.getSeasonId(); this.idSeason = this.arianeService.getSeasonId();
let self = this; let self = this;
this.seasonService.get(this.id_season) this.seasonService.get(this.idSeason)
.then(function(response) { .then((response) => {
console.log("get response of season : " + JSON.stringify(response, null, 2)); console.log(`get response of season : ${ JSON.stringify(response, null, 2)}`);
self.numberVal = response.name; self.numberVal = response.name;
self.description = response.description; self.description = response.description;
self.updateCoverList(response.covers); self.updateCoverList(response.covers);
self.itemIsLoading = false; self.itemIsLoading = false;
}).catch(function(response) { }).catch((response) => {
self.error = "Can not get the data"; self.error = 'Can not get the data';
self.numberVal = null; self.numberVal = null;
self.description = ""; self.description = '';
self.covers_display = []; self.coversDisplay = [];
self.itemIsNotFound = true; self.itemIsNotFound = true;
self.itemIsLoading = false; self.itemIsLoading = false;
}); });
this.seasonService.getVideo(this.id_season) this.seasonService.getVideo(this.idSeason)
.then(function(response:any) { .then((response:any) => {
self.videoCount = response.length; self.videoCount = response.length;
}).catch(function(response:any) { }).catch((response:any) => {
self.videoCount = "---"; self.videoCount = '---';
}); });
} }
updateCoverList(_covers: any) { updateCoverList(covers: any) {
this.covers_display = []; this.coversDisplay = [];
if (_covers !== undefined && _covers !== null) { if(covers !== undefined && covers !== null) {
for (let iii=0; iii<_covers.length; iii++) { for(let iii = 0; iii < covers.length; iii++) {
this.covers_display.push({ this.coversDisplay.push({
id:_covers[iii], id:covers[iii],
url:this.seasonService.getCoverThumbnailUrl(_covers[iii]) url:this.seasonService.getCoverThumbnailUrl(covers[iii])
}); });
} }
} else { } else {
this.covers_display = [] this.coversDisplay = [];
} }
} }
onNumber(_value:any):void { onNumber(value:any):void {
this.numberVal = _value; this.numberVal = value;
} }
onDescription(_value:any):void { onDescription(value:any):void {
this.description = _value; this.description = value;
} }
sendValues():void { sendValues():void {
console.log("send new values...."); console.log('send new values....');
let data = { let data = {
"name": this.numberVal, name: this.numberVal,
"description": this.description description: this.description
}; };
if (this.description === undefined) { if(this.description === undefined) {
data["description"] = null; data.description = null;
} }
this.seasonService.put(this.id_season, data); this.seasonService.put(this.idSeason, data);
} }
// At the drag drop area // At the drag drop area
// (drop)="onDropFile($event)" // (drop)="onDropFile($event)"
onDropFile(_event: DragEvent) { onDropFile(event: DragEvent) {
_event.preventDefault(); event.preventDefault();
//this.uploadFile(_event.dataTransfer.files[0]); // this.uploadFile(event.dataTransfer.files[0]);
} }
// At the drag drop area // At the drag drop area
// (dragover)="onDragOverFile($event)" // (dragover)="onDragOverFile($event)"
onDragOverFile(_event) { onDragOverFile(event) {
_event.stopPropagation(); event.stopPropagation();
_event.preventDefault(); event.preventDefault();
} }
// At the file input element // At the file input element
// (change)="selectFile($event)" // (change)="selectFile($event)"
onChangeCover(_value:any):void { onChangeCover(value:any):void {
this.selectedFiles = _value.files this.selectedFiles = value.files;
this.coverFile = this.selectedFiles[0]; this.coverFile = this.selectedFiles[0];
console.log("select file " + this.coverFile.name); console.log(`select file ${ this.coverFile.name}`);
this.uploadCover(this.coverFile); this.uploadCover(this.coverFile);
} }
uploadCover(_file:File) { uploadCover(file:File) {
if (_file == undefined) { if(file === undefined) {
console.log("No file selected!"); console.log('No file selected!');
return; return;
} }
let self = this; let self = this;
// clean upload labels // clean upload labels
this.upload.clear(); this.upload.clear();
// display the upload pop-in // display the upload pop-in
this.popInService.open("popin-upload-progress"); this.popInService.open('popin-upload-progress');
this.seasonService.uploadCover(_file, this.id_season, function(count, total) { this.seasonService.uploadCover(file, this.idSeason, (count, total) => {
self.upload.mediaSendSize = count; self.upload.mediaSendSize = count;
self.upload.mediaSize = total; self.upload.mediaSize = total;
}) })
.then(function (response:any) { .then((response:any) => {
self.upload.result = "Cover added done"; self.upload.result = 'Cover added done';
// TODO: we retrive the whiole media ==> update data ... // we retrive the whiole media ==> update data ...
self.updateCoverList(response.covers); self.updateCoverList(response.covers);
}).catch(function (response:any) { }).catch((response:any) => {
//self.error = "Can not get the data"; // self.error = "Can not get the data";
console.log("Can not add the cover in the video..."); console.log('Can not add the cover in the video...');
}); });
} }
removeCover(_id:number) { removeCover(id:number) {
this.cleanConfirm(); this.cleanConfirm();
this.confirmDeleteComment = "Delete the cover ID: " + _id; this.confirmDeleteComment = `Delete the cover ID: ${ id}`;
this.confirmDeleteImageUrl = this.seasonService.getCoverThumbnailUrl(_id); this.confirmDeleteImageUrl = this.seasonService.getCoverThumbnailUrl(id);
this.deleteCoverId = _id; this.deleteCoverId = id;
this.popInService.open("popin-delete-confirm"); this.popInService.open('popin-delete-confirm');
} }
removeCoverAfterConfirm(_id:number) { removeCoverAfterConfirm(id:number) {
console.log("Request remove cover: " + _id); console.log(`Request remove cover: ${ id}`);
let self = this; let self = this;
this.seasonService.deleteCover(this.id_season, _id) this.seasonService.deleteCover(this.idSeason, id)
.then(function (response:any) { .then((response:any) => {
self.upload.result = "Cover remove done"; self.upload.result = 'Cover remove done';
// TODO: we retrive the whiole media ==> update data ... // we retrive the whiole media ==> update data ...
self.updateCoverList(response.covers); self.updateCoverList(response.covers);
}).catch(function (response:any) { }).catch((response:any) => {
//self.error = "Can not get the data"; // self.error = "Can not get the data";
console.log("Can not remove the cover of the video..."); console.log('Can not remove the cover of the video...');
}); });
} }
removeItem() { removeItem() {
console.log("Request remove Media..."); console.log('Request remove Media...');
this.cleanConfirm(); this.cleanConfirm();
this.confirmDeleteComment = "Delete the Season: " + this.id_season; this.confirmDeleteComment = `Delete the Season: ${ this.idSeason}`;
this.deleteItemId = this.id_season; this.deleteItemId = this.idSeason;
this.popInService.open("popin-delete-confirm"); this.popInService.open('popin-delete-confirm');
} }
removeItemAfterConfirm(_id:number) { removeItemAfterConfirm(id:number) {
let self = this; let self = this;
this.seasonService.delete(_id) this.seasonService.delete(id)
.then(function(response3) { .then((response3) => {
//self.data_ori = tmpp; // self.dataOri = tmpp;
//self.updateNeedSend(); // self.updateNeedSend();
self.itemIsRemoved = true; self.itemIsRemoved = true;
}).catch(function(response3) { }).catch((response3) => {
//self.updateNeedSend(); // self.updateNeedSend();
}); });
} }
} }

View File

@ -6,8 +6,8 @@
</div> </div>
</div> </div>
<div [className]="cover != null ? 'description-area description-area-cover' : 'description-area description-area-no-cover'"> <div [className]="cover != null ? 'description-area description-area-cover' : 'description-area description-area-no-cover'">
<div *ngIf="series_name" class="title"> <div *ngIf="seriesName" class="title">
{{series_name}} {{seriesName}}
</div> </div>
<div class="sub-title-main"> <div class="sub-title-main">
Season {{name}} Season {{name}}

View File

@ -5,8 +5,7 @@
*/ */
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common';
import { fadeInAnimation } from '../../_animations/index'; import { fadeInAnimation } from '../../_animations/index';
import { SeasonService } from '../../service/season'; import { SeasonService } from '../../service/season';
@ -16,23 +15,21 @@ import { ArianeService } from '../../service/ariane';
@Component({ @Component({
selector: 'app-season', selector: 'app-season',
templateUrl: './season.html', templateUrl: './season.html',
styleUrls: ['./season.less'], styleUrls: [ './season.less' ],
animations: [fadeInAnimation], animations: [ fadeInAnimation ],
host: { '[@fadeInAnimation]': '' } host: { '[@fadeInAnimation]': '' }
}) })
export class SeasonScene implements OnInit { export class SeasonScene implements OnInit {
name: string = ""; name: string = '';
series_name: string = ""; seriesName: string = '';
description: string = ""; description: string = '';
series_id: number = null; seriesId: number = null;
cover: string = "" cover: string = '';
covers: Array<string> = [] covers: Array<string> = [];
id_season = -1; idSeason = -1;
videos_error = ""; videosError = '';
videos = []; videos = [];
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router,
private locate: Location,
private seasonService: SeasonService, private seasonService: SeasonService,
private seriesService: SeriesService, private seriesService: SeriesService,
private arianeService: ArianeService) { private arianeService: ArianeService) {
@ -40,52 +37,51 @@ export class SeasonScene implements OnInit {
} }
ngOnInit() { ngOnInit() {
console.log("ngOnInit(SeasonComponent)"); console.log('ngOnInit(SeasonComponent)');
this.arianeService.updateManual(this.route.snapshot.paramMap); this.arianeService.updateManual(this.route.snapshot.paramMap);
this.id_season = this.arianeService.getSeasonId(); this.idSeason = this.arianeService.getSeasonId();
let self = this; let self = this;
this.seasonService.get(this.id_season) this.seasonService.get(this.idSeason)
.then(function(response:any) { .then((response:any) => {
self.name = response.name; self.name = response.name;
self.series_id = response.parent_id; self.seriesId = response.parentId;
self.description = response.description; self.description = response.description;
if (response.covers == undefined || response.covers == null || response.covers.length == 0) { if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
self.cover = null; self.cover = null;
self.covers = []; self.covers = [];
} else { } else {
self.cover = self.seriesService.getCoverUrl(response.covers[0]); self.cover = self.seriesService.getCoverUrl(response.covers[0]);
for (let iii=0; iii<response.covers.length; iii++) { for(let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.seriesService.getCoverUrl(response.covers[iii])); self.covers.push(self.seriesService.getCoverUrl(response.covers[iii]));
} }
} }
self.seriesService.get(self.series_id) self.seriesService.get(self.seriesId)
.then(function(response:any) { .then((response2:any) => {
self.series_name = response.name; self.seriesName = response2.name;
}).catch(function(response:any) { }).catch((response2:any) => {
self.series_name = ""; self.seriesName = '';
}); });
}).catch(function(response:any) { }).catch((response3:any) => {
self.description = ""; self.description = '';
self.name = "???"; self.name = '???';
self.series_name = ""; self.seriesName = '';
self.series_id = null; self.seriesId = null;
self.cover = null; self.cover = null;
self.covers = []; self.covers = [];
}); });
console.log("get parameter id: " + this.id_season); console.log(`get parameter id: ${ this.idSeason}`);
this.seasonService.getVideo(this.id_season) this.seasonService.getVideo(this.idSeason)
.then(function(response:any) { .then((response4:any) => {
self.videos_error = ""; self.videosError = '';
self.videos = response self.videos = response4;
}).catch(function(response:any) { }).catch((response5:any) => {
self.videos_error = "Can not get the List of video without season"; self.videosError = 'Can not get the List of video without season';
self.videos = [] self.videos = [];
}); });
} }
onSelectVideo(_event: any, _idSelected: number):void { onSelectVideo(event: any, idSelected: number):void {
this.arianeService.navigateVideo(_idSelected, _event.which==2, _event.ctrlKey); this.arianeService.navigateVideo(idSelected, event.which === 2, event.ctrlKey);
} }
} }

View File

@ -30,7 +30,7 @@
Type: Type:
</div> </div>
<div class="input"> <div class="input">
<select [ngModel]="type_id" <select [ngModel]="typeId"
(ngModelChange)="onChangeType($event)"> (ngModelChange)="onChangeType($event)">
<option *ngFor="let element of listType" [ngValue]="element.value">{{element.label}}</option> <option *ngFor="let element of listType" [ngValue]="element.value">{{element.label}}</option>
</select> </select>
@ -79,7 +79,7 @@
</div> </div>
<div class="request_raw"> <div class="request_raw">
<div class="input"> <div class="input">
<div class="cover" *ngFor="let element of covers_display"> <div class="cover" *ngFor="let element of coversDisplay">
<div class="cover-image"> <div class="cover-image">
<img src="{{element.url}}"/> <img src="{{element.url}}"/>
</div> </div>
@ -112,7 +112,7 @@
<i class="material-icons">data_usage</i> ID: <i class="material-icons">data_usage</i> ID:
</div> </div>
<div class="input"> <div class="input">
{{id_series}} {{idSeries}}
</div> </div>
</div> </div>
<div class="clear"></div> <div class="clear"></div>

View File

@ -28,36 +28,36 @@ export class ElementList {
@Component({ @Component({
selector: 'app-series-edit', selector: 'app-series-edit',
templateUrl: './series-edit.html', templateUrl: './series-edit.html',
styleUrls: ['./series-edit.less'], styleUrls: [ './series-edit.less' ],
animations: [fadeInAnimation], animations: [ fadeInAnimation ],
host: { '[@fadeInAnimation]': '' } host: { '[@fadeInAnimation]': '' }
}) })
export class SeriesEditScene implements OnInit { export class SeriesEditScene implements OnInit {
id_series:number = -1; idSeries:number = -1;
itemIsRemoved:boolean = false; itemIsRemoved:boolean = false;
itemIsNotFound:boolean = false; itemIsNotFound:boolean = false;
itemIsLoading:boolean = true; itemIsLoading:boolean = true;
error:string = ""; error:string = '';
type_id:number = null; typeId:number = null;
name:string = ""; name:string = '';
description:string = ""; description:string = '';
coverFile:File; coverFile:File;
upload_file_value:string = ""; uploadFileValue:string = '';
selectedFiles:FileList; selectedFiles:FileList;
seasonsCount:string = null; seasonsCount:string = null;
videoCount:string = null; videoCount:string = null;
covers_display:Array<any> = []; coversDisplay:Array<any> = [];
// section tha define the upload value to display in the pop-in of upload // section tha define the upload value to display in the pop-in of upload
public upload:UploadProgress = new UploadProgress(); public upload:UploadProgress = new UploadProgress();
listType: ElementList[] = [ listType: ElementList[] = [
{value: undefined, label: '---'}, { value: undefined, label: '---' },
]; ];
// --------------- confirm section ------------------ // --------------- confirm section ------------------
@ -66,11 +66,11 @@ export class SeriesEditScene implements OnInit {
private deleteCoverId:number = null; private deleteCoverId:number = null;
private deleteItemId:number = null; private deleteItemId:number = null;
deleteConfirmed() { deleteConfirmed() {
if (this.deleteCoverId !== null) { if(this.deleteCoverId !== null) {
this.removeCoverAfterConfirm(this.deleteCoverId); this.removeCoverAfterConfirm(this.deleteCoverId);
this.cleanConfirm(); this.cleanConfirm();
} }
if (this.deleteItemId !== null) { if(this.deleteItemId !== null) {
this.removeItemAfterConfirm(this.deleteItemId); this.removeItemAfterConfirm(this.deleteItemId);
this.cleanConfirm(); this.cleanConfirm();
} }
@ -96,177 +96,176 @@ export class SeriesEditScene implements OnInit {
ngOnInit() { ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap); this.arianeService.updateManual(this.route.snapshot.paramMap);
this.id_series = this.arianeService.getSeriesId(); this.idSeries = this.arianeService.getSeriesId();
let self = this; let self = this;
this.listType = [{value: null, label: '---'}]; this.listType = [ { value: null, label: '---' } ];
this.typeService.getData() this.typeService.getData()
.then(function(response2) { .then((response2) => {
for(let iii= 0; iii < response2.length; iii++) { for(let iii = 0; iii < response2.length; iii++) {
self.listType.push({value: response2[iii].id, label: response2[iii].name}); self.listType.push({ value: response2[iii].id, label: response2[iii].name });
} }
}).catch(function(response2) { }).catch((response2) => {
console.log("get response22 : " + JSON.stringify(response2, null, 2)); console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
}); });
this.seriesService.get(this.id_series) this.seriesService.get(this.idSeries)
.then(function(response) { .then((response) => {
//console.log("get response of video : " + JSON.stringify(response, null, 2)); // console.log("get response of video : " + JSON.stringify(response, null, 2));
self.name = response.name; self.name = response.name;
self.type_id = response.parent_id; self.typeId = response.parentId;
self.description = response.description; self.description = response.description;
self.updateCoverList(response.covers); self.updateCoverList(response.covers);
//console.log("covers_list : " + JSON.stringify(self.covers_display, null, 2)); // console.log("covers_list : " + JSON.stringify(self.covers_display, null, 2));
self.itemIsLoading = false; self.itemIsLoading = false;
}).catch(function(response) { }).catch((response) => {
self.error = "Can not get the data"; self.error = 'Can not get the data';
self.name = ""; self.name = '';
self.description = ""; self.description = '';
self.covers_display = []; self.coversDisplay = [];
self.itemIsNotFound = true; self.itemIsNotFound = true;
self.itemIsLoading = false; self.itemIsLoading = false;
}); });
console.log("get parameter id: " + this.id_series); console.log(`get parameter id: ${ this.idSeries}`);
this.seriesService.getSeason(this.id_series, ["id", "name"]) this.seriesService.getSeason(this.idSeries, [ 'id', 'name' ])
.then(function(response) { .then((response) => {
self.seasonsCount = response.length; self.seasonsCount = response.length;
}).catch(function(response) { }).catch((response) => {
self.seasonsCount = "---"; self.seasonsCount = '---';
}); });
this.seriesService.getVideo(this.id_series) this.seriesService.getVideo(this.idSeries)
.then(function(response) { .then((response) => {
self.videoCount = response.length; self.videoCount = response.length;
}).catch(function(response) { }).catch((response) => {
self.videoCount = "---"; self.videoCount = '---';
}); });
} }
updateCoverList(_covers: any) { updateCoverList(covers: any) {
this.covers_display = []; this.coversDisplay = [];
if (_covers !== undefined && _covers !== null) { if(covers !== undefined && covers !== null) {
for (let iii=0; iii<_covers.length; iii++) { for(let iii = 0; iii < covers.length; iii++) {
this.covers_display.push({ this.coversDisplay.push({
id:_covers[iii], id:covers[iii],
url:this.seriesService.getCoverThumbnailUrl(_covers[iii]) url:this.seriesService.getCoverThumbnailUrl(covers[iii])
}); });
} }
} else { } else {
this.covers_display = [] this.coversDisplay = [];
} }
} }
onName(_value:any):void { onName(value:any):void {
this.name = _value; this.name = value;
} }
onDescription(_value:any):void { onDescription(value:any):void {
this.description = _value; this.description = value;
} }
onChangeType(_value:any):void { onChangeType(value:any):void {
console.log("Change requested of type ... " + _value); console.log(`Change requested of type ... ${ value}`);
this.type_id = _value; this.typeId = value;
if (this.type_id == undefined) { if(this.typeId === undefined) {
this.type_id = null; this.typeId = null;
} }
} }
sendValues():void { sendValues():void {
console.log("send new values...."); console.log('send new values....');
let data = { let data = {
"parent_id": this.type_id, parentId: this.typeId,
"name": this.name, name: this.name,
"description": this.description description: this.description
}; };
if (this.description === undefined) { if(this.description === undefined) {
data["description"] = null; data.description = null;
} }
this.seriesService.put(this.id_series, data); this.seriesService.put(this.idSeries, data);
} }
// At the drag drop area // At the drag drop area
// (drop)="onDropFile($event)" // (drop)="onDropFile($event)"
onDropFile(_event: DragEvent) { onDropFile(event: DragEvent) {
_event.preventDefault(); event.preventDefault();
//this.uploadFile(_event.dataTransfer.files[0]); // this.uploadFile(_event.dataTransfer.files[0]);
} }
// At the drag drop area // At the drag drop area
// (dragover)="onDragOverFile($event)" // (dragover)="onDragOverFile($event)"
onDragOverFile(_event) { onDragOverFile(event) {
_event.stopPropagation(); event.stopPropagation();
_event.preventDefault(); event.preventDefault();
} }
// At the file input element // At the file input element
// (change)="selectFile($event)" // (change)="selectFile($event)"
onChangeCover(_value:any):void { onChangeCover(value:any):void {
this.selectedFiles = _value.files this.selectedFiles = value.files;
this.coverFile = this.selectedFiles[0]; this.coverFile = this.selectedFiles[0];
console.log("select file " + this.coverFile.name); console.log(`select file ${ this.coverFile.name}`);
this.uploadCover(this.coverFile); this.uploadCover(this.coverFile);
} }
uploadCover(_file:File) { uploadCover(file:File) {
if (_file == undefined) { if(file === undefined) {
console.log("No file selected!"); console.log('No file selected!');
return; return;
} }
let self = this; let self = this;
// clean upload labels // clean upload labels
this.upload.clear(); this.upload.clear();
// display the upload pop-in // display the upload pop-in
this.popInService.open("popin-upload-progress"); this.popInService.open('popin-upload-progress');
this.seriesService.uploadCover(_file, this.id_series, function(count, total) { this.seriesService.uploadCover(file, this.idSeries, (count, total) => {
self.upload.mediaSendSize = count; self.upload.mediaSendSize = count;
self.upload.mediaSize = total; self.upload.mediaSize = total;
}) })
.then(function (response:any) { .then((response:any) => {
self.upload.result = "Cover added done"; self.upload.result = 'Cover added done';
// TODO: we retrive the whiole media ==> update data ... // we retrive the whiole media ==> update data ...
self.updateCoverList(response.covers); self.updateCoverList(response.covers);
}).catch(function (response:any) { }).catch((response:any) => {
//self.error = "Can not get the data"; // self.error = "Can not get the data";
console.log("Can not add the cover in the video..."); console.log('Can not add the cover in the video...');
}); });
} }
removeCover(_id:number) { removeCover(id:number) {
this.cleanConfirm(); this.cleanConfirm();
this.confirmDeleteComment = "Delete the cover ID: " + _id; this.confirmDeleteComment = `Delete the cover ID: ${ id}`;
this.confirmDeleteImageUrl = this.seriesService.getCoverThumbnailUrl(_id); this.confirmDeleteImageUrl = this.seriesService.getCoverThumbnailUrl(id);
this.deleteCoverId = _id; this.deleteCoverId = id;
this.popInService.open("popin-delete-confirm"); this.popInService.open('popin-delete-confirm');
} }
removeCoverAfterConfirm(_id:number) { removeCoverAfterConfirm(id:number) {
console.log("Request remove cover: " + _id); console.log(`Request remove cover: ${ id}`);
let self = this; let self = this;
this.seriesService.deleteCover(this.id_series, _id) this.seriesService.deleteCover(this.idSeries, id)
.then(function (response:any) { .then((response:any) => {
self.upload.result = "Cover remove done"; self.upload.result = 'Cover remove done';
// TODO: we retrive the whiole media ==> update data ... // we retrive the whiole media ==> update data ...
self.updateCoverList(response.covers); self.updateCoverList(response.covers);
}).catch(function (response:any) { }).catch((response:any) => {
//self.error = "Can not get the data"; // self.error = "Can not get the data";
console.log("Can not remove the cover of the video..."); console.log('Can not remove the cover of the video...');
}); });
} }
removeItem() { removeItem() {
console.log("Request remove Media..."); console.log('Request remove Media...');
this.cleanConfirm(); this.cleanConfirm();
this.confirmDeleteComment = "Delete the Series: " + this.id_series; this.confirmDeleteComment = `Delete the Series: ${ this.idSeries}`;
this.deleteItemId = this.id_series; this.deleteItemId = this.idSeries;
this.popInService.open("popin-delete-confirm"); this.popInService.open('popin-delete-confirm');
} }
removeItemAfterConfirm(_id:number) { removeItemAfterConfirm(_id:number) {
let self = this; let self = this;
this.seriesService.delete(_id) this.seriesService.delete(_id)
.then(function(response3) { .then((response3) => {
//self.data_ori = tmpp; // self.data_ori = tmpp;
//self.updateNeedSend(); // self.updateNeedSend();
self.itemIsRemoved = true; self.itemIsRemoved = true;
}).catch(function(response3) { }).catch((response3) => {
//self.updateNeedSend(); // self.updateNeedSend();
}); });
} }
} }

View File

@ -19,7 +19,7 @@
<div class="title" *ngIf="seasons.length > 1">Seasons:</div> <div class="title" *ngIf="seasons.length > 1">Seasons:</div>
<div class="title" *ngIf="seasons.length == 1">Season:</div> <div class="title" *ngIf="seasons.length == 1">Season:</div>
<div *ngFor="let data of seasons" class="item-list" (click)="onSelectSeason($event, data.id)" (auxclick)="onSelectSeason($event, data.id)"> <div *ngFor="let data of seasons" class="item-list" (click)="onSelectSeason($event, data.id)" (auxclick)="onSelectSeason($event, data.id)">
<app-element-season [id_season]="data.id"></app-element-season> <app-element-season [idSeason]="data.id"></app-element-season>
</div> </div>
</div> </div>
<div class="fill-content colomn_mutiple" *ngIf="videos.length != 0"> <div class="fill-content colomn_mutiple" *ngIf="videos.length != 0">
@ -27,7 +27,7 @@
<div class="title" *ngIf="videos.length > 1">Videos:</div> <div class="title" *ngIf="videos.length > 1">Videos:</div>
<div class="title" *ngIf="videos.length == 1">Video:</div> <div class="title" *ngIf="videos.length == 1">Video:</div>
<div *ngFor="let data of videos" class="item item-video" (click)="onSelectVideo($event, data.id)" (auxclick)="onSelectVideo($event, data.id)"> <div *ngFor="let data of videos" class="item item-video" (click)="onSelectVideo($event, data.id)" (auxclick)="onSelectVideo($event, data.id)">
<app-element-video [id_video]="data.id"></app-element-video> <app-element-video [idVideo]="data.id"></app-element-video>
</div> </div>
</div> </div>
<div class="clear"></div> <div class="clear"></div>

View File

@ -5,8 +5,7 @@
*/ */
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common';
import { fadeInAnimation } from '../../_animations/index'; import { fadeInAnimation } from '../../_animations/index';
import { SeriesService } from '../../service/series'; import { SeriesService } from '../../service/series';
@ -15,24 +14,22 @@ import { ArianeService } from '../../service/ariane';
@Component({ @Component({
selector: 'app-series', selector: 'app-series',
templateUrl: './series.html', templateUrl: './series.html',
styleUrls: ['./series.less'], styleUrls: [ './series.less' ],
animations: [fadeInAnimation], animations: [ fadeInAnimation ],
host: { '[@fadeInAnimation]': '' } host: { '[@fadeInAnimation]': '' }
}) })
export class SeriesScene implements OnInit { export class SeriesScene implements OnInit {
id_series = -1; idSeries = -1;
name: string = ""; name: string = '';
description: string = ""; description: string = '';
cover: string = "" cover: string = '';
covers: Array<string> = [] covers: Array<string> = [];
seasons_error: string = ""; seasonsError: string = '';
seasons: Array<any> = []; seasons: Array<any> = [];
videos_error: string = ""; videosError: string = '';
videos: Array<any> = []; videos: Array<any> = [];
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router,
private locate: Location,
private seriesService: SeriesService, private seriesService: SeriesService,
private arianeService: ArianeService) { private arianeService: ArianeService) {
@ -40,85 +37,84 @@ export class SeriesScene implements OnInit {
ngOnInit() { ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap); this.arianeService.updateManual(this.route.snapshot.paramMap);
//this.id_universe = parseInt(this.route.snapshot.paramMap.get('univers_id')); // this.idUniverse = parseInt(this.route.snapshot.paramMap.get('universId'));
//this.id_type = parseInt(this.route.snapshot.paramMap.get('type_id')); // this.idType = parseInt(this.route.snapshot.paramMap.get('typeId'));
this.id_series = this.arianeService.getSeriesId(); this.idSeries = this.arianeService.getSeriesId();
let self = this; let self = this;
let update_ended = { let updateEnded = {
series_metadata: false, seriesMetadata: false,
sub_saison: false, subSaison: false,
sub_video: false, subVideo: false,
} };
this.seriesService.get(this.id_series) this.seriesService.get(this.idSeries)
.then(function(response) { .then((response) => {
self.name = response.name; self.name = response.name;
self.description = response.description; self.description = response.description;
if (response.covers == undefined || response.covers == null || response.covers.length == 0) { if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
self.cover = null; self.cover = null;
self.covers = []; self.covers = [];
} else { } else {
self.cover = self.seriesService.getCoverUrl(response.covers[0]); self.cover = self.seriesService.getCoverUrl(response.covers[0]);
for (let iii=0; iii<response.covers.length; iii++) { for(let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.seriesService.getCoverUrl(response.covers[iii])); self.covers.push(self.seriesService.getCoverUrl(response.covers[iii]));
} }
} }
update_ended.series_metadata = true; updateEnded.seriesMetadata = true;
self.checkIfJumpIsNeeded(update_ended); self.checkIfJumpIsNeeded(updateEnded);
}).catch(function(response) { }).catch((response) => {
self.description = ""; self.description = '';
self.name = "???"; self.name = '???';
self.cover = null; self.cover = null;
self.covers = []; self.covers = [];
// no check just ==> an error occured on season // no check just ==> an error occured on season
}); });
console.log("get parameter id: " + this.id_series); console.log(`get parameter id: ${ this.idSeries}`);
this.seriesService.getSeason(this.id_series, ["id", "name"]) this.seriesService.getSeason(this.idSeries, [ 'id', 'name' ])
.then(function(response) { .then((response) => {
self.seasons_error = ""; self.seasonsError = '';
self.seasons = response self.seasons = response;
update_ended.sub_saison = true; updateEnded.subSaison = true;
self.checkIfJumpIsNeeded(update_ended); self.checkIfJumpIsNeeded(updateEnded);
}).catch(function(response) { }).catch((response) => {
self.seasons_error = "Can not get the list of season in this series"; self.seasonsError = 'Can not get the list of season in this series';
self.seasons = [] self.seasons = [];
update_ended.sub_saison = true; updateEnded.subSaison = true;
self.checkIfJumpIsNeeded(update_ended); self.checkIfJumpIsNeeded(updateEnded);
}); });
this.seriesService.getVideo(this.id_series) this.seriesService.getVideo(this.idSeries)
.then(function(response) { .then((response) => {
self.videos_error = ""; self.videosError = '';
self.videos = response self.videos = response;
update_ended.sub_video = true; updateEnded.subVideo = true;
self.checkIfJumpIsNeeded(update_ended); self.checkIfJumpIsNeeded(updateEnded);
}).catch(function(response) { }).catch((response) => {
self.videos_error = "Can not get the List of video without season"; self.videosError = 'Can not get the List of video without season';
self.videos = [] self.videos = [];
update_ended.sub_video = true; updateEnded.subVideo = true;
self.checkIfJumpIsNeeded(update_ended); self.checkIfJumpIsNeeded(updateEnded);
}); });
} }
onSelectSeason(_event: any, _idSelected: number):void { onSelectSeason(event: any, idSelected: number):void {
this.arianeService.navigateSeason(_idSelected, _event.which==2, _event.ctrlKey); this.arianeService.navigateSeason(idSelected, event.which === 2, event.ctrlKey);
} }
onSelectVideo(_event: any, _idSelected: number):void { onSelectVideo(event: any, idSelected: number):void {
this.arianeService.navigateVideo(_idSelected, _event.which==2, _event.ctrlKey); this.arianeService.navigateVideo(idSelected, event.which === 2, event.ctrlKey);
} }
checkIfJumpIsNeeded(update_ended: { series_metadata: boolean; sub_saison: boolean; sub_video: boolean; }): void { checkIfJumpIsNeeded(updateEnded: { seriesMetadata: boolean; subSaison: boolean; subVideo: boolean; }): void {
// all update is ended // all update is ended
if (update_ended.series_metadata == false || update_ended.sub_saison == false || update_ended.sub_video == false) { if(updateEnded.seriesMetadata === false || updateEnded.subSaison === false || updateEnded.subVideo === false) {
return; return;
} }
// no local video // no local video
if (this.videos.length > 0) { if(this.videos.length > 0) {
return; return;
} }
// only one season: // only one season:
if (this.seasons.length !== 1) { if(this.seasons.length !== 1) {
return; return;
} }
this.arianeService.navigateSeason(this.seasons[0].id, false, false, true); this.arianeService.navigateSeason(this.seasons[0].id, false, false, true);
} }
} }

View File

@ -9,17 +9,15 @@ import { ActivatedRoute } from '@angular/router';
import { ArianeService } from '../../service/ariane'; import { ArianeService } from '../../service/ariane';
@Component({ @Component({
selector: 'app-settings', selector: 'app-settings',
templateUrl: './settings.html', templateUrl: './settings.html',
styleUrls: ['./settings.less'] styleUrls: [ './settings.less' ]
}) })
export class SettingsScene implements OnInit { export class SettingsScene implements OnInit {
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private arianeService: ArianeService) { } private arianeService: ArianeService) { }
ngOnInit() { ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap); this.arianeService.updateManual(this.route.snapshot.paramMap);
} }
} }

View File

@ -5,7 +5,7 @@
*/ */
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from "@angular/router"; import { Router, ActivatedRoute } from '@angular/router';
import { checkLoginValidity, checkEmailValidity, checkPasswordValidity } from '../login/login'; import { checkLoginValidity, checkEmailValidity, checkPasswordValidity } from '../login/login';
import { fadeInAnimation } from '../../_animations/index'; import { fadeInAnimation } from '../../_animations/index';
import { UserService } from '../../service/user'; import { UserService } from '../../service/user';
@ -15,34 +15,33 @@ import { ArianeService } from '../../service/ariane';
@Component({ @Component({
selector: 'app-sign-up', selector: 'app-sign-up',
templateUrl: './sign-up.html', templateUrl: './sign-up.html',
styleUrls: ['./sign-up.less'], styleUrls: [ './sign-up.less' ],
animations: [fadeInAnimation], animations: [ fadeInAnimation ],
host: { '[@fadeInAnimation]': '' } host: { '[@fadeInAnimation]': '' }
}) })
export class SignUpScene implements OnInit { export class SignUpScene implements OnInit {
private signUpIconWrong:string = 'icon-right-not-validate';
private signUpIconWait:string = 'icon-right-load';
private signUpIconRight:string = 'icon-right-validate';
private signUp_iconWrong:string = "icon-right-not-validate"; public login:string = '';
private signUp_iconWait:string = "icon-right-load";
private signUp_iconRight:string = "icon-right-validate";
public login:string = "";
public loginOK:boolean = false; public loginOK:boolean = false;
public loginHelp:string = ""; public loginHelp:string = '';
public loginIcon:string = ""; public loginIcon:string = '';
public email:string = ""; public email:string = '';
public emailOK:boolean = false; public emailOK:boolean = false;
public emailHelp:string = ""; public emailHelp:string = '';
public emailIcon:string = ""; public emailIcon:string = '';
public password:string = ""; public password:string = '';
public passOK:boolean = false; public passOK:boolean = false;
public passHelp:string = ""; public passHelp:string = '';
public passIcon:string = ""; public passIcon:string = '';
public signUpButtonDisabled:boolean = true; public signUpButtonDisabled:boolean = true;
public error:string = ""; public error:string = '';
public rememberMe:boolean = true; public rememberMe:boolean = true;
@ -59,69 +58,68 @@ export class SignUpScene implements OnInit {
} }
updateButtonVisibility():void { updateButtonVisibility():void {
if ( this.loginOK == true if(this.loginOK === true &&
&& this.passOK == true this.passOK === true &&
&& this.emailOK == true) { this.emailOK === true) {
this.signUpButtonDisabled = false; this.signUpButtonDisabled = false;
} else { } else {
this.signUpButtonDisabled = true; this.signUpButtonDisabled = true;
} }
this.error = ""; this.error = '';
} }
checkLogin(_newValue:string):void { checkLogin(newValue:string):void {
//this.userService.loginSha("loooogin", "ekljkj", true); // this.userService.loginSha("loooogin", "ekljkj", true);
this.login = _newValue; this.login = newValue;
if ( this.login == null if(this.login === null ||
|| this.login.length == 0) { this.login.length === 0) {
this.loginOK = false; this.loginOK = false;
this.loginIcon = ""; this.loginIcon = '';
this.loginHelp = ""; this.loginHelp = '';
this.updateButtonVisibility(); this.updateButtonVisibility();
return; return;
} }
if (this.login.length < 6) { if(this.login.length < 6) {
this.loginOK = false; this.loginOK = false;
this.loginHelp = "Need 6 characters"; this.loginHelp = 'Need 6 characters';
this.loginIcon = ""; this.loginIcon = '';
this.updateButtonVisibility(); this.updateButtonVisibility();
return; return;
} }
if (checkLoginValidity(this.login) == true) { if(checkLoginValidity(this.login) === true) {
this.loginOK = false; this.loginOK = false;
//this.loginHelp = "check in progress..."; // this.loginHelp = "check in progress...";
this.loginIcon = this.signUp_iconWait; this.loginIcon = this.signUpIconWait;
let self = this; let self = this;
this.userService.checkLogin(this.login).then(function() { this.userService.checkLogin(this.login).then(() => {
// check if the answer is correct with the question // check if the answer is correct with the question
if (_newValue != self.login) { if(newValue !== self.login) {
return; return;
} }
// the login exist ... ==> it is found... // the login exist ... ==> it is found...
self.loginOK = false; self.loginOK = false;
self.loginHelp = "Login already used ..."; self.loginHelp = 'Login already used ...';
self.loginIcon = self.signUp_iconWrong; self.loginIcon = self.signUpIconWrong;
self.updateButtonVisibility();
}, (error: number) => {
console.log(`1 ${ self}`);
// check if the answer is correct with the question
if(newValue !== self.login) {
return;
}
if(error === 404) {
self.loginOK = true;
self.loginHelp = '';
self.loginIcon = self.signUpIconRight;
self.updateButtonVisibility(); self.updateButtonVisibility();
}, function(error: number) { return;
console.log("1 " + self); }
// check if the answer is correct with the question console.log(`Status ${ error}`);
if (_newValue != self.login) { self.loginOK = false;
return; self.loginHelp = 'Login already used ...';
} self.loginIcon = self.signUpIconWrong;
if (error == 404) { self.updateButtonVisibility();
self.loginOK = true; });
self.loginHelp = "";
self.loginIcon = self.signUp_iconRight;
self.updateButtonVisibility();
return;
}
console.log("Status " + error);
self.loginOK = false;
self.loginHelp = "Login already used ...";
self.loginIcon = self.signUp_iconWrong;
self.updateButtonVisibility();
});
} else { } else {
this.loginOK = false; this.loginOK = false;
this.loginHelp = 'Not valid: characters, numbers and "_-."'; this.loginHelp = 'Not valid: characters, numbers and "_-."';
@ -129,57 +127,57 @@ export class SignUpScene implements OnInit {
this.updateButtonVisibility(); this.updateButtonVisibility();
} }
checkEmail(_newValue:string):void { checkEmail(newValue:string):void {
this.email = _newValue this.email = newValue;
if ( this.email == null if(this.email === null ||
|| this.email.length == 0) { this.email.length === 0) {
this.emailOK = false; this.emailOK = false;
this.updateButtonVisibility(); this.updateButtonVisibility();
this.emailIcon = ""; this.emailIcon = '';
this.emailHelp = ""; this.emailHelp = '';
return; return;
} }
if (this.email.length < 6) { if(this.email.length < 6) {
this.emailOK = false; this.emailOK = false;
this.emailHelp = "Need 6 characters"; this.emailHelp = 'Need 6 characters';
this.updateButtonVisibility(); this.updateButtonVisibility();
this.passIcon = ""; this.passIcon = '';
return; return;
} }
if (checkEmailValidity(this.email) == true) { if(checkEmailValidity(this.email) === true) {
this.emailOK = false; this.emailOK = false;
this.emailHelp = ""; this.emailHelp = '';
//this.loginHelp = "check in progress..."; // this.loginHelp = "check in progress...";
this.emailIcon = this.signUp_iconWait; this.emailIcon = this.signUpIconWait;
let self = this; let self = this;
this.userService.checkEMail(this.email).then(function() { this.userService.checkEMail(this.email).then(() => {
// check if the answer is correct with the question // check if the answer is correct with the question
if (_newValue != self.email) { if(newValue !== self.email) {
return; return;
} }
// the email exist ... ==> it is found... // the email exist ... ==> it is found...
self.emailOK = false; self.emailOK = false;
self.emailHelp = "email already used ..."; self.emailHelp = 'email already used ...';
self.emailIcon = self.signUp_iconWrong; self.emailIcon = self.signUpIconWrong;
self.updateButtonVisibility();
}, (error: number) => {
// check if the answer is correct with the question
if(newValue !== self.email) {
return;
}
if(error === 404) {
self.emailOK = true;
self.emailHelp = '';
self.emailIcon = self.signUpIconRight;
self.updateButtonVisibility(); self.updateButtonVisibility();
}, function(error: number) { return;
// check if the answer is correct with the question }
if (_newValue != self.email) { console.log(`Status ${ error}`);
return; self.emailOK = false;
} self.emailHelp = 'email already used ...';
if (error == 404) { self.emailIcon = self.signUpIconWrong;
self.emailOK = true; self.updateButtonVisibility();
self.emailHelp = ""; });
self.emailIcon = self.signUp_iconRight;
self.updateButtonVisibility();
return;
}
console.log("Status " + error);
self.emailOK = false;
self.emailHelp = "email already used ...";
self.emailIcon = self.signUp_iconWrong;
self.updateButtonVisibility();
});
} else { } else {
this.emailOK = false; this.emailOK = false;
this.emailHelp = 'Not valid: characters, numbers, "_-." and email format: you@example.com'; this.emailHelp = 'Not valid: characters, numbers, "_-." and email format: you@example.com';
@ -187,53 +185,50 @@ export class SignUpScene implements OnInit {
this.updateButtonVisibility(); this.updateButtonVisibility();
} }
checkPassword(_newValue:string):void { checkPassword(newValue:string):void {
this.password = _newValue this.password = newValue;
console.log("ooooooooooooooo " + this.password); console.log(`ooooooooooooooo ${ this.password}`);
if (this.password == null) { if(this.password === null) {
this.passOK = false; this.passOK = false;
this.passHelp = ""; this.passHelp = '';
this.updateButtonVisibility(); this.updateButtonVisibility();
return; return;
} }
if (this.password.length < 6) { if(this.password.length < 6) {
this.passOK = false; this.passOK = false;
this.passHelp = "Need 6 characters"; this.passHelp = 'Need 6 characters';
} else if(checkPasswordValidity(this.password) === true) {
this.passOK = true;
this.passHelp = '';
} else { } else {
if (checkPasswordValidity(this.password) == true) { this.passOK = false;
this.passOK = true; this.passHelp = 'Not valid: characters, numbers and "_-:;.,?!*+=}{([|)]% @&~#/\\<>"';
this.passHelp = "";
} else {
this.passOK = false;
this.passHelp = 'Not valid: characters, numbers and "_-:;.,?!*+=}{([|)]% @&~#/\<>"';
}
} }
this.updateButtonVisibility(); this.updateButtonVisibility();
} }
onSignUp():void { onSignUp():void {
console.log("Validate ... "); console.log('Validate ... ');
if (this.signUpButtonDisabled == true) { if(this.signUpButtonDisabled === true) {
// TODO: ... notify user ... // ... notify user ...
console.log("Not permited action ... ==> control does not validate this action ..."); console.log('Not permited action ... ==> control does not validate this action ...');
return; return;
} }
let self = this; let self = this;
// disable the currect button // disable the currect button
this.signUpButtonDisabled = true; this.signUpButtonDisabled = true;
this.userService.create(this.login, this.email, this.password).then( this.userService.create(this.login, this.email, this.password).then(
function(value) { (value) => {
console.log("User created"); console.log('User created');
self.router.navigate(['login']); self.router.navigate([ 'login' ]);
//TODO : send a generic message in the pop-up enevts... self.emailHelp = "email already used ... (error 2)"; // send a generic message in the pop-up enevts... self.emailHelp = "email already used ... (error 2)";
}, function(value) { }, (value) => {
console.log("User NOT created"); console.log('User NOT created');
//TODO : send a generic message in the pop-up enevts... self.emailHelp = "email already used ... (error 2)"; // send a generic message in the pop-up enevts... self.emailHelp = "email already used ... (error 2)";
}); });
} }
onCancel():void { onCancel():void {
console.log("onCancel ... '" + this.login + "':'" + this.password + "'"); console.log(`onCancel ... '${ this.login }':'${ this.password }'`);
//$rootScope.currentModal = ""; // $rootScope.currentModal = "";
} }
} }

View File

@ -17,13 +17,13 @@
<div class="fill-content colomn_mutiple"> <div class="fill-content colomn_mutiple">
<div class="clear"></div> <div class="clear"></div>
<div *ngFor="let data of seriess" class="item" (click)="onSelectSeries($event, data.id)" (auxclick)="onSelectSeries($event, data.id)"> <div *ngFor="let data of seriess" class="item" (click)="onSelectSeries($event, data.id)" (auxclick)="onSelectSeries($event, data.id)">
<app-element-series [id_type]="type_id" [id_series]="data.id"></app-element-series> <app-element-series [idType]="typeId" [idSeries]="data.id"></app-element-series>
</div> </div>
</div> </div>
<div class="fill-content colomn_mutiple"> <div class="fill-content colomn_mutiple">
<div class="clear"></div> <div class="clear"></div>
<div *ngFor="let data of videos" class="item item-video" (click)="onSelectVideo($event, data.id)" (auxclick)="onSelectVideo($event, data.id)"> <div *ngFor="let data of videos" class="item item-video" (click)="onSelectVideo($event, data.id)" (auxclick)="onSelectVideo($event, data.id)">
<app-element-video [id_video]="data.id"></app-element-video> <app-element-video [idVideo]="data.id"></app-element-video>
</div> </div>
</div> </div>
<div class="clear"></div> <div class="clear"></div>

View File

@ -5,8 +5,7 @@
*/ */
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common';
import { fadeInAnimation } from '../../_animations/index'; import { fadeInAnimation } from '../../_animations/index';
import { TypeService } from '../../service/type'; import { TypeService } from '../../service/type';
@ -15,26 +14,25 @@ import { ArianeService } from '../../service/ariane';
@Component({ @Component({
selector: 'app-type', selector: 'app-type',
templateUrl: './type.html', templateUrl: './type.html',
styleUrls: ['./type.less'], styleUrls: [ './type.less' ],
animations: [fadeInAnimation], animations: [ fadeInAnimation ],
host: { '[@fadeInAnimation]': '' } host: { '[@fadeInAnimation]': '' }
}) })
export class TypeScene implements OnInit { export class TypeScene implements OnInit {
type_id = -1; typeId = -1;
name: string = ""; name: string = '';
description: string = ""; description: string = '';
cover:string = null; cover:string = null;
covers:string[] = []; covers:string[] = [];
seriess_error = ""; seriessError = '';
seriess = []; seriess = [];
videos_error = ""; videosError = '';
videos = []; videos = [];
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router,
private locate: Location,
private typeService: TypeService, private typeService: TypeService,
private arianeService: ArianeService) { private arianeService: ArianeService) {
/* /*
this.route.params.subscribe(params => { this.route.params.subscribe(params => {
console.log(params); console.log(params);
@ -47,52 +45,51 @@ export class TypeScene implements OnInit {
ngOnInit() { ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap); this.arianeService.updateManual(this.route.snapshot.paramMap);
this.type_id = this.arianeService.getTypeId(); this.typeId = this.arianeService.getTypeId();
let self = this; let self = this;
console.log("get parameter id: " + this.type_id); console.log(`get parameter id: ${ this.typeId}`);
this.typeService.get(this.type_id) this.typeService.get(this.typeId)
.then(function(response) { .then((response) => {
self.name = response.name; self.name = response.name;
self.description = response.description; self.description = response.description;
if (response.covers === undefined || response.covers === null || response.covers.length === 0) { if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
self.cover = null; self.cover = null;
self.covers = [] self.covers = [];
} else { } else {
self.cover = self.typeService.getCoverUrl(response.covers[0]); self.cover = self.typeService.getCoverUrl(response.covers[0]);
for (let iii=0; iii<response.covers.length; iii++) { for(let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.typeService.getCoverUrl(response.covers[iii])); self.covers.push(self.typeService.getCoverUrl(response.covers[iii]));
} }
} }
}).catch(function(response) { }).catch((response) => {
self.name = "???"; self.name = '???';
self.description = ""; self.description = '';
self.covers = []; self.covers = [];
self.cover = null; self.cover = null;
}); });
this.typeService.getSubSeries(this.type_id, ["id", "name"]) this.typeService.getSubSeries(this.typeId, [ 'id', 'name' ])
.then(function(response) { .then((response) => {
self.seriess_error = ""; self.seriessError = '';
self.seriess = response self.seriess = response;
}).catch(function(response) { }).catch((response) => {
self.seriess_error = "Wrong e-mail/login or password"; self.seriessError = 'Wrong e-mail/login or password';
self.seriess = [] self.seriess = [];
}); });
this.typeService.getSubVideo(this.type_id, ["id", "name"]) this.typeService.getSubVideo(this.typeId, [ 'id', 'name' ])
.then(function(response) { .then((response) => {
self.videos_error = ""; self.videosError = '';
self.videos = response self.videos = response;
}).catch(function(response) { }).catch((response) => {
self.videos_error = "Wrong e-mail/login or password"; self.videosError = 'Wrong e-mail/login or password';
self.videos = [] self.videos = [];
}); });
} }
onSelectSeries(_event: any, _idSelected: number):void { onSelectSeries(event: any, idSelected: number):void {
this.arianeService.navigateSeries(_idSelected, _event.which==2, _event.ctrlKey); this.arianeService.navigateSeries(idSelected, event.which === 2, event.ctrlKey);
} }
onSelectVideo(_event: any, _idSelected: number):void { onSelectVideo(event: any, idSelected: number):void {
this.arianeService.navigateVideo(_idSelected, _event.which==2, _event.ctrlKey); this.arianeService.navigateVideo(idSelected, event.which === 2, event.ctrlKey);
} }
} }

View File

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

View File

@ -6,62 +6,57 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router'; import { Router, ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common';
import { fadeInAnimation } from '../../_animations/index'; import { fadeInAnimation } from '../../_animations/index';
import { UniverseService } from '../../service/universe';
import { ArianeService } from '../../service/ariane'; import { ArianeService } from '../../service/ariane';
import { environment } from '../../../environments/environment'; import { environment } from '../../../environments/environment';
@Component({ @Component({
selector: 'app-universe', selector: 'app-universe',
templateUrl: './universe.html', templateUrl: './universe.html',
styleUrls: ['./universe.less'], styleUrls: [ './universe.less' ],
animations: [fadeInAnimation], animations: [ fadeInAnimation ],
host: { '[@fadeInAnimation]': '' } host: { '[@fadeInAnimation]': '' }
}) })
export class UniverseScene implements OnInit { export class UniverseScene implements OnInit {
universe_id = -1; universeId = -1;
videos_error = ""; videosError = '';
videos = []; videos = [];
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router, private router: Router,
private locate: Location,
private universeService: UniverseService,
private arianeService: ArianeService) { private arianeService: ArianeService) {
} }
ngOnInit() { ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap); this.arianeService.updateManual(this.route.snapshot.paramMap);
this.universe_id = this.arianeService.getUniverseId(); this.universeId = this.arianeService.getUniverseId();
let self = this; console.log(`get parameter id: ${ this.universeId}`);
console.log("get parameter id: " + this.universe_id);
/* /*
this.universeService.getVideo(this.univers_id) let self = this;
this.universeService.getVideo(this.universId)
.then(function(response) { .then(function(response) {
self.videos_error = ""; self.videosError = "";
self.videos = response self.videos = response
}).catch(function(response) { }).catch(function(response) {
self.videos_error = "Can not get the List of video without season"; self.videosError = "Can not get the List of video without season";
self.videos = [] self.videos = []
}); });
*/ */
} }
onSelectVideo(_event: any, _idSelected: number):void { onSelectVideo(event: any, idSelected: number):void {
if(_event.which==2) { if(event.which === 2) {
if (environment.frontBaseUrl === undefined || environment.frontBaseUrl === null || environment.frontBaseUrl === "") { if(environment.frontBaseUrl === undefined || environment.frontBaseUrl === null || environment.frontBaseUrl === '') {
window.open('/video/' + _idSelected); window.open(`/video/${ idSelected}`);
} else { } else {
window.open("/" + environment.frontBaseUrl + '/video/' + _idSelected); window.open(`/${ environment.frontBaseUrl }/video/${ idSelected}`);
} }
} else { } else {
this.router.navigate(['video/' + _idSelected ]); this.router.navigate([ `video/${ idSelected}` ]);
this.arianeService.setVideo(_idSelected); this.arianeService.setVideo(idSelected);
} }
} }
} }

View File

@ -157,7 +157,7 @@
<div class="clear"></div> <div class="clear"></div>
<div class="send_value"> <div class="send_value">
<button class="button fill-x color-button-validate color-shadow-black" <button class="button fill-x color-button-validate color-shadow-black"
[disabled]="!need_send" [disabled]="!needSend"
(click)="sendFile()" (click)="sendFile()"
type="submit"> type="submit">
<i class="material-icons">cloud_upload</i> Upload <i class="material-icons">cloud_upload</i> Upload

View File

@ -36,34 +36,34 @@ export class FileParsedElement {
public season: number, public season: number,
public episode: number, public episode: number,
public title: string) { public title: string) {
// nothiing to do. // nothiing to do.
} }
} }
export class FileFailParsedElement { export class FileFailParsedElement {
constructor( constructor(
public file: File, public file: File,
public reason: string) { public reason: string) {
// nothiing to do. // nothiing to do.
} }
} }
@Component({ @Component({
selector: 'app-video-edit', selector: 'app-video-edit',
templateUrl: './upload.html', templateUrl: './upload.html',
styleUrls: ['./upload.less'], styleUrls: [ './upload.less' ],
animations: [fadeInAnimation], animations: [ fadeInAnimation ],
host: { '[@fadeInAnimation]': '' } host: { '[@fadeInAnimation]': '' }
}) })
export class UploadScene implements OnInit { export class UploadScene implements OnInit {
parsedElement: FileParsedElement[] = []; parsedElement: FileParsedElement[] = [];
parsedFailedElement: FileFailParsedElement[] = []; parsedFailedElement: FileFailParsedElement[] = [];
upload_file_value: string = "" uploadFileValue: string = '';
selectedFiles: FileList; selectedFiles: FileList;
type_id: number = null typeId: number = null;
series_id: number = null seriesId: number = null;
saison_id: number = null saisonId: number = null;
need_send: boolean = false; needSend: boolean = false;
// list of all files already registered in the bdd to compare with the curent list of files. // list of all files already registered in the bdd to compare with the curent list of files.
listFileInBdd: any = null; listFileInBdd: any = null;
@ -80,7 +80,8 @@ export class UploadScene implements OnInit {
listSeries: ElementList[] = [ listSeries: ElementList[] = [
{ value: null, label: '---' }, { value: null, label: '---' },
]; ];
listSeries2 = [{ id: null, description: '---' }]; listSeries2 = [ { id: null, description: '---' } ];
/* /*
config = { config = {
displayKey: "label", // if objects array passed which key to be displayed defaults to description displayKey: "label", // if objects array passed which key to be displayed defaults to description
@ -89,23 +90,23 @@ export class UploadScene implements OnInit {
}; };
*/ */
config = { config = {
displayKey: "description", //if objects array passed which key to be displayed defaults to description displayKey: 'description', // if objects array passed which key to be displayed defaults to description
search: true, //true/false for the search functionlity defaults to false, search: true, // true/false for the search functionlity defaults to false,
height: 'auto', //height of the list so that if there are more no of items it can show a scroll defaults to auto. With auto height scroll will never appear height: 'auto', // height of the list so that if there are more no of items it can show a scroll defaults to auto. With auto height scroll will never appear
placeholder: 'Select', // text to be displayed when no item is selected defaults to Select, placeholder: 'Select', // text to be displayed when no item is selected defaults to Select,
customComparator: ()=>{}, // a custom function using which user wants to sort the items. default is undefined and Array.sort() will be used in that case, customComparator: () => {}, // a custom function using which user wants to sort the items. default is undefined and Array.sort() will be used in that case,
limitTo: 10, // number thats limits the no of options displayed in the UI (if zero, options will not be limited) limitTo: 10, // number thats limits the no of options displayed in the UI (if zero, options will not be limited)
moreText: 'more', // text to be displayed whenmore than one items are selected like Option 1 + 5 more moreText: 'more', // text to be displayed whenmore than one items are selected like Option 1 + 5 more
noResultsFound: 'No results found!', // text to be displayed when no items are found while searching noResultsFound: 'No results found!', // text to be displayed when no items are found while searching
searchPlaceholder: 'Search', // label thats displayed in search input, searchPlaceholder: 'Search', // label thats displayed in search input,
searchOnKey: 'description', // key on which search should be performed this will be selective search. if undefined this will be extensive search on all keys searchOnKey: 'description', // key on which search should be performed this will be selective search. if undefined this will be extensive search on all keys
} };
listSeason: ElementList[] = [ listSeason: ElementList[] = [
{ value: null, label: '---' }, { value: null, label: '---' },
]; ];
global_universe: string = ""; globalUniverse: string = '';
global_series: string = ""; globalSeries: string = '';
global_season: number = null; globalSeason: number = null;
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private typeService: TypeService, private typeService: TypeService,
private universeService: UniverseService, private universeService: UniverseService,
@ -117,86 +118,84 @@ export class UploadScene implements OnInit {
// nothing to do. // nothing to do.
} }
updateNeedSend (): boolean { updateNeedSend(): boolean {
if (this.parsedElement.length === 0) { if(this.parsedElement.length === 0) {
this.need_send = false; this.needSend = false;
return; return;
} }
this.need_send = true; this.needSend = true;
for (let iii = 0; iii< this.parsedElement.length; iii++) { for(let iii = 0; iii < this.parsedElement.length; iii++) {
if (this.parsedElement[iii].title === undefined || this.parsedElement[iii].title === null || this.parsedElement[iii].title === "") { if(this.parsedElement[iii].title === undefined || this.parsedElement[iii].title === null || this.parsedElement[iii].title === '') {
this.need_send = false; this.needSend = false;
} }
} }
if (this.type_id === undefined || this.type_id === null) { if(this.typeId === undefined || this.typeId === null) {
this.need_send = false; this.needSend = false;
} }
return this.need_send; return this.needSend;
} }
ngOnInit () { ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap); this.arianeService.updateManual(this.route.snapshot.paramMap);
let self = this; let self = this;
this.listType = [{ value: null, label: '---' }]; this.listType = [ { value: null, label: '---' } ];
this.listUniverse = [{ value: null, label: '---' }]; this.listUniverse = [ { value: null, label: '---' } ];
this.listSeries = [{ value: null, label: '---' }]; this.listSeries = [ { value: null, label: '---' } ];
this.listSeason = [{ value: null, label: '---' }]; this.listSeason = [ { value: null, label: '---' } ];
this.universeService.getData() this.universeService.getData()
.then(function (response2) { .then((response2) => {
for (let iii = 0; iii < response2.length; iii++) { for(let iii = 0; iii < response2.length; iii++) {
self.listUniverse.push({ value: response2[iii].id, label: response2[iii].name }); self.listUniverse.push({ value: response2[iii].id, label: response2[iii].name });
} }
}).catch(function (response2) { }).catch((response2) => {
console.log("get response22 : " + JSON.stringify(response2, null, 2)); console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
}); });
this.typeService.getData() this.typeService.getData()
.then(function (response2) { .then((response2) => {
for (let iii = 0; iii < response2.length; iii++) { for(let iii = 0; iii < response2.length; iii++) {
self.listType.push({ value: response2[iii].id, label: response2[iii].name }); self.listType.push({ value: response2[iii].id, label: response2[iii].name });
} }
}).catch(function (response2) { }).catch((response2) => {
console.log("get response22 : " + JSON.stringify(response2, null, 2)); console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
}); });
console.log(" END INIT "); console.log(' END INIT ');
} }
onChangeType (_value: any): void { onChangeType(value: any): void {
this.series_id = null; this.seriesId = null;
this.updateType (_value); this.updateType(value);
} }
private updateType (_value: any): void { private updateType(value: any): void {
console.log("Change requested of type ... " + _value); console.log(`Change requested of type ... ${ value}`);
if (this.type_id == _value) { if(this.typeId === value) {
return; return;
} }
this.type_id = _value; this.typeId = value;
//this.data.series_id = null; // this.data.series_id = null;
//this.data.season_id = null; // this.data.season_id = null;
this.listSeries = [{value: null, label: '---'}]; this.listSeries = [ { value: null, label: '---' } ];
this.listSeason = [{value: null, label: '---'}]; this.listSeason = [ { value: null, label: '---' } ];
let self = this; let self = this;
this.updateNeedSend(); this.updateNeedSend();
if (this.type_id != null) { if(this.typeId !== null) {
self.typeService.getSubSeries(this.type_id, ["id", "name"]) self.typeService.getSubSeries(this.typeId, [ 'id', 'name' ])
.then(function(response2) { .then((response2) => {
for(let iii= 0; iii < response2.length; iii++) { for(let iii = 0; iii < response2.length; iii++) {
self.listSeries.push({value: response2[iii].id, label: response2[iii].name}); self.listSeries.push({ value: response2[iii].id, label: response2[iii].name });
} }
}).catch(function(response2) { }).catch((response2) => {
console.log("get response22 : " + JSON.stringify(response2, null, 2)); console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
}); });
} }
} }
onChangeSeries (_value: any): void { onChangeSeries(value: any): void {
this.series_id = _value; this.seriesId = value;
if (_value === undefined || _value === null) { if(!(value === undefined || value === null)) {
for(let iii = 0; iii < this.listSeries.length; iii++) {
} else { if(this.listSeries[iii].value === value) {
for (let iii = 0 ; iii<this.listSeries.length ; iii++) { this.globalSeries = this.listSeries[iii].label;
if (this.listSeries[iii].value == _value) {
this.global_series = this.listSeries[iii].label;
break; break;
} }
} }
@ -204,151 +203,149 @@ export class UploadScene implements OnInit {
this.updateNeedSend(); this.updateNeedSend();
this.updateListOfVideoToCheck(); this.updateListOfVideoToCheck();
} }
onSeason (_value: any): void { onSeason(value: any): void {
this.global_season = _value; this.globalSeason = value;
//console.log("change episode ID: " + _value + " ==> " + this.parse_season.toString()); // console.log("change episode ID: " + value + " ==> " + this.parseSeason.toString());
this.updateNeedSend(); this.updateNeedSend();
this.updateListOfVideoToCheck(); this.updateListOfVideoToCheck();
} }
onTitle (data: FileParsedElement, _value: any): void { onTitle(data: FileParsedElement, value: any): void {
data.title = _value; data.title = value;
this.updateNeedSend(); this.updateNeedSend();
} }
removeElmentFromList (data: FileParsedElement, _value: any): void { removeElmentFromList(data: FileParsedElement, value: any): void {
for (let iii=0; iii< this.parsedElement.length; iii++) { for(let iii = 0; iii < this.parsedElement.length; iii++) {
if (this.parsedElement[iii] === data) { if(this.parsedElement[iii] === data) {
this.parsedElement.splice(iii, 1); this.parsedElement.splice(iii, 1);
break; break;
} }
} }
this.parsedFailedElement.push(new FileFailParsedElement(data.file, "Removed by user.")); this.parsedFailedElement.push(new FileFailParsedElement(data.file, 'Removed by user.'));
this.updateNeedSend(); this.updateNeedSend();
} }
onUniverse (_value: any): void { onUniverse(value: any): void {
this.global_universe = _value; this.globalUniverse = value;
this.updateNeedSend(); this.updateNeedSend();
} }
onEpisode (data: FileParsedElement, _value: any): void { onEpisode(data: FileParsedElement, value: any): void {
data.episode = _value; data.episode = value;
//console.log("change episode ID: " + _value + " ==> " + this.parse_episode.toString()); // console.log("change episode ID: " + value + " ==> " + this.parseEpisode.toString());
this.updateNeedSend(); this.updateNeedSend();
} }
onSeries (_value: any): void { onSeries(value: any): void {
this.global_series = _value; this.globalSeries = value;
let self = this; let self = this;
if (this.global_series != "") { if(this.globalSeries !== '') {
this.seriesService.getLike(this.global_series) this.seriesService.getLike(this.globalSeries)
.then(function(response: any[]) { .then((response: any[]) => {
console.log("find element: " + response.length); console.log(`find element: ${ response.length}`);
for (let iii = 0; iii<response.length; iii++) { for(let iii = 0; iii < response.length; iii++) {
console.log(" - " + JSON.stringify(response[iii])); console.log(` - ${ JSON.stringify(response[iii])}`);
} }
if (response.length == 0) { if(response.length === 0) {
self.series_id = null; self.seriesId = null;
} else if (response.length == 1) { } else if(response.length === 1) {
self.series_id = response[0].id; self.seriesId = response[0].id;
} }
this.updateListOfVideoToCheck(); self.updateListOfVideoToCheck();
}).catch(function(response) { }).catch((response) => {
console.log("CAN NOT find element: " ); console.log('CAN NOT find element: ');
self.series_id = null; self.seriesId = null;
}); });
} }
this.updateNeedSend(); this.updateNeedSend();
} }
clearData() { clearData() {
this.global_universe = ""; this.globalUniverse = '';
this.global_series = ""; this.globalSeries = '';
this.global_season = null; this.globalSeason = null;
this.parsedElement = []; this.parsedElement = [];
this.parsedFailedElement = []; this.parsedFailedElement = [];
this.listFileInBdd = null; this.listFileInBdd = null;
this.type_id = null; this.typeId = null;
this.series_id = null; this.seriesId = null;
this.saison_id = null; this.saisonId = null;
this.listSeries = [{value: null, label: '---'}]; this.listSeries = [ { value: null, label: '---' } ];
this.listSeason = [{value: null, label: '---'}]; this.listSeason = [ { value: null, label: '---' } ];
} }
addFileWithMetaData(file: File) { addFileWithMetaData(file: File) {
//parsedElement: FileParsedElement[] = []; // parsedElement: FileParsedElement[] = [];
let universe: string = null; let universe: string = null;
let series: string = null; let series: string = null;
let season: number | null = null; let season: number | null = null;
let episode: number | null = null; let episode: number | null = null;
let title: string = ""; let title: string = '';
console.log("select file " + file.name); console.log(`select file ${ file.name}`);
let tmpName = file.name.replace(/[ \t]*-[ \t]*/g,'-'); let tmpName = file.name.replace(/[ \t]*-[ \t]*/g, '-');
tmpName = tmpName.replace(/[Ss]([0-9]+)[- \t]+[Ee]([0-9]+)/g,'-s$1-e$2-'); tmpName = tmpName.replace(/[Ss]([0-9]+)[- \t]+[Ee]([0-9]+)/g, '-s$1-e$2-');
tmpName = tmpName.replace(/[Ee]([0-9]+)[- \t]+[Ss]([0-9]+)/g,'-s$2-e$1-'); tmpName = tmpName.replace(/[Ee]([0-9]+)[- \t]+[Ss]([0-9]+)/g, '-s$2-e$1-');
tmpName = tmpName.replace(/_/g,'-'); tmpName = tmpName.replace(/_/g, '-');
tmpName = tmpName.replace(/--/g,'-'); tmpName = tmpName.replace(/--/g, '-');
console.log("select file " + tmpName); console.log(`select file ${ tmpName}`);
const splitElement = tmpName.split('-'); const splitElement = tmpName.split('-');
if (splitElement.length == 1) { if(splitElement.length === 1) {
title = splitElement[0]; title = splitElement[0];
} else { } else {
if (splitElement.length>=2) { if(splitElement.length >= 2) {
series = splitElement[0]; series = splitElement[0];
} }
splitElement.splice(0,1); splitElement.splice(0, 1);
if (splitElement.length == 1) { if(splitElement.length === 1) {
title = splitElement[0]; title = splitElement[0];
} else { } else {
while (splitElement.length>0) { while(splitElement.length > 0) {
let element = splitElement[0]; let element = splitElement[0];
let find = false; let find = false;
if (season === null) { if(season === null) {
if (element.length >= 1 && (element[0] === 's' || element[0] === 'S') ) { if(element.length >= 1 && (element[0] === 's' || element[0] === 'S')) {
element = element.substring(1); element = element.substring(1);
season = parseInt(element, 10); season = parseInt(element, 10);
find = true; find = true;
} }
} }
if (episode === null && find === false) { if(episode === null && find === false) {
if (element.length >= 1 && (element[0] === 'e' || element[0] === 'E') ) { if(element.length >= 1 && (element[0] === 'e' || element[0] === 'E')) {
element = element.substring(1); element = element.substring(1);
episode = parseInt(element, 10); episode = parseInt(element, 10);
find = true; find = true;
} }
} }
if (find === false) { if(find === false) {
if (season === null && episode === null) { if(season === null && episode === null) {
if (universe === "") { if(universe === '') {
universe = element; universe = element;
} else { } else {
universe = universe + "-" + element; universe = `${universe }-${ element}`;
} }
} else if(title === '') {
title = element;
} else { } else {
if (title === "") { title = `${title }-${ element}`;
title = element;
} else {
title = title + "-" + element;
}
} }
} }
splitElement.splice(0,1); splitElement.splice(0, 1);
} }
} }
} }
if (isNaN(episode)) { if(isNaN(episode)) {
episode = null; episode = null;
} }
if (isNaN(season)) { if(isNaN(season)) {
season = null; season = null;
} }
// remove extention // remove extention
title = title.replace(new RegExp("\.(mkv|MKV|Mkv|webm|WEBM|Webm|mp4)"),""); 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, universe, series, season, episode, title);
console.log("==>" + JSON.stringify(tmp)); console.log(`==>${ JSON.stringify(tmp)}`);
// add it in the list. // add it in the list.
this.parsedElement.push(tmp); this.parsedElement.push(tmp);
} }
@ -356,85 +353,84 @@ export class UploadScene implements OnInit {
// At the file input element // At the file input element
// (change)="selectFile($event)" // (change)="selectFile($event)"
onChangeFile (_value: any): void { onChangeFile(value: any): void {
this.clearData(); this.clearData();
for (let iii=0; iii<_value.files.length; iii++) { for(let iii = 0; iii < value.files.length; iii++) {
this.addFileWithMetaData(_value.files[iii]); this.addFileWithMetaData(value.files[iii]);
} }
// check if all global parameters are generic: // check if all global parameters are generic:
if (this.parsedElement.length == 0) { if(this.parsedElement.length === 0) {
this.updateNeedSend(); this.updateNeedSend();
return; return;
} }
// we verify fith the first value to remove all unknown ... // we verify fith the first value to remove all unknown ...
// clean different univers: // clean different univers:
for (let iii=1; iii<this.parsedElement.length; iii++) { 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 + "'"); 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) { 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")); this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, 'Remove from list due to wrong universe value'));
console.log("Remove from list (!= universe) : [" + (iii+1) + "/" + this.parsedElement.length + "] '" + this.parsedElement[iii].file.name + "'"); console.log(`Remove from list (!= universe) : [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[iii].file.name }'`);
this.parsedElement.splice(iii,1); this.parsedElement.splice(iii, 1);
iii--; iii--;
} }
} }
// clean different series: // clean different series:
for (let iii=1; iii<this.parsedElement.length; iii++) { 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 + "'"); console.log(`check series [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[0].series } !== ${ this.parsedElement[iii].series }'`);
if (this.parsedElement[0].series !== this.parsedElement[iii].series) { if(this.parsedElement[0].series !== this.parsedElement[iii].series) {
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, "Remove from list due to wrong series value")); this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, 'Remove from list due to wrong series value'));
console.log("Remove from list (!= series) : [" + (iii+1) + "/" + this.parsedElement.length + "] '" + this.parsedElement[iii].file.name + "'"); console.log(`Remove from list (!= series) : [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[iii].file.name }'`);
this.parsedElement.splice(iii,1); this.parsedElement.splice(iii, 1);
iii--; iii--;
} }
} }
// clean different season: // clean different season:
for (let iii=1; iii<this.parsedElement.length; iii++) { for(let iii = 1; iii < this.parsedElement.length; iii++) {
console.log("check season [" + (iii+1) + "/" + this.parsedElement.length + "] '" + this.parsedElement[0].season + " !== " + this.parsedElement[iii].season + "'"); console.log(`check season [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[0].season } !== ${ this.parsedElement[iii].season }'`);
if (this.parsedElement[0].season !== this.parsedElement[iii].season) { if(this.parsedElement[0].season !== this.parsedElement[iii].season) {
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, "Remove from list due to wrong season value")); this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, 'Remove from list due to wrong season value'));
console.log("Remove from list (!= season) : [" + (iii+1) + "/" + this.parsedElement.length + "] '" + this.parsedElement[iii].file.name + "'"); console.log(`Remove from list (!= season) : [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[iii].file.name }'`);
this.parsedElement.splice(iii,1); this.parsedElement.splice(iii, 1);
iii--; iii--;
} }
} }
this.global_universe = this.parsedElement[0].universe; this.globalUniverse = this.parsedElement[0].universe;
this.global_series = this.parsedElement[0].series; this.globalSeries = this.parsedElement[0].series;
this.global_season = this.parsedElement[0].season; this.globalSeason = this.parsedElement[0].season;
this.updateNeedSend(); this.updateNeedSend();
this.series_id = null; this.seriesId = null;
this.saison_id = null; this.saisonId = null;
let self = this; let self = this;
if (this.global_series != "") { if(this.globalSeries !== '') {
this.seriesService.getLike(this.global_series) this.seriesService.getLike(this.globalSeries)
.then(function(response: any[]) { .then((response: any[]) => {
console.log("find element: " + response.length); console.log(`find element: ${ response.length}`);
for (let iii = 0; iii<response.length; iii++) { for(let iii = 0; iii < response.length; iii++) {
console.log(" - " + JSON.stringify(response[iii])); console.log(` - ${ JSON.stringify(response[iii])}`);
} }
if (response.length == 0) { if(response.length === 0) {
self.series_id = null; self.seriesId = null;
} else if (response.length == 1) { } else if(response.length === 1) {
let serie_elem = response[0]; let serieElem = response[0];
self.series_id = serie_elem.id; self.seriesId = serieElem.id;
self.updateType(serie_elem.parent_id); self.updateType(serieElem.parentId);
} }
self.updateListOfVideoToCheck(); self.updateListOfVideoToCheck();
}).catch(function(response) { }).catch((response) => {
console.log("CAN NOT find element: " ); console.log('CAN NOT find element: ');
}); });
} }
} }
sendFile(): void { sendFile(): void {
console.log("Send file requested ... " + this.parsedElement.length); console.log(`Send file requested ... ${ this.parsedElement.length}`);
this.upload = new UploadProgress(); this.upload = new UploadProgress();
// display the upload pop-in // display the upload pop-in
this.popInService.open("popin-upload-progress"); this.popInService.open('popin-upload-progress');
this.globalUpLoad(0, this.parsedElement.length); this.globalUpLoad(0, this.parsedElement.length);
} }
@ -442,114 +438,113 @@ export class UploadScene implements OnInit {
let self = this; let self = this;
this.uploadFile(this.parsedElement[id], id, total, () => { this.uploadFile(this.parsedElement[id], id, total, () => {
let id2 = id + 1; let id2 = id + 1;
if (id2 < total) { if(id2 < total) {
self.globalUpLoad(id2, total); self.globalUpLoad(id2, total);
} else { } else {
self.upload.result = "Media creation done"; self.upload.result = 'Media creation done';
} }
}, (value:string) => { }, (value:string) => {
self.upload.error = "Error in the upload of the data..." + value; self.upload.error = `Error in the upload of the data...${ value}`;
}); });
} }
uploadFile (eleemnent: FileParsedElement, id: number, total: number, _sendDone: any, _errorOccured: any): void { uploadFile(eleemnent: FileParsedElement, id: number, total: number, sendDone: any, errorOccured: any): void {
let self = this; let self = this;
self.upload.labelMediaTitle = ''; self.upload.labelMediaTitle = '';
// add universe // add universe
if (self.global_universe !== null) { if(self.globalUniverse !== null) {
self.upload.labelMediaTitle += self.global_universe; self.upload.labelMediaTitle = self.upload.labelMediaTitle + self.globalUniverse;
} }
// add series // add series
if (self.global_series !== null) { if(self.globalSeries !== null) {
if (self.upload.labelMediaTitle.length != 0) { if(self.upload.labelMediaTitle.length !== 0) {
self.upload.labelMediaTitle += ":"; self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }:`;
} }
self.upload.labelMediaTitle += self.global_series; self.upload.labelMediaTitle = self.upload.labelMediaTitle + self.globalSeries;
} }
// add season // add season
if (self.global_season !== null && self.global_season !== undefined && self.global_season.toString().length != 0) { if(self.globalSeason !== null && self.globalSeason !== undefined && self.globalSeason.toString().length !== 0) {
if (self.upload.labelMediaTitle.length != 0) { if(self.upload.labelMediaTitle.length !== 0) {
self.upload.labelMediaTitle += "-"; self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }-`;
} }
self.upload.labelMediaTitle += "s" + self.global_season.toString(); self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }s${ self.globalSeason.toString()}`;
} }
// add episode ID // add episode ID
if (eleemnent.episode !== null && eleemnent.episode !== undefined && eleemnent.episode.toString().length != 0) { if(eleemnent.episode !== null && eleemnent.episode !== undefined && eleemnent.episode.toString().length !== 0) {
if (self.upload.labelMediaTitle.length != 0) { if(self.upload.labelMediaTitle.length !== 0) {
self.upload.labelMediaTitle += "-"; self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }-`;
} }
self.upload.labelMediaTitle += "e" + eleemnent.episode.toString(); self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }e${ eleemnent.episode.toString()}`;
} }
// add title // add title
if (self.upload.labelMediaTitle.length != 0) { if(self.upload.labelMediaTitle.length !== 0) {
self.upload.labelMediaTitle += "-"; self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }-`;
} }
self.upload.labelMediaTitle = '[' + (id+1) + '/' + total + ']' + self.upload.labelMediaTitle + eleemnent.title; self.upload.labelMediaTitle = `[${ id + 1 }/${ total }]${ self.upload.labelMediaTitle }${eleemnent.title}`;
self.videoService.uploadFile(eleemnent.file, self.videoService.uploadFile(eleemnent.file,
self.global_universe, self.globalUniverse,
self.global_series, self.globalSeries,
self.series_id, self.seriesId,
self.global_season, self.globalSeason,
eleemnent.episode, eleemnent.episode,
eleemnent.title, eleemnent.title,
self.type_id, self.typeId,
function(count, total) { (count, totalTmp) => {
//console.log("upload : " + count*100/total); // console.log("upload : " + count*100/totalTmp);
self.upload.mediaSendSize = count; self.upload.mediaSendSize = count;
self.upload.mediaSize = total; self.upload.mediaSize = totalTmp;
}) })
.then(function (response) { .then((response) => {
console.log("get response of video : " + JSON.stringify(response, null, 2)); console.log(`get response of video : ${ JSON.stringify(response, null, 2)}`);
_sendDone(); sendDone();
}).catch(function (response) { }).catch((response) => {
//self.error = "Can not get the data"; // self.error = "Can not get the data";
console.log("Can not add the data in the system..."); console.log('Can not add the data in the system...');
_errorOccured(JSON.stringify(response, null, 2)); errorOccured(JSON.stringify(response, null, 2));
}); });
} }
public checkSimilarString(valueA:string, valueB:string): boolean { public checkSimilarString(valueA:string, valueB:string): boolean {
let valueAL = valueA.toLowerCase(); let valueAL = valueA.toLowerCase();
let valueBL = valueB.toLowerCase(); let valueBL = valueB.toLowerCase();
valueAL = valueAL.replace(/[ \t\n\r-_#~@]/g, ""); valueAL = valueAL.replace(/[ \t\n\r-_#~@]/g, '');
valueBL = valueBL.replace(/[ \t\n\r-_#~@]/g, ""); valueBL = valueBL.replace(/[ \t\n\r-_#~@]/g, '');
if (valueAL == valueBL) { if(valueAL === valueBL) {
return true; return true;
} }
if (valueAL.startsWith(valueBL)) { if(valueAL.startsWith(valueBL)) {
return true; return true;
} }
if (valueBL.startsWith(valueAL)) { if(valueBL.startsWith(valueAL)) {
return true; return true;
} }
return false; return false;
} }
checkConcordence():void { checkConcordence():void {
if (this.parsedElement === null) { if(this.parsedElement === null) {
return; return;
} }
// ckear checker // ckear checker
for (let iii = 0; iii < this.parsedElement.length; iii++) { for(let iii = 0; iii < this.parsedElement.length; iii++) {
this.parsedElement[iii].nameDetected = false; this.parsedElement[iii].nameDetected = false;
this.parsedElement[iii].episodeDetected = false; this.parsedElement[iii].episodeDetected = false;
} }
if (this.listFileInBdd === null) { if(this.listFileInBdd === null) {
return; return;
} }
for (let iii = 0; iii < this.listFileInBdd.length; iii++) { for(let iii = 0; iii < this.listFileInBdd.length; iii++) {
this.listFileInBdd[iii].nameDetected = false; this.listFileInBdd[iii].nameDetected = false;
this.listFileInBdd[iii].episodeDetected = false; this.listFileInBdd[iii].episodeDetected = false;
} }
for (let iii = 0; iii < this.parsedElement.length; iii++) { for(let iii = 0; iii < this.parsedElement.length; iii++) {
for (let jjj = 0; jjj < this.listFileInBdd.length; jjj++) { for(let jjj = 0; jjj < this.listFileInBdd.length; jjj++) {
if (this.checkSimilarString(this.parsedElement[iii].title, this.listFileInBdd[jjj].name)) { if(this.checkSimilarString(this.parsedElement[iii].title, this.listFileInBdd[jjj].name)) {
this.parsedElement[iii].nameDetected = true; this.parsedElement[iii].nameDetected = true;
this.listFileInBdd[jjj].nameDetected = true; this.listFileInBdd[jjj].nameDetected = true;
} }
if (this.parsedElement[iii].episode === this.listFileInBdd[jjj].episode) { if(this.parsedElement[iii].episode === this.listFileInBdd[jjj].episode) {
this.parsedElement[iii].episodeDetected = true; this.parsedElement[iii].episodeDetected = true;
this.listFileInBdd[jjj].episodeDetected = true; this.listFileInBdd[jjj].episodeDetected = true;
} }
@ -559,92 +554,89 @@ export class UploadScene implements OnInit {
updateListOfVideoToCheck(): void { updateListOfVideoToCheck(): void {
// No series ID set ==> nothing to do. // No series ID set ==> nothing to do.
if (this.series_id === null) { if(this.seriesId === null) {
this.listFileInBdd = null; this.listFileInBdd = null;
return; return;
} }
let self = this; let self = this;
// no season check only the series files. // no season check only the series files.
if (this.global_season === null) { if(this.globalSeason === null) {
self.seriesService.getVideo(self.series_id) self.seriesService.getVideo(self.seriesId)
.then(function(response: any[]) { .then((response: any[]) => {
self.listFileInBdd = response; self.listFileInBdd = response;
//console.log("find video: " + response.length); // console.log("find video: " + response.length);
//for (let iii = 0; iii<response.length; iii++) { // for (let iii = 0; iii<response.length; iii++) {
// console.log(" - " + JSON.stringify(response[iii])); // console.log(" - " + JSON.stringify(response[iii]));
//} // }
self.checkConcordence(); self.checkConcordence();
}).catch(function(response) { }).catch((response) => {
self.listFileInBdd = null; self.listFileInBdd = null;
}) });
return; return;
} }
self.saison_id = null; self.saisonId = null;
// set 1 find the ID of the season: // set 1 find the ID of the season:
this.seriesService.getSeason(this.series_id, [ "id" , "name" ]) this.seriesService.getSeason(this.seriesId, [ 'id', 'name' ])
.then(function(response: any[]) { .then((response: any[]) => {
//console.log("find season: " + response.length); // console.log("find season: " + response.length);
for (let iii = 0; iii<response.length; iii++) { for(let iii = 0; iii < response.length; iii++) {
//console.log(" - " + JSON.stringify(response[iii]) + 'compare with : ' + JSON.stringify(self.global_season)); // console.log(" - " + JSON.stringify(response[iii]) + 'compare with : ' + JSON.stringify(self.globalSeason));
if (response[iii].name == ""+self.global_season) { if(response[iii].name === `${self.globalSeason}`) {
self.saison_id = response[iii].id; self.saisonId = response[iii].id;
break; break;
} }
} }
if (self.saison_id === null) { if(self.saisonId === null) {
return; return;
} }
self.seasonService.getVideo(self.saison_id) self.seasonService.getVideo(self.saisonId)
.then(function(response: any[]) { .then((response2: any[]) => {
self.listFileInBdd = response; self.listFileInBdd = response2;
//console.log("find video: " + response.length); // console.log("find video: " + response2.length);
//for (let iii = 0; iii<response.length; iii++) { // for (let iii = 0; iii<response2.length; iii++) {
// console.log(" - " + JSON.stringify(response[iii])); // console.log(" - " + JSON.stringify(response2[iii]));
//} // }
self.checkConcordence(); self.checkConcordence();
}).catch(function(response) { }).catch((response3) => {
self.listFileInBdd = null; self.listFileInBdd = null;
}) });
}).catch(function(response) { }).catch((response4) => {
self.listFileInBdd = null; self.listFileInBdd = null;
}); });
} }
eventPopUpSeason (_event: string): void { eventPopUpSeason(event: string): void {
console.log("GET event: " + _event); console.log(`GET event: ${ event}`);
this.popInService.close("popin-new-season"); this.popInService.close('popin-new-season');
} }
eventPopUpSeries (_event: string): void { eventPopUpSeries(event: string): void {
console.log("GET event: " + _event); console.log(`GET event: ${ event}`);
this.popInService.close("popin-new-series"); this.popInService.close('popin-new-series');
} }
eventPopUpType (_event: string): void { eventPopUpType(event: string): void {
console.log("GET event: " + _event); console.log(`GET event: ${ event}`);
this.popInService.close("popin-new-type"); this.popInService.close('popin-new-type');
} }
eventPopUpUniverse (_event: string): void { eventPopUpUniverse(event: string): void {
console.log("GET event: " + _event); console.log(`GET event: ${ event}`);
this.popInService.close("popin-new-universe"); this.popInService.close('popin-new-universe');
} }
newSeason (): void { newSeason(): void {
console.log("Request new Season..."); console.log('Request new Season...');
this.popInService.open("popin-new-season"); this.popInService.open('popin-new-season');
} }
newSeries (): void { newSeries(): void {
console.log("Request new Series..."); console.log('Request new Series...');
this.popInService.open("popin-new-series"); this.popInService.open('popin-new-series');
} }
newType (): void { newType(): void {
console.log("Request new Type..."); console.log('Request new Type...');
this.popInService.open("popin-create-type"); this.popInService.open('popin-create-type');
} }
newUniverse () { newUniverse() {
console.log("Request new Universe..."); console.log('Request new Universe...');
this.popInService.open("popin-new-universe"); this.popInService.open('popin-new-universe');
} }
} }

View File

@ -3,12 +3,11 @@ import { ActivatedRoute } from '@angular/router';
import { ArianeService } from '../../service/ariane'; import { ArianeService } from '../../service/ariane';
@Component({ @Component({
selector: 'app-validate-email', selector: 'app-validate-email',
templateUrl: './validate-email.html', templateUrl: './validate-email.html',
styleUrls: ['./validate-email.less'] styleUrls: [ './validate-email.less' ]
}) })
export class ValidateEmailScene implements OnInit { export class ValidateEmailScene implements OnInit {
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private arianeService: ArianeService private arianeService: ArianeService
) { ) {
@ -24,6 +23,7 @@ export class ValidateEmailScene implements OnInit {
onCheck() { onCheck() {
} }
} }
/* /*
@ -79,7 +79,7 @@ app.controller("controlerValidateEmail", function($scope, $http, $rootScope, Aut
$http.get(connectionAdresse, config) $http.get(connectionAdresse, config)
.then(function(response) { .then(function(response) {
// check if the answer is correct with the question // check if the answer is correct with the question
if (tmpLogin != $scope.login) { if (tmpLogin !== $scope.login) {
return; return;
} }
console.log("Status " + response.status); console.log("Status " + response.status);
@ -95,7 +95,7 @@ app.controller("controlerValidateEmail", function($scope, $http, $rootScope, Aut
$scope.loginHelp = "Login already used ... (error 2)"; $scope.loginHelp = "Login already used ... (error 2)";
}, function(response) { }, function(response) {
// check if the answer is correct with the question // check if the answer is correct with the question
if (tmpLogin != $scope.login) { if (tmpLogin !== $scope.login) {
return; return;
} }
if (response.status == 404) { if (response.status == 404) {
@ -150,7 +150,7 @@ app.controller("controlerValidateEmail", function($scope, $http, $rootScope, Aut
$http.get(connectionAdresse, config) $http.get(connectionAdresse, config)
.then(function(response) { .then(function(response) {
// check if the answer is correct with the question // check if the answer is correct with the question
if (tmpEmail != $scope.email) { if (tmpEmail !== $scope.email) {
return; return;
} }
console.log("Status " + response.status); console.log("Status " + response.status);
@ -166,7 +166,7 @@ app.controller("controlerValidateEmail", function($scope, $http, $rootScope, Aut
$scope.emailHelp = "email already used ... (error 2)"; $scope.emailHelp = "email already used ... (error 2)";
}, function(response) { }, function(response) {
// check if the answer is correct with the question // check if the answer is correct with the question
if (tmpEmail != $scope.email) { if (tmpEmail !== $scope.email) {
return; return;
} }
if (response.status == 404) { if (response.status == 404) {
@ -251,7 +251,4 @@ app.controller("controlerValidateEmail", function($scope, $http, $rootScope, Aut
}); });
*/ */

View File

@ -67,7 +67,7 @@
Type: Type:
</div> </div>
<div class="input"> <div class="input">
<select [ngModel]="data.type_id" <select [ngModel]="data.typeId"
(ngModelChange)="onChangeType($event)"> (ngModelChange)="onChangeType($event)">
<option *ngFor="let element of listType" [ngValue]="element.value">{{element.label}}</option> <option *ngFor="let element of listType" [ngValue]="element.value">{{element.label}}</option>
</select> </select>
@ -83,7 +83,7 @@
Universe: Universe:
</div> </div>
<div class="input"> <div class="input">
<select [ngModel]="data.universe_id" <select [ngModel]="data.universeId"
(ngModelChange)="onChangeUniverse($event)"> (ngModelChange)="onChangeUniverse($event)">
<option *ngFor="let element of listUniverse" [ngValue]="element.value">{{element.label}}</option> <option *ngFor="let element of listUniverse" [ngValue]="element.value">{{element.label}}</option>
</select> </select>
@ -99,7 +99,7 @@
Series: Series:
</div> </div>
<div class="input"> <div class="input">
<select [ngModel]="data.series_id" <select [ngModel]="data.seriesId"
(ngModelChange)="onChangeSeries($event)"> (ngModelChange)="onChangeSeries($event)">
<option *ngFor="let element of listSeries" [ngValue]="element.value">{{element.label}}</option> <option *ngFor="let element of listSeries" [ngValue]="element.value">{{element.label}}</option>
</select> </select>
@ -115,7 +115,7 @@
Season: Season:
</div> </div>
<div class="input"> <div class="input">
<select [ngModel]="data.season_id" <select [ngModel]="data.seasonId"
(ngModelChange)="onChangeSeason($event)"> (ngModelChange)="onChangeSeason($event)">
<option *ngFor="let element of listSeason" [ngValue]="element.value">{{element.label}}</option> <option *ngFor="let element of listSeason" [ngValue]="element.value">{{element.label}}</option>
</select> </select>

View File

@ -5,83 +5,75 @@
*/ */
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute, ParamMap } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common';
import { fadeInAnimation } from '../../_animations/index'; import { fadeInAnimation } from '../../_animations/index';
import { HttpWrapperService } from '../../service/http-wrapper';
import { PopInService } from '../../service/popin'; import { PopInService } from '../../service/popin';
import { TypeService } from '../../service/type'; import { TypeService } from '../../service/type';
import { UniverseService } from '../../service/universe'; import { UniverseService } from '../../service/universe';
import { SeriesService } from '../../service/series'; import { SeriesService } from '../../service/series';
import { SeasonService } from '../../service/season';
import { VideoService } from '../../service/video'; import { VideoService } from '../../service/video';
import { DataService } from '../../service/data';
import { ArianeService } from '../../service/ariane'; import { ArianeService } from '../../service/ariane';
import { UploadProgress } from '../../popin/upload-progress/upload-progress'; import { UploadProgress } from '../../popin/upload-progress/upload-progress';
export class ElementList { export interface ElementList {
value: number; value?: number;
label: string; label: string;
constructor(_value: number, _label: string) {
this.value = _value;
this.label = _label;
}
} }
class DataToSend { class DataToSend {
name:string = "" name:string = '';
description:string = "" description:string = '';
episode:number = undefined episode:number = undefined;
universe_id:number = null universeId:number = null;
series_id:number = null seriesId:number = null;
season_id:number = null seasonId:number = null;
data_id:number = -1 dataId:number = -1;
time:number = undefined time:number = undefined;
type_id:number = null typeId:number = null;
covers:Array<any> = []; covers:Array<any> = [];
generated_name:string = "" generatedName:string = '';
clone() { clone() {
let tmp = new DataToSend(); let tmp = new DataToSend();
tmp.name = this.name tmp.name = this.name;
tmp.description = this.description tmp.description = this.description;
tmp.episode = this.episode tmp.episode = this.episode;
tmp.universe_id = this.universe_id tmp.universeId = this.universeId;
tmp.series_id = this.series_id tmp.seriesId = this.seriesId;
tmp.season_id = this.season_id tmp.seasonId = this.seasonId;
tmp.data_id = this.data_id tmp.dataId = this.dataId;
tmp.time = this.time tmp.time = this.time;
tmp.type_id = this.type_id tmp.typeId = this.typeId;
tmp.covers = this.covers tmp.covers = this.covers;
tmp.generated_name = this.generated_name tmp.generatedName = this.generatedName;
return tmp; return tmp;
} }
}; }
@Component({ @Component({
selector: 'app-video-edit', selector: 'app-video-edit',
templateUrl: './video-edit.html', templateUrl: './video-edit.html',
styleUrls: ['./video-edit.less'], styleUrls: [ './video-edit.less' ],
animations: [fadeInAnimation], animations: [ fadeInAnimation ],
host: { '[@fadeInAnimation]': '' } host: { '[@fadeInAnimation]': '' }
}) })
export class VideoEditScene implements OnInit { export class VideoEditScene implements OnInit {
id_video:number = -1; idVideo:number = -1;
itemIsRemoved:boolean = false itemIsRemoved:boolean = false;
itemIsNotFound:boolean = false itemIsNotFound:boolean = false;
itemIsLoading:boolean = true itemIsLoading:boolean = true;
error:string = "" error:string = '';
data:DataToSend = new DataToSend(); data:DataToSend = new DataToSend();
data_ori:DataToSend = new DataToSend(); dataOri:DataToSend = new DataToSend();
coverFile:File; coverFile:File;
upload_file_value:string = "" uploadFileValue:string = '';
selectedFiles:FileList; selectedFiles:FileList;
need_send:boolean = false; needSend:boolean = false;
// section tha define the upload value to display in the pop-in of upload // section tha define the upload value to display in the pop-in of upload
@ -92,11 +84,11 @@ export class VideoEditScene implements OnInit {
private deleteCoverId:number = null; private deleteCoverId:number = null;
private deleteMediaId:number = null; private deleteMediaId:number = null;
deleteConfirmed() { deleteConfirmed() {
if (this.deleteCoverId !== null) { if(this.deleteCoverId !== null) {
this.removeCoverAfterConfirm(this.deleteCoverId); this.removeCoverAfterConfirm(this.deleteCoverId);
this.cleanConfirm(); this.cleanConfirm();
} }
if (this.deleteMediaId !== null) { if(this.deleteMediaId !== null) {
this.removeItemAfterConfirm(this.deleteMediaId); this.removeItemAfterConfirm(this.deleteMediaId);
this.cleanConfirm(); this.cleanConfirm();
} }
@ -108,420 +100,415 @@ export class VideoEditScene implements OnInit {
this.deleteMediaId = null; this.deleteMediaId = null;
} }
covers_display:Array<any> = []; coversDisplay:Array<any> = [];
listType: ElementList[] = [ listType: ElementList[] = [
{value: undefined, label: '---'}, { value: undefined, label: '---' },
]; ];
listUniverse: ElementList[] = [ listUniverse: ElementList[] = [
{value: undefined, label: '---'}, { value: undefined, label: '---' },
{value: null, label: '---'}, { value: null, label: '---' },
]; ];
listSeries: ElementList[] = [ listSeries: ElementList[] = [
{value: undefined, label: '---'}, { value: undefined, label: '---' },
]; ];
listSeason: ElementList[] = [ listSeason: ElementList[] = [
{value: undefined, label: '---'}, { value: undefined, label: '---' },
]; ];
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router,
private locate: Location,
private dataService: DataService,
private typeService: TypeService, private typeService: TypeService,
private universeService: UniverseService, private universeService: UniverseService,
private seriesService: SeriesService, private seriesService: SeriesService,
private seasonService: SeasonService,
private videoService: VideoService, private videoService: VideoService,
private httpService: HttpWrapperService,
private arianeService: ArianeService, private arianeService: ArianeService,
private popInService: PopInService) { private popInService: PopInService) {
} }
updateNeedSend(): boolean { updateNeedSend(): boolean {
this.need_send = false; this.needSend = false;
if (this.data.name != this.data_ori.name) { if(this.data.name !== this.dataOri.name) {
this.need_send = true; this.needSend = true;
} }
if (this.data.description != this.data_ori.description) { if(this.data.description !== this.dataOri.description) {
this.need_send = true; this.needSend = true;
} }
if (this.data.episode != this.data_ori.episode) { if(this.data.episode !== this.dataOri.episode) {
this.need_send = true; this.needSend = true;
} }
if (this.data.time != this.data_ori.time) { if(this.data.time !== this.dataOri.time) {
this.need_send = true; this.needSend = true;
} }
if (this.data.type_id != this.data_ori.type_id) { if(this.data.typeId !== this.dataOri.typeId) {
this.need_send = true; this.needSend = true;
} }
if (this.data.universe_id != this.data_ori.universe_id) { if(this.data.universeId !== this.dataOri.universeId) {
this.need_send = true; this.needSend = true;
} }
if (this.data.series_id != this.data_ori.series_id) { if(this.data.seriesId !== this.dataOri.seriesId) {
this.need_send = true; this.needSend = true;
} }
if (this.data.season_id != this.data_ori.season_id) { if(this.data.seasonId !== this.dataOri.seasonId) {
this.need_send = true; this.needSend = true;
} }
return this.need_send; return this.needSend;
} }
updateCoverList(_covers: any) { updateCoverList(covers: any) {
this.covers_display = []; this.coversDisplay = [];
this.data.covers = []; this.data.covers = [];
if (_covers !== undefined && _covers !== null) { if(covers !== undefined && covers !== null) {
for (let iii=0; iii<_covers.length; iii++) { for(let iii = 0; iii < covers.length; iii++) {
this.data.covers.push(_covers[iii]); this.data.covers.push(covers[iii]);
this.covers_display.push({ this.coversDisplay.push({
id:_covers[iii], id:covers[iii],
url:this.videoService.getCoverThumbnailUrl(_covers[iii]) url:this.videoService.getCoverThumbnailUrl(covers[iii])
}); });
} }
} else { } else {
this.covers_display = [] this.coversDisplay = [];
} }
} }
ngOnInit() { ngOnInit() {
this.arianeService.updateManual(this.route.snapshot.paramMap); this.arianeService.updateManual(this.route.snapshot.paramMap);
this.id_video = this.arianeService.getVideoId(); this.idVideo = this.arianeService.getVideoId();
let self = this; let self = this;
this.listType = [{value: null, label: '---'}]; this.listType = [ { value: null, label: '---' } ];
this.listUniverse = [{value: null, label: '---'}]; this.listUniverse = [ { value: null, label: '---' } ];
this.listSeries = [{value: null, label: '---'}]; this.listSeries = [ { value: null, label: '---' } ];
this.listSeason = [{value: null, label: '---'}]; this.listSeason = [ { value: null, label: '---' } ];
this.universeService.getData() this.universeService.getData()
.then(function(response2) { .then((response2) => {
for(let iii= 0; iii < response2.length; iii++) { for(let iii = 0; iii < response2.length; iii++) {
self.listUniverse.push({value: response2[iii].id, label: response2[iii].name}); self.listUniverse.push({ value: response2[iii].id, label: response2[iii].name });
} }
}).catch(function(response2) { }).catch((response2) => {
console.log("get response22 : " + JSON.stringify(response2, null, 2)); console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
}); });
this.typeService.getData() this.typeService.getData()
.then(function(response2) { .then((response2) => {
for(let iii= 0; iii < response2.length; iii++) { for(let iii = 0; iii < response2.length; iii++) {
self.listType.push({value: response2[iii].id, label: response2[iii].name}); self.listType.push({ value: response2[iii].id, label: response2[iii].name });
} }
}).catch(function(response2) { }).catch((response2) => {
console.log("get response22 : " + JSON.stringify(response2, null, 2)); console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
}); });
//this.seriesService.getOrder() // this.seriesService.getOrder()
this.seriesService.getData() this.seriesService.getData()
.then(function(response3) { .then((response3) => {
for(let iii= 0; iii < response3.length; iii++) { for(let iii = 0; iii < response3.length; iii++) {
self.listSeries.push({value: response3[iii].id, label: response3[iii].name}); self.listSeries.push({ value: response3[iii].id, label: response3[iii].name });
console.log("[" + self.data.data_id + "] Get series: " + response3[iii].id + ", label:" + response3[iii].name) console.log(`[${ self.data.dataId }] Get series: ${ response3[iii].id }, label:${ response3[iii].name}`);
} }
}).catch(function(response3) { }).catch((response3) => {
console.log("get response3 : " + JSON.stringify(response3, null, 2)); console.log(`get response3 : ${ JSON.stringify(response3, null, 2)}`);
}); });
this.videoService.get(this.id_video) this.videoService.get(this.idVideo)
.then(function(response) { .then((response) => {
console.log("get response of video : " + JSON.stringify(response, null, 2)); console.log(`get response of video : ${ JSON.stringify(response, null, 2)}`);
self.data.name = response.name; self.data.name = response.name;
self.data.description = response.description; self.data.description = response.description;
self.data.episode = response.episode; self.data.episode = response.episode;
self.data.universe_id = response.univers_id; self.data.universeId = response.universId;
if (self.data.universe_id === undefined) { if(self.data.universeId === undefined) {
self.data.universe_id = null; self.data.universeId = null;
} }
self.data.data_id = response.data_id; self.data.dataId = response.dataId;
self.data.time = response.time; self.data.time = response.time;
self.data.generated_name = response.generated_name; self.data.generatedName = response.generatedName;
self.onChangeType(response.type_id); self.onChangeType(response.typeId);
self.onChangeSeries(response.series_id); self.onChangeSeries(response.seriesId);
self.data.season_id = response.season_id; self.data.seasonId = response.seasonId;
if (self.data.season_id === undefined) { if(self.data.seasonId === undefined) {
self.data.season_id = null; self.data.seasonId = null;
} }
self.data_ori = self.data.clone(); self.dataOri = self.data.clone();
self.updateCoverList(response.covers); self.updateCoverList(response.covers);
self.updateNeedSend(); self.updateNeedSend();
console.log("covers_list : " + JSON.stringify(self.covers_display, null, 2)); console.log(`coversList : ${ JSON.stringify(self.coversDisplay, null, 2)}`);
self.itemIsLoading = false; self.itemIsLoading = false;
}).catch(function(response) { }).catch((response) => {
self.error = "Can not get the data"; self.error = 'Can not get the data';
self.data = new DataToSend(); self.data = new DataToSend();
self.covers_display = []; self.coversDisplay = [];
self.data_ori = self.data.clone(); self.dataOri = self.data.clone();
self.updateNeedSend(); self.updateNeedSend();
self.itemIsNotFound = true; self.itemIsNotFound = true;
self.itemIsLoading = false; self.itemIsLoading = false;
}); });
} }
onChangeType(_value:any):void { onChangeType(value:any):void {
console.log("Change requested of type ... " + _value); console.log(`Change requested of type ... ${value}`);
this.data.type_id = _value; this.data.typeId = value;
if (this.data.type_id == undefined) { if(this.data.typeId === undefined) {
this.data.type_id = null; this.data.typeId = null;
} }
this.data.series_id = null; this.data.seriesId = null;
this.data.season_id = null; this.data.seasonId = null;
this.listSeries = [{value: undefined, label: '---'}]; this.listSeries = [ { value: undefined, label: '---' } ];
this.listSeason = [{value: undefined, label: '---'}]; this.listSeason = [ { value: undefined, label: '---' } ];
let self = this; let self = this;
this.updateNeedSend(); this.updateNeedSend();
if (this.data.type_id != undefined) { if(this.data.typeId !== undefined) {
self.typeService.getSubSeries(this.data.type_id, ["id", "name"]) self.typeService.getSubSeries(this.data.typeId, [ 'id', 'name' ])
.then(function(response2) { .then((response2) => {
for(let iii= 0; iii < response2.length; iii++) { for(let iii = 0; iii < response2.length; iii++) {
self.listSeries.push({value: response2[iii].id, label: response2[iii].name}); self.listSeries.push({ value: response2[iii].id, label: response2[iii].name });
} }
}).catch(function(response2) { }).catch((response2) => {
console.log("get response22 : " + JSON.stringify(response2, null, 2)); console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
}); });
} }
} }
onChangeUniverse(_value:any):void { onChangeUniverse(value:any):void {
this.data.universe_id = _value; this.data.universeId = value;
this.updateNeedSend(); this.updateNeedSend();
} }
onChangeSeries(_value:any):void { onChangeSeries(value:any):void {
this.data.series_id = _value; this.data.seriesId = value;
if (this.data.series_id === undefined) { if(this.data.seriesId === undefined) {
this.data.series_id = null; this.data.seriesId = null;
} }
this.data.season_id = null; this.data.seasonId = null;
this.listSeason = [{value: undefined, label: '---'}]; this.listSeason = [ { value: undefined, label: '---' } ];
let self = this; let self = this;
if (this.data.series_id != undefined) { if(this.data.seriesId !== undefined) {
self.seriesService.getSeason(this.data.series_id, ["id", "name"]) self.seriesService.getSeason(this.data.seriesId, [ 'id', 'name' ])
.then(function(response3) { .then((response3) => {
for(let iii= 0; iii < response3.length; iii++) { for(let iii = 0; iii < response3.length; iii++) {
self.listSeason.push({value: response3[iii].id, label: "season " + response3[iii].name}); self.listSeason.push({ value: response3[iii].id, label: `season ${ response3[iii].name}` });
} }
}).catch(function(response3) { }).catch((response3) => {
console.log("get response22 : " + JSON.stringify(response3, null, 2)); console.log(`get response22 : ${ JSON.stringify(response3, null, 2)}`);
}); });
} }
this.updateNeedSend(); this.updateNeedSend();
} }
onChangeSeason(_value:any):void { onChangeSeason(value:any):void {
this.data.season_id = _value; this.data.seasonId = value;
this.updateNeedSend(); this.updateNeedSend();
} }
onName(_value:any):void { onName(value:any):void {
this.data.name = _value; this.data.name = value;
this.updateNeedSend(); this.updateNeedSend();
} }
onDescription(_value:any):void { onDescription(value:any):void {
if (_value.length == 0) { if(value.length === 0) {
this.data.description = null; this.data.description = null;
} else { } else {
this.data.description = _value; this.data.description = value;
} }
this.updateNeedSend(); this.updateNeedSend();
} }
onDate(_value:any):void { onDate(value:any):void {
if (_value.value.length > 4) { if(value.value.length > 4) {
_value.value = this.data.time; value.value = this.data.time;
} else { } else {
this.data.time = _value.value; this.data.time = value.value;
} }
if (this.data.time < 10) { if(this.data.time < 10) {
this.data.time = null; this.data.time = null;
} }
this.updateNeedSend(); this.updateNeedSend();
} }
onEpisode(_value:any):void { onEpisode(value:any):void {
if (_value.value.length > 4) { if(value.value.length > 4) {
_value.value = this.data.episode; value.value = this.data.episode;
} else { } else {
this.data.episode = parseInt(_value.value, 10); this.data.episode = parseInt(value.value, 10);
} }
this.updateNeedSend(); this.updateNeedSend();
} }
sendValues():void { sendValues():void {
console.log("send new values...."); console.log('send new values....');
let data = {} let data:any = {};
if (this.data.name != this.data_ori.name) { if(this.data.name !== this.dataOri.name) {
data["name"] = this.data.name; data.name = this.data.name;
} }
if (this.data.description != this.data_ori.description) { if(this.data.description !== this.dataOri.description) {
if (this.data.description == undefined) { if(this.data.description === undefined) {
data["description"] = null; data.description = null;
} else { } else {
data["description"] = this.data.description; data.description = this.data.description;
} }
} }
if (this.data.episode != this.data_ori.episode) { if(this.data.episode !== this.dataOri.episode) {
data["episode"] = this.data.episode; data.episode = this.data.episode;
} }
if (this.data.time != this.data_ori.time) { if(this.data.time !== this.dataOri.time) {
data["time"] = this.data.time; data.time = this.data.time;
} }
if (this.data.type_id != this.data_ori.type_id) { if(this.data.typeId !== this.dataOri.typeId) {
if (this.data.type_id == undefined) { if(this.data.typeId === undefined) {
data["type_id"] = null; data.typeId = null;
} else { } else {
data["type_id"] = this.data.type_id; data.typeId = this.data.typeId;
} }
} }
if (this.data.universe_id != this.data_ori.universe_id) { if(this.data.universeId !== this.dataOri.universeId) {
if (this.data.universe_id == undefined) { if(this.data.universeId === undefined) {
data["universe_id"] = null; data.universeId = null;
} else { } else {
data["universe_id"] = this.data.universe_id; data.universeId = this.data.universeId;
} }
} }
if (this.data.series_id != this.data_ori.series_id) { if(this.data.seriesId !== this.dataOri.seriesId) {
if (this.data.series_id == undefined) { if(this.data.seriesId === undefined) {
data["series_id"] = null; data.seriesId = null;
} else { } else {
data["series_id"] = this.data.series_id; data.seriesId = this.data.seriesId;
} }
} }
if (this.data.season_id != this.data_ori.season_id) { if(this.data.seasonId !== this.dataOri.seasonId) {
if (this.data.season_id == undefined) { if(this.data.seasonId === undefined) {
data["season_id"] = null; data.seasonId = null;
} else { } else {
data["season_id"] = this.data.season_id; data.seasonId = this.data.seasonId;
} }
} }
let tmpp = this.data.clone(); let tmpp = this.data.clone();
let self = this; let self = this;
this.videoService.put(this.id_video, data) this.videoService.put(this.idVideo, data)
.then(function(response3) { .then((response3) => {
self.data_ori = tmpp; self.dataOri = tmpp;
self.updateNeedSend(); self.updateNeedSend();
}).catch(function(response3) { }).catch((response3) => {
console.log("get response22 : " + JSON.stringify(response3, null, 2)); console.log(`get response22 : ${ JSON.stringify(response3, null, 2)}`);
self.updateNeedSend(); self.updateNeedSend();
}); });
} }
// At the drag drop area // At the drag drop area
// (drop)="onDropFile($event)" // (drop)="onDropFile($event)"
onDropFile(_event: DragEvent) { onDropFile(event: DragEvent) {
_event.preventDefault(); event.preventDefault();
//TODO : this.uploadFile(_event.dataTransfer.files[0]); // this.uploadFile(event.dataTransfer.files[0]);
console.log("error in drag & drop ..."); console.log('error in drag & drop ...');
} }
// At the drag drop area // At the drag drop area
// (dragover)="onDragOverFile($event)" // (dragover)="onDragOverFile($event)"
onDragOverFile(_event) { onDragOverFile(event) {
_event.stopPropagation(); event.stopPropagation();
_event.preventDefault(); event.preventDefault();
} }
// At the file input element // At the file input element
// (change)="selectFile($event)" // (change)="selectFile($event)"
onChangeCover(_value:any):void { onChangeCover(value:any):void {
this.selectedFiles = _value.files this.selectedFiles = value.files;
this.coverFile = this.selectedFiles[0]; this.coverFile = this.selectedFiles[0];
console.log("select file " + this.coverFile.name); console.log(`select file ${ this.coverFile.name}`);
this.uploadCover(this.coverFile); this.uploadCover(this.coverFile);
this.updateNeedSend(); this.updateNeedSend();
} }
uploadCover(_file:File) { uploadCover(file?:File) {
if (_file == undefined) { if(file === undefined) {
console.log("No file selected!"); console.log('No file selected!');
return; return;
} }
let self = this; let self = this;
// clean upload labels* // clean upload labels*
this.upload.clear(); this.upload.clear();
// display the upload pop-in // display the upload pop-in
this.popInService.open("popin-upload-progress"); this.popInService.open('popin-upload-progress');
this.videoService.uploadCover(_file, this.id_video, function(count, total) { this.videoService.uploadCover(file, this.idVideo, (count, total) => {
self.upload.mediaSendSize = count; self.upload.mediaSendSize = count;
self.upload.mediaSize = total; self.upload.mediaSize = total;
}) })
.then(function (response:any) { .then((response:any) => {
console.log("get response of cover : " + JSON.stringify(response, null, 2)); console.log(`get response of cover : ${ JSON.stringify(response, null, 2)}`);
self.upload.result = "Cover added done"; self.upload.result = 'Cover added done';
// TODO: we retrive the whiole media ==> update data ... // we retrive the whiole media ==> update data ...
self.updateCoverList(response.covers); self.updateCoverList(response.covers);
}).catch(function (response:any) { }).catch((response:any) => {
//self.error = "Can not get the data"; // self.error = "Can not get the data";
console.log("Can not add the cover in the video..."); console.log('Can not add the cover in the video...');
self.upload.error = "Error in the upload of the cover..." + JSON.stringify(response, null, 2); self.upload.error = `Error in the upload of the cover...${ JSON.stringify(response, null, 2)}`;
}); });
} }
removeCover(_id:number) { removeCover(id:number) {
this.cleanConfirm(); this.cleanConfirm();
this.confirmDeleteComment = "Delete the cover ID: " + _id; this.confirmDeleteComment = `Delete the cover ID: ${ id}`;
this.confirmDeleteImageUrl = this.seriesService.getCoverThumbnailUrl(_id); this.confirmDeleteImageUrl = this.seriesService.getCoverThumbnailUrl(id);
this.deleteCoverId = _id; this.deleteCoverId = id;
this.popInService.open("popin-delete-confirm"); this.popInService.open('popin-delete-confirm');
} }
removeCoverAfterConfirm(_id:number) { removeCoverAfterConfirm(id:number) {
console.log("Request remove cover: " + _id); console.log(`Request remove cover: ${ id}`);
let self = this; let self = this;
this.videoService.deleteCover(this.id_video, _id) this.videoService.deleteCover(this.idVideo, id)
.then(function (response:any) { .then((response:any) => {
console.log("get response of remove cover : " + JSON.stringify(response, null, 2)); console.log(`get response of remove cover : ${ JSON.stringify(response, null, 2)}`);
self.upload.result = "Cover remove done"; self.upload.result = 'Cover remove done';
// TODO: we retrive the whiole media ==> update data ... // we retrive the whiole media ==> update data ...
self.updateCoverList(response.covers); self.updateCoverList(response.covers);
}).catch(function (response:any) { }).catch((response:any) => {
//self.error = "Can not get the data"; // self.error = "Can not get the data";
console.log("Can not remove the cover of the video..."); console.log('Can not remove the cover of the video...');
self.upload.error = "Error in the upload of the cover..." + JSON.stringify(response, null, 2); self.upload.error = `Error in the upload of the cover...${ JSON.stringify(response, null, 2)}`;
}); });
} }
removeItem() { removeItem() {
console.log("Request remove Media..."); console.log('Request remove Media...');
this.cleanConfirm(); this.cleanConfirm();
this.confirmDeleteComment = "Delete the Media: " + this.id_video; this.confirmDeleteComment = `Delete the Media: ${ this.idVideo}`;
this.deleteMediaId = this.id_video; this.deleteMediaId = this.idVideo;
this.popInService.open("popin-delete-confirm"); this.popInService.open('popin-delete-confirm');
} }
removeItemAfterConfirm(_id:number) { removeItemAfterConfirm(id:number) {
let self = this; let self = this;
this.videoService.delete(_id) this.videoService.delete(id)
.then(function(response3) { .then((response3) => {
//self.data_ori = tmpp; // self.dataOri = tmpp;
//self.updateNeedSend(); // self.updateNeedSend();
self.itemIsRemoved = true; self.itemIsRemoved = true;
}).catch(function(response3) { }).catch((response3) => {
//self.updateNeedSend(); // self.updateNeedSend();
}); });
} }
eventPopUpSeason(_event: string): void { eventPopUpSeason(event: string): void {
console.log("GET event: " + _event); console.log(`GET event: ${ event}`);
this.popInService.close("popin-new-season"); this.popInService.close('popin-new-season');
} }
eventPopUpSeries(_event: string): void { eventPopUpSeries(event: string): void {
console.log("GET event: " + _event); console.log(`GET event: ${ event}`);
this.popInService.close("popin-new-series"); this.popInService.close('popin-new-series');
} }
eventPopUpType(_event: string): void { eventPopUpType(event: string): void {
console.log("GET event: " + _event); console.log(`GET event: ${ event}`);
this.popInService.close("popin-new-type"); this.popInService.close('popin-new-type');
} }
eventPopUpUniverse(_event: string): void { eventPopUpUniverse(event: string): void {
console.log("GET event: " + _event); console.log(`GET event: ${ event}`);
this.popInService.close("popin-new-universe"); this.popInService.close('popin-new-universe');
} }
newSeason(): void { newSeason(): void {
console.log("Request new Season..."); console.log('Request new Season...');
this.popInService.open("popin-new-season"); this.popInService.open('popin-new-season');
} }
newSeries(): void { newSeries(): void {
console.log("Request new Series..."); console.log('Request new Series...');
this.popInService.open("popin-new-series"); this.popInService.open('popin-new-series');
} }
newType(): void { newType(): void {
console.log("Request new Type..."); console.log('Request new Type...');
this.popInService.open("popin-create-type"); this.popInService.open('popin-create-type');
} }
newUniverse() { newUniverse() {
console.log("Request new Universe..."); console.log('Request new Universe...');
this.popInService.open("popin-new-universe"); this.popInService.open('popin-new-universe');
} }
} }

View File

@ -43,17 +43,17 @@
</div> </div>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
<div class="episode" *ngIf="series_name!=null"> <div class="episode" *ngIf="seriesName!=null">
<b>Series:</b> {{series_name}} <b>Series:</b> {{seriesName}}
</div> </div>
<div class="episode" *ngIf="season_name!=null"> <div class="episode" *ngIf="seasonName!=null">
<b>Season:</b> {{season_name}} <b>Season:</b> {{seasonName}}
</div> </div>
<div class="episode" *ngIf="episode!=null"> <div class="episode" *ngIf="episode!=null">
<b>Episode:</b> {{episode}} <b>Episode:</b> {{episode}}
</div> </div>
<div class="episode"> <div class="episode">
<b>generated_name:</b> {{generated_name}} <b>generatedName:</b> {{generatedName}}
</div> </div>
<div class="description"> <div class="description">
{{description}} {{description}}
@ -65,7 +65,7 @@
(mousemove)="startHideTimer()" (mousemove)="startHideTimer()"
(fullscreenchange)="onFullscreenChange($event)"> (fullscreenchange)="onFullscreenChange($event)">
<div class="video-elem"> <div class="video-elem">
<video src="{{video_source}}/{{generated_name}}" <video src="{{videoSource}}/{{generatedName}}"
#videoPlayer #videoPlayer
preload preload
(play)="changeStateToPlay()" (play)="changeStateToPlay()"
@ -77,7 +77,7 @@
autoplay autoplay
(ended)="onVideoEnded()" (ended)="onVideoEnded()"
><!-- controls > --> <!--preload="none"--> ><!-- controls > --> <!--preload="none"-->
<!--<p>Your browser does not support HTML5 video player. download video: <a href="{{video_source}}>link here</a>.</p>--> <!--<p>Your browser does not support HTML5 video player. download video: <a href="{{videoSource}}>link here</a>.</p>-->
</video> </video>
</div> </div>
<div class="controls" *ngIf="!displayNeedHide || !isPlaying"> <div class="controls" *ngIf="!displayNeedHide || !isPlaying">

View File

@ -5,9 +5,7 @@
*/ */
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common';
import { interval } from 'rxjs';
import { fadeInAnimation } from '../../_animations/index'; import { fadeInAnimation } from '../../_animations/index';
import { HttpWrapperService } from '../../service/http-wrapper'; import { HttpWrapperService } from '../../service/http-wrapper';
import { VideoService } from '../../service/video'; import { VideoService } from '../../service/video';
@ -18,8 +16,8 @@ import { ArianeService } from '../../service/ariane';
@Component({ @Component({
selector: 'app-video', selector: 'app-video',
templateUrl: './video.html', templateUrl: './video.html',
styleUrls: ['./video.less'], styleUrls: [ './video.less' ],
animations: [fadeInAnimation], animations: [ fadeInAnimation ],
host: { '[@fadeInAnimation]': '' } host: { '[@fadeInAnimation]': '' }
}) })
@ -27,44 +25,44 @@ export class VideoScene implements OnInit {
videoGlobal:any; videoGlobal:any;
@ViewChild('globalVideoElement') @ViewChild('globalVideoElement')
set mainDivEl(el: ElementRef) { set mainDivEl(el: ElementRef) {
if (el != null) { if(el !== null) {
this.videoGlobal = el.nativeElement; this.videoGlobal = el.nativeElement;
} }
} }
videoPlayer: HTMLVideoElement; videoPlayer: HTMLVideoElement;
@ViewChild('videoPlayer') @ViewChild('videoPlayer')
set mainVideoEl(el: ElementRef) { set mainVideoEl(el: ElementRef) {
if (el != null) { if(el !== null) {
this.videoPlayer = el.nativeElement; this.videoPlayer = el.nativeElement;
} }
} }
videoCanva: any; videoCanva: any;
@ViewChild('canvascreenshoot') @ViewChild('canvascreenshoot')
set mainCanvaEl(el: ElementRef) { set mainCanvaEl(el: ElementRef) {
if (el != null) { if(el !== null) {
this.videoCanva = el.nativeElement; this.videoCanva = el.nativeElement;
} }
} }
haveNext = null; haveNext = null;
havePrevious = null; havePrevious = null;
id_video:number = -1; idVideo:number = -1;
mediaIsNotFound:boolean = false; mediaIsNotFound:boolean = false;
mediaIsLoading:boolean = true; mediaIsLoading:boolean = true;
error:string = ""; error:string = '';
name:string = ""; name:string = '';
description:string = ""; description:string = '';
episode:number = undefined; episode:number = undefined;
series_id:number = undefined; seriesId:number = undefined;
series_name:string = undefined; seriesName:string = undefined;
season_id:number = undefined; seasonId:number = undefined;
season_name:string = undefined; seasonName:string = undefined;
data_id:number = -1; dataId:number = -1;
time:number = undefined; time:number = undefined;
type_id:number = undefined; typeId:number = undefined;
generated_name:string = ""; generatedName:string = '';
video_source:string = ""; videoSource:string = '';
cover:string = null; cover:string = null;
covers:Array<string> = []; covers:Array<string> = [];
@ -73,9 +71,9 @@ export class VideoScene implements OnInit {
isPlaying:boolean = false; isPlaying:boolean = false;
isFullScreen:boolean = false; isFullScreen:boolean = false;
currentTime:number = 0; currentTime:number = 0;
currentTimeDisplay:string = "00"; currentTimeDisplay:string = '00';
duration:number = 0; duration:number = 0;
durationDisplay:string = "00"; durationDisplay:string = '00';
volumeValue:number = 100; volumeValue:number = 100;
@ -85,40 +83,38 @@ export class VideoScene implements OnInit {
startHideTimer() { startHideTimer() {
this.displayNeedHide = false; this.displayNeedHide = false;
this.timeLeft = 5; this.timeLeft = 5;
if (this.interval != null) { if(this.interval !== null) {
return; return;
} }
let self = this; let self = this;
this.interval = setInterval(() => { this.interval = setInterval(() => {
console.log("periodic event: " + self.timeLeft); console.log(`periodic event: ${ self.timeLeft}`);
if(self.timeLeft > 0) { if(self.timeLeft > 0) {
self.timeLeft--; self.timeLeft--;
} else { } else {
clearInterval(self.interval); clearInterval(self.interval);
self.timeOutDetected(); self.timeOutDetected();
} }
},1000) }, 1000);
} }
timeOutDetected() { timeOutDetected() {
console.log(" ==> stop timer"); console.log(' ==> stop timer');
this.displayNeedHide = true; this.displayNeedHide = true;
clearInterval(this.interval); clearInterval(this.interval);
this.interval = null; this.interval = null;
} }
onRequireNext(_event: any) { onRequireNext(event: any) {
console.log("generate next : " + this.haveNext.id); console.log(`generate next : ${ this.haveNext.id}`);
this.arianeService.navigateVideo(this.haveNext.id, _event.which==2, _event.ctrlKey); this.arianeService.navigateVideo(this.haveNext.id, event.which === 2, event.ctrlKey);
this.arianeService.setVideo(this.haveNext.id); this.arianeService.setVideo(this.haveNext.id);
} }
onRequirePrevious(_event: any) { onRequirePrevious(event: any) {
console.log("generate previous : " + this.havePrevious.id); console.log(`generate previous : ${ this.havePrevious.id}`);
this.arianeService.navigateVideo(this.havePrevious.id, _event.which==2, _event.ctrlKey); this.arianeService.navigateVideo(this.havePrevious.id, event.which === 2, event.ctrlKey);
this.arianeService.setVideo(this.havePrevious.id); this.arianeService.setVideo(this.havePrevious.id);
} }
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router,
private locate: Location,
private videoService: VideoService, private videoService: VideoService,
private seriesService: SeriesService, private seriesService: SeriesService,
private seasonService: SeasonService, private seasonService: SeasonService,
@ -128,34 +124,35 @@ export class VideoScene implements OnInit {
} }
generateName() { generateName() {
this.generated_name = ""; this.generatedName = '';
if (this.series_name != undefined) { if(this.seriesName !== undefined) {
this.generated_name += this.series_name + "-"; this.generatedName = `${this.generatedName }${this.seriesName }-`;
} }
if (this.season_name != undefined) { if(this.seasonName !== undefined) {
if (this.season_name.length < 2) { if(this.seasonName.length < 2) {
this.generated_name += "s0" + this.season_name + "-"; this.generatedName = `${this.generatedName }s0${ this.seasonName }-`;
} else { } else {
this.generated_name += "s" + this.season_name + "-"; this.generatedName = `${this.generatedName }s${ this.seasonName }-`;
} }
} }
if (this.episode != undefined) { if(this.episode !== undefined) {
if (this.episode < 10) { if(this.episode < 10) {
this.generated_name += "e0" + this.episode + "-"; this.generatedName = `${this.generatedName }e0${ this.episode }-`;
} else { } else {
this.generated_name += "e" + this.episode + "-"; this.generatedName = `${this.generatedName }e${ this.episode }-`;
} }
} }
this.generated_name += this.name; this.generatedName = this.generatedName + this.name;
this.generated_name = this.generated_name.replace(new RegExp("&", "g"), "_"); this.generatedName = this.generatedName.replace(new RegExp('&', 'g'), '_');
this.generated_name = this.generated_name.replace(new RegExp("/", "g"), "_"); this.generatedName = this.generatedName.replace(new RegExp('/', 'g'), '_');
} }
myPeriodicCheckFunction() { myPeriodicCheckFunction() {
console.log("check ... "); console.log('check ... ');
} }
changeMetadata() { changeMetadata() {
console.log("list of the stream:"); console.log('list of the stream:');
/* /*
let captureStream = this.videoPlayer.audioTracks; let captureStream = this.videoPlayer.audioTracks;
for (let iii=0; iii < captureStream.length; iii++) { for (let iii=0; iii < captureStream.length; iii++) {
@ -169,7 +166,8 @@ export class VideoScene implements OnInit {
*/ */
} }
audioTracks(event) { audioTracks(event) {
console.log("list of the stream:" + event); console.log(`list of the stream:${ event}`);
/* /*
let captureStream = this.videoPlayer.audioTracks; let captureStream = this.videoPlayer.audioTracks;
for (let iii=0; iii < captureStream.length; iii++) { for (let iii=0; iii < captureStream.length; iii++) {
@ -187,106 +185,106 @@ export class VideoScene implements OnInit {
let self = this; let self = this;
this.startHideTimer(); this.startHideTimer();
this.arianeService.updateManual(this.route.snapshot.paramMap); this.arianeService.updateManual(this.route.snapshot.paramMap);
this.id_video = this.arianeService.getVideoId(); this.idVideo = this.arianeService.getVideoId();
this.arianeService.video_change.subscribe(video_id => { this.arianeService.videoChange.subscribe((videoId) => {
console.log("Detect videoId change..." + video_id); console.log(`Detect videoId change...${ videoId}`);
self.id_video = video_id; self.idVideo = videoId;
self.updateDisplay(); self.updateDisplay();
}); });
self.updateDisplay(); self.updateDisplay();
} }
updateDisplay():void { updateDisplay():void {
let self = this; let self = this;
self.haveNext = null; self.haveNext = null;
self.havePrevious = null; self.havePrevious = null;
this.videoService.get(this.id_video) this.videoService.get(this.idVideo)
.then(function(response) { .then((response) => {
console.log("get response of video : " + JSON.stringify(response, null, 2)); console.log(`get response of video : ${ JSON.stringify(response, null, 2)}`);
self.error = ""; self.error = '';
self.name = response.name; self.name = response.name;
self.description = response.description; self.description = response.description;
self.episode = response.episode; self.episode = response.episode;
self.series_id = response.series_id; self.seriesId = response.seriesId;
self.season_id = response.season_id; self.seasonId = response.seasonId;
self.data_id = response.data_id; self.dataId = response.dataId;
self.time = response.time; self.time = response.time;
self.generated_name = response.generated_name; self.generatedName = response.generatedName;
if (self.data_id != -1) { if(self.dataId !== -1) {
self.video_source = self.httpService.createRESTCall("data/" + self.data_id); self.videoSource = self.httpService.createRESTCall(`data/${ self.dataId}`);
} else { } else {
self.video_source = ""; self.videoSource = '';
} }
if (response.covers === undefined || response.covers === null || response.covers.length === 0) { if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
self.cover = null; self.cover = null;
} else { } else {
self.cover = self.videoService.getCoverUrl(response.covers[0]); self.cover = self.videoService.getCoverUrl(response.covers[0]);
for (let iii=0; iii<response.covers.length; iii++) { for(let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.videoService.getCoverUrl(response.covers[iii])); self.covers.push(self.videoService.getCoverUrl(response.covers[iii]));
} }
} }
self.generateName(); self.generateName();
if (self.series_id !== undefined && self.series_id !== null) { if(self.seriesId !== undefined && self.seriesId !== null) {
self.seriesService.get(self.series_id) self.seriesService.get(self.seriesId)
.then(function(response) { .then((response2) => {
self.series_name = response.name; self.seriesName = response2.name;
self.generateName(); self.generateName();
}).catch(function(response) { }).catch((response3) => {
// nothing to do ... // nothing to do ...
}); });
} }
if (self.season_id !== undefined && self.season_id !== null) { if(self.seasonId !== undefined && self.seasonId !== null) {
self.seasonService.get(self.season_id) self.seasonService.get(self.seasonId)
.then(function(response) { .then((response4) => {
self.season_name = response.name; self.seasonName = response4.name;
self.generateName(); self.generateName();
}).catch(function(response) { }).catch((response5) => {
// nothing to do ... // nothing to do ...
}); });
self.seasonService.getVideo(self.season_id) self.seasonService.getVideo(self.seasonId)
.then(function(response:any) { .then((response6:any) => {
//console.log("saison property: " + JSON.stringify(response, null, 2)); // console.log("saison property: " + JSON.stringify(response, null, 2));
self.haveNext = null; self.haveNext = null;
self.havePrevious = null; self.havePrevious = null;
for (let iii=0; iii<response.length; iii++) { for(let iii = 0; iii < response6.length; iii++) {
if (response[iii].episode === undefined || response[iii].episode === null) { if(response6[iii].episode === undefined || response6[iii].episode === null) {
continue; continue;
} }
if (response[iii].episode < self.episode) { if(response6[iii].episode < self.episode) {
if (self.havePrevious === null) { if(self.havePrevious === null) {
self.havePrevious = response[iii]; self.havePrevious = response6[iii];
} else if (self.havePrevious.episode < response[iii].episode) { } else if(self.havePrevious.episode < response6[iii].episode) {
self.havePrevious = response[iii]; self.havePrevious = response6[iii];
} }
} else if (response[iii].episode > self.episode) { } else if(response6[iii].episode > self.episode) {
if (self.haveNext === null) { if(self.haveNext === null) {
self.haveNext = response[iii]; self.haveNext = response6[iii];
} else if (self.haveNext.episode > response[iii].episode) { } else if(self.haveNext.episode > response6[iii].episode) {
self.haveNext = response[iii]; self.haveNext = response6[iii];
} }
} }
self.covers.push(self.seriesService.getCoverUrl(response[iii])); self.covers.push(self.seriesService.getCoverUrl(response6[iii]));
} }
}).catch(function(response:any) { }).catch((response7:any) => {
}); });
} }
self.mediaIsLoading = false; self.mediaIsLoading = false;
//console.log("display source " + self.video_source); // console.log("display source " + self.videoSource);
//console.log("set transformed : " + JSON.stringify(self, null, 2)); // console.log("set transformed : " + JSON.stringify(self, null, 2));
}).catch(function(response) { }).catch((response8) => {
self.error = "Can not get the data"; self.error = 'Can not get the data';
self.name = ""; self.name = '';
self.description = ""; self.description = '';
self.episode = undefined; self.episode = undefined;
self.series_id = undefined; self.seriesId = undefined;
self.season_id = undefined; self.seasonId = undefined;
self.data_id = -1; self.dataId = -1;
self.time = undefined; self.time = undefined;
self.generated_name = ""; self.generatedName = '';
self.video_source = ""; self.videoSource = '';
self.cover = null; self.cover = null;
self.series_name = undefined; self.seriesName = undefined;
self.season_name = undefined; self.seasonName = undefined;
self.mediaIsNotFound = true; self.mediaIsNotFound = true;
self.mediaIsLoading = false; self.mediaIsLoading = false;
}); });
@ -305,8 +303,9 @@ export class VideoScene implements OnInit {
this.startHideTimer(); this.startHideTimer();
this.playVideo = false; this.playVideo = false;
this.displayVolumeMenu = false; this.displayVolumeMenu = false;
/* /*
if(this.isFullScreen == true) { if(this.isFullScreen === true) {
this.isFullScreen = false; this.isFullScreen = false;
} }
*/ */
@ -314,7 +313,7 @@ export class VideoScene implements OnInit {
changeStateToPlay() { changeStateToPlay() {
this.isPlaying = true; this.isPlaying = true;
if (this.isFullScreen === true) { if(this.isFullScreen === true) {
this.onFullscreen(); this.onFullscreen();
} }
} }
@ -323,68 +322,68 @@ export class VideoScene implements OnInit {
} }
convertIndisplayTime(time:number) : string { convertIndisplayTime(time:number) : string {
let tmpp = parseInt("" + time); let tmpp = parseInt(`${ time}`, 10);
let heures = parseInt("" + (tmpp/3600)); let heures = parseInt(`${ tmpp / 3600}`, 10);
tmpp = tmpp - heures * 3600; tmpp = tmpp - heures * 3600;
let minutes = parseInt("" + (tmpp/60)); let minutes = parseInt(`${ tmpp / 60}`, 10);
let seconds = tmpp - minutes * 60; let seconds = tmpp - minutes * 60;
let out = ""; let out = '';
if (heures != 0) { if(heures !== 0) {
out += heures + ":"; out = `${out }${heures }:`;
} }
if (minutes >= 10) { if(minutes >= 10) {
out += minutes + ":"; out = `${out }${minutes }:`;
} else { } else {
out += "0" + minutes + ":"; out = `${out }0${ minutes }:`;
} }
if (seconds >= 10) { if(seconds >= 10) {
out += seconds; out = out + seconds;
} else { } else {
out += "0" + seconds; out = `${out }0${ seconds}`;
} }
return out; return out;
} }
changeTimeupdate(currentTime: any) { changeTimeupdate(currentTime: any) {
//console.log("time change "); // console.log("time change ");
//console.log(" ==> " + this.videoPlayer.currentTime); // console.log(" ==> " + this.videoPlayer.currentTime);
this.currentTime = this.videoPlayer.currentTime; this.currentTime = this.videoPlayer.currentTime;
this.currentTimeDisplay = this.convertIndisplayTime(this.currentTime); this.currentTimeDisplay = this.convertIndisplayTime(this.currentTime);
//console.log(" ==> " + this.currentTimeDisplay); // console.log(" ==> " + this.currentTimeDisplay);
} }
changeDurationchange(duration: any) { changeDurationchange(duration: any) {
console.log("duration change "); console.log('duration change ');
console.log(" ==> " + this.videoPlayer.duration); console.log(` ==> ${ this.videoPlayer.duration}`);
this.duration = this.videoPlayer.duration; this.duration = this.videoPlayer.duration;
this.durationDisplay = this.convertIndisplayTime(this.duration); this.durationDisplay = this.convertIndisplayTime(this.duration);
} }
onPlay() { onPlay() {
console.log("play"); console.log('play');
this.startHideTimer(); this.startHideTimer();
if (this.videoPlayer === null if(this.videoPlayer === null ||
|| this.videoPlayer === undefined) { this.videoPlayer === undefined) {
console.log("error element: " + this.videoPlayer); console.log(`error element: ${ this.videoPlayer}`);
return; return;
} }
this.videoPlayer.volume = this.volumeValue/100; this.videoPlayer.volume = this.volumeValue / 100;
this.videoPlayer.play(); this.videoPlayer.play();
} }
onPause() { onPause() {
console.log("pause"); console.log('pause');
this.startHideTimer(); this.startHideTimer();
if (this.videoPlayer === null if(this.videoPlayer === null ||
|| this.videoPlayer === undefined) { this.videoPlayer === undefined) {
console.log("error element: " + this.videoPlayer); console.log(`error element: ${ this.videoPlayer}`);
return; return;
} }
this.videoPlayer.pause(); this.videoPlayer.pause();
} }
onPauseToggle() { onPauseToggle() {
console.log("pause toggle ..."); console.log('pause toggle ...');
if (this.isPlaying == true) { if(this.isPlaying === true) {
this.onPause(); this.onPause();
} else { } else {
this.onPlay(); this.onPlay();
@ -392,85 +391,84 @@ export class VideoScene implements OnInit {
} }
onStop() { onStop() {
console.log("stop"); console.log('stop');
this.startHideTimer(); this.startHideTimer();
if (this.videoPlayer === null if(this.videoPlayer === null ||
|| this.videoPlayer === undefined) { this.videoPlayer === undefined) {
console.log("error element: " + this.videoPlayer); console.log(`error element: ${ this.videoPlayer}`);
return; return;
} }
this.videoPlayer.pause(); this.videoPlayer.pause();
this.videoPlayer.currentTime = 0; this.videoPlayer.currentTime = 0;
} }
onBefore() { onBefore() {
console.log("before"); console.log('before');
this.startHideTimer(); this.startHideTimer();
} }
onNext() { onNext() {
console.log("next"); console.log('next');
this.startHideTimer(); this.startHideTimer();
} }
seek(newValue:any) { seek(newValue:any) {
console.log("seek " + newValue.value); console.log(`seek ${ newValue.value}`);
this.startHideTimer(); this.startHideTimer();
if (this.videoPlayer === null if(this.videoPlayer === null ||
|| this.videoPlayer === undefined) { this.videoPlayer === undefined) {
console.log("error element: " + this.videoPlayer); console.log(`error element: ${ this.videoPlayer}`);
return; return;
} }
this.videoPlayer.currentTime = newValue.value; this.videoPlayer.currentTime = newValue.value;
} }
onRewind() { onRewind() {
console.log("rewind"); console.log('rewind');
this.startHideTimer(); this.startHideTimer();
if (this.videoPlayer === null if(this.videoPlayer === null ||
|| this.videoPlayer === undefined) { this.videoPlayer === undefined) {
console.log("error element: " + this.videoPlayer); console.log(`error element: ${ this.videoPlayer}`);
return; return;
} }
this.videoPlayer.currentTime = this.currentTime - 10; this.videoPlayer.currentTime = this.currentTime - 10;
} }
onForward() { onForward() {
console.log("forward"); console.log('forward');
this.startHideTimer(); this.startHideTimer();
if (this.videoPlayer === null if(this.videoPlayer === null ||
|| this.videoPlayer === undefined) { this.videoPlayer === undefined) {
console.log("error element: " + this.videoPlayer); console.log(`error element: ${ this.videoPlayer}`);
return; return;
} }
this.videoPlayer.currentTime = this.currentTime + 10; this.videoPlayer.currentTime = this.currentTime + 10;
} }
onMore() { onMore() {
console.log("more"); console.log('more');
this.startHideTimer(); this.startHideTimer();
if (this.videoPlayer === null if(this.videoPlayer === null ||
|| this.videoPlayer === undefined) { this.videoPlayer === undefined) {
console.log("error element: " + this.videoPlayer); console.log(`error element: ${ this.videoPlayer}`);
return; return;
} }
} }
onFullscreen() { onFullscreen() {
console.log("fullscreen"); console.log('fullscreen');
this.startHideTimer(); this.startHideTimer();
if (this.videoGlobal === null if(this.videoGlobal === null ||
|| this.videoGlobal === undefined) { this.videoGlobal === undefined) {
console.log("error element: " + this.videoGlobal); console.log(`error element: ${ this.videoGlobal}`);
return; return;
} }
if (this.videoGlobal.requestFullscreen) { if(this.videoGlobal.requestFullscreen) {
this.videoGlobal.requestFullscreen(); this.videoGlobal.requestFullscreen();
} else if (this.videoGlobal.mozRequestFullScreen) { } else if(this.videoGlobal.mozRequestFullScreen) {
this.videoGlobal.mozRequestFullScreen(); this.videoGlobal.mozRequestFullScreen();
} else if (this.videoGlobal.webkitRequestFullscreen) { } else if(this.videoGlobal.webkitRequestFullscreen) {
this.videoGlobal.webkitRequestFullscreen(); this.videoGlobal.webkitRequestFullscreen();
} else if (this.videoGlobal.msRequestFullscreen) { } else if(this.videoGlobal.msRequestFullscreen) {
this.videoGlobal.msRequestFullscreen(); this.videoGlobal.msRequestFullscreen();
} }
} }
@ -479,20 +477,20 @@ export class VideoScene implements OnInit {
this.onFullscreenExit22(document); this.onFullscreenExit22(document);
} }
onFullscreenExit22(docc:any) { onFullscreenExit22(docc:any) {
console.log("fullscreen EXIT"); console.log('fullscreen EXIT');
this.startHideTimer(); this.startHideTimer();
if (this.videoGlobal === null if(this.videoGlobal === null ||
|| this.videoGlobal === undefined) { this.videoGlobal === undefined) {
console.log("error element: " + this.videoGlobal); console.log(`error element: ${ this.videoGlobal}`);
return; return;
} }
if (docc.exitFullscreen) { if(docc.exitFullscreen) {
docc.exitFullscreen(); docc.exitFullscreen();
} else if (docc.mozCancelFullScreen) { } else if(docc.mozCancelFullScreen) {
docc.mozCancelFullScreen(); docc.mozCancelFullScreen();
} else if (docc.webkitExitFullscreen) { } else if(docc.webkitExitFullscreen) {
docc.webkitExitFullscreen(); docc.webkitExitFullscreen();
} else if (docc.msExitFullscreen) { } else if(docc.msExitFullscreen) {
docc.msExitFullscreen(); docc.msExitFullscreen();
} }
} }
@ -501,11 +499,11 @@ export class VideoScene implements OnInit {
this.onFullscreenChange22(document); this.onFullscreenChange22(document);
} }
onFullscreenChange22(element:any) { onFullscreenChange22(element:any) {
var isInFullScreen = (element.fullscreenElement && element.fullscreenElement !== null) || let isInFullScreen = element.fullscreenElement && element.fullscreenElement !== null ||
(element.webkitFullscreenElement && element.webkitFullscreenElement !== null) || element.webkitFullscreenElement && element.webkitFullscreenElement !== null ||
(element.mozFullScreenElement && element.mozFullScreenElement !== null) || element.mozFullScreenElement && element.mozFullScreenElement !== null ||
(element.msFullscreenElement && element.msFullscreenElement !== null); element.msFullscreenElement && element.msFullscreenElement !== null;
console.log("onFullscreenChange(" + isInFullScreen + ")"); console.log(`onFullscreenChange(${ isInFullScreen })`);
this.isFullScreen = isInFullScreen; this.isFullScreen = isInFullScreen;
} }
@ -515,61 +513,61 @@ export class VideoScene implements OnInit {
} }
onVolume(newValue:any) { onVolume(newValue:any) {
console.log("onVolume " + newValue.value); console.log(`onVolume ${ newValue.value}`);
this.startHideTimer(); this.startHideTimer();
if (this.videoPlayer === null if(this.videoPlayer === null ||
|| this.videoPlayer === undefined) { this.videoPlayer === undefined) {
console.log("error element: " + this.videoPlayer); console.log(`error element: ${ this.videoPlayer}`);
return; return;
} }
this.volumeValue = newValue.value; this.volumeValue = newValue.value;
this.videoPlayer.volume = this.volumeValue/100; this.videoPlayer.volume = this.volumeValue / 100;
this.videoPlayer.muted=false; this.videoPlayer.muted = false;
} }
onVolumeMute() { onVolumeMute() {
this.startHideTimer(); this.startHideTimer();
if (this.videoPlayer === null if(this.videoPlayer === null ||
|| this.videoPlayer === undefined) { this.videoPlayer === undefined) {
console.log("error element: " + this.videoPlayer); console.log(`error element: ${ this.videoPlayer}`);
return; return;
} }
this.videoPlayer.muted=true; this.videoPlayer.muted = true;
} }
onVolumeUnMute() { onVolumeUnMute() {
this.startHideTimer(); this.startHideTimer();
if (this.videoPlayer === null if(this.videoPlayer === null ||
|| this.videoPlayer === undefined) { this.videoPlayer === undefined) {
console.log("error element: " + this.videoPlayer); console.log(`error element: ${ this.videoPlayer}`);
return; return;
} }
this.videoPlayer.muted=false; this.videoPlayer.muted = false;
} }
onTakeScreenShoot() { onTakeScreenShoot() {
this.startHideTimer(); this.startHideTimer();
//const canvas = document.createElement("canvas"); // const canvas = document.createElement("canvas");
// scale the canvas accordingly // scale the canvas accordingly
this.videoCanva.width = this.videoPlayer.videoWidth; this.videoCanva.width = this.videoPlayer.videoWidth;
this.videoCanva.height = this.videoPlayer.videoHeight; this.videoCanva.height = this.videoPlayer.videoHeight;
// draw the video at that frame // draw the video at that frame
this.videoCanva.getContext('2d').drawImage(this.videoPlayer, 0, 0, this.videoCanva.width, this.videoCanva.height); this.videoCanva.getContext('2d').drawImage(this.videoPlayer, 0, 0, this.videoCanva.width, this.videoCanva.height);
//canvas.crossorigin="anonymous" // canvas.crossorigin="anonymous"
// convert it and send it to the server // convert it and send it to the server
let self = this; let self = this;
this.videoCanva.toBlob(function(blob){ this.videoCanva.toBlob((blob) => {
self.videoService.uploadCoverBlob(blob, this.id_video); self.videoService.uploadCoverBlob(blob, this.idVideo);
}, 'image/jpeg', 0.95); }, 'image/jpeg', 0.95);
/* /*
let tmpUrl = this.videoCanva.toDataURL('image/jpeg', 0.95); let tmpUrl = this.videoCanva.toDataURL('image/jpeg', 0.95);
fetch(tmpUrl) fetch(tmpUrl)
.then(res => res.blob()) // Gets the response and returns it as a blob .then(res => res.blob()) // Gets the response and returns it as a blob
.then(blob => { .then(blob => {
self.videoService.uploadCoverBlob(blob, this.id_video); self.videoService.uploadCoverBlob(blob, this.idVideo);
}); });
*/ */
} }
} }

View File

@ -4,9 +4,9 @@
* @license PROPRIETARY (see license file) * @license PROPRIETARY (see license file)
*/ */
import { Injectable, Output, EventEmitter, OnInit} from '@angular/core' import { Injectable, Output, EventEmitter } from '@angular/core';
import { Router, ActivatedRoute, ParamMap, NavigationEnd } from '@angular/router'; import { Router, ActivatedRoute } from '@angular/router';
import { TypeService } from './type'; import { TypeService } from './type';
import { UniverseService } from './universe'; import { UniverseService } from './universe';
@ -16,370 +16,375 @@ import { VideoService } from './video';
import { environment } from '../../environments/environment'; import { environment } from '../../environments/environment';
export class InputOrders { export class InputOrders {
public type_id: number = null; public typeId: number = null;
public universe_id: number = null; public universeId: number = null;
public series_id: number = null; public seriesId: number = null;
public season_id: number = null; public seasonId: number = null;
public video_id: number = null; public videoId: number = null;
} }
@Injectable() @Injectable()
export class ArianeService { export class ArianeService {
public typeId: number = null;
public typeName: string = null;
@Output() typeChange: EventEmitter<number> = new EventEmitter();
public universeId: number = null;
public universeName: string = null;
@Output() universeChange: EventEmitter<number> = new EventEmitter();
public type_id: number = null; public seriesId: number = null;
public type_name: string = null; public seriesName: string = null;
@Output() type_change: EventEmitter<number> = new EventEmitter(); @Output() seriesChange: EventEmitter<number> = new EventEmitter();
public universe_id: number = null; public seasonId: number = null;
public universe_name: string = null; public seasonName: string = null;
@Output() universe_change: EventEmitter<number> = new EventEmitter(); @Output() seasonChange: EventEmitter<number> = new EventEmitter();
public series_id: number = null; public videoId: number = null;
public series_name: string = null; public videoName: string = null;
@Output() series_change: EventEmitter<number> = new EventEmitter(); @Output() videoChange: EventEmitter<number> = new EventEmitter();
public season_id: number = null; constructor(private router: Router,
public season_name: string = null;
@Output() season_change: EventEmitter<number> = new EventEmitter();
public video_id: number = null;
public video_name: string = null;
@Output() video_change: EventEmitter<number> = new EventEmitter();
constructor(private route: ActivatedRoute,
private router: Router,
private typeService: TypeService, private typeService: TypeService,
private universeService: UniverseService, private universeService: UniverseService,
private seriesService: SeriesService, private seriesService: SeriesService,
private seasonService: SeasonService, private seasonService: SeasonService,
private videoService: VideoService) { private videoService: VideoService) {
console.log("Start ArianeService"); console.log('Start ArianeService');
} }
updateParams(params) { updateParams(params) {
console.log("sparams " + params); console.log(`sparams ${ params}`);
console.log("sparams['type_id'] " + params['type_id']); console.log(`sparams['typeId'] ${ params.typeId}`);
if(params['type_id']) { if(params.typeId) {
this.setType(params['type_id']) this.setType(params.typeId);
} else { } else {
this.setType(null); this.setType(null);
} }
} }
updateManual(params) { updateManual(params) {
let type_id = params.get('type_id'); let typeId = params.get('typeId');
if (type_id === null || type_id === undefined || type_id == "null" || type_id == "NULL" || type_id == "") { if(typeId === null || typeId === undefined || typeId === 'null' || typeId === 'NULL' || typeId === '') {
type_id = null; typeId = null;
} else { } else {
type_id = parseInt(type_id) typeId = parseInt(typeId, 10);
} }
console.log("type_id = " + type_id + " " + params.get('type_id')); console.log(`typeId = ${ typeId } ${ params.get('typeId')}`);
let universe_id = params.get('universe_id'); let universeId = params.get('universeId');
if (universe_id === null || universe_id === undefined || universe_id == "null" || universe_id == "NULL" || universe_id == "") { if(universeId === null || universeId === undefined || universeId === 'null' || universeId === 'NULL' || universeId === '') {
universe_id = null; universeId = null;
} else { } else {
universe_id = parseInt(universe_id) universeId = parseInt(universeId, 10);
} }
console.log("universe_id = " + universe_id + " " + params.get('univers_id')); console.log(`universeId = ${ universeId } ${ params.get('universId')}`);
let series_id = params.get('series_id'); let seriesId = params.get('seriesId');
if (series_id === null || series_id === undefined || series_id == "null" || series_id == "NULL" || series_id == "") { if(seriesId === null || seriesId === undefined || seriesId === 'null' || seriesId === 'NULL' || seriesId === '') {
series_id = null; seriesId = null;
} else { } else {
series_id = parseInt(series_id) seriesId = parseInt(seriesId, 10);
} }
console.log("series_id = " + series_id + " " + params.get('series_id')); console.log(`seriesId = ${ seriesId } ${ params.get('seriesId')}`);
let season_id = params.get('season_id'); let seasonId = params.get('seasonId');
if (season_id === null || season_id === undefined || season_id == "null" || season_id == "NULL" || season_id == "") { if(seasonId === null || seasonId === undefined || seasonId === 'null' || seasonId === 'NULL' || seasonId === '') {
season_id = null; seasonId = null;
} else { } else {
season_id = parseInt(season_id) seasonId = parseInt(seasonId, 10);
} }
console.log("season_id = " + season_id + " " + params.get('season_id')); console.log(`seasonId = ${ seasonId } ${ params.get('seasonId')}`);
let video_id = params.get('video_id'); let videoId = params.get('videoId');
if (video_id === null || video_id === undefined || video_id == "null" || video_id == "NULL" || video_id == "") { if(videoId === null || videoId === undefined || videoId === 'null' || videoId === 'NULL' || videoId === '') {
video_id = null; videoId = null;
} else { } else {
video_id = parseInt(video_id) videoId = parseInt(videoId, 10);
} }
console.log("video_id = " + video_id + " " + params.get('video_id')); console.log(`videoId = ${ videoId } ${ params.get('videoId')}`);
this.setType(type_id); this.setType(typeId);
this.setUniverse(universe_id); this.setUniverse(universeId);
this.setSeries(series_id); this.setSeries(seriesId);
this.setSeason(season_id); this.setSeason(seasonId);
this.setVideo(video_id); this.setVideo(videoId);
} }
reset():void { reset():void {
this.type_id = null; this.typeId = null;
this.type_name = null; this.typeName = null;
this.type_change.emit(this.type_id); this.typeChange.emit(this.typeId);
this.universe_id = null; this.universeId = null;
this.universe_name = null; this.universeName = null;
this.universe_change.emit(this.universe_id); this.universeChange.emit(this.universeId);
this.series_id = null; this.seriesId = null;
this.series_name = null; this.seriesName = null;
this.series_change.emit(this.series_id); this.seriesChange.emit(this.seriesId);
this.season_id = null; this.seasonId = null;
this.season_name = null; this.seasonName = null;
this.season_change.emit(this.season_id); this.seasonChange.emit(this.seasonId);
this.video_id = null; this.videoId = null;
this.video_name = null; this.videoName = null;
this.video_change.emit(this.video_id); this.videoChange.emit(this.videoId);
} }
/* /*
getCurrentRoute():InputOrders { getCurrentRoute():InputOrders {
let out = new InputOrders() let out = new InputOrders()
out.type_id = parseInt(this.route.snapshot.paramMap.get('type_id')); out.typeId = parseInt(this.route.snapshot.paramMap.get('typeId'));
if (out.type_id == 0){ if (out.typeId === 0){
out.type_id = undefined; out.typeId = undefined;
} }
out.universe_id = parseInt(this.route.snapshot.paramMap.get('univers_id')); out.universeId = parseInt(this.route.snapshot.paramMap.get('universId'));
if (out.universe_id == 0){ if (out.universeId === 0){
out.universe_id = undefined; out.universeId = undefined;
} }
out.series_id = parseInt(this.route.snapshot.paramMap.get('series_id')); out.seriesId = parseInt(this.route.snapshot.paramMap.get('seriesId'));
if (out.series_id == 0){ if (out.seriesId === 0){
out.series_id = undefined; out.seriesId = undefined;
} }
out.season_id = parseInt(this.route.snapshot.paramMap.get('season_id')); out.seasonId = parseInt(this.route.snapshot.paramMap.get('seasonId'));
if (out.season_id == 0){ if (out.seasonId === 0){
out.season_id = undefined; out.seasonId = undefined;
} }
out.video_id = parseInt(this.route.snapshot.paramMap.get('video_id')); out.videoId = parseInt(this.route.snapshot.paramMap.get('videoId'));
if (out.video_id == 0){ if (out.videoId === 0){
out.video_id = undefined; out.videoId = undefined;
} }
return out; return out;
} }
routeTo(_data:InputOrders, _destination:string = null) { routeTo(data:InputOrders, destination:string = null) {
routeTo = "" routeTo = ""
//if ( //if (
this.router.navigate(['/type/' + this.type_id + '/series/' + this.id_series + '/season/' + _idSelected ]); this.router.navigate(['/type/' + this.typeId + '/series/' + this.idSeries + '/season/' + IdSelected ]);
} }
*/ */
setType(_id:number):void { setType(id:number):void {
if (this.type_id == _id) { if(this.typeId === id) {
return; return;
} }
if (_id === undefined) { if(id === undefined) {
return; return;
} }
this.type_id = _id; this.typeId = id;
this.type_name = "??--??"; this.typeName = '??--??';
if (this.type_id === null) { if(this.typeId === null) {
this.type_change.emit(this.type_id); this.typeChange.emit(this.typeId);
return; return;
} }
let self = this; let self = this;
this.typeService.get(_id) this.typeService.get(id)
.then(function(response) { .then((response) => {
self.type_name = response.name self.typeName = response.name;
self.type_change.emit(self.type_id); self.typeChange.emit(self.typeId);
}).catch(function(response) { }).catch((response) => {
self.type_change.emit(self.type_id); self.typeChange.emit(self.typeId);
}); });
} }
getTypeId():number { getTypeId():number {
return this.type_id; return this.typeId;
} }
getTypeName():string { getTypeName():string {
return this.type_name; return this.typeName;
} }
setUniverse(_id:number) { setUniverse(id:number) {
if (this.universe_id == _id) { if(this.universeId === id) {
return; return;
} }
if (_id === undefined) { if(id === undefined) {
return; return;
} }
this.universe_id = _id; this.universeId = id;
this.universe_name = "??--??"; this.universeName = '??--??';
if (this.universe_id === null) { if(this.universeId === null) {
this.universe_change.emit(this.universe_id); this.universeChange.emit(this.universeId);
return; return;
} }
let self = this; let self = this;
this.universeService.get(_id) this.universeService.get(id)
.then(function(response) { .then((response) => {
self.universe_name = response.number self.universeName = response.number;
self.universe_change.emit(self.universe_id); self.universeChange.emit(self.universeId);
}).catch(function(response) { }).catch((response) => {
self.universe_change.emit(self.universe_id); self.universeChange.emit(self.universeId);
}); });
} }
getUniverseId():number { getUniverseId():number {
return this.universe_id; return this.universeId;
} }
getUniverseName():string { getUniverseName():string {
return this.universe_name; return this.universeName;
} }
setSeries(_id:number):void { setSeries(id:number):void {
if (this.series_id == _id) { if(this.seriesId === id) {
return; return;
} }
if (_id === undefined) { if(id === undefined) {
return; return;
} }
this.series_id = _id; this.seriesId = id;
this.series_name = "??--??"; this.seriesName = '??--??';
if (this.series_id === null) { if(this.seriesId === null) {
this.series_change.emit(this.series_id); this.seriesChange.emit(this.seriesId);
return; return;
} }
let self = this; let self = this;
this.seriesService.get(_id) this.seriesService.get(id)
.then(function(response) { .then((response) => {
self.series_name = response.name self.seriesName = response.name;
self.series_change.emit(self.series_id); self.seriesChange.emit(self.seriesId);
}).catch(function(response) { }).catch((response) => {
self.series_change.emit(self.series_id); self.seriesChange.emit(self.seriesId);
}); });
} }
getSeriesId():number { getSeriesId():number {
return this.series_id; return this.seriesId;
} }
getSeriesName():string { getSeriesName():string {
return this.series_name; return this.seriesName;
} }
setSeason(_id:number):void { setSeason(id:number):void {
if (this.season_id == _id) { if(this.seasonId === id) {
return; return;
} }
if (_id === undefined) { if(id === undefined) {
return; return;
} }
this.season_id = _id; this.seasonId = id;
this.season_name = "??--??"; this.seasonName = '??--??';
if (this.season_id === null) { if(this.seasonId === null) {
this.season_change.emit(this.season_id); this.seasonChange.emit(this.seasonId);
return; return;
} }
let self = this; let self = this;
this.seasonService.get(_id) this.seasonService.get(id)
.then(function(response) { .then((response) => {
//self.setSeries(response.series_id); // self.setSeries(response.seriesId);
self.season_name = response.name self.seasonName = response.name;
self.season_change.emit(self.season_id); self.seasonChange.emit(self.seasonId);
}).catch(function(response) { }).catch((response) => {
self.season_change.emit(self.season_id); self.seasonChange.emit(self.seasonId);
}); });
} }
getSeasonId():number { getSeasonId():number {
return this.season_id; return this.seasonId;
} }
getSeasonName():string { getSeasonName():string {
return this.season_name; return this.seasonName;
} }
setVideo(_id:number):void { setVideo(id:number):void {
if (this.video_id == _id) { if(this.videoId === id) {
return; return;
} }
if (_id === undefined) { if(id === undefined) {
return; return;
} }
this.video_id = _id; this.videoId = id;
this.video_name = "??--??"; this.videoName = '??--??';
if (this.video_id === null) { if(this.videoId === null) {
this.video_change.emit(this.video_id); this.videoChange.emit(this.videoId);
return; return;
} }
let self = this; let self = this;
this.videoService.get(_id) this.videoService.get(id)
.then(function(response) { .then((response) => {
//self.setSeason(response.season_id); // self.setSeason(response.seasonId);
//self.setSeries(response.series_id); // self.setSeries(response.seriesId);
self.video_name = response.name; self.videoName = response.name;
self.video_change.emit(self.video_id); self.videoChange.emit(self.videoId);
}).catch(function(response) { }).catch((response) => {
self.video_change.emit(self.video_id); self.videoChange.emit(self.videoId);
}); });
} }
getVideoId():number { getVideoId():number {
return this.video_id; return this.videoId;
} }
getVideoName():string { getVideoName():string {
return this.video_name; return this.videoName;
} }
/** /**
* Generic navigation on the browser. * Generic navigation on the browser.
* @param _destination - new destination url * @param destination - new destination url
* @param _universeId - univers ID * @param universeId - univers ID
* @param _typeId - type IF * @param typeId - type IF
* @param _seriesId - series real ID * @param seriesId - series real ID
* @param _seasonId - season ID * @param seasonId - season ID
* @param _videoId - Video ID * @param videoId - Video ID
* @param _newWindows - open in a new windows * @param newWindows - open in a new windows
* @param replaceCurrentPage - consider the curent page is removed from history * @param replaceCurrentPage - consider the curent page is removed from history
*/ */
genericNavigate(_destination:string, _universeId:number, _typeId:number, _seriesId:number, _seasonId:number, _videoId:number, _newWindows:boolean = false, replaceCurrentPage: boolean = false):void { genericNavigate(
let addressOffset = _destination + '/' + _universeId + '/' + _typeId + '/' + _seriesId + '/' + _seasonId + '/' + _videoId; destination:string,
if(_newWindows==true) { universeId:number,
if (environment.frontBaseUrl === undefined || environment.frontBaseUrl === null || environment.frontBaseUrl === "") { typeId:number,
window.open('/' + addressOffset); seriesId:number,
} else { seasonId:number,
window.open("/" + environment.frontBaseUrl + '/' + addressOffset); videoId:number,
} newWindows:boolean = false,
} else { replaceCurrentPage: boolean = false): void {
this.router.navigate([addressOffset], { replaceUrl: replaceCurrentPage }); let addressOffset = `${destination }/${ universeId }/${ typeId }/${ seriesId }/${ seasonId }/${ videoId}`;
} if(newWindows === true) {
if(environment.frontBaseUrl === undefined || environment.frontBaseUrl === null || environment.frontBaseUrl === '') {
window.open(`/${ addressOffset}`);
} else {
window.open(`/${ environment.frontBaseUrl }/${ addressOffset}`);
}
} else {
this.router.navigate([ addressOffset ], { replaceUrl: replaceCurrentPage });
}
} }
navigateUniverse(_id:number, _newWindows:boolean):void { navigateUniverse(id:number, newWindows:boolean):void {
this.genericNavigate('universe', _id, this.type_id, null, null, null, _newWindows); this.genericNavigate('universe', id, this.typeId, null, null, null, newWindows);
} }
navigateUniverseEdit(_id:number, _newWindows:boolean):void { navigateUniverseEdit(id:number, newWindows:boolean):void {
this.genericNavigate('universe-edit', _id, this.type_id, null, null, null, _newWindows); this.genericNavigate('universe-edit', id, this.typeId, null, null, null, newWindows);
} }
navigateType(_id:number, _newWindows:boolean, _ctrl:boolean = false):void { navigateType(id:number, newWindows:boolean, ctrl:boolean = false):void {
if (_ctrl == true) { if(ctrl === true) {
this.navigateTypeEdit(_id, _newWindows); this.navigateTypeEdit(id, newWindows);
return; return;
} }
this.genericNavigate('type', this.universe_id, _id, null, null, null, _newWindows); this.genericNavigate('type', this.universeId, id, null, null, null, newWindows);
} }
navigateTypeEdit(_id:number, _newWindows:boolean):void { navigateTypeEdit(id:number, newWindows:boolean):void {
this.genericNavigate('type-edit', this.universe_id, _id, null, null, null, _newWindows); this.genericNavigate('type-edit', this.universeId, id, null, null, null, newWindows);
} }
navigateSeries(_id:number, _newWindows:boolean, _ctrl:boolean = false):void { navigateSeries(id:number, newWindows:boolean, ctrl:boolean = false):void {
if (_ctrl == true) { if(ctrl === true) {
this.navigateSeriesEdit(_id, _newWindows); this.navigateSeriesEdit(id, newWindows);
return; return;
} }
this.genericNavigate('series', this.universe_id, this.type_id, _id, null, null, _newWindows); this.genericNavigate('series', this.universeId, this.typeId, id, null, null, newWindows);
} }
navigateSeriesEdit(_id:number, _newWindows:boolean):void { navigateSeriesEdit(id:number, newWindows:boolean):void {
this.genericNavigate('series-edit', this.universe_id, this.type_id, _id, null, null, _newWindows); this.genericNavigate('series-edit', this.universeId, this.typeId, id, null, null, newWindows);
} }
navigateSeason(_id:number, _newWindows:boolean, _ctrl:boolean = false, replaceCurrentPage: boolean = false):void { navigateSeason(id:number, newWindows:boolean, ctrl:boolean = false, replaceCurrentPage: boolean = false):void {
if (_ctrl == true) { if(ctrl === true) {
this.navigateSeasonEdit(_id, _newWindows); this.navigateSeasonEdit(id, newWindows);
return; return;
} }
this.genericNavigate('season', this.universe_id, this.type_id, this.series_id, _id, null, _newWindows, replaceCurrentPage); this.genericNavigate('season', this.universeId, this.typeId, this.seriesId, id, null, newWindows, replaceCurrentPage);
} }
navigateSeasonEdit(_id:number, _newWindows:boolean):void { navigateSeasonEdit(id:number, newWindows:boolean):void {
this.genericNavigate('season-edit', this.universe_id, this.type_id, this.series_id, _id, null, _newWindows); this.genericNavigate('season-edit', this.universeId, this.typeId, this.seriesId, id, null, newWindows);
} }
navigateVideo(_id:number, _newWindows:boolean, _ctrl:boolean = false):void { navigateVideo(id:number, newWindows:boolean, ctrl:boolean = false):void {
if (_ctrl == true) { if(ctrl === true) {
this.navigateVideoEdit(_id, _newWindows); this.navigateVideoEdit(id, newWindows);
return; return;
} }
this.genericNavigate('video', this.universe_id, this.type_id, this.series_id, this.season_id, _id, _newWindows); this.genericNavigate('video', this.universeId, this.typeId, this.seriesId, this.seasonId, id, newWindows);
} }
navigateVideoEdit(_id:number, _newWindows:boolean):void { navigateVideoEdit(id:number, newWindows:boolean):void {
this.genericNavigate('video-edit', this.universe_id, this.type_id, this.series_id, this.season_id, _id, _newWindows); this.genericNavigate('video-edit', this.universeId, this.typeId, this.seriesId, this.seasonId, id, newWindows);
} }
} }

View File

@ -6,128 +6,128 @@ import { DataInterface } from './dataInterface';
@Injectable() @Injectable()
export class BddService { export class BddService {
private bdd = { private bdd = {
"type": null, type: null,
"series": null, series: null,
"season": null, season: null,
"universe": null, universe: null,
"video": null video: null
}; };
private bddPomise = { private bddPomise = {
"type": null, type: null,
"series": null, series: null,
"season": null, season: null,
"universe": null, universe: null,
"video": null video: null
}; };
private base_local_storage_name = 'yota_karideo_bdd_'; private baseLocalStorageName = 'yota_karideo_bdd_';
private use_local_storage = false; // we exceed the limit of 5MB private useLocalStorage = false; // we exceed the limit of 5MB
constructor(private http: HttpWrapperService) { constructor(private http: HttpWrapperService) {
console.log("Start BddService"); console.log('Start BddService');
} }
setAfterPut(_name: string, _id: number, ret: any) { setAfterPut(name: string, id: number, ret: any) {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.get(_name) self.get(name)
.then(function(response:DataInterface) { .then((response:DataInterface) => {
let responseTmp = response; let responseTmp = response;
ret.then(function(response2) { ret.then((response2) => {
responseTmp.set(_id, response2); responseTmp.set(id, response2);
resolve(response2); resolve(response2);
}).catch(function(response2) { }).catch((response2) => {
reject(response2); reject(response2);
}); });
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
asyncSetInDB(_name: string, _id: number, data: any) { asyncSetInDB(name: string, id: number, data: any) {
let self = this; let self = this;
self.get(_name) self.get(name)
.then(function(response:DataInterface) { .then((response:DataInterface) => {
response.set(_id, data); response.set(id, data);
}).catch(function(response) { }).catch((response) => {
// nothing to do ... // nothing to do ...
}); });
} }
delete(_name: string, _id: number, ret: any) { delete(name: string, id: number, ret: any) {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.get(_name) self.get(name)
.then(function(response:DataInterface) { .then((response:DataInterface) => {
let responseTmp = response; let responseTmp = response;
ret.then(function(response2) { ret.then((response2) => {
responseTmp.delete(_id); responseTmp.delete(id);
resolve(response2); resolve(response2);
}).catch(function(response2) { }).catch((response2) => {
reject(response2); reject(response2);
}); });
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
// https://blog.logrocket.com/the-complete-guide-to-using-localstorage-in-javascript-apps-ba44edb53a36/#:~:text=localStorage%20is%20a%20type%20of,browser%20window%20has%20been%20closed.
get(_name: string): any { get(name: string): any {
let self = this; let self = this;
console.log("Try to get DB '" + _name + "'"); console.log(`Try to get DB '${ name }'`);
if (this.bdd[_name] === undefined) { if(this.bdd[name] === undefined) {
console.log("Try to get a non existant DB ... '" + _name + "'"); console.log(`Try to get a non existant DB ... '${ name }'`);
return; return;
} }
if (this.bdd[_name] !== null) { if(this.bdd[name] !== null) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
resolve(self.bdd[_name]); resolve(self.bdd[name]);
}); });
} }
console.log("get DB: ?? " + _name + " ??"); console.log(`get DB: ?? ${ name } ??`);
if (this.bddPomise[_name] == null) { if(this.bddPomise[name] === null) {
this.bddPomise[_name] = new Array<any>(); this.bddPomise[name] = [];
// Try to load Local Data (storage) // Try to load Local Data (storage)
let retriveBDDString = null; let retriveBDDString = null;
if (this.use_local_storage == true) { if(this.useLocalStorage === true) {
localStorage.getItem(this.base_local_storage_name + _name); localStorage.getItem(this.baseLocalStorageName + name);
} }
if (retriveBDDString !== null) { if(retriveBDDString !== null) {
console.log("retrive local bdd string (" + _name + ")= " + retriveBDDString); console.log(`retrive local bdd string (${ name })= ${ retriveBDDString}`);
let retriveBDD = JSON.parse(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); let retriveBDDTmp = new DataInterface(name, retriveBDD);
self.bdd[_name] = retriveBDDTmp; self.bdd[name] = retriveBDDTmp;
for (let iii=0; iii<self.bddPomise[_name].length; iii++) { for(let iii = 0; iii < self.bddPomise[name].length; iii++) {
self.bddPomise[_name][iii]["resolve"](self.bdd[_name]); self.bddPomise[name][iii].resolve(self.bdd[name]);
} }
// brut force update of the BDD : TODO optimise it later ... // brut force update of the BDD : TODO optimise it later ...
console.log("Update BDD (" + _name + ")"); console.log(`Update BDD (${ name })`);
self.http.get_specific(_name) self.http.getSpecific(name)
.then(function(response) { .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); self.bdd[name] = new DataInterface(name, response);
localStorage.setItem(self.base_local_storage_name + _name, JSON.stringify(self.bdd[_name].bdd)); localStorage.setItem(self.baseLocalStorageName + name, JSON.stringify(self.bdd[name].bdd));
}).catch(function(response) { }).catch((response) => {
console.log("[E] " + self.constructor.name + ": cant not get data from remote server: " + _name); console.log(`[E] ${ self.constructor.name }: cant not get data from remote server: ${ name}`);
}); });
} else { } else {
console.log("Download BDD (" + _name + ")"); console.log(`Download BDD (${ name })`);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.http.get_specific(_name) self.http.getSpecific(name)
.then(function(response) { .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); self.bdd[name] = new DataInterface(name, response);
if (self.use_local_storage == true) { if(self.useLocalStorage === true) {
localStorage.setItem(self.base_local_storage_name + _name, JSON.stringify(self.bdd[_name].bdd)); localStorage.setItem(self.baseLocalStorageName + name, JSON.stringify(self.bdd[name].bdd));
} }
for (let iii=0; iii<self.bddPomise[_name].length; iii++) { for(let iii = 0; iii < self.bddPomise[name].length; iii++) {
self.bddPomise[_name][iii]["resolve"](self.bdd[_name]); self.bddPomise[name][iii].resolve(self.bdd[name]);
} }
resolve(self.bdd[_name]); resolve(self.bdd[name]);
}).catch(function(response) { }).catch((response) => {
console.log("[E] " + self.constructor.name + ": can not get data from remote server: " + _name); console.log(`[E] ${ self.constructor.name }: can not get data from remote server: ${ name}`);
for (let iii=0; iii<self.bddPomise[_name].length; iii++) { for(let iii = 0; iii < self.bddPomise[name].length; iii++) {
self.bddPomise[_name][iii]["reject"](response); self.bddPomise[name][iii].reject(response);
} }
reject(response); reject(response);
}); });
@ -135,32 +135,32 @@ export class BddService {
} }
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (self.bdd[_name] != null) { if(self.bdd[name] !== null) {
resolve(self.bdd[_name]); resolve(self.bdd[name]);
return; return;
} }
self.bddPomise[_name].push({"resolve": resolve, "reject": reject}); self.bddPomise[name].push({ resolve: resolve, reject: reject });
}); });
} }
getType():any { getType():any {
return this.get("type"); return this.get('type');
} }
getSeries():any { getSeries():any {
return this.get("series"); return this.get('series');
} }
getSeason():any { getSeason():any {
return this.get("season"); return this.get('season');
} }
getUniverse():any { getUniverse():any {
return this.get("universe"); return this.get('universe');
} }
getVideo():any { getVideo():any {
return this.get("video"); return this.get('video');
} }
} }

View File

@ -8,39 +8,38 @@ import { Injectable } from '@angular/core';
@Injectable() @Injectable()
export class CookiesService { export class CookiesService {
constructor() { constructor() {
} }
set(cname, cvalue, exdays) { set(cname, cvalue, exdays) {
if (this.get(cname) != "") { if(this.get(cname) !== '') {
// reset previous cookies... // reset previous cookies...
document.cookie = cname + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/"; document.cookie = `${cname }=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`;
} }
let d = new Date(); let ddd = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); ddd.setTime(ddd.getTime() + exdays * 24 * 60 * 60 * 1000);
let expires = "expires="+d.toUTCString(); let expires = `expires=${ddd.toUTCString()}`;
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; document.cookie = `${cname }=${ cvalue };${ expires };path=/`;
} }
remove(cname) { remove(cname) {
this.set(cname, "", 0); this.set(cname, '', 0);
} }
get(cname) { get(cname) {
let name = cname + "="; let name = `${cname }=`;
let ca = document.cookie.split(';'); let coolies = document.cookie.split(';');
for(let i = 0; i < ca.length; i++) { for(let iii = 0; iii < coolies.length; iii++) {
let c = ca[i]; let ccc = coolies[iii];
while (c.charAt(0) == ' ') { while(ccc.charAt(0) === ' ') {
c = c.substring(1); ccc = ccc.substring(1);
} }
if (c.indexOf(name) == 0) { if(ccc.indexOf(name) === 0) {
return c.substring(name.length, c.length); return ccc.substring(name.length, ccc.length);
} }
} }
return ""; return '';
} }
} }

View File

@ -8,28 +8,28 @@ export class DataService {
// 0: Not hide password; 1 hide password; // 0: Not hide password; 1 hide password;
private identificationVersion: number = 1; private identificationVersion: number = 1;
private bdd: DataInterface = null; private bdd: DataInterface = null;
private serviceName:string = "data"; private serviceName:string = 'data';
constructor(private http: HttpWrapperService) { constructor(private http: HttpWrapperService) {
console.log("Start TypeService"); console.log('Start TypeService');
} }
getData():any { getData():any {
return this.http.get_specific(this.serviceName); return this.http.getSpecific(this.serviceName);
} }
get(_id:number):any { get(_id:number):any {
return this.http.get_specific(this.serviceName, _id); return this.http.getSpecific(this.serviceName, _id);
} }
sendFile(_file:File) { sendFile(_file:File) {
//return this.http.uploadFileMultipart(this.serviceName, null, _file); // return this.http.uploadFileMultipart(this.serviceName, null, _file);
return this.http.uploadFileBase64(this.serviceName, null, _file); return this.http.uploadFileBase64(this.serviceName, null, _file);
} }
uploadFile(_form:FormData, _progress:any = null) { uploadFile(_form:FormData, _progress:any = null) {
//return this.http.uploadFileMultipart(this.serviceName, null, _file); // return this.http.uploadFileMultipart(this.serviceName, null, _file);
return this.http.uploadMultipart(this.serviceName + "/upload/", _form, _progress); return this.http.uploadMultipart(`${this.serviceName }/upload/`, _form, _progress);
} }
} }

View File

@ -10,159 +10,155 @@
* @breif Generic interface to access to the BDD (no BDD, direct file IO) * @breif Generic interface to access to the BDD (no BDD, direct file IO)
*/ */
export class DataInterface { export class DataInterface {
private name: string; constructor(
private bdd: any; private name: string,
private bdd: any) {
constructor(_name:string, _data:any) {
this.name = _name;
this.bdd = _data;
} }
get_table_index(_id) { public getTableIndex(id: number) {
for (let iii=0; iii<this.bdd.length; iii++) { for(let iii = 0; iii < this.bdd.length; iii++) {
if (this.bdd[iii]['id'] == _id) { if(this.bdd[iii].id === id) {
return iii; return iii;
} }
} }
return undefined; return undefined;
} }
gets(_filter=undefined) { public gets(filter?: any) {
console.log("[I] gets " + this.name) console.log(`[I] gets ${ this.name}`);
if (_filter == undefined) { if(filter === undefined) {
return this.bdd return this.bdd;
} }
return this.filter_object_values(this.bdd, _filter) return this.filterObjectValues(this.bdd, filter);
} }
gets_where(_select, _filter=undefined, _orderBy=undefined){ public getsWhere(select, filter = undefined, orderBy = undefined) {
//console.log("[I] gets_where " + this.name + " select " + _select); // console.log("[I] gets_where " + this.name + " select " + _select);
let tmp_list = this.get_sub_list(this.bdd, _select); let tmpList = this.getSubList(this.bdd, select);
tmp_list = this.order_by(tmp_list, _orderBy); tmpList = this.orderBy(tmpList, orderBy);
return this.filter_object_values(tmp_list, _filter); return this.filterObjectValues(tmpList, filter);
} }
get(_id){ public get(id: number) {
//console.log("[I] get " + this.name + " " + _id); // console.log("[I] get " + this.name + " " + _id);
for (let iii=0; iii<this.bdd.length; iii++) { for(let iii = 0; iii < this.bdd.length; iii++) {
if (this.bdd[iii]['id'] == _id) { if(this.bdd[iii].id === id) {
return this.bdd[iii]; return this.bdd[iii];
} }
} }
console.log("[W] not found element{ " + this.bdd.length); console.log(`[W] not found element{ ${ this.bdd.length}`);
return undefined; return undefined;
} }
getNameLikeAll(_name: string){ public getNameLikeAll(name: string) {
let out = undefined; let out = undefined;
let nameLower =_name.toLowerCase(); let nameLower = name.toLowerCase();
for (let iii=0; iii<this.bdd.length; iii++) { for(let iii = 0; iii < this.bdd.length; iii++) {
if (this.bdd[iii]['name'].toLowerCase() == nameLower) { if(this.bdd[iii].name.toLowerCase() === nameLower) {
out.push(this.bdd[iii]); out.push(this.bdd[iii]);
} }
} }
if (out.length == 0) { if(out.length === 0) {
return undefined; return undefined;
} }
return out; return out;
} }
getNameLike(_name: string): any[] { public getNameLike(name: string): any[] {
let out = []; let out = [];
let nameLower = _name.toLowerCase(); let nameLower = name.toLowerCase();
for (let iii=0; iii<this.bdd.length; iii++) { for(let iii = 0; iii < this.bdd.length; iii++) {
//console.log("compare '" + _name + "' ??? '" + this.bdd[iii]['name'] + "'"); // console.log("compare '" + _name + "' ??? '" + this.bdd[iii]['name'] + "'");
if (this.bdd[iii]['name'].toLowerCase() == nameLower) { if(this.bdd[iii].name.toLowerCase() === nameLower) {
out.push(this.bdd[iii]); out.push(this.bdd[iii]);
} }
} }
return out; return out;
} }
set(_id, _value){ public set(id: number, value: any) {
console.log("[I] Set " + this.name + " " + _id) console.log(`[I] Set ${ this.name } ${ id}`);
for (let iii=0; iii<this.bdd.length; iii++) { for(let iii = 0; iii < this.bdd.length; iii++) {
console.log(" check: " + " " + this.bdd[iii]['id']) console.log(` check: ${ this.bdd[iii].id}`);
if (this.bdd[iii]['id'] == _id) { if(this.bdd[iii].id === id) {
console.log(" *** Set specific values: " + _id + " " + JSON.stringify(_value, null, 2)); console.log(` *** Set specific values: ${ id } ${ JSON.stringify(value, null, 2)}`);
this.bdd[iii] = _value this.bdd[iii] = value;
} }
} }
} }
delete(_id) { public delete(id: number) {
console.log("[I] delete " + this.name + " " + _id) console.log(`[I] delete ${ this.name } ${ id}`);
for (let iii=0; iii<this.bdd.length; iii++) { for(let iii = 0; iii < this.bdd.length; iii++) {
if (this.bdd[iii]['id'] == _id) { if(this.bdd[iii].id === id) {
this.bdd.splice(iii, 1); this.bdd.splice(iii, 1);
} }
} }
} }
// TODO: rework this public find(listToken, values) {
find(_listToken, _values) { let out = [];
let out = [] for(let iii = 0; iii < this.bdd.length; iii++) {
for (let iii=0; iii<this.bdd.length; iii++) { let find = true;
let find = true for(let jjj = 0; jjj < listToken.length; jjj++) {
for (let jjj=0; jjj<_listToken.length; jjj++) { if(this.bdd[iii][listToken[jjj]] !== values[listToken[jjj]]) {
if (this.bdd[iii][_listToken[jjj]] != _values[_listToken[jjj]]) {
find = false; find = false;
break; break;
} }
} }
if (find == true) { if(find === true) {
out.push(this.bdd[iii]); out.push(this.bdd[iii]);
} }
} }
return out; return out;
} }
count(_select = undefined) { public count(select = undefined) {
if (_select == undefined) { if(select === undefined) {
return this.bdd.length; return this.bdd.length;
} }
let tmp = this.get_sub_list(this.bdd, _select); let tmp = this.getSubList(this.bdd, select);
return tmp.length; return tmp.length;
} }
exit_in(_value: any, _listValues: any) { public existIn(value: any, listValues: any) {
for (let iii=0; iii<_listValues.length; iii++) { for(let iii = 0; iii < listValues.length; iii++) {
if (_value == _listValues[iii]) { if(value === listValues[iii]) {
return true; return true;
} }
} }
return false; return false;
} }
get_sub_list(_values, _select) { public getSubList(values, select) {
let out = []; let out = [];
for (let iii_elem=0; iii_elem<_values.length; iii_elem++) { for(let iiiElem = 0; iiiElem < values.length; iiiElem++) {
let find = true; let find = true;
if (_select.length == 0) { if(select.length === 0) {
find = false; find = false;
} }
//console.log("Check : " + JSON.stringify(_values[iii_elem], null, 2)); // console.log("Check : " + JSON.stringify(_values[iii_elem], null, 2));
for (let iii_select=0; iii_select < _select.length; iii_select++) { for(let iiiSelect = 0; iiiSelect < select.length; iiiSelect++) {
if (_select[iii_select].length != 3) { if(select[iiiSelect].length !== 3) {
console.log("[E] Internal Server Error: wrong select definition ..."); console.log('[E] Internal Server Error: wrong select definition ...');
return undefined; return undefined;
} }
let type_check = _select[iii_select][0]; let typeCheck = select[iiiSelect][0];
let token = _select[iii_select][1]; let token = select[iiiSelect][1];
let value = _select[iii_select][2]; let value = select[iiiSelect][2];
if (value instanceof Array) { if(Array.isArray(value)) {
if (_values[iii_elem][token] !== undefined) { if(values[iiiElem][token] !== undefined) {
if (type_check == "==") { if(typeCheck === '==') {
if (this.exit_in(_values[iii_elem][token], value) == false) { if(this.existIn(values[iiiElem][token], value) === false) {
find = false find = false;
break break;
} }
} else if (type_check == "!=") { } else if(typeCheck === '!=') {
if (this.exit_in(_values[iii_elem][token], value) == false) { if(this.existIn(values[iiiElem][token], value) === false) {
find = false find = false;
break; break;
} }
} else { } else {
console.log("[ERROR] Internal Server Error{ unknow comparing type ..."); console.log('[ERROR] Internal Server Error{ unknow comparing type ...');
return undefined; return undefined;
} }
} else { } else {
@ -170,41 +166,41 @@ export class DataInterface {
break; break;
} }
} else { } else {
//console.log(" [" + token + "] = " + _values[iii_elem][token]); // console.log(" [" + token + "] = " + values[iii_elem][token]);
if (_values[iii_elem][token] !== undefined) { if(values[iiiElem][token] !== undefined) {
//console.log(" '" + type_check + "' " + value); // console.log(" '" + type_check + "' " + value);
if (type_check == "==") { if(typeCheck === '==') {
if (_values[iii_elem][token] != value) { if(values[iiiElem][token] !== value) {
find = false; find = false;
break; break;
} }
} else if (type_check == "!=") { } else if(typeCheck === '!=') {
if (_values[iii_elem][token] == value) { if(values[iiiElem][token] === value) {
find = false; find = false;
break; break;
} }
} else if (type_check == "<") { } else if(typeCheck === '<') {
if (_values[iii_elem][token] >= value) { if(values[iiiElem][token] >= value) {
find = false; find = false;
break; break;
} }
} else if (type_check == "<=") { } else if(typeCheck === '<=') {
if (_values[iii_elem][token] > value) { if(values[iiiElem][token] > value) {
find = false; find = false;
break; break;
} }
} else if (type_check == ">") { } else if(typeCheck === '>') {
if (_values[iii_elem][token] <= value) { if(values[iiiElem][token] <= value) {
find = false; find = false;
break; break;
} }
} else if (type_check == ">=") { } else if(typeCheck === '>=') {
if (_values[iii_elem][token] < value) { if(values[iiiElem][token] < value) {
find = false; find = false;
break; break;
} }
} else { } else {
console.log("[ERROR] Internal Server Error{ unknow comparing type ..."); console.log('[ERROR] Internal Server Error{ unknow comparing type ...');
return undefined; return undefined;
} }
} else { } else {
@ -213,92 +209,99 @@ export class DataInterface {
} }
} }
} }
if (find == true) { if(find === true) {
//console.log(" ==> SELECTED"); // console.log(" ==> SELECTED");
out.push(_values[iii_elem]) out.push(values[iiiElem]);
} else { } else {
//console.log(" ==> NOT SELECTED"); // console.log(" ==> NOT SELECTED");
} }
} }
return out; return out;
} }
order_by(_values, _order) { public orderBy(values, order) {
if (_order == undefined) { if(order === undefined) {
return _values; return values;
} }
if (_order.length == 0) { if(order.length === 0) {
return _values; return values;
} }
let value_order = _order[0] let valueOrder = order[0];
let out = [] let out = [];
let out_unclassable = [] let outUnclassable = [];
for (let iii=0; iii<_values.length; iii++) { for(let iii = 0; iii < values.length; iii++) {
if (_values[iii][value_order] === undefined) { if(values[iii][valueOrder] === undefined) {
out_unclassable.push(_values[iii]); outUnclassable.push(values[iii]);
continue; continue;
} }
if (_values[iii][value_order] == null) { if(values[iii][valueOrder] === null) {
out_unclassable.push(_values[iii]); outUnclassable.push(values[iii]);
continue; continue;
} }
out.push(_values[iii]); out.push(values[iii]);
} }
//console.log("order in list by : " + value_order); // console.log("order in list by : " + value_order);
//out = sorted(out, key=lambda x{ x[value_order]) // out = sorted(out, key=lambda x{ x[value_order])
if (value_order == "name") { if(valueOrder === 'name') {
out.sort(function (a, b) { out.sort((aaa, bbb) => {
const name1 = a[value_order].toLowerCase(); const name1 = aaa[valueOrder].toLowerCase();
const name2 = b[value_order].toLowerCase(); const name2 = bbb[valueOrder].toLowerCase();
if (name1 > name2) { return 1; } if(name1 > name2) {
if (name1 < name2) { return -1; } return 1;
}
if(name1 < name2) {
return -1;
}
return 0; return 0;
}); });
} else { } else {
out.sort(function (a, b) { out.sort((aaa, bbb) => {
if (a[value_order] > b[value_order]) { return 1; } if(aaa[valueOrder] > bbb[valueOrder]) {
if (a[value_order] < b[value_order]) { return -1; } return 1;
}
if(aaa[valueOrder] < bbb[valueOrder]) {
return -1;
}
return 0; return 0;
}); });
} }
if (_order.length > 1) { if(order.length > 1) {
out_unclassable = this.order_by(out_unclassable, _order.slice(1)); outUnclassable = this.orderBy(outUnclassable, order.slice(1));
} }
for (let jjj=0; jjj<out_unclassable.length; jjj++) { for(let jjj = 0; jjj < outUnclassable.length; jjj++) {
out.push(out_unclassable[jjj]); out.push(outUnclassable[jjj]);
} }
return out; return out;
} }
filter_object_values(_values, _filter) { public filterObjectValues(values, filter) {
let out = [] let out = [];
if (_filter == undefined) { if(filter === undefined) {
return _values; return values;
} }
if (_filter.length == 1) { if(filter.length === 1) {
let token = _filter[0] let token = filter[0];
for (let iii=0; iii<_values.length; iii++) { for(let iii = 0; iii < values.length; iii++) {
if (_values[iii][token] === undefined) { if(values[iii][token] === undefined) {
continue; continue;
} }
if (this.exit_in(_values[iii][token], out) == false) { if(this.existIn(values[iii][token], out) === false) {
out.push(_values[iii][token]); out.push(values[iii][token]);
} }
} }
return out; return out;
} }
for (let iii=0; iii<_values.length; iii++) { for(let iii = 0; iii < values.length; iii++) {
let element_out = {} let elementOut = {};
for (let jjj=0; jjj<_filter.length; jjj++) { for(let jjj = 0; jjj < filter.length; jjj++) {
if (_values[iii][_filter[jjj]] === undefined) { if(values[iii][filter[jjj]] === undefined) {
continue; continue;
} }
element_out[_filter[jjj]] = _values[iii][_filter[jjj]] elementOut[filter[jjj]] = values[iii][filter[jjj]];
} }
out.push(element_out) out.push(elementOut);
} }
return out; return out;
} }
} }

View File

@ -1,8 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams, HttpRequest, HttpEvent} from '@angular/common/http'; import { HttpClient, HttpHeaders } from '@angular/common/http';
import { catchError, map, tap } from 'rxjs/operators';
import {Observable} from "rxjs";
import { environment } from '../../environments/environment'; import { environment } from '../../environments/environment';
@ -13,186 +11,186 @@ export class HttpOAuthWrapperService {
} }
createRESTCall(_api:string, _options:any = undefined) { createRESTCall(api:string, inputOptions?: any) {
let basePage = environment.apiOAuthUrl; let basePage = environment.apiOAuthUrl;
let addressServerRest = basePage + "/"; let addressServerRest = `${basePage }/`;
let out; let options = inputOptions;
if (typeof _options === 'undefined') { if(typeof options === 'undefined') {
_options = []; options = [];
} }
out = addressServerRest + _api; let out = addressServerRest + api;
let first = true; let first = true;
for (let iii=0; iii<_options.length; iii++) { for(let iii = 0; iii < options.length; iii++) {
if (first ==false) { if(first === false) {
out += "&"; out = `${out }&`;
} else { } else {
out += "?"; out = `${out }?`;
first = false; first = false;
} }
out += _options[iii]; out = out + options[iii];
} }
return out; return out;
} }
get(_uriRest:string, _headerOption:any, _params:any) { get(uriRest:string, headerOption:any, params:any) {
let connectionAdresse = this.createRESTCall(_uriRest, {}); let connectionAdresse = this.createRESTCall(uriRest, {});
let config = { let config = {
params: _params, params: params,
headers: new HttpHeaders(_headerOption) headers: new HttpHeaders(headerOption)
}; };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.displayReturn == true) { if(this.displayReturn === true) {
console.log("call GET " + connectionAdresse + " params=" + JSON.stringify(_params, null, 2)); console.log(`call GET ${ connectionAdresse } params=${ JSON.stringify(params, null, 2)}`);
} }
let request = this.http.get<any>(connectionAdresse, config); let request = this.http.get<any>(connectionAdresse, config);
let self = this; let self = this;
request.subscribe((res: any) => { request.subscribe((res: any) => {
if (self.displayReturn == true) { if(self.displayReturn === true) {
console.log("!! data " + JSON.stringify(res, null, 2)); console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
} }
if (res) { if(res) {
if (res.httpCode) { if(res.httpCode) {
resolve({status:res.httpCode, data:res}); resolve({ status:res.httpCode, data:res });
} else {
resolve({status:200, data:res});
}
} else { } else {
resolve({status:200, data:""}); resolve({ status:200, data:res });
} }
}, } else {
error => { resolve({ status:200, data:'' });
if (self.displayReturn == true) { }
console.log("an error occured status: " + error.status); },
console.log("answer: " + JSON.stringify(error, null, 2)); (error) => {
} if(self.displayReturn === true) {
reject({status:error.status, data:error.error}); console.log(`an error occured status: ${ error.status}`);
}); console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
}
reject({ status:error.status, data:error.error });
}); });
});
} }
post(_uriRest:string, _headerOption:any, _data:any) { post(uriRest:string, headerOption:any, data:any) {
let connectionAdresse = this.createRESTCall(_uriRest, {}); let connectionAdresse = this.createRESTCall(uriRest, {});
const httpOption = { const httpOption = {
headers: new HttpHeaders(_headerOption) headers: new HttpHeaders(headerOption)
}; };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.displayReturn == true) { if(this.displayReturn === true) {
console.log("call POST " + connectionAdresse + " data=" + JSON.stringify(_data, null, 2)); console.log(`call POST ${ connectionAdresse } data=${ JSON.stringify(data, null, 2)}`);
} }
let request = this.http.post<any>(connectionAdresse, _data, httpOption); let request = this.http.post<any>(connectionAdresse, data, httpOption);
let self = this; let self = this;
request.subscribe((res: any) => { request.subscribe((res: any) => {
if (self.displayReturn == true) { if(self.displayReturn === true) {
console.log("!! data " + JSON.stringify(res, null, 2)); console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
} }
if (res) { if(res) {
if (res.httpCode) { if(res.httpCode) {
resolve({status:res.httpCode, data:res}); resolve({ status:res.httpCode, data:res });
} else {
resolve({status:200, data:res});
}
} else { } else {
resolve({status:200, data:""}); resolve({ status:200, data:res });
} }
}, } else {
error => { resolve({ status:200, data:'' });
if (self.displayReturn == true) { }
console.log("an error occured status: " + error.status); },
console.log("answer: " + JSON.stringify(error, null, 2)); (error) => {
} if(self.displayReturn === true) {
reject({status:error.status, data:error.error}); console.log(`an error occured status: ${ error.status}`);
}); console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
}
reject({ status:error.status, data:error.error });
}); });
});
} }
put(_uriRest:string, _headerOption:any, _data:any) { put(uriRest:string, headerOption:any, data:any) {
let connectionAdresse = this.createRESTCall(_uriRest, {}); let connectionAdresse = this.createRESTCall(uriRest, {});
const httpOption = { const httpOption = {
headers: new HttpHeaders(_headerOption) headers: new HttpHeaders(headerOption)
}; };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.displayReturn == true) { if(this.displayReturn === true) {
console.log("call POST " + connectionAdresse + " data=" + JSON.stringify(_data, null, 2)); console.log(`call POST ${ connectionAdresse } data=${ JSON.stringify(data, null, 2)}`);
} }
let request = this.http.put<any>(connectionAdresse, _data, httpOption); let request = this.http.put<any>(connectionAdresse, data, httpOption);
let self = this; let self = this;
request.subscribe((res: any) => { request.subscribe((res: any) => {
if (self.displayReturn == true) { if(self.displayReturn === true) {
console.log("!! data " + JSON.stringify(res, null, 2)); console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
} }
if (res) { if(res) {
if (res.httpCode) { if(res.httpCode) {
resolve({status:res.httpCode, data:res}); resolve({ status:res.httpCode, data:res });
} else {
resolve({status:200, data:res});
}
} else { } else {
resolve({status:200, data:""}); resolve({ status:200, data:res });
} }
}, } else {
error => { resolve({ status:200, data:'' });
if (self.displayReturn == true) { }
console.log("an error occured status: " + error.status); },
console.log("answer: " + JSON.stringify(error, null, 2)); (error) => {
} if(self.displayReturn === true) {
reject({status:error.status, data:error.error}); console.log(`an error occured status: ${ error.status}`);
}); console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
}
reject({ status:error.status, data:error.error });
}); });
});
} }
delete(_uriRest:string, _headerOption:any) { delete(uriRest:string, headerOption:any) {
let connectionAdresse = this.createRESTCall(_uriRest, {}); let connectionAdresse = this.createRESTCall(uriRest, {});
const httpOption = { const httpOption = {
headers: new HttpHeaders(_headerOption) headers: new HttpHeaders(headerOption)
}; };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.displayReturn == true) { if(this.displayReturn === true) {
console.log("call POST " + connectionAdresse); console.log(`call POST ${ connectionAdresse}`);
} }
let request = this.http.delete<any>(connectionAdresse, httpOption); let request = this.http.delete<any>(connectionAdresse, httpOption);
let self = this; let self = this;
request.subscribe((res: any) => { request.subscribe((res: any) => {
if (self.displayReturn == true) { if(self.displayReturn === true) {
console.log("!! data " + JSON.stringify(res, null, 2)); console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
} }
if (res) { if(res) {
if (res.httpCode) { if(res.httpCode) {
resolve({status:res.httpCode, data:res}); resolve({ status:res.httpCode, data:res });
} else {
resolve({status:200, data:res});
}
} else { } else {
resolve({status:200, data:""}); resolve({ status:200, data:res });
} }
}, } else {
error => { resolve({ status:200, data:'' });
if (self.displayReturn == true) { }
console.log("an error occured status: " + error.status); },
console.log("answer: " + JSON.stringify(error, null, 2)); (error) => {
} if(self.displayReturn === true) {
reject({status:error.status, data:error.error}); console.log(`an error occured status: ${ error.status}`);
}); console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
}
reject({ status:error.status, data:error.error });
}); });
});
} }
uploadFileMultipart(_base:string, _id:number, _file:File): any { uploadFileMultipart(base:string, id:number, file:File): any {
console.log("Upload file to " + _base); console.log(`Upload file to ${ base}`);
let url = _base; let url = base;
if (_id != null) { if(id !== null) {
url += "/" + _id; url = `${url }/${ id}`;
} }
let formData = new FormData(); let formData = new FormData();
formData.append('upload', _file); formData.append('upload', file);
let headers = new Headers(); let headers = new Headers();
console.log("upload filename : " + _file.name); console.log(`upload filename : ${ file.name}`);
let extention = _file.name.split('.').pop(); let extention = file.name.split('.').pop();
if (extention == "jpg") { if(extention === 'jpg') {
headers.append('Content-Type', "image/jpeg"); headers.append('Content-Type', 'image/jpeg');
} else if (extention == "png") { } else if(extention === 'png') {
headers.append('Content-Type', "image/png"); headers.append('Content-Type', 'image/png');
} else { } else {
return null; return null;
} }
headers.append('filename', _file.name); headers.append('filename', file.name);
const httpOption = { const httpOption = {
headers: headers, headers: headers,
@ -200,224 +198,226 @@ export class HttpOAuthWrapperService {
}; };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.post(url, httpOption, formData) this.post(url, httpOption, formData)
.then(function(response: any) { .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) { if(response.status === 200) {
resolve(response.data); resolve(response.data);
return; return;
} }
reject("An error occured"); reject('An error occured');
}, function(response: any) { }, (response: any) => {
if (typeof response.data === 'undefined') { if(typeof response.data === 'undefined') {
reject("return ERROR undefined"); reject('return ERROR undefined');
} else { } else {
reject("return ERROR " + JSON.stringify(response.data, null, 2)); reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
} }
}); });
}); });
} }
uploadFileBase64(_base:string, _id:number, _file:File): any { /*
console.log("Upload file to " + _base); uploadFileBase64(base:string, id:number, file:File): any {
console.log(`Upload file to ${ base}`);
let url = _base; let url = base;
if (_id != null) { if(id !== null) {
url += "/" + _id; url = `${url }/${ id}`;
} }
let self = this; let self = this;
let reader = new FileReader(); let reader = new FileReader();
reader.readAsArrayBuffer(_file); reader.readAsArrayBuffer(file);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
reader.onload = () => { reader.onload = () => {
let headers = {};//new Headers(); let headers = {};// new Headers();
console.log("upload filename : " + _file.name); console.log(`upload filename : ${ file.name}`);
let extention = _file.name.split('.').pop(); let extention = file.name.split('.').pop();
if (extention == "jpg") { if(extention === 'jpg') {
//headers.append('Content-Type', "image/jpeg"); // headers.append('Content-Type', "image/jpeg");
headers['Content-Type'] = "image/jpeg"; headers['Content-Type'] = 'image/jpeg';
headers['mime-type'] = "image/jpeg"; headers['mime-type'] = 'image/jpeg';
} else if (extention == "jpeg") { } else if(extention === 'jpeg') {
//headers.append('Content-Type', "image/jpeg"); // headers.append('Content-Type', "image/jpeg");
headers['Content-Type'] = "image/jpeg"; headers['Content-Type'] = 'image/jpeg';
headers['mime-type'] = "image/jpeg"; headers['mime-type'] = 'image/jpeg';
} else if (extention == "webp") { } else if(extention === 'webp') {
//headers.append('Content-Type', "image/webp"); // headers.append('Content-Type', "image/webp");
headers['Content-Type'] = "image/webp"; headers['Content-Type'] = 'image/webp';
headers['mime-type'] = "image/webp"; headers['mime-type'] = 'image/webp';
} else if (extention == "png") { } else if(extention === 'png') {
//headers.append('Content-Type', "image/png"); // headers.append('Content-Type', "image/png");
headers['Content-Type'] = "image/png"; headers['Content-Type'] = 'image/png';
headers['mime-type'] = "image/png"; headers['mime-type'] = 'image/png';
} else { } else {
return null; return null;
} }
//headers.append('filename', _file.name); // headers.append('filename', _file.name);
headers['filename'] = _file.name; headers.filename = file.name;
self.post(url, headers, reader.result) self.post(url, headers, reader.result)
.then(function(response: any) { .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) { if(response.status === 200) {
resolve(response.data); resolve(response.data);
return; return;
} }
reject("An error occured"); reject('An error occured');
}, function(response: any) { }, (response: any) => {
if (typeof response.data === 'undefined') { if(typeof response.data === 'undefined') {
reject("return ERROR undefined"); reject('return ERROR undefined');
} else { } else {
reject("return ERROR ...");// + JSON.stringify(response, null, 2)); reject('return ERROR ...');// + JSON.stringify(response, null, 2));
} }
}); });
}; };
}); });
} }
*/
// Complex wrapper to simplify interaction: // Complex wrapper to simplify interaction:
get_specific(_base:string, _id:number = null, _subElement:string = "", _select:Array<string> = []):any { getSpecific(base:string, id:number = null, subElement:string = '', select:Array<string> = []):any {
console.log("Get All data from " + _base); console.log(`Get All data from ${ base}`);
const httpOption = { 'Content-Type': 'application/json' }; const httpOption = { 'Content-Type': 'application/json' };
let url = _base; let url = base;
if (_id != null) { if(id !== null) {
url += "/" + _id; url = `${url }/${ id}`;
} }
if (_subElement != "") { if(subElement !== '') {
url += "/" + _subElement; url = `${url }/${ subElement}`;
} }
if (_select.length != 0) { if(select.length !== 0) {
let select = "" let out = '';
for (let iii=0; iii<_select.length; iii++) { for(let iii = 0; iii < select.length; iii++) {
if (select.length != 0) { if(select.length !== 0) {
select += "&"; out = `${out }&`;
} }
select += "select=" + _select[iii]; out = `${out }select=${ select[iii]}`;
} }
url += "?" + select; url = `${url }?${ out}`;
} }
//console.log("call GET " + url); // console.log("call GET " + url);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.get(url, httpOption, {}) this.get(url, httpOption, {})
.then(function(response: any) { .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) { if(response.status === 200) {
resolve(response.data); resolve(response.data);
return; return;
} }
reject("An error occured"); reject('An error occured');
}, function(response: any) { }, (response: any) => {
if (typeof response.data === 'undefined') { if(typeof response.data === 'undefined') {
reject("return ERROR undefined"); reject('return ERROR undefined');
} else { } else {
reject("return ERROR " + JSON.stringify(response.data, null, 2)); reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
} }
}); });
}); });
} }
// Complex wrapper to simplify interaction: // Complex wrapper to simplify interaction:
delete_specific(_base:string, _id:number, _subElement:string = ""):any { deleteSpecific(base:string, id:number, subElement:string = ''):any {
//console.log("delete data to " + _base); // console.log("delete data to " + _base);
const httpOption = { 'Content-Type': 'application/json' }; const httpOption = { 'Content-Type': 'application/json' };
let url = _base; let url = base;
if (_id != null) { if(id !== null) {
url += "/" + _id; url = `${url }/${ id}`;
} }
if (_subElement != "") { if(subElement !== '') {
url += "/" + _subElement; url = `${url }/${ subElement}`;
} }
//console.log("call DELETE: " + url); // console.log("call DELETE: " + url);
//console.log(" data: " + JSON.stringify(_data, null, 2)); // console.log(" data: " + JSON.stringify(_data, null, 2));
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.delete(url, httpOption) this.delete(url, httpOption)
.then(function(response: any) { .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) { if(response.status === 200) {
resolve(response.data); resolve(response.data);
return; return;
} }
if (response.status == 201) { if(response.status === 201) {
resolve(response.data); resolve(response.data);
return; return;
} }
reject("An error occured"); reject('An error occured');
}, function(response: any) { }, (response: any) => {
if (typeof response.data === 'undefined') { if(typeof response.data === 'undefined') {
reject("return ERROR undefined"); reject('return ERROR undefined');
} else { } else {
reject("return ERROR " + JSON.stringify(response.data, null, 2)); reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
} }
}); });
}); });
} }
// Complex wrapper to simplify interaction: // Complex wrapper to simplify interaction:
put_specific(_base:string, _id:number, _data:any, _subElement:string = ""):any { putSpecific(base:string, id:number, data:any, subElement:string = ''):any {
//console.log("put data to " + _base); // console.log("put data to " + _base);
const httpOption = { 'Content-Type': 'application/json' }; const httpOption = { 'Content-Type': 'application/json' };
let url = _base; let url = base;
if (_id != null) { if(id !== null) {
url += "/" + _id; url = `${url }/${ id}`;
} }
if (_subElement != "") { if(subElement !== '') {
url += "/" + _subElement; url = `${url }/${ subElement}`;
} }
//console.log("call PUT: " + url); // console.log("call PUT: " + url);
//console.log(" data: " + JSON.stringify(_data, null, 2)); // console.log(" data: " + JSON.stringify(_data, null, 2));
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.put(url, httpOption, _data) this.put(url, httpOption, data)
.then(function(response: any) { .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) { if(response.status === 200) {
resolve(response.data); resolve(response.data);
return; return;
} }
if (response.status == 201) { if(response.status === 201) {
resolve(response.data); resolve(response.data);
return; return;
} }
reject("An error occured"); reject('An error occured');
}, function(response: any) { }, (response: any) => {
if (typeof response.data === 'undefined') { if(typeof response.data === 'undefined') {
reject("return ERROR undefined"); reject('return ERROR undefined');
} else { } else {
reject("return ERROR " + JSON.stringify(response.data, null, 2)); reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
} }
}); });
}); });
} }
// Complex wrapper to simplify interaction: // Complex wrapper to simplify interaction:
post_specific(_base:string, _id:number, _data:any, _subElement:string = ""):any { postSpecific(base:string, id:number, data:any, subElement:string = ''):any {
//console.log("put data to " + _base); // console.log("put data to " + _base);
const httpOption = { 'Content-Type': 'application/json' }; const httpOption = { 'Content-Type': 'application/json' };
let url = _base; let url = base;
if (_id != null) { if(id !== null) {
url += "/" + _id; url = `${url }/${ id}`;
} }
if (_subElement != "") { if(subElement !== '') {
url += "/" + _subElement; url = `${url }/${ subElement}`;
} }
//console.log("call PUT: " + url); // console.log("call PUT: " + url);
//console.log(" data: " + JSON.stringify(_data, null, 2)); // console.log(" data: " + JSON.stringify(_data, null, 2));
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.post(url, httpOption, _data) this.post(url, httpOption, data)
.then(function(response: any) { .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) { if(response.status === 200) {
resolve(response.data); resolve(response.data);
return; return;
} }
if (response.status == 201) { if(response.status === 201) {
resolve(response.data); resolve(response.data);
return; return;
} }
reject("An error occured"); reject('An error occured');
}, function(response: any) { }, (response: any) => {
if (typeof response.data === 'undefined') { if(typeof response.data === 'undefined') {
reject("return ERROR undefined"); reject('return ERROR undefined');
} else { } else {
reject("return ERROR " + JSON.stringify(response.data, null, 2)); reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
} }
}); });
}); });

View File

@ -1,8 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams, HttpRequest, HttpEvent, HttpEventType} from '@angular/common/http'; import { HttpClient, HttpHeaders, HttpEventType } from '@angular/common/http';
import { catchError, map, tap } from 'rxjs/operators';
import {Observable} from "rxjs";
import { environment } from '../../environments/environment'; import { environment } from '../../environments/environment';
import { SessionService } from './session'; import { SessionService } from './session';
@ -15,127 +13,128 @@ export class HttpWrapperService {
} }
createRESTCall(_api:string, _options:any = undefined) { createRESTCall(api: string, inputOptions?: any) {
let basePage = environment.apiUrl; let basePage = environment.apiUrl;
let addressServerRest = basePage + "/"; let addressServerRest = `${basePage }/`;
let out; let options = inputOptions;
if (typeof _options === 'undefined') { if(options === undefined) {
_options = []; options = [];
} }
out = addressServerRest + _api; let out = addressServerRest + api;
let first = true; let first = true;
for (let iii=0; iii<_options.length; iii++) { for(let iii = 0; iii < options.length; iii++) {
if (first ==false) { if(first === false) {
out += "&"; out = `${out }&`;
} else { } else {
out += "?"; out = `${out }?`;
first = false; first = false;
} }
out += _options[iii]; out = out + options[iii];
} }
return out; return out;
} }
addTokenIfNeeded(_headerOption:any): any { addTokenIfNeeded(headerOption:any): any {
if (this.session.sessionData != null) { if(this.session.sessionData !== null) {
if (_headerOption.authorization === undefined) { if(headerOption.authorization === undefined) {
_headerOption["authorization"] = "Yota " + this.session.sessionData.userId + ":" + this.session.sessionData.token; headerOption.authorization = `Yota ${ this.session.sessionData.userId }:${ this.session.sessionData.token}`;
} }
} }
return _headerOption; return headerOption;
} }
get(_uriRest:string, _headerOption:any, _params:any) { get(uriRest:string, headerOption:any, params:any) {
this.addTokenIfNeeded(_headerOption); this.addTokenIfNeeded(headerOption);
let connectionAdresse = this.createRESTCall(_uriRest, {}); let connectionAdresse = this.createRESTCall(uriRest, {});
let config = { let config = {
params: _params, params: params,
headers: new HttpHeaders(_headerOption) headers: new HttpHeaders(headerOption)
}; };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.displayReturn == true) { if(this.displayReturn === true) {
console.log("call GET " + connectionAdresse + " params=" + JSON.stringify(_params, null, 2)); console.log(`call GET ${ connectionAdresse } params=${ JSON.stringify(params, null, 2)}`);
} }
let request = this.http.get<any>(connectionAdresse, config); let request = this.http.get<any>(connectionAdresse, config);
let self = this; let self = this;
request.subscribe((res: any) => { request.subscribe((res: any) => {
if (self.displayReturn == true) { if(self.displayReturn === true) {
console.log("!! data " + JSON.stringify(res, null, 2)); console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
} }
if (res) { if(res) {
if (res.httpCode) { if(res.httpCode) {
resolve({status:res.httpCode, data:res}); resolve({ status:res.httpCode, data:res });
} else {
resolve({status:200, data:res});
}
} else { } else {
resolve({status:200, data:""}); resolve({ status:200, data:res });
} }
}, } else {
error => { resolve({ status:200, data:'' });
if (self.displayReturn == true) { }
console.log("an error occured status: " + error.status); },
console.log("answer: " + JSON.stringify(error, null, 2)); (error) => {
} if(self.displayReturn === true) {
reject({status:error.status, data:error.error}); console.log(`an error occured status: ${ error.status}`);
}); console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
}
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:any = null) {
this.addTokenIfNeeded(_headerOption); this.addTokenIfNeeded(headerOption);
let connectionAdresse = this.createRESTCall(_uriRest, {}); let connectionAdresse = this.createRESTCall(uriRest, {});
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.displayReturn == true) { if(this.displayReturn === true) {
console.log("call POST " + connectionAdresse + " data=" + JSON.stringify(_data, null, 2)); console.log(`call POST ${ connectionAdresse } data=${ JSON.stringify(data, null, 2)}`);
} }
let request = this.http.post(connectionAdresse, _data, { let request = this.http.post(connectionAdresse, data, {
headers: new HttpHeaders(_headerOption), headers: new HttpHeaders(headerOption),
reportProgress: true, reportProgress: true,
observe: 'events' observe: 'events'
}); });
let self = this; let self = this;
request.subscribe((res: any) => { request.subscribe((res: any) => {
if (self.displayReturn == true) { if(self.displayReturn === true) {
console.log("!! data " + JSON.stringify(res, null, 2)); console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
}
if(res.type === HttpEventType.Sent) {
/* res.type === 0 */
console.log('post : Sent');
} else if(res.type === HttpEventType.UploadProgress) {
/* res.type === 1 */
// console.log("post : " + res.loaded + " / " + res.total);
progress(res.loaded, res.total);
} else if(res.type === HttpEventType.ResponseHeader) {
/* res.type === 2 */
console.log('post : get header');
} else if(res.type === HttpEventType.DownloadProgress) {
/* res.type === 3 */
console.log(`post : get DownloadProgress ${ res.loaded}`);
} else if(res.type === HttpEventType.Response) {
/* res.type === 4 */
console.log('post : get response');
if(res.httpCode) {
resolve({ status:res.httpCode, data:res });
} else {
resolve({ status:200, data:res });
} }
if (res.type === HttpEventType.Sent) { } else if(res.type === HttpEventType.User) {
/* res.type == 0 */ /* res.type === 5 */
console.log("post : Sent"); console.log('post : get User');
} 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 { } else {
console.log("post : get unknown ... " + res.type); console.log(`post : get unknown ... ${ res.type}`);
} }
}, },
error => { (error) => {
if (self.displayReturn == true) { if(self.displayReturn === true) {
console.log("an error occured status: " + error.status); console.log(`an error occured status: ${ error.status}`);
console.log("answer: " + JSON.stringify(error, null, 2)); console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
} }
reject({status:error.status, data:error.error}); reject({ status:error.status, data:error.error });
}); });
/* /*
switch (event.type) { switch (event.type) {
@ -152,103 +151,103 @@ export class HttpWrapperService {
}) })
); );
*/ */
}); });
} }
put(_uriRest:string, _headerOption:any, _data:any) { put(uriRest:string, headerOption:any, data:any) {
this.addTokenIfNeeded(_headerOption); this.addTokenIfNeeded(headerOption);
let connectionAdresse = this.createRESTCall(_uriRest, {}); let connectionAdresse = this.createRESTCall(uriRest, {});
const httpOption = { const httpOption = {
headers: new HttpHeaders(_headerOption) headers: new HttpHeaders(headerOption)
}; };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.displayReturn == true) { if(this.displayReturn === true) {
console.log("call POST " + connectionAdresse + " data=" + JSON.stringify(_data, null, 2)); console.log(`call POST ${ connectionAdresse } data=${ JSON.stringify(data, null, 2)}`);
} }
let request = this.http.put<any>(connectionAdresse, _data, httpOption); let request = this.http.put<any>(connectionAdresse, data, httpOption);
let self = this; let self = this;
request.subscribe((res: any) => { request.subscribe((res: any) => {
if (self.displayReturn == true) { if(self.displayReturn === true) {
console.log("!! data " + JSON.stringify(res, null, 2)); console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
} }
if (res) { if(res) {
if (res.httpCode) { if(res.httpCode) {
resolve({status:res.httpCode, data:res}); resolve({ status:res.httpCode, data:res });
} else {
resolve({status:200, data:res});
}
} else { } else {
resolve({status:200, data:""}); resolve({ status:200, data:res });
} }
}, } else {
error => { resolve({ status:200, data:'' });
if (self.displayReturn == true) { }
console.log("an error occured status: " + error.status); },
console.log("answer: " + JSON.stringify(error, null, 2)); (error) => {
} if(self.displayReturn === true) {
reject({status:error.status, data:error.error}); console.log(`an error occured status: ${ error.status}`);
}); console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
}
reject({ status:error.status, data:error.error });
}); });
});
} }
delete(_uriRest:string, _headerOption:any) { delete(uriRest:string, headerOption:any) {
this.addTokenIfNeeded(_headerOption); this.addTokenIfNeeded(headerOption);
let connectionAdresse = this.createRESTCall(_uriRest, {}); let connectionAdresse = this.createRESTCall(uriRest, {});
const httpOption = { const httpOption = {
headers: new HttpHeaders(_headerOption) headers: new HttpHeaders(headerOption)
}; };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.displayReturn == true) { if(this.displayReturn === true) {
console.log("call POST " + connectionAdresse); console.log(`call POST ${ connectionAdresse}`);
} }
let request = this.http.delete<any>(connectionAdresse, httpOption); let request = this.http.delete<any>(connectionAdresse, httpOption);
let self = this; let self = this;
request.subscribe((res: any) => { request.subscribe((res: any) => {
if (self.displayReturn == true) { if(self.displayReturn === true) {
console.log("!! data " + JSON.stringify(res, null, 2)); console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
} }
if (res) { if(res) {
if (res.httpCode) { if(res.httpCode) {
resolve({status:res.httpCode, data:res}); resolve({ status:res.httpCode, data:res });
} else {
resolve({status:200, data:res});
}
} else { } else {
resolve({status:200, data:""}); resolve({ status:200, data:res });
} }
}, } else {
error => { resolve({ status:200, data:'' });
if (self.displayReturn == true) { }
console.log("an error occured status: " + error.status); },
console.log("answer: " + JSON.stringify(error, null, 2)); (error) => {
} if(self.displayReturn === true) {
reject({status:error.status, data:error.error}); console.log(`an error occured status: ${ error.status}`);
}); console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
}
reject({ status:error.status, data:error.error });
}); });
});
} }
uploadFileMultipart(_base:string, _id:number, _file:File): any { uploadFileMultipart(base:string, id:number, file:File): any {
console.log("Upload file to " + _base); console.log(`Upload file to ${ base}`);
let url = _base; let url = base;
if (_id != null) { if(id !== null) {
url += "/" + _id; url = `${url }/${ id}`;
} }
let formData = new FormData(); let formData = new FormData();
formData.append('upload', _file); formData.append('upload', file);
let headers = new Headers(); let headers = new Headers();
console.log("upload filename : " + _file.name); console.log(`upload filename : ${ file.name}`);
let extention = _file.name.split('.').pop(); let extention = file.name.split('.').pop();
if (extention == "jpg") { if(extention === 'jpg') {
headers.append('Content-Type', "image/jpeg"); headers.append('Content-Type', 'image/jpeg');
} else if (extention == "png") { } else if(extention === 'png') {
headers.append('Content-Type', "image/png"); headers.append('Content-Type', 'image/png');
} else if (extention == "mkv") { } else if(extention === 'mkv') {
headers.append('Content-Type', "video/x-matroska"); headers.append('Content-Type', 'video/x-matroska');
} else if (extention == "webm") { } else if(extention === 'webm') {
headers.append('Content-Type', "video/webm"); headers.append('Content-Type', 'video/webm');
} else { } else {
return null; return null;
} }
headers.append('filename', _file.name); headers.append('filename', file.name);
const httpOption = { const httpOption = {
headers: headers, headers: headers,
@ -256,170 +255,171 @@ export class HttpWrapperService {
}; };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.post(url, httpOption, formData) this.post(url, httpOption, formData)
.then(function(response: any) { .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) { if(response.status === 200) {
resolve(response.data); resolve(response.data);
return; return;
} }
reject("An error occured"); reject('An error occured');
}, function(response: any) { }, (response: any) => {
if (typeof response.data === 'undefined') { if(typeof response.data === 'undefined') {
reject("return ERROR undefined"); reject('return ERROR undefined');
} else { } else {
reject("return ERROR " + JSON.stringify(response.data, null, 2)); reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
} }
}); });
}); });
} }
uploadFileBase64(_base:string, _id:number, _file:File): any { uploadFileBase64(base:string, id:number, file:File): any {
console.log("Upload file to " + _base); console.log(`Upload file to ${ base}`);
let url = _base; let url = base;
if (_id != null) { if(id !== null) {
url += "/" + _id; url = `${url }/${ id}`;
} }
let self = this; let self = this;
let reader = new FileReader(); let reader = new FileReader();
reader.readAsArrayBuffer(_file); reader.readAsArrayBuffer(file);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
reader.onload = () => { reader.onload = () => {
let headers = {};//new Headers(); let headers:any = {};// new Headers();
console.log("upload filename : " + _file.name); console.log(`upload filename : ${ file.name}`);
let extention = _file.name.split('.').pop(); let extention = file.name.split('.').pop();
if (extention == "jpg") { if(extention === 'jpg') {
//headers.append('Content-Type', "image/jpeg"); // headers.append('Content-Type', "image/jpeg");
headers['Content-Type'] = "image/jpeg"; headers['Content-Type'] = 'image/jpeg';
headers['mime-type'] = "image/jpeg"; headers['mime-type'] = 'image/jpeg';
} else if (extention == "jpeg") { } else if(extention === 'jpeg') {
//headers.append('Content-Type', "image/jpeg"); // headers.append('Content-Type', "image/jpeg");
headers['Content-Type'] = "image/jpeg"; headers['Content-Type'] = 'image/jpeg';
headers['mime-type'] = "image/jpeg"; headers['mime-type'] = 'image/jpeg';
} else if (extention == "webp") { } else if(extention === 'webp') {
//headers.append('Content-Type', "image/webp"); // headers.append('Content-Type', "image/webp");
headers['Content-Type'] = "image/webp"; headers['Content-Type'] = 'image/webp';
headers['mime-type'] = "image/webp"; headers['mime-type'] = 'image/webp';
} else if (extention == "png") { } else if(extention === 'png') {
//headers.append('Content-Type', "image/png"); // headers.append('Content-Type', "image/png");
headers['Content-Type'] = "image/png"; headers['Content-Type'] = 'image/png';
headers['mime-type'] = "image/png"; headers['mime-type'] = 'image/png';
} else if (extention == "mkv") { } else if(extention === 'mkv') {
headers['Content-Type'] = "video/x-matroska"; headers['Content-Type'] = 'video/x-matroska';
headers['mime-type'] = "video/x-matroska"; headers['mime-type'] = 'video/x-matroska';
} else if (extention == "webm") { } else if(extention === 'webm') {
headers['Content-Type'] = "video/webm"; headers['Content-Type'] = 'video/webm';
headers['mime-type'] = "video/webm"; headers['mime-type'] = 'video/webm';
} else { } else {
return null; return null;
} }
//headers.append('filename', _file.name); // headers.append('filename', file.name);
headers['filename'] = _file.name; headers.filename = file.name;
self.post(url, headers, reader.result) self.post(url, headers, reader.result)
.then(function(response: any) { .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) { if(response.status === 200) {
resolve(response.data); resolve(response.data);
return; return;
} }
reject("An error occured"); reject('An error occured');
}, function(response: any) { }, (response: any) => {
if (typeof response.data === 'undefined') { if(typeof response.data === 'undefined') {
reject("return ERROR undefined"); reject('return ERROR undefined');
} else { } else {
reject("return ERROR ...");// + JSON.stringify(response, null, 2)); reject('return ERROR ...');// + JSON.stringify(response, null, 2));
} }
}); });
}; };
}); });
} }
uploadFile(_base:string, _file:File): any { uploadFile(base:string, file:File): any {
console.log("Upload file to " + _base); console.log(`Upload file to ${ base}`);
let url = _base; let url = base;
let self = this; let self = this;
let reader = new FileReader(); let reader = new FileReader();
reader.readAsArrayBuffer(_file); reader.readAsArrayBuffer(file);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
reader.onload = () => { reader.onload = () => {
let headers = {};//new Headers(); let headers: any = {};// new Headers();
console.log("upload filename : " + _file.name); console.log(`upload filename : ${ file.name}`);
let extention = _file.name.split('.').pop(); let extention = file.name.split('.').pop();
if (extention == "jpg") { if(extention === 'jpg') {
//headers.append('Content-Type', "image/jpeg"); // headers.append('Content-Type', "image/jpeg");
headers['Content-Type'] = "image/jpeg"; headers['Content-Type'] = 'image/jpeg';
headers['mime-type'] = "image/jpeg"; headers['mime-type'] = 'image/jpeg';
} else if (extention == "jpeg") { } else if(extention === 'jpeg') {
//headers.append('Content-Type', "image/jpeg"); // headers.append('Content-Type', "image/jpeg");
headers['Content-Type'] = "image/jpeg"; headers['Content-Type'] = 'image/jpeg';
headers['mime-type'] = "image/jpeg"; headers['mime-type'] = 'image/jpeg';
} else if (extention == "webp") { } else if(extention === 'webp') {
//headers.append('Content-Type', "image/webp"); // headers.append('Content-Type', "image/webp");
headers['Content-Type'] = "image/webp"; headers['Content-Type'] = 'image/webp';
headers['mime-type'] = "image/webp"; headers['mime-type'] = 'image/webp';
} else if (extention == "png") { } else if(extention === 'png') {
//headers.append('Content-Type', "image/png"); // headers.append('Content-Type', "image/png");
headers['Content-Type'] = "image/png"; headers['Content-Type'] = 'image/png';
headers['mime-type'] = "image/png"; headers['mime-type'] = 'image/png';
} else if (extention == "mkv") { } else if(extention === 'mkv') {
headers['Content-Type'] = "video/x-matroska"; headers['Content-Type'] = 'video/x-matroska';
headers['mime-type'] = "video/x-matroska"; headers['mime-type'] = 'video/x-matroska';
} else if (extention == "webm") { } else if(extention === 'webm') {
headers['Content-Type'] = "video/webm"; headers['Content-Type'] = 'video/webm';
headers['mime-type'] = "video/webm"; headers['mime-type'] = 'video/webm';
} else { } else {
return null; return null;
} }
//headers.append('filename', _file.name); // headers.append('filename', file.name);
headers['filename'] = _file.name; headers.filename = file.name;
self.post(url, headers, reader.result) self.post(url, headers, reader.result)
.then(function(response: any) { .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) { if(response.status === 200) {
resolve(response.data); resolve(response.data);
return; return;
} }
reject("An error occured"); reject('An error occured');
}, function(response: any) { }, (response: any) => {
if (typeof response.data === 'undefined') { if(typeof response.data === 'undefined') {
reject("return ERROR undefined"); reject('return ERROR undefined');
} else { } else {
reject("return ERROR ...");// + JSON.stringify(response, null, 2)); reject('return ERROR ...');// + JSON.stringify(response, null, 2));
} }
}); });
}; };
}); });
} }
uploadMultipart(_base:string, _multipart:FormData, _progress:any): any { uploadMultipart(base:string, multipart:FormData, progress:any): any {
console.log("Upload multipart to " + _base); console.log(`Upload multipart to ${ base}`);
let url = _base; let url = base;
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let headers = { let headers = {
//'Content-Type': 'multipart/form-data', // 'Content-Type': 'multipart/form-data',
};//new Headers(); };// new Headers();
self.post(url, headers, _multipart, _progress) self.post(url, headers, multipart, progress)
.then(function(response: any) { .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) { if(response.status >= 200 && response.status <= 299) {
resolve(response.data.body); resolve(response.data.body);
return; return;
} }
reject("An error occured"); reject('An error occured');
}, function(response: any) { }, (response: any) => {
if (typeof response.data === 'undefined') { if(typeof response.data === 'undefined') {
reject("return ERROR undefined"); reject('return ERROR undefined');
} else { } else {
reject("return ERROR ...");// + JSON.stringify(response, null, 2)); reject('return ERROR ...');// + JSON.stringify(response, null, 2));
} }
}); });
}); });
} }
/* /*
public upload(_base:string, _id:number, _file:File): any { public upload(base:string, id:number, file:File): any {
data, userId) { data, userId) {
} }
let uploadURL = `${this.SERVER_URL}/auth/${userId}/avatar`; let uploadURL = `${this.SERVER_URL}/auth/${userId}/avatar`;
@ -445,151 +445,151 @@ export class HttpWrapperService {
} }
*/ */
// Complex wrapper to simplify interaction: // Complex wrapper to simplify interaction:
get_specific(_base:string, _id:number = null, _subElement:string = "", _select:Array<string> = []):any { getSpecific(base:string, id:number = null, subElement:string = '', select:string[] = []):any {
console.log("Get All data from " + _base); console.log(`Get All data from ${ base}`);
const httpOption = { 'Content-Type': 'application/json' }; const httpOption = { 'Content-Type': 'application/json' };
let url = _base; let url = base;
if (_id != null) { if(id !== null) {
url += "/" + _id; url = `${url }/${ id}`;
} }
if (_subElement != "") { if(subElement !== '') {
url += "/" + _subElement; url = `${url }/${ subElement}`;
} }
if (_select.length != 0) { if(select.length !== 0) {
let select = "" let newValue = '';
for (let iii=0; iii<_select.length; iii++) { for(let iii = 0; iii < select.length; iii++) {
if (select.length != 0) { if(select.length !== 0) {
select += "&"; newValue = `${newValue}&`;
} }
select += "select=" + _select[iii]; newValue = `${newValue}select=${select[iii]}`;
} }
url += "?" + select; url = `${url}?${newValue}`;
} }
//console.log("call GET " + url); // console.log("call GET " + url);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.get(url, httpOption, {}) this.get(url, httpOption, {})
.then(function(response: any) { .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) { if(response.status === 200) {
resolve(response.data); resolve(response.data);
return; return;
} }
reject("An error occured"); reject('An error occured');
}, function(response: any) { }, (response: any) => {
if (typeof response.data === 'undefined') { if(typeof response.data === 'undefined') {
reject("return ERROR undefined"); reject('return ERROR undefined');
} else { } else {
reject("return ERROR " + JSON.stringify(response.data, null, 2)); reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
} }
}); });
}); });
} }
// Complex wrapper to simplify interaction: // Complex wrapper to simplify interaction:
delete_specific(_base:string, _id:number, _subElement:string = ""):any { deleteSpecific(base:string, id:number, subElement:string = ''):any {
//console.log("delete data to " + _base); // console.log("delete data to " + base);
const httpOption = { 'Content-Type': 'application/json' }; const httpOption = { 'Content-Type': 'application/json' };
let url = _base; let url = base;
if (_id != null) { if(id !== null) {
url += "/" + _id; url = `${url }/${ id}`;
} }
if (_subElement != "") { if(subElement !== '') {
url += "/" + _subElement; url = `${url }/${ subElement}`;
} }
//console.log("call DELETE: " + url); // console.log("call DELETE: " + url);
//console.log(" data: " + JSON.stringify(_data, null, 2)); // console.log(" data: " + JSON.stringify(data, null, 2));
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.delete(url, httpOption) this.delete(url, httpOption)
.then(function(response: any) { .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) { if(response.status === 200) {
resolve(response.data); resolve(response.data);
return; return;
} }
if (response.status == 201) { if(response.status === 201) {
resolve(response.data); resolve(response.data);
return; return;
} }
reject("An error occured"); reject('An error occured');
}, function(response: any) { }, (response: any) => {
if (typeof response.data === 'undefined') { if(typeof response.data === 'undefined') {
reject("return ERROR undefined"); reject('return ERROR undefined');
} else { } else {
reject("return ERROR " + JSON.stringify(response.data, null, 2)); reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
} }
}); });
}); });
} }
// Complex wrapper to simplify interaction: // Complex wrapper to simplify interaction:
put_specific(_base:string, _id:number, _data:any, _subElement:string = ""):any { putSpecific(base:string, id:number, data:any, subElement:string = ''):any {
//console.log("put data to " + _base); // console.log("put data to " + base);
const httpOption = { 'Content-Type': 'application/json' }; const httpOption = { 'Content-Type': 'application/json' };
let url = _base; let url = base;
if (_id != null) { if(id !== null) {
url += "/" + _id; url = `${url }/${ id}`;
} }
if (_subElement != "") { if(subElement !== '') {
url += "/" + _subElement; url = `${url }/${ subElement}`;
} }
//console.log("call PUT: " + url); // console.log("call PUT: " + url);
//console.log(" data: " + JSON.stringify(_data, null, 2)); // console.log(" data: " + JSON.stringify(data, null, 2));
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.put(url, httpOption, _data) this.put(url, httpOption, data)
.then(function(response: any) { .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) { if(response.status === 200) {
resolve(response.data); resolve(response.data);
return; return;
} }
if (response.status == 201) { if(response.status === 201) {
resolve(response.data); resolve(response.data);
return; return;
} }
reject("An error occured"); reject('An error occured');
}, function(response: any) { }, (response: any) => {
if (typeof response.data === 'undefined') { if(typeof response.data === 'undefined') {
reject("return ERROR undefined"); reject('return ERROR undefined');
} else { } else {
reject("return ERROR " + JSON.stringify(response.data, null, 2)); reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
} }
}); });
}); });
} }
// Complex wrapper to simplify interaction: // Complex wrapper to simplify interaction:
post_specific(_base:string, _id:number, _data:any, _subElement:string = ""):any { postSpecific(base:string, id:number, data:any, subElement:string = ''):any {
//console.log("put data to " + _base); // console.log("put data to " + base);
const httpOption = { 'Content-Type': 'application/json' }; const httpOption = { 'Content-Type': 'application/json' };
let url = _base; let url = base;
if (_id != null) { if(id !== null) {
url += "/" + _id; url = `${url }/${ id}`;
} }
if (_subElement != "") { if(subElement !== '') {
url += "/" + _subElement; url = `${url }/${ subElement}`;
} }
//console.log("call PUT: " + url); // console.log("call PUT: " + url);
//console.log(" data: " + JSON.stringify(_data, null, 2)); // console.log(" data: " + JSON.stringify(data, null, 2));
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.post(url, httpOption, _data) this.post(url, httpOption, data)
.then(function(response: any) { .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) { if(response.status === 200) {
resolve(response.data); resolve(response.data);
return; return;
} }
if (response.status == 201) { if(response.status === 201) {
resolve(response.data); resolve(response.data);
return; return;
} }
reject("An error occured"); reject('An error occured');
}, function(response: any) { }, (response: any) => {
if (typeof response.data === 'undefined') { if(typeof response.data === 'undefined') {
reject("return ERROR undefined"); reject('return ERROR undefined');
} else { } else {
reject("return ERROR " + JSON.stringify(response.data, null, 2)); reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
} }
}); });
}); });

View File

@ -5,7 +5,7 @@ export class PopInService {
private popins: any[] = []; private popins: any[] = [];
constructor() { constructor() {
console.log("Start PopIn Service"); console.log('Start PopIn Service');
} }
add(_popin: any) { add(_popin: any) {
@ -15,8 +15,8 @@ export class PopInService {
remove(_id: string) { remove(_id: string) {
// remove popin from array of active popins // remove popin from array of active popins
for( let iii = 0; iii < this.popins.length; iii++) { for(let iii = 0; iii < this.popins.length; iii++) {
if (this.popins[iii].id === _id) { if(this.popins[iii].id === _id) {
this.popins.splice(iii, 1); this.popins.splice(iii, 1);
return; return;
} }
@ -24,26 +24,25 @@ export class PopInService {
} }
open(_id: string) { open(_id: string) {
//console.log("Try to open pop-in: '" + _id + "'"); // console.log("Try to open pop-in: '" + _id + "'");
// open popin specified by id // open popin specified by id
for (let iii=0; iii<this.popins.length; iii++) { for(let iii = 0; iii < this.popins.length; iii++) {
if (this.popins[iii].id == _id) { if(this.popins[iii].id === _id) {
//console.log(" ==>find it ..."); // console.log(" ==>find it ...");
this.popins[iii].open(); this.popins[iii].open();
return; return;
} }
} }
//console.log(" ==> NOT found !!!!!"); // console.log(" ==> NOT found !!!!!");
} }
close(_id: string) { close(_id: string) {
// close popin specified by id // close popin specified by id
for (let iii=0; iii<this.popins.length; iii++) { for(let iii = 0; iii < this.popins.length; iii++) {
if (this.popins[iii].id == _id) { if(this.popins[iii].id === _id) {
this.popins[iii].close(); this.popins[iii].close();
return; return;
} }
} }
} }
} }

View File

@ -7,120 +7,121 @@ import { BddService } from './bdd';
export class SeasonService { export class SeasonService {
// 0: Not hide password; 1 hide password; // 0: Not hide password; 1 hide password;
private identificationVersion: number = 1; private identificationVersion: number = 1;
private serviceName:string = "season"; private serviceName:string = 'season';
constructor(private http: HttpWrapperService, constructor(private http: HttpWrapperService,
private bdd: BddService) { private bdd: BddService) {
console.log("Start SeasonService"); console.log('Start SeasonService');
} }
get(_id:number):any { get(id:number):any {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getSeason() self.bdd.getSeason()
.then(function(response) { .then((response) => {
let data = response.get(_id); let data = response.get(id);
if (data === null || data === undefined) { if(data === null || data === undefined) {
reject("Data does not exist in the local BDD"); reject('Data does not exist in the local BDD');
return; return;
} }
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
/** /**
* Get all the video for a specific season * Get all the video for a specific season
* @param _id - Id of the season. * @param id - Id of the season.
* @returns a promise on the list of season elements * @returns a promise on the list of season elements
*/ */
getVideo(_id:number):any { getVideo(id:number):any {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getVideo() self.bdd.getVideo()
.then(function(response) { .then((response) => {
//let data = response.gets_where([["==", "season_id", _id]], ["id", "name", "episode"], ["episode", "name"]) // let data = response.getsWhere([["==", "seasonId", id]], ["id", "name", "episode"], ["episode", "name"])
let data = response.gets_where([["==", "season_id", _id]], undefined, ["episode", "name"]) let data = response.gets_where([ [ '==', 'season_id', id ] ], undefined, [ 'episode', 'name' ]);
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
/** /**
* Get the number of video in this saison ID * Get the number of video in this saison ID
* @param _id - Id of the season. * @param id - Id of the season.
* @returns The number of element present in this saison * @returns The number of element present in this saison
*/ */
countVideo(_id:number):any { countVideo(id:number):any {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getVideo() self.bdd.getVideo()
.then(function(response) { .then((response) => {
//let data = response.gets_where([["==", "season_id", _id]], ["id", "name", "episode"], ["episode", "name"]) // let data = response.gets_where([["==", "season_id", _id]], ["id", "name", "episode"], ["episode", "name"])
let data = response.gets_where([["==", "season_id", _id]], undefined, ["episode", "name"]) let data = response.gets_where([ [ '==', 'season_id', id ] ], undefined, [ 'episode', 'name' ]);
resolve(data.length); resolve(data.length);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
put(_id:number, _data:any):any { put(id:number, data:any):any {
let ret = this.http.put_specific(this.serviceName, _id, _data); let ret = this.http.putSpecific(this.serviceName, id, data);
return this.bdd.setAfterPut(this.serviceName, _id, ret); return this.bdd.setAfterPut(this.serviceName, id, ret);
} }
delete(_id:number):any { delete(id:number):any {
let ret = this.http.delete_specific(this.serviceName, _id); let ret = this.http.deleteSpecific(this.serviceName, id);
return this.bdd.delete(this.serviceName, _id, ret); return this.bdd.delete(this.serviceName, id, ret);
} }
getCoverUrl(_coverId:number):any { getCoverUrl(coverId:number):any {
return this.http.createRESTCall("data/" + _coverId); return this.http.createRESTCall(`data/${ coverId}`);
} }
getCoverThumbnailUrl(_coverId:number):any { getCoverThumbnailUrl(coverId:number):any {
return this.http.createRESTCall("data/thumbnail/" + _coverId); return this.http.createRESTCall(`data/thumbnail/${ coverId}`);
} }
deleteCover(_node_id:number, deleteCover(nodeId:number,
_cover_id:number) { coverId:number) {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.http.get_specific(this.serviceName + "/" + _node_id + "/rm_cover" , _cover_id) self.http.getSpecific(`${this.serviceName }/${ nodeId }/rm_cover`, coverId)
.then(function(response) { .then((response) => {
let data = response; let data = response;
if (data === null || data === undefined) { if(data === null || data === undefined) {
reject("error retrive data from server"); reject('error retrive data from server');
return; return;
} }
self.bdd.asyncSetInDB(self.serviceName, _node_id, data); self.bdd.asyncSetInDB(self.serviceName, nodeId, data);
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
uploadCover(_file:File, uploadCover(file:File,
_node_id:number, nodeId:number,
_progress:any = null) { progress:any = null) {
const formData = new FormData(); const formData = new FormData();
formData.append('file_name', _file.name); formData.append('file_name', file.name);
formData.append('node_id', _node_id.toString()); formData.append('node_id', nodeId.toString());
formData.append('file', _file); formData.append('file', file);
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.http.uploadMultipart(this.serviceName + "/" + _node_id + "/add_cover/", formData, _progress) self.http.uploadMultipart(`${this.serviceName }/${ nodeId }/add_cover/`, formData, progress)
.then(function(response) { .then((response) => {
let data = response; let data = response;
if (data === null || data === undefined) { if(data === null || data === undefined) {
reject("error retrive data from server"); reject('error retrive data from server');
return; return;
} }
self.bdd.asyncSetInDB(self.serviceName, _node_id, data); self.bdd.asyncSetInDB(self.serviceName, nodeId, data);
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });

View File

@ -8,26 +8,26 @@ import { BddService } from './bdd';
export class SeriesService { export class SeriesService {
// 0: Not hide password; 1 hide password; // 0: Not hide password; 1 hide password;
private identificationVersion: number = 1; private identificationVersion: number = 1;
private serviceName:string = "series"; private serviceName:string = 'series';
constructor(private http: HttpWrapperService, constructor(private http: HttpWrapperService,
private bdd: BddService) { private bdd: BddService) {
console.log("Start SeriesService"); console.log('Start SeriesService');
} }
get(_id:number):any { get(id:number):any {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getSeries() self.bdd.getSeries()
.then(function(response:DataInterface) { .then((response:DataInterface) => {
let data = response.get(_id); let data = response.get(id);
if (data === null || data === undefined) { if(data === null || data === undefined) {
reject("Data does not exist in the local BDD"); reject('Data does not exist in the local BDD');
return; return;
} }
resolve(data); resolve(data);
return; return;
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
@ -37,11 +37,11 @@ export class SeriesService {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getSeries() self.bdd.getSeries()
.then(function(response:DataInterface) { .then((response:DataInterface) => {
let data = response.gets(); let data = response.gets();
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
console.log("[E] " + self.constructor.name + ": can not retrive BDD values"); console.log(`[E] ${ self.constructor.name }: can not retrive BDD values`);
reject(response); reject(response);
}); });
}); });
@ -51,147 +51,147 @@ export class SeriesService {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getSeries() self.bdd.getSeries()
.then(function(response:DataInterface) { .then((response:DataInterface) => {
let data = response.gets_where([["!=", "id", null]], ["id", "name"], ["name","id"]) let data = response.getsWhere([ [ '!=', 'id', null ] ], [ 'id', 'name' ], [ 'name', 'id' ]);
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
console.log("[E] " + self.constructor.name + ": can not retrive BDD values"); console.log(`[E] ${ self.constructor.name }: can not retrive BDD values`);
reject(response); reject(response);
}); });
}); });
} }
getVideoAll(_id:number):any { getVideoAll(id:number):any {
//this.checkLocalBdd(); // this.checkLocalBdd();
} }
getVideo(_id:number):any { getVideo(id:number):any {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getVideo() self.bdd.getVideo()
.then(function(response:DataInterface) { .then((response:DataInterface) => {
let data = response.gets_where([["==", "series_id", _id], ["==", "season_id", null]], undefined, ["episode", "name"]) let data = response.getsWhere([ [ '==', 'series_id', id ], [ '==', 'season_id', null ] ], undefined, [ 'episode', 'name' ]);
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
countVideo(_id:number):any { countVideo(id:number):any {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getVideo() self.bdd.getVideo()
.then(function(response:DataInterface) { .then((response:DataInterface) => {
let data = response.gets_where([["==", "series_id", _id]], undefined, undefined) let data = response.getsWhere([ [ '==', 'series_id', id ] ], undefined, undefined);
resolve(data.length); resolve(data.length);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
/** /**
* Get all the season of a specific series * Get all the season of a specific series
* @param _id - ID of the series * @param id - ID of the series
* @param _select - Selection filter * @param select - Selection filter
* @returns the required List. * @returns the required List.
*/ */
getSeason(_id:number, _select:Array<string> = []):any { getSeason(id:number, select:string[] = []):any {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getSeason() self.bdd.getSeason()
.then(function(response:DataInterface) { .then((response:DataInterface) => {
let data = response.gets_where([["==", "parent_id", _id]], ["id"], ["number"]) let data = response.getsWhere([ [ '==', 'parent_id', id ] ], [ 'id' ], [ 'number' ]);
if (_select.length == 0) { if(select.length === 0) {
resolve(data); resolve(data);
return; return;
} }
if (_select[0] == "*") { if(select[0] === '*') {
let data2 = response.gets_where([["==", "id", data]], undefined, ["number"]) let data2 = response.getsWhere([ [ '==', 'id', data ] ], undefined, [ 'number' ]);
resolve(data2); resolve(data2);
return; return;
} }
let data3 = response.gets_where([["==", "id", data]], _select, ["number"]); let data3 = response.getsWhere([ [ '==', 'id', data ] ], select, [ 'number' ]);
resolve(data3); resolve(data3);
return; return;
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
put(_id:number, _data:any):any { put(id:number, data:any):any {
let ret = this.http.put_specific(this.serviceName, _id, _data); let ret = this.http.putSpecific(this.serviceName, id, data);
return this.bdd.setAfterPut(this.serviceName, _id, ret); return this.bdd.setAfterPut(this.serviceName, id, ret);
} }
delete(_id:number):any { delete(id:number):any {
let ret = this.http.delete_specific(this.serviceName, _id); let ret = this.http.deleteSpecific(this.serviceName, id);
return this.bdd.delete(this.serviceName, _id, ret); return this.bdd.delete(this.serviceName, id, ret);
} }
getCoverUrl(_coverId:number):any { getCoverUrl(coverId:number):any {
return this.http.createRESTCall("data/" + _coverId); return this.http.createRESTCall(`data/${ coverId}`);
} }
getCoverThumbnailUrl(_coverId:number):any { getCoverThumbnailUrl(coverId:number):any {
return this.http.createRESTCall("data/thumbnail/" + _coverId); return this.http.createRESTCall(`data/thumbnail/${ coverId}`);
} }
getLike(_nameSeries:string):any { getLike(nameSeries:string):any {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getSeries() self.bdd.getSeries()
.then(function(response:DataInterface) { .then((response:DataInterface) => {
let data = response.getNameLike(_nameSeries); let data = response.getNameLike(nameSeries);
if (data === null || data === undefined || data.length === 0 ) { if(data === null || data === undefined || data.length === 0) {
reject("Data does not exist in the local BDD"); reject('Data does not exist in the local BDD');
return; return;
} }
resolve(data); resolve(data);
return; return;
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
deleteCover(_node_id:number, deleteCover(nodeId:number,
_cover_id:number) { coverId:number) {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.http.get_specific(this.serviceName + "/" + _node_id + "/rm_cover" , _cover_id) self.http.getSpecific(`${this.serviceName }/${ nodeId }/rm_cover`, coverId)
.then(function(response) { .then((response) => {
let data = response; let data = response;
if (data === null || data === undefined) { if(data === null || data === undefined) {
reject("error retrive data from server"); reject('error retrive data from server');
return; return;
} }
self.bdd.asyncSetInDB(self.serviceName, _node_id, data); self.bdd.asyncSetInDB(self.serviceName, nodeId, data);
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
uploadCover(_file:File, uploadCover(file:File,
_node_id:number, nodeId:number,
_progress:any = null) { progress:any = null) {
const formData = new FormData(); const formData = new FormData();
formData.append('file_name', _file.name); formData.append('file_name', file.name);
formData.append('node_id', _node_id.toString()); formData.append('node_id', nodeId.toString());
formData.append('file', _file); formData.append('file', file);
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.http.uploadMultipart(this.serviceName + "/" + _node_id + "/add_cover/", formData, _progress) self.http.uploadMultipart(`${this.serviceName }/${ nodeId }/add_cover/`, formData, progress)
.then(function(response) { .then((response) => {
let data = response; let data = response;
if (data === null || data === undefined) { if(data === null || data === undefined) {
reject("error retrive data from server"); reject('error retrive data from server');
return; return;
} }
self.bdd.asyncSetInDB(self.serviceName, _node_id, data); self.bdd.asyncSetInDB(self.serviceName, nodeId, data);
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });

View File

@ -4,9 +4,9 @@
* @license PROPRIETARY (see license file) * @license PROPRIETARY (see license file)
*/ */
import { Injectable, Output, EventEmitter } from '@angular/core' import { Injectable, Output, EventEmitter } from '@angular/core';
enum USER_ROLES { export enum UserRoles222 {
admin = 10000, admin = 10000,
user = 1, user = 1,
guest = 10 guest = 10
@ -19,36 +19,44 @@ export class SessionService {
public userAdmin = null; public userAdmin = null;
public userEMail = null; public userEMail = null;
public userAvatar = null; public userAvatar = null;
//public tocken = null; // public tocken = null;
@Output() change: EventEmitter<boolean> = new EventEmitter(); @Output() change: EventEmitter<boolean> = new EventEmitter();
constructor() { constructor() {
} }
/** /**
* @brief Create a new session. * @brief Create a new session.
*
* @param sessionData -
* @param userLogin -
* @param userEMail -
* @param userAdmin -
* @param userAvatar -
*/ */
create(sessionData, create(sessionData,
userLogin:string, userLogin: string,
userEMail:string, userEMail: string,
userAdmin:boolean, userAdmin: boolean,
userAvatar:string) { userAvatar: string) {
console.log("Session Create"); console.log('Session Create');
this.sessionData = sessionData; this.sessionData = sessionData;
this.userLogin = userLogin; this.userLogin = userLogin;
this.userAdmin = userAdmin; this.userAdmin = userAdmin;
this.userEMail = userEMail; this.userEMail = userEMail;
this.userAvatar = userAvatar; this.userAvatar = userAvatar;
this.change.emit(true); this.change.emit(true);
}; }
/** /**
* @brief destroy the current session. * @brief destroy the current session.
*/ */
destroy() { destroy() {
console.log("Session REMOVE"); console.log('Session REMOVE');
//Cookies.remove("yota-login"); // Cookies.remove("yota-login");
//Cookies.remove("yota-password"); // Cookies.remove("yota-password");
let last = this.sessionData; let last = this.sessionData;
this.sessionData = null; this.sessionData = null;
this.userLogin = null; this.userLogin = null;
@ -56,21 +64,21 @@ export class SessionService {
this.userEMail = null; this.userEMail = null;
this.userAvatar = null; this.userAvatar = null;
this.change.emit(false); this.change.emit(false);
}; }
islogged() { islogged() {
return this.sessionData != null; return this.sessionData !== null;
} }
hasRight(type) { hasRight(type) {
if (type == USER_ROLES.admin) { if(type === UserRoles222.admin) {
// sometime needed... // sometime needed...
return this.userAdmin; return this.userAdmin;
} }
if (type == USER_ROLES.user) { if(type === UserRoles222.user) {
// is connected ==> is user // is connected ==> is user
return this.sessionData != null; return this.sessionData !== null;
} }
if (type == USER_ROLES.guest) { if(type === UserRoles222.guest) {
// TODO all the other ... maybe unneeded // all the other ... maybe unneeded
return true; return true;
} }
return false; return false;
@ -82,8 +90,8 @@ export class SessionService {
return this.userLogin; return this.userLogin;
} }
getAvatar() { getAvatar() {
if (this.userAvatar == "") { if(this.userAvatar === '') {
return "assets/images/avatar_generic.svg"; return 'assets/images/avatar_generic.svg';
} }
return this.userAvatar; return this.userAvatar;
} }

View File

@ -1,15 +1,13 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper'; import { HttpWrapperService } from './http-wrapper';
import { DataInterface } from './dataInterface';
import { BddService } from './bdd'; import { BddService } from './bdd';
export interface MessageLogIn { export interface MessageLogIn {
id: number; id: number;
name: string; name: string;
description: string; description: string;
}; }
declare function SHA512(param1: any): any; declare function SHA512(param1: any): any;
declare function dateFormat(param1: any, param2: any): any; declare function dateFormat(param1: any, param2: any): any;
@ -18,24 +16,23 @@ declare function dateFormat(param1: any, param2: any): any;
export class TypeService { export class TypeService {
// 0: Not hide password; 1 hide password; // 0: Not hide password; 1 hide password;
private identificationVersion: number = 1; private identificationVersion: number = 1;
private serviceName:string = "type"; private serviceName:string = 'type';
constructor(private http: HttpWrapperService, constructor(private http: HttpWrapperService,
private bdd: BddService) { private bdd: BddService) {
console.log("Start TypeService"); console.log('Start TypeService');
} }
getData():any { getData():any {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getType() self.bdd.getType()
.then(function(response) { .then((response) => {
let data = response.gets(); let data = response.gets();
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
console.log("[E] " + self.constructor.name + ": can not retrive BDD values"); console.log(`[E] ${ self.constructor.name }: can not retrive BDD values`);
reject(response); reject(response);
}); });
}); });
@ -45,14 +42,14 @@ export class TypeService {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getType() self.bdd.getType()
.then(function(response) { .then((response) => {
let data = response.get(_id); let data = response.get(_id);
if (data === null || data === undefined) { if(data === null || data === undefined) {
reject("Data does not exist in the local BDD"); reject('Data does not exist in the local BDD');
return; return;
} }
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
@ -62,10 +59,10 @@ export class TypeService {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getVideo() self.bdd.getVideo()
.then(function(response) { .then((response) => {
let data = response.gets_where([["==", "type_id", _id]], undefined, undefined) let data = response.gets_where([ [ '==', 'type_id', _id ] ], undefined, undefined);
resolve(data.length); resolve(data.length);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
@ -75,21 +72,21 @@ export class TypeService {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getVideo() self.bdd.getVideo()
.then(function(response) { .then((response) => {
if (_select.length == 0) { if(_select.length === 0) {
let data = response.gets_where([["==", "type_id", _id], ["==", "series_id", null], ["==", "universe_id", null]], undefined, ["name"]); let data = response.gets_where([ [ '==', 'type_id', _id ], [ '==', 'series_id', null ], [ '==', 'universe_id', null ] ], undefined, [ 'name' ]);
resolve(data); resolve(data);
return; return;
} }
if (_select[0] == "*") { if(_select[0] === '*') {
let data = response.gets_where([["==", "type_id", _id], ["==", "series_id", null], ["==", "universe_id", null]], undefined, ["name"]); let data = response.gets_where([ [ '==', 'type_id', _id ], [ '==', 'series_id', null ], [ '==', 'universe_id', null ] ], undefined, [ 'name' ]);
resolve(data); resolve(data);
return; return;
} }
let data = response.gets_where([["==", "type_id", _id], ["==", "series_id", null], ["==", "universe_id", null]], _select, ["name"]); let data = response.gets_where([ [ '==', 'type_id', _id ], [ '==', 'series_id', null ], [ '==', 'universe_id', null ] ], _select, [ 'name' ]);
resolve(data); resolve(data);
return; return;
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
@ -97,6 +94,7 @@ export class TypeService {
getSubSeries(_id:number, _select:Array<string> = []):any { getSubSeries(_id:number, _select:Array<string> = []):any {
let self = this; let self = this;
/* /*
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getVideo() self.bdd.getVideo()
@ -126,10 +124,10 @@ export class TypeService {
*/ */
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getSeries() self.bdd.getSeries()
.then(function(response) { .then((response) => {
let data = response.gets_where([["==", "parent_id", _id]], undefined, ["name"]); let data = response.gets_where([ [ '==', 'parent_id', _id ] ], undefined, [ 'name' ]);
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
@ -139,36 +137,36 @@ export class TypeService {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getVideo() self.bdd.getVideo()
.then(function(response) { .then((response) => {
let data = response.data.gets_where([["==", "type_id", _id], ["==", "series_id", null], ["==", "universe_id", null]], ["univers_id"], ["name"]); let data = response.data.gets_where([ [ '==', 'type_id', _id ], [ '==', 'series_id', null ], [ '==', 'universe_id', null ] ], [ 'univers_id' ], [ 'name' ]);
if (_select.length == 0) { if(_select.length === 0) {
resolve(data); resolve(data);
return; return;
} }
self.bdd.getUniverse() self.bdd.getUniverse()
.then(function(response2) { .then((response2) => {
if (_select[0] == "*") { if(_select[0] === '*') {
let data2 = response2.gets_where([["==", "id", data]], undefined, ["name"]); let data2 = response2.gets_where([ [ '==', 'id', data ] ], undefined, [ 'name' ]);
resolve(data2); resolve(data2);
return; return;
} }
let data3 = response2.gets_where([["==", "id", data]], _select, ["name"]); let data3 = response2.gets_where([ [ '==', 'id', data ] ], _select, [ 'name' ]);
resolve(data3); resolve(data3);
return; return;
}).catch(function(response2) { }).catch((response2) => {
reject(response2); reject(response2);
}); });
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
getCoverUrl(_coverId:number):any { getCoverUrl(_coverId:number):any {
return this.http.createRESTCall("data/" + _coverId); return this.http.createRESTCall(`data/${ _coverId}`);
} }
getCoverThumbnailUrl(_coverId:number):any { getCoverThumbnailUrl(_coverId:number):any {
return this.http.createRESTCall("data/thumbnail/" + _coverId); return this.http.createRESTCall(`data/thumbnail/${ _coverId}`);
} }
} }

View File

@ -7,96 +7,95 @@ import { BddService } from './bdd';
export class UniverseService { export class UniverseService {
// 0: Not hide password; 1 hide password; // 0: Not hide password; 1 hide password;
private identificationVersion: number = 1; private identificationVersion: number = 1;
private serviceName:string = "universe"; private serviceName:string = 'universe';
constructor(private http: HttpWrapperService, constructor(private http: HttpWrapperService,
private bdd: BddService) { private bdd: BddService) {
console.log("Start universeService"); console.log('Start universeService');
} }
getData():any { getData():any {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getUniverse() self.bdd.getUniverse()
.then(function(response) { .then((response) => {
let data = response.gets(); let data = response.gets();
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
get(_id:number):any { get(id:number):any {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getUniverse() self.bdd.getUniverse()
.then(function(response) { .then((response) => {
let data = response.get(_id); let data = response.get(id);
if (data === null || data === undefined) { if(data === null || data === undefined) {
reject("Data does not exist in the local BDD"); reject('Data does not exist in the local BDD');
return; return;
} }
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
getSubSeries(_id:number, _select:Array<string> = []):any { getSubSeries(id:number, select:Array<string> = []):any {
//this.checkLocalBdd(); // this.checkLocalBdd();
} }
getSubVideo(_id:number, _select:Array<string> = []):any { getSubVideo(id:number, select:Array<string> = []):any {
//this.checkLocalBdd(); // this.checkLocalBdd();
} }
put(_id:number, _data:any):any { put(id:number, data:any):any {
let ret = this.http.put_specific(this.serviceName, _id, _data); let ret = this.http.putSpecific(this.serviceName, id, data);
return this.bdd.setAfterPut(this.serviceName, _id, ret); return this.bdd.setAfterPut(this.serviceName, id, ret);
} }
getCoverUrl(_coverId:number):any { getCoverUrl(coverId:number):any {
return this.http.createRESTCall("data/" + _coverId); return this.http.createRESTCall(`data/${ coverId}`);
} }
deleteCover(_node_id:number, deleteCover(nodeId:number,
_cover_id:number) { coverId:number) {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.http.get_specific(this.serviceName + "/" + _node_id + "/rm_cover" , _cover_id) self.http.getSpecific(`${this.serviceName }/${ nodeId }/rm_cover`, coverId)
.then(function(response) { .then((response) => {
let data = response; let data = response;
if (data === null || data === undefined) { if(data === null || data === undefined) {
reject("error retrive data from server"); reject('error retrive data from server');
return; return;
} }
self.bdd.asyncSetInDB(self.serviceName, _node_id, data); self.bdd.asyncSetInDB(self.serviceName, nodeId, data);
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
uploadCover(_file:File, uploadCover(file:File,
_node_id:number, nodeId:number,
_progress:any = null) { progress:any = null) {
const formData = new FormData(); const formData = new FormData();
formData.append('file_name', _file.name); formData.append('file_name', file.name);
formData.append('node_id', _node_id.toString()); formData.append('node_id', nodeId.toString());
formData.append('file', _file); formData.append('file', file);
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.http.uploadMultipart(this.serviceName + "/" + _node_id + "/add_cover/", formData, _progress) self.http.uploadMultipart(`${this.serviceName }/${ nodeId }/add_cover/`, formData, progress)
.then(function(response) { .then((response) => {
let data = response; let data = response;
if (data === null || data === undefined) { if(data === null || data === undefined) {
reject("error retrive data from server"); reject('error retrive data from server');
return; return;
} }
self.bdd.asyncSetInDB(self.serviceName, _node_id, data); self.bdd.asyncSetInDB(self.serviceName, nodeId, data);
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });

View File

@ -1,14 +1,13 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpOAuthWrapperService } from './http-oauth-wrapper'; import { HttpOAuthWrapperService } from './http-oauth-wrapper';
import { HttpWrapperService } from './http-wrapper'; import { HttpWrapperService } from './http-wrapper';
//import { SHA512 } from 'assets/js_3rd_party/sha512';
interface MessageLogIn { interface MessageLogIn {
login: string; login: string;
method: string; method: string;
time: number; time: number;
password: string; password: string;
}; }
interface MessageAnswer_USER_CONNECT { interface MessageAnswer_USER_CONNECT {
sessionId: string, sessionId: string,
@ -16,7 +15,7 @@ interface MessageAnswer_USER_CONNECT {
eMail: string, eMail: string,
role: string, role: string,
avatar: string avatar: string
}; }
declare function SHA512(param1: any): any; declare function SHA512(param1: any): any;
declare function dateFormat(param1: any, param2: any): any; declare function dateFormat(param1: any, param2: any): any;
@ -27,103 +26,103 @@ export class UserService {
private identificationVersion: number = 1; private identificationVersion: number = 1;
constructor(private httpOAuth: HttpOAuthWrapperService, constructor(private httpOAuth: HttpOAuthWrapperService,
private http: HttpWrapperService) { private http: HttpWrapperService) {
console.log("Start UserService"); console.log('Start UserService');
} }
login(_login: string, _password: string):any { login(_login: string, _password: string):any {
return this.loginSha(_login, SHA512(_password)); return this.loginSha(_login, SHA512(_password));
} }
loginSha(_login: string, _password: string):any { loginSha(login: string, password: string):any {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.getTocken(_login, _password).then( self.getTocken(login, password).then(
function(value) { (value: any) => {
console.log("Get token ..."); console.log('Get token ...');
self.loginWithToken(value['userId'], value['token']).then( self.loginWithToken(value.userId, value.token).then(
function(value2) { (value2: any) => {
// transfer the session token property // transfer the session token property
value2["session"] = { value2.session = {
userId: value['userId'], userId: value.userId,
token: value['token'], token: value.token,
endValidityTime: value['endValidityTime'] endValidityTime: value.endValidityTime
}; };
resolve(value2); resolve(value2);
}, function(value2) { }, (value2) => {
reject("sdfsdfsdf"); reject('sdfsdfsdf');
});
}, (value) => {
console.log('User NOT created');
reject('rrfrrrrr');
}); });
}, function(value) {
console.log("User NOT created");
reject("rrfrrrrr");
});
}); });
} }
getTocken(_login : string, _password : string) { getTocken(login : string, password : string) {
console.log("AuthService.getToken ... '" + _login + "':'" + _password + "'"); console.log(`AuthService.getToken ... '${ login }':'${ password }'`);
let currentDate:number = dateFormat(new Date(), 'm-d-Y h:i:s ms'); let currentDate:number = dateFormat(new Date(), 'm-d-Y h:i:s ms');
let data:MessageLogIn; let data:MessageLogIn;
// create request: // create request:
if (this.identificationVersion == 1) { if(this.identificationVersion === 1) {
data = { data = {
login: _login, login: login,
method: "v1", method: 'v1',
time: currentDate, time: currentDate,
// we mix the password to be sure that it can not be used an other time ... // we mix the password to be sure that it can not be used an other time ...
password: SHA512("login='" + _login + "';pass='" + _password + "';date='" + currentDate + "'") password: SHA512(`login='${ login }';pass='${ password }';date='${ currentDate }'`)
}; };
} else { } else {
console.log("AuthService.login ... Wrong method ..."); console.log('AuthService.login ... Wrong method ...');
} }
const httpOption = { 'Content-Type': 'application/json' }; const httpOption = { 'Content-Type': 'application/json' };
console.log("call users/connect data=" + JSON.stringify(data, null, 2)); console.log(`call users/connect data=${ JSON.stringify(data, null, 2)}`);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.httpOAuth.post("users/get_token", httpOption, data) this.httpOAuth.post('users/get_token', httpOption, data)
.then(function(response: any) { .then((response: any) => {
console.log("response status=" + response.status); console.log(`response status=${ response.status}`);
if (response.status >= 200 && response.status <= 299) { if(response.status >= 200 && response.status <= 299) {
console.log("Data token: id=" + response.data['id']); console.log(`Data token: id=${ response.data.id}`);
console.log("Data token: userId=" + response.data['userId']); console.log(`Data token: userId=${ response.data.userId}`);
console.log("Data token: token=" + response.data['token']); console.log(`Data token: token=${ response.data.token}`);
console.log("Data token: createTime=" + response.data['createTime']); console.log(`Data token: createTime=${ response.data.createTime}`);
console.log("Data token: endValidityTime=" + response.data['endValidityTime']); console.log(`Data token: endValidityTime=${ response.data.endValidityTime}`);
resolve(response.data); resolve(response.data);
return; return;
} }
reject("An error occured"); reject('An error occured');
}, function(response: any) { }, (response: any) => {
if (typeof response.data === 'undefined') { if(typeof response.data === 'undefined') {
reject("return ERROR undefined"); reject('return ERROR undefined');
} else { } else {
reject("return ERROR " + JSON.stringify(response.data, null, 2)); reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
}
});
});
}
loginWithToken(userId : string, token : string) {
console.log(`AuthService.loginWithToken ... '${ userId }':'${ token }'`);
let headers = {
authorization: `Yota ${userId}:${token}`
};
return new Promise((resolve, reject) => {
this.http.get('users/me', headers, {})
.then((response: any) => {
if(response.status === 200) {
resolve(response.data);
return;
}
reject('An error occured');
}, (response: any) => {
if(response.data === undefined) {
reject('return ERROR undefined');
} else {
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
} }
}); });
}); });
};
loginWithToken(_user_id : string, _token : string) {
console.log("AuthService.loginWithToken ... '" + _user_id + "':'" + _token + "'");
let headers = {
authorization: "Yota " + _user_id + ":" + _token
};
return new Promise((resolve, reject) => {
this.http.get("users/me", headers, {})
.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));
}
});
});
/* /*
console.log("AuthService.login ... '" + _login + "':'" + _password + "'"); console.log("AuthService.login ... '" + _login + "':'" + _password + "'");
let currentDate:number = dateFormat(new Date(), 'm-d-Y h:i:s ms'); let currentDate:number = dateFormat(new Date(), 'm-d-Y h:i:s ms');
@ -161,47 +160,47 @@ export class UserService {
}); });
}); });
*/ */
};
create(_login : string, _email : string, _password : string) {
return this.createSha(_login, _email, SHA512(_password));
} }
createSha(_login : string, _email : string, _password : string, ) {
let data = {
"method": "v?",
"login": _login,
"email": _email,
"password": _password
}
const httpOption = { 'Content-Type': 'application/json' };
console.log("call users data=" + JSON.stringify(data, null, 2));
if (this.identificationVersion == 1) { create(login : string, email : string, password : string) {
data["methode"] = "v1" return this.createSha(login, email, SHA512(password));
}
createSha(login : string, email : string, password : string) {
let data = {
method: 'v?',
login: login,
email: email,
password: password
};
const httpOption = { 'Content-Type': 'application/json' };
console.log(`call users data=${ JSON.stringify(data, null, 2)}`);
if(this.identificationVersion === 1) {
data.method = 'v1';
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.httpOAuth.post("users", httpOption, data) this.httpOAuth.post('users', httpOption, data)
.then(function(response: any) { .then((response: any) => {
if (response.status == 200) { if(response.status === 200) {
resolve(response.data) resolve(response.data);
} }
reject("An error occured"); reject('An error occured');
}, function(response: any) { }, (response: any) => {
if (typeof response.data === 'undefined') { if(response.data === undefined) {
reject("return ERROR undefined"); reject('return ERROR undefined');
} else { } else {
reject("return ERROR " + JSON.stringify(response.data, null, 2)); reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
} }
}); });
}); });
}; }
isAuthenticated():boolean { isAuthenticated():boolean {
//return !!Session.userId; // return !!Session.userId;
return false; return false;
}; }
isAuthorized(_authorizedRoles: string): boolean { isAuthorized(authorizedRoles: string): boolean {
/* /*
if (!angular.isArray(_authorizedRoles)) { if (!angular.isArray(_authorizedRoles)) {
authorizedRoles = [_authorizedRoles]; authorizedRoles = [_authorizedRoles];
@ -211,36 +210,36 @@ export class UserService {
); );
*/ */
return false; return false;
};
checkLogin(_login: string) {
let params = {
login: _login
};
return new Promise((resolve, reject) => {
this.httpOAuth.get("users/check_login", {}, params).then(
(res: Response) => {
resolve('valid')
},
error => {
reject(error.status);
});
});
} }
checkEMail(_email: string) { checkLogin(login: string) {
let params = { let params = {
"email": _email login: login
}; };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.httpOAuth.get("users/check_email", {}, params).then( this.httpOAuth.get('users/check_login', {}, params).then(
(res: Response) => { (res: Response) => {
resolve('valid') resolve('valid');
}, },
error => { (error) => {
reject(error.status); reject(error.status);
}); });
}); });
}
checkEMail(email: string) {
let params = {
email: email
};
return new Promise((resolve, reject) => {
this.httpOAuth.get('users/check_email', {}, params).then(
(res: Response) => {
resolve('valid');
},
(error) => {
reject(error.status);
});
});
} }
} }

View File

@ -1,159 +1,155 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpWrapperService } from './http-wrapper'; import { HttpWrapperService } from './http-wrapper';
import { DataInterface } from './dataInterface';
import { BddService } from './bdd'; import { BddService } from './bdd';
import { environment } from '../../environments/environment';
@Injectable() @Injectable()
export class VideoService { export class VideoService {
// 0: Not hide password; 1 hide password; // 0: Not hide password; 1 hide password;
private identificationVersion: number = 1; private identificationVersion: number = 1;
private serviceName:string = "video"; private serviceName:string = 'video';
constructor(private http: HttpWrapperService, constructor(private http: HttpWrapperService,
private bdd: BddService) { private bdd: BddService) {
console.log("Start VideoService"); console.log('Start VideoService');
} }
get(_id:number):any { get(id:number):any {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.get(this.serviceName) self.bdd.get(this.serviceName)
.then(function(response) { .then((response) => {
let data = response.get(_id); let data = response.get(id);
if (data === null || data === undefined) { if(data === null || data === undefined) {
reject("Data does not exist in the local BDD"); reject('Data does not exist in the local BDD');
return; return;
} }
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
put(_id:number, _data:any):any { put(id:number, data:any):any {
let ret = this.http.put_specific(this.serviceName, _id, _data); let ret = this.http.putSpecific(this.serviceName, id, data);
return this.bdd.setAfterPut(this.serviceName, _id, ret); return this.bdd.setAfterPut(this.serviceName, id, ret);
} }
delete(_id:number):any { delete(id:number):any {
let ret = this.http.delete_specific(this.serviceName, _id); let ret = this.http.deleteSpecific(this.serviceName, id);
return this.bdd.delete(this.serviceName, _id, ret); return this.bdd.delete(this.serviceName, id, ret);
} }
getCoverUrl(_coverId:number):any { getCoverUrl(coverId:number):any {
return this.http.createRESTCall("data/" + _coverId); return this.http.createRESTCall(`data/${ coverId}`);
} }
getCoverThumbnailUrl(_coverId:number):any { getCoverThumbnailUrl(coverId:number):any {
return this.http.createRESTCall("data/thumbnail/" + _coverId); return this.http.createRESTCall(`data/thumbnail/${ coverId}`);
} }
uploadFile(_file:File, uploadFile(file:File,
_universe:string, universe:string,
_series:string, series:string,
_series_id:number, seriesId:number,
_season:number, season:number,
_episode:number, episode:number,
_title:string, title:string,
_type_id:number, typeId:number,
_progress:any = null) { progress:any = null) {
const formData = new FormData(); const formData = new FormData();
formData.append('file_name', _file.name); formData.append('file_name', file.name);
// set the file at hte begining it will permit to abort the transmission // set the file at hte begining it will permit to abort the transmission
formData.append('file', _file); formData.append('file', file);
formData.append('universe', _universe); formData.append('universe', universe);
if (_series_id != null) { if(seriesId !== null) {
formData.append('series_id', _series_id.toString()); formData.append('series_id', seriesId.toString());
} else { } else {
formData.append('series_id', null); formData.append('series_id', null);
} }
formData.append('series', _series); formData.append('series', series);
if (_season != null) { if(season !== null) {
formData.append('season', _season.toString()); formData.append('season', season.toString());
} else { } else {
formData.append('season', null); formData.append('season', null);
} }
if (_episode != null) { if(episode !== null) {
formData.append('episode', _episode.toString()); formData.append('episode', episode.toString());
} else { } else {
formData.append('episode', null); formData.append('episode', null);
} }
formData.append('title', _title); formData.append('title', title);
if (_type_id != null) { if(typeId !== null) {
formData.append('type_id', _type_id.toString()); formData.append('type_id', typeId.toString());
} else { } else {
formData.append('type_id', null); formData.append('type_id', null);
} }
return this.http.uploadMultipart(this.serviceName + "/upload/", formData, _progress); return this.http.uploadMultipart(`${this.serviceName }/upload/`, formData, progress);
} }
deleteCover(_media_id:number, deleteCover(mediaId:number,
_cover_id:number) { coverId:number) {
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.http.get_specific(this.serviceName + "/" + _media_id + "/rm_cover" , _cover_id) self.http.getSpecific(`${this.serviceName }/${ mediaId }/rm_cover`, coverId)
.then(function(response) { .then((response) => {
let data = response; let data = response;
if (data === null || data === undefined) { if(data === null || data === undefined) {
reject("error retrive data from server"); reject('error retrive data from server');
return; return;
} }
self.bdd.asyncSetInDB(self.serviceName, _media_id, data); self.bdd.asyncSetInDB(self.serviceName, mediaId, data);
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
uploadCover(_file:File, uploadCover(file:File,
_media_id:number, mediaId:number,
_progress:any = null) { progress:any = null) {
const formData = new FormData(); const formData = new FormData();
formData.append('file_name', _file.name); formData.append('file_name', file.name);
formData.append('type_id', _media_id.toString()); formData.append('type_id', mediaId.toString());
formData.append('file', _file); formData.append('file', file);
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.http.uploadMultipart(this.serviceName + "/" + _media_id + "/add_cover/", formData, _progress) self.http.uploadMultipart(`${this.serviceName }/${ mediaId }/add_cover/`, formData, progress)
.then(function(response) { .then((response) => {
let data = response; let data = response;
if (data === null || data === undefined) { if(data === null || data === undefined) {
reject("error retrive data from server"); reject('error retrive data from server');
return; return;
} }
self.bdd.asyncSetInDB(self.serviceName, _media_id, data); self.bdd.asyncSetInDB(self.serviceName, mediaId, data);
resolve(data); resolve(data);
}).catch(function(response) { }).catch((response) => {
reject(response);
});
});
}
uploadCoverBlob(blob:Blob,
mediaId:number,
progress:any = null) {
const formData = new FormData();
formData.append('file_name', 'take_screenshoot');
formData.append('type_id', mediaId.toString());
formData.append('file', blob);
let self = this;
return new Promise((resolve, reject) => {
self.http.uploadMultipart(`${this.serviceName }/${ mediaId }/add_cover/`, formData, progress)
.then((response) => {
let data = response;
if(data === null || data === undefined) {
reject('error retrive data from server');
return;
}
self.bdd.asyncSetInDB(self.serviceName, mediaId, data);
resolve(data);
}).catch((response) => {
reject(response); reject(response);
}); });
}); });
} }
uploadCoverBlob(_blob:Blob,
_media_id:number,
_progress:any = null) {
const formData = new FormData();
formData.append('file_name', "take_screenshoot");
formData.append('type_id', _media_id.toString());
formData.append('file', _blob);
let self = this;
return new Promise((resolve, reject) => {
self.http.uploadMultipart(this.serviceName + "/" + _media_id + "/add_cover/", formData, _progress)
.then(function(response) {
let data = response;
if (data === null || data === undefined) {
reject("error retrive data from server");
return;
}
self.bdd.asyncSetInDB(self.serviceName, _media_id, data);
resolve(data);
}).catch(function(response) {
reject(response);
});
});
}
} }

View File

@ -9,7 +9,7 @@ export const environment = {
apiUrl: 'http://192.168.1.156/karideo/api', apiUrl: 'http://192.168.1.156/karideo/api',
apiOAuthUrl: 'http://192.168.1.156/karauth/api', apiOAuthUrl: 'http://192.168.1.156/karauth/api',
frontBaseUrl: 'karideo', frontBaseUrl: 'karideo',
apiMode: "QUERRY", apiMode: 'QUERRY',
//apiMode: "REWRITE", // apiMode: "REWRITE",
localBdd: true localBdd: true
} };

View File

@ -6,12 +6,12 @@
export const environment = { export const environment = {
production: false, production: false,
// URL of development API // URL of development API
//apiUrl: 'http://localhost:15080', // apiUrl: 'http://localhost:15080',
//apiUrl: 'http://localhost:18080/karideo/api', // apiUrl: 'http://localhost:18080/karideo/api',
apiUrl: 'http://192.168.1.156/karideo/api', apiUrl: 'http://192.168.1.156/karideo/api',
//apiOAuthUrl: 'http://localhost:17080/karauth/api', // apiOAuthUrl: 'http://localhost:17080/karauth/api',
apiOAuthUrl: 'http://192.168.1.156/karauth/api', apiOAuthUrl: 'http://192.168.1.156/karauth/api',
frontBaseUrl: '', frontBaseUrl: '',
//apiMode: "QUERRY" // apiMode: "QUERRY"
apiMode: "REWRITE" apiMode: 'REWRITE'
} };

View File

@ -4,8 +4,10 @@ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module'; import { AppModule } from './app/app.module';
import { environment } from './environments/environment'; import { environment } from './environments/environment';
if (environment.production) { if(environment.production) {
enableProdMode(); enableProdMode();
} }
platformBrowserDynamic().bootstrapModule(AppModule).catch(err => console.log(err)); platformBrowserDynamic().bootstrapModule(AppModule).catch((err) => {
return console.log(err);
});

View File

@ -1,6 +1,5 @@
/** /**
* Required to support Web Animations `@angular/platform-browser/animations`. * Required to support Web Animations `@angular/platform-browser/animations`.
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
@ -12,23 +11,22 @@
* user can disable parts of macroTask/DomEvents patch by setting following flags * user can disable parts of macroTask/DomEvents patch by setting following flags
*/ */
// (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
// (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
// (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
/* /*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge * with the following flag, it will bypass `zone.js` patch for IE/Edge
*/ */
// (window as any).__Zone_enable_cross_context_check = true; // (window as any).__Zone_enable_cross_context_check = true;
/*************************************************************************************************** /** *************************************************************************************************
* Zone JS is required by default for Angular itself. * Zone JS is required by default for Angular itself.
*/ */
import 'zone.js/dist/zone'; // Included with Angular CLI. import 'zone.js/dist/zone'; // Included with Angular CLI.
/** *************************************************************************************************
/***************************************************************************************************
* APPLICATION IMPORTS * APPLICATION IMPORTS
*/ */

View File

@ -3,16 +3,16 @@
import 'zone.js/dist/zone-testing'; import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing'; import { getTestBed } from '@angular/core/testing';
import { import {
BrowserDynamicTestingModule, BrowserDynamicTestingModule,
platformBrowserDynamicTesting platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing'; } from '@angular/platform-browser-dynamic/testing';
declare const require: any; declare const require: any;
// First, initialize the Angular testing environment. // First, initialize the Angular testing environment.
getTestBed().initTestEnvironment( getTestBed().initTestEnvironment(
BrowserDynamicTestingModule, BrowserDynamicTestingModule,
platformBrowserDynamicTesting() platformBrowserDynamicTesting()
); );
// Then we find all the tests. // Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/); const context = require.context('./', true, /\.spec\.ts$/);

View File

@ -1,5 +1,7 @@
/* SystemJS module definition */ /* SystemJS module definition */
declare var module: NodeModule;
interface NodeModule { interface NodeModule {
id: string; id: string;
} }
declare let module: NodeModule;