[DEV] add delete for video
This commit is contained in:
parent
2e9fc87fb5
commit
ac5707b781
@ -380,6 +380,14 @@ export class VideoEditComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
removeMedia() {
|
removeMedia() {
|
||||||
console.log("Request remove Media...");
|
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 {
|
eventPopUpSaison(_event: string): void {
|
||||||
|
@ -43,6 +43,23 @@ export class BddService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete(_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.delete(_id);
|
||||||
|
resolve(response2);
|
||||||
|
}).catch(function(response2) {
|
||||||
|
reject(response2);
|
||||||
|
});
|
||||||
|
}).catch(function(response) {
|
||||||
|
reject(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
get(_name: string): any {
|
get(_name: string): any {
|
||||||
let self = this;
|
let self = this;
|
||||||
if (this.bdd[_name] === undefined) {
|
if (this.bdd[_name] === undefined) {
|
||||||
|
@ -68,7 +68,7 @@ export class DataInterface {
|
|||||||
console.log("[I] delete " + this.name + " " + _id)
|
console.log("[I] delete " + this.name + " " + _id)
|
||||||
for (let iii=0; iii<this.bdd.length; iii++) {
|
for (let iii=0; iii<this.bdd.length; iii++) {
|
||||||
if (this.bdd[iii]['id'] == _id) {
|
if (this.bdd[iii]['id'] == _id) {
|
||||||
this.bdd[iii] = undefined
|
this.bdd.splice(iii, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,6 +138,40 @@ export class HttpWrapperService {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
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 {
|
uploadFileMultipart(_base:string, _id:number, _file:File): any {
|
||||||
console.log("Upload file to " + _base);
|
console.log("Upload file to " + _base);
|
||||||
@ -259,12 +293,12 @@ export class HttpWrapperService {
|
|||||||
}
|
}
|
||||||
url += "?" + select;
|
url += "?" + select;
|
||||||
}
|
}
|
||||||
console.log("call GET " + url);
|
//console.log("call GET " + url);
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.get(url, httpOption, {})
|
this.get(url, httpOption, {})
|
||||||
.then(function(response: any) {
|
.then(function(response: any) {
|
||||||
console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
//console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||||
if (response.status == 200) {
|
if (response.status == 200) {
|
||||||
resolve(response.data);
|
resolve(response.data);
|
||||||
return;
|
return;
|
||||||
@ -281,8 +315,8 @@ export class HttpWrapperService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Complex wrapper to simplify interaction:
|
// Complex wrapper to simplify interaction:
|
||||||
put_specific(_base:string, _id:number, _data:any, _subElement:string = ""):any {
|
delete_specific(_base:string, _id:number, _subElement:string = ""):any {
|
||||||
console.log("put data to " + _base);
|
//console.log("delete data to " + _base);
|
||||||
const httpOption = { 'Content-Type': 'application/json' };
|
const httpOption = { 'Content-Type': 'application/json' };
|
||||||
let url = _base;
|
let url = _base;
|
||||||
if (_id != null) {
|
if (_id != null) {
|
||||||
@ -291,13 +325,49 @@ export class HttpWrapperService {
|
|||||||
if (_subElement != "") {
|
if (_subElement != "") {
|
||||||
url += "/" + _subElement;
|
url += "/" + _subElement;
|
||||||
}
|
}
|
||||||
console.log("call PUT: " + url);
|
//console.log("call DELETE: " + url);
|
||||||
console.log(" data: " + JSON.stringify(_data, null, 2));
|
//console.log(" data: " + JSON.stringify(_data, null, 2));
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
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) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.put(url, httpOption, _data)
|
this.put(url, httpOption, _data)
|
||||||
.then(function(response: any) {
|
.then(function(response: any) {
|
||||||
console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
//console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||||
if (response.status == 200) {
|
if (response.status == 200) {
|
||||||
resolve(response.data);
|
resolve(response.data);
|
||||||
return;
|
return;
|
||||||
@ -318,7 +388,7 @@ export class HttpWrapperService {
|
|||||||
};
|
};
|
||||||
// Complex wrapper to simplify interaction:
|
// Complex wrapper to simplify interaction:
|
||||||
post_specific(_base:string, _id:number, _data:any, _subElement:string = ""):any {
|
post_specific(_base:string, _id:number, _data:any, _subElement:string = ""):any {
|
||||||
console.log("put data to " + _base);
|
//console.log("put data to " + _base);
|
||||||
const httpOption = { 'Content-Type': 'application/json' };
|
const httpOption = { 'Content-Type': 'application/json' };
|
||||||
let url = _base;
|
let url = _base;
|
||||||
if (_id != null) {
|
if (_id != null) {
|
||||||
@ -327,13 +397,13 @@ export class HttpWrapperService {
|
|||||||
if (_subElement != "") {
|
if (_subElement != "") {
|
||||||
url += "/" + _subElement;
|
url += "/" + _subElement;
|
||||||
}
|
}
|
||||||
console.log("call PUT: " + url);
|
//console.log("call PUT: " + url);
|
||||||
console.log(" data: " + JSON.stringify(_data, null, 2));
|
//console.log(" data: " + JSON.stringify(_data, null, 2));
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.post(url, httpOption, _data)
|
this.post(url, httpOption, _data)
|
||||||
.then(function(response: any) {
|
.then(function(response: any) {
|
||||||
console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
//console.log("URL: " + url + "\nRespond(" + response.status + "): " + JSON.stringify(response.data, null, 2));
|
||||||
if (response.status == 200) {
|
if (response.status == 200) {
|
||||||
resolve(response.data);
|
resolve(response.data);
|
||||||
return;
|
return;
|
||||||
|
@ -39,11 +39,12 @@ export class VideoService {
|
|||||||
|
|
||||||
put(_id:number, _data:any):any {
|
put(_id:number, _data:any):any {
|
||||||
let ret = this.http.put_specific(this.serviceName, _id, _data);
|
let ret = this.http.put_specific(this.serviceName, _id, _data);
|
||||||
if (environment.localBdd != true) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
return this.bdd.setAfterPut(this.serviceName, _id, ret);
|
return this.bdd.setAfterPut(this.serviceName, _id, ret);
|
||||||
};
|
};
|
||||||
|
delete(_id:number):any {
|
||||||
|
let ret = this.http.delete_specific(this.serviceName, _id);
|
||||||
|
return this.bdd.delete(this.serviceName, _id, ret);
|
||||||
|
};
|
||||||
addCover(_id:number, _coverId:number):any {
|
addCover(_id:number, _coverId:number):any {
|
||||||
return this.http.post_specific(this.serviceName, _id, {"data_id":_coverId}, "add_cover");
|
return this.http.post_specific(this.serviceName, _id, {"data_id":_coverId}, "add_cover");
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user