[DEV] update the linter
This commit is contained in:
parent
ef1ee8dfae
commit
89cd0263c4
@ -9,7 +9,7 @@ services:
|
||||
- ./config.env
|
||||
volumes:
|
||||
- /workspace/data/karideo/db:/var/lib/mysql
|
||||
mem_limit: 400m
|
||||
mem_limit: 600m
|
||||
|
||||
karideo_adminer_service:
|
||||
image: adminer:latest
|
||||
|
4
front/.eslintignore
Normal file
4
front/.eslintignore
Normal file
@ -0,0 +1,4 @@
|
||||
node_modules/*
|
||||
build/*
|
||||
out/*
|
||||
dist/*
|
225
front/.eslintrc.js
Normal file
225
front/.eslintrc.js
Normal 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,
|
||||
},
|
||||
};
|
@ -68,6 +68,17 @@
|
||||
}
|
||||
},
|
||||
"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",
|
||||
"options" : {
|
||||
"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" : {
|
||||
|
4137
front/package-lock.json
generated
4137
front/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@
|
||||
"test": "ng test",
|
||||
"lint": "ng lint",
|
||||
"e2e": "ng e2e"
|
||||
},
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^13.2.5",
|
||||
@ -32,13 +32,22 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@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/compiler-cli": "^13.2.5",
|
||||
"@angular/language-service": "^13.2.5",
|
||||
"@types/jasmine": "^3.10.3",
|
||||
"@types/jasminewd2": "^2.0.10",
|
||||
"@types/node": "^17.0.21",
|
||||
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
||||
"@typescript-eslint/parser": "^5.17.0",
|
||||
"codelyzer": "^6.0.2",
|
||||
"eslint": "^8.12.0",
|
||||
"eslint-config-google": "^0.14.0",
|
||||
"jasmine-core": "^4.0.1",
|
||||
"jasmine-spec-reporter": "^7.0.0",
|
||||
"karma": "^6.3.17",
|
||||
|
@ -23,3 +23,12 @@ plus facilement:
|
||||
npm install @angular-devkit/build-angular@0.901.9
|
||||
npm start
|
||||
|
||||
|
||||
|
||||
Apply linter:
|
||||
==============
|
||||
```
|
||||
npx ng lint
|
||||
```
|
||||
|
||||
|
||||
|
@ -1,16 +1,15 @@
|
||||
import { trigger, state, animate, transition, style } from '@angular/animations';
|
||||
import { trigger, animate, transition, style } from '@angular/animations';
|
||||
|
||||
export const fadeInAnimation =
|
||||
trigger('fadeInAnimation', [
|
||||
// route 'enter' transition
|
||||
transition(':enter', [
|
||||
// route 'enter' transition
|
||||
transition(':enter', [
|
||||
|
||||
// styles at start of transition
|
||||
style({ opacity: 0 }),
|
||||
// styles at start of transition
|
||||
style({ opacity: 0 }),
|
||||
|
||||
// animation and styles at end of transition
|
||||
animate('.5s', style({ opacity: 1 }))
|
||||
]),
|
||||
// animation and styles at end of transition
|
||||
animate('.5s', style({ opacity: 1 }))
|
||||
]),
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
@ -3,49 +3,49 @@ import { trigger, state, animate, transition, style } from '@angular/animations'
|
||||
export const slideInOutAnimation =
|
||||
trigger('slideInOutAnimation', [
|
||||
|
||||
// end state styles for route container (host)
|
||||
state('*', style({
|
||||
// the view covers the whole screen with a semi tranparent background
|
||||
position: 'fixed',
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.8)'
|
||||
})),
|
||||
// end state styles for route container (host)
|
||||
state('*', style({
|
||||
// the view covers the whole screen with a semi tranparent background
|
||||
position: 'fixed',
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.8)'
|
||||
})),
|
||||
|
||||
// route 'enter' transition
|
||||
transition(':enter', [
|
||||
// route 'enter' transition
|
||||
transition(':enter', [
|
||||
|
||||
// styles at start of transition
|
||||
style({
|
||||
// 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
|
||||
right: '-400%',
|
||||
// styles at start of transition
|
||||
style({
|
||||
// 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
|
||||
right: '-400%',
|
||||
|
||||
// start with background opacity set to 0 (invisible)
|
||||
backgroundColor: 'rgba(0, 0, 0, 0)'
|
||||
}),
|
||||
// start with background opacity set to 0 (invisible)
|
||||
backgroundColor: 'rgba(0, 0, 0, 0)'
|
||||
}),
|
||||
|
||||
// animation and styles at end of transition
|
||||
animate('.5s ease-in-out', style({
|
||||
// transition the right position to 0 which slides the content into view
|
||||
right: 0,
|
||||
// animation and styles at end of transition
|
||||
animate('.5s ease-in-out', style({
|
||||
// transition the right position to 0 which slides the content into view
|
||||
right: 0,
|
||||
|
||||
// transition the background opacity to 0.8 to fade it in
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.8)'
|
||||
}))
|
||||
]),
|
||||
// transition the background opacity to 0.8 to fade it in
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.8)'
|
||||
}))
|
||||
]),
|
||||
|
||||
// route 'leave' transition
|
||||
transition(':leave', [
|
||||
// animation and styles at end of transition
|
||||
animate('.5s ease-in-out', style({
|
||||
// transition the right position to -400% which slides the content out of view
|
||||
right: '-400%',
|
||||
// route 'leave' transition
|
||||
transition(':leave', [
|
||||
// animation and styles at end of transition
|
||||
animate('.5s ease-in-out', style({
|
||||
// transition the right position to -400% which slides the content out of view
|
||||
right: '-400%',
|
||||
|
||||
// transition the background opacity to 0 to fade it out
|
||||
backgroundColor: 'rgba(0, 0, 0, 0)'
|
||||
}))
|
||||
])
|
||||
]);
|
||||
// transition the background opacity to 0 to fade it out
|
||||
backgroundColor: 'rgba(0, 0, 0, 0)'
|
||||
}))
|
||||
])
|
||||
]);
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router'; // CLI imports router
|
||||
import { ModuleWithProviders } from '@angular/core';
|
||||
|
||||
import { HomeScene } from './scene/home/home';
|
||||
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 { SeriesEditScene } from './scene/series-edit/series-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
|
||||
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', redirectTo: '/home', pathMatch: 'full'},
|
||||
{ path: '', redirectTo: '/home', pathMatch: 'full' },
|
||||
{ path: 'home', component: HomeScene },
|
||||
{ path: 'upload', component: UploadScene },
|
||||
{ path: 'type/:universe_id/:type_id/:series_id/:season_id/:video_id', component: TypeScene },
|
||||
|
||||
{ path: 'universe/:universe_id/:type_id/:series_id/:season_id/:video_id', component: UniverseScene },
|
||||
|
||||
{ path: 'series/:universe_id/:type_id/:series_id/:season_id/:video_id', component: SeriesScene },
|
||||
{ path: 'series-edit/:universe_id/:type_id/:series_id/:season_id/:video_id', component: SeriesEditScene },
|
||||
|
||||
{ path: 'season/:universe_id/:type_id/:series_id/:season_id/:video_id', component: SeasonScene },
|
||||
{ path: 'season-edit/:universe_id/:type_id/:series_id/:season_id/:video_id', component: SeasonEditScene },
|
||||
|
||||
{ path: 'video/:universe_id/:type_id/:series_id/:season_id/:video_id', component: VideoScene },
|
||||
{ path: 'video-edit/:universe_id/:type_id/:series_id/:season_id/:video_id', component: VideoEditScene },
|
||||
|
||||
{ path: 'type/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: TypeScene },
|
||||
|
||||
{ path: 'universe/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: UniverseScene },
|
||||
|
||||
{ path: 'series/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: SeriesScene },
|
||||
{ path: 'series-edit/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: SeriesEditScene },
|
||||
|
||||
{ path: 'season/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: SeasonScene },
|
||||
{ path: 'season-edit/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: SeasonEditScene },
|
||||
|
||||
{ path: 'video/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: VideoScene },
|
||||
{ path: 'video-edit/:universeId/:typeId/:seriesId/:seasonId/:videoId', component: VideoEditScene },
|
||||
|
||||
{ path: 'login', component: LoginScene },
|
||||
{ path: 'signup', component: SignUpScene },
|
||||
{ path: 'settings', component: SettingsScene },
|
||||
/*{ path: 'help', component: HelpComponent }*/
|
||||
|
||||
/* { path: 'help', component: HelpComponent }*/
|
||||
];
|
||||
|
||||
/*
|
||||
@NgModule({
|
||||
imports: [
|
||||
@ -61,10 +62,9 @@ export class AppRoutingModule {}
|
||||
*/
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy' })],
|
||||
exports: [RouterModule]
|
||||
imports: [ RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy' }) ],
|
||||
exports: [ RouterModule ]
|
||||
})
|
||||
export class AppRoutingModule { }
|
||||
//export const routing: ModuleWithProviders = RouterModule.forRoot(routes);
|
||||
|
||||
|
||||
// export const routing: ModuleWithProviders = RouterModule.forRoot(routes);
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @license PROPRIETARY (see license file)
|
||||
*/
|
||||
|
||||
import { Component, OnInit} from '@angular/core';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { UserService } from './service/user';
|
||||
import { SessionService } from './service/session';
|
||||
import { CookiesService } from './service/cookies';
|
||||
@ -14,41 +14,39 @@ import { CookiesService } from './service/cookies';
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: [
|
||||
'./app.component.less',
|
||||
]
|
||||
]
|
||||
})
|
||||
export class AppComponent implements OnInit {
|
||||
title = 'Karideo';
|
||||
constructor(private cookiesService: CookiesService,
|
||||
private userService: UserService,
|
||||
private sessionService: SessionService) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
let login = this.cookiesService.get("yota-login");
|
||||
let password = this.cookiesService.get("yota-password");
|
||||
if ( login != ""
|
||||
&& password != ""
|
||||
&& password.length > 40) {
|
||||
console.log("Get previous connection ... " + login + ":xxxxxx");
|
||||
let login = this.cookiesService.get('yota-login');
|
||||
let password = this.cookiesService.get('yota-password');
|
||||
if(login !== '' &&
|
||||
password !== '' &&
|
||||
password.length > 40) {
|
||||
console.log(`Get previous connection ... ${ login }:xxxxxx`);
|
||||
let self = this;
|
||||
this.userService.loginSha(login, password)
|
||||
.then(function(response) {
|
||||
console.log("auto log ==> OK");
|
||||
self.sessionService.create(response['session'],
|
||||
response['login'],
|
||||
response['email'],
|
||||
response['admin'],
|
||||
response['avatar']);
|
||||
//self.router.navigate(['home']);
|
||||
}).catch(function(response) {
|
||||
console.log("auto log ==> Error");
|
||||
self.cookiesService.remove("yota-login");
|
||||
self.cookiesService.remove("yota-password");
|
||||
});
|
||||
.then((response: any) => {
|
||||
console.log('auto log ==> OK');
|
||||
self.sessionService.create(response.session,
|
||||
response.login,
|
||||
response.email,
|
||||
response.admin,
|
||||
response.avatar);
|
||||
// self.router.navigate(['home']);
|
||||
}).catch((response: any) => {
|
||||
console.log('auto log ==> Error');
|
||||
self.cookiesService.remove('yota-login');
|
||||
self.cookiesService.remove('yota-password');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ import { AppComponent } from './app.component';
|
||||
SeasonEditScene,
|
||||
SeriesEditScene,
|
||||
UploadScene
|
||||
],
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
RouterModule,
|
||||
@ -101,7 +101,7 @@ import { AppComponent } from './app.component';
|
||||
HttpClientModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
],
|
||||
],
|
||||
providers: [
|
||||
PopInService,
|
||||
HttpWrapperService,
|
||||
@ -118,7 +118,7 @@ import { AppComponent } from './app.component';
|
||||
SeasonService,
|
||||
VideoService,
|
||||
ArianeService
|
||||
],
|
||||
],
|
||||
exports: [
|
||||
AppComponent,
|
||||
TopMenuComponent,
|
||||
@ -136,7 +136,7 @@ import { AppComponent } from './app.component';
|
||||
],
|
||||
bootstrap: [
|
||||
AppComponent
|
||||
],
|
||||
],
|
||||
schemas: [
|
||||
CUSTOM_ELEMENTS_SCHEMA,
|
||||
NO_ERRORS_SCHEMA
|
||||
|
@ -5,62 +5,57 @@
|
||||
*/
|
||||
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';
|
||||
|
||||
@Component({
|
||||
selector: 'app-element-season',
|
||||
templateUrl: './element-season.html',
|
||||
styleUrls: ['./element-season.less']
|
||||
styleUrls: [ './element-season.less' ]
|
||||
})
|
||||
|
||||
@Injectable()
|
||||
export class ElementSeasonComponent implements OnInit {
|
||||
// input parameters
|
||||
@Input() id_season:number = -1;
|
||||
|
||||
error:string = "";
|
||||
@Input() idSeason:number = -1;
|
||||
|
||||
error:string = '';
|
||||
numberSeason:number = -1;
|
||||
count:number = 0;
|
||||
cover:string = "";
|
||||
cover:string = '';
|
||||
covers:Array<string> = [];
|
||||
description:string = "";
|
||||
|
||||
constructor(private router: Router,
|
||||
private seasonService: SeasonService) {
|
||||
|
||||
description:string = '';
|
||||
|
||||
constructor(private seasonService: SeasonService) {
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
let self = this;
|
||||
console.log("get season properties id: " + this.id_season);
|
||||
this.seasonService.get(this.id_season)
|
||||
.then(function(response) {
|
||||
self.error = "";
|
||||
console.log(`get season properties id: ${ this.idSeason}`);
|
||||
this.seasonService.get(this.idSeason)
|
||||
.then((response) => {
|
||||
self.error = '';
|
||||
self.numberSeason = response.name;
|
||||
self.description = response.description;
|
||||
if (response.covers == undefined || response.covers == null || response.covers.length == 0) {
|
||||
if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
|
||||
self.cover = null;
|
||||
//self.covers = [];
|
||||
// self.covers = [];
|
||||
} else {
|
||||
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]));
|
||||
}
|
||||
}
|
||||
}).catch(function(response) {
|
||||
self.error = "Can not get the data";
|
||||
self.numberSeason = -1
|
||||
}).catch((response) => {
|
||||
self.error = 'Can not get the data';
|
||||
self.numberSeason = -1;
|
||||
self.cover = null;
|
||||
self.covers = [];
|
||||
self.description = "";
|
||||
self.description = '';
|
||||
});
|
||||
this.seasonService.countVideo(this.id_season)
|
||||
.then(function(response) {
|
||||
this.seasonService.countVideo(this.idSeason)
|
||||
.then((response) => {
|
||||
self.count = response;
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
self.count = null;
|
||||
});
|
||||
}
|
||||
|
@ -5,64 +5,59 @@
|
||||
*/
|
||||
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';
|
||||
|
||||
@Component({
|
||||
selector: 'app-element-series',
|
||||
templateUrl: './element-series.html',
|
||||
styleUrls: ['./element-series.less']
|
||||
styleUrls: [ './element-series.less' ]
|
||||
})
|
||||
|
||||
@Injectable()
|
||||
export class ElementSeriesComponent implements OnInit {
|
||||
// input parameters
|
||||
@Input() id_series:number = -1;
|
||||
@Input() id_type:number = -1;
|
||||
|
||||
error:string = "";
|
||||
name:string = "plouf";
|
||||
description:string = "";
|
||||
@Input() idSeries:number = -1;
|
||||
@Input() idType:number = -1;
|
||||
|
||||
error:string = '';
|
||||
name:string = 'plouf';
|
||||
description:string = '';
|
||||
countvideo:number = null;
|
||||
imageSource:string = null;
|
||||
|
||||
cover:string = "";
|
||||
|
||||
cover:string = '';
|
||||
covers:Array<string> = [];
|
||||
|
||||
constructor(private router: Router,
|
||||
private seriesService: SeriesService) {
|
||||
|
||||
|
||||
constructor(private seriesService: SeriesService) {
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
this.name = "ll " + this.id_type + "+" + this.id_series
|
||||
this.name = `ll ${ this.idType }+${ this.idSeries}`;
|
||||
let self = this;
|
||||
console.log("get parameter id: " + this.id_type);
|
||||
this.seriesService.get(this.id_series)
|
||||
.then(function(response) {
|
||||
self.error = "";
|
||||
self.name = response.name
|
||||
if (response.covers == undefined || response.covers == null || response.covers.length == 0) {
|
||||
console.log(`get parameter id: ${ this.idType}`);
|
||||
this.seriesService.get(this.idSeries)
|
||||
.then((response) => {
|
||||
self.error = '';
|
||||
self.name = response.name;
|
||||
if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
|
||||
self.cover = null;
|
||||
//self.covers = [];
|
||||
// self.covers = [];
|
||||
} else {
|
||||
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]));
|
||||
}
|
||||
}
|
||||
}).catch(function(response) {
|
||||
self.error = "Can not get the data";
|
||||
self.name = ""
|
||||
}).catch((response) => {
|
||||
self.error = 'Can not get the data';
|
||||
self.name = '';
|
||||
self.cover = null;
|
||||
self.covers = [];
|
||||
});
|
||||
this.seriesService.countVideo(this.id_series)
|
||||
.then(function(response) {
|
||||
this.seriesService.countVideo(this.idSeries)
|
||||
.then((response) => {
|
||||
self.countvideo = response;
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
self.countvideo = 0;
|
||||
});
|
||||
}
|
||||
|
@ -5,100 +5,96 @@
|
||||
*/
|
||||
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';
|
||||
|
||||
@Component({
|
||||
selector: 'app-element-type',
|
||||
templateUrl: './element-type.html',
|
||||
styleUrls: ['./element-type.less']
|
||||
styleUrls: [ './element-type.less' ]
|
||||
})
|
||||
|
||||
@Injectable()
|
||||
export class ElementTypeComponent implements OnInit {
|
||||
// input parameters
|
||||
@Input() id_type:number = -1;
|
||||
|
||||
imageSource:string = "";
|
||||
name:string = "";
|
||||
error:string = "";
|
||||
description:string = "";
|
||||
@Input() idType:number = -1;
|
||||
|
||||
imageSource:string = '';
|
||||
name:string = '';
|
||||
error:string = '';
|
||||
description:string = '';
|
||||
countvideo:number = null;
|
||||
countserie:number = null;
|
||||
|
||||
cover:string = "";
|
||||
|
||||
cover:string = '';
|
||||
covers:Array<string> = [];
|
||||
|
||||
constructor(private router: Router,
|
||||
private typeService: TypeService) {
|
||||
|
||||
|
||||
constructor(private typeService: TypeService) {
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
this.name = "ll " + this.id_type
|
||||
this.name = `ll ${ this.idType}`;
|
||||
let self = this;
|
||||
console.log("get parameter id: " + this.id_type);
|
||||
this.typeService.get(this.id_type)
|
||||
.then(function(response) {
|
||||
self.error = "";
|
||||
self.name = response.name
|
||||
self.description = response.description
|
||||
if (response.covers == undefined || response.covers == null || response.covers.length == 0) {
|
||||
console.log(`get parameter id: ${ this.idType}`);
|
||||
this.typeService.get(this.idType)
|
||||
.then((response) => {
|
||||
self.error = '';
|
||||
self.name = response.name;
|
||||
self.description = response.description;
|
||||
if(response.covers === undefined || response.covers === null || response.covers.length === 0) {
|
||||
self.cover = null;
|
||||
//self.covers = [];
|
||||
// self.covers = [];
|
||||
} else {
|
||||
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]));
|
||||
}
|
||||
}
|
||||
console.log("plouf : '" + self.name + "'");
|
||||
switch (self.name) {
|
||||
case "Documentary":
|
||||
self.imageSource = "assets/images/type_documentary.svg";
|
||||
break;
|
||||
case "Movie":
|
||||
self.imageSource = "assets/images/type_film.svg";
|
||||
break;
|
||||
case "Annimation":
|
||||
self.imageSource = "assets/images/type_annimation.svg";
|
||||
break;
|
||||
case "Short Films":
|
||||
self.imageSource = "assets/images/type_film-short.svg";
|
||||
break;
|
||||
case "tv show":
|
||||
self.imageSource = "assets/images/type_tv-show.svg";
|
||||
break;
|
||||
case "Anniation tv show":
|
||||
self.imageSource = "assets/images/type_tv-show-annimation.svg";
|
||||
break;
|
||||
case "Theater":
|
||||
self.imageSource = "assets/images/type_theater.svg";
|
||||
break;
|
||||
case "One man show":
|
||||
self.imageSource = "assets/images/type_one-man-show.svg";
|
||||
break;
|
||||
case "Concert":
|
||||
self.imageSource = "assets/images/type_concert.svg";
|
||||
break;
|
||||
case "Opera":
|
||||
self.imageSource = "assets/images/type_opera.svg";
|
||||
break;
|
||||
case 'Documentary':
|
||||
self.imageSource = 'assets/images/type_documentary.svg';
|
||||
break;
|
||||
case 'Movie':
|
||||
self.imageSource = 'assets/images/type_film.svg';
|
||||
break;
|
||||
case 'Annimation':
|
||||
self.imageSource = 'assets/images/type_annimation.svg';
|
||||
break;
|
||||
case 'Short Films':
|
||||
self.imageSource = 'assets/images/type_film-short.svg';
|
||||
break;
|
||||
case 'tv show':
|
||||
self.imageSource = 'assets/images/type_tv-show.svg';
|
||||
break;
|
||||
case 'Anniation tv show':
|
||||
self.imageSource = 'assets/images/type_tv-show-annimation.svg';
|
||||
break;
|
||||
case 'Theater':
|
||||
self.imageSource = 'assets/images/type_theater.svg';
|
||||
break;
|
||||
case 'One man show':
|
||||
self.imageSource = 'assets/images/type_one-man-show.svg';
|
||||
break;
|
||||
case 'Concert':
|
||||
self.imageSource = 'assets/images/type_concert.svg';
|
||||
break;
|
||||
case 'Opera':
|
||||
self.imageSource = 'assets/images/type_opera.svg';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}).catch(function(response) {
|
||||
self.error = "Can not get the data";
|
||||
self.name = "";
|
||||
self.description = "";
|
||||
self.imageSource = "";
|
||||
}).catch((response) => {
|
||||
self.error = 'Can not get the data';
|
||||
self.name = '';
|
||||
self.description = '';
|
||||
self.imageSource = '';
|
||||
self.cover = null;
|
||||
self.covers = [];
|
||||
});
|
||||
this.typeService.countVideo(this.id_type)
|
||||
.then(function(response) {
|
||||
this.typeService.countVideo(this.idType)
|
||||
.then((response) => {
|
||||
self.countvideo = response;
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
self.countvideo = 0;
|
||||
});
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="title-small">
|
||||
{{episode_display}} {{name}}
|
||||
{{episodeDisplay}} {{name}}
|
||||
</div>
|
||||
<!--
|
||||
<div class="description-small" *ngIf="description">
|
||||
|
@ -5,107 +5,102 @@
|
||||
*/
|
||||
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 { HttpWrapperService } from '../../service/http-wrapper';
|
||||
|
||||
@Component({
|
||||
selector: 'app-element-video',
|
||||
templateUrl: './element-video.html',
|
||||
styleUrls: ['./element-video.less']
|
||||
styleUrls: [ './element-video.less' ]
|
||||
})
|
||||
|
||||
@Injectable()
|
||||
export class ElementVideoComponent implements OnInit {
|
||||
// input parameters
|
||||
@Input() id_video:number = -1;
|
||||
@Input() display_video:boolean = false;
|
||||
|
||||
error:string = "";
|
||||
|
||||
name:string = "";
|
||||
description:string = "";
|
||||
@Input() idVideo:number = -1;
|
||||
@Input() displayVideo:boolean = false;
|
||||
|
||||
error:string = '';
|
||||
|
||||
name:string = '';
|
||||
description:string = '';
|
||||
episode:number = undefined;
|
||||
series_id:number = undefined;
|
||||
season_id:number = undefined;
|
||||
data_id:number = -1;
|
||||
seriesId:number = undefined;
|
||||
seasonId:number = undefined;
|
||||
dataId:number = -1;
|
||||
time:number = undefined;
|
||||
type_id:number = undefined;
|
||||
generated_name:string = "";
|
||||
video_source:string = "";
|
||||
video_enable:boolean = false;
|
||||
typeId:number = undefined;
|
||||
generatedName:string = '';
|
||||
videoSource:string = '';
|
||||
videoEnable:boolean = false;
|
||||
imageSource:string = null;
|
||||
episode_display:string = "";
|
||||
|
||||
cover:string = "";
|
||||
covers:Array<string> = [];
|
||||
|
||||
constructor(private router: Router,
|
||||
private videoService: VideoService,
|
||||
episodeDisplay:string = '';
|
||||
|
||||
cover:string = '';
|
||||
covers:string[] = [];
|
||||
|
||||
constructor(private videoService: VideoService,
|
||||
private httpService: HttpWrapperService) {
|
||||
|
||||
|
||||
}
|
||||
OnDestroy() {
|
||||
this.video_source = "";
|
||||
this.video_enable = false;
|
||||
this.videoSource = '';
|
||||
this.videoEnable = false;
|
||||
}
|
||||
ngOnInit() {
|
||||
this.name = "ll " + this.id_video
|
||||
this.name = `ll ${ this.idVideo}`;
|
||||
let self = this;
|
||||
//console.log("get video id: " + this.id_video);
|
||||
this.videoService.get(this.id_video)
|
||||
.then(function(response) {
|
||||
//console.log("get response of video : " + JSON.stringify(response, null, 2));
|
||||
self.error = "";
|
||||
// console.log("get video id: " + this.idVideo);
|
||||
this.videoService.get(this.idVideo)
|
||||
.then((response) => {
|
||||
// console.log("get response of video : " + JSON.stringify(response, null, 2));
|
||||
self.error = '';
|
||||
self.name = response.name;
|
||||
self.description = response.description;
|
||||
self.episode = response.episode;
|
||||
if (response.episode === undefined || response.episode === null || response.episode == '') {
|
||||
self.episode_display = "";
|
||||
if(response.episode === undefined || response.episode === null || response.episode === '') {
|
||||
self.episodeDisplay = '';
|
||||
} else {
|
||||
self.episode_display = response.episode + " - ";
|
||||
self.episodeDisplay = `${response.episode } - `;
|
||||
}
|
||||
self.series_id = response.series_id;
|
||||
self.season_id = response.season_id;
|
||||
self.data_id = response.data_id;
|
||||
self.seriesId = response.seriesId;
|
||||
self.seasonId = response.seasonId;
|
||||
self.dataId = response.dataId;
|
||||
self.time = response.time;
|
||||
self.generated_name = response.generated_name;
|
||||
if (self.data_id != -1) {
|
||||
self.video_source = self.httpService.createRESTCall("data/" + self.data_id);
|
||||
self.video_enable = true;
|
||||
self.generatedName = response.generatedName;
|
||||
if(self.dataId !== -1) {
|
||||
self.videoSource = self.httpService.createRESTCall(`data/${ self.dataId}`);
|
||||
self.videoEnable = true;
|
||||
} else {
|
||||
self.video_source = "";
|
||||
self.video_enable = false;
|
||||
self.videoSource = '';
|
||||
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.covers = [];
|
||||
// self.covers = [];
|
||||
} else {
|
||||
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]));
|
||||
}
|
||||
}
|
||||
//console.log("101010 " + self.video_enable + " " + self.video_source);
|
||||
//console.log("set transformed : " + JSON.stringify(self, null, 2));
|
||||
}).catch(function(response) {
|
||||
self.error = "Can not get the data";
|
||||
self.name = "";
|
||||
self.description = "";
|
||||
// console.log("101010 " + self.videoEnable + " " + self.videoSource);
|
||||
// console.log("set transformed : " + JSON.stringify(self, null, 2));
|
||||
}).catch((response) => {
|
||||
self.error = 'Can not get the data';
|
||||
self.name = '';
|
||||
self.description = '';
|
||||
self.episode = undefined;
|
||||
self.episode_display = "";
|
||||
self.series_id = undefined;
|
||||
self.season_id = undefined;
|
||||
self.data_id = -1;
|
||||
self.episodeDisplay = '';
|
||||
self.seriesId = undefined;
|
||||
self.seasonId = undefined;
|
||||
self.dataId = -1;
|
||||
self.time = undefined;
|
||||
self.generated_name = "";
|
||||
self.video_source = "";
|
||||
self.video_enable = false;
|
||||
self.generatedName = '';
|
||||
self.videoSource = '';
|
||||
self.videoEnable = false;
|
||||
self.cover = null;
|
||||
self.covers = [];
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,78 +4,78 @@
|
||||
* @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';
|
||||
|
||||
@Component({
|
||||
//moduleId: module.id.toString(),
|
||||
// moduleId: module.id.toString(),
|
||||
selector: 'app-popin',
|
||||
templateUrl: './popin.html',
|
||||
styleUrls: ['./popin.less']
|
||||
styleUrls: [ './popin.less' ]
|
||||
})
|
||||
|
||||
export class PopInComponent implements OnInit, OnDestroy {
|
||||
@Input() id: string;
|
||||
@Input() popTitle: string = 'No title';
|
||||
@Input() closeTopRight: any = "false";
|
||||
@Input() popSize: string = "medium";
|
||||
|
||||
@Input() closeTopRight: any = 'false';
|
||||
@Input() popSize: string = 'medium';
|
||||
|
||||
@Output() callback: EventEmitter<any> = new EventEmitter();
|
||||
@Input() closeTitle: any = null;
|
||||
@Input() validateTitle: any = null;
|
||||
@Input() saveTitle: any = null;
|
||||
@Input() otherTitle: any = null;
|
||||
|
||||
|
||||
public displayPopIn: boolean = false;
|
||||
|
||||
|
||||
constructor(private popInService: PopInService) {
|
||||
|
||||
|
||||
}
|
||||
ngOnInit(): void {
|
||||
// ensure id attribute exists
|
||||
if (!this.id) {
|
||||
if(!this.id) {
|
||||
console.error('popin must have an id');
|
||||
return;
|
||||
}
|
||||
// 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.element.hide();
|
||||
// this.element.hide();
|
||||
}
|
||||
// remove self from popIn service when directive is destroyed
|
||||
ngOnDestroy(): void {
|
||||
this.popInService.remove(this.id);
|
||||
//this.element.remove();
|
||||
// this.element.remove();
|
||||
}
|
||||
// open popIn
|
||||
open(): void {
|
||||
this.displayPopIn = true;
|
||||
//this.element.show();
|
||||
// this.element.show();
|
||||
}
|
||||
// close popin
|
||||
close(): void {
|
||||
this.displayPopIn = false;
|
||||
//this.element.hide();
|
||||
// this.element.hide();
|
||||
}
|
||||
|
||||
|
||||
onCloseTop(): void {
|
||||
this.callback.emit(["close-top"]);
|
||||
this.callback.emit([ 'close-top' ]);
|
||||
}
|
||||
|
||||
|
||||
onValidate(): void {
|
||||
this.callback.emit(["validate"]);
|
||||
this.callback.emit([ 'validate' ]);
|
||||
}
|
||||
|
||||
|
||||
onClose(): void {
|
||||
this.callback.emit(["close"]);
|
||||
this.callback.emit([ 'close' ]);
|
||||
}
|
||||
|
||||
|
||||
onOther(): void {
|
||||
this.callback.emit(["other"]);
|
||||
this.callback.emit([ 'other' ]);
|
||||
}
|
||||
|
||||
|
||||
onSave(): void {
|
||||
this.callback.emit(["save"]);
|
||||
this.callback.emit([ 'save' ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,51 +12,51 @@
|
||||
</button>
|
||||
<div class="ariane">
|
||||
<button class="item"
|
||||
*ngIf="ariane_type_id != null"
|
||||
*ngIf="arianeTypeId != null"
|
||||
title="Uype"
|
||||
(click)="onArianeType($event)"
|
||||
(auxclick)="onArianeType($event)">
|
||||
<div class="xdesktop">
|
||||
{{ariane_type_name}}
|
||||
{{arianeTypeName}}
|
||||
</div>
|
||||
<div class="xmobile">
|
||||
T
|
||||
</div>
|
||||
</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"
|
||||
*ngIf="ariane_universe_id != null"
|
||||
*ngIf="arianeUniverseId != null"
|
||||
title="Universe"
|
||||
(click)="onArianeUniverse($event)"
|
||||
(auxclick)="onArianeUniverse($event)">
|
||||
<div class="xdesktop">
|
||||
{{ariane_universe_name}}
|
||||
{{arianeUniverseName}}
|
||||
</div>
|
||||
<div class="xmobile">
|
||||
U
|
||||
</div>
|
||||
</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"
|
||||
*ngIf="ariane_series_id != null"
|
||||
*ngIf="arianeSeriesId != null"
|
||||
title="Series"
|
||||
(click)="onArianeSeries($event)"
|
||||
(auxclick)="onArianeSeries($event)">
|
||||
<div class="xdesktop">
|
||||
{{ariane_series_name}}
|
||||
{{arianeSeriesName}}
|
||||
</div>
|
||||
<div class="xmobile">
|
||||
G
|
||||
</div>
|
||||
</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"
|
||||
*ngIf="ariane_season_id != null"
|
||||
*ngIf="arianeSeasonId != null"
|
||||
title="Season"
|
||||
(click)="onArianeSeason($event)"
|
||||
(auxclick)="onArianeSeason($event)">
|
||||
<div class="xdesktop">
|
||||
{{ariane_season_name}}
|
||||
{{arianeSeasonName}}
|
||||
</div>
|
||||
<div class="xmobile">
|
||||
S
|
||||
@ -94,7 +94,7 @@
|
||||
<img class="avatar" src="{{avatar}}"/>
|
||||
</button>
|
||||
<button class="item"
|
||||
*ngIf="edit_show == true"
|
||||
*ngIf="editShow == true"
|
||||
style="float:right; height:56px;"
|
||||
(click)="onEdit()">
|
||||
<div class="xdesktop">
|
||||
@ -139,32 +139,32 @@
|
||||
<div class="sub-menu edit-menu color-menu-background">
|
||||
<!--
|
||||
<button class="item"
|
||||
*ngIf="ariane_type_id != null"
|
||||
*ngIf="arianeTypeId != null"
|
||||
(click)="onSubEditType($event)"
|
||||
(auxclick)="onSubEditType($event)">
|
||||
<b>Edit Type</b>
|
||||
</button>
|
||||
<button class="item"
|
||||
*ngIf="ariane_universe_id != null"
|
||||
*ngIf="arianeUniverseId != null"
|
||||
(click)="onSubEditUniverse($event)"
|
||||
(auxclick)="onSubEditUniverse($event)">
|
||||
<b>Edit Universe</b>
|
||||
</button>
|
||||
-->
|
||||
<button class="item"
|
||||
*ngIf="ariane_series_id != null"
|
||||
*ngIf="arianeSeriesId != null"
|
||||
(click)="onSubEditSeries($event)"
|
||||
(auxclick)="onSubEditSeries($event)">
|
||||
<b>Edit Series</b>
|
||||
</button>
|
||||
<button class="item"
|
||||
*ngIf="ariane_season_id != null"
|
||||
*ngIf="arianeSeasonId != null"
|
||||
(click)="onSubEditSeason($event)"
|
||||
(auxclick)="onSubEditSeason($event)">
|
||||
<b>Edit Season</b>
|
||||
</button>
|
||||
<button class="item"
|
||||
*ngIf="ariane_video_id != null"
|
||||
*ngIf="arianeVideoId != null"
|
||||
(click)="onSubEditVideo($event)"
|
||||
(auxclick)="onSubEditVideo($event)">
|
||||
<b>Edit Video</b>
|
||||
@ -175,32 +175,32 @@
|
||||
<div class="sub-menu edit-menu-mob color-menu-background">
|
||||
<!--
|
||||
<button class="item"
|
||||
*ngIf="ariane_type_id != null"
|
||||
*ngIf="arianeTypeId != null"
|
||||
(click)="onSubEditType($event)"
|
||||
(auxclick)="onSubEditType($event)">
|
||||
<b>Edit Type</b>
|
||||
</button>
|
||||
<button class="item"
|
||||
*ngIf="ariane_universe_id != null"
|
||||
*ngIf="arianeUniverseId != null"
|
||||
(click)="onSubEditUniverse($event)"
|
||||
(auxclick)="onSubEditUniverse($event)">
|
||||
<b>Edit Universe</b>
|
||||
</button>
|
||||
-->
|
||||
<button class="item"
|
||||
*ngIf="ariane_series_id != null"
|
||||
*ngIf="arianeSeriesId != null"
|
||||
(click)="onSubEditSeries($event)"
|
||||
(auxclick)="onSubEditSeries($event)">
|
||||
<b>Edit Series</b>
|
||||
</button>
|
||||
<button class="item"
|
||||
*ngIf="ariane_season_id != null"
|
||||
*ngIf="arianeSeasonId != null"
|
||||
(click)="onSubEditSeason($event)"
|
||||
(auxclick)="onSubEditSeason($event)">
|
||||
<b>Edit Season</b>
|
||||
</button>
|
||||
<button class="item"
|
||||
*ngIf="ariane_video_id != null"
|
||||
*ngIf="arianeVideoId != null"
|
||||
(click)="onSubEditVideo($event)"
|
||||
(auxclick)="onSubEditVideo($event)">
|
||||
<b>Edit Video</b>
|
||||
|
@ -5,277 +5,203 @@
|
||||
*/
|
||||
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 { ActivatedRoute, Params } from '@angular/router';
|
||||
import { Router } from '@angular/router';
|
||||
import { SessionService } from '../../service/session';
|
||||
import { ArianeService } from '../../service/ariane';
|
||||
|
||||
@Component({
|
||||
selector: 'app-top-menu',
|
||||
templateUrl: './top-menu.html',
|
||||
styleUrls: ['./top-menu.less']
|
||||
selector: 'app-top-menu',
|
||||
templateUrl: './top-menu.html',
|
||||
styleUrls: [ './top-menu.less' ]
|
||||
})
|
||||
@Injectable()
|
||||
export class TopMenuComponent implements OnInit {
|
||||
public login: string = null;//Session.getLogin();
|
||||
public avatar: string = null;//Session.getAvatar();
|
||||
public displayUserMenu: boolean = false;
|
||||
public displayEditMenu: boolean = false;
|
||||
|
||||
public ariane_type_id: number = null;
|
||||
public ariane_type_name: string = null;
|
||||
|
||||
public ariane_universe_id: number = null;
|
||||
public ariane_universe_name: string = null;
|
||||
|
||||
public ariane_series_id: number = null;
|
||||
public ariane_series_name: string = null;
|
||||
|
||||
public ariane_season_id: number = null;
|
||||
public ariane_season_name: string = null;
|
||||
|
||||
public ariane_video_id: number = null;
|
||||
public ariane_video_name: string = null;
|
||||
|
||||
public edit_show: boolean = false;
|
||||
|
||||
constructor(private router: Router,
|
||||
public login: string = null;// Session.getLogin();
|
||||
public avatar: string = null;// Session.getAvatar();
|
||||
public displayUserMenu: boolean = false;
|
||||
public displayEditMenu: boolean = false;
|
||||
|
||||
public arianeTypeId: number = null;
|
||||
public arianeTypeName: string = null;
|
||||
|
||||
public arianeUniverseId: number = null;
|
||||
public arianeUniverseName: string = null;
|
||||
|
||||
public arianeSeriesId: number = null;
|
||||
public arianeSeriesName: string = null;
|
||||
|
||||
public arianeSeasonId: number = null;
|
||||
public arianeSeasonName: string = null;
|
||||
|
||||
public arianeVideoId: number = null;
|
||||
public arianeVideoName: string = null;
|
||||
|
||||
public editShow: boolean = false;
|
||||
|
||||
constructor(private router: Router,
|
||||
private sessionService: SessionService,
|
||||
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 {
|
||||
console.log("onAddMedia()");
|
||||
this.router.navigate(['upload']);
|
||||
this.displayUserMenu = false;
|
||||
}
|
||||
|
||||
onSetting(_event: any): void {
|
||||
console.log("onSetting()");
|
||||
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.ariane_type_id + ")");
|
||||
this.arianeService.navigateType(this.ariane_type_id, _event.which==2);
|
||||
}
|
||||
|
||||
onArianeUniverse(_event: any): void {
|
||||
console.log("onArianeUniverse(" + this.ariane_universe_id + ")");
|
||||
this.arianeService.navigateUniverse(this.ariane_universe_id, _event.which==2);
|
||||
}
|
||||
|
||||
onArianeSeries(_event: any): void {
|
||||
console.log("onArianeSeries(" + this.ariane_series_id + ")");
|
||||
this.arianeService.navigateSeries(this.ariane_series_id, _event.which==2);
|
||||
}
|
||||
|
||||
onArianeSeason(_event: any): void {
|
||||
console.log("onArianeSeason(" + this.ariane_season_id + ")");
|
||||
this.arianeService.navigateSeason(this.ariane_season_id, _event.which==2);
|
||||
}
|
||||
|
||||
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.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;
|
||||
}
|
||||
|
||||
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.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);
|
||||
}
|
||||
|
||||
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 {
|
||||
console.log('onAddMedia()');
|
||||
this.router.navigate([ 'upload' ]);
|
||||
this.displayUserMenu = false;
|
||||
}
|
||||
|
||||
onSetting(event: any): void {
|
||||
console.log('onSetting()');
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
||||
*/
|
@ -1,20 +1,20 @@
|
||||
import { Component} from '@angular/core';
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-upload-file',
|
||||
templateUrl: './upload-file.html',
|
||||
styleUrls: ['./upload-file.less']
|
||||
styleUrls: [ './upload-file.less' ]
|
||||
})
|
||||
|
||||
export class UploadFileComponent {
|
||||
files: any = [];
|
||||
uploadFile(event) {
|
||||
for (let index = 0; index < event.length; index++) {
|
||||
for(let index = 0; index < event.length; index++) {
|
||||
const element = event[index];
|
||||
this.files.push(element.name)
|
||||
this.files.push(element.name);
|
||||
}
|
||||
}
|
||||
deleteAttachment(index) {
|
||||
this.files.splice(index, 1)
|
||||
this.files.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
@ -7,15 +7,13 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-error',
|
||||
templateUrl: './error.html',
|
||||
styleUrls: ['./error.less']
|
||||
selector: 'app-error',
|
||||
templateUrl: './error.html',
|
||||
styleUrls: [ './error.less' ]
|
||||
})
|
||||
export class ErrorComponent implements OnInit {
|
||||
constructor() { }
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
}
|
||||
|
@ -3,60 +3,52 @@
|
||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||
* @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';
|
||||
|
||||
@Component({
|
||||
selector: 'create-type',
|
||||
templateUrl: './create-type.html',
|
||||
styleUrls: ['./create-type.less']
|
||||
styleUrls: [ './create-type.less' ]
|
||||
})
|
||||
|
||||
@Injectable()
|
||||
export class PopInCreateType implements OnInit {
|
||||
|
||||
name: string = "";
|
||||
description: string = "";
|
||||
|
||||
constructor(private router: Router,
|
||||
private typeService: TypeService,
|
||||
private popInService: PopInService) {
|
||||
|
||||
name: string = '';
|
||||
description: string = '';
|
||||
|
||||
constructor(private popInService: PopInService) {
|
||||
|
||||
}
|
||||
OnDestroy() {
|
||||
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
|
||||
|
||||
}
|
||||
eventPopUp(_event: string): void {
|
||||
console.log("GET event: " + _event);
|
||||
this.popInService.close("popin-create-type");
|
||||
eventPopUp(event: string): void {
|
||||
console.log(`GET event: ${ event}`);
|
||||
this.popInService.close('popin-create-type');
|
||||
}
|
||||
updateNeedSend():void {
|
||||
|
||||
|
||||
}
|
||||
onName(_value:any):void {
|
||||
if (_value.length == 0) {
|
||||
this.name = "";
|
||||
onName(value:any):void {
|
||||
if(value.length === 0) {
|
||||
this.name = '';
|
||||
} else {
|
||||
this.name = _value;
|
||||
this.name = value;
|
||||
}
|
||||
this.updateNeedSend();
|
||||
}
|
||||
|
||||
onDescription(_value:any):void {
|
||||
if (_value.length == 0) {
|
||||
this.description = "";
|
||||
|
||||
onDescription(value:any):void {
|
||||
if(value.length === 0) {
|
||||
this.description = '';
|
||||
} else {
|
||||
this.description = _value;
|
||||
this.description = value;
|
||||
}
|
||||
this.updateNeedSend();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,11 @@
|
||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||
* @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 { TypeService } from '../../service/type';
|
||||
import { PopInService } from '../../service/popin';
|
||||
@ -15,38 +15,36 @@ import { PopInService } from '../../service/popin';
|
||||
@Component({
|
||||
selector: 'delete-confirm',
|
||||
templateUrl: './delete-confirm.html',
|
||||
styleUrls: ['./delete-confirm.less']
|
||||
styleUrls: [ './delete-confirm.less' ]
|
||||
})
|
||||
|
||||
@Injectable()
|
||||
export class PopInDeleteConfirm implements OnInit {
|
||||
|
||||
@Input() comment: string = null;
|
||||
@Input() imageUrl: string = null;
|
||||
@Output() callback: EventEmitter<any> = new EventEmitter();
|
||||
|
||||
public closeButtonTitle: string = "Cancel";
|
||||
public validateButtonTitle: string = "Validate";
|
||||
|
||||
|
||||
public closeButtonTitle: string = 'Cancel';
|
||||
public validateButtonTitle: string = 'Validate';
|
||||
|
||||
constructor(private router: Router,
|
||||
private popInService: PopInService) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
OnDestroy() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
eventPopUp(_event: string): void {
|
||||
console.log("GET event: " + _event);
|
||||
this.popInService.close("popin-delete-confirm");
|
||||
if (_event == "validate") {
|
||||
console.log(`GET event: ${ _event}`);
|
||||
this.popInService.close('popin-delete-confirm');
|
||||
if(_event === 'validate') {
|
||||
this.callback.emit(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
|
||||
|
||||
.expand {
|
||||
width: 100%;
|
||||
input {
|
||||
width: 100%;
|
||||
};
|
||||
textarea {
|
||||
width: 100%;
|
||||
};
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
*/
|
||||
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 { TypeService } from '../../service/type';
|
||||
import { PopInService } from '../../service/popin';
|
||||
@ -15,114 +15,113 @@ import { PopInService } from '../../service/popin';
|
||||
@Component({
|
||||
selector: 'upload-progress',
|
||||
templateUrl: './upload-progress.html',
|
||||
styleUrls: ['./upload-progress.less']
|
||||
styleUrls: [ './upload-progress.less' ]
|
||||
})
|
||||
|
||||
@Injectable()
|
||||
export class PopInUploadProgress implements OnInit {
|
||||
|
||||
@Input() mediaTitle: string = "";
|
||||
@Input() mediaTitle: string = '';
|
||||
@Input() mediaUploaded: number = 0;
|
||||
@Input() mediaSize: number = 999999999999;
|
||||
@Input() result: string = null;
|
||||
@Input() error: string = null;
|
||||
public closeButtonTitle: string = "Abort";
|
||||
public closeButtonTitle: string = 'Abort';
|
||||
public otherButtonTitle: string = null;
|
||||
public validateButtonTitle: string = null;
|
||||
public uploadDisplay: string = "";
|
||||
public sizeDisplay: string = "";
|
||||
public uploadDisplay: string = '';
|
||||
public sizeDisplay: string = '';
|
||||
public progress: number = 0;
|
||||
constructor(private router: Router,
|
||||
private popInService: PopInService) {
|
||||
|
||||
|
||||
}
|
||||
OnDestroy() {
|
||||
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
|
||||
|
||||
}
|
||||
eventPopUp(_event: string): void {
|
||||
console.log("GET event: " + _event);
|
||||
this.popInService.close("popin-upload-progress");
|
||||
console.log(`GET event: ${ _event}`);
|
||||
this.popInService.close('popin-upload-progress');
|
||||
}
|
||||
updateNeedSend():void {
|
||||
|
||||
|
||||
}
|
||||
|
||||
limit3(count:number):string {
|
||||
if (count>=1000) {
|
||||
return "" + count;
|
||||
if(count >= 1000) {
|
||||
return `${ count}`;
|
||||
}
|
||||
if (count>=100) {
|
||||
return " " + count;
|
||||
if(count >= 100) {
|
||||
return ` ${ count}`;
|
||||
}
|
||||
if (count>=10) {
|
||||
return " " + count;
|
||||
if(count >= 10) {
|
||||
return ` ${ count}`;
|
||||
}
|
||||
return " " + count;
|
||||
return ` ${ count}`;
|
||||
}
|
||||
convertInHuman(countIn:number):string {
|
||||
let count = countIn;
|
||||
let tera = Math.trunc(count/(1024*1024*1024*1024));
|
||||
count = count - tera*1024*1024*1024*1024;
|
||||
let giga = Math.trunc(count/(1024*1024*1024));
|
||||
count = count - giga*1024*1024*1024;
|
||||
let mega = Math.trunc(count/(1024*1024));
|
||||
count = count - mega*1024*1024;
|
||||
let kilo = Math.trunc(count/1024);
|
||||
count = count - kilo*1024;
|
||||
let out = ""
|
||||
if (out.length != 0 || tera != 0) {
|
||||
out += " " + this.limit3(tera) + "T";
|
||||
let tera = Math.trunc(count / (1024 * 1024 * 1024 * 1024));
|
||||
count = count - tera * 1024 * 1024 * 1024 * 1024;
|
||||
let giga = Math.trunc(count / (1024 * 1024 * 1024));
|
||||
count = count - giga * 1024 * 1024 * 1024;
|
||||
let mega = Math.trunc(count / (1024 * 1024));
|
||||
count = count - mega * 1024 * 1024;
|
||||
let kilo = Math.trunc(count / 1024);
|
||||
count = count - kilo * 1024;
|
||||
let out = '';
|
||||
if(out.length !== 0 || tera !== 0) {
|
||||
out = `${out } ${ this.limit3(tera) }T`;
|
||||
}
|
||||
if (out.length != 0 || giga != 0) {
|
||||
out += " " + this.limit3(giga) + "G";
|
||||
if(out.length !== 0 || giga !== 0) {
|
||||
out = `${out } ${ this.limit3(giga) }G`;
|
||||
}
|
||||
if (out.length != 0 || mega != 0) {
|
||||
out += " " + this.limit3(mega)+ "M";
|
||||
if(out.length !== 0 || mega !== 0) {
|
||||
out = `${out } ${ this.limit3(mega) }M`;
|
||||
}
|
||||
if (out.length != 0 || kilo != 0) {
|
||||
out += " " + this.limit3(kilo) + "k";
|
||||
if(out.length !== 0 || kilo !== 0) {
|
||||
out = `${out } ${ this.limit3(kilo) }k`;
|
||||
}
|
||||
if (out.length != 0 || count != 0) {
|
||||
out += " " + this.limit3(count) + "B";
|
||||
if(out.length !== 0 || count !== 0) {
|
||||
out = `${out } ${ this.limit3(count) }B`;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
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.sizeDisplay = this.convertInHuman(this.mediaSize);
|
||||
if ( this.error == null && this.result == null) {
|
||||
this.closeButtonTitle = "Abort";
|
||||
if(this.error === null && this.result === null) {
|
||||
this.closeButtonTitle = 'Abort';
|
||||
this.otherButtonTitle = null;
|
||||
this.validateButtonTitle = null;
|
||||
} else if (this.result == null) {
|
||||
} else if(this.result === null) {
|
||||
this.closeButtonTitle = null;
|
||||
this.otherButtonTitle = "Close";
|
||||
this.otherButtonTitle = 'Close';
|
||||
this.validateButtonTitle = null;
|
||||
} else {
|
||||
this.closeButtonTitle = null;
|
||||
this.otherButtonTitle = null;
|
||||
this.validateButtonTitle = "Ok";
|
||||
this.validateButtonTitle = 'Ok';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class UploadProgress {
|
||||
labelMediaTitle: string = "";
|
||||
labelMediaTitle: string = '';
|
||||
mediaSendSize: number = 0;
|
||||
mediaSize: number = 99999999999999;
|
||||
result: string = null;
|
||||
error: string = null;
|
||||
clear() {
|
||||
this.labelMediaTitle = "";
|
||||
this.labelMediaTitle = '';
|
||||
this.mediaSendSize = 0;
|
||||
this.mediaSize = 99999999999999;
|
||||
this.result = null;
|
||||
this.error = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -9,18 +9,16 @@ import { ActivatedRoute } from '@angular/router';
|
||||
import { ArianeService } from '../../service/ariane';
|
||||
|
||||
@Component({
|
||||
selector: 'app-error-viewer',
|
||||
templateUrl: './error-viewer.html',
|
||||
styleUrls: ['./error-viewer.less']
|
||||
selector: 'app-error-viewer',
|
||||
templateUrl: './error-viewer.html',
|
||||
styleUrls: [ './error-viewer.less' ]
|
||||
})
|
||||
export class ErrorViewerScene implements OnInit {
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private arianeService: ArianeService) { }
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -3,17 +3,15 @@ import { ActivatedRoute } from '@angular/router';
|
||||
import { ArianeService } from '../../service/ariane';
|
||||
|
||||
@Component({
|
||||
selector: 'app-help',
|
||||
templateUrl: './help.html',
|
||||
styleUrls: ['./help.less']
|
||||
selector: 'app-help',
|
||||
templateUrl: './help.html',
|
||||
styleUrls: [ './help.less' ]
|
||||
})
|
||||
export class HelpScene implements OnInit {
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private arianeService: ArianeService) { }
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,8 +3,8 @@
|
||||
Karideo
|
||||
</div>
|
||||
<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)">
|
||||
<app-element-type [id_type]="data.id"></app-element-type>
|
||||
<div *ngFor="let data of dataList" class="item-home" (click)="onSelectType($event, data.id)" (auxclick)="onSelectType($event, data.id)">
|
||||
<app-element-type [idType]="data.id"></app-element-type>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
@ -5,8 +5,7 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from "@angular/router";
|
||||
import { Location } from '@angular/common';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { fadeInAnimation } from '../../_animations/index';
|
||||
|
||||
import { TypeService } from '../../service/type';
|
||||
@ -15,38 +14,35 @@ import { ArianeService } from '../../service/ariane';
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
templateUrl: './home.html',
|
||||
styleUrls: ['./home.less'],
|
||||
animations: [fadeInAnimation],
|
||||
styleUrls: [ './home.less' ],
|
||||
animations: [ fadeInAnimation ],
|
||||
host: { '[@fadeInAnimation]': '' }
|
||||
})
|
||||
export class HomeScene implements OnInit {
|
||||
data_list = [];
|
||||
error = "";
|
||||
dataList = [];
|
||||
error = '';
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private locate: Location,
|
||||
private typeService: TypeService,
|
||||
private arianeService: ArianeService) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
||||
let self = this
|
||||
let self = this;
|
||||
this.typeService.getData()
|
||||
.then(function(response) {
|
||||
self.error = "";
|
||||
self.data_list = response
|
||||
console.log("Get response: " + JSON.stringify(response, null, 2));
|
||||
}).catch(function(response) {
|
||||
self.error = "Wrong e-mail/login or password";
|
||||
console.log("[E] " + self.constructor.name + ": Does not get a correct response from the server ...");
|
||||
self.data_list = []
|
||||
.then((response) => {
|
||||
self.error = '';
|
||||
self.dataList = response;
|
||||
console.log(`Get response: ${ JSON.stringify(response, null, 2)}`);
|
||||
}).catch((response) => {
|
||||
self.error = 'Wrong e-mail/login or password';
|
||||
console.log(`[E] ${ self.constructor.name }: Does not get a correct response from the server ...`);
|
||||
self.dataList = [];
|
||||
});
|
||||
this.arianeService.reset();
|
||||
}
|
||||
onSelectType(_event: any, _idSelected: number):void {
|
||||
this.arianeService.navigateType(_idSelected, _event.which==2);
|
||||
this.arianeService.navigateType(_idSelected, _event.which === 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Router } from "@angular/router";
|
||||
import { Router } from '@angular/router';
|
||||
import { Location } from '@angular/common';
|
||||
import { fadeInAnimation } from '../../_animations/index';
|
||||
import { UserService } from '../../service/user';
|
||||
@ -15,29 +15,29 @@ import { CookiesService } from '../../service/cookies';
|
||||
import { ArianeService } from '../../service/ariane';
|
||||
|
||||
|
||||
export let checkLoginValidity = function(_value:string):boolean {
|
||||
let regexCheck = new RegExp("^[a-zA-Z0-9_\.-]+$");
|
||||
if (regexCheck.test(_value)) {
|
||||
export function checkLoginValidity(value:string):boolean {
|
||||
let regexCheck = new RegExp('^[a-zA-Z0-9_\\.-]+$');
|
||||
if(regexCheck.test(value)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
export let checkEmailValidity = function(_value:string):boolean {
|
||||
let regexCheck = new RegExp("^[a-zA-Z0-9_\.@-]+@[a-zA-Z0-9_\.-]+\\.[a-zA-Z]+$");
|
||||
if (regexCheck.test(_value)) {
|
||||
export function checkEmailValidity(value:string):boolean {
|
||||
let regexCheck = new RegExp('^[a-zA-Z0-9_\\.@-]+@[a-zA-Z0-9_\\.-]+\\.[a-zA-Z]+$');
|
||||
if(regexCheck.test(value)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
export let checkPasswordValidity = function(_value:string):boolean {
|
||||
let regexCheck = new RegExp("^[a-zA-Z0-9_\.@ %:;,=}{\?\!\*\+\(\)\[\]\|&#%~/\\\<\>-£€]+$");
|
||||
if (regexCheck.test(_value)) {
|
||||
export function checkPasswordValidity(value:string):boolean {
|
||||
let regexCheck = new RegExp('^[a-zA-Z0-9_\\.@ %:;,=}{\\?\\!\\*\\+\\(\\)\\[\\]\\|&#%~/\\\\\\<\\>-£€]+$');
|
||||
if(regexCheck.test(value)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
declare function SHA512(param1: any): any;
|
||||
@ -45,23 +45,23 @@ declare function SHA512(param1: any): any;
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
templateUrl: './login.html',
|
||||
styleUrls: ['./login.less'],
|
||||
animations: [fadeInAnimation],
|
||||
styleUrls: [ './login.less' ],
|
||||
animations: [ fadeInAnimation ],
|
||||
host: { '[@fadeInAnimation]': '' }
|
||||
})
|
||||
export class LoginScene implements OnInit {
|
||||
public loginOK:boolean = false;
|
||||
public loginHelp:string = "";
|
||||
public login:string = "";
|
||||
public loginHelp:string = '';
|
||||
public login:string = '';
|
||||
public passOK:boolean = false;
|
||||
public passHelp:string = "";
|
||||
public password:string = "";
|
||||
public passHelp:string = '';
|
||||
public password:string = '';
|
||||
public loginButtonDisabled:boolean = true;
|
||||
public error:string = "";
|
||||
public loginType:string = "Username/E-mail";
|
||||
|
||||
public error:string = '';
|
||||
public loginType:string = 'Username/E-mail';
|
||||
|
||||
public rememberMe:boolean = true;
|
||||
|
||||
|
||||
constructor(private router: Router,
|
||||
private route: ActivatedRoute,
|
||||
private locate: Location,
|
||||
@ -69,105 +69,102 @@ export class LoginScene implements OnInit {
|
||||
private userService: UserService,
|
||||
private sessionService: SessionService,
|
||||
private arianeService: ArianeService) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
updateButtonVisibility():void {
|
||||
if ( this.loginOK == true
|
||||
&& this.passOK == true) {
|
||||
if(this.loginOK === true &&
|
||||
this.passOK === true) {
|
||||
this.loginButtonDisabled = false;
|
||||
} else {
|
||||
this.loginButtonDisabled = true;
|
||||
}
|
||||
this.error = "";
|
||||
this.error = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the login writing rules
|
||||
*/
|
||||
checkLogin(_newValue:string):void {
|
||||
this.login = _newValue;
|
||||
if (this.login == null) {
|
||||
checkLogin(newValue:string):void {
|
||||
this.login = newValue;
|
||||
if(this.login === null) {
|
||||
this.loginOK = false;
|
||||
this.loginHelp = "";
|
||||
this.loginHelp = '';
|
||||
this.updateButtonVisibility();
|
||||
return;
|
||||
}
|
||||
if (this.login.length < 6) {
|
||||
if(this.login.length < 6) {
|
||||
this.loginOK = false;
|
||||
this.loginHelp = "Need 6 characters";
|
||||
this.loginType = "Username/E-mail";
|
||||
this.loginHelp = 'Need 6 characters';
|
||||
this.loginType = 'Username/E-mail';
|
||||
this.updateButtonVisibility();
|
||||
return;
|
||||
}
|
||||
if (checkLoginValidity(this.login) == true) {
|
||||
if(checkLoginValidity(this.login) === true) {
|
||||
this.loginOK = true;
|
||||
this.loginHelp = "";
|
||||
this.loginType = "Username";
|
||||
this.loginHelp = '';
|
||||
this.loginType = 'Username';
|
||||
} else if(checkEmailValidity(this.login) === true) {
|
||||
this.loginOK = true;
|
||||
this.loginHelp = '';
|
||||
this.loginType = 'E-mail';
|
||||
} else {
|
||||
if (checkEmailValidity(this.login) == true) {
|
||||
this.loginOK = true;
|
||||
this.loginHelp = "";
|
||||
this.loginType = "E-mail";
|
||||
} else {
|
||||
this.loginOK = false;
|
||||
this.loginHelp = 'Not valid: characters, numbers, "_-." and email format: you@example.com';
|
||||
}
|
||||
this.loginOK = false;
|
||||
this.loginHelp = 'Not valid: characters, numbers, "_-." and email format: you@example.com';
|
||||
}
|
||||
this.updateButtonVisibility();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check the password writing rules
|
||||
*/
|
||||
checkPassword(_newValue:string):void {
|
||||
this.password = _newValue;
|
||||
if (this.password == null) {
|
||||
checkPassword(newValue:string):void {
|
||||
this.password = newValue;
|
||||
if(this.password === null) {
|
||||
this.passOK = false;
|
||||
this.passHelp = "";
|
||||
this.passHelp = '';
|
||||
this.updateButtonVisibility();
|
||||
return;
|
||||
}
|
||||
if (this.password.length < 6) {
|
||||
if(this.password.length < 6) {
|
||||
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 {
|
||||
if (checkPasswordValidity(this.password) == true) {
|
||||
this.passOK = true;
|
||||
this.passHelp = "";
|
||||
} else {
|
||||
this.passOK = false;
|
||||
this.passHelp = 'Not valid: characters, numbers and "_-:;.,?!*+=}{([|)]% @&~#/\<>"';
|
||||
}
|
||||
this.passOK = false;
|
||||
this.passHelp = 'Not valid: characters, numbers and "_-:;.,?!*+=}{([|)]% @&~#/\\<>"';
|
||||
}
|
||||
this.updateButtonVisibility();
|
||||
}
|
||||
onLogin():void {
|
||||
this.sessionService.destroy();
|
||||
let self = this
|
||||
let self = this;
|
||||
this.userService.login(this.login, this.password)
|
||||
.then(function(response) {
|
||||
self.error = "Login ...";
|
||||
self.sessionService.create(response['sessionId'],
|
||||
response['login'],
|
||||
response['email'],
|
||||
response['role'],
|
||||
response['avatar']);
|
||||
if (self.rememberMe == true) {
|
||||
self.cookiesService.set("yota-login", response['login'], 120);
|
||||
self.cookiesService.set("yota-password", SHA512(self.password), 60);
|
||||
.then((response) => {
|
||||
self.error = 'Login ...';
|
||||
self.sessionService.create(response.sessionId,
|
||||
response.login,
|
||||
response.email,
|
||||
response.role,
|
||||
response.avatar);
|
||||
if(self.rememberMe === true) {
|
||||
self.cookiesService.set('yota-login', response.login, 120);
|
||||
self.cookiesService.set('yota-password', SHA512(self.password), 60);
|
||||
}
|
||||
self.router.navigate(['home']);
|
||||
}).catch(function(response) {
|
||||
self.error = "Wrong e-mail/login or password";
|
||||
self.router.navigate([ 'home' ]);
|
||||
}).catch((response) => {
|
||||
self.error = 'Wrong e-mail/login or password';
|
||||
});
|
||||
}
|
||||
onCancel():void {
|
||||
console.log("onCancel ... '" + this.login + "':'" + this.password + "'");
|
||||
console.log(`onCancel ... '${ this.login }':'${ this.password }'`);
|
||||
this.locate.back();
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@
|
||||
</div>
|
||||
<div class="request_raw">
|
||||
<div class="input">
|
||||
<div class="cover" *ngFor="let element of covers_display">
|
||||
<div class="cover" *ngFor="let element of coversDisplay">
|
||||
<div class="cover-image">
|
||||
<img src="{{element.url}}"/>
|
||||
</div>
|
||||
@ -100,7 +100,7 @@
|
||||
<i class="material-icons">data_usage</i> ID:
|
||||
</div>
|
||||
<div class="input">
|
||||
{{id_season}}
|
||||
{{idSeason}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
|
@ -5,63 +5,57 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { Location } from '@angular/common';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { fadeInAnimation } from '../../_animations/index';
|
||||
|
||||
import { SeasonService } from '../../service/season';
|
||||
import { DataService } from '../../service/data';
|
||||
import { ArianeService } from '../../service/ariane';
|
||||
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;
|
||||
label: string;
|
||||
constructor(_value: number, _label: string) {
|
||||
this.value = _value;
|
||||
this.label = _label;
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-season-edit',
|
||||
templateUrl: './season-edit.html',
|
||||
styleUrls: ['./season-edit.less'],
|
||||
animations: [fadeInAnimation],
|
||||
styleUrls: [ './season-edit.less' ],
|
||||
animations: [ fadeInAnimation ],
|
||||
host: { '[@fadeInAnimation]': '' }
|
||||
})
|
||||
|
||||
export class SeasonEditScene implements OnInit {
|
||||
id_season:number = -1;
|
||||
idSeason:number = -1;
|
||||
itemIsRemoved:boolean = false;
|
||||
itemIsNotFound:boolean = false;
|
||||
itemIsLoading:boolean = true;
|
||||
|
||||
error:string = "";
|
||||
|
||||
numberVal:number = null;
|
||||
description:string = "";
|
||||
coverFile:File;
|
||||
upload_file_value:string = "";
|
||||
selectedFiles:FileList;
|
||||
videoCount:string = null;
|
||||
|
||||
|
||||
covers_display:Array<any> = [];
|
||||
// section tha define the upload value to display in the pop-in of upload
|
||||
public upload:UploadProgress = new UploadProgress();
|
||||
// --------------- confirm section ------------------
|
||||
public confirmDeleteComment:string = null;
|
||||
public confirmDeleteImageUrl:string = null;
|
||||
private deleteCoverId:number = null;
|
||||
private deleteItemId:number = null;
|
||||
error:string = '';
|
||||
|
||||
numberVal: number = null;
|
||||
description: string = '';
|
||||
coverFile: File;
|
||||
uploadFileValue: string = '';
|
||||
selectedFiles: FileList;
|
||||
videoCount: string = null;
|
||||
|
||||
|
||||
coversDisplay: Array<any> = [];
|
||||
// section tha define the upload value to display in the pop-in of upload
|
||||
public upload: UploadProgress = new UploadProgress();
|
||||
// --------------- confirm section ------------------
|
||||
public confirmDeleteComment: string = null;
|
||||
public confirmDeleteImageUrl: string = null;
|
||||
private deleteCoverId: number = null;
|
||||
private deleteItemId: number = null;
|
||||
deleteConfirmed() {
|
||||
if (this.deleteCoverId !== null) {
|
||||
if(this.deleteCoverId !== null) {
|
||||
this.removeCoverAfterConfirm(this.deleteCoverId);
|
||||
this.cleanConfirm();
|
||||
}
|
||||
if (this.deleteItemId !== null) {
|
||||
if(this.deleteItemId !== null) {
|
||||
this.removeItemAfterConfirm(this.deleteItemId);
|
||||
this.cleanConfirm();
|
||||
}
|
||||
@ -72,162 +66,159 @@ export class SeasonEditScene implements OnInit {
|
||||
this.deleteCoverId = null;
|
||||
this.deleteItemId = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private locate: Location,
|
||||
private dataService: DataService,
|
||||
private seasonService: SeasonService,
|
||||
private arianeService: ArianeService,
|
||||
private popInService: PopInService) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
||||
this.id_season = this.arianeService.getSeasonId();
|
||||
this.idSeason = this.arianeService.getSeasonId();
|
||||
let self = this;
|
||||
this.seasonService.get(this.id_season)
|
||||
.then(function(response) {
|
||||
console.log("get response of season : " + JSON.stringify(response, null, 2));
|
||||
this.seasonService.get(this.idSeason)
|
||||
.then((response) => {
|
||||
console.log(`get response of season : ${ JSON.stringify(response, null, 2)}`);
|
||||
self.numberVal = response.name;
|
||||
self.description = response.description;
|
||||
self.updateCoverList(response.covers);
|
||||
self.itemIsLoading = false;
|
||||
}).catch(function(response) {
|
||||
self.error = "Can not get the data";
|
||||
}).catch((response) => {
|
||||
self.error = 'Can not get the data';
|
||||
self.numberVal = null;
|
||||
self.description = "";
|
||||
self.covers_display = [];
|
||||
self.description = '';
|
||||
self.coversDisplay = [];
|
||||
self.itemIsNotFound = true;
|
||||
self.itemIsLoading = false;
|
||||
});
|
||||
this.seasonService.getVideo(this.id_season)
|
||||
.then(function(response:any) {
|
||||
this.seasonService.getVideo(this.idSeason)
|
||||
.then((response:any) => {
|
||||
self.videoCount = response.length;
|
||||
}).catch(function(response:any) {
|
||||
self.videoCount = "---";
|
||||
}).catch((response:any) => {
|
||||
self.videoCount = '---';
|
||||
});
|
||||
}
|
||||
|
||||
updateCoverList(_covers: any) {
|
||||
this.covers_display = [];
|
||||
if (_covers !== undefined && _covers !== null) {
|
||||
for (let iii=0; iii<_covers.length; iii++) {
|
||||
this.covers_display.push({
|
||||
id:_covers[iii],
|
||||
url:this.seasonService.getCoverThumbnailUrl(_covers[iii])
|
||||
});
|
||||
updateCoverList(covers: any) {
|
||||
this.coversDisplay = [];
|
||||
if(covers !== undefined && covers !== null) {
|
||||
for(let iii = 0; iii < covers.length; iii++) {
|
||||
this.coversDisplay.push({
|
||||
id:covers[iii],
|
||||
url:this.seasonService.getCoverThumbnailUrl(covers[iii])
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.covers_display = []
|
||||
this.coversDisplay = [];
|
||||
}
|
||||
}
|
||||
onNumber(_value:any):void {
|
||||
this.numberVal = _value;
|
||||
onNumber(value:any):void {
|
||||
this.numberVal = value;
|
||||
}
|
||||
|
||||
onDescription(_value:any):void {
|
||||
this.description = _value;
|
||||
|
||||
onDescription(value:any):void {
|
||||
this.description = value;
|
||||
}
|
||||
|
||||
|
||||
sendValues():void {
|
||||
console.log("send new values....");
|
||||
console.log('send new values....');
|
||||
let data = {
|
||||
"name": this.numberVal,
|
||||
"description": this.description
|
||||
name: this.numberVal,
|
||||
description: this.description
|
||||
};
|
||||
if (this.description === undefined) {
|
||||
data["description"] = null;
|
||||
if(this.description === undefined) {
|
||||
data.description = null;
|
||||
}
|
||||
this.seasonService.put(this.id_season, data);
|
||||
this.seasonService.put(this.idSeason, data);
|
||||
}
|
||||
|
||||
|
||||
// At the drag drop area
|
||||
// (drop)="onDropFile($event)"
|
||||
onDropFile(_event: DragEvent) {
|
||||
_event.preventDefault();
|
||||
//this.uploadFile(_event.dataTransfer.files[0]);
|
||||
onDropFile(event: DragEvent) {
|
||||
event.preventDefault();
|
||||
// this.uploadFile(event.dataTransfer.files[0]);
|
||||
}
|
||||
|
||||
|
||||
// At the drag drop area
|
||||
// (dragover)="onDragOverFile($event)"
|
||||
onDragOverFile(_event) {
|
||||
_event.stopPropagation();
|
||||
_event.preventDefault();
|
||||
onDragOverFile(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
// At the file input element
|
||||
// (change)="selectFile($event)"
|
||||
onChangeCover(_value:any):void {
|
||||
this.selectedFiles = _value.files
|
||||
onChangeCover(value:any):void {
|
||||
this.selectedFiles = value.files;
|
||||
this.coverFile = this.selectedFiles[0];
|
||||
console.log("select file " + this.coverFile.name);
|
||||
console.log(`select file ${ this.coverFile.name}`);
|
||||
this.uploadCover(this.coverFile);
|
||||
}
|
||||
|
||||
uploadCover(_file:File) {
|
||||
if (_file == undefined) {
|
||||
console.log("No file selected!");
|
||||
|
||||
uploadCover(file:File) {
|
||||
if(file === undefined) {
|
||||
console.log('No file selected!');
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
// clean upload labels
|
||||
this.upload.clear();
|
||||
// display the upload pop-in
|
||||
this.popInService.open("popin-upload-progress");
|
||||
this.seasonService.uploadCover(_file, this.id_season, function(count, total) {
|
||||
this.popInService.open('popin-upload-progress');
|
||||
this.seasonService.uploadCover(file, this.idSeason, (count, total) => {
|
||||
self.upload.mediaSendSize = count;
|
||||
self.upload.mediaSize = total;
|
||||
})
|
||||
.then(function (response:any) {
|
||||
self.upload.result = "Cover added done";
|
||||
// TODO: we retrive the whiole media ==> update data ...
|
||||
.then((response:any) => {
|
||||
self.upload.result = 'Cover added done';
|
||||
// we retrive the whiole media ==> update data ...
|
||||
self.updateCoverList(response.covers);
|
||||
}).catch(function (response:any) {
|
||||
//self.error = "Can not get the data";
|
||||
console.log("Can not add the cover in the video...");
|
||||
}).catch((response:any) => {
|
||||
// self.error = "Can not get the data";
|
||||
console.log('Can not add the cover in the video...');
|
||||
});
|
||||
}
|
||||
|
||||
removeCover(_id:number) {
|
||||
removeCover(id:number) {
|
||||
this.cleanConfirm();
|
||||
this.confirmDeleteComment = "Delete the cover ID: " + _id;
|
||||
this.confirmDeleteImageUrl = this.seasonService.getCoverThumbnailUrl(_id);
|
||||
this.deleteCoverId = _id;
|
||||
this.popInService.open("popin-delete-confirm");
|
||||
this.confirmDeleteComment = `Delete the cover ID: ${ id}`;
|
||||
this.confirmDeleteImageUrl = this.seasonService.getCoverThumbnailUrl(id);
|
||||
this.deleteCoverId = id;
|
||||
this.popInService.open('popin-delete-confirm');
|
||||
}
|
||||
removeCoverAfterConfirm(_id:number) {
|
||||
console.log("Request remove cover: " + _id);
|
||||
removeCoverAfterConfirm(id:number) {
|
||||
console.log(`Request remove cover: ${ id}`);
|
||||
let self = this;
|
||||
this.seasonService.deleteCover(this.id_season, _id)
|
||||
.then(function (response:any) {
|
||||
self.upload.result = "Cover remove done";
|
||||
// TODO: we retrive the whiole media ==> update data ...
|
||||
this.seasonService.deleteCover(this.idSeason, id)
|
||||
.then((response:any) => {
|
||||
self.upload.result = 'Cover remove done';
|
||||
// we retrive the whiole media ==> update data ...
|
||||
self.updateCoverList(response.covers);
|
||||
}).catch(function (response:any) {
|
||||
//self.error = "Can not get the data";
|
||||
console.log("Can not remove the cover of the video...");
|
||||
}).catch((response:any) => {
|
||||
// self.error = "Can not get the data";
|
||||
console.log('Can not remove the cover of the video...');
|
||||
});
|
||||
}
|
||||
|
||||
removeItem() {
|
||||
console.log("Request remove Media...");
|
||||
console.log('Request remove Media...');
|
||||
this.cleanConfirm();
|
||||
this.confirmDeleteComment = "Delete the Season: " + this.id_season;
|
||||
this.deleteItemId = this.id_season;
|
||||
this.popInService.open("popin-delete-confirm");
|
||||
this.confirmDeleteComment = `Delete the Season: ${ this.idSeason}`;
|
||||
this.deleteItemId = this.idSeason;
|
||||
this.popInService.open('popin-delete-confirm');
|
||||
}
|
||||
removeItemAfterConfirm(_id:number) {
|
||||
removeItemAfterConfirm(id:number) {
|
||||
let self = this;
|
||||
this.seasonService.delete(_id)
|
||||
.then(function(response3) {
|
||||
//self.data_ori = tmpp;
|
||||
//self.updateNeedSend();
|
||||
this.seasonService.delete(id)
|
||||
.then((response3) => {
|
||||
// self.dataOri = tmpp;
|
||||
// self.updateNeedSend();
|
||||
self.itemIsRemoved = true;
|
||||
}).catch(function(response3) {
|
||||
//self.updateNeedSend();
|
||||
}).catch((response3) => {
|
||||
// self.updateNeedSend();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<div [className]="cover != null ? 'description-area description-area-cover' : 'description-area description-area-no-cover'">
|
||||
<div *ngIf="series_name" class="title">
|
||||
{{series_name}}
|
||||
<div *ngIf="seriesName" class="title">
|
||||
{{seriesName}}
|
||||
</div>
|
||||
<div class="sub-title-main">
|
||||
Season {{name}}
|
||||
|
@ -5,8 +5,7 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { Location } from '@angular/common';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { fadeInAnimation } from '../../_animations/index';
|
||||
|
||||
import { SeasonService } from '../../service/season';
|
||||
@ -16,76 +15,73 @@ import { ArianeService } from '../../service/ariane';
|
||||
@Component({
|
||||
selector: 'app-season',
|
||||
templateUrl: './season.html',
|
||||
styleUrls: ['./season.less'],
|
||||
animations: [fadeInAnimation],
|
||||
styleUrls: [ './season.less' ],
|
||||
animations: [ fadeInAnimation ],
|
||||
host: { '[@fadeInAnimation]': '' }
|
||||
})
|
||||
export class SeasonScene implements OnInit {
|
||||
name: string = "";
|
||||
series_name: string = "";
|
||||
description: string = "";
|
||||
series_id: number = null;
|
||||
cover: string = ""
|
||||
covers: Array<string> = []
|
||||
id_season = -1;
|
||||
videos_error = "";
|
||||
name: string = '';
|
||||
seriesName: string = '';
|
||||
description: string = '';
|
||||
seriesId: number = null;
|
||||
cover: string = '';
|
||||
covers: Array<string> = [];
|
||||
idSeason = -1;
|
||||
videosError = '';
|
||||
videos = [];
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private locate: Location,
|
||||
private seasonService: SeasonService,
|
||||
private seriesService: SeriesService,
|
||||
private arianeService: ArianeService) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
console.log("ngOnInit(SeasonComponent)");
|
||||
console.log('ngOnInit(SeasonComponent)');
|
||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
||||
this.id_season = this.arianeService.getSeasonId();
|
||||
|
||||
this.idSeason = this.arianeService.getSeasonId();
|
||||
|
||||
let self = this;
|
||||
this.seasonService.get(this.id_season)
|
||||
.then(function(response:any) {
|
||||
this.seasonService.get(this.idSeason)
|
||||
.then((response:any) => {
|
||||
self.name = response.name;
|
||||
self.series_id = response.parent_id;
|
||||
self.seriesId = response.parentId;
|
||||
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.covers = [];
|
||||
} else {
|
||||
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.seriesService.get(self.series_id)
|
||||
.then(function(response:any) {
|
||||
self.series_name = response.name;
|
||||
}).catch(function(response:any) {
|
||||
self.series_name = "";
|
||||
self.seriesService.get(self.seriesId)
|
||||
.then((response2:any) => {
|
||||
self.seriesName = response2.name;
|
||||
}).catch((response2:any) => {
|
||||
self.seriesName = '';
|
||||
});
|
||||
}).catch(function(response:any) {
|
||||
self.description = "";
|
||||
self.name = "???";
|
||||
self.series_name = "";
|
||||
self.series_id = null;
|
||||
}).catch((response3:any) => {
|
||||
self.description = '';
|
||||
self.name = '???';
|
||||
self.seriesName = '';
|
||||
self.seriesId = null;
|
||||
self.cover = null;
|
||||
self.covers = [];
|
||||
});
|
||||
console.log("get parameter id: " + this.id_season);
|
||||
this.seasonService.getVideo(this.id_season)
|
||||
.then(function(response:any) {
|
||||
self.videos_error = "";
|
||||
self.videos = response
|
||||
}).catch(function(response:any) {
|
||||
self.videos_error = "Can not get the List of video without season";
|
||||
self.videos = []
|
||||
console.log(`get parameter id: ${ this.idSeason}`);
|
||||
this.seasonService.getVideo(this.idSeason)
|
||||
.then((response4:any) => {
|
||||
self.videosError = '';
|
||||
self.videos = response4;
|
||||
}).catch((response5:any) => {
|
||||
self.videosError = 'Can not get the List of video without season';
|
||||
self.videos = [];
|
||||
});
|
||||
}
|
||||
|
||||
onSelectVideo(_event: any, _idSelected: number):void {
|
||||
this.arianeService.navigateVideo(_idSelected, _event.which==2, _event.ctrlKey);
|
||||
}
|
||||
|
||||
onSelectVideo(event: any, idSelected: number):void {
|
||||
this.arianeService.navigateVideo(idSelected, event.which === 2, event.ctrlKey);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
Type:
|
||||
</div>
|
||||
<div class="input">
|
||||
<select [ngModel]="type_id"
|
||||
<select [ngModel]="typeId"
|
||||
(ngModelChange)="onChangeType($event)">
|
||||
<option *ngFor="let element of listType" [ngValue]="element.value">{{element.label}}</option>
|
||||
</select>
|
||||
@ -79,7 +79,7 @@
|
||||
</div>
|
||||
<div class="request_raw">
|
||||
<div class="input">
|
||||
<div class="cover" *ngFor="let element of covers_display">
|
||||
<div class="cover" *ngFor="let element of coversDisplay">
|
||||
<div class="cover-image">
|
||||
<img src="{{element.url}}"/>
|
||||
</div>
|
||||
@ -112,7 +112,7 @@
|
||||
<i class="material-icons">data_usage</i> ID:
|
||||
</div>
|
||||
<div class="input">
|
||||
{{id_series}}
|
||||
{{idSeries}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
|
@ -28,49 +28,49 @@ export class ElementList {
|
||||
@Component({
|
||||
selector: 'app-series-edit',
|
||||
templateUrl: './series-edit.html',
|
||||
styleUrls: ['./series-edit.less'],
|
||||
animations: [fadeInAnimation],
|
||||
styleUrls: [ './series-edit.less' ],
|
||||
animations: [ fadeInAnimation ],
|
||||
host: { '[@fadeInAnimation]': '' }
|
||||
})
|
||||
|
||||
export class SeriesEditScene implements OnInit {
|
||||
id_series:number = -1;
|
||||
idSeries:number = -1;
|
||||
itemIsRemoved:boolean = false;
|
||||
itemIsNotFound:boolean = false;
|
||||
itemIsLoading:boolean = true;
|
||||
|
||||
error:string = "";
|
||||
|
||||
type_id:number = null;
|
||||
name:string = "";
|
||||
description:string = "";
|
||||
error:string = '';
|
||||
|
||||
typeId:number = null;
|
||||
name:string = '';
|
||||
description:string = '';
|
||||
coverFile:File;
|
||||
upload_file_value:string = "";
|
||||
uploadFileValue:string = '';
|
||||
selectedFiles:FileList;
|
||||
|
||||
seasonsCount:string = null;
|
||||
videoCount:string = null;
|
||||
|
||||
covers_display:Array<any> = [];
|
||||
// section tha define the upload value to display in the pop-in of upload
|
||||
|
||||
coversDisplay:Array<any> = [];
|
||||
// section tha define the upload value to display in the pop-in of upload
|
||||
public upload:UploadProgress = new UploadProgress();
|
||||
|
||||
|
||||
listType: ElementList[] = [
|
||||
{value: undefined, label: '---'},
|
||||
{ value: undefined, label: '---' },
|
||||
];
|
||||
|
||||
// --------------- confirm section ------------------
|
||||
|
||||
// --------------- confirm section ------------------
|
||||
public confirmDeleteComment:string = null;
|
||||
public confirmDeleteImageUrl:string = null;
|
||||
private deleteCoverId:number = null;
|
||||
private deleteItemId:number = null;
|
||||
deleteConfirmed() {
|
||||
if (this.deleteCoverId !== null) {
|
||||
if(this.deleteCoverId !== null) {
|
||||
this.removeCoverAfterConfirm(this.deleteCoverId);
|
||||
this.cleanConfirm();
|
||||
}
|
||||
if (this.deleteItemId !== null) {
|
||||
if(this.deleteItemId !== null) {
|
||||
this.removeItemAfterConfirm(this.deleteItemId);
|
||||
this.cleanConfirm();
|
||||
}
|
||||
@ -81,8 +81,8 @@ export class SeriesEditScene implements OnInit {
|
||||
this.deleteCoverId = null;
|
||||
this.deleteItemId = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private locate: Location,
|
||||
@ -91,182 +91,181 @@ export class SeriesEditScene implements OnInit {
|
||||
private seriesService: SeriesService,
|
||||
private arianeService: ArianeService,
|
||||
private popInService: PopInService) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
||||
this.id_series = this.arianeService.getSeriesId();
|
||||
this.idSeries = this.arianeService.getSeriesId();
|
||||
let self = this;
|
||||
this.listType = [{value: null, label: '---'}];
|
||||
this.listType = [ { value: null, label: '---' } ];
|
||||
|
||||
this.typeService.getData()
|
||||
.then(function(response2) {
|
||||
for(let iii= 0; iii < response2.length; iii++) {
|
||||
self.listType.push({value: response2[iii].id, label: response2[iii].name});
|
||||
.then((response2) => {
|
||||
for(let iii = 0; iii < response2.length; iii++) {
|
||||
self.listType.push({ value: response2[iii].id, label: response2[iii].name });
|
||||
}
|
||||
}).catch(function(response2) {
|
||||
console.log("get response22 : " + JSON.stringify(response2, null, 2));
|
||||
}).catch((response2) => {
|
||||
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
|
||||
});
|
||||
|
||||
this.seriesService.get(this.id_series)
|
||||
.then(function(response) {
|
||||
//console.log("get response of video : " + JSON.stringify(response, null, 2));
|
||||
|
||||
this.seriesService.get(this.idSeries)
|
||||
.then((response) => {
|
||||
// console.log("get response of video : " + JSON.stringify(response, null, 2));
|
||||
self.name = response.name;
|
||||
self.type_id = response.parent_id;
|
||||
self.typeId = response.parentId;
|
||||
self.description = response.description;
|
||||
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;
|
||||
}).catch(function(response) {
|
||||
self.error = "Can not get the data";
|
||||
self.name = "";
|
||||
self.description = "";
|
||||
self.covers_display = [];
|
||||
}).catch((response) => {
|
||||
self.error = 'Can not get the data';
|
||||
self.name = '';
|
||||
self.description = '';
|
||||
self.coversDisplay = [];
|
||||
self.itemIsNotFound = true;
|
||||
self.itemIsLoading = false;
|
||||
});
|
||||
console.log("get parameter id: " + this.id_series);
|
||||
this.seriesService.getSeason(this.id_series, ["id", "name"])
|
||||
.then(function(response) {
|
||||
self.seasonsCount = response.length;
|
||||
}).catch(function(response) {
|
||||
self.seasonsCount = "---";
|
||||
});
|
||||
this.seriesService.getVideo(this.id_series)
|
||||
.then(function(response) {
|
||||
self.videoCount = response.length;
|
||||
}).catch(function(response) {
|
||||
self.videoCount = "---";
|
||||
});
|
||||
console.log(`get parameter id: ${ this.idSeries}`);
|
||||
this.seriesService.getSeason(this.idSeries, [ 'id', 'name' ])
|
||||
.then((response) => {
|
||||
self.seasonsCount = response.length;
|
||||
}).catch((response) => {
|
||||
self.seasonsCount = '---';
|
||||
});
|
||||
this.seriesService.getVideo(this.idSeries)
|
||||
.then((response) => {
|
||||
self.videoCount = response.length;
|
||||
}).catch((response) => {
|
||||
self.videoCount = '---';
|
||||
});
|
||||
}
|
||||
|
||||
updateCoverList(_covers: any) {
|
||||
this.covers_display = [];
|
||||
if (_covers !== undefined && _covers !== null) {
|
||||
for (let iii=0; iii<_covers.length; iii++) {
|
||||
this.covers_display.push({
|
||||
id:_covers[iii],
|
||||
url:this.seriesService.getCoverThumbnailUrl(_covers[iii])
|
||||
});
|
||||
updateCoverList(covers: any) {
|
||||
this.coversDisplay = [];
|
||||
if(covers !== undefined && covers !== null) {
|
||||
for(let iii = 0; iii < covers.length; iii++) {
|
||||
this.coversDisplay.push({
|
||||
id:covers[iii],
|
||||
url:this.seriesService.getCoverThumbnailUrl(covers[iii])
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.covers_display = []
|
||||
this.coversDisplay = [];
|
||||
}
|
||||
}
|
||||
|
||||
onName(_value:any):void {
|
||||
this.name = _value;
|
||||
}
|
||||
|
||||
onDescription(_value:any):void {
|
||||
this.description = _value;
|
||||
}
|
||||
|
||||
onChangeType(_value:any):void {
|
||||
console.log("Change requested of type ... " + _value);
|
||||
this.type_id = _value;
|
||||
if (this.type_id == undefined) {
|
||||
this.type_id = null;
|
||||
onName(value:any):void {
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
onDescription(value:any):void {
|
||||
this.description = value;
|
||||
}
|
||||
|
||||
onChangeType(value:any):void {
|
||||
console.log(`Change requested of type ... ${ value}`);
|
||||
this.typeId = value;
|
||||
if(this.typeId === undefined) {
|
||||
this.typeId = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sendValues():void {
|
||||
console.log("send new values....");
|
||||
console.log('send new values....');
|
||||
let data = {
|
||||
"parent_id": this.type_id,
|
||||
"name": this.name,
|
||||
"description": this.description
|
||||
parentId: this.typeId,
|
||||
name: this.name,
|
||||
description: this.description
|
||||
};
|
||||
if (this.description === undefined) {
|
||||
data["description"] = null;
|
||||
if(this.description === undefined) {
|
||||
data.description = null;
|
||||
}
|
||||
this.seriesService.put(this.id_series, data);
|
||||
this.seriesService.put(this.idSeries, data);
|
||||
}
|
||||
|
||||
|
||||
// At the drag drop area
|
||||
// (drop)="onDropFile($event)"
|
||||
onDropFile(_event: DragEvent) {
|
||||
_event.preventDefault();
|
||||
//this.uploadFile(_event.dataTransfer.files[0]);
|
||||
onDropFile(event: DragEvent) {
|
||||
event.preventDefault();
|
||||
// this.uploadFile(_event.dataTransfer.files[0]);
|
||||
}
|
||||
|
||||
|
||||
// At the drag drop area
|
||||
// (dragover)="onDragOverFile($event)"
|
||||
onDragOverFile(_event) {
|
||||
_event.stopPropagation();
|
||||
_event.preventDefault();
|
||||
onDragOverFile(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
|
||||
// At the file input element
|
||||
// (change)="selectFile($event)"
|
||||
onChangeCover(_value:any):void {
|
||||
this.selectedFiles = _value.files
|
||||
onChangeCover(value:any):void {
|
||||
this.selectedFiles = value.files;
|
||||
this.coverFile = this.selectedFiles[0];
|
||||
console.log("select file " + this.coverFile.name);
|
||||
console.log(`select file ${ this.coverFile.name}`);
|
||||
this.uploadCover(this.coverFile);
|
||||
}
|
||||
|
||||
uploadCover(_file:File) {
|
||||
if (_file == undefined) {
|
||||
console.log("No file selected!");
|
||||
|
||||
uploadCover(file:File) {
|
||||
if(file === undefined) {
|
||||
console.log('No file selected!');
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
// clean upload labels
|
||||
this.upload.clear();
|
||||
// display the upload pop-in
|
||||
this.popInService.open("popin-upload-progress");
|
||||
this.seriesService.uploadCover(_file, this.id_series, function(count, total) {
|
||||
this.popInService.open('popin-upload-progress');
|
||||
this.seriesService.uploadCover(file, this.idSeries, (count, total) => {
|
||||
self.upload.mediaSendSize = count;
|
||||
self.upload.mediaSize = total;
|
||||
})
|
||||
.then(function (response:any) {
|
||||
self.upload.result = "Cover added done";
|
||||
// TODO: we retrive the whiole media ==> update data ...
|
||||
.then((response:any) => {
|
||||
self.upload.result = 'Cover added done';
|
||||
// we retrive the whiole media ==> update data ...
|
||||
self.updateCoverList(response.covers);
|
||||
}).catch(function (response:any) {
|
||||
//self.error = "Can not get the data";
|
||||
console.log("Can not add the cover in the video...");
|
||||
}).catch((response:any) => {
|
||||
// self.error = "Can not get the data";
|
||||
console.log('Can not add the cover in the video...');
|
||||
});
|
||||
}
|
||||
removeCover(_id:number) {
|
||||
removeCover(id:number) {
|
||||
this.cleanConfirm();
|
||||
this.confirmDeleteComment = "Delete the cover ID: " + _id;
|
||||
this.confirmDeleteImageUrl = this.seriesService.getCoverThumbnailUrl(_id);
|
||||
this.deleteCoverId = _id;
|
||||
this.popInService.open("popin-delete-confirm");
|
||||
this.confirmDeleteComment = `Delete the cover ID: ${ id}`;
|
||||
this.confirmDeleteImageUrl = this.seriesService.getCoverThumbnailUrl(id);
|
||||
this.deleteCoverId = id;
|
||||
this.popInService.open('popin-delete-confirm');
|
||||
}
|
||||
removeCoverAfterConfirm(_id:number) {
|
||||
console.log("Request remove cover: " + _id);
|
||||
removeCoverAfterConfirm(id:number) {
|
||||
console.log(`Request remove cover: ${ id}`);
|
||||
let self = this;
|
||||
this.seriesService.deleteCover(this.id_series, _id)
|
||||
.then(function (response:any) {
|
||||
self.upload.result = "Cover remove done";
|
||||
// TODO: we retrive the whiole media ==> update data ...
|
||||
this.seriesService.deleteCover(this.idSeries, id)
|
||||
.then((response:any) => {
|
||||
self.upload.result = 'Cover remove done';
|
||||
// we retrive the whiole media ==> update data ...
|
||||
self.updateCoverList(response.covers);
|
||||
}).catch(function (response:any) {
|
||||
//self.error = "Can not get the data";
|
||||
console.log("Can not remove the cover of the video...");
|
||||
}).catch((response:any) => {
|
||||
// self.error = "Can not get the data";
|
||||
console.log('Can not remove the cover of the video...');
|
||||
});
|
||||
}
|
||||
removeItem() {
|
||||
console.log("Request remove Media...");
|
||||
console.log('Request remove Media...');
|
||||
this.cleanConfirm();
|
||||
this.confirmDeleteComment = "Delete the Series: " + this.id_series;
|
||||
this.deleteItemId = this.id_series;
|
||||
this.popInService.open("popin-delete-confirm");
|
||||
this.confirmDeleteComment = `Delete the Series: ${ this.idSeries}`;
|
||||
this.deleteItemId = this.idSeries;
|
||||
this.popInService.open('popin-delete-confirm');
|
||||
}
|
||||
removeItemAfterConfirm(_id:number) {
|
||||
let self = this;
|
||||
this.seriesService.delete(_id)
|
||||
.then(function(response3) {
|
||||
//self.data_ori = tmpp;
|
||||
//self.updateNeedSend();
|
||||
.then((response3) => {
|
||||
// self.data_ori = tmpp;
|
||||
// self.updateNeedSend();
|
||||
self.itemIsRemoved = true;
|
||||
}).catch(function(response3) {
|
||||
//self.updateNeedSend();
|
||||
}).catch((response3) => {
|
||||
// self.updateNeedSend();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
<div class="title" *ngIf="seasons.length > 1">Seasons:</div>
|
||||
<div class="title" *ngIf="seasons.length == 1">Season:</div>
|
||||
<div *ngFor="let data of seasons" class="item-list" (click)="onSelectSeason($event, data.id)" (auxclick)="onSelectSeason($event, data.id)">
|
||||
<app-element-season [id_season]="data.id"></app-element-season>
|
||||
<app-element-season [idSeason]="data.id"></app-element-season>
|
||||
</div>
|
||||
</div>
|
||||
<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">Video:</div>
|
||||
<div *ngFor="let data of videos" class="item item-video" (click)="onSelectVideo($event, data.id)" (auxclick)="onSelectVideo($event, data.id)">
|
||||
<app-element-video [id_video]="data.id"></app-element-video>
|
||||
<app-element-video [idVideo]="data.id"></app-element-video>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
|
@ -5,8 +5,7 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { Location } from '@angular/common';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { fadeInAnimation } from '../../_animations/index';
|
||||
|
||||
import { SeriesService } from '../../service/series';
|
||||
@ -15,110 +14,107 @@ import { ArianeService } from '../../service/ariane';
|
||||
@Component({
|
||||
selector: 'app-series',
|
||||
templateUrl: './series.html',
|
||||
styleUrls: ['./series.less'],
|
||||
animations: [fadeInAnimation],
|
||||
styleUrls: [ './series.less' ],
|
||||
animations: [ fadeInAnimation ],
|
||||
host: { '[@fadeInAnimation]': '' }
|
||||
})
|
||||
|
||||
export class SeriesScene implements OnInit {
|
||||
id_series = -1;
|
||||
name: string = "";
|
||||
description: string = "";
|
||||
cover: string = ""
|
||||
covers: Array<string> = []
|
||||
seasons_error: string = "";
|
||||
idSeries = -1;
|
||||
name: string = '';
|
||||
description: string = '';
|
||||
cover: string = '';
|
||||
covers: Array<string> = [];
|
||||
seasonsError: string = '';
|
||||
seasons: Array<any> = [];
|
||||
videos_error: string = "";
|
||||
videosError: string = '';
|
||||
videos: Array<any> = [];
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private locate: Location,
|
||||
private seriesService: SeriesService,
|
||||
private arianeService: ArianeService) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
||||
//this.id_universe = parseInt(this.route.snapshot.paramMap.get('univers_id'));
|
||||
//this.id_type = parseInt(this.route.snapshot.paramMap.get('type_id'));
|
||||
this.id_series = this.arianeService.getSeriesId();
|
||||
// this.idUniverse = parseInt(this.route.snapshot.paramMap.get('universId'));
|
||||
// this.idType = parseInt(this.route.snapshot.paramMap.get('typeId'));
|
||||
this.idSeries = this.arianeService.getSeriesId();
|
||||
let self = this;
|
||||
let update_ended = {
|
||||
series_metadata: false,
|
||||
sub_saison: false,
|
||||
sub_video: false,
|
||||
}
|
||||
this.seriesService.get(this.id_series)
|
||||
.then(function(response) {
|
||||
let updateEnded = {
|
||||
seriesMetadata: false,
|
||||
subSaison: false,
|
||||
subVideo: false,
|
||||
};
|
||||
this.seriesService.get(this.idSeries)
|
||||
.then((response) => {
|
||||
self.name = response.name;
|
||||
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.covers = [];
|
||||
} else {
|
||||
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]));
|
||||
}
|
||||
}
|
||||
update_ended.series_metadata = true;
|
||||
self.checkIfJumpIsNeeded(update_ended);
|
||||
}).catch(function(response) {
|
||||
self.description = "";
|
||||
self.name = "???";
|
||||
updateEnded.seriesMetadata = true;
|
||||
self.checkIfJumpIsNeeded(updateEnded);
|
||||
}).catch((response) => {
|
||||
self.description = '';
|
||||
self.name = '???';
|
||||
self.cover = null;
|
||||
self.covers = [];
|
||||
// no check just ==> an error occured on season
|
||||
});
|
||||
console.log("get parameter id: " + this.id_series);
|
||||
this.seriesService.getSeason(this.id_series, ["id", "name"])
|
||||
.then(function(response) {
|
||||
self.seasons_error = "";
|
||||
self.seasons = response
|
||||
update_ended.sub_saison = true;
|
||||
self.checkIfJumpIsNeeded(update_ended);
|
||||
}).catch(function(response) {
|
||||
self.seasons_error = "Can not get the list of season in this series";
|
||||
self.seasons = []
|
||||
update_ended.sub_saison = true;
|
||||
self.checkIfJumpIsNeeded(update_ended);
|
||||
console.log(`get parameter id: ${ this.idSeries}`);
|
||||
this.seriesService.getSeason(this.idSeries, [ 'id', 'name' ])
|
||||
.then((response) => {
|
||||
self.seasonsError = '';
|
||||
self.seasons = response;
|
||||
updateEnded.subSaison = true;
|
||||
self.checkIfJumpIsNeeded(updateEnded);
|
||||
}).catch((response) => {
|
||||
self.seasonsError = 'Can not get the list of season in this series';
|
||||
self.seasons = [];
|
||||
updateEnded.subSaison = true;
|
||||
self.checkIfJumpIsNeeded(updateEnded);
|
||||
});
|
||||
this.seriesService.getVideo(this.id_series)
|
||||
.then(function(response) {
|
||||
self.videos_error = "";
|
||||
self.videos = response
|
||||
update_ended.sub_video = true;
|
||||
self.checkIfJumpIsNeeded(update_ended);
|
||||
}).catch(function(response) {
|
||||
self.videos_error = "Can not get the List of video without season";
|
||||
self.videos = []
|
||||
update_ended.sub_video = true;
|
||||
self.checkIfJumpIsNeeded(update_ended);
|
||||
this.seriesService.getVideo(this.idSeries)
|
||||
.then((response) => {
|
||||
self.videosError = '';
|
||||
self.videos = response;
|
||||
updateEnded.subVideo = true;
|
||||
self.checkIfJumpIsNeeded(updateEnded);
|
||||
}).catch((response) => {
|
||||
self.videosError = 'Can not get the List of video without season';
|
||||
self.videos = [];
|
||||
updateEnded.subVideo = true;
|
||||
self.checkIfJumpIsNeeded(updateEnded);
|
||||
});
|
||||
}
|
||||
onSelectSeason(_event: any, _idSelected: number):void {
|
||||
this.arianeService.navigateSeason(_idSelected, _event.which==2, _event.ctrlKey);
|
||||
onSelectSeason(event: any, idSelected: number):void {
|
||||
this.arianeService.navigateSeason(idSelected, event.which === 2, event.ctrlKey);
|
||||
}
|
||||
|
||||
onSelectVideo(_event: any, _idSelected: number):void {
|
||||
this.arianeService.navigateVideo(_idSelected, _event.which==2, _event.ctrlKey);
|
||||
|
||||
onSelectVideo(event: any, idSelected: number):void {
|
||||
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
|
||||
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;
|
||||
}
|
||||
// no local video
|
||||
if (this.videos.length > 0) {
|
||||
if(this.videos.length > 0) {
|
||||
return;
|
||||
}
|
||||
// only one season:
|
||||
if (this.seasons.length !== 1) {
|
||||
if(this.seasons.length !== 1) {
|
||||
return;
|
||||
}
|
||||
this.arianeService.navigateSeason(this.seasons[0].id, false, false, true);
|
||||
this.arianeService.navigateSeason(this.seasons[0].id, false, false, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -9,17 +9,15 @@ import { ActivatedRoute } from '@angular/router';
|
||||
import { ArianeService } from '../../service/ariane';
|
||||
|
||||
@Component({
|
||||
selector: 'app-settings',
|
||||
templateUrl: './settings.html',
|
||||
styleUrls: ['./settings.less']
|
||||
selector: 'app-settings',
|
||||
templateUrl: './settings.html',
|
||||
styleUrls: [ './settings.less' ]
|
||||
})
|
||||
export class SettingsScene implements OnInit {
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private arianeService: ArianeService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
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 { fadeInAnimation } from '../../_animations/index';
|
||||
import { UserService } from '../../service/user';
|
||||
@ -15,225 +15,220 @@ import { ArianeService } from '../../service/ariane';
|
||||
@Component({
|
||||
selector: 'app-sign-up',
|
||||
templateUrl: './sign-up.html',
|
||||
styleUrls: ['./sign-up.less'],
|
||||
animations: [fadeInAnimation],
|
||||
styleUrls: [ './sign-up.less' ],
|
||||
animations: [ fadeInAnimation ],
|
||||
host: { '[@fadeInAnimation]': '' }
|
||||
})
|
||||
|
||||
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";
|
||||
private signUp_iconWait:string = "icon-right-load";
|
||||
private signUp_iconRight:string = "icon-right-validate";
|
||||
|
||||
public login:string = "";
|
||||
public login:string = '';
|
||||
public loginOK:boolean = false;
|
||||
public loginHelp:string = "";
|
||||
public loginIcon:string = "";
|
||||
|
||||
public email:string = "";
|
||||
public loginHelp:string = '';
|
||||
public loginIcon:string = '';
|
||||
|
||||
public email:string = '';
|
||||
public emailOK:boolean = false;
|
||||
public emailHelp:string = "";
|
||||
public emailIcon:string = "";
|
||||
|
||||
public password:string = "";
|
||||
public emailHelp:string = '';
|
||||
public emailIcon:string = '';
|
||||
|
||||
public password:string = '';
|
||||
public passOK:boolean = false;
|
||||
public passHelp:string = "";
|
||||
public passIcon:string = "";
|
||||
|
||||
public passHelp:string = '';
|
||||
public passIcon:string = '';
|
||||
|
||||
public signUpButtonDisabled:boolean = true;
|
||||
public error:string = "";
|
||||
|
||||
public error:string = '';
|
||||
|
||||
public rememberMe:boolean = true;
|
||||
|
||||
|
||||
|
||||
|
||||
constructor(private userService: UserService,
|
||||
private router: Router,
|
||||
private route: ActivatedRoute,
|
||||
private arianeService: ArianeService) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
updateButtonVisibility():void {
|
||||
if ( this.loginOK == true
|
||||
&& this.passOK == true
|
||||
&& this.emailOK == true) {
|
||||
if(this.loginOK === true &&
|
||||
this.passOK === true &&
|
||||
this.emailOK === true) {
|
||||
this.signUpButtonDisabled = false;
|
||||
} else {
|
||||
this.signUpButtonDisabled = true;
|
||||
}
|
||||
this.error = "";
|
||||
this.error = '';
|
||||
}
|
||||
checkLogin(_newValue:string):void {
|
||||
//this.userService.loginSha("loooogin", "ekljkj", true);
|
||||
this.login = _newValue;
|
||||
if ( this.login == null
|
||||
|| this.login.length == 0) {
|
||||
checkLogin(newValue:string):void {
|
||||
// this.userService.loginSha("loooogin", "ekljkj", true);
|
||||
this.login = newValue;
|
||||
if(this.login === null ||
|
||||
this.login.length === 0) {
|
||||
this.loginOK = false;
|
||||
this.loginIcon = "";
|
||||
this.loginHelp = "";
|
||||
this.loginIcon = '';
|
||||
this.loginHelp = '';
|
||||
this.updateButtonVisibility();
|
||||
return;
|
||||
}
|
||||
if (this.login.length < 6) {
|
||||
if(this.login.length < 6) {
|
||||
this.loginOK = false;
|
||||
this.loginHelp = "Need 6 characters";
|
||||
this.loginIcon = "";
|
||||
this.loginHelp = 'Need 6 characters';
|
||||
this.loginIcon = '';
|
||||
this.updateButtonVisibility();
|
||||
return;
|
||||
}
|
||||
if (checkLoginValidity(this.login) == true) {
|
||||
if(checkLoginValidity(this.login) === true) {
|
||||
this.loginOK = false;
|
||||
//this.loginHelp = "check in progress...";
|
||||
this.loginIcon = this.signUp_iconWait;
|
||||
// this.loginHelp = "check in progress...";
|
||||
this.loginIcon = this.signUpIconWait;
|
||||
let self = this;
|
||||
this.userService.checkLogin(this.login).then(function() {
|
||||
// check if the answer is correct with the question
|
||||
if (_newValue != self.login) {
|
||||
return;
|
||||
}
|
||||
// the login exist ... ==> it is found...
|
||||
self.loginOK = false;
|
||||
self.loginHelp = "Login already used ...";
|
||||
self.loginIcon = self.signUp_iconWrong;
|
||||
this.userService.checkLogin(this.login).then(() => {
|
||||
// check if the answer is correct with the question
|
||||
if(newValue !== self.login) {
|
||||
return;
|
||||
}
|
||||
// the login exist ... ==> it is found...
|
||||
self.loginOK = false;
|
||||
self.loginHelp = 'Login already used ...';
|
||||
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();
|
||||
}, function(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.signUp_iconRight;
|
||||
self.updateButtonVisibility();
|
||||
return;
|
||||
}
|
||||
console.log("Status " + error);
|
||||
self.loginOK = false;
|
||||
self.loginHelp = "Login already used ...";
|
||||
self.loginIcon = self.signUp_iconWrong;
|
||||
self.updateButtonVisibility();
|
||||
});
|
||||
return;
|
||||
}
|
||||
console.log(`Status ${ error}`);
|
||||
self.loginOK = false;
|
||||
self.loginHelp = 'Login already used ...';
|
||||
self.loginIcon = self.signUpIconWrong;
|
||||
self.updateButtonVisibility();
|
||||
});
|
||||
} else {
|
||||
this.loginOK = false;
|
||||
this.loginHelp = 'Not valid: characters, numbers and "_-."';
|
||||
}
|
||||
this.updateButtonVisibility();
|
||||
}
|
||||
|
||||
checkEmail(_newValue:string):void {
|
||||
this.email = _newValue
|
||||
if ( this.email == null
|
||||
|| this.email.length == 0) {
|
||||
|
||||
checkEmail(newValue:string):void {
|
||||
this.email = newValue;
|
||||
if(this.email === null ||
|
||||
this.email.length === 0) {
|
||||
this.emailOK = false;
|
||||
this.updateButtonVisibility();
|
||||
this.emailIcon = "";
|
||||
this.emailHelp = "";
|
||||
this.emailIcon = '';
|
||||
this.emailHelp = '';
|
||||
return;
|
||||
}
|
||||
if (this.email.length < 6) {
|
||||
if(this.email.length < 6) {
|
||||
this.emailOK = false;
|
||||
this.emailHelp = "Need 6 characters";
|
||||
this.emailHelp = 'Need 6 characters';
|
||||
this.updateButtonVisibility();
|
||||
this.passIcon = "";
|
||||
this.passIcon = '';
|
||||
return;
|
||||
}
|
||||
if (checkEmailValidity(this.email) == true) {
|
||||
if(checkEmailValidity(this.email) === true) {
|
||||
this.emailOK = false;
|
||||
this.emailHelp = "";
|
||||
//this.loginHelp = "check in progress...";
|
||||
this.emailIcon = this.signUp_iconWait;
|
||||
this.emailHelp = '';
|
||||
// this.loginHelp = "check in progress...";
|
||||
this.emailIcon = this.signUpIconWait;
|
||||
let self = this;
|
||||
this.userService.checkEMail(this.email).then(function() {
|
||||
// check if the answer is correct with the question
|
||||
if (_newValue != self.email) {
|
||||
return;
|
||||
}
|
||||
// the email exist ... ==> it is found...
|
||||
self.emailOK = false;
|
||||
self.emailHelp = "email already used ...";
|
||||
self.emailIcon = self.signUp_iconWrong;
|
||||
this.userService.checkEMail(this.email).then(() => {
|
||||
// check if the answer is correct with the question
|
||||
if(newValue !== self.email) {
|
||||
return;
|
||||
}
|
||||
// the email exist ... ==> it is found...
|
||||
self.emailOK = false;
|
||||
self.emailHelp = 'email already used ...';
|
||||
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();
|
||||
}, function(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.signUp_iconRight;
|
||||
self.updateButtonVisibility();
|
||||
return;
|
||||
}
|
||||
console.log("Status " + error);
|
||||
self.emailOK = false;
|
||||
self.emailHelp = "email already used ...";
|
||||
self.emailIcon = self.signUp_iconWrong;
|
||||
self.updateButtonVisibility();
|
||||
});
|
||||
return;
|
||||
}
|
||||
console.log(`Status ${ error}`);
|
||||
self.emailOK = false;
|
||||
self.emailHelp = 'email already used ...';
|
||||
self.emailIcon = self.signUpIconWrong;
|
||||
self.updateButtonVisibility();
|
||||
});
|
||||
} else {
|
||||
this.emailOK = false;
|
||||
this.emailHelp = 'Not valid: characters, numbers, "_-." and email format: you@example.com';
|
||||
}
|
||||
this.updateButtonVisibility();
|
||||
}
|
||||
|
||||
checkPassword(_newValue:string):void {
|
||||
this.password = _newValue
|
||||
console.log("ooooooooooooooo " + this.password);
|
||||
if (this.password == null) {
|
||||
|
||||
checkPassword(newValue:string):void {
|
||||
this.password = newValue;
|
||||
console.log(`ooooooooooooooo ${ this.password}`);
|
||||
if(this.password === null) {
|
||||
this.passOK = false;
|
||||
this.passHelp = "";
|
||||
this.passHelp = '';
|
||||
this.updateButtonVisibility();
|
||||
return;
|
||||
}
|
||||
if (this.password.length < 6) {
|
||||
if(this.password.length < 6) {
|
||||
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 {
|
||||
if (checkPasswordValidity(this.password) == true) {
|
||||
this.passOK = true;
|
||||
this.passHelp = "";
|
||||
} else {
|
||||
this.passOK = false;
|
||||
this.passHelp = 'Not valid: characters, numbers and "_-:;.,?!*+=}{([|)]% @&~#/\<>"';
|
||||
}
|
||||
this.passOK = false;
|
||||
this.passHelp = 'Not valid: characters, numbers and "_-:;.,?!*+=}{([|)]% @&~#/\\<>"';
|
||||
}
|
||||
this.updateButtonVisibility();
|
||||
}
|
||||
onSignUp():void {
|
||||
console.log("Validate ... ");
|
||||
if (this.signUpButtonDisabled == true) {
|
||||
// TODO: ... notify user ...
|
||||
console.log("Not permited action ... ==> control does not validate this action ...");
|
||||
console.log('Validate ... ');
|
||||
if(this.signUpButtonDisabled === true) {
|
||||
// ... notify user ...
|
||||
console.log('Not permited action ... ==> control does not validate this action ...');
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
// disable the currect button
|
||||
this.signUpButtonDisabled = true;
|
||||
this.userService.create(this.login, this.email, this.password).then(
|
||||
function(value) {
|
||||
console.log("User created");
|
||||
self.router.navigate(['login']);
|
||||
//TODO : send a generic message in the pop-up enevts... self.emailHelp = "email already used ... (error 2)";
|
||||
}, function(value) {
|
||||
console.log("User NOT created");
|
||||
//TODO : send a generic message in the pop-up enevts... self.emailHelp = "email already used ... (error 2)";
|
||||
(value) => {
|
||||
console.log('User created');
|
||||
self.router.navigate([ 'login' ]);
|
||||
// send a generic message in the pop-up enevts... self.emailHelp = "email already used ... (error 2)";
|
||||
}, (value) => {
|
||||
console.log('User NOT created');
|
||||
// send a generic message in the pop-up enevts... self.emailHelp = "email already used ... (error 2)";
|
||||
});
|
||||
}
|
||||
onCancel():void {
|
||||
console.log("onCancel ... '" + this.login + "':'" + this.password + "'");
|
||||
//$rootScope.currentModal = "";
|
||||
console.log(`onCancel ... '${ this.login }':'${ this.password }'`);
|
||||
// $rootScope.currentModal = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -17,13 +17,13 @@
|
||||
<div class="fill-content colomn_mutiple">
|
||||
<div class="clear"></div>
|
||||
<div *ngFor="let data of seriess" class="item" (click)="onSelectSeries($event, data.id)" (auxclick)="onSelectSeries($event, data.id)">
|
||||
<app-element-series [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 class="fill-content colomn_mutiple">
|
||||
<div class="clear"></div>
|
||||
<div *ngFor="let data of videos" class="item item-video" (click)="onSelectVideo($event, data.id)" (auxclick)="onSelectVideo($event, data.id)">
|
||||
<app-element-video [id_video]="data.id"></app-element-video>
|
||||
<app-element-video [idVideo]="data.id"></app-element-video>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
|
@ -5,8 +5,7 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { Location } from '@angular/common';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { fadeInAnimation } from '../../_animations/index';
|
||||
|
||||
import { TypeService } from '../../service/type';
|
||||
@ -15,26 +14,25 @@ import { ArianeService } from '../../service/ariane';
|
||||
@Component({
|
||||
selector: 'app-type',
|
||||
templateUrl: './type.html',
|
||||
styleUrls: ['./type.less'],
|
||||
animations: [fadeInAnimation],
|
||||
styleUrls: [ './type.less' ],
|
||||
animations: [ fadeInAnimation ],
|
||||
host: { '[@fadeInAnimation]': '' }
|
||||
})
|
||||
|
||||
export class TypeScene implements OnInit {
|
||||
type_id = -1;
|
||||
name: string = "";
|
||||
description: string = "";
|
||||
typeId = -1;
|
||||
name: string = '';
|
||||
description: string = '';
|
||||
cover:string = null;
|
||||
covers:string[] = [];
|
||||
seriess_error = "";
|
||||
seriessError = '';
|
||||
seriess = [];
|
||||
videos_error = "";
|
||||
videosError = '';
|
||||
videos = [];
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private locate: Location,
|
||||
private typeService: TypeService,
|
||||
private arianeService: ArianeService) {
|
||||
|
||||
/*
|
||||
this.route.params.subscribe(params => {
|
||||
console.log(params);
|
||||
@ -44,55 +42,54 @@ export class TypeScene implements OnInit {
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
||||
this.type_id = this.arianeService.getTypeId();
|
||||
this.typeId = this.arianeService.getTypeId();
|
||||
let self = this;
|
||||
console.log("get parameter id: " + this.type_id);
|
||||
this.typeService.get(this.type_id)
|
||||
.then(function(response) {
|
||||
console.log(`get parameter id: ${ this.typeId}`);
|
||||
this.typeService.get(this.typeId)
|
||||
.then((response) => {
|
||||
self.name = response.name;
|
||||
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.covers = []
|
||||
self.covers = [];
|
||||
} else {
|
||||
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]));
|
||||
}
|
||||
}
|
||||
}).catch(function(response) {
|
||||
self.name = "???";
|
||||
self.description = "";
|
||||
}).catch((response) => {
|
||||
self.name = '???';
|
||||
self.description = '';
|
||||
self.covers = [];
|
||||
self.cover = null;
|
||||
});
|
||||
this.typeService.getSubSeries(this.type_id, ["id", "name"])
|
||||
.then(function(response) {
|
||||
self.seriess_error = "";
|
||||
self.seriess = response
|
||||
}).catch(function(response) {
|
||||
self.seriess_error = "Wrong e-mail/login or password";
|
||||
self.seriess = []
|
||||
this.typeService.getSubSeries(this.typeId, [ 'id', 'name' ])
|
||||
.then((response) => {
|
||||
self.seriessError = '';
|
||||
self.seriess = response;
|
||||
}).catch((response) => {
|
||||
self.seriessError = 'Wrong e-mail/login or password';
|
||||
self.seriess = [];
|
||||
});
|
||||
this.typeService.getSubVideo(this.type_id, ["id", "name"])
|
||||
.then(function(response) {
|
||||
self.videos_error = "";
|
||||
self.videos = response
|
||||
}).catch(function(response) {
|
||||
self.videos_error = "Wrong e-mail/login or password";
|
||||
self.videos = []
|
||||
this.typeService.getSubVideo(this.typeId, [ 'id', 'name' ])
|
||||
.then((response) => {
|
||||
self.videosError = '';
|
||||
self.videos = response;
|
||||
}).catch((response) => {
|
||||
self.videosError = 'Wrong e-mail/login or password';
|
||||
self.videos = [];
|
||||
});
|
||||
}
|
||||
onSelectSeries(_event: any, _idSelected: number):void {
|
||||
this.arianeService.navigateSeries(_idSelected, _event.which==2, _event.ctrlKey);
|
||||
}
|
||||
|
||||
onSelectVideo(_event: any, _idSelected: number):void {
|
||||
this.arianeService.navigateVideo(_idSelected, _event.which==2, _event.ctrlKey);
|
||||
onSelectSeries(event: any, idSelected: number):void {
|
||||
this.arianeService.navigateSeries(idSelected, event.which === 2, event.ctrlKey);
|
||||
}
|
||||
|
||||
onSelectVideo(event: any, idSelected: number):void {
|
||||
this.arianeService.navigateVideo(idSelected, event.which === 2, event.ctrlKey);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<div class="generic-page">
|
||||
<div class="fill-all colomn_mutiple">
|
||||
<div *ngFor="let data of videos" class="item item-video" (click)="onSelectVideo($event, data)" (auxclick)="onSelectVideo($event, data)">
|
||||
<app-element-video [id_video]="data"></app-element-video>
|
||||
<app-element-video [idVideo]="data"></app-element-video>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
@ -6,62 +6,57 @@
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { Location } from '@angular/common';
|
||||
|
||||
import { fadeInAnimation } from '../../_animations/index';
|
||||
|
||||
import { UniverseService } from '../../service/universe';
|
||||
import { ArianeService } from '../../service/ariane';
|
||||
|
||||
import { environment } from '../../../environments/environment';
|
||||
|
||||
@Component({
|
||||
selector: 'app-universe',
|
||||
templateUrl: './universe.html',
|
||||
styleUrls: ['./universe.less'],
|
||||
animations: [fadeInAnimation],
|
||||
styleUrls: [ './universe.less' ],
|
||||
animations: [ fadeInAnimation ],
|
||||
host: { '[@fadeInAnimation]': '' }
|
||||
})
|
||||
|
||||
export class UniverseScene implements OnInit {
|
||||
universe_id = -1;
|
||||
videos_error = "";
|
||||
universeId = -1;
|
||||
videosError = '';
|
||||
videos = [];
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private locate: Location,
|
||||
private universeService: UniverseService,
|
||||
private arianeService: ArianeService) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
||||
this.universe_id = this.arianeService.getUniverseId();
|
||||
let self = this;
|
||||
console.log("get parameter id: " + this.universe_id);
|
||||
this.universeId = this.arianeService.getUniverseId();
|
||||
console.log(`get parameter id: ${ this.universeId}`);
|
||||
|
||||
/*
|
||||
this.universeService.getVideo(this.univers_id)
|
||||
let self = this;
|
||||
this.universeService.getVideo(this.universId)
|
||||
.then(function(response) {
|
||||
self.videos_error = "";
|
||||
self.videosError = "";
|
||||
self.videos = 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 = []
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
onSelectVideo(_event: any, _idSelected: number):void {
|
||||
if(_event.which==2) {
|
||||
if (environment.frontBaseUrl === undefined || environment.frontBaseUrl === null || environment.frontBaseUrl === "") {
|
||||
window.open('/video/' + _idSelected);
|
||||
|
||||
onSelectVideo(event: any, idSelected: number):void {
|
||||
if(event.which === 2) {
|
||||
if(environment.frontBaseUrl === undefined || environment.frontBaseUrl === null || environment.frontBaseUrl === '') {
|
||||
window.open(`/video/${ idSelected}`);
|
||||
} else {
|
||||
window.open("/" + environment.frontBaseUrl + '/video/' + _idSelected);
|
||||
window.open(`/${ environment.frontBaseUrl }/video/${ idSelected}`);
|
||||
}
|
||||
} else {
|
||||
this.router.navigate(['video/' + _idSelected ]);
|
||||
this.arianeService.setVideo(_idSelected);
|
||||
this.router.navigate([ `video/${ idSelected}` ]);
|
||||
this.arianeService.setVideo(idSelected);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -157,7 +157,7 @@
|
||||
<div class="clear"></div>
|
||||
<div class="send_value">
|
||||
<button class="button fill-x color-button-validate color-shadow-black"
|
||||
[disabled]="!need_send"
|
||||
[disabled]="!needSend"
|
||||
(click)="sendFile()"
|
||||
type="submit">
|
||||
<i class="material-icons">cloud_upload</i> Upload
|
||||
|
@ -36,39 +36,39 @@ export class FileParsedElement {
|
||||
public season: number,
|
||||
public episode: number,
|
||||
public title: string) {
|
||||
// nothiing to do.
|
||||
// nothiing to do.
|
||||
}
|
||||
}
|
||||
export class FileFailParsedElement {
|
||||
constructor(
|
||||
public file: File,
|
||||
public reason: string) {
|
||||
// nothiing to do.
|
||||
// nothiing to do.
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-video-edit',
|
||||
templateUrl: './upload.html',
|
||||
styleUrls: ['./upload.less'],
|
||||
animations: [fadeInAnimation],
|
||||
styleUrls: [ './upload.less' ],
|
||||
animations: [ fadeInAnimation ],
|
||||
host: { '[@fadeInAnimation]': '' }
|
||||
})
|
||||
|
||||
export class UploadScene implements OnInit {
|
||||
parsedElement: FileParsedElement[] = [];
|
||||
parsedFailedElement: FileFailParsedElement[] = [];
|
||||
upload_file_value: string = ""
|
||||
uploadFileValue: string = '';
|
||||
selectedFiles: FileList;
|
||||
type_id: number = null
|
||||
series_id: number = null
|
||||
saison_id: number = null
|
||||
need_send: boolean = false;
|
||||
typeId: number = null;
|
||||
seriesId: number = null;
|
||||
saisonId: number = null;
|
||||
needSend: boolean = false;
|
||||
|
||||
// list of all files already registered in the bdd to compare with the curent list of files.
|
||||
listFileInBdd: any = null;
|
||||
|
||||
// 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();
|
||||
|
||||
listType: ElementList[] = [
|
||||
@ -80,7 +80,8 @@ export class UploadScene implements OnInit {
|
||||
listSeries: ElementList[] = [
|
||||
{ value: null, label: '---' },
|
||||
];
|
||||
listSeries2 = [{ id: null, description: '---' }];
|
||||
listSeries2 = [ { id: null, description: '---' } ];
|
||||
|
||||
/*
|
||||
config = {
|
||||
displayKey: "label", // if objects array passed which key to be displayed defaults to description
|
||||
@ -89,23 +90,23 @@ export class UploadScene implements OnInit {
|
||||
};
|
||||
*/
|
||||
config = {
|
||||
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,
|
||||
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
|
||||
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,
|
||||
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,
|
||||
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)
|
||||
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
|
||||
searchPlaceholder: 'Search', // label thats displayed in search input,
|
||||
searchOnKey: 'description', // key on which search should be performed this will be selective search. if undefined this will be extensive search on all keys
|
||||
}
|
||||
};
|
||||
listSeason: ElementList[] = [
|
||||
{ value: null, label: '---' },
|
||||
];
|
||||
global_universe: string = "";
|
||||
global_series: string = "";
|
||||
global_season: number = null;
|
||||
globalUniverse: string = '';
|
||||
globalSeries: string = '';
|
||||
globalSeason: number = null;
|
||||
constructor(private route: ActivatedRoute,
|
||||
private typeService: TypeService,
|
||||
private universeService: UniverseService,
|
||||
@ -117,86 +118,84 @@ export class UploadScene implements OnInit {
|
||||
// nothing to do.
|
||||
}
|
||||
|
||||
updateNeedSend (): boolean {
|
||||
if (this.parsedElement.length === 0) {
|
||||
this.need_send = false;
|
||||
updateNeedSend(): boolean {
|
||||
if(this.parsedElement.length === 0) {
|
||||
this.needSend = false;
|
||||
return;
|
||||
}
|
||||
this.need_send = true;
|
||||
for (let iii = 0; iii< this.parsedElement.length; iii++) {
|
||||
if (this.parsedElement[iii].title === undefined || this.parsedElement[iii].title === null || this.parsedElement[iii].title === "") {
|
||||
this.need_send = false;
|
||||
this.needSend = true;
|
||||
for(let iii = 0; iii < this.parsedElement.length; iii++) {
|
||||
if(this.parsedElement[iii].title === undefined || this.parsedElement[iii].title === null || this.parsedElement[iii].title === '') {
|
||||
this.needSend = false;
|
||||
}
|
||||
}
|
||||
if (this.type_id === undefined || this.type_id === null) {
|
||||
this.need_send = false;
|
||||
if(this.typeId === undefined || this.typeId === null) {
|
||||
this.needSend = false;
|
||||
}
|
||||
return this.need_send;
|
||||
return this.needSend;
|
||||
}
|
||||
|
||||
ngOnInit () {
|
||||
ngOnInit() {
|
||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
||||
let self = this;
|
||||
this.listType = [{ value: null, label: '---' }];
|
||||
this.listUniverse = [{ value: null, label: '---' }];
|
||||
this.listSeries = [{ value: null, label: '---' }];
|
||||
this.listSeason = [{ value: null, label: '---' }];
|
||||
this.listType = [ { value: null, label: '---' } ];
|
||||
this.listUniverse = [ { value: null, label: '---' } ];
|
||||
this.listSeries = [ { value: null, label: '---' } ];
|
||||
this.listSeason = [ { value: null, label: '---' } ];
|
||||
this.universeService.getData()
|
||||
.then(function (response2) {
|
||||
for (let iii = 0; iii < response2.length; iii++) {
|
||||
.then((response2) => {
|
||||
for(let iii = 0; iii < response2.length; iii++) {
|
||||
self.listUniverse.push({ value: response2[iii].id, label: response2[iii].name });
|
||||
}
|
||||
}).catch(function (response2) {
|
||||
console.log("get response22 : " + JSON.stringify(response2, null, 2));
|
||||
}).catch((response2) => {
|
||||
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
|
||||
});
|
||||
this.typeService.getData()
|
||||
.then(function (response2) {
|
||||
for (let iii = 0; iii < response2.length; iii++) {
|
||||
.then((response2) => {
|
||||
for(let iii = 0; iii < response2.length; iii++) {
|
||||
self.listType.push({ value: response2[iii].id, label: response2[iii].name });
|
||||
}
|
||||
}).catch(function (response2) {
|
||||
console.log("get response22 : " + JSON.stringify(response2, null, 2));
|
||||
}).catch((response2) => {
|
||||
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
|
||||
});
|
||||
console.log(" END INIT ");
|
||||
console.log(' END INIT ');
|
||||
}
|
||||
|
||||
onChangeType (_value: any): void {
|
||||
this.series_id = null;
|
||||
this.updateType (_value);
|
||||
onChangeType(value: any): void {
|
||||
this.seriesId = null;
|
||||
this.updateType(value);
|
||||
}
|
||||
|
||||
private updateType (_value: any): void {
|
||||
console.log("Change requested of type ... " + _value);
|
||||
if (this.type_id == _value) {
|
||||
private updateType(value: any): void {
|
||||
console.log(`Change requested of type ... ${ value}`);
|
||||
if(this.typeId === value) {
|
||||
return;
|
||||
}
|
||||
this.type_id = _value;
|
||||
//this.data.series_id = null;
|
||||
//this.data.season_id = null;
|
||||
this.listSeries = [{value: null, label: '---'}];
|
||||
this.listSeason = [{value: null, label: '---'}];
|
||||
this.typeId = value;
|
||||
// this.data.series_id = null;
|
||||
// this.data.season_id = null;
|
||||
this.listSeries = [ { value: null, label: '---' } ];
|
||||
this.listSeason = [ { value: null, label: '---' } ];
|
||||
let self = this;
|
||||
this.updateNeedSend();
|
||||
if (this.type_id != null) {
|
||||
self.typeService.getSubSeries(this.type_id, ["id", "name"])
|
||||
.then(function(response2) {
|
||||
for(let iii= 0; iii < response2.length; iii++) {
|
||||
self.listSeries.push({value: response2[iii].id, label: response2[iii].name});
|
||||
if(this.typeId !== null) {
|
||||
self.typeService.getSubSeries(this.typeId, [ 'id', 'name' ])
|
||||
.then((response2) => {
|
||||
for(let iii = 0; iii < response2.length; iii++) {
|
||||
self.listSeries.push({ value: response2[iii].id, label: response2[iii].name });
|
||||
}
|
||||
}).catch(function(response2) {
|
||||
console.log("get response22 : " + JSON.stringify(response2, null, 2));
|
||||
}).catch((response2) => {
|
||||
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onChangeSeries (_value: any): void {
|
||||
this.series_id = _value;
|
||||
if (_value === undefined || _value === null) {
|
||||
|
||||
} else {
|
||||
for (let iii = 0 ; iii<this.listSeries.length ; iii++) {
|
||||
if (this.listSeries[iii].value == _value) {
|
||||
this.global_series = this.listSeries[iii].label;
|
||||
onChangeSeries(value: any): void {
|
||||
this.seriesId = value;
|
||||
if(!(value === undefined || value === null)) {
|
||||
for(let iii = 0; iii < this.listSeries.length; iii++) {
|
||||
if(this.listSeries[iii].value === value) {
|
||||
this.globalSeries = this.listSeries[iii].label;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -204,151 +203,149 @@ export class UploadScene implements OnInit {
|
||||
this.updateNeedSend();
|
||||
this.updateListOfVideoToCheck();
|
||||
}
|
||||
onSeason (_value: any): void {
|
||||
this.global_season = _value;
|
||||
//console.log("change episode ID: " + _value + " ==> " + this.parse_season.toString());
|
||||
onSeason(value: any): void {
|
||||
this.globalSeason = value;
|
||||
// console.log("change episode ID: " + value + " ==> " + this.parseSeason.toString());
|
||||
this.updateNeedSend();
|
||||
this.updateListOfVideoToCheck();
|
||||
}
|
||||
|
||||
onTitle (data: FileParsedElement, _value: any): void {
|
||||
data.title = _value;
|
||||
onTitle(data: FileParsedElement, value: any): void {
|
||||
data.title = value;
|
||||
this.updateNeedSend();
|
||||
}
|
||||
removeElmentFromList (data: FileParsedElement, _value: any): void {
|
||||
for (let iii=0; iii< this.parsedElement.length; iii++) {
|
||||
if (this.parsedElement[iii] === data) {
|
||||
removeElmentFromList(data: FileParsedElement, value: any): void {
|
||||
for(let iii = 0; iii < this.parsedElement.length; iii++) {
|
||||
if(this.parsedElement[iii] === data) {
|
||||
this.parsedElement.splice(iii, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.parsedFailedElement.push(new FileFailParsedElement(data.file, "Removed by user."));
|
||||
this.parsedFailedElement.push(new FileFailParsedElement(data.file, 'Removed by user.'));
|
||||
this.updateNeedSend();
|
||||
}
|
||||
|
||||
onUniverse (_value: any): void {
|
||||
this.global_universe = _value;
|
||||
onUniverse(value: any): void {
|
||||
this.globalUniverse = value;
|
||||
this.updateNeedSend();
|
||||
}
|
||||
|
||||
onEpisode (data: FileParsedElement, _value: any): void {
|
||||
data.episode = _value;
|
||||
//console.log("change episode ID: " + _value + " ==> " + this.parse_episode.toString());
|
||||
onEpisode(data: FileParsedElement, value: any): void {
|
||||
data.episode = value;
|
||||
// console.log("change episode ID: " + value + " ==> " + this.parseEpisode.toString());
|
||||
this.updateNeedSend();
|
||||
}
|
||||
|
||||
onSeries (_value: any): void {
|
||||
this.global_series = _value;
|
||||
onSeries(value: any): void {
|
||||
this.globalSeries = value;
|
||||
let self = this;
|
||||
if (this.global_series != "") {
|
||||
this.seriesService.getLike(this.global_series)
|
||||
.then(function(response: any[]) {
|
||||
console.log("find element: " + response.length);
|
||||
for (let iii = 0; iii<response.length; iii++) {
|
||||
console.log(" - " + JSON.stringify(response[iii]));
|
||||
}
|
||||
if (response.length == 0) {
|
||||
self.series_id = null;
|
||||
} else if (response.length == 1) {
|
||||
self.series_id = response[0].id;
|
||||
}
|
||||
this.updateListOfVideoToCheck();
|
||||
}).catch(function(response) {
|
||||
console.log("CAN NOT find element: " );
|
||||
self.series_id = null;
|
||||
});
|
||||
if(this.globalSeries !== '') {
|
||||
this.seriesService.getLike(this.globalSeries)
|
||||
.then((response: any[]) => {
|
||||
console.log(`find element: ${ response.length}`);
|
||||
for(let iii = 0; iii < response.length; iii++) {
|
||||
console.log(` - ${ JSON.stringify(response[iii])}`);
|
||||
}
|
||||
if(response.length === 0) {
|
||||
self.seriesId = null;
|
||||
} else if(response.length === 1) {
|
||||
self.seriesId = response[0].id;
|
||||
}
|
||||
self.updateListOfVideoToCheck();
|
||||
}).catch((response) => {
|
||||
console.log('CAN NOT find element: ');
|
||||
self.seriesId = null;
|
||||
});
|
||||
}
|
||||
this.updateNeedSend();
|
||||
}
|
||||
|
||||
|
||||
|
||||
clearData() {
|
||||
this.global_universe = "";
|
||||
this.global_series = "";
|
||||
this.global_season = null;
|
||||
this.globalUniverse = '';
|
||||
this.globalSeries = '';
|
||||
this.globalSeason = null;
|
||||
this.parsedElement = [];
|
||||
this.parsedFailedElement = [];
|
||||
this.listFileInBdd = null;
|
||||
|
||||
this.type_id = null;
|
||||
this.series_id = null;
|
||||
this.saison_id = null;
|
||||
this.listSeries = [{value: null, label: '---'}];
|
||||
this.listSeason = [{value: null, label: '---'}];
|
||||
this.typeId = null;
|
||||
this.seriesId = null;
|
||||
this.saisonId = null;
|
||||
this.listSeries = [ { value: null, label: '---' } ];
|
||||
this.listSeason = [ { value: null, label: '---' } ];
|
||||
}
|
||||
|
||||
|
||||
addFileWithMetaData(file: File) {
|
||||
//parsedElement: FileParsedElement[] = [];
|
||||
// parsedElement: FileParsedElement[] = [];
|
||||
let universe: string = null;
|
||||
let series: string = null;
|
||||
let season: number | null = null;
|
||||
let episode: number | null = null;
|
||||
let title: string = "";
|
||||
let title: string = '';
|
||||
|
||||
console.log("select file " + file.name);
|
||||
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(/[Ee]([0-9]+)[- \t]+[Ss]([0-9]+)/g,'-s$2-e$1-');
|
||||
tmpName = tmpName.replace(/_/g,'-');
|
||||
tmpName = tmpName.replace(/--/g,'-');
|
||||
console.log("select file " + tmpName);
|
||||
console.log(`select file ${ file.name}`);
|
||||
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(/[Ee]([0-9]+)[- \t]+[Ss]([0-9]+)/g, '-s$2-e$1-');
|
||||
tmpName = tmpName.replace(/_/g, '-');
|
||||
tmpName = tmpName.replace(/--/g, '-');
|
||||
console.log(`select file ${ tmpName}`);
|
||||
const splitElement = tmpName.split('-');
|
||||
if (splitElement.length == 1) {
|
||||
if(splitElement.length === 1) {
|
||||
title = splitElement[0];
|
||||
} else {
|
||||
if (splitElement.length>=2) {
|
||||
if(splitElement.length >= 2) {
|
||||
series = splitElement[0];
|
||||
}
|
||||
splitElement.splice(0,1);
|
||||
if (splitElement.length == 1) {
|
||||
splitElement.splice(0, 1);
|
||||
if(splitElement.length === 1) {
|
||||
title = splitElement[0];
|
||||
} else {
|
||||
while (splitElement.length>0) {
|
||||
while(splitElement.length > 0) {
|
||||
let element = splitElement[0];
|
||||
let find = false;
|
||||
if (season === null) {
|
||||
if (element.length >= 1 && (element[0] === 's' || element[0] === 'S') ) {
|
||||
if(season === null) {
|
||||
if(element.length >= 1 && (element[0] === 's' || element[0] === 'S')) {
|
||||
element = element.substring(1);
|
||||
season = parseInt(element, 10);
|
||||
find = true;
|
||||
}
|
||||
}
|
||||
if (episode === null && find === false) {
|
||||
if (element.length >= 1 && (element[0] === 'e' || element[0] === 'E') ) {
|
||||
if(episode === null && find === false) {
|
||||
if(element.length >= 1 && (element[0] === 'e' || element[0] === 'E')) {
|
||||
element = element.substring(1);
|
||||
episode = parseInt(element, 10);
|
||||
find = true;
|
||||
}
|
||||
}
|
||||
if (find === false) {
|
||||
if (season === null && episode === null) {
|
||||
if (universe === "") {
|
||||
if(find === false) {
|
||||
if(season === null && episode === null) {
|
||||
if(universe === '') {
|
||||
universe = element;
|
||||
} else {
|
||||
universe = universe + "-" + element;
|
||||
universe = `${universe }-${ element}`;
|
||||
}
|
||||
} else if(title === '') {
|
||||
title = element;
|
||||
} else {
|
||||
if (title === "") {
|
||||
title = element;
|
||||
} else {
|
||||
title = title + "-" + element;
|
||||
}
|
||||
title = `${title }-${ element}`;
|
||||
}
|
||||
}
|
||||
splitElement.splice(0,1);
|
||||
splitElement.splice(0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isNaN(episode)) {
|
||||
if(isNaN(episode)) {
|
||||
episode = null;
|
||||
}
|
||||
if (isNaN(season)) {
|
||||
if(isNaN(season)) {
|
||||
season = null;
|
||||
}
|
||||
// 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);
|
||||
console.log("==>" + JSON.stringify(tmp));
|
||||
console.log(`==>${ JSON.stringify(tmp)}`);
|
||||
// add it in the list.
|
||||
this.parsedElement.push(tmp);
|
||||
}
|
||||
@ -356,200 +353,198 @@ export class UploadScene implements OnInit {
|
||||
|
||||
// At the file input element
|
||||
// (change)="selectFile($event)"
|
||||
onChangeFile (_value: any): void {
|
||||
onChangeFile(value: any): void {
|
||||
this.clearData();
|
||||
|
||||
for (let iii=0; iii<_value.files.length; iii++) {
|
||||
this.addFileWithMetaData(_value.files[iii]);
|
||||
|
||||
for(let iii = 0; iii < value.files.length; iii++) {
|
||||
this.addFileWithMetaData(value.files[iii]);
|
||||
}
|
||||
// check if all global parameters are generic:
|
||||
if (this.parsedElement.length == 0) {
|
||||
if(this.parsedElement.length === 0) {
|
||||
this.updateNeedSend();
|
||||
return;
|
||||
}
|
||||
// we verify fith the first value to remove all unknown ...
|
||||
// clean different univers:
|
||||
for (let iii=1; iii<this.parsedElement.length; iii++) {
|
||||
console.log("check universe [" + (iii+1) + "/" + this.parsedElement.length + "] '" + this.parsedElement[0].universe + " !== " + this.parsedElement[iii].universe + "'");
|
||||
if (this.parsedElement[0].universe !== this.parsedElement[iii].universe) {
|
||||
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, "Remove from list due to wrong universe value"));
|
||||
console.log("Remove from list (!= universe) : [" + (iii+1) + "/" + this.parsedElement.length + "] '" + this.parsedElement[iii].file.name + "'");
|
||||
this.parsedElement.splice(iii,1);
|
||||
for(let iii = 1; iii < this.parsedElement.length; iii++) {
|
||||
console.log(`check universe [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[0].universe } !== ${ this.parsedElement[iii].universe }'`);
|
||||
if(this.parsedElement[0].universe !== this.parsedElement[iii].universe) {
|
||||
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, 'Remove from list due to wrong universe value'));
|
||||
console.log(`Remove from list (!= universe) : [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[iii].file.name }'`);
|
||||
this.parsedElement.splice(iii, 1);
|
||||
iii--;
|
||||
}
|
||||
}
|
||||
// clean different series:
|
||||
for (let iii=1; iii<this.parsedElement.length; iii++) {
|
||||
console.log("check series [" + (iii+1) + "/" + this.parsedElement.length + "] '" + this.parsedElement[0].series + " !== " + this.parsedElement[iii].series + "'");
|
||||
if (this.parsedElement[0].series !== this.parsedElement[iii].series) {
|
||||
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, "Remove from list due to wrong series value"));
|
||||
console.log("Remove from list (!= series) : [" + (iii+1) + "/" + this.parsedElement.length + "] '" + this.parsedElement[iii].file.name + "'");
|
||||
this.parsedElement.splice(iii,1);
|
||||
for(let iii = 1; iii < this.parsedElement.length; iii++) {
|
||||
console.log(`check series [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[0].series } !== ${ this.parsedElement[iii].series }'`);
|
||||
if(this.parsedElement[0].series !== this.parsedElement[iii].series) {
|
||||
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, 'Remove from list due to wrong series value'));
|
||||
console.log(`Remove from list (!= series) : [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[iii].file.name }'`);
|
||||
this.parsedElement.splice(iii, 1);
|
||||
iii--;
|
||||
}
|
||||
}
|
||||
// clean different season:
|
||||
for (let iii=1; iii<this.parsedElement.length; iii++) {
|
||||
console.log("check season [" + (iii+1) + "/" + this.parsedElement.length + "] '" + this.parsedElement[0].season + " !== " + this.parsedElement[iii].season + "'");
|
||||
if (this.parsedElement[0].season !== this.parsedElement[iii].season) {
|
||||
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, "Remove from list due to wrong season value"));
|
||||
console.log("Remove from list (!= season) : [" + (iii+1) + "/" + this.parsedElement.length + "] '" + this.parsedElement[iii].file.name + "'");
|
||||
this.parsedElement.splice(iii,1);
|
||||
for(let iii = 1; iii < this.parsedElement.length; iii++) {
|
||||
console.log(`check season [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[0].season } !== ${ this.parsedElement[iii].season }'`);
|
||||
if(this.parsedElement[0].season !== this.parsedElement[iii].season) {
|
||||
this.parsedFailedElement.push(new FileFailParsedElement(this.parsedElement[iii].file, 'Remove from list due to wrong season value'));
|
||||
console.log(`Remove from list (!= season) : [${ iii + 1 }/${ this.parsedElement.length }] '${ this.parsedElement[iii].file.name }'`);
|
||||
this.parsedElement.splice(iii, 1);
|
||||
iii--;
|
||||
}
|
||||
}
|
||||
|
||||
this.global_universe = this.parsedElement[0].universe;
|
||||
this.global_series = this.parsedElement[0].series;
|
||||
this.global_season = this.parsedElement[0].season;
|
||||
this.globalUniverse = this.parsedElement[0].universe;
|
||||
this.globalSeries = this.parsedElement[0].series;
|
||||
this.globalSeason = this.parsedElement[0].season;
|
||||
|
||||
this.updateNeedSend();
|
||||
this.series_id = null;
|
||||
this.saison_id = null;
|
||||
this.seriesId = null;
|
||||
this.saisonId = null;
|
||||
let self = this;
|
||||
if (this.global_series != "") {
|
||||
this.seriesService.getLike(this.global_series)
|
||||
.then(function(response: any[]) {
|
||||
console.log("find element: " + response.length);
|
||||
for (let iii = 0; iii<response.length; iii++) {
|
||||
console.log(" - " + JSON.stringify(response[iii]));
|
||||
}
|
||||
if (response.length == 0) {
|
||||
self.series_id = null;
|
||||
} else if (response.length == 1) {
|
||||
let serie_elem = response[0];
|
||||
self.series_id = serie_elem.id;
|
||||
self.updateType(serie_elem.parent_id);
|
||||
}
|
||||
self.updateListOfVideoToCheck();
|
||||
}).catch(function(response) {
|
||||
console.log("CAN NOT find element: " );
|
||||
});
|
||||
if(this.globalSeries !== '') {
|
||||
this.seriesService.getLike(this.globalSeries)
|
||||
.then((response: any[]) => {
|
||||
console.log(`find element: ${ response.length}`);
|
||||
for(let iii = 0; iii < response.length; iii++) {
|
||||
console.log(` - ${ JSON.stringify(response[iii])}`);
|
||||
}
|
||||
if(response.length === 0) {
|
||||
self.seriesId = null;
|
||||
} else if(response.length === 1) {
|
||||
let serieElem = response[0];
|
||||
self.seriesId = serieElem.id;
|
||||
self.updateType(serieElem.parentId);
|
||||
}
|
||||
self.updateListOfVideoToCheck();
|
||||
}).catch((response) => {
|
||||
console.log('CAN NOT find element: ');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
sendFile(): void {
|
||||
console.log("Send file requested ... " + this.parsedElement.length);
|
||||
console.log(`Send file requested ... ${ this.parsedElement.length}`);
|
||||
this.upload = new UploadProgress();
|
||||
// display the upload pop-in
|
||||
this.popInService.open("popin-upload-progress");
|
||||
this.popInService.open('popin-upload-progress');
|
||||
this.globalUpLoad(0, this.parsedElement.length);
|
||||
}
|
||||
|
||||
globalUpLoad(id: number, total: number): void {
|
||||
let self = this;
|
||||
let self = this;
|
||||
this.uploadFile(this.parsedElement[id], id, total, () => {
|
||||
let id2 = id + 1;
|
||||
if (id2 < total) {
|
||||
if(id2 < total) {
|
||||
self.globalUpLoad(id2, total);
|
||||
} else {
|
||||
self.upload.result = "Media creation done";
|
||||
self.upload.result = 'Media creation done';
|
||||
}
|
||||
}, (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;
|
||||
|
||||
self.upload.labelMediaTitle = '';
|
||||
// add universe
|
||||
if (self.global_universe !== null) {
|
||||
self.upload.labelMediaTitle += self.global_universe;
|
||||
if(self.globalUniverse !== null) {
|
||||
self.upload.labelMediaTitle = self.upload.labelMediaTitle + self.globalUniverse;
|
||||
}
|
||||
// add series
|
||||
if (self.global_series !== null) {
|
||||
if (self.upload.labelMediaTitle.length != 0) {
|
||||
self.upload.labelMediaTitle += ":";
|
||||
if(self.globalSeries !== null) {
|
||||
if(self.upload.labelMediaTitle.length !== 0) {
|
||||
self.upload.labelMediaTitle = `${self.upload.labelMediaTitle }:`;
|
||||
}
|
||||
self.upload.labelMediaTitle += self.global_series;
|
||||
self.upload.labelMediaTitle = self.upload.labelMediaTitle + self.globalSeries;
|
||||
}
|
||||
// add season
|
||||
if (self.global_season !== null && self.global_season !== undefined && self.global_season.toString().length != 0) {
|
||||
if (self.upload.labelMediaTitle.length != 0) {
|
||||
self.upload.labelMediaTitle += "-";
|
||||
if(self.globalSeason !== null && self.globalSeason !== undefined && self.globalSeason.toString().length !== 0) {
|
||||
if(self.upload.labelMediaTitle.length !== 0) {
|
||||
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
|
||||
if (eleemnent.episode !== null && eleemnent.episode !== undefined && eleemnent.episode.toString().length != 0) {
|
||||
if (self.upload.labelMediaTitle.length != 0) {
|
||||
self.upload.labelMediaTitle += "-";
|
||||
if(eleemnent.episode !== null && eleemnent.episode !== undefined && eleemnent.episode.toString().length !== 0) {
|
||||
if(self.upload.labelMediaTitle.length !== 0) {
|
||||
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
|
||||
if (self.upload.labelMediaTitle.length != 0) {
|
||||
self.upload.labelMediaTitle += "-";
|
||||
if(self.upload.labelMediaTitle.length !== 0) {
|
||||
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.global_universe,
|
||||
self.global_series,
|
||||
self.series_id,
|
||||
self.global_season,
|
||||
eleemnent.episode,
|
||||
eleemnent.title,
|
||||
self.type_id,
|
||||
function(count, total) {
|
||||
//console.log("upload : " + count*100/total);
|
||||
self.upload.mediaSendSize = count;
|
||||
self.upload.mediaSize = total;
|
||||
})
|
||||
.then(function (response) {
|
||||
console.log("get response of video : " + JSON.stringify(response, null, 2));
|
||||
_sendDone();
|
||||
}).catch(function (response) {
|
||||
//self.error = "Can not get the data";
|
||||
console.log("Can not add the data in the system...");
|
||||
_errorOccured(JSON.stringify(response, null, 2));
|
||||
});
|
||||
self.globalUniverse,
|
||||
self.globalSeries,
|
||||
self.seriesId,
|
||||
self.globalSeason,
|
||||
eleemnent.episode,
|
||||
eleemnent.title,
|
||||
self.typeId,
|
||||
(count, totalTmp) => {
|
||||
// console.log("upload : " + count*100/totalTmp);
|
||||
self.upload.mediaSendSize = count;
|
||||
self.upload.mediaSize = totalTmp;
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(`get response of video : ${ JSON.stringify(response, null, 2)}`);
|
||||
sendDone();
|
||||
}).catch((response) => {
|
||||
// self.error = "Can not get the data";
|
||||
console.log('Can not add the data in the system...');
|
||||
errorOccured(JSON.stringify(response, null, 2));
|
||||
});
|
||||
}
|
||||
|
||||
public checkSimilarString(valueA:string, valueB:string): boolean {
|
||||
let valueAL = valueA.toLowerCase();
|
||||
let valueBL = valueB.toLowerCase();
|
||||
valueAL = valueAL.replace(/[ \t\n\r-_#~@]/g, "");
|
||||
valueBL = valueBL.replace(/[ \t\n\r-_#~@]/g, "");
|
||||
if (valueAL == valueBL) {
|
||||
valueAL = valueAL.replace(/[ \t\n\r-_#~@]/g, '');
|
||||
valueBL = valueBL.replace(/[ \t\n\r-_#~@]/g, '');
|
||||
if(valueAL === valueBL) {
|
||||
return true;
|
||||
}
|
||||
if (valueAL.startsWith(valueBL)) {
|
||||
if(valueAL.startsWith(valueBL)) {
|
||||
return true;
|
||||
}
|
||||
if (valueBL.startsWith(valueAL)) {
|
||||
if(valueBL.startsWith(valueAL)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
checkConcordence():void {
|
||||
if (this.parsedElement === null) {
|
||||
if(this.parsedElement === null) {
|
||||
return;
|
||||
}
|
||||
// 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].episodeDetected = false;
|
||||
}
|
||||
if (this.listFileInBdd === null) {
|
||||
if(this.listFileInBdd === null) {
|
||||
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].episodeDetected = false;
|
||||
}
|
||||
for (let iii = 0; iii < this.parsedElement.length; iii++) {
|
||||
for (let jjj = 0; jjj < this.listFileInBdd.length; jjj++) {
|
||||
if (this.checkSimilarString(this.parsedElement[iii].title, this.listFileInBdd[jjj].name)) {
|
||||
for(let iii = 0; iii < this.parsedElement.length; iii++) {
|
||||
for(let jjj = 0; jjj < this.listFileInBdd.length; jjj++) {
|
||||
if(this.checkSimilarString(this.parsedElement[iii].title, this.listFileInBdd[jjj].name)) {
|
||||
this.parsedElement[iii].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.listFileInBdd[jjj].episodeDetected = true;
|
||||
}
|
||||
@ -559,92 +554,89 @@ export class UploadScene implements OnInit {
|
||||
|
||||
updateListOfVideoToCheck(): void {
|
||||
// No series ID set ==> nothing to do.
|
||||
if (this.series_id === null) {
|
||||
if(this.seriesId === null) {
|
||||
this.listFileInBdd = null;
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
// no season check only the series files.
|
||||
if (this.global_season === null) {
|
||||
self.seriesService.getVideo(self.series_id)
|
||||
.then(function(response: any[]) {
|
||||
self.listFileInBdd = response;
|
||||
//console.log("find video: " + response.length);
|
||||
//for (let iii = 0; iii<response.length; iii++) {
|
||||
// console.log(" - " + JSON.stringify(response[iii]));
|
||||
//}
|
||||
self.checkConcordence();
|
||||
}).catch(function(response) {
|
||||
self.listFileInBdd = null;
|
||||
})
|
||||
if(this.globalSeason === null) {
|
||||
self.seriesService.getVideo(self.seriesId)
|
||||
.then((response: any[]) => {
|
||||
self.listFileInBdd = response;
|
||||
// console.log("find video: " + response.length);
|
||||
// for (let iii = 0; iii<response.length; iii++) {
|
||||
// console.log(" - " + JSON.stringify(response[iii]));
|
||||
// }
|
||||
self.checkConcordence();
|
||||
}).catch((response) => {
|
||||
self.listFileInBdd = null;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
self.saison_id = null;
|
||||
self.saisonId = null;
|
||||
// set 1 find the ID of the season:
|
||||
this.seriesService.getSeason(this.series_id, [ "id" , "name" ])
|
||||
.then(function(response: any[]) {
|
||||
//console.log("find season: " + response.length);
|
||||
for (let iii = 0; iii<response.length; iii++) {
|
||||
//console.log(" - " + JSON.stringify(response[iii]) + 'compare with : ' + JSON.stringify(self.global_season));
|
||||
if (response[iii].name == ""+self.global_season) {
|
||||
self.saison_id = response[iii].id;
|
||||
this.seriesService.getSeason(this.seriesId, [ 'id', 'name' ])
|
||||
.then((response: any[]) => {
|
||||
// console.log("find season: " + response.length);
|
||||
for(let iii = 0; iii < response.length; iii++) {
|
||||
// console.log(" - " + JSON.stringify(response[iii]) + 'compare with : ' + JSON.stringify(self.globalSeason));
|
||||
if(response[iii].name === `${self.globalSeason}`) {
|
||||
self.saisonId = response[iii].id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (self.saison_id === null) {
|
||||
if(self.saisonId === null) {
|
||||
return;
|
||||
}
|
||||
self.seasonService.getVideo(self.saison_id)
|
||||
.then(function(response: any[]) {
|
||||
self.listFileInBdd = response;
|
||||
//console.log("find video: " + response.length);
|
||||
//for (let iii = 0; iii<response.length; iii++) {
|
||||
// console.log(" - " + JSON.stringify(response[iii]));
|
||||
//}
|
||||
self.seasonService.getVideo(self.saisonId)
|
||||
.then((response2: any[]) => {
|
||||
self.listFileInBdd = response2;
|
||||
// console.log("find video: " + response2.length);
|
||||
// for (let iii = 0; iii<response2.length; iii++) {
|
||||
// console.log(" - " + JSON.stringify(response2[iii]));
|
||||
// }
|
||||
self.checkConcordence();
|
||||
}).catch(function(response) {
|
||||
}).catch((response3) => {
|
||||
self.listFileInBdd = null;
|
||||
})
|
||||
}).catch(function(response) {
|
||||
});
|
||||
}).catch((response4) => {
|
||||
self.listFileInBdd = null;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
eventPopUpSeason (_event: string): void {
|
||||
console.log("GET event: " + _event);
|
||||
this.popInService.close("popin-new-season");
|
||||
eventPopUpSeason(event: string): void {
|
||||
console.log(`GET event: ${ event}`);
|
||||
this.popInService.close('popin-new-season');
|
||||
}
|
||||
eventPopUpSeries (_event: string): void {
|
||||
console.log("GET event: " + _event);
|
||||
this.popInService.close("popin-new-series");
|
||||
eventPopUpSeries(event: string): void {
|
||||
console.log(`GET event: ${ event}`);
|
||||
this.popInService.close('popin-new-series');
|
||||
}
|
||||
eventPopUpType (_event: string): void {
|
||||
console.log("GET event: " + _event);
|
||||
this.popInService.close("popin-new-type");
|
||||
eventPopUpType(event: string): void {
|
||||
console.log(`GET event: ${ event}`);
|
||||
this.popInService.close('popin-new-type');
|
||||
}
|
||||
eventPopUpUniverse (_event: string): void {
|
||||
console.log("GET event: " + _event);
|
||||
this.popInService.close("popin-new-universe");
|
||||
eventPopUpUniverse(event: string): void {
|
||||
console.log(`GET event: ${ event}`);
|
||||
this.popInService.close('popin-new-universe');
|
||||
}
|
||||
|
||||
newSeason (): void {
|
||||
console.log("Request new Season...");
|
||||
this.popInService.open("popin-new-season");
|
||||
newSeason(): void {
|
||||
console.log('Request new Season...');
|
||||
this.popInService.open('popin-new-season');
|
||||
}
|
||||
newSeries (): void {
|
||||
console.log("Request new Series...");
|
||||
this.popInService.open("popin-new-series");
|
||||
newSeries(): void {
|
||||
console.log('Request new Series...');
|
||||
this.popInService.open('popin-new-series');
|
||||
}
|
||||
newType (): void {
|
||||
console.log("Request new Type...");
|
||||
this.popInService.open("popin-create-type");
|
||||
newType(): void {
|
||||
console.log('Request new Type...');
|
||||
this.popInService.open('popin-create-type');
|
||||
}
|
||||
newUniverse () {
|
||||
console.log("Request new Universe...");
|
||||
this.popInService.open("popin-new-universe");
|
||||
newUniverse() {
|
||||
console.log('Request new Universe...');
|
||||
this.popInService.open('popin-new-universe');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,16 +3,15 @@ import { ActivatedRoute } from '@angular/router';
|
||||
import { ArianeService } from '../../service/ariane';
|
||||
|
||||
@Component({
|
||||
selector: 'app-validate-email',
|
||||
templateUrl: './validate-email.html',
|
||||
styleUrls: ['./validate-email.less']
|
||||
selector: 'app-validate-email',
|
||||
templateUrl: './validate-email.html',
|
||||
styleUrls: [ './validate-email.less' ]
|
||||
})
|
||||
export class ValidateEmailScene implements OnInit {
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private arianeService: ArianeService
|
||||
) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@ -24,6 +23,7 @@ export class ValidateEmailScene implements OnInit {
|
||||
onCheck() {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
|
||||
@ -31,11 +31,11 @@ app.controller("controlerValidateEmail", function($scope, $http, $rootScope, Aut
|
||||
$scope.sendButtonDisabled = false;
|
||||
$scope.syncButtonDisabled = false;
|
||||
$scope.error = "";
|
||||
|
||||
|
||||
$scope.rememberMe = true;
|
||||
|
||||
|
||||
$rootScope.currentModalCanRemove = true;
|
||||
|
||||
|
||||
$scope.updateButtonVisibility = function() {
|
||||
if ( $scope.loginOK == true
|
||||
&& $scope.passOK == true
|
||||
@ -46,7 +46,7 @@ app.controller("controlerValidateEmail", function($scope, $http, $rootScope, Aut
|
||||
}
|
||||
$scope.error = "";
|
||||
}
|
||||
|
||||
|
||||
$scope.checkLogin = function() {
|
||||
if ( $scope.login == null
|
||||
|| $scope.login.length == 0) {
|
||||
@ -79,7 +79,7 @@ app.controller("controlerValidateEmail", function($scope, $http, $rootScope, Aut
|
||||
$http.get(connectionAdresse, config)
|
||||
.then(function(response) {
|
||||
// check if the answer is correct with the question
|
||||
if (tmpLogin != $scope.login) {
|
||||
if (tmpLogin !== $scope.login) {
|
||||
return;
|
||||
}
|
||||
console.log("Status " + response.status);
|
||||
@ -95,7 +95,7 @@ app.controller("controlerValidateEmail", function($scope, $http, $rootScope, Aut
|
||||
$scope.loginHelp = "Login already used ... (error 2)";
|
||||
}, function(response) {
|
||||
// check if the answer is correct with the question
|
||||
if (tmpLogin != $scope.login) {
|
||||
if (tmpLogin !== $scope.login) {
|
||||
return;
|
||||
}
|
||||
if (response.status == 404) {
|
||||
@ -116,7 +116,7 @@ app.controller("controlerValidateEmail", function($scope, $http, $rootScope, Aut
|
||||
}
|
||||
$scope.updateButtonVisibility();
|
||||
}
|
||||
|
||||
|
||||
$scope.checkEmail = function() {
|
||||
if ( $scope.email == null
|
||||
|| $scope.email.length == 0) {
|
||||
@ -150,7 +150,7 @@ app.controller("controlerValidateEmail", function($scope, $http, $rootScope, Aut
|
||||
$http.get(connectionAdresse, config)
|
||||
.then(function(response) {
|
||||
// check if the answer is correct with the question
|
||||
if (tmpEmail != $scope.email) {
|
||||
if (tmpEmail !== $scope.email) {
|
||||
return;
|
||||
}
|
||||
console.log("Status " + response.status);
|
||||
@ -166,7 +166,7 @@ app.controller("controlerValidateEmail", function($scope, $http, $rootScope, Aut
|
||||
$scope.emailHelp = "email already used ... (error 2)";
|
||||
}, function(response) {
|
||||
// check if the answer is correct with the question
|
||||
if (tmpEmail != $scope.email) {
|
||||
if (tmpEmail !== $scope.email) {
|
||||
return;
|
||||
}
|
||||
if (response.status == 404) {
|
||||
@ -187,7 +187,7 @@ app.controller("controlerValidateEmail", function($scope, $http, $rootScope, Aut
|
||||
}
|
||||
$scope.updateButtonVisibility();
|
||||
}
|
||||
|
||||
|
||||
$scope.checkPassword = function() {
|
||||
if ($scope.password == null) {
|
||||
$scope.passOK = false;
|
||||
@ -234,7 +234,7 @@ app.controller("controlerValidateEmail", function($scope, $http, $rootScope, Aut
|
||||
console.log("Status " + response.status);
|
||||
console.log("data " + JSON.stringify(response.data, null, 2));
|
||||
if (response.status == 200) {
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
$scope.emailOK = false;
|
||||
@ -251,7 +251,4 @@ app.controller("controlerValidateEmail", function($scope, $http, $rootScope, Aut
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
*/
|
||||
|
@ -67,7 +67,7 @@
|
||||
Type:
|
||||
</div>
|
||||
<div class="input">
|
||||
<select [ngModel]="data.type_id"
|
||||
<select [ngModel]="data.typeId"
|
||||
(ngModelChange)="onChangeType($event)">
|
||||
<option *ngFor="let element of listType" [ngValue]="element.value">{{element.label}}</option>
|
||||
</select>
|
||||
@ -83,7 +83,7 @@
|
||||
Universe:
|
||||
</div>
|
||||
<div class="input">
|
||||
<select [ngModel]="data.universe_id"
|
||||
<select [ngModel]="data.universeId"
|
||||
(ngModelChange)="onChangeUniverse($event)">
|
||||
<option *ngFor="let element of listUniverse" [ngValue]="element.value">{{element.label}}</option>
|
||||
</select>
|
||||
@ -99,7 +99,7 @@
|
||||
Series:
|
||||
</div>
|
||||
<div class="input">
|
||||
<select [ngModel]="data.series_id"
|
||||
<select [ngModel]="data.seriesId"
|
||||
(ngModelChange)="onChangeSeries($event)">
|
||||
<option *ngFor="let element of listSeries" [ngValue]="element.value">{{element.label}}</option>
|
||||
</select>
|
||||
@ -115,7 +115,7 @@
|
||||
Season:
|
||||
</div>
|
||||
<div class="input">
|
||||
<select [ngModel]="data.season_id"
|
||||
<select [ngModel]="data.seasonId"
|
||||
(ngModelChange)="onChangeSeason($event)">
|
||||
<option *ngFor="let element of listSeason" [ngValue]="element.value">{{element.label}}</option>
|
||||
</select>
|
||||
|
@ -5,98 +5,90 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router, ActivatedRoute, ParamMap } from '@angular/router';
|
||||
import { Location } from '@angular/common';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { fadeInAnimation } from '../../_animations/index';
|
||||
import { HttpWrapperService } from '../../service/http-wrapper';
|
||||
|
||||
|
||||
import { PopInService } from '../../service/popin';
|
||||
import { TypeService } from '../../service/type';
|
||||
import { UniverseService } from '../../service/universe';
|
||||
import { SeriesService } from '../../service/series';
|
||||
import { SeasonService } from '../../service/season';
|
||||
import { VideoService } from '../../service/video';
|
||||
import { DataService } from '../../service/data';
|
||||
import { ArianeService } from '../../service/ariane';
|
||||
import { UploadProgress } from '../../popin/upload-progress/upload-progress';
|
||||
|
||||
export class ElementList {
|
||||
value: number;
|
||||
export interface ElementList {
|
||||
value?: number;
|
||||
label: string;
|
||||
constructor(_value: number, _label: string) {
|
||||
this.value = _value;
|
||||
this.label = _label;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DataToSend {
|
||||
name:string = ""
|
||||
description:string = ""
|
||||
episode:number = undefined
|
||||
universe_id:number = null
|
||||
series_id:number = null
|
||||
season_id:number = null
|
||||
data_id:number = -1
|
||||
time:number = undefined
|
||||
type_id:number = null
|
||||
name:string = '';
|
||||
description:string = '';
|
||||
episode:number = undefined;
|
||||
universeId:number = null;
|
||||
seriesId:number = null;
|
||||
seasonId:number = null;
|
||||
dataId:number = -1;
|
||||
time:number = undefined;
|
||||
typeId:number = null;
|
||||
covers:Array<any> = [];
|
||||
generated_name:string = ""
|
||||
generatedName:string = '';
|
||||
clone() {
|
||||
let tmp = new DataToSend();
|
||||
tmp.name = this.name
|
||||
tmp.description = this.description
|
||||
tmp.episode = this.episode
|
||||
tmp.universe_id = this.universe_id
|
||||
tmp.series_id = this.series_id
|
||||
tmp.season_id = this.season_id
|
||||
tmp.data_id = this.data_id
|
||||
tmp.time = this.time
|
||||
tmp.type_id = this.type_id
|
||||
tmp.covers = this.covers
|
||||
tmp.generated_name = this.generated_name
|
||||
tmp.name = this.name;
|
||||
tmp.description = this.description;
|
||||
tmp.episode = this.episode;
|
||||
tmp.universeId = this.universeId;
|
||||
tmp.seriesId = this.seriesId;
|
||||
tmp.seasonId = this.seasonId;
|
||||
tmp.dataId = this.dataId;
|
||||
tmp.time = this.time;
|
||||
tmp.typeId = this.typeId;
|
||||
tmp.covers = this.covers;
|
||||
tmp.generatedName = this.generatedName;
|
||||
return tmp;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-video-edit',
|
||||
templateUrl: './video-edit.html',
|
||||
styleUrls: ['./video-edit.less'],
|
||||
animations: [fadeInAnimation],
|
||||
styleUrls: [ './video-edit.less' ],
|
||||
animations: [ fadeInAnimation ],
|
||||
host: { '[@fadeInAnimation]': '' }
|
||||
})
|
||||
|
||||
export class VideoEditScene implements OnInit {
|
||||
id_video:number = -1;
|
||||
itemIsRemoved:boolean = false
|
||||
itemIsNotFound:boolean = false
|
||||
itemIsLoading:boolean = true
|
||||
|
||||
error:string = ""
|
||||
|
||||
data:DataToSend = new DataToSend();
|
||||
data_ori:DataToSend = new DataToSend();
|
||||
coverFile:File;
|
||||
upload_file_value:string = ""
|
||||
selectedFiles:FileList;
|
||||
need_send:boolean = false;
|
||||
|
||||
idVideo:number = -1;
|
||||
itemIsRemoved:boolean = false;
|
||||
itemIsNotFound:boolean = false;
|
||||
itemIsLoading:boolean = true;
|
||||
|
||||
// section tha define the upload value to display in the pop-in of upload
|
||||
error:string = '';
|
||||
|
||||
data:DataToSend = new DataToSend();
|
||||
dataOri:DataToSend = new DataToSend();
|
||||
coverFile:File;
|
||||
uploadFileValue:string = '';
|
||||
selectedFiles:FileList;
|
||||
needSend:boolean = false;
|
||||
|
||||
|
||||
// section tha define the upload value to display in the pop-in of upload
|
||||
upload:UploadProgress = new UploadProgress();
|
||||
// --------------- confirm section ------------------
|
||||
// --------------- confirm section ------------------
|
||||
public confirmDeleteComment:string = null;
|
||||
public confirmDeleteImageUrl:string = null;
|
||||
private deleteCoverId:number = null;
|
||||
private deleteMediaId:number = null;
|
||||
deleteConfirmed() {
|
||||
if (this.deleteCoverId !== null) {
|
||||
if(this.deleteCoverId !== null) {
|
||||
this.removeCoverAfterConfirm(this.deleteCoverId);
|
||||
this.cleanConfirm();
|
||||
}
|
||||
if (this.deleteMediaId !== null) {
|
||||
if(this.deleteMediaId !== null) {
|
||||
this.removeItemAfterConfirm(this.deleteMediaId);
|
||||
this.cleanConfirm();
|
||||
}
|
||||
@ -108,420 +100,415 @@ export class VideoEditScene implements OnInit {
|
||||
this.deleteMediaId = null;
|
||||
}
|
||||
|
||||
covers_display:Array<any> = [];
|
||||
|
||||
coversDisplay:Array<any> = [];
|
||||
|
||||
listType: ElementList[] = [
|
||||
{value: undefined, label: '---'},
|
||||
{ value: undefined, label: '---' },
|
||||
];
|
||||
listUniverse: ElementList[] = [
|
||||
{value: undefined, label: '---'},
|
||||
{value: null, label: '---'},
|
||||
{ value: undefined, label: '---' },
|
||||
{ value: null, label: '---' },
|
||||
];
|
||||
listSeries: ElementList[] = [
|
||||
{value: undefined, label: '---'},
|
||||
{ value: undefined, label: '---' },
|
||||
];
|
||||
listSeason: ElementList[] = [
|
||||
{value: undefined, label: '---'},
|
||||
{ value: undefined, label: '---' },
|
||||
];
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private locate: Location,
|
||||
private dataService: DataService,
|
||||
private typeService: TypeService,
|
||||
private universeService: UniverseService,
|
||||
private seriesService: SeriesService,
|
||||
private seasonService: SeasonService,
|
||||
private videoService: VideoService,
|
||||
private httpService: HttpWrapperService,
|
||||
private arianeService: ArianeService,
|
||||
private popInService: PopInService) {
|
||||
|
||||
}
|
||||
|
||||
updateNeedSend(): boolean {
|
||||
this.need_send = false;
|
||||
if (this.data.name != this.data_ori.name) {
|
||||
this.need_send = true;
|
||||
}
|
||||
if (this.data.description != this.data_ori.description) {
|
||||
this.need_send = true;
|
||||
}
|
||||
if (this.data.episode != this.data_ori.episode) {
|
||||
this.need_send = true;
|
||||
}
|
||||
if (this.data.time != this.data_ori.time) {
|
||||
this.need_send = true;
|
||||
}
|
||||
if (this.data.type_id != this.data_ori.type_id) {
|
||||
this.need_send = true;
|
||||
}
|
||||
if (this.data.universe_id != this.data_ori.universe_id) {
|
||||
this.need_send = true;
|
||||
}
|
||||
if (this.data.series_id != this.data_ori.series_id) {
|
||||
this.need_send = true;
|
||||
}
|
||||
if (this.data.season_id != this.data_ori.season_id) {
|
||||
this.need_send = true;
|
||||
}
|
||||
return this.need_send;
|
||||
|
||||
}
|
||||
|
||||
updateCoverList(_covers: any) {
|
||||
this.covers_display = [];
|
||||
updateNeedSend(): boolean {
|
||||
this.needSend = false;
|
||||
if(this.data.name !== this.dataOri.name) {
|
||||
this.needSend = true;
|
||||
}
|
||||
if(this.data.description !== this.dataOri.description) {
|
||||
this.needSend = true;
|
||||
}
|
||||
if(this.data.episode !== this.dataOri.episode) {
|
||||
this.needSend = true;
|
||||
}
|
||||
if(this.data.time !== this.dataOri.time) {
|
||||
this.needSend = true;
|
||||
}
|
||||
if(this.data.typeId !== this.dataOri.typeId) {
|
||||
this.needSend = true;
|
||||
}
|
||||
if(this.data.universeId !== this.dataOri.universeId) {
|
||||
this.needSend = true;
|
||||
}
|
||||
if(this.data.seriesId !== this.dataOri.seriesId) {
|
||||
this.needSend = true;
|
||||
}
|
||||
if(this.data.seasonId !== this.dataOri.seasonId) {
|
||||
this.needSend = true;
|
||||
}
|
||||
return this.needSend;
|
||||
}
|
||||
|
||||
updateCoverList(covers: any) {
|
||||
this.coversDisplay = [];
|
||||
this.data.covers = [];
|
||||
if (_covers !== undefined && _covers !== null) {
|
||||
for (let iii=0; iii<_covers.length; iii++) {
|
||||
this.data.covers.push(_covers[iii]);
|
||||
this.covers_display.push({
|
||||
id:_covers[iii],
|
||||
url:this.videoService.getCoverThumbnailUrl(_covers[iii])
|
||||
});
|
||||
if(covers !== undefined && covers !== null) {
|
||||
for(let iii = 0; iii < covers.length; iii++) {
|
||||
this.data.covers.push(covers[iii]);
|
||||
this.coversDisplay.push({
|
||||
id:covers[iii],
|
||||
url:this.videoService.getCoverThumbnailUrl(covers[iii])
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.covers_display = []
|
||||
this.coversDisplay = [];
|
||||
}
|
||||
}
|
||||
ngOnInit() {
|
||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
||||
this.id_video = this.arianeService.getVideoId();
|
||||
this.idVideo = this.arianeService.getVideoId();
|
||||
let self = this;
|
||||
this.listType = [{value: null, label: '---'}];
|
||||
this.listUniverse = [{value: null, label: '---'}];
|
||||
this.listSeries = [{value: null, label: '---'}];
|
||||
this.listSeason = [{value: null, label: '---'}];
|
||||
this.listType = [ { value: null, label: '---' } ];
|
||||
this.listUniverse = [ { value: null, label: '---' } ];
|
||||
this.listSeries = [ { value: null, label: '---' } ];
|
||||
this.listSeason = [ { value: null, label: '---' } ];
|
||||
this.universeService.getData()
|
||||
.then(function(response2) {
|
||||
for(let iii= 0; iii < response2.length; iii++) {
|
||||
self.listUniverse.push({value: response2[iii].id, label: response2[iii].name});
|
||||
.then((response2) => {
|
||||
for(let iii = 0; iii < response2.length; iii++) {
|
||||
self.listUniverse.push({ value: response2[iii].id, label: response2[iii].name });
|
||||
}
|
||||
}).catch(function(response2) {
|
||||
console.log("get response22 : " + JSON.stringify(response2, null, 2));
|
||||
}).catch((response2) => {
|
||||
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
|
||||
});
|
||||
this.typeService.getData()
|
||||
.then(function(response2) {
|
||||
for(let iii= 0; iii < response2.length; iii++) {
|
||||
self.listType.push({value: response2[iii].id, label: response2[iii].name});
|
||||
.then((response2) => {
|
||||
for(let iii = 0; iii < response2.length; iii++) {
|
||||
self.listType.push({ value: response2[iii].id, label: response2[iii].name });
|
||||
}
|
||||
}).catch(function(response2) {
|
||||
console.log("get response22 : " + JSON.stringify(response2, null, 2));
|
||||
}).catch((response2) => {
|
||||
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
|
||||
});
|
||||
//this.seriesService.getOrder()
|
||||
// this.seriesService.getOrder()
|
||||
this.seriesService.getData()
|
||||
.then(function(response3) {
|
||||
for(let iii= 0; iii < response3.length; iii++) {
|
||||
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)
|
||||
.then((response3) => {
|
||||
for(let iii = 0; iii < response3.length; iii++) {
|
||||
self.listSeries.push({ value: response3[iii].id, label: response3[iii].name });
|
||||
console.log(`[${ self.data.dataId }] Get series: ${ response3[iii].id }, label:${ response3[iii].name}`);
|
||||
}
|
||||
}).catch(function(response3) {
|
||||
console.log("get response3 : " + JSON.stringify(response3, null, 2));
|
||||
}).catch((response3) => {
|
||||
console.log(`get response3 : ${ JSON.stringify(response3, null, 2)}`);
|
||||
});
|
||||
this.videoService.get(this.id_video)
|
||||
.then(function(response) {
|
||||
console.log("get response of video : " + JSON.stringify(response, null, 2));
|
||||
this.videoService.get(this.idVideo)
|
||||
.then((response) => {
|
||||
console.log(`get response of video : ${ JSON.stringify(response, null, 2)}`);
|
||||
self.data.name = response.name;
|
||||
self.data.description = response.description;
|
||||
self.data.episode = response.episode;
|
||||
self.data.universe_id = response.univers_id;
|
||||
if (self.data.universe_id === undefined) {
|
||||
self.data.universe_id = null;
|
||||
self.data.universeId = response.universId;
|
||||
if(self.data.universeId === undefined) {
|
||||
self.data.universeId = null;
|
||||
}
|
||||
self.data.data_id = response.data_id;
|
||||
self.data.dataId = response.dataId;
|
||||
self.data.time = response.time;
|
||||
self.data.generated_name = response.generated_name;
|
||||
self.onChangeType(response.type_id);
|
||||
self.onChangeSeries(response.series_id);
|
||||
self.data.season_id = response.season_id;
|
||||
if (self.data.season_id === undefined) {
|
||||
self.data.season_id = null;
|
||||
self.data.generatedName = response.generatedName;
|
||||
self.onChangeType(response.typeId);
|
||||
self.onChangeSeries(response.seriesId);
|
||||
self.data.seasonId = response.seasonId;
|
||||
if(self.data.seasonId === undefined) {
|
||||
self.data.seasonId = null;
|
||||
}
|
||||
self.data_ori = self.data.clone();
|
||||
self.dataOri = self.data.clone();
|
||||
self.updateCoverList(response.covers);
|
||||
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;
|
||||
}).catch(function(response) {
|
||||
self.error = "Can not get the data";
|
||||
}).catch((response) => {
|
||||
self.error = 'Can not get the data';
|
||||
self.data = new DataToSend();
|
||||
self.covers_display = [];
|
||||
self.data_ori = self.data.clone();
|
||||
self.coversDisplay = [];
|
||||
self.dataOri = self.data.clone();
|
||||
self.updateNeedSend();
|
||||
self.itemIsNotFound = true;
|
||||
self.itemIsLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
onChangeType(_value:any):void {
|
||||
console.log("Change requested of type ... " + _value);
|
||||
this.data.type_id = _value;
|
||||
if (this.data.type_id == undefined) {
|
||||
this.data.type_id = null;
|
||||
|
||||
onChangeType(value:any):void {
|
||||
console.log(`Change requested of type ... ${value}`);
|
||||
this.data.typeId = value;
|
||||
if(this.data.typeId === undefined) {
|
||||
this.data.typeId = null;
|
||||
}
|
||||
this.data.series_id = null;
|
||||
this.data.season_id = null;
|
||||
this.listSeries = [{value: undefined, label: '---'}];
|
||||
this.listSeason = [{value: undefined, label: '---'}];
|
||||
this.data.seriesId = null;
|
||||
this.data.seasonId = null;
|
||||
this.listSeries = [ { value: undefined, label: '---' } ];
|
||||
this.listSeason = [ { value: undefined, label: '---' } ];
|
||||
let self = this;
|
||||
this.updateNeedSend();
|
||||
if (this.data.type_id != undefined) {
|
||||
self.typeService.getSubSeries(this.data.type_id, ["id", "name"])
|
||||
.then(function(response2) {
|
||||
for(let iii= 0; iii < response2.length; iii++) {
|
||||
self.listSeries.push({value: response2[iii].id, label: response2[iii].name});
|
||||
if(this.data.typeId !== undefined) {
|
||||
self.typeService.getSubSeries(this.data.typeId, [ 'id', 'name' ])
|
||||
.then((response2) => {
|
||||
for(let iii = 0; iii < response2.length; iii++) {
|
||||
self.listSeries.push({ value: response2[iii].id, label: response2[iii].name });
|
||||
}
|
||||
}).catch(function(response2) {
|
||||
console.log("get response22 : " + JSON.stringify(response2, null, 2));
|
||||
}).catch((response2) => {
|
||||
console.log(`get response22 : ${ JSON.stringify(response2, null, 2)}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onChangeUniverse(_value:any):void {
|
||||
this.data.universe_id = _value;
|
||||
|
||||
onChangeUniverse(value:any):void {
|
||||
this.data.universeId = value;
|
||||
this.updateNeedSend();
|
||||
}
|
||||
|
||||
onChangeSeries(_value:any):void {
|
||||
this.data.series_id = _value;
|
||||
if (this.data.series_id === undefined) {
|
||||
this.data.series_id = null;
|
||||
|
||||
onChangeSeries(value:any):void {
|
||||
this.data.seriesId = value;
|
||||
if(this.data.seriesId === undefined) {
|
||||
this.data.seriesId = null;
|
||||
}
|
||||
this.data.season_id = null;
|
||||
this.listSeason = [{value: undefined, label: '---'}];
|
||||
this.data.seasonId = null;
|
||||
this.listSeason = [ { value: undefined, label: '---' } ];
|
||||
let self = this;
|
||||
if (this.data.series_id != undefined) {
|
||||
self.seriesService.getSeason(this.data.series_id, ["id", "name"])
|
||||
.then(function(response3) {
|
||||
for(let iii= 0; iii < response3.length; iii++) {
|
||||
self.listSeason.push({value: response3[iii].id, label: "season " + response3[iii].name});
|
||||
if(this.data.seriesId !== undefined) {
|
||||
self.seriesService.getSeason(this.data.seriesId, [ 'id', 'name' ])
|
||||
.then((response3) => {
|
||||
for(let iii = 0; iii < response3.length; iii++) {
|
||||
self.listSeason.push({ value: response3[iii].id, label: `season ${ response3[iii].name}` });
|
||||
}
|
||||
}).catch(function(response3) {
|
||||
console.log("get response22 : " + JSON.stringify(response3, null, 2));
|
||||
}).catch((response3) => {
|
||||
console.log(`get response22 : ${ JSON.stringify(response3, null, 2)}`);
|
||||
});
|
||||
}
|
||||
this.updateNeedSend();
|
||||
}
|
||||
onChangeSeason(_value:any):void {
|
||||
this.data.season_id = _value;
|
||||
onChangeSeason(value:any):void {
|
||||
this.data.seasonId = value;
|
||||
this.updateNeedSend();
|
||||
}
|
||||
|
||||
onName(_value:any):void {
|
||||
this.data.name = _value;
|
||||
|
||||
onName(value:any):void {
|
||||
this.data.name = value;
|
||||
this.updateNeedSend();
|
||||
}
|
||||
|
||||
onDescription(_value:any):void {
|
||||
if (_value.length == 0) {
|
||||
|
||||
onDescription(value:any):void {
|
||||
if(value.length === 0) {
|
||||
this.data.description = null;
|
||||
} else {
|
||||
this.data.description = _value;
|
||||
this.data.description = value;
|
||||
}
|
||||
this.updateNeedSend();
|
||||
}
|
||||
onDate(_value:any):void {
|
||||
if (_value.value.length > 4) {
|
||||
_value.value = this.data.time;
|
||||
onDate(value:any):void {
|
||||
if(value.value.length > 4) {
|
||||
value.value = this.data.time;
|
||||
} 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.updateNeedSend();
|
||||
}
|
||||
|
||||
onEpisode(_value:any):void {
|
||||
if (_value.value.length > 4) {
|
||||
_value.value = this.data.episode;
|
||||
|
||||
onEpisode(value:any):void {
|
||||
if(value.value.length > 4) {
|
||||
value.value = this.data.episode;
|
||||
} else {
|
||||
this.data.episode = parseInt(_value.value, 10);
|
||||
this.data.episode = parseInt(value.value, 10);
|
||||
}
|
||||
this.updateNeedSend();
|
||||
}
|
||||
|
||||
|
||||
sendValues():void {
|
||||
console.log("send new values....");
|
||||
let data = {}
|
||||
if (this.data.name != this.data_ori.name) {
|
||||
data["name"] = this.data.name;
|
||||
console.log('send new values....');
|
||||
let data:any = {};
|
||||
if(this.data.name !== this.dataOri.name) {
|
||||
data.name = this.data.name;
|
||||
}
|
||||
if (this.data.description != this.data_ori.description) {
|
||||
if (this.data.description == undefined) {
|
||||
data["description"] = null;
|
||||
if(this.data.description !== this.dataOri.description) {
|
||||
if(this.data.description === undefined) {
|
||||
data.description = null;
|
||||
} else {
|
||||
data["description"] = this.data.description;
|
||||
data.description = this.data.description;
|
||||
}
|
||||
}
|
||||
if (this.data.episode != this.data_ori.episode) {
|
||||
data["episode"] = this.data.episode;
|
||||
if(this.data.episode !== this.dataOri.episode) {
|
||||
data.episode = this.data.episode;
|
||||
}
|
||||
if (this.data.time != this.data_ori.time) {
|
||||
data["time"] = this.data.time;
|
||||
if(this.data.time !== this.dataOri.time) {
|
||||
data.time = this.data.time;
|
||||
}
|
||||
if (this.data.type_id != this.data_ori.type_id) {
|
||||
if (this.data.type_id == undefined) {
|
||||
data["type_id"] = null;
|
||||
if(this.data.typeId !== this.dataOri.typeId) {
|
||||
if(this.data.typeId === undefined) {
|
||||
data.typeId = null;
|
||||
} 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.universe_id == undefined) {
|
||||
data["universe_id"] = null;
|
||||
if(this.data.universeId !== this.dataOri.universeId) {
|
||||
if(this.data.universeId === undefined) {
|
||||
data.universeId = null;
|
||||
} 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.series_id == undefined) {
|
||||
data["series_id"] = null;
|
||||
if(this.data.seriesId !== this.dataOri.seriesId) {
|
||||
if(this.data.seriesId === undefined) {
|
||||
data.seriesId = null;
|
||||
} 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.season_id == undefined) {
|
||||
data["season_id"] = null;
|
||||
if(this.data.seasonId !== this.dataOri.seasonId) {
|
||||
if(this.data.seasonId === undefined) {
|
||||
data.seasonId = null;
|
||||
} else {
|
||||
data["season_id"] = this.data.season_id;
|
||||
data.seasonId = this.data.seasonId;
|
||||
}
|
||||
}
|
||||
let tmpp = this.data.clone();
|
||||
let self = this;
|
||||
this.videoService.put(this.id_video, data)
|
||||
.then(function(response3) {
|
||||
self.data_ori = tmpp;
|
||||
this.videoService.put(this.idVideo, data)
|
||||
.then((response3) => {
|
||||
self.dataOri = tmpp;
|
||||
self.updateNeedSend();
|
||||
}).catch(function(response3) {
|
||||
console.log("get response22 : " + JSON.stringify(response3, null, 2));
|
||||
}).catch((response3) => {
|
||||
console.log(`get response22 : ${ JSON.stringify(response3, null, 2)}`);
|
||||
self.updateNeedSend();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// At the drag drop area
|
||||
// (drop)="onDropFile($event)"
|
||||
onDropFile(_event: DragEvent) {
|
||||
_event.preventDefault();
|
||||
//TODO : this.uploadFile(_event.dataTransfer.files[0]);
|
||||
console.log("error in drag & drop ...");
|
||||
onDropFile(event: DragEvent) {
|
||||
event.preventDefault();
|
||||
// this.uploadFile(event.dataTransfer.files[0]);
|
||||
console.log('error in drag & drop ...');
|
||||
}
|
||||
|
||||
|
||||
// At the drag drop area
|
||||
// (dragover)="onDragOverFile($event)"
|
||||
onDragOverFile(_event) {
|
||||
_event.stopPropagation();
|
||||
_event.preventDefault();
|
||||
onDragOverFile(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
|
||||
// At the file input element
|
||||
// (change)="selectFile($event)"
|
||||
onChangeCover(_value:any):void {
|
||||
this.selectedFiles = _value.files
|
||||
onChangeCover(value:any):void {
|
||||
this.selectedFiles = value.files;
|
||||
this.coverFile = this.selectedFiles[0];
|
||||
console.log("select file " + this.coverFile.name);
|
||||
console.log(`select file ${ this.coverFile.name}`);
|
||||
this.uploadCover(this.coverFile);
|
||||
this.updateNeedSend();
|
||||
}
|
||||
|
||||
uploadCover(_file:File) {
|
||||
if (_file == undefined) {
|
||||
console.log("No file selected!");
|
||||
|
||||
uploadCover(file?:File) {
|
||||
if(file === undefined) {
|
||||
console.log('No file selected!');
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
// clean upload labels*
|
||||
this.upload.clear();
|
||||
// display the upload pop-in
|
||||
this.popInService.open("popin-upload-progress");
|
||||
this.videoService.uploadCover(_file, this.id_video, function(count, total) {
|
||||
this.popInService.open('popin-upload-progress');
|
||||
this.videoService.uploadCover(file, this.idVideo, (count, total) => {
|
||||
self.upload.mediaSendSize = count;
|
||||
self.upload.mediaSize = total;
|
||||
})
|
||||
.then(function (response:any) {
|
||||
console.log("get response of cover : " + JSON.stringify(response, null, 2));
|
||||
self.upload.result = "Cover added done";
|
||||
// TODO: we retrive the whiole media ==> update data ...
|
||||
self.updateCoverList(response.covers);
|
||||
}).catch(function (response:any) {
|
||||
//self.error = "Can not get the data";
|
||||
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);
|
||||
});
|
||||
.then((response:any) => {
|
||||
console.log(`get response of cover : ${ JSON.stringify(response, null, 2)}`);
|
||||
self.upload.result = 'Cover added done';
|
||||
// we retrive the whiole media ==> update data ...
|
||||
self.updateCoverList(response.covers);
|
||||
}).catch((response:any) => {
|
||||
// self.error = "Can not get the data";
|
||||
console.log('Can not add the cover in the video...');
|
||||
self.upload.error = `Error in the upload of the cover...${ JSON.stringify(response, null, 2)}`;
|
||||
});
|
||||
}
|
||||
|
||||
removeCover(_id:number) {
|
||||
removeCover(id:number) {
|
||||
this.cleanConfirm();
|
||||
this.confirmDeleteComment = "Delete the cover ID: " + _id;
|
||||
this.confirmDeleteImageUrl = this.seriesService.getCoverThumbnailUrl(_id);
|
||||
this.deleteCoverId = _id;
|
||||
this.popInService.open("popin-delete-confirm");
|
||||
this.confirmDeleteComment = `Delete the cover ID: ${ id}`;
|
||||
this.confirmDeleteImageUrl = this.seriesService.getCoverThumbnailUrl(id);
|
||||
this.deleteCoverId = id;
|
||||
this.popInService.open('popin-delete-confirm');
|
||||
}
|
||||
removeCoverAfterConfirm(_id:number) {
|
||||
console.log("Request remove cover: " + _id);
|
||||
removeCoverAfterConfirm(id:number) {
|
||||
console.log(`Request remove cover: ${ id}`);
|
||||
let self = this;
|
||||
this.videoService.deleteCover(this.id_video, _id)
|
||||
.then(function (response:any) {
|
||||
console.log("get response of remove cover : " + JSON.stringify(response, null, 2));
|
||||
self.upload.result = "Cover remove done";
|
||||
// TODO: we retrive the whiole media ==> update data ...
|
||||
this.videoService.deleteCover(this.idVideo, id)
|
||||
.then((response:any) => {
|
||||
console.log(`get response of remove cover : ${ JSON.stringify(response, null, 2)}`);
|
||||
self.upload.result = 'Cover remove done';
|
||||
// we retrive the whiole media ==> update data ...
|
||||
self.updateCoverList(response.covers);
|
||||
}).catch(function (response:any) {
|
||||
//self.error = "Can not get the data";
|
||||
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);
|
||||
}).catch((response:any) => {
|
||||
// self.error = "Can not get the data";
|
||||
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)}`;
|
||||
});
|
||||
}
|
||||
removeItem() {
|
||||
console.log("Request remove Media...");
|
||||
console.log('Request remove Media...');
|
||||
this.cleanConfirm();
|
||||
this.confirmDeleteComment = "Delete the Media: " + this.id_video;
|
||||
this.deleteMediaId = this.id_video;
|
||||
this.popInService.open("popin-delete-confirm");
|
||||
this.confirmDeleteComment = `Delete the Media: ${ this.idVideo}`;
|
||||
this.deleteMediaId = this.idVideo;
|
||||
this.popInService.open('popin-delete-confirm');
|
||||
}
|
||||
removeItemAfterConfirm(_id:number) {
|
||||
removeItemAfterConfirm(id:number) {
|
||||
let self = this;
|
||||
this.videoService.delete(_id)
|
||||
.then(function(response3) {
|
||||
//self.data_ori = tmpp;
|
||||
//self.updateNeedSend();
|
||||
this.videoService.delete(id)
|
||||
.then((response3) => {
|
||||
// self.dataOri = tmpp;
|
||||
// self.updateNeedSend();
|
||||
self.itemIsRemoved = true;
|
||||
}).catch(function(response3) {
|
||||
//self.updateNeedSend();
|
||||
}).catch((response3) => {
|
||||
// self.updateNeedSend();
|
||||
});
|
||||
}
|
||||
|
||||
eventPopUpSeason(_event: string): void {
|
||||
console.log("GET event: " + _event);
|
||||
this.popInService.close("popin-new-season");
|
||||
|
||||
eventPopUpSeason(event: string): void {
|
||||
console.log(`GET event: ${ event}`);
|
||||
this.popInService.close('popin-new-season');
|
||||
}
|
||||
eventPopUpSeries(_event: string): void {
|
||||
console.log("GET event: " + _event);
|
||||
this.popInService.close("popin-new-series");
|
||||
eventPopUpSeries(event: string): void {
|
||||
console.log(`GET event: ${ event}`);
|
||||
this.popInService.close('popin-new-series');
|
||||
}
|
||||
eventPopUpType(_event: string): void {
|
||||
console.log("GET event: " + _event);
|
||||
this.popInService.close("popin-new-type");
|
||||
eventPopUpType(event: string): void {
|
||||
console.log(`GET event: ${ event}`);
|
||||
this.popInService.close('popin-new-type');
|
||||
}
|
||||
eventPopUpUniverse(_event: string): void {
|
||||
console.log("GET event: " + _event);
|
||||
this.popInService.close("popin-new-universe");
|
||||
eventPopUpUniverse(event: string): void {
|
||||
console.log(`GET event: ${ event}`);
|
||||
this.popInService.close('popin-new-universe');
|
||||
}
|
||||
|
||||
|
||||
newSeason(): void {
|
||||
console.log("Request new Season...");
|
||||
this.popInService.open("popin-new-season");
|
||||
console.log('Request new Season...');
|
||||
this.popInService.open('popin-new-season');
|
||||
}
|
||||
newSeries(): void {
|
||||
console.log("Request new Series...");
|
||||
this.popInService.open("popin-new-series");
|
||||
console.log('Request new Series...');
|
||||
this.popInService.open('popin-new-series');
|
||||
}
|
||||
newType(): void {
|
||||
console.log("Request new Type...");
|
||||
this.popInService.open("popin-create-type");
|
||||
console.log('Request new Type...');
|
||||
this.popInService.open('popin-create-type');
|
||||
}
|
||||
newUniverse() {
|
||||
console.log("Request new Universe...");
|
||||
this.popInService.open("popin-new-universe");
|
||||
console.log('Request new Universe...');
|
||||
this.popInService.open('popin-new-universe');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,17 +43,17 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<div class="episode" *ngIf="series_name!=null">
|
||||
<b>Series:</b> {{series_name}}
|
||||
<div class="episode" *ngIf="seriesName!=null">
|
||||
<b>Series:</b> {{seriesName}}
|
||||
</div>
|
||||
<div class="episode" *ngIf="season_name!=null">
|
||||
<b>Season:</b> {{season_name}}
|
||||
<div class="episode" *ngIf="seasonName!=null">
|
||||
<b>Season:</b> {{seasonName}}
|
||||
</div>
|
||||
<div class="episode" *ngIf="episode!=null">
|
||||
<b>Episode:</b> {{episode}}
|
||||
</div>
|
||||
<div class="episode">
|
||||
<b>generated_name:</b> {{generated_name}}
|
||||
<b>generatedName:</b> {{generatedName}}
|
||||
</div>
|
||||
<div class="description">
|
||||
{{description}}
|
||||
@ -65,7 +65,7 @@
|
||||
(mousemove)="startHideTimer()"
|
||||
(fullscreenchange)="onFullscreenChange($event)">
|
||||
<div class="video-elem">
|
||||
<video src="{{video_source}}/{{generated_name}}"
|
||||
<video src="{{videoSource}}/{{generatedName}}"
|
||||
#videoPlayer
|
||||
preload
|
||||
(play)="changeStateToPlay()"
|
||||
@ -77,7 +77,7 @@
|
||||
autoplay
|
||||
(ended)="onVideoEnded()"
|
||||
><!-- 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>
|
||||
</div>
|
||||
<div class="controls" *ngIf="!displayNeedHide || !isPlaying">
|
||||
|
@ -5,9 +5,7 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { Location } from '@angular/common';
|
||||
import { interval } from 'rxjs';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { fadeInAnimation } from '../../_animations/index';
|
||||
import { HttpWrapperService } from '../../service/http-wrapper';
|
||||
import { VideoService } from '../../service/video';
|
||||
@ -18,8 +16,8 @@ import { ArianeService } from '../../service/ariane';
|
||||
@Component({
|
||||
selector: 'app-video',
|
||||
templateUrl: './video.html',
|
||||
styleUrls: ['./video.less'],
|
||||
animations: [fadeInAnimation],
|
||||
styleUrls: [ './video.less' ],
|
||||
animations: [ fadeInAnimation ],
|
||||
host: { '[@fadeInAnimation]': '' }
|
||||
})
|
||||
|
||||
@ -27,57 +25,57 @@ export class VideoScene implements OnInit {
|
||||
videoGlobal:any;
|
||||
@ViewChild('globalVideoElement')
|
||||
set mainDivEl(el: ElementRef) {
|
||||
if (el != null) {
|
||||
if(el !== null) {
|
||||
this.videoGlobal = el.nativeElement;
|
||||
}
|
||||
}
|
||||
videoPlayer: HTMLVideoElement;
|
||||
@ViewChild('videoPlayer')
|
||||
set mainVideoEl(el: ElementRef) {
|
||||
if (el != null) {
|
||||
if(el !== null) {
|
||||
this.videoPlayer = el.nativeElement;
|
||||
}
|
||||
}
|
||||
videoCanva: any;
|
||||
@ViewChild('canvascreenshoot')
|
||||
set mainCanvaEl(el: ElementRef) {
|
||||
if (el != null) {
|
||||
if(el !== null) {
|
||||
this.videoCanva = el.nativeElement;
|
||||
}
|
||||
}
|
||||
haveNext = null;
|
||||
havePrevious = null;
|
||||
id_video:number = -1;
|
||||
idVideo:number = -1;
|
||||
|
||||
mediaIsNotFound:boolean = false;
|
||||
mediaIsLoading:boolean = true;
|
||||
error:string = "";
|
||||
|
||||
name:string = "";
|
||||
description:string = "";
|
||||
error:string = '';
|
||||
|
||||
name:string = '';
|
||||
description:string = '';
|
||||
episode:number = undefined;
|
||||
series_id:number = undefined;
|
||||
series_name:string = undefined;
|
||||
season_id:number = undefined;
|
||||
season_name:string = undefined;
|
||||
data_id:number = -1;
|
||||
seriesId:number = undefined;
|
||||
seriesName:string = undefined;
|
||||
seasonId:number = undefined;
|
||||
seasonName:string = undefined;
|
||||
dataId:number = -1;
|
||||
time:number = undefined;
|
||||
type_id:number = undefined;
|
||||
generated_name:string = "";
|
||||
video_source:string = "";
|
||||
typeId:number = undefined;
|
||||
generatedName:string = '';
|
||||
videoSource:string = '';
|
||||
cover:string = null;
|
||||
covers:Array<string> = [];
|
||||
|
||||
|
||||
playVideo:boolean = false;
|
||||
displayVolumeMenu:boolean = false;
|
||||
isPlaying:boolean = false;
|
||||
isFullScreen:boolean = false;
|
||||
currentTime:number = 0;
|
||||
currentTimeDisplay:string = "00";
|
||||
currentTimeDisplay:string = '00';
|
||||
duration:number = 0;
|
||||
durationDisplay:string = "00";
|
||||
durationDisplay:string = '00';
|
||||
volumeValue:number = 100;
|
||||
|
||||
|
||||
|
||||
displayNeedHide:boolean = false;
|
||||
timeLeft: number = 10;
|
||||
@ -85,77 +83,76 @@ export class VideoScene implements OnInit {
|
||||
startHideTimer() {
|
||||
this.displayNeedHide = false;
|
||||
this.timeLeft = 5;
|
||||
if (this.interval != null) {
|
||||
if(this.interval !== null) {
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.interval = setInterval(() => {
|
||||
console.log("periodic event: " + self.timeLeft);
|
||||
console.log(`periodic event: ${ self.timeLeft}`);
|
||||
if(self.timeLeft > 0) {
|
||||
self.timeLeft--;
|
||||
} else {
|
||||
clearInterval(self.interval);
|
||||
self.timeOutDetected();
|
||||
}
|
||||
},1000)
|
||||
}, 1000);
|
||||
}
|
||||
timeOutDetected() {
|
||||
console.log(" ==> stop timer");
|
||||
console.log(' ==> stop timer');
|
||||
this.displayNeedHide = true;
|
||||
clearInterval(this.interval);
|
||||
this.interval = null;
|
||||
}
|
||||
onRequireNext(_event: any) {
|
||||
console.log("generate next : " + this.haveNext.id);
|
||||
this.arianeService.navigateVideo(this.haveNext.id, _event.which==2, _event.ctrlKey);
|
||||
onRequireNext(event: any) {
|
||||
console.log(`generate next : ${ this.haveNext.id}`);
|
||||
this.arianeService.navigateVideo(this.haveNext.id, event.which === 2, event.ctrlKey);
|
||||
this.arianeService.setVideo(this.haveNext.id);
|
||||
}
|
||||
onRequirePrevious(_event: any) {
|
||||
console.log("generate previous : " + this.havePrevious.id);
|
||||
this.arianeService.navigateVideo(this.havePrevious.id, _event.which==2, _event.ctrlKey);
|
||||
onRequirePrevious(event: any) {
|
||||
console.log(`generate previous : ${ this.havePrevious.id}`);
|
||||
this.arianeService.navigateVideo(this.havePrevious.id, event.which === 2, event.ctrlKey);
|
||||
this.arianeService.setVideo(this.havePrevious.id);
|
||||
}
|
||||
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private locate: Location,
|
||||
private videoService: VideoService,
|
||||
private seriesService: SeriesService,
|
||||
private seasonService: SeasonService,
|
||||
private httpService: HttpWrapperService,
|
||||
private arianeService: ArianeService) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
generateName() {
|
||||
this.generated_name = "";
|
||||
if (this.series_name != undefined) {
|
||||
this.generated_name += this.series_name + "-";
|
||||
this.generatedName = '';
|
||||
if(this.seriesName !== undefined) {
|
||||
this.generatedName = `${this.generatedName }${this.seriesName }-`;
|
||||
}
|
||||
if (this.season_name != undefined) {
|
||||
if (this.season_name.length < 2) {
|
||||
this.generated_name += "s0" + this.season_name + "-";
|
||||
if(this.seasonName !== undefined) {
|
||||
if(this.seasonName.length < 2) {
|
||||
this.generatedName = `${this.generatedName }s0${ this.seasonName }-`;
|
||||
} else {
|
||||
this.generated_name += "s" + this.season_name + "-";
|
||||
this.generatedName = `${this.generatedName }s${ this.seasonName }-`;
|
||||
}
|
||||
}
|
||||
if (this.episode != undefined) {
|
||||
if (this.episode < 10) {
|
||||
this.generated_name += "e0" + this.episode + "-";
|
||||
if(this.episode !== undefined) {
|
||||
if(this.episode < 10) {
|
||||
this.generatedName = `${this.generatedName }e0${ this.episode }-`;
|
||||
} else {
|
||||
this.generated_name += "e" + this.episode + "-";
|
||||
this.generatedName = `${this.generatedName }e${ this.episode }-`;
|
||||
}
|
||||
}
|
||||
this.generated_name += this.name;
|
||||
this.generated_name = this.generated_name.replace(new RegExp("&", "g"), "_");
|
||||
this.generated_name = this.generated_name.replace(new RegExp("/", "g"), "_");
|
||||
this.generatedName = this.generatedName + this.name;
|
||||
this.generatedName = this.generatedName.replace(new RegExp('&', 'g'), '_');
|
||||
this.generatedName = this.generatedName.replace(new RegExp('/', 'g'), '_');
|
||||
}
|
||||
|
||||
|
||||
myPeriodicCheckFunction() {
|
||||
console.log("check ... ");
|
||||
console.log('check ... ');
|
||||
}
|
||||
changeMetadata() {
|
||||
console.log("list of the stream:");
|
||||
console.log('list of the stream:');
|
||||
|
||||
/*
|
||||
let captureStream = this.videoPlayer.audioTracks;
|
||||
for (let iii=0; iii < captureStream.length; iii++) {
|
||||
@ -169,7 +166,8 @@ export class VideoScene implements OnInit {
|
||||
*/
|
||||
}
|
||||
audioTracks(event) {
|
||||
console.log("list of the stream:" + event);
|
||||
console.log(`list of the stream:${ event}`);
|
||||
|
||||
/*
|
||||
let captureStream = this.videoPlayer.audioTracks;
|
||||
for (let iii=0; iii < captureStream.length; iii++) {
|
||||
@ -182,111 +180,111 @@ export class VideoScene implements OnInit {
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
let self = this;
|
||||
this.startHideTimer();
|
||||
this.arianeService.updateManual(this.route.snapshot.paramMap);
|
||||
this.id_video = this.arianeService.getVideoId();
|
||||
this.arianeService.video_change.subscribe(video_id => {
|
||||
console.log("Detect videoId change..." + video_id);
|
||||
self.id_video = video_id;
|
||||
self.updateDisplay();
|
||||
});
|
||||
this.idVideo = this.arianeService.getVideoId();
|
||||
this.arianeService.videoChange.subscribe((videoId) => {
|
||||
console.log(`Detect videoId change...${ videoId}`);
|
||||
self.idVideo = videoId;
|
||||
self.updateDisplay();
|
||||
});
|
||||
self.updateDisplay();
|
||||
}
|
||||
updateDisplay():void {
|
||||
updateDisplay():void {
|
||||
let self = this;
|
||||
self.haveNext = null;
|
||||
self.havePrevious = null;
|
||||
this.videoService.get(this.id_video)
|
||||
.then(function(response) {
|
||||
console.log("get response of video : " + JSON.stringify(response, null, 2));
|
||||
self.error = "";
|
||||
this.videoService.get(this.idVideo)
|
||||
.then((response) => {
|
||||
console.log(`get response of video : ${ JSON.stringify(response, null, 2)}`);
|
||||
self.error = '';
|
||||
self.name = response.name;
|
||||
self.description = response.description;
|
||||
self.episode = response.episode;
|
||||
self.series_id = response.series_id;
|
||||
self.season_id = response.season_id;
|
||||
self.data_id = response.data_id;
|
||||
self.seriesId = response.seriesId;
|
||||
self.seasonId = response.seasonId;
|
||||
self.dataId = response.dataId;
|
||||
self.time = response.time;
|
||||
self.generated_name = response.generated_name;
|
||||
if (self.data_id != -1) {
|
||||
self.video_source = self.httpService.createRESTCall("data/" + self.data_id);
|
||||
self.generatedName = response.generatedName;
|
||||
if(self.dataId !== -1) {
|
||||
self.videoSource = self.httpService.createRESTCall(`data/${ self.dataId}`);
|
||||
} 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;
|
||||
} else {
|
||||
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.generateName();
|
||||
if (self.series_id !== undefined && self.series_id !== null) {
|
||||
self.seriesService.get(self.series_id)
|
||||
.then(function(response) {
|
||||
self.series_name = response.name;
|
||||
if(self.seriesId !== undefined && self.seriesId !== null) {
|
||||
self.seriesService.get(self.seriesId)
|
||||
.then((response2) => {
|
||||
self.seriesName = response2.name;
|
||||
self.generateName();
|
||||
}).catch(function(response) {
|
||||
}).catch((response3) => {
|
||||
// nothing to do ...
|
||||
});
|
||||
}
|
||||
if (self.season_id !== undefined && self.season_id !== null) {
|
||||
self.seasonService.get(self.season_id)
|
||||
.then(function(response) {
|
||||
self.season_name = response.name;
|
||||
if(self.seasonId !== undefined && self.seasonId !== null) {
|
||||
self.seasonService.get(self.seasonId)
|
||||
.then((response4) => {
|
||||
self.seasonName = response4.name;
|
||||
self.generateName();
|
||||
}).catch(function(response) {
|
||||
}).catch((response5) => {
|
||||
// nothing to do ...
|
||||
});
|
||||
self.seasonService.getVideo(self.season_id)
|
||||
.then(function(response:any) {
|
||||
//console.log("saison property: " + JSON.stringify(response, null, 2));
|
||||
self.seasonService.getVideo(self.seasonId)
|
||||
.then((response6:any) => {
|
||||
// console.log("saison property: " + JSON.stringify(response, null, 2));
|
||||
self.haveNext = null;
|
||||
self.havePrevious = null;
|
||||
for (let iii=0; iii<response.length; iii++) {
|
||||
if (response[iii].episode === undefined || response[iii].episode === null) {
|
||||
for(let iii = 0; iii < response6.length; iii++) {
|
||||
if(response6[iii].episode === undefined || response6[iii].episode === null) {
|
||||
continue;
|
||||
}
|
||||
if (response[iii].episode < self.episode) {
|
||||
if (self.havePrevious === null) {
|
||||
self.havePrevious = response[iii];
|
||||
} else if (self.havePrevious.episode < response[iii].episode) {
|
||||
self.havePrevious = response[iii];
|
||||
if(response6[iii].episode < self.episode) {
|
||||
if(self.havePrevious === null) {
|
||||
self.havePrevious = response6[iii];
|
||||
} else if(self.havePrevious.episode < response6[iii].episode) {
|
||||
self.havePrevious = response6[iii];
|
||||
}
|
||||
} else if (response[iii].episode > self.episode) {
|
||||
if (self.haveNext === null) {
|
||||
self.haveNext = response[iii];
|
||||
} else if (self.haveNext.episode > response[iii].episode) {
|
||||
self.haveNext = response[iii];
|
||||
} else if(response6[iii].episode > self.episode) {
|
||||
if(self.haveNext === null) {
|
||||
self.haveNext = response6[iii];
|
||||
} else if(self.haveNext.episode > response6[iii].episode) {
|
||||
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;
|
||||
//console.log("display source " + self.video_source);
|
||||
//console.log("set transformed : " + JSON.stringify(self, null, 2));
|
||||
}).catch(function(response) {
|
||||
self.error = "Can not get the data";
|
||||
self.name = "";
|
||||
self.description = "";
|
||||
// console.log("display source " + self.videoSource);
|
||||
// console.log("set transformed : " + JSON.stringify(self, null, 2));
|
||||
}).catch((response8) => {
|
||||
self.error = 'Can not get the data';
|
||||
self.name = '';
|
||||
self.description = '';
|
||||
self.episode = undefined;
|
||||
self.series_id = undefined;
|
||||
self.season_id = undefined;
|
||||
self.data_id = -1;
|
||||
self.seriesId = undefined;
|
||||
self.seasonId = undefined;
|
||||
self.dataId = -1;
|
||||
self.time = undefined;
|
||||
self.generated_name = "";
|
||||
self.video_source = "";
|
||||
self.generatedName = '';
|
||||
self.videoSource = '';
|
||||
self.cover = null;
|
||||
self.series_name = undefined;
|
||||
self.season_name = undefined;
|
||||
self.seriesName = undefined;
|
||||
self.seasonName = undefined;
|
||||
self.mediaIsNotFound = true;
|
||||
self.mediaIsLoading = false;
|
||||
});
|
||||
@ -305,271 +303,271 @@ export class VideoScene implements OnInit {
|
||||
this.startHideTimer();
|
||||
this.playVideo = false;
|
||||
this.displayVolumeMenu = false;
|
||||
|
||||
/*
|
||||
if(this.isFullScreen == true) {
|
||||
if(this.isFullScreen === true) {
|
||||
this.isFullScreen = false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
changeStateToPlay() {
|
||||
this.isPlaying = true;
|
||||
if (this.isFullScreen === true) {
|
||||
if(this.isFullScreen === true) {
|
||||
this.onFullscreen();
|
||||
}
|
||||
}
|
||||
changeStateToPause() {
|
||||
this.isPlaying = false;
|
||||
}
|
||||
|
||||
|
||||
convertIndisplayTime(time:number) : string {
|
||||
let tmpp = parseInt("" + time);
|
||||
let heures = parseInt("" + (tmpp/3600));
|
||||
let tmpp = parseInt(`${ time}`, 10);
|
||||
let heures = parseInt(`${ tmpp / 3600}`, 10);
|
||||
tmpp = tmpp - heures * 3600;
|
||||
let minutes = parseInt("" + (tmpp/60));
|
||||
let minutes = parseInt(`${ tmpp / 60}`, 10);
|
||||
let seconds = tmpp - minutes * 60;
|
||||
let out = "";
|
||||
if (heures != 0) {
|
||||
out += heures + ":";
|
||||
let out = '';
|
||||
if(heures !== 0) {
|
||||
out = `${out }${heures }:`;
|
||||
}
|
||||
if (minutes >= 10) {
|
||||
out += minutes + ":";
|
||||
if(minutes >= 10) {
|
||||
out = `${out }${minutes }:`;
|
||||
} else {
|
||||
out += "0" + minutes + ":";
|
||||
out = `${out }0${ minutes }:`;
|
||||
}
|
||||
if (seconds >= 10) {
|
||||
out += seconds;
|
||||
if(seconds >= 10) {
|
||||
out = out + seconds;
|
||||
} else {
|
||||
out += "0" + seconds;
|
||||
out = `${out }0${ seconds}`;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
changeTimeupdate(currentTime: any) {
|
||||
//console.log("time change ");
|
||||
//console.log(" ==> " + this.videoPlayer.currentTime);
|
||||
// console.log("time change ");
|
||||
// console.log(" ==> " + this.videoPlayer.currentTime);
|
||||
this.currentTime = this.videoPlayer.currentTime;
|
||||
this.currentTimeDisplay = this.convertIndisplayTime(this.currentTime);
|
||||
//console.log(" ==> " + this.currentTimeDisplay);
|
||||
// console.log(" ==> " + this.currentTimeDisplay);
|
||||
}
|
||||
changeDurationchange(duration: any) {
|
||||
console.log("duration change ");
|
||||
console.log(" ==> " + this.videoPlayer.duration);
|
||||
console.log('duration change ');
|
||||
console.log(` ==> ${ this.videoPlayer.duration}`);
|
||||
this.duration = this.videoPlayer.duration;
|
||||
this.durationDisplay = this.convertIndisplayTime(this.duration);
|
||||
}
|
||||
|
||||
|
||||
onPlay() {
|
||||
console.log("play");
|
||||
console.log('play');
|
||||
this.startHideTimer();
|
||||
if (this.videoPlayer === null
|
||||
|| this.videoPlayer === undefined) {
|
||||
console.log("error element: " + this.videoPlayer);
|
||||
if(this.videoPlayer === null ||
|
||||
this.videoPlayer === undefined) {
|
||||
console.log(`error element: ${ this.videoPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.videoPlayer.volume = this.volumeValue/100;
|
||||
this.videoPlayer.volume = this.volumeValue / 100;
|
||||
this.videoPlayer.play();
|
||||
}
|
||||
|
||||
|
||||
onPause() {
|
||||
console.log("pause");
|
||||
console.log('pause');
|
||||
this.startHideTimer();
|
||||
if (this.videoPlayer === null
|
||||
|| this.videoPlayer === undefined) {
|
||||
console.log("error element: " + this.videoPlayer);
|
||||
if(this.videoPlayer === null ||
|
||||
this.videoPlayer === undefined) {
|
||||
console.log(`error element: ${ this.videoPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.videoPlayer.pause();
|
||||
}
|
||||
|
||||
onPauseToggle() {
|
||||
console.log("pause toggle ...");
|
||||
if (this.isPlaying == true) {
|
||||
console.log('pause toggle ...');
|
||||
if(this.isPlaying === true) {
|
||||
this.onPause();
|
||||
} else {
|
||||
this.onPlay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onStop() {
|
||||
console.log("stop");
|
||||
console.log('stop');
|
||||
this.startHideTimer();
|
||||
if (this.videoPlayer === null
|
||||
|| this.videoPlayer === undefined) {
|
||||
console.log("error element: " + this.videoPlayer);
|
||||
if(this.videoPlayer === null ||
|
||||
this.videoPlayer === undefined) {
|
||||
console.log(`error element: ${ this.videoPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.videoPlayer.pause();
|
||||
this.videoPlayer.currentTime = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
onBefore() {
|
||||
console.log("before");
|
||||
console.log('before');
|
||||
this.startHideTimer();
|
||||
}
|
||||
|
||||
|
||||
onNext() {
|
||||
console.log("next");
|
||||
console.log('next');
|
||||
this.startHideTimer();
|
||||
}
|
||||
|
||||
|
||||
seek(newValue:any) {
|
||||
console.log("seek " + newValue.value);
|
||||
console.log(`seek ${ newValue.value}`);
|
||||
this.startHideTimer();
|
||||
if (this.videoPlayer === null
|
||||
|| this.videoPlayer === undefined) {
|
||||
console.log("error element: " + this.videoPlayer);
|
||||
if(this.videoPlayer === null ||
|
||||
this.videoPlayer === undefined) {
|
||||
console.log(`error element: ${ this.videoPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.videoPlayer.currentTime = newValue.value;
|
||||
}
|
||||
|
||||
|
||||
onRewind() {
|
||||
console.log("rewind");
|
||||
console.log('rewind');
|
||||
this.startHideTimer();
|
||||
if (this.videoPlayer === null
|
||||
|| this.videoPlayer === undefined) {
|
||||
console.log("error element: " + this.videoPlayer);
|
||||
if(this.videoPlayer === null ||
|
||||
this.videoPlayer === undefined) {
|
||||
console.log(`error element: ${ this.videoPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.videoPlayer.currentTime = this.currentTime - 10;
|
||||
}
|
||||
|
||||
|
||||
onForward() {
|
||||
console.log("forward");
|
||||
console.log('forward');
|
||||
this.startHideTimer();
|
||||
if (this.videoPlayer === null
|
||||
|| this.videoPlayer === undefined) {
|
||||
console.log("error element: " + this.videoPlayer);
|
||||
if(this.videoPlayer === null ||
|
||||
this.videoPlayer === undefined) {
|
||||
console.log(`error element: ${ this.videoPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.videoPlayer.currentTime = this.currentTime + 10;
|
||||
}
|
||||
|
||||
|
||||
onMore() {
|
||||
console.log("more");
|
||||
console.log('more');
|
||||
this.startHideTimer();
|
||||
if (this.videoPlayer === null
|
||||
|| this.videoPlayer === undefined) {
|
||||
console.log("error element: " + this.videoPlayer);
|
||||
if(this.videoPlayer === null ||
|
||||
this.videoPlayer === undefined) {
|
||||
console.log(`error element: ${ this.videoPlayer}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
onFullscreen() {
|
||||
console.log("fullscreen");
|
||||
console.log('fullscreen');
|
||||
this.startHideTimer();
|
||||
if (this.videoGlobal === null
|
||||
|| this.videoGlobal === undefined) {
|
||||
console.log("error element: " + this.videoGlobal);
|
||||
if(this.videoGlobal === null ||
|
||||
this.videoGlobal === undefined) {
|
||||
console.log(`error element: ${ this.videoGlobal}`);
|
||||
return;
|
||||
}
|
||||
if (this.videoGlobal.requestFullscreen) {
|
||||
if(this.videoGlobal.requestFullscreen) {
|
||||
this.videoGlobal.requestFullscreen();
|
||||
} else if (this.videoGlobal.mozRequestFullScreen) {
|
||||
} else if(this.videoGlobal.mozRequestFullScreen) {
|
||||
this.videoGlobal.mozRequestFullScreen();
|
||||
} else if (this.videoGlobal.webkitRequestFullscreen) {
|
||||
} else if(this.videoGlobal.webkitRequestFullscreen) {
|
||||
this.videoGlobal.webkitRequestFullscreen();
|
||||
} else if (this.videoGlobal.msRequestFullscreen) {
|
||||
} else if(this.videoGlobal.msRequestFullscreen) {
|
||||
this.videoGlobal.msRequestFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onFullscreenExit() {
|
||||
this.onFullscreenExit22(document);
|
||||
}
|
||||
onFullscreenExit22(docc:any) {
|
||||
console.log("fullscreen EXIT");
|
||||
console.log('fullscreen EXIT');
|
||||
this.startHideTimer();
|
||||
if (this.videoGlobal === null
|
||||
|| this.videoGlobal === undefined) {
|
||||
console.log("error element: " + this.videoGlobal);
|
||||
if(this.videoGlobal === null ||
|
||||
this.videoGlobal === undefined) {
|
||||
console.log(`error element: ${ this.videoGlobal}`);
|
||||
return;
|
||||
}
|
||||
if (docc.exitFullscreen) {
|
||||
if(docc.exitFullscreen) {
|
||||
docc.exitFullscreen();
|
||||
} else if (docc.mozCancelFullScreen) {
|
||||
} else if(docc.mozCancelFullScreen) {
|
||||
docc.mozCancelFullScreen();
|
||||
} else if (docc.webkitExitFullscreen) {
|
||||
} else if(docc.webkitExitFullscreen) {
|
||||
docc.webkitExitFullscreen();
|
||||
} else if (docc.msExitFullscreen) {
|
||||
} else if(docc.msExitFullscreen) {
|
||||
docc.msExitFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onFullscreenChange() {
|
||||
this.onFullscreenChange22(document);
|
||||
}
|
||||
onFullscreenChange22(element:any) {
|
||||
var isInFullScreen = (element.fullscreenElement && element.fullscreenElement !== null) ||
|
||||
(element.webkitFullscreenElement && element.webkitFullscreenElement !== null) ||
|
||||
(element.mozFullScreenElement && element.mozFullScreenElement !== null) ||
|
||||
(element.msFullscreenElement && element.msFullscreenElement !== null);
|
||||
console.log("onFullscreenChange(" + isInFullScreen + ")");
|
||||
let isInFullScreen = element.fullscreenElement && element.fullscreenElement !== null ||
|
||||
element.webkitFullscreenElement && element.webkitFullscreenElement !== null ||
|
||||
element.mozFullScreenElement && element.mozFullScreenElement !== null ||
|
||||
element.msFullscreenElement && element.msFullscreenElement !== null;
|
||||
console.log(`onFullscreenChange(${ isInFullScreen })`);
|
||||
this.isFullScreen = isInFullScreen;
|
||||
}
|
||||
|
||||
|
||||
onVolumeMenu() {
|
||||
this.displayVolumeMenu = !this.displayVolumeMenu;
|
||||
this.startHideTimer();
|
||||
}
|
||||
|
||||
|
||||
onVolume(newValue:any) {
|
||||
console.log("onVolume " + newValue.value);
|
||||
console.log(`onVolume ${ newValue.value}`);
|
||||
this.startHideTimer();
|
||||
if (this.videoPlayer === null
|
||||
|| this.videoPlayer === undefined) {
|
||||
console.log("error element: " + this.videoPlayer);
|
||||
if(this.videoPlayer === null ||
|
||||
this.videoPlayer === undefined) {
|
||||
console.log(`error element: ${ this.videoPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.volumeValue = newValue.value;
|
||||
this.videoPlayer.volume = this.volumeValue/100;
|
||||
this.videoPlayer.muted=false;
|
||||
this.videoPlayer.volume = this.volumeValue / 100;
|
||||
this.videoPlayer.muted = false;
|
||||
}
|
||||
|
||||
|
||||
onVolumeMute() {
|
||||
this.startHideTimer();
|
||||
if (this.videoPlayer === null
|
||||
|| this.videoPlayer === undefined) {
|
||||
console.log("error element: " + this.videoPlayer);
|
||||
if(this.videoPlayer === null ||
|
||||
this.videoPlayer === undefined) {
|
||||
console.log(`error element: ${ this.videoPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.videoPlayer.muted=true;
|
||||
this.videoPlayer.muted = true;
|
||||
}
|
||||
|
||||
|
||||
onVolumeUnMute() {
|
||||
this.startHideTimer();
|
||||
if (this.videoPlayer === null
|
||||
|| this.videoPlayer === undefined) {
|
||||
console.log("error element: " + this.videoPlayer);
|
||||
return;
|
||||
}
|
||||
this.videoPlayer.muted=false;
|
||||
if(this.videoPlayer === null ||
|
||||
this.videoPlayer === undefined) {
|
||||
console.log(`error element: ${ this.videoPlayer}`);
|
||||
return;
|
||||
}
|
||||
this.videoPlayer.muted = false;
|
||||
}
|
||||
|
||||
onTakeScreenShoot() {
|
||||
this.startHideTimer();
|
||||
//const canvas = document.createElement("canvas");
|
||||
// const canvas = document.createElement("canvas");
|
||||
// scale the canvas accordingly
|
||||
this.videoCanva.width = this.videoPlayer.videoWidth;
|
||||
this.videoCanva.height = this.videoPlayer.videoHeight;
|
||||
// draw the video at that frame
|
||||
this.videoCanva.getContext('2d').drawImage(this.videoPlayer, 0, 0, this.videoCanva.width, this.videoCanva.height);
|
||||
//canvas.crossorigin="anonymous"
|
||||
// canvas.crossorigin="anonymous"
|
||||
// convert it and send it to the server
|
||||
let self = this;
|
||||
|
||||
this.videoCanva.toBlob(function(blob){
|
||||
self.videoService.uploadCoverBlob(blob, this.id_video);
|
||||
|
||||
this.videoCanva.toBlob((blob) => {
|
||||
self.videoService.uploadCoverBlob(blob, this.idVideo);
|
||||
}, 'image/jpeg', 0.95);
|
||||
|
||||
/*
|
||||
let tmpUrl = this.videoCanva.toDataURL('image/jpeg', 0.95);
|
||||
fetch(tmpUrl)
|
||||
.then(res => res.blob()) // Gets the response and returns it as a blob
|
||||
.then(blob => {
|
||||
self.videoService.uploadCoverBlob(blob, this.id_video);
|
||||
self.videoService.uploadCoverBlob(blob, this.idVideo);
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,9 +4,9 @@
|
||||
* @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 { UniverseService } from './universe';
|
||||
@ -16,370 +16,375 @@ import { VideoService } from './video';
|
||||
import { environment } from '../../environments/environment';
|
||||
|
||||
export class InputOrders {
|
||||
public type_id: number = null;
|
||||
public universe_id: number = null;
|
||||
public series_id: number = null;
|
||||
public season_id: number = null;
|
||||
public video_id: number = null;
|
||||
public typeId: number = null;
|
||||
public universeId: number = null;
|
||||
public seriesId: number = null;
|
||||
public seasonId: number = null;
|
||||
public videoId: number = null;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class ArianeService {
|
||||
|
||||
|
||||
public type_id: number = null;
|
||||
public type_name: string = null;
|
||||
@Output() type_change: EventEmitter<number> = new EventEmitter();
|
||||
|
||||
public universe_id: number = null;
|
||||
public universe_name: string = null;
|
||||
@Output() universe_change: EventEmitter<number> = new EventEmitter();
|
||||
|
||||
public series_id: number = null;
|
||||
public series_name: string = null;
|
||||
@Output() series_change: EventEmitter<number> = new EventEmitter();
|
||||
|
||||
public season_id: number = null;
|
||||
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,
|
||||
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 seriesId: number = null;
|
||||
public seriesName: string = null;
|
||||
@Output() seriesChange: EventEmitter<number> = new EventEmitter();
|
||||
|
||||
public seasonId: number = null;
|
||||
public seasonName: string = null;
|
||||
@Output() seasonChange: EventEmitter<number> = new EventEmitter();
|
||||
|
||||
public videoId: number = null;
|
||||
public videoName: string = null;
|
||||
@Output() videoChange: EventEmitter<number> = new EventEmitter();
|
||||
|
||||
constructor(private router: Router,
|
||||
private typeService: TypeService,
|
||||
private universeService: UniverseService,
|
||||
private seriesService: SeriesService,
|
||||
private seasonService: SeasonService,
|
||||
private videoService: VideoService) {
|
||||
console.log("Start ArianeService");
|
||||
console.log('Start ArianeService');
|
||||
}
|
||||
updateParams(params) {
|
||||
console.log("sparams " + params);
|
||||
console.log("sparams['type_id'] " + params['type_id']);
|
||||
if(params['type_id']) {
|
||||
this.setType(params['type_id'])
|
||||
} else {
|
||||
this.setType(null);
|
||||
}
|
||||
console.log(`sparams ${ params}`);
|
||||
console.log(`sparams['typeId'] ${ params.typeId}`);
|
||||
if(params.typeId) {
|
||||
this.setType(params.typeId);
|
||||
} else {
|
||||
this.setType(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
updateManual(params) {
|
||||
let type_id = params.get('type_id');
|
||||
if (type_id === null || type_id === undefined || type_id == "null" || type_id == "NULL" || type_id == "") {
|
||||
type_id = null;
|
||||
} else {
|
||||
type_id = parseInt(type_id)
|
||||
}
|
||||
console.log("type_id = " + type_id + " " + params.get('type_id'));
|
||||
|
||||
let universe_id = params.get('universe_id');
|
||||
if (universe_id === null || universe_id === undefined || universe_id == "null" || universe_id == "NULL" || universe_id == "") {
|
||||
universe_id = null;
|
||||
} else {
|
||||
universe_id = parseInt(universe_id)
|
||||
}
|
||||
console.log("universe_id = " + universe_id + " " + params.get('univers_id'));
|
||||
|
||||
let series_id = params.get('series_id');
|
||||
if (series_id === null || series_id === undefined || series_id == "null" || series_id == "NULL" || series_id == "") {
|
||||
series_id = null;
|
||||
} else {
|
||||
series_id = parseInt(series_id)
|
||||
}
|
||||
console.log("series_id = " + series_id + " " + params.get('series_id'));
|
||||
|
||||
let season_id = params.get('season_id');
|
||||
if (season_id === null || season_id === undefined || season_id == "null" || season_id == "NULL" || season_id == "") {
|
||||
season_id = null;
|
||||
} else {
|
||||
season_id = parseInt(season_id)
|
||||
}
|
||||
console.log("season_id = " + season_id + " " + params.get('season_id'));
|
||||
|
||||
let video_id = params.get('video_id');
|
||||
if (video_id === null || video_id === undefined || video_id == "null" || video_id == "NULL" || video_id == "") {
|
||||
video_id = null;
|
||||
} else {
|
||||
video_id = parseInt(video_id)
|
||||
}
|
||||
console.log("video_id = " + video_id + " " + params.get('video_id'));
|
||||
|
||||
this.setType(type_id);
|
||||
this.setUniverse(universe_id);
|
||||
this.setSeries(series_id);
|
||||
this.setSeason(season_id);
|
||||
this.setVideo(video_id);
|
||||
let typeId = params.get('typeId');
|
||||
if(typeId === null || typeId === undefined || typeId === 'null' || typeId === 'NULL' || typeId === '') {
|
||||
typeId = null;
|
||||
} else {
|
||||
typeId = parseInt(typeId, 10);
|
||||
}
|
||||
console.log(`typeId = ${ typeId } ${ params.get('typeId')}`);
|
||||
|
||||
let universeId = params.get('universeId');
|
||||
if(universeId === null || universeId === undefined || universeId === 'null' || universeId === 'NULL' || universeId === '') {
|
||||
universeId = null;
|
||||
} else {
|
||||
universeId = parseInt(universeId, 10);
|
||||
}
|
||||
console.log(`universeId = ${ universeId } ${ params.get('universId')}`);
|
||||
|
||||
let seriesId = params.get('seriesId');
|
||||
if(seriesId === null || seriesId === undefined || seriesId === 'null' || seriesId === 'NULL' || seriesId === '') {
|
||||
seriesId = null;
|
||||
} else {
|
||||
seriesId = parseInt(seriesId, 10);
|
||||
}
|
||||
console.log(`seriesId = ${ seriesId } ${ params.get('seriesId')}`);
|
||||
|
||||
let seasonId = params.get('seasonId');
|
||||
if(seasonId === null || seasonId === undefined || seasonId === 'null' || seasonId === 'NULL' || seasonId === '') {
|
||||
seasonId = null;
|
||||
} else {
|
||||
seasonId = parseInt(seasonId, 10);
|
||||
}
|
||||
console.log(`seasonId = ${ seasonId } ${ params.get('seasonId')}`);
|
||||
|
||||
let videoId = params.get('videoId');
|
||||
if(videoId === null || videoId === undefined || videoId === 'null' || videoId === 'NULL' || videoId === '') {
|
||||
videoId = null;
|
||||
} else {
|
||||
videoId = parseInt(videoId, 10);
|
||||
}
|
||||
console.log(`videoId = ${ videoId } ${ params.get('videoId')}`);
|
||||
|
||||
this.setType(typeId);
|
||||
this.setUniverse(universeId);
|
||||
this.setSeries(seriesId);
|
||||
this.setSeason(seasonId);
|
||||
this.setVideo(videoId);
|
||||
}
|
||||
reset():void {
|
||||
this.type_id = null;
|
||||
this.type_name = null;
|
||||
this.type_change.emit(this.type_id);
|
||||
this.universe_id = null;
|
||||
this.universe_name = null;
|
||||
this.universe_change.emit(this.universe_id);
|
||||
this.series_id = null;
|
||||
this.series_name = null;
|
||||
this.series_change.emit(this.series_id);
|
||||
this.season_id = null;
|
||||
this.season_name = null;
|
||||
this.season_change.emit(this.season_id);
|
||||
this.video_id = null;
|
||||
this.video_name = null;
|
||||
this.video_change.emit(this.video_id);
|
||||
this.typeId = null;
|
||||
this.typeName = null;
|
||||
this.typeChange.emit(this.typeId);
|
||||
this.universeId = null;
|
||||
this.universeName = null;
|
||||
this.universeChange.emit(this.universeId);
|
||||
this.seriesId = null;
|
||||
this.seriesName = null;
|
||||
this.seriesChange.emit(this.seriesId);
|
||||
this.seasonId = null;
|
||||
this.seasonName = null;
|
||||
this.seasonChange.emit(this.seasonId);
|
||||
this.videoId = null;
|
||||
this.videoName = null;
|
||||
this.videoChange.emit(this.videoId);
|
||||
}
|
||||
|
||||
/*
|
||||
getCurrentRoute():InputOrders {
|
||||
let out = new InputOrders()
|
||||
out.type_id = parseInt(this.route.snapshot.paramMap.get('type_id'));
|
||||
if (out.type_id == 0){
|
||||
out.type_id = undefined;
|
||||
out.typeId = parseInt(this.route.snapshot.paramMap.get('typeId'));
|
||||
if (out.typeId === 0){
|
||||
out.typeId = undefined;
|
||||
}
|
||||
out.universe_id = parseInt(this.route.snapshot.paramMap.get('univers_id'));
|
||||
if (out.universe_id == 0){
|
||||
out.universe_id = undefined;
|
||||
out.universeId = parseInt(this.route.snapshot.paramMap.get('universId'));
|
||||
if (out.universeId === 0){
|
||||
out.universeId = undefined;
|
||||
}
|
||||
out.series_id = parseInt(this.route.snapshot.paramMap.get('series_id'));
|
||||
if (out.series_id == 0){
|
||||
out.series_id = undefined;
|
||||
out.seriesId = parseInt(this.route.snapshot.paramMap.get('seriesId'));
|
||||
if (out.seriesId === 0){
|
||||
out.seriesId = undefined;
|
||||
}
|
||||
out.season_id = parseInt(this.route.snapshot.paramMap.get('season_id'));
|
||||
if (out.season_id == 0){
|
||||
out.season_id = undefined;
|
||||
out.seasonId = parseInt(this.route.snapshot.paramMap.get('seasonId'));
|
||||
if (out.seasonId === 0){
|
||||
out.seasonId = undefined;
|
||||
}
|
||||
out.video_id = parseInt(this.route.snapshot.paramMap.get('video_id'));
|
||||
if (out.video_id == 0){
|
||||
out.video_id = undefined;
|
||||
out.videoId = parseInt(this.route.snapshot.paramMap.get('videoId'));
|
||||
if (out.videoId === 0){
|
||||
out.videoId = undefined;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
routeTo(_data:InputOrders, _destination:string = null) {
|
||||
|
||||
routeTo(data:InputOrders, destination:string = null) {
|
||||
routeTo = ""
|
||||
//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 {
|
||||
if (this.type_id == _id) {
|
||||
return;
|
||||
}
|
||||
if (_id === undefined) {
|
||||
return;
|
||||
}
|
||||
this.type_id = _id;
|
||||
this.type_name = "??--??";
|
||||
if (this.type_id === null) {
|
||||
this.type_change.emit(this.type_id);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.typeService.get(_id)
|
||||
.then(function(response) {
|
||||
self.type_name = response.name
|
||||
self.type_change.emit(self.type_id);
|
||||
}).catch(function(response) {
|
||||
self.type_change.emit(self.type_id);
|
||||
});
|
||||
|
||||
setType(id:number):void {
|
||||
if(this.typeId === id) {
|
||||
return;
|
||||
}
|
||||
if(id === undefined) {
|
||||
return;
|
||||
}
|
||||
this.typeId = id;
|
||||
this.typeName = '??--??';
|
||||
if(this.typeId === null) {
|
||||
this.typeChange.emit(this.typeId);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.typeService.get(id)
|
||||
.then((response) => {
|
||||
self.typeName = response.name;
|
||||
self.typeChange.emit(self.typeId);
|
||||
}).catch((response) => {
|
||||
self.typeChange.emit(self.typeId);
|
||||
});
|
||||
}
|
||||
getTypeId():number {
|
||||
return this.type_id;
|
||||
return this.typeId;
|
||||
}
|
||||
getTypeName():string {
|
||||
return this.type_name;
|
||||
return this.typeName;
|
||||
}
|
||||
|
||||
setUniverse(_id:number) {
|
||||
if (this.universe_id == _id) {
|
||||
return;
|
||||
}
|
||||
if (_id === undefined) {
|
||||
return;
|
||||
}
|
||||
this.universe_id = _id;
|
||||
this.universe_name = "??--??";
|
||||
if (this.universe_id === null) {
|
||||
this.universe_change.emit(this.universe_id);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.universeService.get(_id)
|
||||
.then(function(response) {
|
||||
self.universe_name = response.number
|
||||
self.universe_change.emit(self.universe_id);
|
||||
}).catch(function(response) {
|
||||
self.universe_change.emit(self.universe_id);
|
||||
});
|
||||
|
||||
setUniverse(id:number) {
|
||||
if(this.universeId === id) {
|
||||
return;
|
||||
}
|
||||
if(id === undefined) {
|
||||
return;
|
||||
}
|
||||
this.universeId = id;
|
||||
this.universeName = '??--??';
|
||||
if(this.universeId === null) {
|
||||
this.universeChange.emit(this.universeId);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.universeService.get(id)
|
||||
.then((response) => {
|
||||
self.universeName = response.number;
|
||||
self.universeChange.emit(self.universeId);
|
||||
}).catch((response) => {
|
||||
self.universeChange.emit(self.universeId);
|
||||
});
|
||||
}
|
||||
getUniverseId():number {
|
||||
return this.universe_id;
|
||||
return this.universeId;
|
||||
}
|
||||
getUniverseName():string {
|
||||
return this.universe_name;
|
||||
return this.universeName;
|
||||
}
|
||||
|
||||
setSeries(_id:number):void {
|
||||
if (this.series_id == _id) {
|
||||
return;
|
||||
}
|
||||
if (_id === undefined) {
|
||||
return;
|
||||
}
|
||||
this.series_id = _id;
|
||||
this.series_name = "??--??";
|
||||
if (this.series_id === null) {
|
||||
this.series_change.emit(this.series_id);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.seriesService.get(_id)
|
||||
.then(function(response) {
|
||||
self.series_name = response.name
|
||||
self.series_change.emit(self.series_id);
|
||||
}).catch(function(response) {
|
||||
self.series_change.emit(self.series_id);
|
||||
});
|
||||
|
||||
setSeries(id:number):void {
|
||||
if(this.seriesId === id) {
|
||||
return;
|
||||
}
|
||||
if(id === undefined) {
|
||||
return;
|
||||
}
|
||||
this.seriesId = id;
|
||||
this.seriesName = '??--??';
|
||||
if(this.seriesId === null) {
|
||||
this.seriesChange.emit(this.seriesId);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.seriesService.get(id)
|
||||
.then((response) => {
|
||||
self.seriesName = response.name;
|
||||
self.seriesChange.emit(self.seriesId);
|
||||
}).catch((response) => {
|
||||
self.seriesChange.emit(self.seriesId);
|
||||
});
|
||||
}
|
||||
getSeriesId():number {
|
||||
return this.series_id;
|
||||
return this.seriesId;
|
||||
}
|
||||
getSeriesName():string {
|
||||
return this.series_name;
|
||||
return this.seriesName;
|
||||
}
|
||||
|
||||
setSeason(_id:number):void {
|
||||
if (this.season_id == _id) {
|
||||
return;
|
||||
}
|
||||
if (_id === undefined) {
|
||||
return;
|
||||
}
|
||||
this.season_id = _id;
|
||||
this.season_name = "??--??";
|
||||
if (this.season_id === null) {
|
||||
this.season_change.emit(this.season_id);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.seasonService.get(_id)
|
||||
.then(function(response) {
|
||||
//self.setSeries(response.series_id);
|
||||
self.season_name = response.name
|
||||
self.season_change.emit(self.season_id);
|
||||
}).catch(function(response) {
|
||||
self.season_change.emit(self.season_id);
|
||||
});
|
||||
|
||||
setSeason(id:number):void {
|
||||
if(this.seasonId === id) {
|
||||
return;
|
||||
}
|
||||
if(id === undefined) {
|
||||
return;
|
||||
}
|
||||
this.seasonId = id;
|
||||
this.seasonName = '??--??';
|
||||
if(this.seasonId === null) {
|
||||
this.seasonChange.emit(this.seasonId);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.seasonService.get(id)
|
||||
.then((response) => {
|
||||
// self.setSeries(response.seriesId);
|
||||
self.seasonName = response.name;
|
||||
self.seasonChange.emit(self.seasonId);
|
||||
}).catch((response) => {
|
||||
self.seasonChange.emit(self.seasonId);
|
||||
});
|
||||
}
|
||||
getSeasonId():number {
|
||||
return this.season_id;
|
||||
return this.seasonId;
|
||||
}
|
||||
getSeasonName():string {
|
||||
return this.season_name;
|
||||
return this.seasonName;
|
||||
}
|
||||
|
||||
setVideo(_id:number):void {
|
||||
if (this.video_id == _id) {
|
||||
return;
|
||||
}
|
||||
if (_id === undefined) {
|
||||
return;
|
||||
}
|
||||
this.video_id = _id;
|
||||
this.video_name = "??--??";
|
||||
if (this.video_id === null) {
|
||||
this.video_change.emit(this.video_id);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.videoService.get(_id)
|
||||
.then(function(response) {
|
||||
//self.setSeason(response.season_id);
|
||||
//self.setSeries(response.series_id);
|
||||
self.video_name = response.name;
|
||||
self.video_change.emit(self.video_id);
|
||||
}).catch(function(response) {
|
||||
self.video_change.emit(self.video_id);
|
||||
});
|
||||
|
||||
setVideo(id:number):void {
|
||||
if(this.videoId === id) {
|
||||
return;
|
||||
}
|
||||
if(id === undefined) {
|
||||
return;
|
||||
}
|
||||
this.videoId = id;
|
||||
this.videoName = '??--??';
|
||||
if(this.videoId === null) {
|
||||
this.videoChange.emit(this.videoId);
|
||||
return;
|
||||
}
|
||||
let self = this;
|
||||
this.videoService.get(id)
|
||||
.then((response) => {
|
||||
// self.setSeason(response.seasonId);
|
||||
// self.setSeries(response.seriesId);
|
||||
self.videoName = response.name;
|
||||
self.videoChange.emit(self.videoId);
|
||||
}).catch((response) => {
|
||||
self.videoChange.emit(self.videoId);
|
||||
});
|
||||
}
|
||||
getVideoId():number {
|
||||
return this.video_id;
|
||||
return this.videoId;
|
||||
}
|
||||
getVideoName():string {
|
||||
return this.video_name;
|
||||
return this.videoName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic navigation on the browser.
|
||||
* @param _destination - new destination url
|
||||
* @param _universeId - univers ID
|
||||
* @param _typeId - type IF
|
||||
* @param _seriesId - series real ID
|
||||
* @param _seasonId - season ID
|
||||
* @param _videoId - Video ID
|
||||
* @param _newWindows - open in a new windows
|
||||
* @param destination - new destination url
|
||||
* @param universeId - univers ID
|
||||
* @param typeId - type IF
|
||||
* @param seriesId - series real ID
|
||||
* @param seasonId - season ID
|
||||
* @param videoId - Video ID
|
||||
* @param newWindows - open in a new windows
|
||||
* @param replaceCurrentPage - consider the curent page is removed from history
|
||||
*/
|
||||
genericNavigate(_destination:string, _universeId:number, _typeId:number, _seriesId:number, _seasonId:number, _videoId:number, _newWindows:boolean = false, replaceCurrentPage: boolean = false):void {
|
||||
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 });
|
||||
}
|
||||
genericNavigate(
|
||||
destination:string,
|
||||
universeId:number,
|
||||
typeId:number,
|
||||
seriesId:number,
|
||||
seasonId:number,
|
||||
videoId:number,
|
||||
newWindows:boolean = false,
|
||||
replaceCurrentPage: boolean = false): void {
|
||||
let addressOffset = `${destination }/${ universeId }/${ typeId }/${ seriesId }/${ seasonId }/${ videoId}`;
|
||||
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 {
|
||||
this.genericNavigate('universe', _id, this.type_id, null, null, null, _newWindows);
|
||||
navigateUniverse(id:number, newWindows:boolean):void {
|
||||
this.genericNavigate('universe', id, this.typeId, null, null, null, newWindows);
|
||||
}
|
||||
navigateUniverseEdit(_id:number, _newWindows:boolean):void {
|
||||
this.genericNavigate('universe-edit', _id, this.type_id, null, null, null, _newWindows);
|
||||
navigateUniverseEdit(id:number, newWindows:boolean):void {
|
||||
this.genericNavigate('universe-edit', id, this.typeId, null, null, null, newWindows);
|
||||
}
|
||||
navigateType(_id:number, _newWindows:boolean, _ctrl:boolean = false):void {
|
||||
if (_ctrl == true) {
|
||||
this.navigateTypeEdit(_id, _newWindows);
|
||||
navigateType(id:number, newWindows:boolean, ctrl:boolean = false):void {
|
||||
if(ctrl === true) {
|
||||
this.navigateTypeEdit(id, newWindows);
|
||||
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 {
|
||||
this.genericNavigate('type-edit', this.universe_id, _id, null, null, null, _newWindows);
|
||||
navigateTypeEdit(id:number, newWindows:boolean):void {
|
||||
this.genericNavigate('type-edit', this.universeId, id, null, null, null, newWindows);
|
||||
}
|
||||
navigateSeries(_id:number, _newWindows:boolean, _ctrl:boolean = false):void {
|
||||
if (_ctrl == true) {
|
||||
this.navigateSeriesEdit(_id, _newWindows);
|
||||
navigateSeries(id:number, newWindows:boolean, ctrl:boolean = false):void {
|
||||
if(ctrl === true) {
|
||||
this.navigateSeriesEdit(id, newWindows);
|
||||
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 {
|
||||
this.genericNavigate('series-edit', this.universe_id, this.type_id, _id, null, null, _newWindows);
|
||||
navigateSeriesEdit(id:number, newWindows:boolean):void {
|
||||
this.genericNavigate('series-edit', this.universeId, this.typeId, id, null, null, newWindows);
|
||||
}
|
||||
navigateSeason(_id:number, _newWindows:boolean, _ctrl:boolean = false, replaceCurrentPage: boolean = false):void {
|
||||
if (_ctrl == true) {
|
||||
this.navigateSeasonEdit(_id, _newWindows);
|
||||
navigateSeason(id:number, newWindows:boolean, ctrl:boolean = false, replaceCurrentPage: boolean = false):void {
|
||||
if(ctrl === true) {
|
||||
this.navigateSeasonEdit(id, newWindows);
|
||||
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 {
|
||||
this.genericNavigate('season-edit', this.universe_id, this.type_id, this.series_id, _id, null, _newWindows);
|
||||
navigateSeasonEdit(id:number, newWindows:boolean):void {
|
||||
this.genericNavigate('season-edit', this.universeId, this.typeId, this.seriesId, id, null, newWindows);
|
||||
}
|
||||
navigateVideo(_id:number, _newWindows:boolean, _ctrl:boolean = false):void {
|
||||
if (_ctrl == true) {
|
||||
this.navigateVideoEdit(_id, _newWindows);
|
||||
navigateVideo(id:number, newWindows:boolean, ctrl:boolean = false):void {
|
||||
if(ctrl === true) {
|
||||
this.navigateVideoEdit(id, newWindows);
|
||||
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 {
|
||||
this.genericNavigate('video-edit', this.universe_id, this.type_id, this.series_id, this.season_id, _id, _newWindows);
|
||||
navigateVideoEdit(id:number, newWindows:boolean):void {
|
||||
this.genericNavigate('video-edit', this.universeId, this.typeId, this.seriesId, this.seasonId, id, newWindows);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import { Injectable } from '@angular/core';
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
constructor() {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,128 +6,128 @@ import { DataInterface } from './dataInterface';
|
||||
@Injectable()
|
||||
export class BddService {
|
||||
private bdd = {
|
||||
"type": null,
|
||||
"series": null,
|
||||
"season": null,
|
||||
"universe": null,
|
||||
"video": null
|
||||
type: null,
|
||||
series: null,
|
||||
season: null,
|
||||
universe: null,
|
||||
video: null
|
||||
};
|
||||
private bddPomise = {
|
||||
"type": null,
|
||||
"series": null,
|
||||
"season": null,
|
||||
"universe": null,
|
||||
"video": null
|
||||
type: null,
|
||||
series: null,
|
||||
season: null,
|
||||
universe: null,
|
||||
video: null
|
||||
};
|
||||
private base_local_storage_name = 'yota_karideo_bdd_';
|
||||
private use_local_storage = false; // we exceed the limit of 5MB
|
||||
|
||||
private baseLocalStorageName = 'yota_karideo_bdd_';
|
||||
private useLocalStorage = false; // we exceed the limit of 5MB
|
||||
|
||||
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;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.get(_name)
|
||||
.then(function(response:DataInterface) {
|
||||
self.get(name)
|
||||
.then((response:DataInterface) => {
|
||||
let responseTmp = response;
|
||||
ret.then(function(response2) {
|
||||
responseTmp.set(_id, response2);
|
||||
ret.then((response2) => {
|
||||
responseTmp.set(id, response2);
|
||||
resolve(response2);
|
||||
}).catch(function(response2) {
|
||||
}).catch((response2) => {
|
||||
reject(response2);
|
||||
});
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
asyncSetInDB(_name: string, _id: number, data: any) {
|
||||
asyncSetInDB(name: string, id: number, data: any) {
|
||||
let self = this;
|
||||
self.get(_name)
|
||||
.then(function(response:DataInterface) {
|
||||
response.set(_id, data);
|
||||
}).catch(function(response) {
|
||||
self.get(name)
|
||||
.then((response:DataInterface) => {
|
||||
response.set(id, data);
|
||||
}).catch((response) => {
|
||||
// nothing to do ...
|
||||
});
|
||||
}
|
||||
|
||||
delete(_name: string, _id: number, ret: any) {
|
||||
|
||||
delete(name: string, id: number, ret: any) {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.get(_name)
|
||||
.then(function(response:DataInterface) {
|
||||
self.get(name)
|
||||
.then((response:DataInterface) => {
|
||||
let responseTmp = response;
|
||||
ret.then(function(response2) {
|
||||
responseTmp.delete(_id);
|
||||
ret.then((response2) => {
|
||||
responseTmp.delete(id);
|
||||
resolve(response2);
|
||||
}).catch(function(response2) {
|
||||
}).catch((response2) => {
|
||||
reject(response2);
|
||||
});
|
||||
}).catch(function(response) {
|
||||
}).catch((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;
|
||||
console.log("Try to get DB '" + _name + "'");
|
||||
if (this.bdd[_name] === undefined) {
|
||||
console.log("Try to get a non existant DB ... '" + _name + "'");
|
||||
console.log(`Try to get DB '${ name }'`);
|
||||
if(this.bdd[name] === undefined) {
|
||||
console.log(`Try to get a non existant DB ... '${ name }'`);
|
||||
return;
|
||||
}
|
||||
if (this.bdd[_name] !== null) {
|
||||
if(this.bdd[name] !== null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(self.bdd[_name]);
|
||||
resolve(self.bdd[name]);
|
||||
});
|
||||
}
|
||||
console.log("get DB: ?? " + _name + " ??");
|
||||
if (this.bddPomise[_name] == null) {
|
||||
this.bddPomise[_name] = new Array<any>();
|
||||
console.log(`get DB: ?? ${ name } ??`);
|
||||
if(this.bddPomise[name] === null) {
|
||||
this.bddPomise[name] = [];
|
||||
// Try to load Local Data (storage)
|
||||
let retriveBDDString = null;
|
||||
if (this.use_local_storage == true) {
|
||||
localStorage.getItem(this.base_local_storage_name + _name);
|
||||
if(this.useLocalStorage === true) {
|
||||
localStorage.getItem(this.baseLocalStorageName + name);
|
||||
}
|
||||
if (retriveBDDString !== null) {
|
||||
console.log("retrive local bdd string (" + _name + ")= " + retriveBDDString);
|
||||
if(retriveBDDString !== null) {
|
||||
console.log(`retrive local bdd string (${ name })= ${ retriveBDDString}`);
|
||||
let retriveBDD = JSON.parse(retriveBDDString);
|
||||
console.log("retrive local bdd (" + _name + ")= " + retriveBDD);
|
||||
let retriveBDDTmp = new DataInterface(_name, retriveBDD);
|
||||
self.bdd[_name] = retriveBDDTmp;
|
||||
for (let iii=0; iii<self.bddPomise[_name].length; iii++) {
|
||||
self.bddPomise[_name][iii]["resolve"](self.bdd[_name]);
|
||||
console.log(`retrive local bdd (${ name })= ${ retriveBDD}`);
|
||||
let retriveBDDTmp = new DataInterface(name, retriveBDD);
|
||||
self.bdd[name] = retriveBDDTmp;
|
||||
for(let iii = 0; iii < self.bddPomise[name].length; iii++) {
|
||||
self.bddPomise[name][iii].resolve(self.bdd[name]);
|
||||
}
|
||||
// brut force update of the BDD : TODO optimise it later ...
|
||||
console.log("Update BDD (" + _name + ")");
|
||||
self.http.get_specific(_name)
|
||||
.then(function(response) {
|
||||
console.log("end download DB: ==> " + _name + " " + response.length);
|
||||
self.bdd[_name] = new DataInterface(_name, response);
|
||||
localStorage.setItem(self.base_local_storage_name + _name, JSON.stringify(self.bdd[_name].bdd));
|
||||
}).catch(function(response) {
|
||||
console.log("[E] " + self.constructor.name + ": cant not get data from remote server: " + _name);
|
||||
});
|
||||
console.log(`Update BDD (${ name })`);
|
||||
self.http.getSpecific(name)
|
||||
.then((response) => {
|
||||
console.log(`end download DB: ==> ${ name } ${ response.length}`);
|
||||
self.bdd[name] = new DataInterface(name, response);
|
||||
localStorage.setItem(self.baseLocalStorageName + name, JSON.stringify(self.bdd[name].bdd));
|
||||
}).catch((response) => {
|
||||
console.log(`[E] ${ self.constructor.name }: cant not get data from remote server: ${ name}`);
|
||||
});
|
||||
} else {
|
||||
console.log("Download BDD (" + _name + ")");
|
||||
console.log(`Download BDD (${ name })`);
|
||||
return new Promise((resolve, reject) => {
|
||||
self.http.get_specific(_name)
|
||||
.then(function(response) {
|
||||
console.log("end download DB: ==> " + _name + " " + response.length);// + " " + JSON.stringify(response).length);
|
||||
self.bdd[_name] = new DataInterface(_name, response);
|
||||
if (self.use_local_storage == true) {
|
||||
localStorage.setItem(self.base_local_storage_name + _name, JSON.stringify(self.bdd[_name].bdd));
|
||||
self.http.getSpecific(name)
|
||||
.then((response) => {
|
||||
console.log(`end download DB: ==> ${ name } ${ response.length}`);// + " " + JSON.stringify(response).length);
|
||||
self.bdd[name] = new DataInterface(name, response);
|
||||
if(self.useLocalStorage === true) {
|
||||
localStorage.setItem(self.baseLocalStorageName + name, JSON.stringify(self.bdd[name].bdd));
|
||||
}
|
||||
for (let iii=0; iii<self.bddPomise[_name].length; iii++) {
|
||||
self.bddPomise[_name][iii]["resolve"](self.bdd[_name]);
|
||||
for(let iii = 0; iii < self.bddPomise[name].length; iii++) {
|
||||
self.bddPomise[name][iii].resolve(self.bdd[name]);
|
||||
}
|
||||
resolve(self.bdd[_name]);
|
||||
}).catch(function(response) {
|
||||
console.log("[E] " + self.constructor.name + ": can not get data from remote server: " + _name);
|
||||
for (let iii=0; iii<self.bddPomise[_name].length; iii++) {
|
||||
self.bddPomise[_name][iii]["reject"](response);
|
||||
resolve(self.bdd[name]);
|
||||
}).catch((response) => {
|
||||
console.log(`[E] ${ self.constructor.name }: can not get data from remote server: ${ name}`);
|
||||
for(let iii = 0; iii < self.bddPomise[name].length; iii++) {
|
||||
self.bddPomise[name][iii].reject(response);
|
||||
}
|
||||
reject(response);
|
||||
});
|
||||
@ -135,32 +135,32 @@ export class BddService {
|
||||
}
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
if (self.bdd[_name] != null) {
|
||||
resolve(self.bdd[_name]);
|
||||
if(self.bdd[name] !== null) {
|
||||
resolve(self.bdd[name]);
|
||||
return;
|
||||
}
|
||||
self.bddPomise[_name].push({"resolve": resolve, "reject": reject});
|
||||
self.bddPomise[name].push({ resolve: resolve, reject: reject });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
getType():any {
|
||||
return this.get("type");
|
||||
return this.get('type');
|
||||
}
|
||||
|
||||
|
||||
getSeries():any {
|
||||
return this.get("series");
|
||||
return this.get('series');
|
||||
}
|
||||
|
||||
|
||||
getSeason():any {
|
||||
return this.get("season");
|
||||
return this.get('season');
|
||||
}
|
||||
|
||||
|
||||
getUniverse():any {
|
||||
return this.get("universe");
|
||||
return this.get('universe');
|
||||
}
|
||||
|
||||
|
||||
getVideo():any {
|
||||
return this.get("video");
|
||||
return this.get('video');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,39 +8,38 @@ import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class CookiesService {
|
||||
|
||||
constructor() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
set(cname, cvalue, exdays) {
|
||||
if (this.get(cname) != "") {
|
||||
if(this.get(cname) !== '') {
|
||||
// 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();
|
||||
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
|
||||
let expires = "expires="+d.toUTCString();
|
||||
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
|
||||
let ddd = new Date();
|
||||
ddd.setTime(ddd.getTime() + exdays * 24 * 60 * 60 * 1000);
|
||||
let expires = `expires=${ddd.toUTCString()}`;
|
||||
document.cookie = `${cname }=${ cvalue };${ expires };path=/`;
|
||||
}
|
||||
|
||||
|
||||
remove(cname) {
|
||||
this.set(cname, "", 0);
|
||||
this.set(cname, '', 0);
|
||||
}
|
||||
|
||||
|
||||
get(cname) {
|
||||
let name = cname + "=";
|
||||
let ca = document.cookie.split(';');
|
||||
for(let i = 0; i < ca.length; i++) {
|
||||
let c = ca[i];
|
||||
while (c.charAt(0) == ' ') {
|
||||
c = c.substring(1);
|
||||
let name = `${cname }=`;
|
||||
let coolies = document.cookie.split(';');
|
||||
for(let iii = 0; iii < coolies.length; iii++) {
|
||||
let ccc = coolies[iii];
|
||||
while(ccc.charAt(0) === ' ') {
|
||||
ccc = ccc.substring(1);
|
||||
}
|
||||
if (c.indexOf(name) == 0) {
|
||||
return c.substring(name.length, c.length);
|
||||
if(ccc.indexOf(name) === 0) {
|
||||
return ccc.substring(name.length, ccc.length);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,28 +8,28 @@ export class DataService {
|
||||
// 0: Not hide password; 1 hide password;
|
||||
private identificationVersion: number = 1;
|
||||
private bdd: DataInterface = null;
|
||||
private serviceName:string = "data";
|
||||
|
||||
private serviceName:string = 'data';
|
||||
|
||||
constructor(private http: HttpWrapperService) {
|
||||
console.log("Start TypeService");
|
||||
console.log('Start TypeService');
|
||||
}
|
||||
|
||||
|
||||
getData():any {
|
||||
return this.http.get_specific(this.serviceName);
|
||||
return this.http.getSpecific(this.serviceName);
|
||||
}
|
||||
|
||||
|
||||
get(_id:number):any {
|
||||
return this.http.get_specific(this.serviceName, _id);
|
||||
return this.http.getSpecific(this.serviceName, _id);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
uploadFile(_form:FormData, _progress:any = null) {
|
||||
//return this.http.uploadFileMultipart(this.serviceName, null, _file);
|
||||
return this.http.uploadMultipart(this.serviceName + "/upload/", _form, _progress);
|
||||
// return this.http.uploadFileMultipart(this.serviceName, null, _file);
|
||||
return this.http.uploadMultipart(`${this.serviceName }/upload/`, _form, _progress);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,159 +10,155 @@
|
||||
* @breif Generic interface to access to the BDD (no BDD, direct file IO)
|
||||
*/
|
||||
export class DataInterface {
|
||||
private name: string;
|
||||
private bdd: any;
|
||||
|
||||
constructor(_name:string, _data:any) {
|
||||
this.name = _name;
|
||||
this.bdd = _data;
|
||||
constructor(
|
||||
private name: string,
|
||||
private bdd: any) {
|
||||
}
|
||||
|
||||
get_table_index(_id) {
|
||||
for (let iii=0; iii<this.bdd.length; iii++) {
|
||||
if (this.bdd[iii]['id'] == _id) {
|
||||
|
||||
public getTableIndex(id: number) {
|
||||
for(let iii = 0; iii < this.bdd.length; iii++) {
|
||||
if(this.bdd[iii].id === id) {
|
||||
return iii;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
gets(_filter=undefined) {
|
||||
console.log("[I] gets " + this.name)
|
||||
if (_filter == undefined) {
|
||||
return this.bdd
|
||||
|
||||
public gets(filter?: any) {
|
||||
console.log(`[I] gets ${ this.name}`);
|
||||
if(filter === undefined) {
|
||||
return this.bdd;
|
||||
}
|
||||
return this.filter_object_values(this.bdd, _filter)
|
||||
return this.filterObjectValues(this.bdd, filter);
|
||||
}
|
||||
|
||||
gets_where(_select, _filter=undefined, _orderBy=undefined){
|
||||
//console.log("[I] gets_where " + this.name + " select " + _select);
|
||||
let tmp_list = this.get_sub_list(this.bdd, _select);
|
||||
tmp_list = this.order_by(tmp_list, _orderBy);
|
||||
return this.filter_object_values(tmp_list, _filter);
|
||||
|
||||
public getsWhere(select, filter = undefined, orderBy = undefined) {
|
||||
// console.log("[I] gets_where " + this.name + " select " + _select);
|
||||
let tmpList = this.getSubList(this.bdd, select);
|
||||
tmpList = this.orderBy(tmpList, orderBy);
|
||||
return this.filterObjectValues(tmpList, filter);
|
||||
}
|
||||
|
||||
get(_id){
|
||||
//console.log("[I] get " + this.name + " " + _id);
|
||||
for (let iii=0; iii<this.bdd.length; iii++) {
|
||||
if (this.bdd[iii]['id'] == _id) {
|
||||
|
||||
public get(id: number) {
|
||||
// console.log("[I] get " + this.name + " " + _id);
|
||||
for(let iii = 0; iii < this.bdd.length; iii++) {
|
||||
if(this.bdd[iii].id === id) {
|
||||
return this.bdd[iii];
|
||||
}
|
||||
}
|
||||
console.log("[W] not found element{ " + this.bdd.length);
|
||||
console.log(`[W] not found element{ ${ this.bdd.length}`);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
getNameLikeAll(_name: string){
|
||||
public getNameLikeAll(name: string) {
|
||||
let out = undefined;
|
||||
let nameLower =_name.toLowerCase();
|
||||
for (let iii=0; iii<this.bdd.length; iii++) {
|
||||
if (this.bdd[iii]['name'].toLowerCase() == nameLower) {
|
||||
let nameLower = name.toLowerCase();
|
||||
for(let iii = 0; iii < this.bdd.length; iii++) {
|
||||
if(this.bdd[iii].name.toLowerCase() === nameLower) {
|
||||
out.push(this.bdd[iii]);
|
||||
}
|
||||
}
|
||||
if (out.length == 0) {
|
||||
if(out.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
getNameLike(_name: string): any[] {
|
||||
public getNameLike(name: string): any[] {
|
||||
let out = [];
|
||||
let nameLower = _name.toLowerCase();
|
||||
for (let iii=0; iii<this.bdd.length; iii++) {
|
||||
//console.log("compare '" + _name + "' ??? '" + this.bdd[iii]['name'] + "'");
|
||||
if (this.bdd[iii]['name'].toLowerCase() == nameLower) {
|
||||
let nameLower = name.toLowerCase();
|
||||
for(let iii = 0; iii < this.bdd.length; iii++) {
|
||||
// console.log("compare '" + _name + "' ??? '" + this.bdd[iii]['name'] + "'");
|
||||
if(this.bdd[iii].name.toLowerCase() === nameLower) {
|
||||
out.push(this.bdd[iii]);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
set(_id, _value){
|
||||
console.log("[I] Set " + this.name + " " + _id)
|
||||
for (let iii=0; iii<this.bdd.length; iii++) {
|
||||
console.log(" check: " + " " + this.bdd[iii]['id'])
|
||||
if (this.bdd[iii]['id'] == _id) {
|
||||
console.log(" *** Set specific values: " + _id + " " + JSON.stringify(_value, null, 2));
|
||||
this.bdd[iii] = _value
|
||||
|
||||
public set(id: number, value: any) {
|
||||
console.log(`[I] Set ${ this.name } ${ id}`);
|
||||
for(let iii = 0; iii < this.bdd.length; iii++) {
|
||||
console.log(` check: ${ this.bdd[iii].id}`);
|
||||
if(this.bdd[iii].id === id) {
|
||||
console.log(` *** Set specific values: ${ id } ${ JSON.stringify(value, null, 2)}`);
|
||||
this.bdd[iii] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete(_id) {
|
||||
console.log("[I] delete " + this.name + " " + _id)
|
||||
for (let iii=0; iii<this.bdd.length; iii++) {
|
||||
if (this.bdd[iii]['id'] == _id) {
|
||||
|
||||
public delete(id: number) {
|
||||
console.log(`[I] delete ${ this.name } ${ id}`);
|
||||
for(let iii = 0; iii < this.bdd.length; iii++) {
|
||||
if(this.bdd[iii].id === id) {
|
||||
this.bdd.splice(iii, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: rework this
|
||||
find(_listToken, _values) {
|
||||
let out = []
|
||||
for (let iii=0; iii<this.bdd.length; iii++) {
|
||||
let find = true
|
||||
for (let jjj=0; jjj<_listToken.length; jjj++) {
|
||||
if (this.bdd[iii][_listToken[jjj]] != _values[_listToken[jjj]]) {
|
||||
|
||||
public find(listToken, values) {
|
||||
let out = [];
|
||||
for(let iii = 0; iii < this.bdd.length; iii++) {
|
||||
let find = true;
|
||||
for(let jjj = 0; jjj < listToken.length; jjj++) {
|
||||
if(this.bdd[iii][listToken[jjj]] !== values[listToken[jjj]]) {
|
||||
find = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (find == true) {
|
||||
if(find === true) {
|
||||
out.push(this.bdd[iii]);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
count(_select = undefined) {
|
||||
if (_select == undefined) {
|
||||
|
||||
public count(select = undefined) {
|
||||
if(select === undefined) {
|
||||
return this.bdd.length;
|
||||
}
|
||||
let tmp = this.get_sub_list(this.bdd, _select);
|
||||
let tmp = this.getSubList(this.bdd, select);
|
||||
return tmp.length;
|
||||
}
|
||||
|
||||
exit_in(_value: any, _listValues: any) {
|
||||
for (let iii=0; iii<_listValues.length; iii++) {
|
||||
if (_value == _listValues[iii]) {
|
||||
|
||||
public existIn(value: any, listValues: any) {
|
||||
for(let iii = 0; iii < listValues.length; iii++) {
|
||||
if(value === listValues[iii]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
get_sub_list(_values, _select) {
|
||||
|
||||
public getSubList(values, select) {
|
||||
let out = [];
|
||||
for (let iii_elem=0; iii_elem<_values.length; iii_elem++) {
|
||||
for(let iiiElem = 0; iiiElem < values.length; iiiElem++) {
|
||||
let find = true;
|
||||
if (_select.length == 0) {
|
||||
if(select.length === 0) {
|
||||
find = false;
|
||||
}
|
||||
//console.log("Check : " + JSON.stringify(_values[iii_elem], null, 2));
|
||||
for (let iii_select=0; iii_select < _select.length; iii_select++) {
|
||||
if (_select[iii_select].length != 3) {
|
||||
console.log("[E] Internal Server Error: wrong select definition ...");
|
||||
// console.log("Check : " + JSON.stringify(_values[iii_elem], null, 2));
|
||||
for(let iiiSelect = 0; iiiSelect < select.length; iiiSelect++) {
|
||||
if(select[iiiSelect].length !== 3) {
|
||||
console.log('[E] Internal Server Error: wrong select definition ...');
|
||||
return undefined;
|
||||
}
|
||||
let type_check = _select[iii_select][0];
|
||||
let token = _select[iii_select][1];
|
||||
let value = _select[iii_select][2];
|
||||
if (value instanceof Array) {
|
||||
if (_values[iii_elem][token] !== undefined) {
|
||||
if (type_check == "==") {
|
||||
if (this.exit_in(_values[iii_elem][token], value) == false) {
|
||||
find = false
|
||||
break
|
||||
let typeCheck = select[iiiSelect][0];
|
||||
let token = select[iiiSelect][1];
|
||||
let value = select[iiiSelect][2];
|
||||
if(Array.isArray(value)) {
|
||||
if(values[iiiElem][token] !== undefined) {
|
||||
if(typeCheck === '==') {
|
||||
if(this.existIn(values[iiiElem][token], value) === false) {
|
||||
find = false;
|
||||
break;
|
||||
}
|
||||
} else if (type_check == "!=") {
|
||||
if (this.exit_in(_values[iii_elem][token], value) == false) {
|
||||
find = false
|
||||
} else if(typeCheck === '!=') {
|
||||
if(this.existIn(values[iiiElem][token], value) === false) {
|
||||
find = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
console.log("[ERROR] Internal Server Error{ unknow comparing type ...");
|
||||
console.log('[ERROR] Internal Server Error{ unknow comparing type ...');
|
||||
return undefined;
|
||||
}
|
||||
} else {
|
||||
@ -170,41 +166,41 @@ export class DataInterface {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
//console.log(" [" + token + "] = " + _values[iii_elem][token]);
|
||||
if (_values[iii_elem][token] !== undefined) {
|
||||
//console.log(" '" + type_check + "' " + value);
|
||||
if (type_check == "==") {
|
||||
if (_values[iii_elem][token] != value) {
|
||||
// console.log(" [" + token + "] = " + values[iii_elem][token]);
|
||||
if(values[iiiElem][token] !== undefined) {
|
||||
// console.log(" '" + type_check + "' " + value);
|
||||
if(typeCheck === '==') {
|
||||
if(values[iiiElem][token] !== value) {
|
||||
find = false;
|
||||
break;
|
||||
}
|
||||
} else if (type_check == "!=") {
|
||||
if (_values[iii_elem][token] == value) {
|
||||
} else if(typeCheck === '!=') {
|
||||
if(values[iiiElem][token] === value) {
|
||||
find = false;
|
||||
break;
|
||||
}
|
||||
} else if (type_check == "<") {
|
||||
if (_values[iii_elem][token] >= value) {
|
||||
} else if(typeCheck === '<') {
|
||||
if(values[iiiElem][token] >= value) {
|
||||
find = false;
|
||||
break;
|
||||
}
|
||||
} else if (type_check == "<=") {
|
||||
if (_values[iii_elem][token] > value) {
|
||||
} else if(typeCheck === '<=') {
|
||||
if(values[iiiElem][token] > value) {
|
||||
find = false;
|
||||
break;
|
||||
}
|
||||
} else if (type_check == ">") {
|
||||
if (_values[iii_elem][token] <= value) {
|
||||
} else if(typeCheck === '>') {
|
||||
if(values[iiiElem][token] <= value) {
|
||||
find = false;
|
||||
break;
|
||||
}
|
||||
} else if (type_check == ">=") {
|
||||
if (_values[iii_elem][token] < value) {
|
||||
} else if(typeCheck === '>=') {
|
||||
if(values[iiiElem][token] < value) {
|
||||
find = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
console.log("[ERROR] Internal Server Error{ unknow comparing type ...");
|
||||
console.log('[ERROR] Internal Server Error{ unknow comparing type ...');
|
||||
return undefined;
|
||||
}
|
||||
} else {
|
||||
@ -213,92 +209,99 @@ export class DataInterface {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (find == true) {
|
||||
//console.log(" ==> SELECTED");
|
||||
out.push(_values[iii_elem])
|
||||
if(find === true) {
|
||||
// console.log(" ==> SELECTED");
|
||||
out.push(values[iiiElem]);
|
||||
} else {
|
||||
//console.log(" ==> NOT SELECTED");
|
||||
// console.log(" ==> NOT SELECTED");
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
order_by(_values, _order) {
|
||||
if (_order == undefined) {
|
||||
return _values;
|
||||
|
||||
public orderBy(values, order) {
|
||||
if(order === undefined) {
|
||||
return values;
|
||||
}
|
||||
if (_order.length == 0) {
|
||||
return _values;
|
||||
if(order.length === 0) {
|
||||
return values;
|
||||
}
|
||||
let value_order = _order[0]
|
||||
let out = []
|
||||
let out_unclassable = []
|
||||
for (let iii=0; iii<_values.length; iii++) {
|
||||
if (_values[iii][value_order] === undefined) {
|
||||
out_unclassable.push(_values[iii]);
|
||||
let valueOrder = order[0];
|
||||
let out = [];
|
||||
let outUnclassable = [];
|
||||
for(let iii = 0; iii < values.length; iii++) {
|
||||
if(values[iii][valueOrder] === undefined) {
|
||||
outUnclassable.push(values[iii]);
|
||||
continue;
|
||||
}
|
||||
if (_values[iii][value_order] == null) {
|
||||
out_unclassable.push(_values[iii]);
|
||||
if(values[iii][valueOrder] === null) {
|
||||
outUnclassable.push(values[iii]);
|
||||
continue;
|
||||
}
|
||||
out.push(_values[iii]);
|
||||
out.push(values[iii]);
|
||||
}
|
||||
//console.log("order in list by : " + value_order);
|
||||
//out = sorted(out, key=lambda x{ x[value_order])
|
||||
if (value_order == "name") {
|
||||
out.sort(function (a, b) {
|
||||
const name1 = a[value_order].toLowerCase();
|
||||
const name2 = b[value_order].toLowerCase();
|
||||
if (name1 > name2) { return 1; }
|
||||
if (name1 < name2) { return -1; }
|
||||
// console.log("order in list by : " + value_order);
|
||||
// out = sorted(out, key=lambda x{ x[value_order])
|
||||
if(valueOrder === 'name') {
|
||||
out.sort((aaa, bbb) => {
|
||||
const name1 = aaa[valueOrder].toLowerCase();
|
||||
const name2 = bbb[valueOrder].toLowerCase();
|
||||
if(name1 > name2) {
|
||||
return 1;
|
||||
}
|
||||
if(name1 < name2) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
} else {
|
||||
out.sort(function (a, b) {
|
||||
if (a[value_order] > b[value_order]) { return 1; }
|
||||
if (a[value_order] < b[value_order]) { return -1; }
|
||||
out.sort((aaa, bbb) => {
|
||||
if(aaa[valueOrder] > bbb[valueOrder]) {
|
||||
return 1;
|
||||
}
|
||||
if(aaa[valueOrder] < bbb[valueOrder]) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
if (_order.length > 1) {
|
||||
out_unclassable = this.order_by(out_unclassable, _order.slice(1));
|
||||
if(order.length > 1) {
|
||||
outUnclassable = this.orderBy(outUnclassable, order.slice(1));
|
||||
}
|
||||
for (let jjj=0; jjj<out_unclassable.length; jjj++) {
|
||||
out.push(out_unclassable[jjj]);
|
||||
for(let jjj = 0; jjj < outUnclassable.length; jjj++) {
|
||||
out.push(outUnclassable[jjj]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
filter_object_values(_values, _filter) {
|
||||
let out = []
|
||||
if (_filter == undefined) {
|
||||
return _values;
|
||||
|
||||
public filterObjectValues(values, filter) {
|
||||
let out = [];
|
||||
if(filter === undefined) {
|
||||
return values;
|
||||
}
|
||||
if (_filter.length == 1) {
|
||||
let token = _filter[0]
|
||||
for (let iii=0; iii<_values.length; iii++) {
|
||||
if (_values[iii][token] === undefined) {
|
||||
if(filter.length === 1) {
|
||||
let token = filter[0];
|
||||
for(let iii = 0; iii < values.length; iii++) {
|
||||
if(values[iii][token] === undefined) {
|
||||
continue;
|
||||
}
|
||||
if (this.exit_in(_values[iii][token], out) == false) {
|
||||
out.push(_values[iii][token]);
|
||||
if(this.existIn(values[iii][token], out) === false) {
|
||||
out.push(values[iii][token]);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
for (let iii=0; iii<_values.length; iii++) {
|
||||
let element_out = {}
|
||||
for (let jjj=0; jjj<_filter.length; jjj++) {
|
||||
if (_values[iii][_filter[jjj]] === undefined) {
|
||||
for(let iii = 0; iii < values.length; iii++) {
|
||||
let elementOut = {};
|
||||
for(let jjj = 0; jjj < filter.length; jjj++) {
|
||||
if(values[iii][filter[jjj]] === undefined) {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { HttpClient, HttpHeaders, HttpParams, HttpRequest, HttpEvent} from '@angular/common/http';
|
||||
import { catchError, map, tap } from 'rxjs/operators';
|
||||
import {Observable} from "rxjs";
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
|
||||
import { environment } from '../../environments/environment';
|
||||
|
||||
@ -10,414 +8,416 @@ import { environment } from '../../environments/environment';
|
||||
export class HttpOAuthWrapperService {
|
||||
private displayReturn:boolean = false;
|
||||
constructor(private http: HttpClient) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
createRESTCall(_api:string, _options:any = undefined) {
|
||||
|
||||
createRESTCall(api:string, inputOptions?: any) {
|
||||
let basePage = environment.apiOAuthUrl;
|
||||
let addressServerRest = basePage + "/";
|
||||
let out;
|
||||
if (typeof _options === 'undefined') {
|
||||
_options = [];
|
||||
let addressServerRest = `${basePage }/`;
|
||||
let options = inputOptions;
|
||||
if(typeof options === 'undefined') {
|
||||
options = [];
|
||||
}
|
||||
out = addressServerRest + _api;
|
||||
let out = addressServerRest + api;
|
||||
let first = true;
|
||||
for (let iii=0; iii<_options.length; iii++) {
|
||||
if (first ==false) {
|
||||
out += "&";
|
||||
for(let iii = 0; iii < options.length; iii++) {
|
||||
if(first === false) {
|
||||
out = `${out }&`;
|
||||
} else {
|
||||
out += "?";
|
||||
out = `${out }?`;
|
||||
first = false;
|
||||
}
|
||||
out += _options[iii];
|
||||
out = out + options[iii];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
get(_uriRest:string, _headerOption:any, _params:any) {
|
||||
let connectionAdresse = this.createRESTCall(_uriRest, {});
|
||||
|
||||
get(uriRest:string, headerOption:any, params:any) {
|
||||
let connectionAdresse = this.createRESTCall(uriRest, {});
|
||||
let config = {
|
||||
params: _params,
|
||||
headers: new HttpHeaders(_headerOption)
|
||||
params: params,
|
||||
headers: new HttpHeaders(headerOption)
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.displayReturn == true) {
|
||||
console.log("call GET " + connectionAdresse + " params=" + JSON.stringify(_params, null, 2));
|
||||
if(this.displayReturn === true) {
|
||||
console.log(`call GET ${ connectionAdresse } params=${ JSON.stringify(params, null, 2)}`);
|
||||
}
|
||||
let request = this.http.get<any>(connectionAdresse, config);
|
||||
let self = this;
|
||||
request.subscribe((res: any) => {
|
||||
if (self.displayReturn == true) {
|
||||
console.log("!! data " + JSON.stringify(res, null, 2));
|
||||
}
|
||||
if (res) {
|
||||
if (res.httpCode) {
|
||||
resolve({status:res.httpCode, data:res});
|
||||
} else {
|
||||
resolve({status:200, data:res});
|
||||
}
|
||||
if(self.displayReturn === true) {
|
||||
console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
|
||||
}
|
||||
if(res) {
|
||||
if(res.httpCode) {
|
||||
resolve({ status:res.httpCode, data:res });
|
||||
} else {
|
||||
resolve({status:200, data:""});
|
||||
resolve({ status:200, data:res });
|
||||
}
|
||||
},
|
||||
error => {
|
||||
if (self.displayReturn == true) {
|
||||
console.log("an error occured status: " + error.status);
|
||||
console.log("answer: " + JSON.stringify(error, null, 2));
|
||||
}
|
||||
reject({status:error.status, data:error.error});
|
||||
});
|
||||
} else {
|
||||
resolve({ status:200, data:'' });
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
if(self.displayReturn === true) {
|
||||
console.log(`an error occured status: ${ error.status}`);
|
||||
console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
|
||||
}
|
||||
reject({ status:error.status, data:error.error });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
post(_uriRest:string, _headerOption:any, _data:any) {
|
||||
let connectionAdresse = this.createRESTCall(_uriRest, {});
|
||||
|
||||
post(uriRest:string, headerOption:any, data:any) {
|
||||
let connectionAdresse = this.createRESTCall(uriRest, {});
|
||||
const httpOption = {
|
||||
headers: new HttpHeaders(_headerOption)
|
||||
headers: new HttpHeaders(headerOption)
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.displayReturn == true) {
|
||||
console.log("call POST " + connectionAdresse + " data=" + JSON.stringify(_data, null, 2));
|
||||
if(this.displayReturn === true) {
|
||||
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;
|
||||
request.subscribe((res: any) => {
|
||||
if (self.displayReturn == true) {
|
||||
console.log("!! data " + JSON.stringify(res, null, 2));
|
||||
}
|
||||
if (res) {
|
||||
if (res.httpCode) {
|
||||
resolve({status:res.httpCode, data:res});
|
||||
} else {
|
||||
resolve({status:200, data:res});
|
||||
}
|
||||
if(self.displayReturn === true) {
|
||||
console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
|
||||
}
|
||||
if(res) {
|
||||
if(res.httpCode) {
|
||||
resolve({ status:res.httpCode, data:res });
|
||||
} else {
|
||||
resolve({status:200, data:""});
|
||||
resolve({ status:200, data:res });
|
||||
}
|
||||
},
|
||||
error => {
|
||||
if (self.displayReturn == true) {
|
||||
console.log("an error occured status: " + error.status);
|
||||
console.log("answer: " + JSON.stringify(error, null, 2));
|
||||
}
|
||||
reject({status:error.status, data:error.error});
|
||||
});
|
||||
} else {
|
||||
resolve({ status:200, data:'' });
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
if(self.displayReturn === true) {
|
||||
console.log(`an error occured status: ${ error.status}`);
|
||||
console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
|
||||
}
|
||||
reject({ status:error.status, data:error.error });
|
||||
});
|
||||
});
|
||||
}
|
||||
put(_uriRest:string, _headerOption:any, _data:any) {
|
||||
let connectionAdresse = this.createRESTCall(_uriRest, {});
|
||||
put(uriRest:string, headerOption:any, data:any) {
|
||||
let connectionAdresse = this.createRESTCall(uriRest, {});
|
||||
const httpOption = {
|
||||
headers: new HttpHeaders(_headerOption)
|
||||
headers: new HttpHeaders(headerOption)
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.displayReturn == true) {
|
||||
console.log("call POST " + connectionAdresse + " data=" + JSON.stringify(_data, null, 2));
|
||||
if(this.displayReturn === true) {
|
||||
console.log(`call POST ${ connectionAdresse } data=${ JSON.stringify(data, null, 2)}`);
|
||||
}
|
||||
let request = this.http.put<any>(connectionAdresse, _data, httpOption);
|
||||
let request = this.http.put<any>(connectionAdresse, data, httpOption);
|
||||
let self = this;
|
||||
request.subscribe((res: any) => {
|
||||
if (self.displayReturn == true) {
|
||||
console.log("!! data " + JSON.stringify(res, null, 2));
|
||||
}
|
||||
if (res) {
|
||||
if (res.httpCode) {
|
||||
resolve({status:res.httpCode, data:res});
|
||||
} else {
|
||||
resolve({status:200, data:res});
|
||||
}
|
||||
if(self.displayReturn === true) {
|
||||
console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
|
||||
}
|
||||
if(res) {
|
||||
if(res.httpCode) {
|
||||
resolve({ status:res.httpCode, data:res });
|
||||
} else {
|
||||
resolve({status:200, data:""});
|
||||
resolve({ status:200, data:res });
|
||||
}
|
||||
},
|
||||
error => {
|
||||
if (self.displayReturn == true) {
|
||||
console.log("an error occured status: " + error.status);
|
||||
console.log("answer: " + JSON.stringify(error, null, 2));
|
||||
}
|
||||
reject({status:error.status, data:error.error});
|
||||
});
|
||||
} else {
|
||||
resolve({ status:200, data:'' });
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
if(self.displayReturn === true) {
|
||||
console.log(`an error occured status: ${ error.status}`);
|
||||
console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
|
||||
}
|
||||
reject({ status:error.status, data:error.error });
|
||||
});
|
||||
});
|
||||
}
|
||||
delete(_uriRest:string, _headerOption:any) {
|
||||
let connectionAdresse = this.createRESTCall(_uriRest, {});
|
||||
delete(uriRest:string, headerOption:any) {
|
||||
let connectionAdresse = this.createRESTCall(uriRest, {});
|
||||
const httpOption = {
|
||||
headers: new HttpHeaders(_headerOption)
|
||||
headers: new HttpHeaders(headerOption)
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.displayReturn == true) {
|
||||
console.log("call POST " + connectionAdresse);
|
||||
if(this.displayReturn === true) {
|
||||
console.log(`call POST ${ connectionAdresse}`);
|
||||
}
|
||||
let request = this.http.delete<any>(connectionAdresse, httpOption);
|
||||
let self = this;
|
||||
request.subscribe((res: any) => {
|
||||
if (self.displayReturn == true) {
|
||||
console.log("!! data " + JSON.stringify(res, null, 2));
|
||||
}
|
||||
if (res) {
|
||||
if (res.httpCode) {
|
||||
resolve({status:res.httpCode, data:res});
|
||||
} else {
|
||||
resolve({status:200, data:res});
|
||||
}
|
||||
if(self.displayReturn === true) {
|
||||
console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
|
||||
}
|
||||
if(res) {
|
||||
if(res.httpCode) {
|
||||
resolve({ status:res.httpCode, data:res });
|
||||
} else {
|
||||
resolve({status:200, data:""});
|
||||
resolve({ status:200, data:res });
|
||||
}
|
||||
},
|
||||
error => {
|
||||
if (self.displayReturn == true) {
|
||||
console.log("an error occured status: " + error.status);
|
||||
console.log("answer: " + JSON.stringify(error, null, 2));
|
||||
}
|
||||
reject({status:error.status, data:error.error});
|
||||
});
|
||||
} else {
|
||||
resolve({ status:200, data:'' });
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
if(self.displayReturn === true) {
|
||||
console.log(`an error occured status: ${ error.status}`);
|
||||
console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
|
||||
}
|
||||
reject({ status:error.status, data:error.error });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
uploadFileMultipart(_base:string, _id:number, _file:File): any {
|
||||
console.log("Upload file to " + _base);
|
||||
|
||||
let url = _base;
|
||||
if (_id != null) {
|
||||
url += "/" + _id;
|
||||
|
||||
uploadFileMultipart(base:string, id:number, file:File): any {
|
||||
console.log(`Upload file to ${ base}`);
|
||||
|
||||
let url = base;
|
||||
if(id !== null) {
|
||||
url = `${url }/${ id}`;
|
||||
}
|
||||
let formData = new FormData();
|
||||
formData.append('upload', _file);
|
||||
formData.append('upload', file);
|
||||
let headers = new Headers();
|
||||
console.log("upload filename : " + _file.name);
|
||||
let extention = _file.name.split('.').pop();
|
||||
if (extention == "jpg") {
|
||||
headers.append('Content-Type', "image/jpeg");
|
||||
} else if (extention == "png") {
|
||||
headers.append('Content-Type', "image/png");
|
||||
console.log(`upload filename : ${ file.name}`);
|
||||
let extention = file.name.split('.').pop();
|
||||
if(extention === 'jpg') {
|
||||
headers.append('Content-Type', 'image/jpeg');
|
||||
} else if(extention === 'png') {
|
||||
headers.append('Content-Type', 'image/png');
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
headers.append('filename', _file.name);
|
||||
|
||||
headers.append('filename', file.name);
|
||||
|
||||
const httpOption = {
|
||||
headers: headers,
|
||||
reportProgress: true,
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
this.post(url, httpOption, formData)
|
||||
.then(function(response: any) {
|
||||
console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if (response.status == 200) {
|
||||
.then((response: any) => {
|
||||
console.log(`URL: ${ url }\nRespond(${ response.status }): ${ JSON.stringify(response.data, null, 2)}`);
|
||||
if(response.status === 200) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
reject("An error occured");
|
||||
}, function(response: any) {
|
||||
if (typeof response.data === 'undefined') {
|
||||
reject("return ERROR undefined");
|
||||
reject('An error occured');
|
||||
}, (response: any) => {
|
||||
if(typeof response.data === 'undefined') {
|
||||
reject('return ERROR undefined');
|
||||
} else {
|
||||
reject("return ERROR " + JSON.stringify(response.data, null, 2));
|
||||
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
uploadFileBase64(_base:string, _id:number, _file:File): any {
|
||||
console.log("Upload file to " + _base);
|
||||
|
||||
let url = _base;
|
||||
if (_id != null) {
|
||||
url += "/" + _id;
|
||||
/*
|
||||
uploadFileBase64(base:string, id:number, file:File): any {
|
||||
console.log(`Upload file to ${ base}`);
|
||||
|
||||
let url = base;
|
||||
if(id !== null) {
|
||||
url = `${url }/${ id}`;
|
||||
}
|
||||
let self = this;
|
||||
let reader = new FileReader();
|
||||
reader.readAsArrayBuffer(_file);
|
||||
reader.readAsArrayBuffer(file);
|
||||
return new Promise((resolve, reject) => {
|
||||
reader.onload = () => {
|
||||
let headers = {};//new Headers();
|
||||
console.log("upload filename : " + _file.name);
|
||||
let extention = _file.name.split('.').pop();
|
||||
if (extention == "jpg") {
|
||||
//headers.append('Content-Type', "image/jpeg");
|
||||
headers['Content-Type'] = "image/jpeg";
|
||||
headers['mime-type'] = "image/jpeg";
|
||||
} else if (extention == "jpeg") {
|
||||
//headers.append('Content-Type', "image/jpeg");
|
||||
headers['Content-Type'] = "image/jpeg";
|
||||
headers['mime-type'] = "image/jpeg";
|
||||
} else if (extention == "webp") {
|
||||
//headers.append('Content-Type', "image/webp");
|
||||
headers['Content-Type'] = "image/webp";
|
||||
headers['mime-type'] = "image/webp";
|
||||
} else if (extention == "png") {
|
||||
//headers.append('Content-Type', "image/png");
|
||||
headers['Content-Type'] = "image/png";
|
||||
headers['mime-type'] = "image/png";
|
||||
let headers = {};// new Headers();
|
||||
console.log(`upload filename : ${ file.name}`);
|
||||
let extention = file.name.split('.').pop();
|
||||
if(extention === 'jpg') {
|
||||
// headers.append('Content-Type', "image/jpeg");
|
||||
headers['Content-Type'] = 'image/jpeg';
|
||||
headers['mime-type'] = 'image/jpeg';
|
||||
} else if(extention === 'jpeg') {
|
||||
// headers.append('Content-Type', "image/jpeg");
|
||||
headers['Content-Type'] = 'image/jpeg';
|
||||
headers['mime-type'] = 'image/jpeg';
|
||||
} else if(extention === 'webp') {
|
||||
// headers.append('Content-Type', "image/webp");
|
||||
headers['Content-Type'] = 'image/webp';
|
||||
headers['mime-type'] = 'image/webp';
|
||||
} else if(extention === 'png') {
|
||||
// headers.append('Content-Type', "image/png");
|
||||
headers['Content-Type'] = 'image/png';
|
||||
headers['mime-type'] = 'image/png';
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
//headers.append('filename', _file.name);
|
||||
headers['filename'] = _file.name;
|
||||
|
||||
// headers.append('filename', _file.name);
|
||||
headers.filename = file.name;
|
||||
|
||||
self.post(url, headers, reader.result)
|
||||
.then(function(response: any) {
|
||||
console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if (response.status == 200) {
|
||||
.then((response: any) => {
|
||||
console.log(`URL: ${ url }\nRespond(${ response.status }): ${ JSON.stringify(response.data, null, 2)}`);
|
||||
if(response.status === 200) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
reject("An error occured");
|
||||
}, function(response: any) {
|
||||
if (typeof response.data === 'undefined') {
|
||||
reject("return ERROR undefined");
|
||||
reject('An error occured');
|
||||
}, (response: any) => {
|
||||
if(typeof response.data === 'undefined') {
|
||||
reject('return ERROR undefined');
|
||||
} else {
|
||||
reject("return ERROR ...");// + JSON.stringify(response, null, 2));
|
||||
reject('return ERROR ...');// + JSON.stringify(response, null, 2));
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
// Complex wrapper to simplify interaction:
|
||||
get_specific(_base:string, _id:number = null, _subElement:string = "", _select:Array<string> = []):any {
|
||||
console.log("Get All data from " + _base);
|
||||
getSpecific(base:string, id:number = null, subElement:string = '', select:Array<string> = []):any {
|
||||
console.log(`Get All data from ${ base}`);
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = _base;
|
||||
if (_id != null) {
|
||||
url += "/" + _id;
|
||||
let url = base;
|
||||
if(id !== null) {
|
||||
url = `${url }/${ id}`;
|
||||
}
|
||||
if (_subElement != "") {
|
||||
url += "/" + _subElement;
|
||||
if(subElement !== '') {
|
||||
url = `${url }/${ subElement}`;
|
||||
}
|
||||
if (_select.length != 0) {
|
||||
let select = ""
|
||||
for (let iii=0; iii<_select.length; iii++) {
|
||||
if (select.length != 0) {
|
||||
select += "&";
|
||||
if(select.length !== 0) {
|
||||
let out = '';
|
||||
for(let iii = 0; iii < select.length; iii++) {
|
||||
if(select.length !== 0) {
|
||||
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) => {
|
||||
this.get(url, httpOption, {})
|
||||
.then(function(response: any) {
|
||||
//console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if (response.status == 200) {
|
||||
.then((response: any) => {
|
||||
// console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if(response.status === 200) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
reject("An error occured");
|
||||
}, function(response: any) {
|
||||
if (typeof response.data === 'undefined') {
|
||||
reject("return ERROR undefined");
|
||||
reject('An error occured');
|
||||
}, (response: any) => {
|
||||
if(typeof response.data === 'undefined') {
|
||||
reject('return ERROR undefined');
|
||||
} else {
|
||||
reject("return ERROR " + JSON.stringify(response.data, null, 2));
|
||||
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Complex wrapper to simplify interaction:
|
||||
delete_specific(_base:string, _id:number, _subElement:string = ""):any {
|
||||
//console.log("delete data to " + _base);
|
||||
deleteSpecific(base:string, id:number, subElement:string = ''):any {
|
||||
// console.log("delete data to " + _base);
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = _base;
|
||||
if (_id != null) {
|
||||
url += "/" + _id;
|
||||
let url = base;
|
||||
if(id !== null) {
|
||||
url = `${url }/${ id}`;
|
||||
}
|
||||
if (_subElement != "") {
|
||||
url += "/" + _subElement;
|
||||
if(subElement !== '') {
|
||||
url = `${url }/${ subElement}`;
|
||||
}
|
||||
//console.log("call DELETE: " + url);
|
||||
//console.log(" data: " + JSON.stringify(_data, null, 2));
|
||||
|
||||
// console.log("call DELETE: " + url);
|
||||
// console.log(" data: " + JSON.stringify(_data, null, 2));
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.delete(url, httpOption)
|
||||
.then(function(response: any) {
|
||||
//console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if (response.status == 200) {
|
||||
.then((response: any) => {
|
||||
// console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if(response.status === 200) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
if (response.status == 201) {
|
||||
if(response.status === 201) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
reject("An error occured");
|
||||
}, function(response: any) {
|
||||
if (typeof response.data === 'undefined') {
|
||||
reject("return ERROR undefined");
|
||||
reject('An error occured');
|
||||
}, (response: any) => {
|
||||
if(typeof response.data === 'undefined') {
|
||||
reject('return ERROR undefined');
|
||||
} else {
|
||||
reject("return ERROR " + JSON.stringify(response.data, null, 2));
|
||||
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
// Complex wrapper to simplify interaction:
|
||||
put_specific(_base:string, _id:number, _data:any, _subElement:string = ""):any {
|
||||
//console.log("put data to " + _base);
|
||||
putSpecific(base:string, id:number, data:any, subElement:string = ''):any {
|
||||
// console.log("put data to " + _base);
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = _base;
|
||||
if (_id != null) {
|
||||
url += "/" + _id;
|
||||
let url = base;
|
||||
if(id !== null) {
|
||||
url = `${url }/${ id}`;
|
||||
}
|
||||
if (_subElement != "") {
|
||||
url += "/" + _subElement;
|
||||
if(subElement !== '') {
|
||||
url = `${url }/${ subElement}`;
|
||||
}
|
||||
//console.log("call PUT: " + url);
|
||||
//console.log(" data: " + JSON.stringify(_data, null, 2));
|
||||
|
||||
// console.log("call PUT: " + url);
|
||||
// console.log(" data: " + JSON.stringify(_data, null, 2));
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.put(url, httpOption, _data)
|
||||
.then(function(response: any) {
|
||||
//console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if (response.status == 200) {
|
||||
this.put(url, httpOption, data)
|
||||
.then((response: any) => {
|
||||
// console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if(response.status === 200) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
if (response.status == 201) {
|
||||
if(response.status === 201) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
reject("An error occured");
|
||||
}, function(response: any) {
|
||||
if (typeof response.data === 'undefined') {
|
||||
reject("return ERROR undefined");
|
||||
reject('An error occured');
|
||||
}, (response: any) => {
|
||||
if(typeof response.data === 'undefined') {
|
||||
reject('return ERROR undefined');
|
||||
} else {
|
||||
reject("return ERROR " + JSON.stringify(response.data, null, 2));
|
||||
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
// Complex wrapper to simplify interaction:
|
||||
post_specific(_base:string, _id:number, _data:any, _subElement:string = ""):any {
|
||||
//console.log("put data to " + _base);
|
||||
postSpecific(base:string, id:number, data:any, subElement:string = ''):any {
|
||||
// console.log("put data to " + _base);
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = _base;
|
||||
if (_id != null) {
|
||||
url += "/" + _id;
|
||||
let url = base;
|
||||
if(id !== null) {
|
||||
url = `${url }/${ id}`;
|
||||
}
|
||||
if (_subElement != "") {
|
||||
url += "/" + _subElement;
|
||||
if(subElement !== '') {
|
||||
url = `${url }/${ subElement}`;
|
||||
}
|
||||
//console.log("call PUT: " + url);
|
||||
//console.log(" data: " + JSON.stringify(_data, null, 2));
|
||||
|
||||
// console.log("call PUT: " + url);
|
||||
// console.log(" data: " + JSON.stringify(_data, null, 2));
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.post(url, httpOption, _data)
|
||||
.then(function(response: any) {
|
||||
//console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if (response.status == 200) {
|
||||
this.post(url, httpOption, data)
|
||||
.then((response: any) => {
|
||||
// console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if(response.status === 200) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
if (response.status == 201) {
|
||||
if(response.status === 201) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
reject("An error occured");
|
||||
}, function(response: any) {
|
||||
if (typeof response.data === 'undefined') {
|
||||
reject("return ERROR undefined");
|
||||
reject('An error occured');
|
||||
}, (response: any) => {
|
||||
if(typeof response.data === 'undefined') {
|
||||
reject('return ERROR undefined');
|
||||
} else {
|
||||
reject("return ERROR " + JSON.stringify(response.data, null, 2));
|
||||
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { HttpClient, HttpHeaders, HttpParams, HttpRequest, HttpEvent, HttpEventType} from '@angular/common/http';
|
||||
import { catchError, map, tap } from 'rxjs/operators';
|
||||
import {Observable} from "rxjs";
|
||||
import { HttpClient, HttpHeaders, HttpEventType } from '@angular/common/http';
|
||||
|
||||
import { environment } from '../../environments/environment';
|
||||
import { SessionService } from './session';
|
||||
@ -12,130 +10,131 @@ export class HttpWrapperService {
|
||||
private displayReturn:boolean = false;
|
||||
constructor(private http: HttpClient,
|
||||
private session: SessionService) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
createRESTCall(_api:string, _options:any = undefined) {
|
||||
|
||||
createRESTCall(api: string, inputOptions?: any) {
|
||||
let basePage = environment.apiUrl;
|
||||
let addressServerRest = basePage + "/";
|
||||
let out;
|
||||
if (typeof _options === 'undefined') {
|
||||
_options = [];
|
||||
let addressServerRest = `${basePage }/`;
|
||||
let options = inputOptions;
|
||||
if(options === undefined) {
|
||||
options = [];
|
||||
}
|
||||
out = addressServerRest + _api;
|
||||
let out = addressServerRest + api;
|
||||
let first = true;
|
||||
for (let iii=0; iii<_options.length; iii++) {
|
||||
if (first ==false) {
|
||||
out += "&";
|
||||
for(let iii = 0; iii < options.length; iii++) {
|
||||
if(first === false) {
|
||||
out = `${out }&`;
|
||||
} else {
|
||||
out += "?";
|
||||
out = `${out }?`;
|
||||
first = false;
|
||||
}
|
||||
out += _options[iii];
|
||||
out = out + options[iii];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
addTokenIfNeeded(_headerOption:any): any {
|
||||
if (this.session.sessionData != null) {
|
||||
if (_headerOption.authorization === undefined) {
|
||||
_headerOption["authorization"] = "Yota " + this.session.sessionData.userId + ":" + this.session.sessionData.token;
|
||||
|
||||
addTokenIfNeeded(headerOption:any): any {
|
||||
if(this.session.sessionData !== null) {
|
||||
if(headerOption.authorization === undefined) {
|
||||
headerOption.authorization = `Yota ${ this.session.sessionData.userId }:${ this.session.sessionData.token}`;
|
||||
}
|
||||
}
|
||||
return _headerOption;
|
||||
return headerOption;
|
||||
}
|
||||
|
||||
get(_uriRest:string, _headerOption:any, _params:any) {
|
||||
this.addTokenIfNeeded(_headerOption);
|
||||
let connectionAdresse = this.createRESTCall(_uriRest, {});
|
||||
|
||||
get(uriRest:string, headerOption:any, params:any) {
|
||||
this.addTokenIfNeeded(headerOption);
|
||||
let connectionAdresse = this.createRESTCall(uriRest, {});
|
||||
let config = {
|
||||
params: _params,
|
||||
headers: new HttpHeaders(_headerOption)
|
||||
params: params,
|
||||
headers: new HttpHeaders(headerOption)
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.displayReturn == true) {
|
||||
console.log("call GET " + connectionAdresse + " params=" + JSON.stringify(_params, null, 2));
|
||||
if(this.displayReturn === true) {
|
||||
console.log(`call GET ${ connectionAdresse } params=${ JSON.stringify(params, null, 2)}`);
|
||||
}
|
||||
let request = this.http.get<any>(connectionAdresse, config);
|
||||
let self = this;
|
||||
request.subscribe((res: any) => {
|
||||
if (self.displayReturn == true) {
|
||||
console.log("!! data " + JSON.stringify(res, null, 2));
|
||||
}
|
||||
if (res) {
|
||||
if (res.httpCode) {
|
||||
resolve({status:res.httpCode, data:res});
|
||||
} else {
|
||||
resolve({status:200, data:res});
|
||||
}
|
||||
if(self.displayReturn === true) {
|
||||
console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
|
||||
}
|
||||
if(res) {
|
||||
if(res.httpCode) {
|
||||
resolve({ status:res.httpCode, data:res });
|
||||
} else {
|
||||
resolve({status:200, data:""});
|
||||
resolve({ status:200, data:res });
|
||||
}
|
||||
},
|
||||
error => {
|
||||
if (self.displayReturn == true) {
|
||||
console.log("an error occured status: " + error.status);
|
||||
console.log("answer: " + JSON.stringify(error, null, 2));
|
||||
}
|
||||
reject({status:error.status, data:error.error});
|
||||
});
|
||||
} else {
|
||||
resolve({ status:200, data:'' });
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
if(self.displayReturn === true) {
|
||||
console.log(`an error occured status: ${ error.status}`);
|
||||
console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
|
||||
}
|
||||
reject({ status:error.status, data:error.error });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
post(_uriRest:string, _headerOption:any, _data:any, _progress:any = null) {
|
||||
this.addTokenIfNeeded(_headerOption);
|
||||
let connectionAdresse = this.createRESTCall(_uriRest, {});
|
||||
|
||||
|
||||
post(uriRest:string, headerOption:any, data:any, progress:any = null) {
|
||||
this.addTokenIfNeeded(headerOption);
|
||||
let connectionAdresse = this.createRESTCall(uriRest, {});
|
||||
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.displayReturn == true) {
|
||||
console.log("call POST " + connectionAdresse + " data=" + JSON.stringify(_data, null, 2));
|
||||
if(this.displayReturn === true) {
|
||||
console.log(`call POST ${ connectionAdresse } data=${ JSON.stringify(data, null, 2)}`);
|
||||
}
|
||||
let request = this.http.post(connectionAdresse, _data, {
|
||||
headers: new HttpHeaders(_headerOption),
|
||||
reportProgress: true,
|
||||
observe: 'events'
|
||||
let request = this.http.post(connectionAdresse, data, {
|
||||
headers: new HttpHeaders(headerOption),
|
||||
reportProgress: true,
|
||||
observe: 'events'
|
||||
});
|
||||
let self = this;
|
||||
request.subscribe((res: any) => {
|
||||
if (self.displayReturn == true) {
|
||||
console.log("!! data " + JSON.stringify(res, null, 2));
|
||||
if(self.displayReturn === true) {
|
||||
console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
|
||||
}
|
||||
if(res.type === HttpEventType.Sent) {
|
||||
/* res.type === 0 */
|
||||
console.log('post : Sent');
|
||||
} else if(res.type === HttpEventType.UploadProgress) {
|
||||
/* res.type === 1 */
|
||||
// console.log("post : " + res.loaded + " / " + res.total);
|
||||
progress(res.loaded, res.total);
|
||||
} else if(res.type === HttpEventType.ResponseHeader) {
|
||||
/* res.type === 2 */
|
||||
console.log('post : get header');
|
||||
} else if(res.type === HttpEventType.DownloadProgress) {
|
||||
/* res.type === 3 */
|
||||
console.log(`post : get DownloadProgress ${ res.loaded}`);
|
||||
} else if(res.type === HttpEventType.Response) {
|
||||
/* res.type === 4 */
|
||||
console.log('post : get response');
|
||||
if(res.httpCode) {
|
||||
resolve({ status:res.httpCode, data:res });
|
||||
} else {
|
||||
resolve({ status:200, data:res });
|
||||
}
|
||||
if (res.type === HttpEventType.Sent) {
|
||||
/* res.type == 0 */
|
||||
console.log("post : Sent");
|
||||
} else if (res.type === HttpEventType.UploadProgress) {
|
||||
/* res.type == 1 */
|
||||
//console.log("post : " + res.loaded + " / " + res.total);
|
||||
_progress(res.loaded, res.total);
|
||||
} else if (res.type === HttpEventType.ResponseHeader) {
|
||||
/* res.type == 2 */
|
||||
console.log("post : get header");
|
||||
} else if (res.type === HttpEventType.DownloadProgress) {
|
||||
/* res.type == 3 */
|
||||
console.log("post : get DownloadProgress " + res.loaded);
|
||||
} else if (res.type === HttpEventType.Response) {
|
||||
/* res.type == 4 */
|
||||
console.log("post : get response");
|
||||
if (res.httpCode) {
|
||||
resolve({status:res.httpCode, data:res});
|
||||
} else {
|
||||
resolve({status:200, data:res});
|
||||
}
|
||||
} else if (res.type === HttpEventType.User) {
|
||||
/* res.type == 5 */
|
||||
console.log("post : get User");
|
||||
} else if(res.type === HttpEventType.User) {
|
||||
/* res.type === 5 */
|
||||
console.log('post : get User');
|
||||
} else {
|
||||
console.log("post : get unknown ... " + res.type);
|
||||
console.log(`post : get unknown ... ${ res.type}`);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
if (self.displayReturn == true) {
|
||||
console.log("an error occured status: " + error.status);
|
||||
console.log("answer: " + JSON.stringify(error, null, 2));
|
||||
}
|
||||
reject({status:error.status, data:error.error});
|
||||
});
|
||||
},
|
||||
(error) => {
|
||||
if(self.displayReturn === true) {
|
||||
console.log(`an error occured status: ${ error.status}`);
|
||||
console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
|
||||
}
|
||||
reject({ status:error.status, data:error.error });
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
switch (event.type) {
|
||||
@ -152,274 +151,275 @@ export class HttpWrapperService {
|
||||
})
|
||||
);
|
||||
*/
|
||||
});
|
||||
});
|
||||
}
|
||||
put(_uriRest:string, _headerOption:any, _data:any) {
|
||||
this.addTokenIfNeeded(_headerOption);
|
||||
let connectionAdresse = this.createRESTCall(_uriRest, {});
|
||||
put(uriRest:string, headerOption:any, data:any) {
|
||||
this.addTokenIfNeeded(headerOption);
|
||||
let connectionAdresse = this.createRESTCall(uriRest, {});
|
||||
const httpOption = {
|
||||
headers: new HttpHeaders(_headerOption)
|
||||
headers: new HttpHeaders(headerOption)
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.displayReturn == true) {
|
||||
console.log("call POST " + connectionAdresse + " data=" + JSON.stringify(_data, null, 2));
|
||||
if(this.displayReturn === true) {
|
||||
console.log(`call POST ${ connectionAdresse } data=${ JSON.stringify(data, null, 2)}`);
|
||||
}
|
||||
let request = this.http.put<any>(connectionAdresse, _data, httpOption);
|
||||
let request = this.http.put<any>(connectionAdresse, data, httpOption);
|
||||
let self = this;
|
||||
request.subscribe((res: any) => {
|
||||
if (self.displayReturn == true) {
|
||||
console.log("!! data " + JSON.stringify(res, null, 2));
|
||||
}
|
||||
if (res) {
|
||||
if (res.httpCode) {
|
||||
resolve({status:res.httpCode, data:res});
|
||||
} else {
|
||||
resolve({status:200, data:res});
|
||||
}
|
||||
if(self.displayReturn === true) {
|
||||
console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
|
||||
}
|
||||
if(res) {
|
||||
if(res.httpCode) {
|
||||
resolve({ status:res.httpCode, data:res });
|
||||
} else {
|
||||
resolve({status:200, data:""});
|
||||
resolve({ status:200, data:res });
|
||||
}
|
||||
},
|
||||
error => {
|
||||
if (self.displayReturn == true) {
|
||||
console.log("an error occured status: " + error.status);
|
||||
console.log("answer: " + JSON.stringify(error, null, 2));
|
||||
}
|
||||
reject({status:error.status, data:error.error});
|
||||
});
|
||||
} else {
|
||||
resolve({ status:200, data:'' });
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
if(self.displayReturn === true) {
|
||||
console.log(`an error occured status: ${ error.status}`);
|
||||
console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
|
||||
}
|
||||
reject({ status:error.status, data:error.error });
|
||||
});
|
||||
});
|
||||
}
|
||||
delete(_uriRest:string, _headerOption:any) {
|
||||
this.addTokenIfNeeded(_headerOption);
|
||||
let connectionAdresse = this.createRESTCall(_uriRest, {});
|
||||
delete(uriRest:string, headerOption:any) {
|
||||
this.addTokenIfNeeded(headerOption);
|
||||
let connectionAdresse = this.createRESTCall(uriRest, {});
|
||||
const httpOption = {
|
||||
headers: new HttpHeaders(_headerOption)
|
||||
headers: new HttpHeaders(headerOption)
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.displayReturn == true) {
|
||||
console.log("call POST " + connectionAdresse);
|
||||
if(this.displayReturn === true) {
|
||||
console.log(`call POST ${ connectionAdresse}`);
|
||||
}
|
||||
let request = this.http.delete<any>(connectionAdresse, httpOption);
|
||||
let self = this;
|
||||
request.subscribe((res: any) => {
|
||||
if (self.displayReturn == true) {
|
||||
console.log("!! data " + JSON.stringify(res, null, 2));
|
||||
}
|
||||
if (res) {
|
||||
if (res.httpCode) {
|
||||
resolve({status:res.httpCode, data:res});
|
||||
} else {
|
||||
resolve({status:200, data:res});
|
||||
}
|
||||
if(self.displayReturn === true) {
|
||||
console.log(`!! data ${ JSON.stringify(res, null, 2)}`);
|
||||
}
|
||||
if(res) {
|
||||
if(res.httpCode) {
|
||||
resolve({ status:res.httpCode, data:res });
|
||||
} else {
|
||||
resolve({status:200, data:""});
|
||||
resolve({ status:200, data:res });
|
||||
}
|
||||
},
|
||||
error => {
|
||||
if (self.displayReturn == true) {
|
||||
console.log("an error occured status: " + error.status);
|
||||
console.log("answer: " + JSON.stringify(error, null, 2));
|
||||
}
|
||||
reject({status:error.status, data:error.error});
|
||||
});
|
||||
} else {
|
||||
resolve({ status:200, data:'' });
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
if(self.displayReturn === true) {
|
||||
console.log(`an error occured status: ${ error.status}`);
|
||||
console.log(`answer: ${ JSON.stringify(error, null, 2)}`);
|
||||
}
|
||||
reject({ status:error.status, data:error.error });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
uploadFileMultipart(_base:string, _id:number, _file:File): any {
|
||||
console.log("Upload file to " + _base);
|
||||
|
||||
let url = _base;
|
||||
if (_id != null) {
|
||||
url += "/" + _id;
|
||||
|
||||
uploadFileMultipart(base:string, id:number, file:File): any {
|
||||
console.log(`Upload file to ${ base}`);
|
||||
|
||||
let url = base;
|
||||
if(id !== null) {
|
||||
url = `${url }/${ id}`;
|
||||
}
|
||||
let formData = new FormData();
|
||||
formData.append('upload', _file);
|
||||
formData.append('upload', file);
|
||||
let headers = new Headers();
|
||||
console.log("upload filename : " + _file.name);
|
||||
let extention = _file.name.split('.').pop();
|
||||
if (extention == "jpg") {
|
||||
headers.append('Content-Type', "image/jpeg");
|
||||
} else if (extention == "png") {
|
||||
headers.append('Content-Type', "image/png");
|
||||
} else if (extention == "mkv") {
|
||||
headers.append('Content-Type', "video/x-matroska");
|
||||
} else if (extention == "webm") {
|
||||
headers.append('Content-Type', "video/webm");
|
||||
console.log(`upload filename : ${ file.name}`);
|
||||
let extention = file.name.split('.').pop();
|
||||
if(extention === 'jpg') {
|
||||
headers.append('Content-Type', 'image/jpeg');
|
||||
} else if(extention === 'png') {
|
||||
headers.append('Content-Type', 'image/png');
|
||||
} else if(extention === 'mkv') {
|
||||
headers.append('Content-Type', 'video/x-matroska');
|
||||
} else if(extention === 'webm') {
|
||||
headers.append('Content-Type', 'video/webm');
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
headers.append('filename', _file.name);
|
||||
|
||||
headers.append('filename', file.name);
|
||||
|
||||
const httpOption = {
|
||||
headers: headers,
|
||||
reportProgress: true,
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
this.post(url, httpOption, formData)
|
||||
.then(function(response: any) {
|
||||
console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if (response.status == 200) {
|
||||
.then((response: any) => {
|
||||
console.log(`URL: ${ url }\nRespond(${ response.status }): ${ JSON.stringify(response.data, null, 2)}`);
|
||||
if(response.status === 200) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
reject("An error occured");
|
||||
}, function(response: any) {
|
||||
if (typeof response.data === 'undefined') {
|
||||
reject("return ERROR undefined");
|
||||
reject('An error occured');
|
||||
}, (response: any) => {
|
||||
if(typeof response.data === 'undefined') {
|
||||
reject('return ERROR undefined');
|
||||
} else {
|
||||
reject("return ERROR " + JSON.stringify(response.data, null, 2));
|
||||
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
uploadFileBase64(_base:string, _id:number, _file:File): any {
|
||||
console.log("Upload file to " + _base);
|
||||
|
||||
let url = _base;
|
||||
if (_id != null) {
|
||||
url += "/" + _id;
|
||||
uploadFileBase64(base:string, id:number, file:File): any {
|
||||
console.log(`Upload file to ${ base}`);
|
||||
|
||||
let url = base;
|
||||
if(id !== null) {
|
||||
url = `${url }/${ id}`;
|
||||
}
|
||||
let self = this;
|
||||
let reader = new FileReader();
|
||||
reader.readAsArrayBuffer(_file);
|
||||
reader.readAsArrayBuffer(file);
|
||||
return new Promise((resolve, reject) => {
|
||||
reader.onload = () => {
|
||||
let headers = {};//new Headers();
|
||||
console.log("upload filename : " + _file.name);
|
||||
let extention = _file.name.split('.').pop();
|
||||
if (extention == "jpg") {
|
||||
//headers.append('Content-Type', "image/jpeg");
|
||||
headers['Content-Type'] = "image/jpeg";
|
||||
headers['mime-type'] = "image/jpeg";
|
||||
} else if (extention == "jpeg") {
|
||||
//headers.append('Content-Type', "image/jpeg");
|
||||
headers['Content-Type'] = "image/jpeg";
|
||||
headers['mime-type'] = "image/jpeg";
|
||||
} else if (extention == "webp") {
|
||||
//headers.append('Content-Type', "image/webp");
|
||||
headers['Content-Type'] = "image/webp";
|
||||
headers['mime-type'] = "image/webp";
|
||||
} else if (extention == "png") {
|
||||
//headers.append('Content-Type', "image/png");
|
||||
headers['Content-Type'] = "image/png";
|
||||
headers['mime-type'] = "image/png";
|
||||
} else if (extention == "mkv") {
|
||||
headers['Content-Type'] = "video/x-matroska";
|
||||
headers['mime-type'] = "video/x-matroska";
|
||||
} else if (extention == "webm") {
|
||||
headers['Content-Type'] = "video/webm";
|
||||
headers['mime-type'] = "video/webm";
|
||||
let headers:any = {};// new Headers();
|
||||
console.log(`upload filename : ${ file.name}`);
|
||||
let extention = file.name.split('.').pop();
|
||||
if(extention === 'jpg') {
|
||||
// headers.append('Content-Type', "image/jpeg");
|
||||
headers['Content-Type'] = 'image/jpeg';
|
||||
headers['mime-type'] = 'image/jpeg';
|
||||
} else if(extention === 'jpeg') {
|
||||
// headers.append('Content-Type', "image/jpeg");
|
||||
headers['Content-Type'] = 'image/jpeg';
|
||||
headers['mime-type'] = 'image/jpeg';
|
||||
} else if(extention === 'webp') {
|
||||
// headers.append('Content-Type', "image/webp");
|
||||
headers['Content-Type'] = 'image/webp';
|
||||
headers['mime-type'] = 'image/webp';
|
||||
} else if(extention === 'png') {
|
||||
// headers.append('Content-Type', "image/png");
|
||||
headers['Content-Type'] = 'image/png';
|
||||
headers['mime-type'] = 'image/png';
|
||||
} else if(extention === 'mkv') {
|
||||
headers['Content-Type'] = 'video/x-matroska';
|
||||
headers['mime-type'] = 'video/x-matroska';
|
||||
} else if(extention === 'webm') {
|
||||
headers['Content-Type'] = 'video/webm';
|
||||
headers['mime-type'] = 'video/webm';
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
//headers.append('filename', _file.name);
|
||||
headers['filename'] = _file.name;
|
||||
|
||||
// headers.append('filename', file.name);
|
||||
headers.filename = file.name;
|
||||
|
||||
self.post(url, headers, reader.result)
|
||||
.then(function(response: any) {
|
||||
console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if (response.status == 200) {
|
||||
.then((response: any) => {
|
||||
console.log(`URL: ${ url }\nRespond(${ response.status }): ${ JSON.stringify(response.data, null, 2)}`);
|
||||
if(response.status === 200) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
reject("An error occured");
|
||||
}, function(response: any) {
|
||||
if (typeof response.data === 'undefined') {
|
||||
reject("return ERROR undefined");
|
||||
reject('An error occured');
|
||||
}, (response: any) => {
|
||||
if(typeof response.data === 'undefined') {
|
||||
reject('return ERROR undefined');
|
||||
} else {
|
||||
reject("return ERROR ...");// + JSON.stringify(response, null, 2));
|
||||
reject('return ERROR ...');// + JSON.stringify(response, null, 2));
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
uploadFile(_base:string, _file:File): any {
|
||||
console.log("Upload file to " + _base);
|
||||
|
||||
let url = _base;
|
||||
uploadFile(base:string, file:File): any {
|
||||
console.log(`Upload file to ${ base}`);
|
||||
|
||||
let url = base;
|
||||
let self = this;
|
||||
let reader = new FileReader();
|
||||
reader.readAsArrayBuffer(_file);
|
||||
reader.readAsArrayBuffer(file);
|
||||
return new Promise((resolve, reject) => {
|
||||
reader.onload = () => {
|
||||
let headers = {};//new Headers();
|
||||
console.log("upload filename : " + _file.name);
|
||||
let extention = _file.name.split('.').pop();
|
||||
if (extention == "jpg") {
|
||||
//headers.append('Content-Type', "image/jpeg");
|
||||
headers['Content-Type'] = "image/jpeg";
|
||||
headers['mime-type'] = "image/jpeg";
|
||||
} else if (extention == "jpeg") {
|
||||
//headers.append('Content-Type', "image/jpeg");
|
||||
headers['Content-Type'] = "image/jpeg";
|
||||
headers['mime-type'] = "image/jpeg";
|
||||
} else if (extention == "webp") {
|
||||
//headers.append('Content-Type', "image/webp");
|
||||
headers['Content-Type'] = "image/webp";
|
||||
headers['mime-type'] = "image/webp";
|
||||
} else if (extention == "png") {
|
||||
//headers.append('Content-Type', "image/png");
|
||||
headers['Content-Type'] = "image/png";
|
||||
headers['mime-type'] = "image/png";
|
||||
} else if (extention == "mkv") {
|
||||
headers['Content-Type'] = "video/x-matroska";
|
||||
headers['mime-type'] = "video/x-matroska";
|
||||
} else if (extention == "webm") {
|
||||
headers['Content-Type'] = "video/webm";
|
||||
headers['mime-type'] = "video/webm";
|
||||
let headers: any = {};// new Headers();
|
||||
console.log(`upload filename : ${ file.name}`);
|
||||
let extention = file.name.split('.').pop();
|
||||
if(extention === 'jpg') {
|
||||
// headers.append('Content-Type', "image/jpeg");
|
||||
headers['Content-Type'] = 'image/jpeg';
|
||||
headers['mime-type'] = 'image/jpeg';
|
||||
} else if(extention === 'jpeg') {
|
||||
// headers.append('Content-Type', "image/jpeg");
|
||||
headers['Content-Type'] = 'image/jpeg';
|
||||
headers['mime-type'] = 'image/jpeg';
|
||||
} else if(extention === 'webp') {
|
||||
// headers.append('Content-Type', "image/webp");
|
||||
headers['Content-Type'] = 'image/webp';
|
||||
headers['mime-type'] = 'image/webp';
|
||||
} else if(extention === 'png') {
|
||||
// headers.append('Content-Type', "image/png");
|
||||
headers['Content-Type'] = 'image/png';
|
||||
headers['mime-type'] = 'image/png';
|
||||
} else if(extention === 'mkv') {
|
||||
headers['Content-Type'] = 'video/x-matroska';
|
||||
headers['mime-type'] = 'video/x-matroska';
|
||||
} else if(extention === 'webm') {
|
||||
headers['Content-Type'] = 'video/webm';
|
||||
headers['mime-type'] = 'video/webm';
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
//headers.append('filename', _file.name);
|
||||
headers['filename'] = _file.name;
|
||||
|
||||
// headers.append('filename', file.name);
|
||||
headers.filename = file.name;
|
||||
|
||||
self.post(url, headers, reader.result)
|
||||
.then(function(response: any) {
|
||||
console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if (response.status == 200) {
|
||||
.then((response: any) => {
|
||||
console.log(`URL: ${ url }\nRespond(${ response.status }): ${ JSON.stringify(response.data, null, 2)}`);
|
||||
if(response.status === 200) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
reject("An error occured");
|
||||
}, function(response: any) {
|
||||
if (typeof response.data === 'undefined') {
|
||||
reject("return ERROR undefined");
|
||||
reject('An error occured');
|
||||
}, (response: any) => {
|
||||
if(typeof response.data === 'undefined') {
|
||||
reject('return ERROR undefined');
|
||||
} 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 {
|
||||
console.log("Upload multipart to " + _base);
|
||||
|
||||
let url = _base;
|
||||
uploadMultipart(base:string, multipart:FormData, progress:any): any {
|
||||
console.log(`Upload multipart to ${ base}`);
|
||||
|
||||
let url = base;
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
let headers = {
|
||||
//'Content-Type': 'multipart/form-data',
|
||||
};//new Headers();
|
||||
|
||||
self.post(url, headers, _multipart, _progress)
|
||||
.then(function(response: any) {
|
||||
console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if (response.status >= 200 && response.status <= 299) {
|
||||
// 'Content-Type': 'multipart/form-data',
|
||||
};// new Headers();
|
||||
|
||||
self.post(url, headers, multipart, progress)
|
||||
.then((response: any) => {
|
||||
console.log(`URL: ${ url }\nRespond(${ response.status }): ${ JSON.stringify(response.data, null, 2)}`);
|
||||
if(response.status >= 200 && response.status <= 299) {
|
||||
resolve(response.data.body);
|
||||
return;
|
||||
}
|
||||
reject("An error occured");
|
||||
}, function(response: any) {
|
||||
if (typeof response.data === 'undefined') {
|
||||
reject("return ERROR undefined");
|
||||
reject('An error occured');
|
||||
}, (response: any) => {
|
||||
if(typeof response.data === 'undefined') {
|
||||
reject('return ERROR undefined');
|
||||
} 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) {
|
||||
}
|
||||
let uploadURL = `${this.SERVER_URL}/auth/${userId}/avatar`;
|
||||
@ -445,151 +445,151 @@ export class HttpWrapperService {
|
||||
}
|
||||
*/
|
||||
// Complex wrapper to simplify interaction:
|
||||
get_specific(_base:string, _id:number = null, _subElement:string = "", _select:Array<string> = []):any {
|
||||
console.log("Get All data from " + _base);
|
||||
getSpecific(base:string, id:number = null, subElement:string = '', select:string[] = []):any {
|
||||
console.log(`Get All data from ${ base}`);
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = _base;
|
||||
if (_id != null) {
|
||||
url += "/" + _id;
|
||||
let url = base;
|
||||
if(id !== null) {
|
||||
url = `${url }/${ id}`;
|
||||
}
|
||||
if (_subElement != "") {
|
||||
url += "/" + _subElement;
|
||||
if(subElement !== '') {
|
||||
url = `${url }/${ subElement}`;
|
||||
}
|
||||
if (_select.length != 0) {
|
||||
let select = ""
|
||||
for (let iii=0; iii<_select.length; iii++) {
|
||||
if (select.length != 0) {
|
||||
select += "&";
|
||||
if(select.length !== 0) {
|
||||
let newValue = '';
|
||||
for(let iii = 0; iii < select.length; iii++) {
|
||||
if(select.length !== 0) {
|
||||
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) => {
|
||||
this.get(url, httpOption, {})
|
||||
.then(function(response: any) {
|
||||
//console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if (response.status == 200) {
|
||||
.then((response: any) => {
|
||||
// console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if(response.status === 200) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
reject("An error occured");
|
||||
}, function(response: any) {
|
||||
if (typeof response.data === 'undefined') {
|
||||
reject("return ERROR undefined");
|
||||
reject('An error occured');
|
||||
}, (response: any) => {
|
||||
if(typeof response.data === 'undefined') {
|
||||
reject('return ERROR undefined');
|
||||
} else {
|
||||
reject("return ERROR " + JSON.stringify(response.data, null, 2));
|
||||
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Complex wrapper to simplify interaction:
|
||||
delete_specific(_base:string, _id:number, _subElement:string = ""):any {
|
||||
//console.log("delete data to " + _base);
|
||||
deleteSpecific(base:string, id:number, subElement:string = ''):any {
|
||||
// console.log("delete data to " + base);
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = _base;
|
||||
if (_id != null) {
|
||||
url += "/" + _id;
|
||||
let url = base;
|
||||
if(id !== null) {
|
||||
url = `${url }/${ id}`;
|
||||
}
|
||||
if (_subElement != "") {
|
||||
url += "/" + _subElement;
|
||||
if(subElement !== '') {
|
||||
url = `${url }/${ subElement}`;
|
||||
}
|
||||
//console.log("call DELETE: " + url);
|
||||
//console.log(" data: " + JSON.stringify(_data, null, 2));
|
||||
|
||||
// console.log("call DELETE: " + url);
|
||||
// console.log(" data: " + JSON.stringify(data, null, 2));
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.delete(url, httpOption)
|
||||
.then(function(response: any) {
|
||||
//console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if (response.status == 200) {
|
||||
.then((response: any) => {
|
||||
// console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if(response.status === 200) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
if (response.status == 201) {
|
||||
if(response.status === 201) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
reject("An error occured");
|
||||
}, function(response: any) {
|
||||
if (typeof response.data === 'undefined') {
|
||||
reject("return ERROR undefined");
|
||||
reject('An error occured');
|
||||
}, (response: any) => {
|
||||
if(typeof response.data === 'undefined') {
|
||||
reject('return ERROR undefined');
|
||||
} else {
|
||||
reject("return ERROR " + JSON.stringify(response.data, null, 2));
|
||||
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
// Complex wrapper to simplify interaction:
|
||||
put_specific(_base:string, _id:number, _data:any, _subElement:string = ""):any {
|
||||
//console.log("put data to " + _base);
|
||||
putSpecific(base:string, id:number, data:any, subElement:string = ''):any {
|
||||
// console.log("put data to " + base);
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = _base;
|
||||
if (_id != null) {
|
||||
url += "/" + _id;
|
||||
let url = base;
|
||||
if(id !== null) {
|
||||
url = `${url }/${ id}`;
|
||||
}
|
||||
if (_subElement != "") {
|
||||
url += "/" + _subElement;
|
||||
if(subElement !== '') {
|
||||
url = `${url }/${ subElement}`;
|
||||
}
|
||||
//console.log("call PUT: " + url);
|
||||
//console.log(" data: " + JSON.stringify(_data, null, 2));
|
||||
|
||||
// console.log("call PUT: " + url);
|
||||
// console.log(" data: " + JSON.stringify(data, null, 2));
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.put(url, httpOption, _data)
|
||||
.then(function(response: any) {
|
||||
//console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if (response.status == 200) {
|
||||
this.put(url, httpOption, data)
|
||||
.then((response: any) => {
|
||||
// console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if(response.status === 200) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
if (response.status == 201) {
|
||||
if(response.status === 201) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
reject("An error occured");
|
||||
}, function(response: any) {
|
||||
if (typeof response.data === 'undefined') {
|
||||
reject("return ERROR undefined");
|
||||
reject('An error occured');
|
||||
}, (response: any) => {
|
||||
if(typeof response.data === 'undefined') {
|
||||
reject('return ERROR undefined');
|
||||
} else {
|
||||
reject("return ERROR " + JSON.stringify(response.data, null, 2));
|
||||
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
// Complex wrapper to simplify interaction:
|
||||
post_specific(_base:string, _id:number, _data:any, _subElement:string = ""):any {
|
||||
//console.log("put data to " + _base);
|
||||
postSpecific(base:string, id:number, data:any, subElement:string = ''):any {
|
||||
// console.log("put data to " + base);
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = _base;
|
||||
if (_id != null) {
|
||||
url += "/" + _id;
|
||||
let url = base;
|
||||
if(id !== null) {
|
||||
url = `${url }/${ id}`;
|
||||
}
|
||||
if (_subElement != "") {
|
||||
url += "/" + _subElement;
|
||||
if(subElement !== '') {
|
||||
url = `${url }/${ subElement}`;
|
||||
}
|
||||
//console.log("call PUT: " + url);
|
||||
//console.log(" data: " + JSON.stringify(_data, null, 2));
|
||||
|
||||
// console.log("call PUT: " + url);
|
||||
// console.log(" data: " + JSON.stringify(data, null, 2));
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.post(url, httpOption, _data)
|
||||
.then(function(response: any) {
|
||||
//console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if (response.status == 200) {
|
||||
this.post(url, httpOption, data)
|
||||
.then((response: any) => {
|
||||
// console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||
if(response.status === 200) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
if (response.status == 201) {
|
||||
if(response.status === 201) {
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
reject("An error occured");
|
||||
}, function(response: any) {
|
||||
if (typeof response.data === 'undefined') {
|
||||
reject("return ERROR undefined");
|
||||
reject('An error occured');
|
||||
}, (response: any) => {
|
||||
if(typeof response.data === 'undefined') {
|
||||
reject('return ERROR undefined');
|
||||
} else {
|
||||
reject("return ERROR " + JSON.stringify(response.data, null, 2));
|
||||
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -3,47 +3,46 @@ import { Injectable } from '@angular/core';
|
||||
@Injectable()
|
||||
export class PopInService {
|
||||
private popins: any[] = [];
|
||||
|
||||
|
||||
constructor() {
|
||||
console.log("Start PopIn Service");
|
||||
console.log('Start PopIn Service');
|
||||
}
|
||||
|
||||
|
||||
add(_popin: any) {
|
||||
// add popin to array of active popins
|
||||
this.popins.push(_popin);
|
||||
}
|
||||
|
||||
|
||||
remove(_id: string) {
|
||||
// remove popin from array of active popins
|
||||
for( let iii = 0; iii < this.popins.length; iii++) {
|
||||
if (this.popins[iii].id === _id) {
|
||||
for(let iii = 0; iii < this.popins.length; iii++) {
|
||||
if(this.popins[iii].id === _id) {
|
||||
this.popins.splice(iii, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
open(_id: string) {
|
||||
//console.log("Try to open pop-in: '" + _id + "'");
|
||||
// console.log("Try to open pop-in: '" + _id + "'");
|
||||
// open popin specified by id
|
||||
for (let iii=0; iii<this.popins.length; iii++) {
|
||||
if (this.popins[iii].id == _id) {
|
||||
//console.log(" ==>find it ...");
|
||||
for(let iii = 0; iii < this.popins.length; iii++) {
|
||||
if(this.popins[iii].id === _id) {
|
||||
// console.log(" ==>find it ...");
|
||||
this.popins[iii].open();
|
||||
return;
|
||||
}
|
||||
}
|
||||
//console.log(" ==> NOT found !!!!!");
|
||||
// console.log(" ==> NOT found !!!!!");
|
||||
}
|
||||
|
||||
|
||||
close(_id: string) {
|
||||
// close popin specified by id
|
||||
for (let iii=0; iii<this.popins.length; iii++) {
|
||||
if (this.popins[iii].id == _id) {
|
||||
for(let iii = 0; iii < this.popins.length; iii++) {
|
||||
if(this.popins[iii].id === _id) {
|
||||
this.popins[iii].close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -7,120 +7,121 @@ import { BddService } from './bdd';
|
||||
export class SeasonService {
|
||||
// 0: Not hide password; 1 hide password;
|
||||
private identificationVersion: number = 1;
|
||||
private serviceName:string = "season";
|
||||
|
||||
private serviceName:string = 'season';
|
||||
|
||||
constructor(private http: HttpWrapperService,
|
||||
private bdd: BddService) {
|
||||
console.log("Start SeasonService");
|
||||
console.log('Start SeasonService');
|
||||
}
|
||||
|
||||
|
||||
get(_id:number):any {
|
||||
|
||||
|
||||
get(id:number):any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getSeason()
|
||||
.then(function(response) {
|
||||
let data = response.get(_id);
|
||||
if (data === null || data === undefined) {
|
||||
reject("Data does not exist in the local BDD");
|
||||
.then((response) => {
|
||||
let data = response.get(id);
|
||||
if(data === null || data === undefined) {
|
||||
reject('Data does not exist in the local BDD');
|
||||
return;
|
||||
}
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Get all the video for a specific season
|
||||
* @param _id - Id of the season.
|
||||
* @returns a promise on the list of season elements
|
||||
*/
|
||||
getVideo(_id:number):any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getVideo()
|
||||
.then(function(response) {
|
||||
//let data = response.gets_where([["==", "season_id", _id]], ["id", "name", "episode"], ["episode", "name"])
|
||||
let data = response.gets_where([["==", "season_id", _id]], undefined, ["episode", "name"])
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Get the number of video in this saison ID
|
||||
* @param _id - Id of the season.
|
||||
* @returns The number of element present in this saison
|
||||
*/
|
||||
countVideo(_id:number):any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getVideo()
|
||||
.then(function(response) {
|
||||
//let data = response.gets_where([["==", "season_id", _id]], ["id", "name", "episode"], ["episode", "name"])
|
||||
let data = response.gets_where([["==", "season_id", _id]], undefined, ["episode", "name"])
|
||||
resolve(data.length);
|
||||
}).catch(function(response) {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
put(_id:number, _data:any):any {
|
||||
let ret = this.http.put_specific(this.serviceName, _id, _data);
|
||||
return this.bdd.setAfterPut(this.serviceName, _id, ret);
|
||||
}
|
||||
|
||||
delete(_id:number):any {
|
||||
let ret = this.http.delete_specific(this.serviceName, _id);
|
||||
return this.bdd.delete(this.serviceName, _id, ret);
|
||||
}
|
||||
|
||||
getCoverUrl(_coverId:number):any {
|
||||
return this.http.createRESTCall("data/" + _coverId);
|
||||
}
|
||||
getCoverThumbnailUrl(_coverId:number):any {
|
||||
return this.http.createRESTCall("data/thumbnail/" + _coverId);
|
||||
}
|
||||
deleteCover(_node_id:number,
|
||||
_cover_id:number) {
|
||||
let self = this;
|
||||
/**
|
||||
* Get all the video for a specific season
|
||||
* @param id - Id of the season.
|
||||
* @returns a promise on the list of season elements
|
||||
*/
|
||||
getVideo(id:number):any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.http.get_specific(this.serviceName + "/" + _node_id + "/rm_cover" , _cover_id)
|
||||
.then(function(response) {
|
||||
let data = response;
|
||||
if (data === null || data === undefined) {
|
||||
reject("error retrive data from server");
|
||||
return;
|
||||
}
|
||||
self.bdd.asyncSetInDB(self.serviceName, _node_id, data);
|
||||
self.bdd.getVideo()
|
||||
.then((response) => {
|
||||
// let data = response.getsWhere([["==", "seasonId", id]], ["id", "name", "episode"], ["episode", "name"])
|
||||
let data = response.gets_where([ [ '==', 'season_id', id ] ], undefined, [ 'episode', 'name' ]);
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
uploadCover(_file:File,
|
||||
_node_id:number,
|
||||
_progress:any = null) {
|
||||
const formData = new FormData();
|
||||
formData.append('file_name', _file.name);
|
||||
formData.append('node_id', _node_id.toString());
|
||||
formData.append('file', _file);
|
||||
|
||||
/**
|
||||
* Get the number of video in this saison ID
|
||||
* @param id - Id of the season.
|
||||
* @returns The number of element present in this saison
|
||||
*/
|
||||
countVideo(id:number):any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getVideo()
|
||||
.then((response) => {
|
||||
// let data = response.gets_where([["==", "season_id", _id]], ["id", "name", "episode"], ["episode", "name"])
|
||||
let data = response.gets_where([ [ '==', 'season_id', id ] ], undefined, [ 'episode', 'name' ]);
|
||||
resolve(data.length);
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
put(id:number, data:any):any {
|
||||
let ret = this.http.putSpecific(this.serviceName, id, data);
|
||||
return this.bdd.setAfterPut(this.serviceName, id, ret);
|
||||
}
|
||||
|
||||
delete(id:number):any {
|
||||
let ret = this.http.deleteSpecific(this.serviceName, id);
|
||||
return this.bdd.delete(this.serviceName, id, ret);
|
||||
}
|
||||
|
||||
getCoverUrl(coverId:number):any {
|
||||
return this.http.createRESTCall(`data/${ coverId}`);
|
||||
}
|
||||
getCoverThumbnailUrl(coverId:number):any {
|
||||
return this.http.createRESTCall(`data/thumbnail/${ coverId}`);
|
||||
}
|
||||
deleteCover(nodeId:number,
|
||||
coverId:number) {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.http.uploadMultipart(this.serviceName + "/" + _node_id + "/add_cover/", formData, _progress)
|
||||
.then(function(response) {
|
||||
self.http.getSpecific(`${this.serviceName }/${ nodeId }/rm_cover`, coverId)
|
||||
.then((response) => {
|
||||
let data = response;
|
||||
if (data === null || data === undefined) {
|
||||
reject("error retrive data from server");
|
||||
if(data === null || data === undefined) {
|
||||
reject('error retrive data from server');
|
||||
return;
|
||||
}
|
||||
self.bdd.asyncSetInDB(self.serviceName, _node_id, data);
|
||||
self.bdd.asyncSetInDB(self.serviceName, nodeId, data);
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
uploadCover(file:File,
|
||||
nodeId:number,
|
||||
progress:any = null) {
|
||||
const formData = new FormData();
|
||||
formData.append('file_name', file.name);
|
||||
formData.append('node_id', nodeId.toString());
|
||||
formData.append('file', file);
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.http.uploadMultipart(`${this.serviceName }/${ nodeId }/add_cover/`, formData, progress)
|
||||
.then((response) => {
|
||||
let data = response;
|
||||
if(data === null || data === undefined) {
|
||||
reject('error retrive data from server');
|
||||
return;
|
||||
}
|
||||
self.bdd.asyncSetInDB(self.serviceName, nodeId, data);
|
||||
resolve(data);
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
|
@ -8,190 +8,190 @@ import { BddService } from './bdd';
|
||||
export class SeriesService {
|
||||
// 0: Not hide password; 1 hide password;
|
||||
private identificationVersion: number = 1;
|
||||
private serviceName:string = "series";
|
||||
|
||||
private serviceName:string = 'series';
|
||||
|
||||
constructor(private http: HttpWrapperService,
|
||||
private bdd: BddService) {
|
||||
console.log("Start SeriesService");
|
||||
console.log('Start SeriesService');
|
||||
}
|
||||
|
||||
get(_id:number):any {
|
||||
|
||||
get(id:number):any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getSeries()
|
||||
.then(function(response:DataInterface) {
|
||||
let data = response.get(_id);
|
||||
if (data === null || data === undefined) {
|
||||
reject("Data does not exist in the local BDD");
|
||||
.then((response:DataInterface) => {
|
||||
let data = response.get(id);
|
||||
if(data === null || data === undefined) {
|
||||
reject('Data does not exist in the local BDD');
|
||||
return;
|
||||
}
|
||||
resolve(data);
|
||||
return;
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
getData():any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getSeries()
|
||||
.then(function(response:DataInterface) {
|
||||
.then((response:DataInterface) => {
|
||||
let data = response.gets();
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
console.log("[E] " + self.constructor.name + ": can not retrive BDD values");
|
||||
}).catch((response) => {
|
||||
console.log(`[E] ${ self.constructor.name }: can not retrive BDD values`);
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
getOrder():any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getSeries()
|
||||
.then(function(response:DataInterface) {
|
||||
let data = response.gets_where([["!=", "id", null]], ["id", "name"], ["name","id"])
|
||||
.then((response:DataInterface) => {
|
||||
let data = response.getsWhere([ [ '!=', 'id', null ] ], [ 'id', 'name' ], [ 'name', 'id' ]);
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
console.log("[E] " + self.constructor.name + ": can not retrive BDD values");
|
||||
}).catch((response) => {
|
||||
console.log(`[E] ${ self.constructor.name }: can not retrive BDD values`);
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getVideoAll(_id:number):any {
|
||||
//this.checkLocalBdd();
|
||||
|
||||
getVideoAll(id:number):any {
|
||||
// this.checkLocalBdd();
|
||||
}
|
||||
|
||||
getVideo(_id:number):any {
|
||||
|
||||
getVideo(id:number):any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getVideo()
|
||||
.then(function(response:DataInterface) {
|
||||
let data = response.gets_where([["==", "series_id", _id], ["==", "season_id", null]], undefined, ["episode", "name"])
|
||||
.then((response:DataInterface) => {
|
||||
let data = response.getsWhere([ [ '==', 'series_id', id ], [ '==', 'season_id', null ] ], undefined, [ 'episode', 'name' ]);
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
countVideo(_id:number):any {
|
||||
countVideo(id:number):any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getVideo()
|
||||
.then(function(response:DataInterface) {
|
||||
let data = response.gets_where([["==", "series_id", _id]], undefined, undefined)
|
||||
.then((response:DataInterface) => {
|
||||
let data = response.getsWhere([ [ '==', 'series_id', id ] ], undefined, undefined);
|
||||
resolve(data.length);
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the season of a specific series
|
||||
* @param _id - ID of the series
|
||||
* @param _select - Selection filter
|
||||
* @param id - ID of the series
|
||||
* @param select - Selection filter
|
||||
* @returns the required List.
|
||||
*/
|
||||
getSeason(_id:number, _select:Array<string> = []):any {
|
||||
getSeason(id:number, select:string[] = []):any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getSeason()
|
||||
.then(function(response:DataInterface) {
|
||||
let data = response.gets_where([["==", "parent_id", _id]], ["id"], ["number"])
|
||||
if (_select.length == 0) {
|
||||
.then((response:DataInterface) => {
|
||||
let data = response.getsWhere([ [ '==', 'parent_id', id ] ], [ 'id' ], [ 'number' ]);
|
||||
if(select.length === 0) {
|
||||
resolve(data);
|
||||
return;
|
||||
}
|
||||
if (_select[0] == "*") {
|
||||
let data2 = response.gets_where([["==", "id", data]], undefined, ["number"])
|
||||
if(select[0] === '*') {
|
||||
let data2 = response.getsWhere([ [ '==', 'id', data ] ], undefined, [ 'number' ]);
|
||||
resolve(data2);
|
||||
return;
|
||||
}
|
||||
let data3 = response.gets_where([["==", "id", data]], _select, ["number"]);
|
||||
let data3 = response.getsWhere([ [ '==', 'id', data ] ], select, [ 'number' ]);
|
||||
resolve(data3);
|
||||
return;
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
put(_id:number, _data:any):any {
|
||||
let ret = this.http.put_specific(this.serviceName, _id, _data);
|
||||
return this.bdd.setAfterPut(this.serviceName, _id, ret);
|
||||
|
||||
put(id:number, data:any):any {
|
||||
let ret = this.http.putSpecific(this.serviceName, id, data);
|
||||
return this.bdd.setAfterPut(this.serviceName, id, ret);
|
||||
}
|
||||
|
||||
delete(_id:number):any {
|
||||
let ret = this.http.delete_specific(this.serviceName, _id);
|
||||
return this.bdd.delete(this.serviceName, _id, ret);
|
||||
delete(id:number):any {
|
||||
let ret = this.http.deleteSpecific(this.serviceName, id);
|
||||
return this.bdd.delete(this.serviceName, id, ret);
|
||||
}
|
||||
|
||||
getCoverUrl(_coverId:number):any {
|
||||
return this.http.createRESTCall("data/" + _coverId);
|
||||
|
||||
getCoverUrl(coverId:number):any {
|
||||
return this.http.createRESTCall(`data/${ coverId}`);
|
||||
}
|
||||
|
||||
getCoverThumbnailUrl(_coverId:number):any {
|
||||
return this.http.createRESTCall("data/thumbnail/" + _coverId);
|
||||
|
||||
getCoverThumbnailUrl(coverId:number):any {
|
||||
return this.http.createRESTCall(`data/thumbnail/${ coverId}`);
|
||||
}
|
||||
|
||||
getLike(_nameSeries:string):any {
|
||||
|
||||
getLike(nameSeries:string):any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getSeries()
|
||||
.then(function(response:DataInterface) {
|
||||
let data = response.getNameLike(_nameSeries);
|
||||
if (data === null || data === undefined || data.length === 0 ) {
|
||||
reject("Data does not exist in the local BDD");
|
||||
.then((response:DataInterface) => {
|
||||
let data = response.getNameLike(nameSeries);
|
||||
if(data === null || data === undefined || data.length === 0) {
|
||||
reject('Data does not exist in the local BDD');
|
||||
return;
|
||||
}
|
||||
resolve(data);
|
||||
return;
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
deleteCover(_node_id:number,
|
||||
_cover_id:number) {
|
||||
deleteCover(nodeId:number,
|
||||
coverId:number) {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.http.get_specific(this.serviceName + "/" + _node_id + "/rm_cover" , _cover_id)
|
||||
.then(function(response) {
|
||||
self.http.getSpecific(`${this.serviceName }/${ nodeId }/rm_cover`, coverId)
|
||||
.then((response) => {
|
||||
let data = response;
|
||||
if (data === null || data === undefined) {
|
||||
reject("error retrive data from server");
|
||||
if(data === null || data === undefined) {
|
||||
reject('error retrive data from server');
|
||||
return;
|
||||
}
|
||||
self.bdd.asyncSetInDB(self.serviceName, _node_id, data);
|
||||
self.bdd.asyncSetInDB(self.serviceName, nodeId, data);
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
uploadCover(_file:File,
|
||||
_node_id:number,
|
||||
_progress:any = null) {
|
||||
uploadCover(file:File,
|
||||
nodeId:number,
|
||||
progress:any = null) {
|
||||
const formData = new FormData();
|
||||
formData.append('file_name', _file.name);
|
||||
formData.append('node_id', _node_id.toString());
|
||||
formData.append('file', _file);
|
||||
formData.append('file_name', file.name);
|
||||
formData.append('node_id', nodeId.toString());
|
||||
formData.append('file', file);
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.http.uploadMultipart(this.serviceName + "/" + _node_id + "/add_cover/", formData, _progress)
|
||||
.then(function(response) {
|
||||
self.http.uploadMultipart(`${this.serviceName }/${ nodeId }/add_cover/`, formData, progress)
|
||||
.then((response) => {
|
||||
let data = response;
|
||||
if (data === null || data === undefined) {
|
||||
reject("error retrive data from server");
|
||||
if(data === null || data === undefined) {
|
||||
reject('error retrive data from server');
|
||||
return;
|
||||
}
|
||||
self.bdd.asyncSetInDB(self.serviceName, _node_id, data);
|
||||
self.bdd.asyncSetInDB(self.serviceName, nodeId, data);
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
|
@ -4,9 +4,9 @@
|
||||
* @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,
|
||||
user = 1,
|
||||
guest = 10
|
||||
@ -19,36 +19,44 @@ export class SessionService {
|
||||
public userAdmin = null;
|
||||
public userEMail = null;
|
||||
public userAvatar = null;
|
||||
//public tocken = null;
|
||||
|
||||
// public tocken = null;
|
||||
|
||||
@Output() change: EventEmitter<boolean> = new EventEmitter();
|
||||
|
||||
|
||||
constructor() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create a new session.
|
||||
*
|
||||
* @param sessionData -
|
||||
* @param userLogin -
|
||||
* @param userEMail -
|
||||
* @param userAdmin -
|
||||
* @param userAvatar -
|
||||
*/
|
||||
create(sessionData,
|
||||
userLogin:string,
|
||||
userEMail:string,
|
||||
userAdmin:boolean,
|
||||
userAvatar:string) {
|
||||
console.log("Session Create");
|
||||
userLogin: string,
|
||||
userEMail: string,
|
||||
userAdmin: boolean,
|
||||
userAvatar: string) {
|
||||
console.log('Session Create');
|
||||
this.sessionData = sessionData;
|
||||
this.userLogin = userLogin;
|
||||
this.userAdmin = userAdmin;
|
||||
this.userEMail = userEMail;
|
||||
this.userAvatar = userAvatar;
|
||||
this.change.emit(true);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief destroy the current session.
|
||||
*/
|
||||
destroy() {
|
||||
console.log("Session REMOVE");
|
||||
//Cookies.remove("yota-login");
|
||||
//Cookies.remove("yota-password");
|
||||
console.log('Session REMOVE');
|
||||
// Cookies.remove("yota-login");
|
||||
// Cookies.remove("yota-password");
|
||||
let last = this.sessionData;
|
||||
this.sessionData = null;
|
||||
this.userLogin = null;
|
||||
@ -56,21 +64,21 @@ export class SessionService {
|
||||
this.userEMail = null;
|
||||
this.userAvatar = null;
|
||||
this.change.emit(false);
|
||||
};
|
||||
}
|
||||
islogged() {
|
||||
return this.sessionData != null;
|
||||
return this.sessionData !== null;
|
||||
}
|
||||
hasRight(type) {
|
||||
if (type == USER_ROLES.admin) {
|
||||
if(type === UserRoles222.admin) {
|
||||
// sometime needed...
|
||||
return this.userAdmin;
|
||||
}
|
||||
if (type == USER_ROLES.user) {
|
||||
if(type === UserRoles222.user) {
|
||||
// is connected ==> is user
|
||||
return this.sessionData != null;
|
||||
return this.sessionData !== null;
|
||||
}
|
||||
if (type == USER_ROLES.guest) {
|
||||
// TODO all the other ... maybe unneeded
|
||||
if(type === UserRoles222.guest) {
|
||||
// all the other ... maybe unneeded
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -82,9 +90,9 @@ export class SessionService {
|
||||
return this.userLogin;
|
||||
}
|
||||
getAvatar() {
|
||||
if (this.userAvatar == "") {
|
||||
return "assets/images/avatar_generic.svg";
|
||||
if(this.userAvatar === '') {
|
||||
return 'assets/images/avatar_generic.svg';
|
||||
}
|
||||
return this.userAvatar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpWrapperService } from './http-wrapper';
|
||||
import { DataInterface } from './dataInterface';
|
||||
import { BddService } from './bdd';
|
||||
|
||||
|
||||
|
||||
export interface MessageLogIn {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
};
|
||||
}
|
||||
|
||||
declare function SHA512(param1: any): any;
|
||||
declare function dateFormat(param1: any, param2: any): any;
|
||||
@ -18,41 +16,40 @@ declare function dateFormat(param1: any, param2: any): any;
|
||||
export class TypeService {
|
||||
// 0: Not hide password; 1 hide password;
|
||||
private identificationVersion: number = 1;
|
||||
private serviceName:string = "type";
|
||||
|
||||
private serviceName:string = 'type';
|
||||
|
||||
constructor(private http: HttpWrapperService,
|
||||
private bdd: BddService) {
|
||||
console.log("Start TypeService");
|
||||
console.log('Start TypeService');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
getData():any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getType()
|
||||
.then(function(response) {
|
||||
.then((response) => {
|
||||
let data = response.gets();
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
console.log("[E] " + self.constructor.name + ": can not retrive BDD values");
|
||||
}).catch((response) => {
|
||||
console.log(`[E] ${ self.constructor.name }: can not retrive BDD values`);
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
get(_id:number):any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getType()
|
||||
.then(function(response) {
|
||||
.then((response) => {
|
||||
let data = response.get(_id);
|
||||
if (data === null || data === undefined) {
|
||||
reject("Data does not exist in the local BDD");
|
||||
if(data === null || data === undefined) {
|
||||
reject('Data does not exist in the local BDD');
|
||||
return;
|
||||
}
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
@ -62,41 +59,42 @@ export class TypeService {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getVideo()
|
||||
.then(function(response) {
|
||||
let data = response.gets_where([["==", "type_id", _id]], undefined, undefined)
|
||||
.then((response) => {
|
||||
let data = response.gets_where([ [ '==', 'type_id', _id ] ], undefined, undefined);
|
||||
resolve(data.length);
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
getSubVideo(_id:number, _select:Array<string> = []):any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getVideo()
|
||||
.then(function(response) {
|
||||
if (_select.length == 0) {
|
||||
let data = response.gets_where([["==", "type_id", _id], ["==", "series_id", null], ["==", "universe_id", null]], undefined, ["name"]);
|
||||
.then((response) => {
|
||||
if(_select.length === 0) {
|
||||
let data = response.gets_where([ [ '==', 'type_id', _id ], [ '==', 'series_id', null ], [ '==', 'universe_id', null ] ], undefined, [ 'name' ]);
|
||||
resolve(data);
|
||||
return;
|
||||
}
|
||||
if (_select[0] == "*") {
|
||||
let data = response.gets_where([["==", "type_id", _id], ["==", "series_id", null], ["==", "universe_id", null]], undefined, ["name"]);
|
||||
if(_select[0] === '*') {
|
||||
let data = response.gets_where([ [ '==', 'type_id', _id ], [ '==', 'series_id', null ], [ '==', 'universe_id', null ] ], undefined, [ 'name' ]);
|
||||
resolve(data);
|
||||
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);
|
||||
return;
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
getSubSeries(_id:number, _select:Array<string> = []):any {
|
||||
let self = this;
|
||||
|
||||
/*
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getVideo()
|
||||
@ -126,49 +124,49 @@ export class TypeService {
|
||||
*/
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getSeries()
|
||||
.then(function(response) {
|
||||
let data = response.gets_where([["==", "parent_id", _id]], undefined, ["name"]);
|
||||
.then((response) => {
|
||||
let data = response.gets_where([ [ '==', 'parent_id', _id ] ], undefined, [ 'name' ]);
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
getSubUniverse(_id:number, _select:Array<string> = []):any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getVideo()
|
||||
.then(function(response) {
|
||||
let data = response.data.gets_where([["==", "type_id", _id], ["==", "series_id", null], ["==", "universe_id", null]], ["univers_id"], ["name"]);
|
||||
if (_select.length == 0) {
|
||||
.then((response) => {
|
||||
let data = response.data.gets_where([ [ '==', 'type_id', _id ], [ '==', 'series_id', null ], [ '==', 'universe_id', null ] ], [ 'univers_id' ], [ 'name' ]);
|
||||
if(_select.length === 0) {
|
||||
resolve(data);
|
||||
return;
|
||||
}
|
||||
self.bdd.getUniverse()
|
||||
.then(function(response2) {
|
||||
if (_select[0] == "*") {
|
||||
let data2 = response2.gets_where([["==", "id", data]], undefined, ["name"]);
|
||||
.then((response2) => {
|
||||
if(_select[0] === '*') {
|
||||
let data2 = response2.gets_where([ [ '==', 'id', data ] ], undefined, [ 'name' ]);
|
||||
resolve(data2);
|
||||
return;
|
||||
}
|
||||
let data3 = response2.gets_where([["==", "id", data]], _select, ["name"]);
|
||||
let data3 = response2.gets_where([ [ '==', 'id', data ] ], _select, [ 'name' ]);
|
||||
resolve(data3);
|
||||
return;
|
||||
}).catch(function(response2) {
|
||||
}).catch((response2) => {
|
||||
reject(response2);
|
||||
});
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
getCoverUrl(_coverId:number):any {
|
||||
return this.http.createRESTCall("data/" + _coverId);
|
||||
return this.http.createRESTCall(`data/${ _coverId}`);
|
||||
}
|
||||
getCoverThumbnailUrl(_coverId:number):any {
|
||||
return this.http.createRESTCall("data/thumbnail/" + _coverId);
|
||||
return this.http.createRESTCall(`data/thumbnail/${ _coverId}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,96 +7,95 @@ import { BddService } from './bdd';
|
||||
export class UniverseService {
|
||||
// 0: Not hide password; 1 hide password;
|
||||
private identificationVersion: number = 1;
|
||||
private serviceName:string = "universe";
|
||||
|
||||
private serviceName:string = 'universe';
|
||||
|
||||
constructor(private http: HttpWrapperService,
|
||||
private bdd: BddService) {
|
||||
console.log("Start universeService");
|
||||
console.log('Start universeService');
|
||||
}
|
||||
|
||||
|
||||
getData():any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getUniverse()
|
||||
.then(function(response) {
|
||||
.then((response) => {
|
||||
let data = response.gets();
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
get(_id:number):any {
|
||||
|
||||
get(id:number):any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.getUniverse()
|
||||
.then(function(response) {
|
||||
let data = response.get(_id);
|
||||
if (data === null || data === undefined) {
|
||||
reject("Data does not exist in the local BDD");
|
||||
.then((response) => {
|
||||
let data = response.get(id);
|
||||
if(data === null || data === undefined) {
|
||||
reject('Data does not exist in the local BDD');
|
||||
return;
|
||||
}
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getSubSeries(_id:number, _select:Array<string> = []):any {
|
||||
//this.checkLocalBdd();
|
||||
|
||||
getSubSeries(id:number, select:Array<string> = []):any {
|
||||
// this.checkLocalBdd();
|
||||
}
|
||||
|
||||
getSubVideo(_id:number, _select:Array<string> = []):any {
|
||||
//this.checkLocalBdd();
|
||||
|
||||
getSubVideo(id:number, select:Array<string> = []):any {
|
||||
// this.checkLocalBdd();
|
||||
}
|
||||
|
||||
put(_id:number, _data:any):any {
|
||||
let ret = this.http.put_specific(this.serviceName, _id, _data);
|
||||
return this.bdd.setAfterPut(this.serviceName, _id, ret);
|
||||
|
||||
put(id:number, data:any):any {
|
||||
let ret = this.http.putSpecific(this.serviceName, id, data);
|
||||
return this.bdd.setAfterPut(this.serviceName, id, ret);
|
||||
}
|
||||
getCoverUrl(_coverId:number):any {
|
||||
return this.http.createRESTCall("data/" + _coverId);
|
||||
getCoverUrl(coverId:number):any {
|
||||
return this.http.createRESTCall(`data/${ coverId}`);
|
||||
}
|
||||
deleteCover(_node_id:number,
|
||||
_cover_id:number) {
|
||||
deleteCover(nodeId:number,
|
||||
coverId:number) {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.http.get_specific(this.serviceName + "/" + _node_id + "/rm_cover" , _cover_id)
|
||||
.then(function(response) {
|
||||
self.http.getSpecific(`${this.serviceName }/${ nodeId }/rm_cover`, coverId)
|
||||
.then((response) => {
|
||||
let data = response;
|
||||
if (data === null || data === undefined) {
|
||||
reject("error retrive data from server");
|
||||
if(data === null || data === undefined) {
|
||||
reject('error retrive data from server');
|
||||
return;
|
||||
}
|
||||
self.bdd.asyncSetInDB(self.serviceName, _node_id, data);
|
||||
self.bdd.asyncSetInDB(self.serviceName, nodeId, data);
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
uploadCover(_file:File,
|
||||
_node_id:number,
|
||||
_progress:any = null) {
|
||||
uploadCover(file:File,
|
||||
nodeId:number,
|
||||
progress:any = null) {
|
||||
const formData = new FormData();
|
||||
formData.append('file_name', _file.name);
|
||||
formData.append('node_id', _node_id.toString());
|
||||
formData.append('file', _file);
|
||||
formData.append('file_name', file.name);
|
||||
formData.append('node_id', nodeId.toString());
|
||||
formData.append('file', file);
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.http.uploadMultipart(this.serviceName + "/" + _node_id + "/add_cover/", formData, _progress)
|
||||
.then(function(response) {
|
||||
self.http.uploadMultipart(`${this.serviceName }/${ nodeId }/add_cover/`, formData, progress)
|
||||
.then((response) => {
|
||||
let data = response;
|
||||
if (data === null || data === undefined) {
|
||||
reject("error retrive data from server");
|
||||
if(data === null || data === undefined) {
|
||||
reject('error retrive data from server');
|
||||
return;
|
||||
}
|
||||
self.bdd.asyncSetInDB(self.serviceName, _node_id, data);
|
||||
self.bdd.asyncSetInDB(self.serviceName, nodeId, data);
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
|
@ -1,14 +1,13 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpOAuthWrapperService } from './http-oauth-wrapper';
|
||||
import { HttpWrapperService } from './http-wrapper';
|
||||
//import { SHA512 } from 'assets/js_3rd_party/sha512';
|
||||
|
||||
interface MessageLogIn {
|
||||
login: string;
|
||||
method: string;
|
||||
time: number;
|
||||
password: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface MessageAnswer_USER_CONNECT {
|
||||
sessionId: string,
|
||||
@ -16,7 +15,7 @@ interface MessageAnswer_USER_CONNECT {
|
||||
eMail: string,
|
||||
role: string,
|
||||
avatar: string
|
||||
};
|
||||
}
|
||||
|
||||
declare function SHA512(param1: any): any;
|
||||
declare function dateFormat(param1: any, param2: any): any;
|
||||
@ -25,105 +24,105 @@ declare function dateFormat(param1: any, param2: any): any;
|
||||
export class UserService {
|
||||
// 0: Not hide password; 1 hide password;
|
||||
private identificationVersion: number = 1;
|
||||
|
||||
|
||||
constructor(private httpOAuth: HttpOAuthWrapperService,
|
||||
private http: HttpWrapperService) {
|
||||
console.log("Start UserService");
|
||||
private http: HttpWrapperService) {
|
||||
console.log('Start UserService');
|
||||
}
|
||||
|
||||
|
||||
login(_login: string, _password: string):any {
|
||||
return this.loginSha(_login, SHA512(_password));
|
||||
}
|
||||
loginSha(_login: string, _password: string):any {
|
||||
loginSha(login: string, password: string):any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.getTocken(_login, _password).then(
|
||||
function(value) {
|
||||
console.log("Get token ...");
|
||||
self.loginWithToken(value['userId'], value['token']).then(
|
||||
function(value2) {
|
||||
// transfer the session token property
|
||||
value2["session"] = {
|
||||
userId: value['userId'],
|
||||
token: value['token'],
|
||||
endValidityTime: value['endValidityTime']
|
||||
};
|
||||
resolve(value2);
|
||||
}, function(value2) {
|
||||
reject("sdfsdfsdf");
|
||||
self.getTocken(login, password).then(
|
||||
(value: any) => {
|
||||
console.log('Get token ...');
|
||||
self.loginWithToken(value.userId, value.token).then(
|
||||
(value2: any) => {
|
||||
// transfer the session token property
|
||||
value2.session = {
|
||||
userId: value.userId,
|
||||
token: value.token,
|
||||
endValidityTime: value.endValidityTime
|
||||
};
|
||||
resolve(value2);
|
||||
}, (value2) => {
|
||||
reject('sdfsdfsdf');
|
||||
});
|
||||
}, (value) => {
|
||||
console.log('User NOT created');
|
||||
reject('rrfrrrrr');
|
||||
});
|
||||
}, function(value) {
|
||||
console.log("User NOT created");
|
||||
reject("rrfrrrrr");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getTocken(_login : string, _password : string) {
|
||||
console.log("AuthService.getToken ... '" + _login + "':'" + _password + "'");
|
||||
|
||||
getTocken(login : string, password : string) {
|
||||
console.log(`AuthService.getToken ... '${ login }':'${ password }'`);
|
||||
let currentDate:number = dateFormat(new Date(), 'm-d-Y h:i:s ms');
|
||||
let data:MessageLogIn;
|
||||
// create request:
|
||||
if (this.identificationVersion == 1) {
|
||||
if(this.identificationVersion === 1) {
|
||||
data = {
|
||||
login: _login,
|
||||
method: "v1",
|
||||
login: login,
|
||||
method: 'v1',
|
||||
time: currentDate,
|
||||
// we mix the password to be sure that it can not be used an other time ...
|
||||
password: SHA512("login='" + _login + "';pass='" + _password + "';date='" + currentDate + "'")
|
||||
password: SHA512(`login='${ login }';pass='${ password }';date='${ currentDate }'`)
|
||||
};
|
||||
} else {
|
||||
console.log("AuthService.login ... Wrong method ...");
|
||||
console.log('AuthService.login ... Wrong method ...');
|
||||
}
|
||||
|
||||
|
||||
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) => {
|
||||
this.httpOAuth.post("users/get_token", httpOption, data)
|
||||
.then(function(response: any) {
|
||||
console.log("response status=" + response.status);
|
||||
if (response.status >= 200 && response.status <= 299) {
|
||||
console.log("Data token: id=" + response.data['id']);
|
||||
console.log("Data token: userId=" + response.data['userId']);
|
||||
console.log("Data token: token=" + response.data['token']);
|
||||
console.log("Data token: createTime=" + response.data['createTime']);
|
||||
console.log("Data token: endValidityTime=" + response.data['endValidityTime']);
|
||||
this.httpOAuth.post('users/get_token', httpOption, data)
|
||||
.then((response: any) => {
|
||||
console.log(`response status=${ response.status}`);
|
||||
if(response.status >= 200 && response.status <= 299) {
|
||||
console.log(`Data token: id=${ response.data.id}`);
|
||||
console.log(`Data token: userId=${ response.data.userId}`);
|
||||
console.log(`Data token: token=${ response.data.token}`);
|
||||
console.log(`Data token: createTime=${ response.data.createTime}`);
|
||||
console.log(`Data token: endValidityTime=${ response.data.endValidityTime}`);
|
||||
resolve(response.data);
|
||||
return;
|
||||
}
|
||||
reject("An error occured");
|
||||
}, function(response: any) {
|
||||
if (typeof response.data === 'undefined') {
|
||||
reject("return ERROR undefined");
|
||||
reject('An error occured');
|
||||
}, (response: any) => {
|
||||
if(typeof response.data === 'undefined') {
|
||||
reject('return ERROR undefined');
|
||||
} else {
|
||||
reject("return ERROR " + JSON.stringify(response.data, null, 2));
|
||||
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
loginWithToken(_user_id : string, _token : string) {
|
||||
console.log("AuthService.loginWithToken ... '" + _user_id + "':'" + _token + "'");
|
||||
}
|
||||
loginWithToken(userId : string, token : string) {
|
||||
console.log(`AuthService.loginWithToken ... '${ userId }':'${ token }'`);
|
||||
let headers = {
|
||||
authorization: "Yota " + _user_id + ":" + _token
|
||||
authorization: `Yota ${userId}:${token}`
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http.get("users/me", headers, {})
|
||||
.then(function(response: any) {
|
||||
if (response.status == 200) {
|
||||
this.http.get('users/me', headers, {})
|
||||
.then((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");
|
||||
reject('An error occured');
|
||||
}, (response: any) => {
|
||||
if(response.data === undefined) {
|
||||
reject('return ERROR undefined');
|
||||
} else {
|
||||
reject("return ERROR " + JSON.stringify(response.data, null, 2));
|
||||
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
console.log("AuthService.login ... '" + _login + "':'" + _password + "'");
|
||||
let currentDate:number = dateFormat(new Date(), 'm-d-Y h:i:s ms');
|
||||
@ -140,10 +139,10 @@ export class UserService {
|
||||
} else {
|
||||
console.log("AuthService.login ... Wrong method ...");
|
||||
}
|
||||
|
||||
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
console.log("call users/connect data=" + JSON.stringify(data, null, 2));
|
||||
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.httpOAuth.post("users/connect", httpOption, data)
|
||||
.then(function(response: any) {
|
||||
@ -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, ) {
|
||||
|
||||
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
|
||||
}
|
||||
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["methode"] = "v1"
|
||||
console.log(`call users data=${ JSON.stringify(data, null, 2)}`);
|
||||
|
||||
if(this.identificationVersion === 1) {
|
||||
data.method = 'v1';
|
||||
}
|
||||
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.httpOAuth.post("users", httpOption, data)
|
||||
.then(function(response: any) {
|
||||
if (response.status == 200) {
|
||||
resolve(response.data)
|
||||
this.httpOAuth.post('users', httpOption, data)
|
||||
.then((response: any) => {
|
||||
if(response.status === 200) {
|
||||
resolve(response.data);
|
||||
}
|
||||
reject("An error occured");
|
||||
}, function(response: any) {
|
||||
if (typeof response.data === 'undefined') {
|
||||
reject("return ERROR undefined");
|
||||
reject('An error occured');
|
||||
}, (response: any) => {
|
||||
if(response.data === undefined) {
|
||||
reject('return ERROR undefined');
|
||||
} else {
|
||||
reject("return ERROR " + JSON.stringify(response.data, null, 2));
|
||||
reject(`return ERROR ${ JSON.stringify(response.data, null, 2)}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
isAuthenticated():boolean {
|
||||
//return !!Session.userId;
|
||||
// return !!Session.userId;
|
||||
return false;
|
||||
};
|
||||
isAuthorized(_authorizedRoles: string): boolean {
|
||||
}
|
||||
isAuthorized(authorizedRoles: string): boolean {
|
||||
/*
|
||||
if (!angular.isArray(_authorizedRoles)) {
|
||||
authorizedRoles = [_authorizedRoles];
|
||||
@ -211,36 +210,36 @@ export class UserService {
|
||||
);
|
||||
*/
|
||||
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 = {
|
||||
"email": _email
|
||||
login: login
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
this.httpOAuth.get("users/check_email", {}, params).then(
|
||||
this.httpOAuth.get('users/check_login', {}, params).then(
|
||||
(res: Response) => {
|
||||
resolve('valid')
|
||||
resolve('valid');
|
||||
},
|
||||
error => {
|
||||
(error) => {
|
||||
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);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,159 +1,155 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpWrapperService } from './http-wrapper';
|
||||
import { DataInterface } from './dataInterface';
|
||||
import { BddService } from './bdd';
|
||||
|
||||
import { environment } from '../../environments/environment';
|
||||
|
||||
@Injectable()
|
||||
export class VideoService {
|
||||
// 0: Not hide password; 1 hide password;
|
||||
private identificationVersion: number = 1;
|
||||
private serviceName:string = "video";
|
||||
|
||||
|
||||
private serviceName:string = 'video';
|
||||
|
||||
|
||||
constructor(private http: HttpWrapperService,
|
||||
private bdd: BddService) {
|
||||
console.log("Start VideoService");
|
||||
console.log('Start VideoService');
|
||||
}
|
||||
|
||||
get(_id:number):any {
|
||||
|
||||
get(id:number):any {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.bdd.get(this.serviceName)
|
||||
.then(function(response) {
|
||||
let data = response.get(_id);
|
||||
if (data === null || data === undefined) {
|
||||
reject("Data does not exist in the local BDD");
|
||||
.then((response) => {
|
||||
let data = response.get(id);
|
||||
if(data === null || data === undefined) {
|
||||
reject('Data does not exist in the local BDD');
|
||||
return;
|
||||
}
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
put(_id:number, _data:any):any {
|
||||
let ret = this.http.put_specific(this.serviceName, _id, _data);
|
||||
return this.bdd.setAfterPut(this.serviceName, _id, ret);
|
||||
|
||||
put(id:number, data:any):any {
|
||||
let ret = this.http.putSpecific(this.serviceName, id, data);
|
||||
return this.bdd.setAfterPut(this.serviceName, id, ret);
|
||||
}
|
||||
delete(_id:number):any {
|
||||
let ret = this.http.delete_specific(this.serviceName, _id);
|
||||
return this.bdd.delete(this.serviceName, _id, ret);
|
||||
delete(id:number):any {
|
||||
let ret = this.http.deleteSpecific(this.serviceName, id);
|
||||
return this.bdd.delete(this.serviceName, id, ret);
|
||||
}
|
||||
getCoverUrl(_coverId:number):any {
|
||||
return this.http.createRESTCall("data/" + _coverId);
|
||||
getCoverUrl(coverId:number):any {
|
||||
return this.http.createRESTCall(`data/${ coverId}`);
|
||||
}
|
||||
getCoverThumbnailUrl(_coverId:number):any {
|
||||
return this.http.createRESTCall("data/thumbnail/" + _coverId);
|
||||
getCoverThumbnailUrl(coverId:number):any {
|
||||
return this.http.createRESTCall(`data/thumbnail/${ coverId}`);
|
||||
}
|
||||
|
||||
uploadFile(_file:File,
|
||||
_universe:string,
|
||||
_series:string,
|
||||
_series_id:number,
|
||||
_season:number,
|
||||
_episode:number,
|
||||
_title:string,
|
||||
_type_id:number,
|
||||
_progress:any = null) {
|
||||
uploadFile(file:File,
|
||||
universe:string,
|
||||
series:string,
|
||||
seriesId:number,
|
||||
season:number,
|
||||
episode:number,
|
||||
title:string,
|
||||
typeId:number,
|
||||
progress:any = null) {
|
||||
const formData = new FormData();
|
||||
formData.append('file_name', _file.name);
|
||||
formData.append('file_name', file.name);
|
||||
// set the file at hte begining it will permit to abort the transmission
|
||||
formData.append('file', _file);
|
||||
formData.append('universe', _universe);
|
||||
if (_series_id != null) {
|
||||
formData.append('series_id', _series_id.toString());
|
||||
formData.append('file', file);
|
||||
formData.append('universe', universe);
|
||||
if(seriesId !== null) {
|
||||
formData.append('series_id', seriesId.toString());
|
||||
} else {
|
||||
formData.append('series_id', null);
|
||||
}
|
||||
formData.append('series', _series);
|
||||
if (_season != null) {
|
||||
formData.append('season', _season.toString());
|
||||
formData.append('series', series);
|
||||
if(season !== null) {
|
||||
formData.append('season', season.toString());
|
||||
} else {
|
||||
formData.append('season', null);
|
||||
}
|
||||
|
||||
if (_episode != null) {
|
||||
formData.append('episode', _episode.toString());
|
||||
|
||||
if(episode !== null) {
|
||||
formData.append('episode', episode.toString());
|
||||
} else {
|
||||
formData.append('episode', null);
|
||||
}
|
||||
formData.append('title', _title);
|
||||
formData.append('title', title);
|
||||
|
||||
if (_type_id != null) {
|
||||
formData.append('type_id', _type_id.toString());
|
||||
if(typeId !== null) {
|
||||
formData.append('type_id', typeId.toString());
|
||||
} else {
|
||||
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,
|
||||
_cover_id:number) {
|
||||
deleteCover(mediaId:number,
|
||||
coverId:number) {
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.http.get_specific(this.serviceName + "/" + _media_id + "/rm_cover" , _cover_id)
|
||||
.then(function(response) {
|
||||
self.http.getSpecific(`${this.serviceName }/${ mediaId }/rm_cover`, coverId)
|
||||
.then((response) => {
|
||||
let data = response;
|
||||
if (data === null || data === undefined) {
|
||||
reject("error retrive data from server");
|
||||
if(data === null || data === undefined) {
|
||||
reject('error retrive data from server');
|
||||
return;
|
||||
}
|
||||
self.bdd.asyncSetInDB(self.serviceName, _media_id, data);
|
||||
self.bdd.asyncSetInDB(self.serviceName, mediaId, data);
|
||||
resolve(data);
|
||||
}).catch(function(response) {
|
||||
}).catch((response) => {
|
||||
reject(response);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
uploadCover(_file:File,
|
||||
_media_id:number,
|
||||
_progress:any = null) {
|
||||
uploadCover(file:File,
|
||||
mediaId:number,
|
||||
progress:any = null) {
|
||||
const formData = new FormData();
|
||||
formData.append('file_name', _file.name);
|
||||
formData.append('type_id', _media_id.toString());
|
||||
formData.append('file', _file);
|
||||
formData.append('file_name', file.name);
|
||||
formData.append('type_id', mediaId.toString());
|
||||
formData.append('file', file);
|
||||
let self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.http.uploadMultipart(this.serviceName + "/" + _media_id + "/add_cover/", formData, _progress)
|
||||
.then(function(response) {
|
||||
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");
|
||||
if(data === null || data === undefined) {
|
||||
reject('error retrive data from server');
|
||||
return;
|
||||
}
|
||||
self.bdd.asyncSetInDB(self.serviceName, _media_id, data);
|
||||
self.bdd.asyncSetInDB(self.serviceName, mediaId, 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);
|
||||
});
|
||||
});
|
||||
}
|
||||
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);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ export const environment = {
|
||||
apiUrl: 'http://192.168.1.156/karideo/api',
|
||||
apiOAuthUrl: 'http://192.168.1.156/karauth/api',
|
||||
frontBaseUrl: 'karideo',
|
||||
apiMode: "QUERRY",
|
||||
//apiMode: "REWRITE",
|
||||
apiMode: 'QUERRY',
|
||||
// apiMode: "REWRITE",
|
||||
localBdd: true
|
||||
}
|
||||
};
|
||||
|
@ -6,12 +6,12 @@
|
||||
export const environment = {
|
||||
production: false,
|
||||
// URL of development API
|
||||
//apiUrl: 'http://localhost:15080',
|
||||
//apiUrl: 'http://localhost:18080/karideo/api',
|
||||
// apiUrl: 'http://localhost:15080',
|
||||
// apiUrl: 'http://localhost:18080/karideo/api',
|
||||
apiUrl: 'http://192.168.1.156/karideo/api',
|
||||
//apiOAuthUrl: 'http://localhost:17080/karauth/api',
|
||||
// apiOAuthUrl: 'http://localhost:17080/karauth/api',
|
||||
apiOAuthUrl: 'http://192.168.1.156/karauth/api',
|
||||
frontBaseUrl: '',
|
||||
//apiMode: "QUERRY"
|
||||
apiMode: "REWRITE"
|
||||
}
|
||||
// apiMode: "QUERRY"
|
||||
apiMode: 'REWRITE'
|
||||
};
|
||||
|
@ -4,8 +4,10 @@ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
import { AppModule } from './app/app.module';
|
||||
import { environment } from './environments/environment';
|
||||
|
||||
if (environment.production) {
|
||||
if(environment.production) {
|
||||
enableProdMode();
|
||||
}
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule).catch(err => console.log(err));
|
||||
platformBrowserDynamic().bootstrapModule(AppModule).catch((err) => {
|
||||
return console.log(err);
|
||||
});
|
||||
|
@ -1,6 +1,5 @@
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Required to support Web Animations `@angular/platform-browser/animations`.
|
||||
* 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
|
||||
*/
|
||||
|
||||
// (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_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
|
||||
// (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_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
|
||||
|
||||
/*
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
// (window as any).__Zone_enable_cross_context_check = true;
|
||||
|
||||
/***************************************************************************************************
|
||||
/** *************************************************************************************************
|
||||
* 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
|
||||
*/
|
||||
|
@ -3,16 +3,16 @@
|
||||
import 'zone.js/dist/zone-testing';
|
||||
import { getTestBed } from '@angular/core/testing';
|
||||
import {
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting
|
||||
} from '@angular/platform-browser-dynamic/testing';
|
||||
|
||||
declare const require: any;
|
||||
|
||||
// First, initialize the Angular testing environment.
|
||||
getTestBed().initTestEnvironment(
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting()
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting()
|
||||
);
|
||||
// Then we find all the tests.
|
||||
const context = require.context('./', true, /\.spec\.ts$/);
|
||||
|
4
front/src/typings.d.ts
vendored
4
front/src/typings.d.ts
vendored
@ -1,5 +1,7 @@
|
||||
/* SystemJS module definition */
|
||||
declare var module: NodeModule;
|
||||
interface NodeModule {
|
||||
id: string;
|
||||
}
|
||||
|
||||
|
||||
declare let module: NodeModule;
|
||||
|
Loading…
Reference in New Issue
Block a user