[DEV] some updates

This commit is contained in:
Edouard DUPIN 2020-10-10 22:35:09 +02:00
parent f6df685694
commit fe67849ea7
29 changed files with 6069 additions and 3281 deletions

10
.checkstyle Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
<local-check-config name="Scenarium" location="/home/heero/dev/workspace-scenarium/scenarium-core/CheckStyle.xml" type="external" description="">
<additional-data name="protect-config-file" value="false"/>
</local-check-config>
<fileset name="all" enabled="true" check-config-name="Scenarium" local="true">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
</fileset-config>

View File

@ -187,73 +187,3 @@ def add(_app, _name_api):
await _response.write(json.dumps(return_bdd, sort_keys=True, indent=4))
return response.stream(streaming, content_type='application/json')
@elem_blueprint.get('/' + _name_api + '/<id:int>/<custom_user_video_name:string>', strict_slashes=True)
@doc.summary("get a specific resource")
@doc.description("Get a resource with all the needed datas ... It permeit seek for video stream.")
@doc.produces(content_type='application/json')
def retrive2(request, id, custom_user_video_name):
return retrive(request, id)
@elem_blueprint.get('/' + _name_api + '/<id:int>', strict_slashes=True)
@doc.summary("get a specific resource")
@doc.description("Get a resource with all the needed datas ... It permeit seek for video stream.")
@doc.produces(content_type='application/json')
async def retrive(request, id):
debug.warning("Request data media 2 : " + str(id));
"""
if id[-4:] == ".mp4":
id = id[:-4]
if id[-4:] == ".mkv":
id = id[:-4]
"""
filename = os.path.join(_app.config['REST_MEDIA_DATA'], str(id), "data")
value = data_global_elements.get_interface(_name_api).get(id)
debug.info("plouuuuuuf " + str(value))
headers = {
'Content-Type': value["mime_type"],
'Accept-Ranges': 'Accept-Ranges: bytes'
}
if tools.exist(filename) == False:
return response.HTTPResponse(status=404)
file_length = tools.file_size(filename);
try:
range_start = None
range_end = None
try:
range_ = '0-' + str(file_length)
if 'range' in request.headers:
range_ = request.headers['range'].split('=')[1]
range_split = range_.split('-')
range_start = int(range_split[0])
range_end = int(range_split[1])
except ValueError:
pass
if range_start and range_start != 0:
if not range_end:
range_end = file_length
read_length = range_end - range_start
else:
range_start = 0
read_length = file_length
range_end = file_length
headers['Content-Length'] = read_length
headers['Content-Range'] = f'bytes {range_start}-{range_end-1}/{file_length}'
async def streaming_fn(response):
with open(filename, 'rb') as fff:
chunk_size = 8192
current_offset = range_start
while (current_offset < file_length):
chunk_start = current_offset
fff.seek(current_offset)
chunk_data = fff.read(min(chunk_size, file_length - current_offset))
current_offset += chunk_size
await response.write(chunk_data)
return response.stream(streaming_fn, headers=headers, status=206)
except FileNotFoundError:
return response.HTTPResponse(status=404)
_app.blueprint(elem_blueprint)

View File

@ -1,140 +1,184 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"no-comment": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/favicon.ico"
],
"styles": [
"src/styles.less",
"src/generic_page.less",
"src/theme.color.blue.less",
"src/theme.checkbox.less",
"src/theme.modal.less"
],
"scripts": []
"$schema" : "./node_modules/@angular/cli/lib/config/schema.json",
"version" : 1,
"newProjectRoot" : "projects",
"defaultProject" : "no-comment",
"projects" : {
"no-comment" : {
"root" : "",
"sourceRoot" : "src",
"projectType" : "application",
"architect" : {
"build" : {
"builder" : "@angular-devkit/build-angular:browser",
"options" : {
"outputPath" : "dist",
"index" : "src/index.html",
"main" : "src/main.ts",
"tsConfig" : "src/tsconfig.app.json",
"polyfills" : "src/polyfills.ts",
"assets" : [ "src/assets", "src/favicon.ico" ],
"styles" : [ "src/styles.less", "src/generic_page.less", "src/theme.color.blue.less", "src/theme.checkbox.less", "src/theme.modal.less" ],
"scripts" : [ ]
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
"configurations" : {
"production" : {
"optimization" : true,
"outputHashing" : "all",
"sourceMap" : false,
"extractCss" : true,
"namedChunks" : false,
"aot" : true,
"extractLicenses" : true,
"vendorChunk" : false,
"buildOptimizer" : true,
"fileReplacements" : [ {
"replace" : "src/environments/environment.ts",
"with" : "src/environments/environment.prod.ts"
} ]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "no-comment:build"
"serve" : {
"builder" : "@angular-devkit/build-angular:dev-server",
"options" : {
"browserTarget" : "no-comment:build"
},
"configurations": {
"production": {
"browserTarget": "no-comment:build:production"
"configurations" : {
"production" : {
"browserTarget" : "no-comment:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "no-comment:build"
"extract-i18n" : {
"builder" : "@angular-devkit/build-angular:extract-i18n",
"options" : {
"browserTarget" : "no-comment:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": [],
"styles": [
"src/styles.less",
"src/generic_page.less",
"src/theme.color.blue.less",
"src/theme.checkbox.less",
"src/theme.modal.less"
],
"assets": [
"src/assets",
"src/favicon.ico"
]
"test" : {
"builder" : "@angular-devkit/build-angular:karma",
"options" : {
"main" : "src/test.ts",
"karmaConfig" : "./karma.conf.js",
"polyfills" : "src/polyfills.ts",
"tsConfig" : "src/tsconfig.spec.json",
"scripts" : [ ],
"styles" : [ "src/styles.less", "src/generic_page.less", "src/theme.color.blue.less", "src/theme.checkbox.less", "src/theme.modal.less" ],
"assets" : [ "src/assets", "src/favicon.ico" ]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
"lint" : {
"builder" : "@angular-devkit/build-angular:tslint",
"options" : {
"tsConfig" : [ "src/tsconfig.app.json", "src/tsconfig.spec.json" ],
"exclude" : [ "**/node_modules/**" ]
}
}
}
},
"no-comment-e2e": {
"root": "e2e",
"sourceRoot": "e2e",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "no-comment:serve"
"no-comment-e2e" : {
"root" : "e2e",
"sourceRoot" : "e2e",
"projectType" : "application",
"architect" : {
"e2e" : {
"builder" : "@angular-devkit/build-angular:protractor",
"options" : {
"protractorConfig" : "./protractor.conf.js",
"devServerTarget" : "no-comment:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": [
"**/node_modules/**"
]
"lint" : {
"builder" : "@angular-devkit/build-angular:tslint",
"options" : {
"tsConfig" : [ "e2e/tsconfig.e2e.json" ],
"exclude" : [ "**/node_modules/**" ]
}
}
}
},
"__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,
"extractCss" : true,
"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/**" ]
}
}
}
}
},
"defaultProject": "no-comment",
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"styleext": "less"
"schematics" : {
"@schematics/angular:component" : {
"prefix" : "app",
"styleext" : "less"
},
"@schematics/angular:directive": {
"prefix": "app"
"@schematics/angular:directive" : {
"prefix" : "app"
}
}
}

6161
front/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -23,13 +23,14 @@
"@angular/platform-browser-dynamic": "~9.0.5",
"@angular/router": "^9.0.5",
"core-js": "^3.6.4",
"jquery": "3.4.1",
"jquery": "^3.5.1",
"ngx-select-dropdown": "^1.4.4",
"rxjs": "^6.5.4",
"tslib": "^1.11.1",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.900.5",
"@angular-devkit/build-angular": "^0.901.9",
"@angular/cli": "^9.0.5",
"@angular/compiler-cli": "~9.0.5",
"@angular/language-service": "~9.0.5",

View File

@ -12,11 +12,14 @@ upgrade package
npm audit fix
```
## npm install -g angular-cli
start the application:
```
npx ng serve --watch
```
plus facilement:
npm install @angular-devkit/build-angular@0.901.9
npm start

View File

@ -20,12 +20,14 @@ import { SettingsComponent } from './scene/settings/settings';
import { VideoEditComponent } from './scene/video-edit/video-edit';
import { GroupEditComponent } from './scene/group-edit/group-edit';
import { SaisonEditComponent } from './scene/saison-edit/saison-edit';
import { UploadScene } from './scene/upload/upload';
//import { HelpComponent } from './help/help.component';
const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full'},
{ path: 'home', component: HomeComponent },
{ path: 'upload', component: UploadScene },
{ path: 'type/:univers_id/:type_id/:group_id/:saison_id/:video_id', component: TypeComponent },
{ path: 'univers/:univers_id/:type_id/:group_id/:saison_id/:video_id', component: UniversComponent },

View File

@ -35,10 +35,10 @@ export class AppComponent implements OnInit {
this.userService.loginSha(login, password)
.then(function(response) {
console.log("auto log ==> OK");
self.sessionService.create(response['sessionId'],
self.sessionService.create(response['session'],
response['login'],
response['email'],
response['role'],
response['admin'],
response['avatar']);
//self.router.navigate(['home']);
}).catch(function(response) {

View File

@ -12,7 +12,7 @@ import { HttpClientModule } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { routing } from './app-routing.module';
import { SelectDropDownModule } from 'ngx-select-dropdown'
import { UploadFileComponent } from './component/upload-file/upload-file';
import { TopMenuComponent } from './component/top-menu/top-menu';
@ -37,6 +37,7 @@ import { SettingsComponent } from './scene/settings/settings';
import { ErrorViewerComponent } from './scene/error-viewer/error-viewer';
import { ErrorComponent } from './error/error';
import { VideoEditComponent } from './scene/video-edit/video-edit';
import { UploadScene } from './scene/upload/upload';
import { SaisonEditComponent } from './scene/saison-edit/saison-edit';
import { GroupEditComponent } from './scene/group-edit/group-edit';
@ -44,6 +45,7 @@ import { AuthService } from './service/auth';
import { ArianeService } from './service/ariane';
import { CookiesService } from './service/cookies';
import { HttpWrapperService } from './service/http-wrapper';
import { HttpOAuthWrapperService } from './service/http-oauth-wrapper';
import { UserService } from './service/user';
import { UniversService } from './service/univers';
import { GroupService } from './service/group';
@ -82,7 +84,8 @@ import { AppComponent } from './app.component';
SaisonEditComponent,
GroupEditComponent,
PopInComponent,
CreateTypeComponent
CreateTypeComponent,
UploadScene
],
imports: [
BrowserModule,
@ -92,11 +95,13 @@ import { AppComponent } from './app.component';
HttpClientModule,
FormsModule,
ReactiveFormsModule,
MatProgressSpinnerModule
MatProgressSpinnerModule,
SelectDropDownModule
],
providers: [
PopInService,
HttpWrapperService,
HttpOAuthWrapperService,
BddService,
AuthService,
SessionService,

View File

@ -126,6 +126,11 @@
(auxclick)="onLogout($event)">
<i class="material-icons">exit_to_app</i> Sign out
</button>
<button class="item"
(click)="onAddMedia($event)"
(auxclick)="onAddMedia($event)">
<i class="material-icons">add_circle</i> Add media
</button>
</div>
</div>
<div class="fill-all" *ngIf="displayEditMenu == true" (click)="onOutUserProperty()">

View File

@ -13,263 +13,269 @@ 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_univers_id: number = null;
public ariane_univers_name: string = null;
public ariane_group_id: number = null;
public ariane_group_name: string = null;
public ariane_saison_id: number = null;
public ariane_saison_name: string = null;
public ariane_video_id: number = null;
public ariane_video_name: string = null;
public edit_show: boolean = false;
constructor(private router: Router,
private sessionService: SessionService,
private arianeService: ArianeService) {
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_univers_id: number = null;
public ariane_univers_name: string = null;
public ariane_group_id: number = null;
public ariane_group_name: string = null;
public ariane_saison_id: number = null;
public ariane_saison_name: string = null;
public ariane_video_id: number = null;
public ariane_video_name: string = null;
public edit_show: 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.univers_change.subscribe(univers_id => {
this.ariane_univers_id = univers_id;
this.ariane_univers_name = this.arianeService.getUniversName();
this.updateEditShow();
});
this.arianeService.group_change.subscribe(group_id => {
this.ariane_group_id = group_id;
this.ariane_group_name = this.arianeService.getGroupName();
this.updateEditShow();
});
this.arianeService.saison_change.subscribe(saison_id => {
this.ariane_saison_id = saison_id;
this.ariane_saison_name = this.arianeService.getSaisonName();
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_univers_id != null
||*/ this.ariane_group_id != null
|| this.ariane_saison_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);
}
onSubEditSaison(_event: any): void {
console.log("onSubEdit()");
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateSaisonEdit(this.ariane_saison_id, _event.which==2);
}
onSubEditGroup(_event: any): void {
console.log("onSubEdit()");
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateGroupEdit(this.ariane_group_id, _event.which==2);
}
onSubEditUnivers(_event: any): void {
console.log("onSubEdit()");
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateUniversEdit(this.ariane_univers_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;
}
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.univers_change.subscribe(univers_id => {
this.ariane_univers_id = univers_id;
this.ariane_univers_name = this.arianeService.getUniversName();
this.updateEditShow();
});
this.arianeService.group_change.subscribe(group_id => {
this.ariane_group_id = group_id;
this.ariane_group_name = this.arianeService.getGroupName();
this.updateEditShow();
});
this.arianeService.saison_change.subscribe(saison_id => {
this.ariane_saison_id = saison_id;
this.ariane_saison_name = this.arianeService.getSaisonName();
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_univers_id != null
||*/ this.ariane_group_id != null
|| this.ariane_saison_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);
}
onSubEditSaison(_event: any): void {
console.log("onSubEdit()");
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateSaisonEdit(this.ariane_saison_id, _event.which==2);
}
onSubEditGroup(_event: any): void {
console.log("onSubEdit()");
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateGroupEdit(this.ariane_group_id, _event.which==2);
}
onSubEditUnivers(_event: any): void {
console.log("onSubEdit()");
this.displayEditMenu = false;
this.displayUserMenu = false;
this.arianeService.navigateUniversEdit(this.ariane_univers_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;
}
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);
}
onArianeUnivers(_event: any): void {
console.log("onArianeUnivers(" + this.ariane_univers_id + ")");
this.arianeService.navigateUnivers(this.ariane_univers_id, _event.which==2);
}
onArianeGroup(_event: any): void {
console.log("onArianeGroup(" + this.ariane_group_id + ")");
this.arianeService.navigateGroup(this.ariane_group_id, _event.which==2);
}
onArianeSaison(_event: any): void {
console.log("onArianeSaison(" + this.ariane_saison_id + ")");
this.arianeService.navigateSaison(this.ariane_saison_id, _event.which==2);
}
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);
}
onArianeUnivers(_event: any): void {
console.log("onArianeUnivers(" + this.ariane_univers_id + ")");
this.arianeService.navigateUnivers(this.ariane_univers_id, _event.which==2);
}
onArianeGroup(_event: any): void {
console.log("onArianeGroup(" + this.ariane_group_id + ")");
this.arianeService.navigateGroup(this.ariane_group_id, _event.which==2);
}
onArianeSaison(_event: any): void {
console.log("onArianeSaison(" + this.ariane_saison_id + ")");
this.arianeService.navigateSaison(this.ariane_saison_id, _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;
}
$rootScope.$on(SESSION_EVENTS.login, function(event) {
console.log("event ... " + SESSION_EVENTS.login);
$scope.login = Session.getLogin();
$scope.avatar = Session.getAvatar();
$scope.displayUserMenu = false;
$rootScope.currentDisplay = "home.html";
$rootScope.currentModal = "";
$rootScope.currentModalCanRemove = false;
});
$rootScope.$on(SESSION_EVENTS.logout, function(event) {
console.log("event ... " + SESSION_EVENTS.login);
$scope.login = Session.getLogin();
$scope.avatar = Session.getAvatar();
$scope.displayUserMenu = false;
$rootScope.currentDisplay = "home.html";
$rootScope.currentModal = "";
$rootScope.currentModalCanRemove = false;
});
$scope.login = Session.getLogin();
$scope.avatar = Session.getAvatar();
$scope.displayUserMenu = false;
$scope.onAvatar = function() {
$scope.displayUserMenu = !$scope.displayUserMenu;
}
$scope.onHome = function() {
$rootScope.currentDisplay = "home.html";
}
$scope.onSignIn = function() {
Session.destroy();
$rootScope.currentDisplay = "signUp.html";
}
$scope.onLogin = function() {
Session.destroy();
$rootScope.currentModal = "login.html";
$scope.displayUserMenu = false;
}
$scope.onLogout = function() {
Session.destroy();
$rootScope.currentDisplay = "home.html";
$scope.displayUserMenu = false;
}
$scope.onSetting = function() {
$rootScope.currentModal = "";
$rootScope.currentDisplay = "setting.html";
$scope.displayUserMenu = false;
}
$scope.onHelp = function() {
$rootScope.currentModal = "";
$rootScope.currentDisplay = "help.html";
$scope.displayUserMenu = false;
}
$scope.onOutUserProperty = function() {
console.log("onOutUserProperty ==> event...");
$rootScope.currentModal = "";
$scope.displayUserMenu = false;
}
});
*/

View File

@ -31,8 +31,13 @@
</label>
</div>
<div class="container">
<button class="button cancel color-button-cancel color-shadow-black" (click)="onCancel()">Cancel</button>
<button class="button login color-button-validate color-shadow-black" id="login-button" [disabled]="loginButtonDisabled" (click)="onLogin()" type="submit">Login</button>
<button class="button cancel color-button-cancel color-shadow-black"
(click)="onCancel()">Cancel</button>
<button class="button login color-button-validate color-shadow-black"
id="login-button"
[disabled]="loginButtonDisabled"
(click)="onLogin()"
type="submit">Login</button>
</div>
<div class="container">
{{error}}

View File

@ -33,7 +33,7 @@ export let checkEmailValidity = function(_value:string):boolean {
};
export let checkPasswordValidity = function(_value:string):boolean {
let regexCheck = new RegExp("^[a-zA-Z0-9_\.@ %:;,=}{\?\!\*\+\(\)\[\]\|&#%~°/\\\<\>-]+$");
let regexCheck = new RegExp("^[a-zA-Z0-9_\.@ %:;,=}{\?\!\*\+\(\)\[\]\|&#%~/\\\<\>-£€]+$");
if (regexCheck.test(_value)) {
return true;
}
@ -87,7 +87,9 @@ export class LoginComponent implements OnInit {
}
this.error = "";
}
/**
* Check the login writing rules
*/
checkLogin(_newValue:string):void {
this.login = _newValue;
if (this.login == null) {
@ -120,6 +122,9 @@ export class LoginComponent implements OnInit {
this.updateButtonVisibility();
}
/**
* Check the password writing rules
*/
checkPassword(_newValue:string):void {
this.password = _newValue;
if (this.password == null) {
@ -154,8 +159,8 @@ export class LoginComponent implements OnInit {
response['role'],
response['avatar']);
if (self.rememberMe == true) {
self.cookiesService.set("yota-login", response['login'], 365);
self.cookiesService.set("yota-password", SHA512(self.password), 365);
self.cookiesService.set("yota-login", response['login'], 120);
self.cookiesService.set("yota-password", SHA512(self.password), 60);
}
self.router.navigate(['home']);
}).catch(function(response) {

View File

@ -0,0 +1,135 @@
<div class="main-reduce">
<div class="fill-all">
<div class="title">
&gt;&gt;&gt; Upload Media &lt;&lt;&lt;
</div>
<div class="request_raw">
<div class="label">
format:
</div>
<div class="input">
The format of the media permit to automatic find meta-data:<br/>
Media series name-media universe name-sXX-eXX-my name of my media.mkv<br/>
<b> example:</b> Captain America-Marvel-e02-The winter soldier.mkv
</div>
</div>
<div class="request_raw2">
<div class="label">
Media:
</div>
<div class="input">
<input type="file"
(change)="onChangeFile($event.target)"
placeholder="Select a media file"
accept=".mkv,.webm"/>{{upload_file_value}}
</div>
</div>
<div class="clear"></div>
<div class="title">
Parsed data:
</div>
<div class="request_raw">
<div class="label">
*Type:
</div>
<div class="input">
<select [ngModel]="type_id"
(ngModelChange)="onChangeType($event)">
<option *ngFor="let element of listType" [ngValue]="element.value">{{element.label}}</option>
</select>
</div>
</div>
<div class="request_raw">
<div class="label">
*Title:
</div>
<div class="input">
<input type="text"
placeholder="Name of the Media"
[value]="parse_title"
(input)="onTitle($event.target.value)"
/>
</div>
</div>
<div class="request_raw">
<div class="label">
Universe:
</div>
<div class="input">
<input type="text"
placeholder="Universe of the Media"
[value]="parse_universe"
(input)="onUniverse($event.target.value)"
/>
</div>
</div>
<div class="request_raw">
<div class="label">
Series:
</div>
<div class="input">
<input type="text"
placeholder="Series of the Media"
[value]="parse_serie"
(input)="onSerie($event.target.value)"
/>
</div>
</div>
<div class="request_raw">
<div class="label">
==&gt;
</div>
<div class="input">
<!-- <ngx-select-dropdown [config]="config" [options]="listGroup2"
[(ngModel)]="parse_serie" [multiple]="false" ></ngx-select-dropdown>-->
<select [ngModel]="serie_id"
(ngModelChange)="onChangeGroup($event)">
<option *ngFor="let element of listGroup" [ngValue]="element.value">{{element.label}}</option>
</select>
</div>
<!-- <div class="input_add">
<button class="button color-button-normal color-shadow-black" (click)="newSerie()" type="submit">
<i class="material-icons">add_circle_outline</i>
</button>
</div>-->
</div>
<div class="request_raw">
<div class="label">
Season:
</div>
<div class="input">
<input type="number"
pattern="[0-9]{0-4}"
placeholder="saison of the Media"
[value]="parse_saison"
(input)="onSaison($event.target.value)"
/>
</div>
</div>
<div class="request_raw">
<div class="label">
Episode:
</div>
<div class="input">
<input type="number"
pattern="[0-9]{0-4}"
placeholder="Episode of the Media"
[value]="parse_episode"
(input)="onEpisode($event.target.value)"
/>
</div>
</div>
<div class="clear"></div>
<div class="send_value">
<button class="button fill-x color-button-validate color-shadow-black"
[disabled]="!need_send"
(click)="sendFile()"
type="submit">
<i class="material-icons">cloud_upload</i> Upload
</button>
</div>
<div class="clear"></div>
</div>
</div>

View File

@ -0,0 +1,145 @@
d.fill-all{
//width:100%;
max-width:80%;
height:100%;
margin: 20px auto;
padding: 20px;
border:0;
background-color: rgba(200, 200, 200, 0.5);
box-shadow: 0px 2px 4px 0 rgba(0, 0, 0, 0.6);
}
.title {
width: 90%;
margin: 0 auto;
font-size: 50px;
text-align: center;
}
.request_raw2 {
width: 90%;
margin: 0 auto;
height: 160px;
.label {
width: 15%;
margin-right: 10px;
text-align: right;
float: left;
display: block;
}
.input {
width: 75%;
float: left;
display: block;
textarea {
width: 100%;
font-size: 20px;
resize: none;
}
}
}
.request_raw {
width: 90%;
margin: 0 auto;
height: 45px;
.label {
width: 15%;
margin-right: 10px;
text-align: right;
float: left;
display: block;
}
.input {
width: 75%;
float: left;
display: block;
input {
width: 100%;
font-size: 20px;
}
select {
width: 100%;
font-size: 20px;
}
textarea {
width: 100%;
font-size: 20px;
}
}
.input_add {
width: 5%;
float: right;
display: block;
}
.cover_div {
float: left;
display: block;
}
.cover_remove_div {
float: left;
display: block;
}
.cover {
max-width: 30%;
}
}
.send_value {
width: 300px;
margin: 0 auto;
padding: 10px;
display: block;
}
.item {
font-size: 20px;
height: 21%;
width: 23%;
margin: 1%;
padding: 0;
overflow: hidden;
//box-shadow: 0 1px 1.5px 0 rgba(0,0,0,.12),0 1px 1px 0 rgba(0,0,0,.24);
box-shadow: 0px 2px 4px 0 rgba(0, 0, 0, 0.6);
line-height: normal;
border: none;
font-family: "Roboto","Helvetica","Arial",sans-serif;
font-weight: 500;
text-transform: uppercase;
letter-spacing: 0;
will-change: box-shadow;
outline: none;
cursor: pointer;
text-decoration: none;
text-align: center;
vertical-align: middle;
transition-duration: 0.4s;
float:left;
display:block;
h1 {
font-size: 24px;
}
&:hover {
background-color: #F00;
}
.material-icons {
vertical-align: middle;
}
.material-icons {
position: absolute;
top: 50%;
left: 50%;
transform: ~"translate(-12px,-12px)";
line-height: 24px;
width: 24px;
}
}
.item-video {
&:hover {
background-color: #0F0;
}
}

View File

@ -0,0 +1,477 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute, ParamMap } from '@angular/router';
import { Location } from '@angular/common';
import { NgForm } from '@angular/forms';
import { FormGroup, FormControl } from "@angular/forms";
import { fadeInAnimation } from '../../_animations/index';
import { HttpWrapperService } from '../../service/http-wrapper';
import { HttpEventType, HttpResponse } from '@angular/common/http';
import { PopInService } from '../../service/popin';
import { TypeService } from '../../service/type';
import { UniversService } from '../../service/univers';
import { GroupService } from '../../service/group';
import { VideoService } from '../../service/video';
import { DataService } from '../../service/data';
import { ArianeService } from '../../service/ariane';
export class ElementList {
value: number;
label: string;
constructor(_value: number, _label: string) {
this.value = _value;
this.label = _label;
}
}
@Component({
selector: 'app-video-edit',
templateUrl: './upload.html',
styleUrls: ['./upload.less'],
animations: [fadeInAnimation],
host: { '[@fadeInAnimation]': '' }
})
// https://www.sitepoint.com/angular-forms/
export class UploadScene implements OnInit {
id_video: number = -1;
error: string = "";
coverFile: File;
mediaFile: File = null;
upload_file_value: string = ""
selectedFiles: FileList;
type_id: number = undefined
serie_id: number = undefined
need_send: boolean = false;
covers_display: Array<any> = [];
listType: ElementList[] = [
{ value: undefined, label: '---' },
];
listUnivers: ElementList[] = [
{ value: undefined, label: '---' },
{ value: null, label: '---' },
];
listGroup: ElementList[] = [
{ value: undefined, label: '---' },
];
listGroup2 = [{ id: undefined, description: '---' }];
/*
config = {
displayKey: "label", // if objects array passed which key to be displayed defaults to description
search: true,
limitTo: 3,
};
*/
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
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,
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
}
listSaison: ElementList[] = [
{ value: undefined, label: '---' },
];
parse_universe: string = "";
parse_serie: string = "";
parse_saison: number = null;
parse_episode: number = null;
parse_title: string = "";
constructor(private route: ActivatedRoute,
private router: Router,
private locate: Location,
private dataService: DataService,
private typeService: TypeService,
private universService: UniversService,
private groupService: GroupService,
private videoService: VideoService,
private httpService: HttpWrapperService,
private arianeService: ArianeService,
private popInService: PopInService) {
}
updateNeedSend (): boolean {
if (this.mediaFile == null) {
this.need_send = false;
return;
}
this.need_send = true;
if (this.parse_title === undefined || this.parse_title === null || this.parse_title === "") {
this.need_send = false;
}
if (this.type_id === undefined) {
this.need_send = false;
}
return this.need_send;
}
ngOnInit () {
this.arianeService.updateManual(this.route.snapshot.paramMap);
this.id_video = this.arianeService.getVideoId();
let self = this;
this.listType = [{ value: undefined, label: '---' }];
this.listUnivers = [{ value: undefined, label: '---' }];
this.listGroup = [{ value: undefined, label: '---' }];
this.listSaison = [{ value: undefined, label: '---' }];
this.universService.getData()
.then(function (response2) {
for (let iii = 0; iii < response2.length; iii++) {
self.listUnivers.push({ value: response2[iii].id, label: response2[iii].name });
}
}).catch(function (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 });
}
}).catch(function (response2) {
console.log("get response22 : " + JSON.stringify(response2, null, 2));
});
//this.groupService.getOrder()
this.groupService.getData()
.then(function (response3) {
for (let iii = 0; iii < response3.length; iii++) {
self.listGroup.push({ value: response3[iii].id, label: response3[iii].name });
self.listGroup2 = [...self.listGroup2,{ id: response3[iii].id, description: response3[iii].name }];
//self.listGroup2.push(response3[iii].name);
console.log("[" + self.data_id + "] Get serie: " + response3[iii].id + ", label:" + response3[iii].name)
}
}).catch(function (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));
self.data.name = response.name;
self.data.description = response.description;
self.data.episode = response.episode;
self.data.univers_id = response.univers_id;
self.data.data_id = response.data_id;
self.data.time = response.time;
self.data.generated_name = response.generated_name;
self.onChangeType(response.type_id);
self.onChangeGroup(response.serie_id);
self.data.saison_id = response.saison_id;
self.data_ori = self.data.clone();
if (response.covers !== undefined && response.covers !== null) {
for (let iii = 0; iii < response.covers.length; iii++) {
self.data.covers.push(response.covers[iii]);
self.covers_display.push({
id: response.covers[iii],
url: self.videoService.getCoverUrl(response.covers[iii])
});
}
} else {
self.covers_display = []
}
self.updateNeedSend();
console.log("covers_list : " + JSON.stringify(self.covers_display, null, 2));
}).catch(function (response) {
self.error = "Can not get the data";
self.data = new DataToSend();
self.covers_display = [];
self.data_ori = self.data.clone();
self.updateNeedSend();
});
*/
console.log(" END INIT ");
}
onChangeType (_value: any): void {
console.log("Change requested of type ... " + _value);
this.type_id = _value;
//this.data.serie_id = null;
//this.data.saison_id = null;
//this.listGroup = [{value: undefined, label: '---'}];
//this.listSaison = [{value: undefined, label: '---'}];
let self = this;
this.updateNeedSend();
/*
if (this.type_id != undefined) {
self.typeService.getSubGroup(this.type_id, ["id", "name"])
.then(function(response2) {
for(let iii= 0; iii < response2.length; iii++) {
self.listGroup.push({value: response2[iii].id, label: response2[iii].name});
}
}).catch(function(response2) {
console.log("get response22 : " + JSON.stringify(response2, null, 2));
});
}
*/
}
onChangeGroup (_value: any): void {
this.serie_id = _value;
if (_value === undefined || _value === null) {
} else {
for (let iii = 0 ; iii<this.listGroup.length ; iii++) {
if (this.listGroup[iii].value == _value) {
this.parse_serie = this.listGroup[iii].label;
break;
}
}
}
this.updateNeedSend();
}
onSaison (_value: any): void {
this.parse_saison = _value;
this.updateNeedSend();
}
onTitle (_value: any): void {
this.parse_title = _value;
this.updateNeedSend();
}
onUniverse (_value: any): void {
this.parse_universe = _value;
this.updateNeedSend();
}
onEpisode (_value: any): void {
this.parse_episode = parseInt(_value.value, 10);
this.updateNeedSend();
}
onSerie (_value: any): void {
this.parse_serie = _value;
let self = this;
if (this.parse_serie != "") {
this.groupService.getLike(this.parse_serie)
.then(function(response) {
console.log("find elemet: " + response.name + " " + response.id);
self.serie_id = response.id;
}).catch(function(response) {
console.log("CAN NOT find element: " );
self.serie_id = null;
});
}
this.updateNeedSend();
}
sendFile(): void {
}
sendValues (): void {
console.log("send new values....");
let data = {}
if (this.data.name != this.data_ori.name) {
data["name"] = this.data.name;
}
if (this.data.description != this.data_ori.description) {
data["description"] = this.data.description;
}
if (this.data.episode != this.data_ori.episode) {
data["episode"] = this.data.episode;
}
if (this.data.time != this.data_ori.time) {
data["time"] = this.data.time;
}
if (this.data.type_id != this.data_ori.type_id) {
data["type_id"] = this.data.type_id;
}
if (this.data.univers_id != this.data_ori.univers_id) {
data["univers_id"] = this.data.univers_id;
}
if (this.data.serie_id != this.data_ori.serie_id) {
data["serie_id"] = this.data.serie_id;
}
if (this.data.saison_id != this.data_ori.saison_id) {
data["saison_id"] = this.data.saison_id;
}
let tmpp = this.data.clone();
let self = this;
this.videoService.put(this.id_video, data)
.then(function (response3) {
self.data_ori = tmpp;
self.updateNeedSend();
}).catch(function (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();
this.uploadFile(_event.dataTransfer.files[0]);
}
// At the drag drop area
// (dragover)="onDragOverFile($event)"
onDragOverFile (_event) {
_event.stopPropagation();
_event.preventDefault();
}
// At the file input element
// (change)="selectFile($event)"
onChangeFile (_value: any): void {
this.parse_universe = "";
this.parse_serie = "";
this.parse_saison = null;
this.parse_episode = null;
this.parse_title = "";
this.selectedFiles = _value.files
this.mediaFile = this.selectedFiles[0];
console.log("select file " + this.mediaFile.name);
const splitElement = this.mediaFile.name.split('-');
if (splitElement.length == 1) {
this.parse_title = splitElement[0];
} else {
if (splitElement.length>=2) {
this.parse_serie = splitElement[0];
}
splitElement.splice(0,1);
if (splitElement.length == 1) {
this.parse_title = splitElement[0];
} else {
while (splitElement.length>0) {
let element = splitElement[0];
let find = false;
if (this.parse_saison == null) {
if (element.length >= 1 && (element[0] == 's' || element[0] == 'S') ) {
element = element.substring(1);
this.parse_saison = parseInt(element, 10);
find = true;
}
}
if (this.parse_episode == null && find == false) {
if (element.length >= 1 && (element[0] == 'e' || element[0] == 'E') ) {
element = element.substring(1);
this.parse_episode = parseInt(element, 10);
find = true;
}
}
if (find == false) {
if (this.parse_saison == null && this.parse_episode == null) {
if (this.parse_universe == "") {
this.parse_universe = element;
} else {
this.parse_universe = this.parse_universe + "-" + element;
}
} else {
if (this.parse_title == "") {
this.parse_title = element;
} else {
this.parse_title = this.parse_title + "-" + element;
}
}
}
splitElement.splice(0,1);
}
}
}
// remove extention
this.parse_title = this.parse_title.replace(new RegExp("\.(mkv|MKV|Mkv|webm|WEBM|Webm)"),"");
//this.uploadFile(this.coverFile);
this.updateNeedSend();
let self = this;
if (this.parse_serie != "") {
this.groupService.getLike(this.parse_serie)
.then(function(response) {
console.log("find elemet: " + response.name + " " + response.id);
self.serie_id = response.id;
}).catch(function(response) {
console.log("CAN NOT find element: " );
});
}
}
uploadFile (_file: File) {
if (_file == undefined) {
console.log("No file selected!");
return;
}
let self = this;
this.dataService.sendFile(_file)
.then(function (response) {
console.log("get response of video : " + JSON.stringify(response, null, 2));
let id_of_image = response.id;
self.videoService.addCover(self.id_video, id_of_image)
.then(function (response) {
console.log("cover added");
self.covers_display.push(self.videoService.getCoverUrl(id_of_image));
}).catch(function (response) {
console.log("Can not cover in the cover_list...");
});
}).catch(function (response) {
//self.error = "Can not get the data";
console.log("Can not add the data in the system...");
});
}
removeCover (_id) {
console.log("Request remove cover: " + _id);
}
removeMedia () {
console.log("Request remove Media...");
this.videoService.delete(this.id_video)
.then(function (response3) {
//self.data_ori = tmpp;
//self.updateNeedSend();
}).catch(function (response3) {
//self.updateNeedSend();
});
}
eventPopUpSaison (_event: string): void {
console.log("GET event: " + _event);
this.popInService.close("popin-new-saison");
}
eventPopUpSerie (_event: string): void {
console.log("GET event: " + _event);
this.popInService.close("popin-new-serie");
}
eventPopUpType (_event: string): void {
console.log("GET event: " + _event);
this.popInService.close("popin-new-type");
}
eventPopUpUnivers (_event: string): void {
console.log("GET event: " + _event);
this.popInService.close("popin-new-univers");
}
newSaison (): void {
console.log("Request new Saison...");
this.popInService.open("popin-new-saison");
}
newSerie (): void {
console.log("Request new Serie...");
this.popInService.open("popin-new-serie");
}
newType (): void {
console.log("Request new Type...");
this.popInService.open("popin-create-type");
}
newUnivers () {
console.log("Request new Univers...");
this.popInService.open("popin-new-univers");
}
}

View File

@ -16,344 +16,344 @@ import { VideoService } from 'app/service/video';
import { environment } from 'environments/environment';
export class InputOrders {
public type_id: number = null;
public univers_id: number = null;
public group_id: number = null;
public saison_id: number = null;
public video_id: number = null;
public type_id: number = null;
public univers_id: number = null;
public group_id: number = null;
public saison_id: number = null;
public video_id: number = null;
}
@Injectable()
export class ArianeService {
public type_id: number = null;
public type_name: string = null;
@Output() type_change: EventEmitter<number> = new EventEmitter();
public univers_id: number = null;
public univers_name: string = null;
@Output() univers_change: EventEmitter<number> = new EventEmitter();
public group_id: number = null;
public group_name: string = null;
@Output() group_change: EventEmitter<number> = new EventEmitter();
public saison_id: number = null;
public saison_name: string = null;
@Output() saison_change: EventEmitter<number> = new EventEmitter();
public video_id: number = null;
public video_name: string = null;
@Output() video_change: EventEmitter<number> = new EventEmitter();
constructor(private route: ActivatedRoute,
private router: Router,
private typeService: TypeService,
private universService: UniversService,
private groupService: GroupService,
private saisonService: SaisonService,
private videoService: VideoService) {
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);
}
}
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 univers_id = params.get('univers_id');
if (univers_id === null || univers_id === undefined || univers_id == "null" || univers_id == "NULL" || univers_id == "") {
univers_id = null;
} else {
univers_id = parseInt(univers_id)
}
console.log("univers_id = " + univers_id + " " + params.get('univers_id'));
let group_id = params.get('group_id');
if (group_id === null || group_id === undefined || group_id == "null" || group_id == "NULL" || group_id == "") {
group_id = null;
} else {
group_id = parseInt(group_id)
}
console.log("group_id = " + group_id + " " + params.get('group_id'));
let saison_id = params.get('saison_id');
if (saison_id === null || saison_id === undefined || saison_id == "null" || saison_id == "NULL" || saison_id == "") {
saison_id = null;
} else {
saison_id = parseInt(saison_id)
}
console.log("saison_id = " + saison_id + " " + params.get('saison_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.setUnivers(univers_id);
this.setGroup(group_id);
this.setSaison(saison_id);
this.setVideo(video_id);
}
reset():void {
this.type_id = null;
this.type_name = null;
this.type_change.emit(this.type_id);
this.univers_id = null;
this.univers_name = null;
this.univers_change.emit(this.univers_id);
this.group_id = null;
this.group_name = null;
this.group_change.emit(this.group_id);
this.saison_id = null;
this.saison_name = null;
this.saison_change.emit(this.saison_id);
this.video_id = null;
this.video_name = null;
this.video_change.emit(this.video_id);
}
/*
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.univers_id = parseInt(this.route.snapshot.paramMap.get('univers_id'));
if (out.univers_id == 0){
out.univers_id = undefined;
}
out.group_id = parseInt(this.route.snapshot.paramMap.get('group_id'));
if (out.group_id == 0){
out.group_id = undefined;
}
out.saison_id = parseInt(this.route.snapshot.paramMap.get('saison_id'));
if (out.saison_id == 0){
out.saison_id = undefined;
}
out.video_id = parseInt(this.route.snapshot.paramMap.get('video_id'));
if (out.video_id == 0){
out.video_id = undefined;
}
return out;
}
routeTo(_data:InputOrders, _destination:string = null) {
routeTo = ""
//if (
this.router.navigate(['/type/' + this.type_id + '/group/' + this.id_group + '/saison/' + _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);
});
}
getTypeId():number {
return this.type_id;
}
getTypeName():string {
return this.type_name;
}
setUnivers(_id:number) {
if (this.univers_id == _id) {
return;
}
if (_id === undefined) {
return;
}
this.univers_id = _id;
this.univers_name = "??--??";
if (this.univers_id === null) {
this.univers_change.emit(this.univers_id);
return;
}
let self = this;
this.universService.get(_id)
.then(function(response) {
self.univers_name = response.number
self.univers_change.emit(self.univers_id);
}).catch(function(response) {
self.univers_change.emit(self.univers_id);
});
}
getUniversId():number {
return this.univers_id;
}
getUniversName():string {
return this.univers_name;
}
setGroup(_id:number):void {
if (this.group_id == _id) {
return;
}
if (_id === undefined) {
return;
}
this.group_id = _id;
this.group_name = "??--??";
if (this.group_id === null) {
this.group_change.emit(this.group_id);
return;
}
let self = this;
this.groupService.get(_id)
.then(function(response) {
self.group_name = response.name
self.group_change.emit(self.group_id);
}).catch(function(response) {
self.group_change.emit(self.group_id);
});
}
getGroupId():number {
return this.group_id;
}
getGroupName():string {
return this.group_name;
}
setSaison(_id:number):void {
if (this.saison_id == _id) {
return;
}
if (_id === undefined) {
return;
}
this.saison_id = _id;
this.saison_name = "??--??";
if (this.saison_id === null) {
this.saison_change.emit(this.saison_id);
return;
}
let self = this;
this.saisonService.get(_id)
.then(function(response) {
//self.setGroup(response.group_id);
self.saison_name = response.name
self.saison_change.emit(self.saison_id);
}).catch(function(response) {
self.saison_change.emit(self.saison_id);
});
}
getSaisonId():number {
return this.saison_id;
}
getSaisonName():string {
return this.saison_name;
}
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.setSaison(response.saison_id);
//self.setGroup(response.group_id);
self.video_name = response.name;
self.video_change.emit(self.video_id);
}).catch(function(response) {
self.video_change.emit(self.video_id);
});
}
getVideoId():number {
return this.video_id;
}
getVideoName():string {
return this.video_name;
}
genericNavigate(_destination:string, _universId:number, _typeId:number, _groupId:number, _saisonId:number, _videoId:number, _newWindows:boolean):void {
let addressOffset = _destination + '/' + _universId + '/' + _typeId + '/' + _groupId + '/' + _saisonId + '/' + _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]);
}
}
public type_id: number = null;
public type_name: string = null;
@Output() type_change: EventEmitter<number> = new EventEmitter();
public univers_id: number = null;
public univers_name: string = null;
@Output() univers_change: EventEmitter<number> = new EventEmitter();
public group_id: number = null;
public group_name: string = null;
@Output() group_change: EventEmitter<number> = new EventEmitter();
public saison_id: number = null;
public saison_name: string = null;
@Output() saison_change: EventEmitter<number> = new EventEmitter();
public video_id: number = null;
public video_name: string = null;
@Output() video_change: EventEmitter<number> = new EventEmitter();
constructor(private route: ActivatedRoute,
private router: Router,
private typeService: TypeService,
private universService: UniversService,
private groupService: GroupService,
private saisonService: SaisonService,
private videoService: VideoService) {
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);
}
}
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 univers_id = params.get('univers_id');
if (univers_id === null || univers_id === undefined || univers_id == "null" || univers_id == "NULL" || univers_id == "") {
univers_id = null;
} else {
univers_id = parseInt(univers_id)
}
console.log("univers_id = " + univers_id + " " + params.get('univers_id'));
let group_id = params.get('group_id');
if (group_id === null || group_id === undefined || group_id == "null" || group_id == "NULL" || group_id == "") {
group_id = null;
} else {
group_id = parseInt(group_id)
}
console.log("group_id = " + group_id + " " + params.get('group_id'));
let saison_id = params.get('saison_id');
if (saison_id === null || saison_id === undefined || saison_id == "null" || saison_id == "NULL" || saison_id == "") {
saison_id = null;
} else {
saison_id = parseInt(saison_id)
}
console.log("saison_id = " + saison_id + " " + params.get('saison_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.setUnivers(univers_id);
this.setGroup(group_id);
this.setSaison(saison_id);
this.setVideo(video_id);
}
reset():void {
this.type_id = null;
this.type_name = null;
this.type_change.emit(this.type_id);
this.univers_id = null;
this.univers_name = null;
this.univers_change.emit(this.univers_id);
this.group_id = null;
this.group_name = null;
this.group_change.emit(this.group_id);
this.saison_id = null;
this.saison_name = null;
this.saison_change.emit(this.saison_id);
this.video_id = null;
this.video_name = null;
this.video_change.emit(this.video_id);
}
/*
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.univers_id = parseInt(this.route.snapshot.paramMap.get('univers_id'));
if (out.univers_id == 0){
out.univers_id = undefined;
}
out.group_id = parseInt(this.route.snapshot.paramMap.get('group_id'));
if (out.group_id == 0){
out.group_id = undefined;
}
out.saison_id = parseInt(this.route.snapshot.paramMap.get('saison_id'));
if (out.saison_id == 0){
out.saison_id = undefined;
}
out.video_id = parseInt(this.route.snapshot.paramMap.get('video_id'));
if (out.video_id == 0){
out.video_id = undefined;
}
return out;
}
routeTo(_data:InputOrders, _destination:string = null) {
routeTo = ""
//if (
this.router.navigate(['/type/' + this.type_id + '/group/' + this.id_group + '/saison/' + _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);
});
}
getTypeId():number {
return this.type_id;
}
getTypeName():string {
return this.type_name;
}
setUnivers(_id:number) {
if (this.univers_id == _id) {
return;
}
if (_id === undefined) {
return;
}
this.univers_id = _id;
this.univers_name = "??--??";
if (this.univers_id === null) {
this.univers_change.emit(this.univers_id);
return;
}
let self = this;
this.universService.get(_id)
.then(function(response) {
self.univers_name = response.number
self.univers_change.emit(self.univers_id);
}).catch(function(response) {
self.univers_change.emit(self.univers_id);
});
}
getUniversId():number {
return this.univers_id;
}
getUniversName():string {
return this.univers_name;
}
setGroup(_id:number):void {
if (this.group_id == _id) {
return;
}
if (_id === undefined) {
return;
}
this.group_id = _id;
this.group_name = "??--??";
if (this.group_id === null) {
this.group_change.emit(this.group_id);
return;
}
let self = this;
this.groupService.get(_id)
.then(function(response) {
self.group_name = response.name
self.group_change.emit(self.group_id);
}).catch(function(response) {
self.group_change.emit(self.group_id);
});
}
getGroupId():number {
return this.group_id;
}
getGroupName():string {
return this.group_name;
}
setSaison(_id:number):void {
if (this.saison_id == _id) {
return;
}
if (_id === undefined) {
return;
}
this.saison_id = _id;
this.saison_name = "??--??";
if (this.saison_id === null) {
this.saison_change.emit(this.saison_id);
return;
}
let self = this;
this.saisonService.get(_id)
.then(function(response) {
//self.setGroup(response.group_id);
self.saison_name = response.name
self.saison_change.emit(self.saison_id);
}).catch(function(response) {
self.saison_change.emit(self.saison_id);
});
}
getSaisonId():number {
return this.saison_id;
}
getSaisonName():string {
return this.saison_name;
}
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.setSaison(response.saison_id);
//self.setGroup(response.group_id);
self.video_name = response.name;
self.video_change.emit(self.video_id);
}).catch(function(response) {
self.video_change.emit(self.video_id);
});
}
getVideoId():number {
return this.video_id;
}
getVideoName():string {
return this.video_name;
}
genericNavigate(_destination:string, _universId:number, _typeId:number, _groupId:number, _saisonId:number, _videoId:number, _newWindows:boolean):void {
let addressOffset = _destination + '/' + _universId + '/' + _typeId + '/' + _groupId + '/' + _saisonId + '/' + _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]);
}
}
navigateUnivers(_id:number, _newWindows:boolean):void {
this.genericNavigate('univers', _id, this.type_id, null, null, null, _newWindows);
}
navigateUniversEdit(_id:number, _newWindows:boolean):void {
this.genericNavigate('univers-edit', _id, this.type_id, null, null, null, _newWindows);
}
navigateType(_id:number, _newWindows:boolean):void {
this.genericNavigate('type', this.univers_id, _id, null, null, null, _newWindows);
}
navigateTypeEdit(_id:number, _newWindows:boolean):void {
this.genericNavigate('type-edit', this.univers_id, _id, null, null, null, _newWindows);
}
navigateGroup(_id:number, _newWindows:boolean):void {
this.genericNavigate('group', this.univers_id, this.type_id, _id, null, null, _newWindows);
}
navigateGroupEdit(_id:number, _newWindows:boolean):void {
this.genericNavigate('group-edit', this.univers_id, this.type_id, _id, null, null, _newWindows);
}
navigateSaison(_id:number, _newWindows:boolean):void {
this.genericNavigate('saison', this.univers_id, this.type_id, this.group_id, _id, null, _newWindows);
}
navigateSaisonEdit(_id:number, _newWindows:boolean):void {
this.genericNavigate('saison-edit', this.univers_id, this.type_id, this.group_id, _id, null, _newWindows);
}
navigateVideo(_id:number, _newWindows:boolean):void {
this.genericNavigate('video', this.univers_id, this.type_id, this.group_id, this.saison_id, _id, _newWindows);
}
navigateVideoEdit(_id:number, _newWindows:boolean):void {
this.genericNavigate('video-edit', this.univers_id, this.type_id, this.group_id, this.saison_id, _id, _newWindows);
}
navigateUnivers(_id:number, _newWindows:boolean):void {
this.genericNavigate('univers', _id, this.type_id, null, null, null, _newWindows);
}
navigateUniversEdit(_id:number, _newWindows:boolean):void {
this.genericNavigate('univers-edit', _id, this.type_id, null, null, null, _newWindows);
}
navigateType(_id:number, _newWindows:boolean):void {
this.genericNavigate('type', this.univers_id, _id, null, null, null, _newWindows);
}
navigateTypeEdit(_id:number, _newWindows:boolean):void {
this.genericNavigate('type-edit', this.univers_id, _id, null, null, null, _newWindows);
}
navigateGroup(_id:number, _newWindows:boolean):void {
this.genericNavigate('group', this.univers_id, this.type_id, _id, null, null, _newWindows);
}
navigateGroupEdit(_id:number, _newWindows:boolean):void {
this.genericNavigate('group-edit', this.univers_id, this.type_id, _id, null, null, _newWindows);
}
navigateSaison(_id:number, _newWindows:boolean):void {
this.genericNavigate('saison', this.univers_id, this.type_id, this.group_id, _id, null, _newWindows);
}
navigateSaisonEdit(_id:number, _newWindows:boolean):void {
this.genericNavigate('saison-edit', this.univers_id, this.type_id, this.group_id, _id, null, _newWindows);
}
navigateVideo(_id:number, _newWindows:boolean):void {
this.genericNavigate('video', this.univers_id, this.type_id, this.group_id, this.saison_id, _id, _newWindows);
}
navigateVideoEdit(_id:number, _newWindows:boolean):void {
this.genericNavigate('video-edit', this.univers_id, this.type_id, this.group_id, this.saison_id, _id, _newWindows);
}
}

View File

@ -71,11 +71,13 @@ export class BddService {
resolve(self.bdd[_name]);
});
}
console.log("get DB: ?? " + _name + " ??");
if (this.bddPomise[_name] == null) {
this.bddPomise[_name] = new Array<any>();
return new Promise((resolve, reject) => {
self.http.get_specific(_name)
.then(function(response) {
console.log("end download DB: ==> " + _name + " " + response.length);
self.bdd[_name] = new DataInterface(_name, response);
for (let iii=0; iii<self.bddPomise[_name].length; iii++) {
self.bddPomise[_name][iii]["resolve"](self.bdd[_name]);

View File

@ -52,6 +52,33 @@ export class DataInterface {
console.log("[W] not found element{ " + this.bdd.length);
return undefined;
}
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) {
out.push(this.bdd[iii]);
}
}
if (out.length == 0) {
return undefined;
}
return out;
}
getNameLike(_name: string){
let out = undefined;
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'] == _name) {
return this.bdd[iii];
} else if (this.bdd[iii]['name'].toLowerCase() == nameLower) {
out = this.bdd[iii];
}
}
return out;
}
set(_id, _value){
console.log("[I] Set " + this.name + " " + _id)

View File

@ -63,16 +63,10 @@ export class GroupService {
};
getVideoAll(_id:number):any {
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id, "video_all");
}
//this.checkLocalBdd();
};
getVideo(_id:number):any {
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id, "video");
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
@ -87,9 +81,6 @@ export class GroupService {
};
getSaison(_id:number, _select:Array<string> = []):any {
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id, "saison", _select);
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getSaison()
@ -115,9 +106,6 @@ export class GroupService {
put(_id:number, _data:any):any {
let ret = this.http.put_specific(this.serviceName, _id, _data);
if (environment.localBdd != true) {
return ret;
}
return this.bdd.setAfterPut(this.serviceName, _id, ret);
};
@ -128,5 +116,23 @@ export class GroupService {
getCoverUrl(_coverId:number):any {
return this.http.createRESTCall("data/" + _coverId);
};
getLike(_nameGroup:string):any {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getGroup()
.then(function(response) {
let data = response.getNameLike(_nameGroup);
if (data === null || data === undefined) {
reject("Data does not exist in the local BDD");
return;
}
resolve(data);
return;
}).catch(function(response) {
reject(response);
});
});
}
}

View File

@ -0,0 +1,425 @@
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 { environment } from 'environments/environment';
@Injectable()
export class HttpOAuthWrapperService {
private displayReturn:boolean = false;
constructor(private http: HttpClient) {
}
createRESTCall(_api:string, _options:any = undefined) {
let basePage = environment.apiOAuthUrl;
let addressServerRest = basePage + "/";
let out;
if (typeof _options === 'undefined') {
_options = [];
}
out = addressServerRest + _api;
let first = true;
for (let iii=0; iii<_options.length; iii++) {
if (first ==false) {
out += "&";
} else {
out += "?";
first = false;
}
out += _options[iii];
}
return out;
}
get(_uriRest:string, _headerOption:any, _params:any) {
let connectionAdresse = this.createRESTCall(_uriRest, {});
let config = {
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));
}
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});
}
} 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, {});
const httpOption = {
headers: new HttpHeaders(_headerOption)
};
return new Promise((resolve, reject) => {
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 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});
}
} 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, {});
const httpOption = {
headers: new HttpHeaders(_headerOption)
};
return new Promise((resolve, reject) => {
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 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});
}
} 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, {});
const httpOption = {
headers: new HttpHeaders(_headerOption)
};
return new Promise((resolve, reject) => {
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});
}
} 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;
}
let formData = new FormData();
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 {
return null;
}
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) {
resolve(response.data);
return;
}
reject("An error occured");
}, function(response: any) {
if (typeof response.data === 'undefined') {
reject("return ERROR undefined");
} else {
reject("return ERROR " + JSON.stringify(response.data, null, 2));
}
});
});
}
uploadFileBase64(_base:string, _id:number, _file:File): any {
console.log("Upload file to " + _base);
let url = _base;
if (_id != null) {
url += "/" + _id;
}
let self = this;
let reader = new FileReader();
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 {
return null;
}
//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) {
resolve(response.data);
return;
}
reject("An error occured");
}, function(response: any) {
if (typeof response.data === 'undefined') {
reject("return ERROR undefined");
} else {
reject("return ERROR ...");// + JSON.stringify(response, 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);
const httpOption = { 'Content-Type': 'application/json' };
let url = _base;
if (_id != null) {
url += "/" + _id;
}
if (_subElement != "") {
url += "/" + _subElement;
}
if (_select.length != 0) {
let select = ""
for (let iii=0; iii<_select.length; iii++) {
if (select.length != 0) {
select += "&";
}
select += "select=" + _select[iii];
}
url += "?" + select;
}
//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) {
resolve(response.data);
return;
}
reject("An error occured");
}, function(response: any) {
if (typeof response.data === 'undefined') {
reject("return ERROR undefined");
} else {
reject("return ERROR " + JSON.stringify(response.data, null, 2));
}
});
});
};
// Complex wrapper to simplify interaction:
delete_specific(_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;
}
if (_subElement != "") {
url += "/" + _subElement;
}
//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) {
resolve(response.data);
return;
}
if (response.status == 201) {
resolve(response.data);
return;
}
reject("An error occured");
}, function(response: any) {
if (typeof response.data === 'undefined') {
reject("return ERROR undefined");
} else {
reject("return ERROR " + JSON.stringify(response.data, null, 2));
}
});
});
};
// Complex wrapper to simplify interaction:
put_specific(_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;
}
if (_subElement != "") {
url += "/" + _subElement;
}
//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) {
resolve(response.data);
return;
}
if (response.status == 201) {
resolve(response.data);
return;
}
reject("An error occured");
}, function(response: any) {
if (typeof response.data === 'undefined') {
reject("return ERROR undefined");
} else {
reject("return ERROR " + JSON.stringify(response.data, null, 2));
}
});
});
};
// Complex wrapper to simplify interaction:
post_specific(_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;
}
if (_subElement != "") {
url += "/" + _subElement;
}
//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) {
resolve(response.data);
return;
}
if (response.status == 201) {
resolve(response.data);
return;
}
reject("An error occured");
}, function(response: any) {
if (typeof response.data === 'undefined') {
reject("return ERROR undefined");
} else {
reject("return ERROR " + JSON.stringify(response.data, null, 2));
}
});
});
};
}

View File

@ -5,11 +5,13 @@ import { catchError, map, tap } from 'rxjs/operators';
import {Observable} from "rxjs";
import { environment } from 'environments/environment';
import { SessionService } from 'app/service/session';
@Injectable()
export class HttpWrapperService {
private displayReturn:boolean = false;
constructor(private http: HttpClient) {
constructor(private http: HttpClient,
private session: SessionService) {
}
@ -34,7 +36,17 @@ export class HttpWrapperService {
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;
}
}
return _headerOption;
}
get(_uriRest:string, _headerOption:any, _params:any) {
this.addTokenIfNeeded(_headerOption);
let connectionAdresse = this.createRESTCall(_uriRest, {});
let config = {
params: _params,
@ -71,40 +83,101 @@ export class HttpWrapperService {
}
post(_uriRest:string, _headerOption:any, _data:any) {
this.addTokenIfNeeded(_headerOption);
let connectionAdresse = this.createRESTCall(_uriRest, {});
const httpOption = {
headers: new HttpHeaders(_headerOption)
};
return new Promise((resolve, reject) => {
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 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 (false) {
const httpOption = {
headers: new HttpHeaders(_headerOption)
};
return new Promise((resolve, reject) => {
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 self = this;
request.subscribe((res: any) => {
if (self.displayReturn == true) {
console.log("!! data " + JSON.stringify(res, null, 2));
}
} 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});
if (res) {
if (res.httpCode) {
resolve({status:res.httpCode, data:res});
} else {
resolve({status:200, data:res});
}
} 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});
});
});
});
} else {
const httpOption = {
headers: new HttpHeaders(_headerOption),
reportProgress: true,
observe: 'events'
};
return new Promise((resolve, reject) => {
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 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});
}
} 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});
});
});
}
/*
return this.http.post<any>(uploadURL, data, {
reportProgress: true,
observe: 'events'
}).pipe(map((event) => {
switch (event.type) {
case HttpEventType.UploadProgress:
const progress = Math.round(100 * event.loaded / event.total);
return { status: 'progress', message: progress };
case HttpEventType.Response:
return event.body;
default:
return `Unhandled event: ${event.type}`;
}
})
);
}
*/
}
put(_uriRest:string, _headerOption:any, _data:any) {
this.addTokenIfNeeded(_headerOption);
let connectionAdresse = this.createRESTCall(_uriRest, {});
const httpOption = {
headers: new HttpHeaders(_headerOption)
@ -139,6 +212,7 @@ export class HttpWrapperService {
});
}
delete(_uriRest:string, _headerOption:any) {
this.addTokenIfNeeded(_headerOption);
let connectionAdresse = this.createRESTCall(_uriRest, {});
const httpOption = {
headers: new HttpHeaders(_headerOption)
@ -271,7 +345,32 @@ export class HttpWrapperService {
};
});
}
/*
public upload(_base:string, _id:number, _file:File): any {
data, userId) {
}
let uploadURL = `${this.SERVER_URL}/auth/${userId}/avatar`;
return this.http.post<any>(uploadURL, data, {
reportProgress: true,
observe: 'events'
}).pipe(map((event) => {
switch (event.type) {
case HttpEventType.UploadProgress:
const progress = Math.round(100 * event.loaded / event.total);
return { status: 'progress', message: progress };
case HttpEventType.Response:
return event.body;
default:
return `Unhandled event: ${event.type}`;
}
})
);
}
*/
// 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);

View File

@ -17,9 +17,6 @@ export class SaisonService {
get(_id:number):any {
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id);
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getSaison()
@ -36,9 +33,6 @@ export class SaisonService {
});
};
getVideo(_id:number):any {
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id, "video");
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
@ -52,9 +46,6 @@ export class SaisonService {
});
};
countVideo(_id:number):any {
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id, "video");
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
@ -69,9 +60,6 @@ export class SaisonService {
};
put(_id:number, _data:any):any {
let ret = this.http.put_specific(this.serviceName, _id, _data);
if (environment.localBdd != true) {
return ret;
}
return this.bdd.setAfterPut(this.serviceName, _id, ret);
};
addCover(_id:number, _coverId:number):any {

View File

@ -14,9 +14,9 @@ enum USER_ROLES {
@Injectable()
export class SessionService {
public id = null;
public userId = null;
public userRole = null;
public sessionData = null;
public userLogin = null;
public userAdmin = null;
public userEMail = null;
public userAvatar = null;
//public tocken = null;
@ -29,15 +29,15 @@ export class SessionService {
/**
* @brief Create a new session.
*/
create(sessionId,
userId,
create(sessionData,
userLogin:string,
userEMail:string,
userRole:string,
userAdmin:boolean,
userAvatar:string) {
console.log("Session Create");
this.id = sessionId;
this.userId = userId;
this.userRole = userRole;
this.sessionData = sessionData;
this.userLogin = userLogin;
this.userAdmin = userAdmin;
this.userEMail = userEMail;
this.userAvatar = userAvatar;
this.change.emit(true);
@ -49,29 +49,29 @@ export class SessionService {
console.log("Session REMOVE");
//Cookies.remove("yota-login");
//Cookies.remove("yota-password");
let last = this.id;
this.id = null;
this.userId = null;
this.userRole = null;
let last = this.sessionData;
this.sessionData = null;
this.userLogin = null;
this.userAdmin = null;
this.userEMail = null;
this.userAvatar = null;
this.change.emit(false);
};
islogged() {
return this.id != null;
return this.sessionData != null;
}
hasRight(type) {
if (type == USER_ROLES.admin) {
return this.userRole == USER_ROLES.admin;
// sometime needed...
return this.userAdmin;
}
if (type == USER_ROLES.user) {
return this.userRole == USER_ROLES.admin
|| this.userRole == USER_ROLES.user;
// is connected ==> is user
return this.sessionData != null;
}
if (type == USER_ROLES.guest) {
return this.userRole == USER_ROLES.admin
|| this.userRole == USER_ROLES.user
|| this.userRole == USER_ROLES.guest;
// TODO all the other ... maybe unneeded
return true;
}
return false;
}
@ -79,7 +79,7 @@ export class SessionService {
return !this.hasRight(type);
}
getLogin() {
return this.userId;
return this.userLogin;
}
getAvatar() {
if (this.userAvatar == "") {

View File

@ -30,9 +30,6 @@ export class TypeService {
getData():any {
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName);
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getType()
@ -47,9 +44,6 @@ export class TypeService {
};
get(_id:number):any {
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id);
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getType()
@ -67,9 +61,6 @@ export class TypeService {
};
getSubVideo(_id:number, _select:Array<string> = []):any {
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id, "video", _select);
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
@ -94,9 +85,6 @@ export class TypeService {
};
getSubGroup(_id:number, _select:Array<string> = []):any {
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id, "group", _select);
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
@ -126,9 +114,6 @@ export class TypeService {
};
getSubUnivers(_id:number, _select:Array<string> = []):any {
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id, "univers", _select);
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()

View File

@ -17,9 +17,6 @@ export class UniversService {
}
getData():any {
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName);
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getUnivers()
@ -33,9 +30,6 @@ export class UniversService {
};
get(_id:number):any {
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id);
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getUnivers()
@ -53,24 +47,15 @@ export class UniversService {
};
getSubGroup(_id:number, _select:Array<string> = []):any {
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id, "group", _select);
}
//this.checkLocalBdd();
};
getSubVideo(_id:number, _select:Array<string> = []):any {
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id, "video", _select);
}
//this.checkLocalBdd();
};
put(_id:number, _data:any):any {
let ret = this.http.put_specific(this.serviceName, _id, _data);
if (environment.localBdd != true) {
return ret;
}
return this.bdd.setAfterPut(this.serviceName, _id, ret);
};
addCover(_id:number, _coverId:number):any {

View File

@ -1,10 +1,11 @@
import { Injectable } from '@angular/core';
import { HttpOAuthWrapperService } from 'app/service/http-oauth-wrapper';
import { HttpWrapperService } from 'app/service/http-wrapper';
//import { SHA512 } from 'assets/js_3rd_party/sha512';
interface MessageLogIn {
login: string;
methode: string;
method: string;
time: number;
password: string;
};
@ -25,43 +26,69 @@ export class UserService {
// 0: Not hide password; 1 hide password;
private identificationVersion: number = 1;
constructor(private http: HttpWrapperService) {
constructor(private httpOAuth: HttpOAuthWrapperService,
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 {
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");
});
}, function(value) {
console.log("User NOT created");
reject("rrfrrrrr");
});
});
}
loginSha(_login : string, _password : string) {
console.log("AuthService.login ... '" + _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 == 0) {
if (this.identificationVersion == 1) {
data = {
login: _login,
methode: "v0",
time: currentDate,
password: _password
};
} else if (this.identificationVersion == 1) {
data = {
login: _login,
methode: "v1",
method: "v1",
time: currentDate,
// we mix the password to be sure that it can not be used an other time ...
password: SHA512("login='" + _login + "';pass='" + _password + "';date='" + currentDate + "'")
};
} else {
console.log("AuthService.login ... Wrong method ...");
}
const httpOption = { 'Content-Type': 'application/json' };
console.log("call users/connect data=" + JSON.stringify(data, null, 2));
return new Promise((resolve, reject) => {
this.http.post("rest-auth/login", httpOption, data)
this.httpOAuth.post("users/get_token", httpOption, data)
.then(function(response: any) {
if (response.status == 200) {
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;
}
@ -76,13 +103,72 @@ export class UserService {
});
};
loginWithToken(_user_id : string, _token : string) {
console.log("AuthService.loginWithToken ... '" + _user_id + "':'" + _token + "'");
let headers = {
authorization: "Yota " + _user_id + ":" + _token
};
return new Promise((resolve, reject) => {
this.http.get("users/me", headers, {})
.then(function(response: any) {
if (response.status == 200) {
resolve(response.data);
return;
}
reject("An error occured");
}, function(response: any) {
if (typeof response.data === 'undefined') {
reject("return ERROR undefined");
} else {
reject("return ERROR " + JSON.stringify(response.data, null, 2));
}
});
});
/*
console.log("AuthService.login ... '" + _login + "':'" + _password + "'");
let currentDate:number = dateFormat(new Date(), 'm-d-Y h:i:s ms');
let data:MessageLogIn;
// create request:
if (this.identificationVersion == 1) {
data = {
login: _login,
method: "v1",
time: currentDate,
// we mix the password to be sure that it can not be used an other time ...
password: SHA512("login='" + _login + "';pass='" + _password + "';date='" + currentDate + "'")
};
} else {
console.log("AuthService.login ... Wrong method ...");
}
const httpOption = { 'Content-Type': 'application/json' };
console.log("call users/connect data=" + JSON.stringify(data, null, 2));
return new Promise((resolve, reject) => {
this.httpOAuth.post("users/connect", httpOption, data)
.then(function(response: any) {
if (response.status == 200) {
resolve(response.data);
return;
}
reject("An error occured");
}, function(response: any) {
if (typeof response.data === 'undefined') {
reject("return ERROR undefined");
} else {
reject("return ERROR " + JSON.stringify(response.data, null, 2));
}
});
});
*/
};
create(_login : string, _email : string, _password : string) {
return this.createSha(_login, _email, SHA512(_password));
}
createSha(_login : string, _email : string, _password : string, ) {
let data = {
"methode": "v?",
"method": "v?",
"login": _login,
"email": _email,
"password": _password
@ -90,14 +176,12 @@ export class UserService {
const httpOption = { 'Content-Type': 'application/json' };
console.log("call users data=" + JSON.stringify(data, null, 2));
if (this.identificationVersion == 0) {
data["methode"] = "v0"
} else if (this.identificationVersion == 1) {
if (this.identificationVersion == 1) {
data["methode"] = "v1"
}
return new Promise((resolve, reject) => {
this.http.post("users", httpOption, data)
this.httpOAuth.post("users", httpOption, data)
.then(function(response: any) {
if (response.status == 200) {
resolve(response.data)
@ -134,7 +218,7 @@ export class UserService {
login: _login
};
return new Promise((resolve, reject) => {
this.http.get("users/check_login", {}, params).then(
this.httpOAuth.get("users/check_login", {}, params).then(
(res: Response) => {
resolve()
},
@ -149,7 +233,7 @@ export class UserService {
"email": _email
};
return new Promise((resolve, reject) => {
this.http.get("users/check_email", {}, params).then(
this.httpOAuth.get("users/check_email", {}, params).then(
(res: Response) => {
resolve()
},

View File

@ -18,9 +18,6 @@ export class VideoService {
}
get(_id:number):any {
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id);
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.get(this.serviceName)

View File

@ -7,9 +7,9 @@ export const environment = {
production: false,
// URL of development API
//apiUrl: 'http://localhost:15080',
apiUrl: 'http://192.168.1.156/karideo/api',
apiUrl: 'http://localhost:18080/karideo/api',
apiOAuthUrl: 'http://localhost:17080/oauth/api',
frontBaseUrl: '',
//apiMode: "QUERRY"
apiMode: "REWRITE",
localBdd: true
apiMode: "REWRITE"
}