[DEV] copy in local the main db to manage it in local ==> release the server of siple request all the time...

This commit is contained in:
Edouard DUPIN 2020-02-09 21:57:41 +01:00
parent 108675e6e6
commit 4cca379971
22 changed files with 2880 additions and 1261 deletions

3278
front/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -20,19 +20,19 @@
"@angular/platform-browser": "^8.2.14",
"@angular/platform-browser-dynamic": "^8.2.14",
"@angular/router": "^8.2.14",
"core-js": "^3.6.2",
"core-js": "^3.6.4",
"rxjs": "^6.5.4",
"tslib": "^1.10.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.21",
"@angular/cli": "^8.3.21",
"@angular-devkit/build-angular": "^0.803.25",
"@angular/cli": "^8.3.25",
"@angular/compiler-cli": "^8.2.14",
"@angular/language-service": "^8.2.14",
"@types/jasmine": "^3.5.0",
"@types/jasmine": "^3.5.3",
"@types/jasminewd2": "^2.0.8",
"@types/node": "^13.1.4",
"@types/node": "^13.7.0",
"codelyzer": "^5.0.1",
"jasmine-core": "^3.5.0",
"jasmine-spec-reporter": "^4.2.1",
@ -40,9 +40,9 @@
"karma-chrome-launcher": "^3.1.0",
"karma-coverage-istanbul-reporter": "^2.1.1",
"karma-jasmine": "^2.0.1",
"karma-jasmine-html-reporter": "^1.5.1",
"protractor": "^5.4.2",
"ts-node": "^8.5.4",
"karma-jasmine-html-reporter": "^1.5.2",
"protractor": "^5.4.3",
"ts-node": "^8.6.2",
"tslint": "^5.20.1",
"typescript": "~3.5.0"
}

View File

@ -50,6 +50,7 @@ import { TypeService } from './service/type.service';
import { SaisonService } from './service/saison.service';
import { VideoService } from './service/video.service';
import { SessionService } from './service/session.service';
import { BddService } from './service/bdd.service';
import { AppComponent } from './app.component';
@ -92,6 +93,7 @@ import { AppComponent } from './app.component';
],
providers: [
HttpWrapperService,
BddService,
AuthService,
SessionService,
CookiesService,

View File

@ -50,10 +50,10 @@ export class ElementVideoComponent implements OnInit {
ngOnInit() {
this.name = "ll " + this.id_video
let self = this;
console.log("get video id: " + this.id_video);
//console.log("get video id: " + this.id_video);
this.videoService.get(this.id_video)
.then(function(response) {
console.log("get response of video : " + JSON.stringify(response, null, 2));
//console.log("get response of video : " + JSON.stringify(response, null, 2));
self.error = "";
self.name = response.name;
self.description = response.description;
@ -79,7 +79,7 @@ export class ElementVideoComponent implements OnInit {
self.covers.push(self.videoService.getCoverUrl(response.covers[iii]));
}
}
console.log("101010 " + self.video_enable + " " + self.video_source);
//console.log("101010 " + self.video_enable + " " + self.video_source);
//console.log("set transformed : " + JSON.stringify(self, null, 2));
}).catch(function(response) {
self.error = "Can not get the data";

View File

@ -11,6 +11,7 @@ import { fadeInAnimation } from '../../_animations/index';
import { GroupService } from '../../service/group.service';
import { ArianeService } from '../../service/ariane.service';
import { environment } from 'environments/environment';
@Component({
selector: 'app-group',
@ -62,7 +63,11 @@ export class GroupComponent implements OnInit {
}
onSelectSaison(_event: any, _idSelected: number):void {
if(_event.which==2) {
window.open('/saison/' + _idSelected);
if (environment.frontBaseUrl === undefined || environment.frontBaseUrl === null || environment.frontBaseUrl === "") {
window.open('/saison/' + _idSelected);
} else {
window.open("/" + environment.frontBaseUrl + '/saison/' + _idSelected);
}
} else {
this.router.navigate(['/saison/' + _idSelected ]);
this.arianeService.setSaison(_idSelected);
@ -71,7 +76,11 @@ export class GroupComponent implements OnInit {
onSelectVideo(_event: any, _idSelected: number):void {
if(_event.which==2) {
window.open('/video/' + _idSelected);
if (environment.frontBaseUrl === undefined || environment.frontBaseUrl === null || environment.frontBaseUrl === "") {
window.open('/video/' + _idSelected);
} else {
window.open("/" + environment.frontBaseUrl + '/video/' + _idSelected);
}
} else {
this.router.navigate(['/video/' + _idSelected ]);
this.arianeService.setVideo(_idSelected);

View File

@ -11,6 +11,7 @@ import { fadeInAnimation } from '../../_animations/index';
import { TypeService } from '../../service/type.service';
import { ArianeService } from '../../service/ariane.service';
import { environment } from 'environments/environment';
@Component({
selector: 'app-home',
@ -35,15 +36,21 @@ export class HomeComponent implements OnInit {
.then(function(response) {
self.error = "";
self.data_list = response
console.log("Get response: " + JSON.stringify(response, null, 2));
}).catch(function(response) {
self.error = "Wrong e-mail/login or password";
console.log("[E] " + self.constructor.name + ": Does not get a correct response from the server ...");
self.data_list = []
});
this.arianeService.reset();
}
onSelectType(_event: any, _idSelected: number):void {
if(_event.which==2) {
window.open('/type/' + _idSelected);
if (environment.frontBaseUrl === undefined || environment.frontBaseUrl === null || environment.frontBaseUrl === "") {
window.open('/type/' + _idSelected);
} else {
window.open("/" + environment.frontBaseUrl + '/type/' + _idSelected);
}
} else {
this.arianeService.setType(_idSelected);
//this.router.navigate(['type/', { id: _idSelected} ]);

View File

@ -11,6 +11,7 @@ import { fadeInAnimation } from '../../_animations/index';
import { SaisonService } from '../../service/saison.service';
import { ArianeService } from '../../service/ariane.service';
import { environment } from 'environments/environment';
@Component({
selector: 'app-saison',
@ -34,6 +35,7 @@ export class SaisonComponent implements OnInit {
ngOnInit() {
this.id_saison = parseInt(this.route.snapshot.paramMap.get('saison_id'));
this.arianeService.setSaison(this.id_saison);
let self = this;
console.log("get parameter id: " + this.id_saison);
this.saisonService.getVideo(this.id_saison)
@ -48,7 +50,11 @@ export class SaisonComponent implements OnInit {
onSelectVideo(_event: any, _idSelected: number):void {
if(_event.which==2) {
window.open('/video/' + _idSelected);
if (environment.frontBaseUrl === undefined || environment.frontBaseUrl === null || environment.frontBaseUrl === "") {
window.open('/video/' + _idSelected);
} else {
window.open("/" + environment.frontBaseUrl + '/video/' + _idSelected);
}
} else {
this.router.navigate(['video/' + _idSelected ]);
this.arianeService.setVideo(_idSelected);

View File

@ -11,6 +11,7 @@ import { fadeInAnimation } from '../../_animations/index';
import { TypeService } from '../../service/type.service';
import { ArianeService } from '../../service/ariane.service';
import { environment } from 'environments/environment';
@Component({
selector: 'app-type',
@ -64,7 +65,11 @@ export class TypeComponent implements OnInit {
}
onSelectGroup(_event: any, _idSelected: number):void {
if(_event.which==2) {
window.open('/group/' + _idSelected);
if (environment.frontBaseUrl === undefined || environment.frontBaseUrl === null || environment.frontBaseUrl === "") {
window.open('/group/' + _idSelected);
} else {
window.open("/" + environment.frontBaseUrl + '/group/' + _idSelected);
}
} else {
this.router.navigate(['/group/' + _idSelected ]);
this.arianeService.setGroup(_idSelected);
@ -74,7 +79,11 @@ export class TypeComponent implements OnInit {
onSelectVideo(_event: any, _idSelected: number):void {
//console.log("event: " + _event.which);
if(_event.which==2) {
window.open('/video/' + _idSelected);
if (environment.frontBaseUrl === undefined || environment.frontBaseUrl === null || environment.frontBaseUrl === "") {
window.open('/video/' + _idSelected);
} else {
window.open("/" + environment.frontBaseUrl + '/video/' + _idSelected);
}
} else {
this.router.navigate(['/video/' + _idSelected ]);
this.arianeService.setVideo(_idSelected);

View File

@ -12,6 +12,8 @@ import { fadeInAnimation } from '../../_animations/index';
import { UniversService } from '../../service/univers.service';
import { ArianeService } from '../../service/ariane.service';
import { environment } from 'environments/environment';
@Component({
selector: 'app-univers',
templateUrl: './univers.html',
@ -50,7 +52,11 @@ export class UniversComponent implements OnInit {
onSelectVideo(_event: any, _idSelected: number):void {
if(_event.which==2) {
window.open('/video/' + _idSelected);
if (environment.frontBaseUrl === undefined || environment.frontBaseUrl === null || environment.frontBaseUrl === "") {
window.open('/video/' + _idSelected);
} else {
window.open("/" + environment.frontBaseUrl + '/video/' + _idSelected);
}
} else {
this.router.navigate(['video/' + _idSelected ]);
this.arianeService.setVideo(_idSelected);

View File

@ -19,6 +19,7 @@ import { UniversService } from '../../service/univers.service';
import { GroupService } from '../../service/group.service';
import { VideoService } from '../../service/video.service';
import { DataService } from '../../service/data.service';
import { ArianeService } from '../../service/ariane.service';
export class ElementList {
value: number;
@ -79,12 +80,14 @@ export class VideoEditComponent implements OnInit {
private universService: UniversService,
private groupService: GroupService,
private videoService: VideoService,
private httpService: HttpWrapperService) {
private httpService: HttpWrapperService,
private arianeService: ArianeService) {
}
ngOnInit() {
this.id_video = parseInt(this.route.snapshot.paramMap.get('video_id'));
this.arianeService.setVideo(this.id_video);
let self = this;
this.listType = [{value: undefined, label: '---'}];
this.listUnivers = [{value: undefined, label: '---'}];

View File

@ -10,6 +10,7 @@ import { Location } from '@angular/common';
import { fadeInAnimation } from '../../_animations/index';
import { HttpWrapperService } from '../../service/http-wrapper.service';
import { VideoService } from '../../service/video.service';
import { ArianeService } from '../../service/ariane.service';
@Component({
selector: 'app-video',
@ -41,12 +42,14 @@ export class VideoComponent implements OnInit {
private router: Router,
private locate: Location,
private videoService: VideoService,
private httpService: HttpWrapperService) {
private httpService: HttpWrapperService,
private arianeService: ArianeService) {
}
ngOnInit() {
this.id_video = parseInt(this.route.snapshot.paramMap.get('video_id'));
this.arianeService.setVideo(this.id_video);
let self = this;
this.videoService.get(this.id_video)
.then(function(response) {

View File

@ -12,6 +12,7 @@ import { TypeService } from 'app/service/type.service';
import { UniversService } from 'app/service/univers.service';
import { GroupService } from 'app/service/group.service';
import { SaisonService } from 'app/service/saison.service';
import { VideoService } from 'app/service/video.service';
export class InputOrders {
public type_id: number = null;
@ -42,13 +43,15 @@ export class ArianeService {
@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 typeService: TypeService,
private universService: UniversService,
private groupService: GroupService,
private saisonService: SaisonService) {
private saisonService: SaisonService,
private videoService: VideoService) {
}
@ -66,6 +69,7 @@ export class ArianeService {
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);
}
/*
@ -192,6 +196,7 @@ export class ArianeService {
let self = this;
this.saisonService.get(id)
.then(function(response) {
self.setGroup(response.group_id);
self.saison_name = response.number
self.saison_change.emit(self.saison_id);
}).catch(function(response) {
@ -210,7 +215,21 @@ export class ArianeService {
return;
}
this.video_id = id;
this.video_change.emit(this.video_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;

View File

@ -0,0 +1,105 @@
import { Injectable } from '@angular/core';
import { HttpWrapperService } from 'app/service/http-wrapper.service';
import { DataInterface } from 'app/service/dataInterface';
import { environment } from 'environments/environment';
@Injectable()
export class BddService {
private bdd = {
"type": null,
"group": null,
"saison": null,
"univers": null,
"video": null
};
private bddPomise = {
"type": null,
"group": null,
"saison": null,
"univers": null,
"video": null
};
constructor(private http: HttpWrapperService) {
console.log("Start BddService");
}
setAfterPut(_name: string, _id: number, ret: any) {
let self = this;
return new Promise((resolve, reject) => {
self.get(_name)
.then(function(response) {
ret.then(function(response2) {
response.set(_id, response2);
resolve(response2);
}).catch(function(response2) {
reject(response2);
});
}).catch(function(response) {
reject(response);
});
});
}
get(_name: string): any {
let self = this;
if (this.bdd[_name] === undefined) {
console.log("Try to get a non existant BDD ... '" + _name + "'");
return;
}
if (this.bdd[_name] !== null) {
return new Promise((resolve, reject) => {
resolve(self.bdd[_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) {
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]);
}
resolve(self.bdd[_name]);
}).catch(function(response) {
console.log("[E] " + self.constructor.name + ": cant not get data from remote server: " + _name);
for (let iii=0; iii<self.bddPomise[_name].length; iii++) {
self.bddPomise[_name][iii]["reject"](response);
}
reject(response);
});
});
}
return new Promise((resolve, reject) => {
if (self.bdd[_name] != null) {
resolve(self.bdd[_name]);
return;
}
self.bddPomise[_name].push({"resolve": resolve, "reject": reject});
});
}
getType():any {
return this.get("type");
};
getGroup():any {
return this.get("group");
};
getSaison():any {
return this.get("saison");
};
getUnivers():any {
return this.get("univers");
};
getVideo():any {
return this.get("video");
};
}

View File

@ -1,26 +1,31 @@
import { Injectable } from '@angular/core';
import { HttpWrapperService } from 'app/service/http-wrapper.service';
import { DataInterface } from 'app/service/dataInterface';
import { environment } from 'environments/environment';
@Injectable()
export class DataService {
// 0: Not hide password; 1 hide password;
private identificationVersion: number = 1;
private bdd: DataInterface = null;
private serviceName:string = "data";
constructor(private http: HttpWrapperService) {
console.log("Start TypeService");
}
getData():any {
return this.http.get_specific("data");
return this.http.get_specific(this.serviceName);
};
get(_id:number):any {
return this.http.get_specific("data", _id);
return this.http.get_specific(this.serviceName, _id);
};
sendFile(_file:File) {
//return this.http.uploadFileMultipart("data", null, _file);
return this.http.uploadFileBase64("data", null, _file);
//return this.http.uploadFileMultipart(this.serviceName, null, _file);
return this.http.uploadFileBase64(this.serviceName, null, _file);
}
}

View File

@ -0,0 +1,268 @@
/**
* @author Edouard DUPIN
*
* @copyright 2019, Edouard DUPIN, all right reserved
*
* @license MPL v2.0 (see license file)
*/
/**
* @breif Generic interface to access to the BDD (no BDD, direct file IO)
*/
export class DataInterface {
private name: string;
private bdd: any;
constructor(_name, _data) {
this.name = _name;
this.bdd = _data;
}
get_table_index(_id) {
for (let iii=0; iii<this.bdd.length; iii++) {
if (this.bdd[iii]['id'] == _id) {
return iii;
}
}
return undefined;
}
gets(_filter=undefined) {
console.log("[I] gets " + this.name)
if (_filter == undefined) {
return this.bdd
}
return this.filter_object_values(this.bdd, _filter)
}
gets_where(_select, _filter=undefined, _orderBy=undefined){
console.log("[I] gets " + this.name);
let tmp_list = this.get_sub_list(this.bdd, _select);
tmp_list = this.order_by(tmp_list, _orderBy);
return this.filter_object_values(tmp_list, _filter);
}
get(_id){
//console.log("[I] get " + this.name + " " + _id);
for (let iii=0; iii<this.bdd.length; iii++) {
if (this.bdd[iii]['id'] == _id) {
return this.bdd[iii];
}
}
console.log("[W] not found element{ " + this.bdd.length);
return undefined;
}
set(_id, _value){
console.log("[I] Set " + this.name + "{ " + _id)
for (let iii=0; iii<this.bdd.length; iii++) {
if (this.bdd[iii]['id'] == _id) {
this.bdd[iii] = _value
}
}
}
delete(_id) {
console.log("[I] delete " + this.name + "{ " + _id)
for (let iii=0; iii<this.bdd.length; iii++) {
if (this.bdd[iii]['id'] == _id) {
this.bdd[iii] = undefined
}
}
}
// TODO: rework this
find(_listToken, _values) {
let out = []
for (let iii=0; iii<this.bdd.length; iii++) {
let find = true
for (let jjj=0; jjj<_listToken.length; jjj++) {
if (this.bdd[iii][_listToken[jjj]] != _values[_listToken[jjj]]) {
find = false;
break;
}
}
if (find == true) {
out.push(this.bdd[iii]);
}
}
return out;
}
count(_select = undefined) {
if (_select == undefined) {
return this.bdd.length;
}
let tmp = this.get_sub_list(this.bdd, _select);
return tmp.length;
}
exit_in(_value: any, _listValues: any) {
for (let iii=0; iii<_listValues.length; iii++) {
if (_value == _listValues[iii]) {
return true;
}
}
return false;
}
get_sub_list(_values, _select) {
let out = [];
for (let iii_elem=0; iii_elem<_values.length; iii_elem++) {
let find = true;
if (_select.length == 0) {
find = false;
}
//console.log("Check : " + JSON.stringify(_values[iii_elem], null, 2));
for (let iii_select=0; iii_select < _select.length; iii_select++) {
if (_select[iii_select].length != 3) {
console.log("[E] Internal Server Error: wrong select definition ...");
return undefined;
}
let type_check = _select[iii_select][0];
let token = _select[iii_select][1];
let value = _select[iii_select][2];
if (value instanceof Array) {
if (_values[iii_elem][token] !== undefined) {
if (type_check == "==") {
if (this.exit_in(_values[iii_elem][token], value) == false) {
find = false
break
}
} else if (type_check == "!=") {
if (this.exit_in(_values[iii_elem][token], value) == false) {
find = false
break;
}
} else {
console.log("[ERROR] Internal Server Error{ unknow comparing type ...");
return undefined;
}
} else {
find = false;
break;
}
} else {
//console.log(" [" + token + "] = " + _values[iii_elem][token]);
if (_values[iii_elem][token] !== undefined) {
//console.log(" '" + type_check + "' " + value);
if (type_check == "==") {
if (_values[iii_elem][token] != value) {
find = false;
break;
}
} else if (type_check == "!=") {
if (_values[iii_elem][token] == value) {
find = false;
break;
}
} else if (type_check == "<") {
if (_values[iii_elem][token] >= value) {
find = false;
break;
}
} else if (type_check == "<=") {
if (_values[iii_elem][token] > value) {
find = false;
break;
}
} else if (type_check == ">") {
if (_values[iii_elem][token] <= value) {
find = false;
break;
}
} else if (type_check == ">=") {
if (_values[iii_elem][token] < value) {
find = false;
break;
}
} else {
console.log("[ERROR] Internal Server Error{ unknow comparing type ...");
return undefined;
}
} else {
find = false;
break;
}
}
}
if (find == true) {
//console.log(" ==> SELECTED");
out.push(_values[iii_elem])
} else {
//console.log(" ==> NOT SELECTED");
}
}
return out;
}
order_by(_values, _order) {
if (_order == undefined) {
return _values;
}
if (_order.length == 0) {
return _values;
}
let value_order = _order[0]
let out = []
let out_unclassable = []
for (let iii=0; iii<_values.length; iii++) {
if (_values[iii][value_order] === undefined) {
out_unclassable.push(_values[iii]);
continue;
}
if (_values[iii][value_order] == null) {
out_unclassable.push(_values[iii]);
continue;
}
out.push(_values[iii]);
}
//out = sorted(out, key=lambda x{ x[value_order])
out.sort(function (a, b) {
//const name1 = t1.name.toLowerCase();
//const name2 = t2.name.toLowerCase();
if (a[value_order] > b[value_order]) { return 1; }
if (a[value_order] < b[value_order]) { return -1; }
return 0;
});
if (_order.length > 1) {
out_unclassable = this.order_by(out_unclassable, _order.slice(1));
}
for (let jjj=0; jjj<out_unclassable.length; jjj++) {
out.push(out_unclassable[jjj]);
}
return out;
}
filter_object_values(_values, _filter) {
let out = []
if (_filter == undefined) {
return _values;
}
if (_filter.length == 1) {
let token = _filter[0]
for (let iii=0; iii<_values.length; iii++) {
if (_values[iii][token] === undefined) {
continue;
}
if (this.exit_in(_values[iii][token], out) == false) {
out.push(_values[iii][token]);
}
}
return out;
}
for (let iii=0; iii<_values.length; iii++) {
let element_out = {}
for (let jjj=0; jjj<_filter.length; jjj++) {
if (_values[iii][_filter[jjj]] === undefined) {
continue;
}
element_out[_filter[jjj]] = _values[iii][_filter[jjj]]
}
out.push(element_out)
}
return out;
}
}

View File

@ -1,40 +1,118 @@
import { Injectable } from '@angular/core';
import { HttpWrapperService } from 'app/service/http-wrapper.service';
import { DataInterface } from 'app/service/dataInterface';
import { BddService } from 'app/service/bdd.service';
import { environment } from 'environments/environment';
@Injectable()
export class GroupService {
// 0: Not hide password; 1 hide password;
private identificationVersion: number = 1;
private serviceName:string = "group";
constructor(private http: HttpWrapperService) {
constructor(private http: HttpWrapperService,
private bdd: BddService) {
console.log("Start GroupService");
}
get(_id:number):any {
return this.http.get_specific("group", _id);
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id);
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getGroup()
.then(function(response) {
let data = response.get(_id);
if (data === null || data === undefined) {
reject("Data does not exist in the local BDD");
return;
}
resolve(data);
}).catch(function(response) {
reject(response);
});
});
};
getOrder():any {
return this.http.get_specific("group", null, "", ["name","id"]);
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, null, "", ["name","id"]);
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getGroup()
.then(function(response) {
let data = response.gets_where([["!=", "id", null]], ["id"], ["name","id"])
resolve(data);
}).catch(function(response) {
reject(response);
});
});
};
getVideoAll(_id:number):any {
return this.http.get_specific("group", _id, "video_all");
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id, "video_all");
}
//this.checkLocalBdd();
};
getVideo(_id:number):any {
return this.http.get_specific("group", _id, "video");
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id, "video");
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
.then(function(response) {
let data = response.gets_where([["==", "group_id", _id], ["==", "saison_id", null]], ["id"], ["name"])
resolve(data);
}).catch(function(response) {
reject(response);
});
});
};
getSaison(_id:number, _select:Array<string> = []):any {
return this.http.get_specific("group", _id, "saison", _select);
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()
.then(function(response) {
let data = response.gets_where([["==", "group_id", _id]], ["id"], ["number"])
if (_select.length == 0) {
resolve(data);
return;
}
if (_select[0] == "*") {
let data2 = response.gets_where([["==", "id", data]], undefined, ["number"])
resolve(data2);
return;
}
let data3 = response.gets_where([["==", "id", data]], _select, ["number"]);
resolve(data3);
return;
}).catch(function(response) {
reject(response);
});
});
};
put(_id:number, _data:any):any {
return this.http.put_specific("group", _id, _data);
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 {
return this.http.post_specific("group", _id, {"data_id":_coverId}, "add_cover");
return this.http.post_specific(this.serviceName, _id, {"data_id":_coverId}, "add_cover");
};
getCoverUrl(_coverId:number):any {
return this.http.createRESTCall("data/" + _coverId);
};

View File

@ -1,26 +1,64 @@
import { Injectable } from '@angular/core';
import { HttpWrapperService } from 'app/service/http-wrapper.service';
import { DataInterface } from 'app/service/dataInterface';
import { environment } from 'environments/environment';
import { BddService } from 'app/service/bdd.service';
@Injectable()
export class SaisonService {
// 0: Not hide password; 1 hide password;
private identificationVersion: number = 1;
private serviceName:string = "saison";
constructor(private http: HttpWrapperService) {
constructor(private http: HttpWrapperService,
private bdd: BddService) {
console.log("Start SaisonService");
}
get(_id:number):any {
return this.http.get_specific("saison", _id);
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id);
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getSaison()
.then(function(response) {
let data = response.get(_id);
if (data === null || data === undefined) {
reject("Data does not exist in the local BDD");
return;
}
resolve(data);
}).catch(function(response) {
reject(response);
});
});
};
getVideo(_id:number):any {
return this.http.get_specific("saison", _id, "video");
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id, "video");
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getVideo()
.then(function(response) {
let data = response.gets_where([["==", "saison_id", _id]], ["id"], ["episode", "name"])
resolve(data);
}).catch(function(response) {
reject(response);
});
});
};
put(_id:number, _data:any):any {
return this.http.put_specific("saison", _id, _data);
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 {
return this.http.post_specific("saison", _id, {"data_id":_coverId}, "add_cover");
return this.http.post_specific(this.serviceName, _id, {"data_id":_coverId}, "add_cover");
};
getCoverUrl(_coverId:number):any {
return this.http.createRESTCall("data/" + _coverId);

View File

@ -1,6 +1,11 @@
import { Injectable } from '@angular/core';
import { HttpWrapperService } from 'app/service/http-wrapper.service';
//import { SHA512 } from 'assets/js_3rd_party/sha512';
import { DataInterface } from 'app/service/dataInterface';
import { BddService } from 'app/service/bdd.service';
import { environment } from 'environments/environment';
export interface MessageLogIn {
id: number;
@ -15,30 +20,130 @@ declare function dateFormat(param1: any, param2: any): any;
export class TypeService {
// 0: Not hide password; 1 hide password;
private identificationVersion: number = 1;
private serviceName:string = "type";
constructor(private http: HttpWrapperService) {
constructor(private http: HttpWrapperService,
private bdd: BddService) {
console.log("Start TypeService");
}
getData():any {
return this.http.get_specific("type");
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName);
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getType()
.then(function(response) {
let data = response.gets();
resolve(data);
}).catch(function(response) {
console.log("[E] " + self.constructor.name + ": can not retrive BDD values");
reject(response);
});
});
};
get(_id:number):any {
return this.http.get_specific("type", _id);
};
getSubGroup(_id:number, _select:Array<string> = []):any {
return this.http.get_specific("type", _id, "group", _select);
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id);
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getType()
.then(function(response) {
let data = response.get(_id);
if (data === null || data === undefined) {
reject("Data does not exist in the local BDD");
return;
}
resolve(data);
}).catch(function(response) {
reject(response);
});
});
};
getSubVideo(_id:number, _select:Array<string> = []):any {
return this.http.get_specific("type", _id, "video", _select);
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()
.then(function(response) {
let data = response.gets_where([["==", "type_id", _id], ["==", "group_id", null], ["==", "univers_id", null]], ["id"], ["name"]);
resolve(data);
}).catch(function(response) {
reject(response);
});
});
};
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()
.then(function(response) {
let data = response.gets_where([["==", "type_id", _id], ["!=", "group_id", null], ["==", "univers_id", null]], ["group_id"], ["name"]);
if (_select.length == 0) {
resolve(data);
return;
}
self.bdd.getGroup()
.then(function(response2) {
if (_select[0] == "*") {
let data2 = response2.gets_where([["==", "id", data]], undefined, ["name"]);
resolve(data2);
return;
}
let data3 = response2.gets_where([["==", "id", data]], _select, ["name"]);
resolve(data3);
return;
}).catch(function(response2) {
reject(response2);
});
}).catch(function(response) {
reject(response);
});
});
};
getSubUnivers(_id:number, _select:Array<string> = []):any {
return this.http.get_specific("type", _id, "univers", _select);
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()
.then(function(response) {
let data = response.data.gets_where([["==", "type_id", _id], ["==", "group_id", null], ["==", "univers_id", null]], ["univers_id"], ["name"]);
if (_select.length == 0) {
resolve(data);
return;
}
self.bdd.getUnivers()
.then(function(response2) {
if (_select[0] == "*") {
let data2 = response2.gets_where([["==", "id", data]], undefined, ["name"]);
resolve(data2);
return;
}
let data3 = response2.gets_where([["==", "id", data]], _select, ["name"]);
resolve(data3);
return;
}).catch(function(response2) {
reject(response2);
});
}).catch(function(response) {
reject(response);
});
});
};
getCoverUrl(_coverId:number):any {

View File

@ -1,36 +1,80 @@
import { Injectable } from '@angular/core';
import { HttpWrapperService } from 'app/service/http-wrapper.service';
import { DataInterface } from 'app/service/dataInterface';
import { BddService } from 'app/service/bdd.service';
import { environment } from 'environments/environment';
@Injectable()
export class UniversService {
// 0: Not hide password; 1 hide password;
private identificationVersion: number = 1;
private serviceName:string = "univers";
constructor(private http: HttpWrapperService) {
constructor(private http: HttpWrapperService,
private bdd: BddService) {
console.log("Start universService");
}
getData():any {
return this.http.get_specific("univers");
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName);
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getUnivers()
.then(function(response) {
let data = response.gets();
resolve(data);
}).catch(function(response) {
reject(response);
});
});
};
get(_id:number):any {
return this.http.get_specific("univers", _id);
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id);
}
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getUnivers()
.then(function(response) {
let data = response.get(_id);
if (data === null || data === undefined) {
reject("Data does not exist in the local BDD");
return;
}
resolve(data);
}).catch(function(response) {
reject(response);
});
});
};
getSubGroup(_id:number, _select:Array<string> = []):any {
return this.http.get_specific("univers", _id, "group", _select);
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id, "group", _select);
}
//this.checkLocalBdd();
};
getSubVideo(_id:number, _select:Array<string> = []):any {
return this.http.get_specific("univers", _id, "video", _select);
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id, "video", _select);
}
//this.checkLocalBdd();
};
put(_id:number, _data:any):any {
return this.http.put_specific("univers", _id, _data);
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 {
return this.http.post_specific("univers", _id, {"data_id":_coverId}, "add_cover");
return this.http.post_specific(this.serviceName, _id, {"data_id":_coverId}, "add_cover");
};
getCoverUrl(_coverId:number):any {
return this.http.createRESTCall("data/" + _coverId);

View File

@ -1,24 +1,51 @@
import { Injectable } from '@angular/core';
import { HttpWrapperService } from 'app/service/http-wrapper.service';
import { DataInterface } from 'app/service/dataInterface';
import { BddService } from 'app/service/bdd.service';
import { environment } from 'environments/environment';
@Injectable()
export class VideoService {
// 0: Not hide password; 1 hide password;
private identificationVersion: number = 1;
private serviceName:string = "video";
constructor(private http: HttpWrapperService) {
constructor(private http: HttpWrapperService,
private bdd: BddService) {
console.log("Start VideoService");
}
get(_id:number):any {
return this.http.get_specific("video", _id);
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)
.then(function(response) {
let data = response.get(_id);
if (data === null || data === undefined) {
reject("Data does not exist in the local BDD");
return;
}
resolve(data);
}).catch(function(response) {
reject(response);
});
});
};
put(_id:number, _data:any):any {
return this.http.put_specific("video", _id, _data);
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 {
return this.http.post_specific("video", _id, {"data_id":_coverId}, "add_cover");
return this.http.post_specific(this.serviceName, _id, {"data_id":_coverId}, "add_cover");
};
getCoverUrl(_coverId:number):any {
return this.http.createRESTCall("data/" + _coverId);

View File

@ -7,6 +7,8 @@ export const environment = {
production: false,
// URL of development API
apiUrl: 'http://192.168.1.157/karideo/api',
apiMode: "QUERRY"
//apiMode: "REWRITE"
frontBaseUrl: 'karideo',
apiMode: "QUERRY",
//apiMode: "REWRITE",
localBdd: true
}

View File

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