|
|
@ -74,7 +74,8 @@ export class AnalyticService { |
|
|
|
panelTemplate: PanelTemplate, |
|
|
|
panelTemplate: PanelTemplate, |
|
|
|
templateVariables: TemplateVariables |
|
|
|
templateVariables: TemplateVariables |
|
|
|
): Promise<void> { |
|
|
|
): Promise<void> { |
|
|
|
await this.post('/panels/template', { panelTemplate, templateVariables }); |
|
|
|
const rawError = true; |
|
|
|
|
|
|
|
return this.post('/panels/template', { panelTemplate, templateVariables }, rawError); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async postNewAnalyticUnit( |
|
|
|
async postNewAnalyticUnit( |
|
|
@ -282,7 +283,7 @@ export class AnalyticService { |
|
|
|
return this.post('/analyticUnits/detect', { ids, from, to }); |
|
|
|
return this.post('/analyticUnits/detect', { ids, from, to }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async _analyticRequest(method: string, url: string, data?: any) { |
|
|
|
private async _analyticRequest(method: string, url: string, data?: any, rawError: boolean = false) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
method = method.toUpperCase(); |
|
|
|
method = method.toUpperCase(); |
|
|
|
url = this._hasticDatasourceURL + url; |
|
|
|
url = this._hasticDatasourceURL + url; |
|
|
@ -296,6 +297,9 @@ export class AnalyticService { |
|
|
|
this._isUp = true; |
|
|
|
this._isUp = true; |
|
|
|
return response.data; |
|
|
|
return response.data; |
|
|
|
} catch(error) { |
|
|
|
} catch(error) { |
|
|
|
|
|
|
|
if(rawError) { |
|
|
|
|
|
|
|
throw error; |
|
|
|
|
|
|
|
} |
|
|
|
// xhrStatus may be one of: ('complete', 'error', 'timeout' or 'abort')
|
|
|
|
// xhrStatus may be one of: ('complete', 'error', 'timeout' or 'abort')
|
|
|
|
// See: https://github.com/angular/angular.js/blob/55075b840c9194b8524627a293d6166528b9a1c2/src/ng/http.js#L919-L920
|
|
|
|
// See: https://github.com/angular/angular.js/blob/55075b840c9194b8524627a293d6166528b9a1c2/src/ng/http.js#L919-L920
|
|
|
|
if(error.xhrStatus !== 'complete' || error.status > 500) { |
|
|
|
if(error.xhrStatus !== 'complete' || error.status > 500) { |
|
|
@ -336,20 +340,20 @@ export class AnalyticService { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async get(url, params?) { |
|
|
|
private async get(url: string, params?: any, rawError: boolean = false): Promise<any> { |
|
|
|
return this._analyticRequest('GET', url, params); |
|
|
|
return this._analyticRequest('GET', url, params, rawError); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async post(url, data?) { |
|
|
|
private async post(url: string, data?: any, rawError: boolean = false): Promise<any> { |
|
|
|
return this._analyticRequest('POST', url, data); |
|
|
|
return this._analyticRequest('POST', url, data, rawError); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async patch(url, data?) { |
|
|
|
private async patch(url: string, data?: any, rawError: boolean = false): Promise<any> { |
|
|
|
return this._analyticRequest('PATCH', url, data); |
|
|
|
return this._analyticRequest('PATCH', url, data, rawError); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async delete(url, data?) { |
|
|
|
private async delete(url: string, data?: any, rawError: boolean = false): Promise<any> { |
|
|
|
return this._analyticRequest('DELETE', url, data); |
|
|
|
return this._analyticRequest('DELETE', url, data, rawError); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private _displayNoConnectionAlert(statusText: string): void { |
|
|
|
private _displayNoConnectionAlert(statusText: string): void { |
|
|
|