|
|
@@ -30,21 +30,21 @@ class Connection{
|
|
|
switch (method) {
|
|
|
case HTTP_METHOD.GET:
|
|
|
if(args.id)
|
|
|
- return this.getItem(url, args.id)
|
|
|
+ return this.getItem(url, args.id, args.progress)
|
|
|
else
|
|
|
- return this.getCollection(url)
|
|
|
+ return this.getCollection(url, args.progress)
|
|
|
|
|
|
case HTTP_METHOD.PUT:
|
|
|
if(this.isArgsIsDataPersisterArgs(args)){
|
|
|
if(!args.data)
|
|
|
throw new Error('data not found')
|
|
|
|
|
|
- return this.put(url, args.id, args.data)
|
|
|
+ return this.put(url, args.id, args.data, args.progress)
|
|
|
}
|
|
|
else throw new Error('args not a dataPersisterArgs')
|
|
|
|
|
|
case HTTP_METHOD.DELETE:
|
|
|
- return this.deleteItem(url, args.id)
|
|
|
+ return this.deleteItem(url, args.id, args.progress)
|
|
|
}
|
|
|
|
|
|
throw new Error('Method unknown')
|
|
|
@@ -54,12 +54,14 @@ class Connection{
|
|
|
* GET Item : préparation de la config pour la récupération d'un item
|
|
|
* @param {string} url
|
|
|
* @param {number} id
|
|
|
+ * @param {boolean} progress
|
|
|
* @return {Promise<any>}
|
|
|
*/
|
|
|
- private getItem(url: string, id: number): Promise<any>{
|
|
|
+ private getItem(url: string, id: number, progress: boolean = true): Promise<any>{
|
|
|
const config:AxiosRequestConfig = {
|
|
|
url: `${url}/${id}`,
|
|
|
method: HTTP_METHOD.GET,
|
|
|
+ progress: progress
|
|
|
}
|
|
|
return this.request(config)
|
|
|
}
|
|
|
@@ -67,12 +69,14 @@ class Connection{
|
|
|
/**
|
|
|
* Get collection : préparation de la config pour la récupération d'une collection d'items
|
|
|
* @param {string} url
|
|
|
+ * @param {boolean} progress
|
|
|
* @return {Promise<any>}
|
|
|
*/
|
|
|
- private getCollection(url: string): Promise<any>{
|
|
|
+ private getCollection(url: string, progress: boolean = true): Promise<any>{
|
|
|
const config:AxiosRequestConfig = {
|
|
|
url: `${url}`,
|
|
|
method: HTTP_METHOD.GET,
|
|
|
+ progress: progress
|
|
|
}
|
|
|
return this.request(config)
|
|
|
}
|
|
|
@@ -82,13 +86,15 @@ class Connection{
|
|
|
* @param {string} url
|
|
|
* @param {number} id
|
|
|
* @param {AnyJson} data
|
|
|
+ * @param {boolean} progress
|
|
|
* @return {Promise<any>}
|
|
|
*/
|
|
|
- private put(url: string, id: number, data: AnyJson): Promise<any>{
|
|
|
+ private put(url: string, id: number, data: AnyJson, progress: boolean = true): Promise<any>{
|
|
|
const config:AxiosRequestConfig = {
|
|
|
url: `${url}/${id}`,
|
|
|
method: HTTP_METHOD.PUT,
|
|
|
- data: data
|
|
|
+ data: data,
|
|
|
+ progress: progress
|
|
|
}
|
|
|
return this.request(config)
|
|
|
}
|
|
|
@@ -97,12 +103,14 @@ class Connection{
|
|
|
* DELETE Item : préparation de la config pour la suppression d'un item
|
|
|
* @param {string} url
|
|
|
* @param {number} id
|
|
|
+ * @param {boolean} progress
|
|
|
* @return {Promise<any>}
|
|
|
*/
|
|
|
- private deleteItem(url: string, id: number): Promise<any>{
|
|
|
+ private deleteItem(url: string, id: number, progress: boolean = true): Promise<any>{
|
|
|
const config:AxiosRequestConfig = {
|
|
|
url: `${url}/${id}`,
|
|
|
method: HTTP_METHOD.DELETE,
|
|
|
+ progress: progress
|
|
|
}
|
|
|
return this.request(config)
|
|
|
}
|