[DEV] integrate update of video properties
This commit is contained in:
parent
8c2a836e65
commit
766db280f9
@ -104,17 +104,24 @@ def add(_app, _name_api):
|
||||
@doc.description("List all the videos availlable for this group tht does not depend on saison.")
|
||||
@doc.produces(content_type='application/json')
|
||||
async def retrive_saison(request, id):
|
||||
value = data_global_elements.get_interface(data_global_elements.API_SAISON).gets_where(select=[["==", "group_id", id]], filter=["id"])
|
||||
if value != None:
|
||||
return response.json(value)
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_SAISON).gets_where(select=[["==", "group_id", id]], filter=["id"])
|
||||
if list_values == None:
|
||||
raise ServerError("No data found", status_code=404)
|
||||
if len(list_values) == 0:
|
||||
return response.json(list_values)
|
||||
if "select" in request.args:
|
||||
if request.args["select"] == "*":
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_SAISON).gets_where(select=[["==", "id", list_values]])
|
||||
else:
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_SAISON).gets_where(select=[["==", "id", list_values]], filter=request.args["select"])
|
||||
return response.json(list_values)
|
||||
|
||||
@elem_blueprint.put('/' + _name_api + '/<id:int>', strict_slashes=True)
|
||||
@doc.summary("Update resource")
|
||||
@doc.description("Update the specified resource in storage.")
|
||||
@doc.response_success(status=201, description='If successful updated')
|
||||
async def update(request, id):
|
||||
ret = data_global_elements.get_interface(_name_api).put(id)
|
||||
ret = data_global_elements.get_interface(_name_api).put(id, request.json)
|
||||
return response.json({})
|
||||
|
||||
@elem_blueprint.delete('/' + _name_api + '/<id:int>', strict_slashes=True)
|
||||
|
@ -97,7 +97,7 @@ def add(_app, _name_api):
|
||||
@doc.description("Update the specified resource in storage.")
|
||||
@doc.response_success(status=201, description='If successful updated')
|
||||
async def update(request, id):
|
||||
ret = data_global_elements.get_interface(_name_api).put(id)
|
||||
ret = data_global_elements.get_interface(_name_api).put(id, request.json)
|
||||
return response.json({})
|
||||
|
||||
@elem_blueprint.delete('/' + _name_api + '/<id:int>', strict_slashes=True)
|
||||
|
@ -73,7 +73,7 @@ def add(_app, _name_api):
|
||||
@doc.description("Update the specified resource in storage.")
|
||||
@doc.response_success(status=201, description='If successful updated')
|
||||
async def update(request, id):
|
||||
ret = data_global_elements.get_interface(_name_api).put(id)
|
||||
ret = data_global_elements.get_interface(_name_api).put(id, request.json)
|
||||
return response.json({})
|
||||
|
||||
@elem_blueprint.delete('/' + _name_api + '/<id:int>', strict_slashes=True)
|
||||
@ -111,6 +111,8 @@ def add(_app, _name_api):
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_VIDEO).gets_where(select=[["==", "type_id", id], ["==", "group_id", None], ["==", "univers_id", None]], filter=["id"])
|
||||
return response.json(list_values)
|
||||
|
||||
## ----------------------------------------------------------------------------------------
|
||||
## sub list of Groups ...
|
||||
@elem_blueprint.get('/' + _name_api + '/<id:int>/group', strict_slashes=True)
|
||||
@doc.summary("List all group availlable.")
|
||||
@doc.description("List all groups availlable in this type (not depending of an univers).")
|
||||
@ -119,9 +121,15 @@ def add(_app, _name_api):
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_VIDEO).gets_where(select=[["==", "type_id", id], ["!=", "group_id", None], ["==", "univers_id", None]], filter=["group_id"])
|
||||
if len(list_values) == 0:
|
||||
return response.json(list_values)
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_GROUP).gets_where(select=[["==", "id", list_values]], filter=["id", "name"])
|
||||
if "select" in request.args:
|
||||
if request.args["select"] == "*":
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_GROUP).gets_where(select=[["==", "id", list_values]])
|
||||
else:
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_GROUP).gets_where(select=[["==", "id", list_values]], filter=request.args["select"])
|
||||
return response.json(list_values)
|
||||
|
||||
## ----------------------------------------------------------------------------------------
|
||||
## Sub list of univers ...
|
||||
@elem_blueprint.get('/' + _name_api + '/<id:int>/univers', strict_slashes=True)
|
||||
@doc.summary("List all univers availlable.")
|
||||
@doc.description("List all univers availlable.")
|
||||
@ -130,7 +138,11 @@ def add(_app, _name_api):
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_VIDEO).gets_where(select=[["==", "type_id", id], ["!=", "univers_id", None]], filter=["univers_id"])
|
||||
if len(list_values) == 0:
|
||||
return response.json(list_values)
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_UNIVERS).gets_where(select=[["==", "id", list_values]], filter=["id", "name"])
|
||||
if "select" in request.args:
|
||||
if request.args["select"] == "*":
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_UNIVERS).gets_where(select=[["==", "id", list_values]])
|
||||
else:
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_UNIVERS).gets_where(select=[["==", "id", list_values]], filter=request.args["select"])
|
||||
return response.json(list_values)
|
||||
|
||||
_app.blueprint(elem_blueprint)
|
@ -74,7 +74,7 @@ def add(_app, _name_api):
|
||||
@doc.description("Update the specified resource in storage.")
|
||||
@doc.response_success(status=201, description='If successful updated')
|
||||
async def update(request, id):
|
||||
ret = data_global_elements.get_interface(_name_api).put(id)
|
||||
ret = data_global_elements.get_interface(_name_api).put(id, request.json)
|
||||
return response.json({})
|
||||
|
||||
@elem_blueprint.delete('/' + _name_api + '/<id:int>', strict_slashes=True)
|
||||
@ -112,12 +112,18 @@ def add(_app, _name_api):
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_VIDEO).gets_where(select=[["==", "univers_id", id], ["==", "group_id", None], ["==", "univers_id", None]], filter=["id"])
|
||||
return response.json(list_values)
|
||||
|
||||
## ----------------------------------------------------------------------------------------
|
||||
@elem_blueprint.get('/' + _name_api + '/<id:int>/group', strict_slashes=True)
|
||||
@doc.summary("List all group availlable.")
|
||||
@doc.description("List all groups availlable in this univers (not depending of an univers).")
|
||||
@doc.produces(content_type='application/json')
|
||||
async def retrive_group(request, id):
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_VIDEO).gets_where(select=[["==", "univers_id", id], ["!=", "group_id", None], ["==", "univers_id", None]], filter=["group_id"])
|
||||
if "select" in request.args:
|
||||
if request.args["select"] == "*":
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_GROUP).gets_where(select=[["==", "id", list_values]])
|
||||
else:
|
||||
list_values = data_global_elements.get_interface(data_global_elements.API_GROUP).gets_where(select=[["==", "id", list_values]], filter=request.args["select"].split('|'))
|
||||
return response.json(list_values)
|
||||
|
||||
@elem_blueprint.post('/' + _name_api + "/<id:int>/add_cover", strict_slashes=True)
|
||||
|
@ -152,8 +152,8 @@ def add(_app, _name_api):
|
||||
@doc.description("Update the specified resource in storage.")
|
||||
@doc.response_success(status=201, description='If successful updated')
|
||||
async def update(request, id):
|
||||
ret = data_global_elements.get_interface(_name_api).put(id)
|
||||
return response.json({})
|
||||
ret = data_global_elements.get_interface(_name_api).put(id, request.json)
|
||||
return response.json({"update":"done"});
|
||||
|
||||
@elem_blueprint.delete('/' + _name_api + '/<id:int>', strict_slashes=True)
|
||||
@doc.summary("Remove resource")
|
||||
|
@ -12,6 +12,7 @@ import tools
|
||||
import json
|
||||
from realog import debug
|
||||
import random
|
||||
import copy
|
||||
from sanic.exceptions import ServerError
|
||||
##
|
||||
## @breif Generic interface to access to the BDD (no BDD, direct file IO)
|
||||
@ -167,8 +168,16 @@ class DataInterface():
|
||||
id_in_bdd = self.get_table_index(_id)
|
||||
if id_in_bdd == None:
|
||||
return False
|
||||
_value["id"] = _id
|
||||
self.bdd[id_in_bdd] = _value
|
||||
# todo: check the model before update ...
|
||||
debug.warning("update element: " + str(_id))
|
||||
value_bdd = copy.deepcopy(self.bdd[id_in_bdd]);
|
||||
for elem in _value.keys():
|
||||
debug.warning(" [" + elem + "] " + str(value_bdd[elem]) + " ==> " + str(_value[elem]))
|
||||
value_bdd[elem] = _value[elem]
|
||||
if self.check_with_model(value_bdd) == False:
|
||||
raise ServerError("FORBIDDEN Corelation with BDD error", status_code=403)
|
||||
self.bdd[id_in_bdd] = value_bdd
|
||||
debug.warning(" ==> " + str(self.bdd[id_in_bdd]))
|
||||
self.mark_to_store()
|
||||
return True
|
||||
|
||||
@ -265,6 +274,8 @@ class DataInterface():
|
||||
|
||||
def filter_object_values(self, _values, _filter):
|
||||
out = []
|
||||
if _filter == None:
|
||||
return _values
|
||||
if len(_filter) == 1:
|
||||
token = _filter[0]
|
||||
for elem in _values:
|
||||
|
@ -6,8 +6,9 @@
|
||||
</div>
|
||||
<div class="input">
|
||||
<input type="text"
|
||||
placeholder="Name of the film"
|
||||
[(value)]="name"
|
||||
placeholder="Name of the Media"
|
||||
[value]="name"
|
||||
(input)="onName($event.target.value)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -16,7 +17,10 @@
|
||||
Description:
|
||||
</div>
|
||||
<div class="input">
|
||||
<input type="text" [(value)]="description"/>
|
||||
<input type="text"
|
||||
placeholder="Description of the Media"
|
||||
[value]="description"
|
||||
(input)="onDescription($event.target.value)"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="request_raw">
|
||||
@ -24,7 +28,9 @@
|
||||
Date:
|
||||
</div>
|
||||
<div class="input">
|
||||
<input type="text" [(value)]="time"/>
|
||||
<input type="text"
|
||||
[value]="time"
|
||||
(input)="onDate($event.target.value)"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="request_raw">
|
||||
@ -32,7 +38,8 @@
|
||||
Type:
|
||||
</div>
|
||||
<div class="input">
|
||||
<select [(ngModel)]="type_id">
|
||||
<select [ngModel]="type_id"
|
||||
(ngModelChange)="onChangeType($event)">
|
||||
<option *ngFor="let element of listType" [ngValue]="element.value">{{element.label}}</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -42,7 +49,8 @@
|
||||
Univers:
|
||||
</div>
|
||||
<div class="input">
|
||||
<select [(ngModel)]="univers_id">
|
||||
<select [ngModel]="univers_id"
|
||||
(ngModelChange)="onChangeUnivers($event)">
|
||||
<option *ngFor="let element of listUnivers" [ngValue]="element.value">{{element.label}}</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -52,7 +60,8 @@
|
||||
Group:
|
||||
</div>
|
||||
<div class="input">
|
||||
<select [(ngModel)]="group_id">
|
||||
<select [ngModel]="group_id"
|
||||
(ngModelChange)="onChangeGroup($event)">
|
||||
<option *ngFor="let element of listGroup" [ngValue]="element.value">{{element.label}}</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -62,7 +71,8 @@
|
||||
Saison:
|
||||
</div>
|
||||
<div class="input">
|
||||
<select [(ngModel)]="saison_id">
|
||||
<select [ngModel]="saison_id"
|
||||
(ngModelChange)="onChangeSaison($event)">
|
||||
<option *ngFor="let element of listSaison" [ngValue]="element.value">{{element.label}}</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -72,7 +82,9 @@
|
||||
Episode:
|
||||
</div>
|
||||
<div class="input">
|
||||
<input type="text" [(value)]="episode"/>
|
||||
<input type="text"
|
||||
[value]="episode"
|
||||
(input)="onEpisode($event.target.value)"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="request_raw">
|
||||
|
@ -15,6 +15,7 @@ import { HttpWrapperService } from '../../service/http-wrapper.service';
|
||||
|
||||
import { TypeService } from '../../service/type.service';
|
||||
import { UniversService } from '../../service/univers.service';
|
||||
import { GroupService } from '../../service/group.service';
|
||||
import { VideoService } from '../../service/video.service';
|
||||
|
||||
export class ElementList {
|
||||
@ -49,7 +50,6 @@ export class VideoEditComponent implements OnInit {
|
||||
time:number = undefined
|
||||
type_id:number = undefined
|
||||
generated_name:string = ""
|
||||
video_source:string = ""
|
||||
listType: ElementList[] = [
|
||||
{value: undefined, label: '---'},
|
||||
];
|
||||
@ -68,66 +68,48 @@ export class VideoEditComponent implements OnInit {
|
||||
private locate: Location,
|
||||
private typeService: TypeService,
|
||||
private universService: UniversService,
|
||||
private groupService: GroupService,
|
||||
private videoService: VideoService,
|
||||
private httpService: HttpWrapperService) {
|
||||
|
||||
}
|
||||
|
||||
sendValues():void {
|
||||
console.log("send new values....");
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.id_video = parseInt(this.route.snapshot.paramMap.get('video_id'));
|
||||
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) {
|
||||
self.listUnivers = [{value: undefined, label: '---'}];
|
||||
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.videoService.get(this.id_video)
|
||||
.then(function(response) {
|
||||
console.log("get response of video : " + JSON.stringify(response, null, 2));
|
||||
self.name = response.name;
|
||||
self.description = response.description;
|
||||
self.episode = response.episode;
|
||||
self.type_id = response.type_id;
|
||||
self.typeService.getData()
|
||||
.then(function(response2) {
|
||||
self.listType = [{value: undefined, label: '---'}];
|
||||
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));
|
||||
});
|
||||
self.saison_id = response.saison_id;
|
||||
self.group_id = response.group_id;
|
||||
self.listGroup = [{value: undefined, label: '---'}];
|
||||
if (response.type_id != undefined) {
|
||||
self.typeService.getSubGroup(response.type_id)
|
||||
.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));
|
||||
});
|
||||
}
|
||||
self.univers_id = response.univers_id;
|
||||
self.data_id = response.data_id;
|
||||
self.time = response.time;
|
||||
self.generated_name = response.generated_name;
|
||||
if (self.data_id != -1) {
|
||||
self.video_source = self.httpService.createRESTCall("data/" + self.data_id);
|
||||
} else {
|
||||
self.video_source = "";
|
||||
}
|
||||
console.log("display source " + self.video_source);
|
||||
self.onChangeType(response.type_id);
|
||||
self.onChangeGroup(response.group_id);
|
||||
self.saison_id = response.saison_id;
|
||||
//console.log("set transformed : " + JSON.stringify(self, null, 2));
|
||||
}).catch(function(response) {
|
||||
self.error = "Can not get the data";
|
||||
@ -140,12 +122,83 @@ export class VideoEditComponent implements OnInit {
|
||||
self.data_id = -1;
|
||||
self.time = undefined;
|
||||
self.generated_name = "";
|
||||
self.video_source = "";
|
||||
});
|
||||
}
|
||||
submitChange(videoForm:NgForm):void {
|
||||
console.log("videoForm form display" + videoForm);
|
||||
|
||||
onChangeType(_value:any):void {
|
||||
console.log("Change requested of type ... " + _value);
|
||||
this.type_id = _value;
|
||||
this.group_id = null;
|
||||
this.saison_id = null;
|
||||
this.listGroup = [{value: undefined, label: '---'}];
|
||||
this.listSaison = [{value: undefined, label: '---'}];
|
||||
let self = this;
|
||||
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));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onChangeUnivers(_value:any):void {
|
||||
this.univers_id = _value;
|
||||
}
|
||||
|
||||
onChangeGroup(_value:any):void {
|
||||
this.group_id = _value;
|
||||
this.saison_id = null;
|
||||
this.listSaison = [{value: undefined, label: '---'}];
|
||||
let self = this;
|
||||
if (this.group_id != undefined) {
|
||||
self.groupService.getSaison(this.group_id, ["id", "number"])
|
||||
.then(function(response3) {
|
||||
for(let iii= 0; iii < response3.length; iii++) {
|
||||
self.listSaison.push({value: response3[iii].id, label: "saison " + response3[iii].number});
|
||||
}
|
||||
}).catch(function(response3) {
|
||||
console.log("get response22 : " + JSON.stringify(response3, null, 2));
|
||||
});
|
||||
}
|
||||
}
|
||||
onChangeSaison(_value:any):void {
|
||||
this.saison_id = _value;
|
||||
}
|
||||
|
||||
onName(_value:any):void {
|
||||
this.name = _value;
|
||||
}
|
||||
|
||||
onDescription(_value:any):void {
|
||||
this.description = _value;
|
||||
}
|
||||
|
||||
onDate(_value:any):void {
|
||||
this.time = _value;
|
||||
}
|
||||
|
||||
onEpisode(_value:any):void {
|
||||
this.episode = _value;
|
||||
}
|
||||
|
||||
|
||||
sendValues():void {
|
||||
console.log("send new values....");
|
||||
let data = {
|
||||
"name": this.name,
|
||||
"description": this.description,
|
||||
"episode": this.episode,
|
||||
"time": this.time,
|
||||
"type_id": this.type_id,
|
||||
"univers_id": this.univers_id,
|
||||
"group_id": this.group_id,
|
||||
"saison_id": this.saison_id
|
||||
};
|
||||
this.videoService.put(this.id_video, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,47 +10,20 @@ export class GroupService {
|
||||
console.log("Start GroupService");
|
||||
}
|
||||
|
||||
get_specific(_id:number, _subElement:string = ""):any {
|
||||
console.log("Get All data from types");
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = "group/" + _id;
|
||||
if (_subElement != "") {
|
||||
url += "/" + _subElement;
|
||||
}
|
||||
console.log("call GET " + url);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http.get(url, httpOption, {})
|
||||
.then(function(response: any) {
|
||||
if (response.status == 200) {
|
||||
resolve(response.data);
|
||||
//console.log("get data from type : " + 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));
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
get(_id:number):any {
|
||||
return this.get_specific(_id);
|
||||
return this.http.get_specific("group", _id);
|
||||
};
|
||||
|
||||
getVideoAll(_id:number):any {
|
||||
return this.get_specific(_id, "video_all");
|
||||
return this.http.get_specific("group", _id, "video_all");
|
||||
};
|
||||
|
||||
getVideo(_id:number):any {
|
||||
return this.get_specific(_id, "video");
|
||||
return this.http.get_specific("group", _id, "video");
|
||||
};
|
||||
|
||||
getSaison(_id:number):any {
|
||||
return this.get_specific(_id, "saison");
|
||||
getSaison(_id:number, _select:Array<string> = []):any {
|
||||
return this.http.get_specific("group", _id, "saison", _select);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -103,4 +103,117 @@ export class HttpWrapperService {
|
||||
});
|
||||
});
|
||||
}
|
||||
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});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 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:
|
||||
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));
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -10,40 +10,12 @@ export class SaisonService {
|
||||
console.log("Start SaisonService");
|
||||
}
|
||||
|
||||
get_specific(_id:number, _subElement:string = ""):any {
|
||||
console.log("Get All data from types");
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = "saison/" + _id;
|
||||
if (_subElement != "") {
|
||||
url += "/" + _subElement;
|
||||
}
|
||||
console.log("call GET " + url);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http.get(url, httpOption, {})
|
||||
.then(function(response: any) {
|
||||
if (response.status == 200) {
|
||||
resolve(response.data);
|
||||
//console.log("get data from type : " + 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));
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
get(_id:number):any {
|
||||
return this.get_specific(_id);
|
||||
return this.http.get_specific("saison", _id);
|
||||
};
|
||||
|
||||
getVideo(_id:number):any {
|
||||
return this.get_specific(_id, "video");
|
||||
return this.http.get_specific("saison", _id, "video");
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -20,136 +20,25 @@ export class TypeService {
|
||||
console.log("Start TypeService");
|
||||
}
|
||||
|
||||
getData():any {
|
||||
console.log("Get All data from types");
|
||||
let currentDate:number = dateFormat(new Date(), 'm-d-Y h:i:s ms');
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = "type";
|
||||
console.log("call GET " + url);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http.get(url, httpOption, {})
|
||||
.then(function(response: any) {
|
||||
if (response.status == 200) {
|
||||
resolve(response.data);
|
||||
//console.log("get data from type : " + 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));
|
||||
}
|
||||
});
|
||||
});
|
||||
getData():any {
|
||||
return this.http.get_specific("type");
|
||||
};
|
||||
|
||||
get(_id:number):any {
|
||||
console.log("Get All data from types");
|
||||
let currentDate:number = dateFormat(new Date(), 'm-d-Y h:i:s ms');
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = "type/" + _id;
|
||||
console.log("call GET " + url);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http.get(url, httpOption, {})
|
||||
.then(function(response: any) {
|
||||
if (response.status == 200) {
|
||||
resolve(response.data);
|
||||
console.log("get data from type : " + 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));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return this.http.get_specific("type", _id);
|
||||
};
|
||||
|
||||
getSubGroup(_id: number):any {
|
||||
console.log("Get All data from types");
|
||||
let currentDate:number = dateFormat(new Date(), 'm-d-Y h:i:s ms');
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = "type/" + _id + "/group";
|
||||
console.log("call GET " + url);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http.get(url, httpOption, {})
|
||||
.then(function(response: any) {
|
||||
if (response.status == 200) {
|
||||
resolve(response.data);
|
||||
console.log("get data from type : " + 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));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
getSubGroup(_id:number, _select:Array<string> = []):any {
|
||||
return this.http.get_specific("type", _id, "group", _select);
|
||||
};
|
||||
|
||||
getSubVideo(_id: number):any {
|
||||
console.log("Get All data from types");
|
||||
let currentDate:number = dateFormat(new Date(), 'm-d-Y h:i:s ms');
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = "type/" + _id + "/video";
|
||||
console.log("call GET " + url);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http.get(url, httpOption, {})
|
||||
.then(function(response: any) {
|
||||
if (response.status == 200) {
|
||||
resolve(response.data);
|
||||
console.log("get data from type : " + 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));
|
||||
}
|
||||
});
|
||||
});
|
||||
getSubVideo(_id:number, _select:Array<string> = []):any {
|
||||
return this.http.get_specific("type", _id, "video", _select);
|
||||
};
|
||||
|
||||
getSubUnivers(_id: number):any {
|
||||
console.log("Get All data from types");
|
||||
let currentDate:number = dateFormat(new Date(), 'm-d-Y h:i:s ms');
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = "type/" + _id + "/univers";
|
||||
console.log("call GET " + url);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http.get(url, httpOption, {})
|
||||
.then(function(response: any) {
|
||||
if (response.status == 200) {
|
||||
resolve(response.data);
|
||||
console.log("get data from type : " + 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));
|
||||
}
|
||||
});
|
||||
});
|
||||
getSubUnivers(_id:number, _select:Array<string> = []):any {
|
||||
return this.http.get_specific("type", _id, "univers", _select);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -11,106 +11,19 @@ export class UniversService {
|
||||
}
|
||||
|
||||
getData():any {
|
||||
console.log("Get All data from types");
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = "univers";
|
||||
console.log("call GET " + url);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http.get(url, httpOption, {})
|
||||
.then(function(response: any) {
|
||||
if (response.status == 200) {
|
||||
resolve(response.data);
|
||||
//console.log("get data from univers : " + 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));
|
||||
}
|
||||
});
|
||||
});
|
||||
return this.http.get_specific("univers");
|
||||
};
|
||||
|
||||
get(_id:number):any {
|
||||
console.log("Get All data from univers");
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = "univers/" + _id;
|
||||
console.log("call GET " + url);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http.get(url, httpOption, {})
|
||||
.then(function(response: any) {
|
||||
if (response.status == 200) {
|
||||
resolve(response.data);
|
||||
console.log("get data from type : " + 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));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return this.http.get_specific("univers", _id);
|
||||
};
|
||||
|
||||
getSubGroup(_id: number):any {
|
||||
console.log("Get All data from types");
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = "univers/" + _id + "/group";
|
||||
console.log("call GET " + url);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http.get(url, httpOption, {})
|
||||
.then(function(response: any) {
|
||||
if (response.status == 200) {
|
||||
resolve(response.data);
|
||||
console.log("get data from type : " + 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));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
getSubGroup(_id:number, _select:Array<string> = []):any {
|
||||
return this.http.get_specific("univers", _id, "group", _select);
|
||||
};
|
||||
|
||||
getSubVideo(_id: number):any {
|
||||
console.log("Get All data from types");
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = "univers/" + _id + "/video_no_group";
|
||||
console.log("call GET " + url);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http.get(url, httpOption, {})
|
||||
.then(function(response: any) {
|
||||
if (response.status == 200) {
|
||||
resolve(response.data);
|
||||
console.log("get data from type : " + 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));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
getSubVideo(_id:number, _select:Array<string> = []):any {
|
||||
return this.http.get_specific("univers", _id, "video", _select);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -10,35 +10,11 @@ export class VideoService {
|
||||
console.log("Start VideoService");
|
||||
}
|
||||
|
||||
get_specific(_id:number, _subElement:string = ""):any {
|
||||
console.log("Get All data from types");
|
||||
const httpOption = { 'Content-Type': 'application/json' };
|
||||
let url = "video/" + _id;
|
||||
if (_subElement != "") {
|
||||
url += "/" + _subElement;
|
||||
}
|
||||
console.log("call GET " + url);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http.get(url, httpOption, {})
|
||||
.then(function(response: any) {
|
||||
if (response.status == 200) {
|
||||
resolve(response.data);
|
||||
//console.log("get data from response : " + JSON.stringify(response.data, null, 2));
|
||||
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));
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
get(_id:number):any {
|
||||
return this.get_specific(_id);
|
||||
return this.http.get_specific("video", _id);
|
||||
};
|
||||
put(_id:number, _data:any):any {
|
||||
return this.http.put_specific("video", _id, _data);
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user