From b8a3b8ae14c944542297d009acce65f704baf7f7 Mon Sep 17 00:00:00 2001 From: Kalutka Zhenya Date: Tue, 3 Aug 2021 17:00:23 +0300 Subject: [PATCH 1/2] Fixed startTs, endTs in deleteEntityTimeseries --- ui-ngx/src/app/core/http/attribute.service.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ui-ngx/src/app/core/http/attribute.service.ts b/ui-ngx/src/app/core/http/attribute.service.ts index 1bed864ab1..f68835121a 100644 --- a/ui-ngx/src/app/core/http/attribute.service.ts +++ b/ui-ngx/src/app/core/http/attribute.service.ts @@ -50,11 +50,17 @@ export class AttributeService { } public deleteEntityTimeseries(entityId: EntityId, timeseries: Array, deleteAllDataForKeys = false, - config?: RequestConfig): Observable { + startTs?: number, endTs?: number, config?: RequestConfig): Observable { const keys = timeseries.map(attribute => encodeURI(attribute.key)).join(','); - return this.http.delete(`/api/plugins/telemetry/${entityId.entityType}/${entityId.id}/timeseries/delete` + - `?keys=${keys}&deleteAllDataForKeys=${deleteAllDataForKeys}`, - defaultHttpOptionsFromConfig(config)); + let url = `/api/plugins/telemetry/${entityId.entityType}/${entityId.id}/timeseries/delete` + + `?keys=${keys}&deleteAllDataForKeys=${deleteAllDataForKeys}`; + if (startTs) { + url += `&startTs=${startTs}`; + } + if (endTs) { + url += `&endTs=${endTs}`; + } + return this.http.delete(url, defaultHttpOptionsFromConfig(config)); } public saveEntityAttributes(entityId: EntityId, attributeScope: AttributeScope, attributes: Array, @@ -97,7 +103,7 @@ export class AttributeService { }); let deleteEntityTimeseriesObservable: Observable; if (deleteTimeseries.length) { - deleteEntityTimeseriesObservable = this.deleteEntityTimeseries(entityId, deleteTimeseries, true, config); + deleteEntityTimeseriesObservable = this.deleteEntityTimeseries(entityId, deleteTimeseries, true, null, null, config); } else { deleteEntityTimeseriesObservable = of(null); } From 82bdb6acf158863c928762da1c62feb56b11a700 Mon Sep 17 00:00:00 2001 From: Kalutka Zhenya Date: Wed, 4 Aug 2021 10:46:24 +0300 Subject: [PATCH 2/2] Refactoring --- ui-ngx/src/app/core/http/attribute.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/core/http/attribute.service.ts b/ui-ngx/src/app/core/http/attribute.service.ts index f68835121a..df7941cef3 100644 --- a/ui-ngx/src/app/core/http/attribute.service.ts +++ b/ui-ngx/src/app/core/http/attribute.service.ts @@ -54,10 +54,10 @@ export class AttributeService { const keys = timeseries.map(attribute => encodeURI(attribute.key)).join(','); let url = `/api/plugins/telemetry/${entityId.entityType}/${entityId.id}/timeseries/delete` + `?keys=${keys}&deleteAllDataForKeys=${deleteAllDataForKeys}`; - if (startTs) { + if (isDefinedAndNotNull(startTs)) { url += `&startTs=${startTs}`; } - if (endTs) { + if (isDefinedAndNotNull(endTs)) { url += `&endTs=${endTs}`; } return this.http.delete(url, defaultHttpOptionsFromConfig(config));