From 78235deb7db3ee76be5551ebf0fda676147f9f21 Mon Sep 17 00:00:00 2001 From: Ruslan Vasylkiv <87172504+rusikv@users.noreply.github.com> Date: Mon, 17 Jul 2023 23:46:06 +0300 Subject: [PATCH] Removed deleteEntityLatestTimeseries, edited strategies names (#8948) * added rewrite param to delete latest timeseries, enabled single selection deletion * Removed deleteEntityLatestTimeseries, edited strategies names --- ui-ngx/src/app/core/http/attribute.service.ts | 8 ------- .../attribute/attribute-table.component.ts | 21 ++++++++----------- .../delete-timeseries-panel.component.html | 2 +- .../delete-timeseries-panel.component.ts | 8 +++---- .../models/telemetry/telemetry.models.ts | 12 +++++------ .../assets/locale/locale.constant-en_US.json | 8 +++---- 6 files changed, 24 insertions(+), 35 deletions(-) diff --git a/ui-ngx/src/app/core/http/attribute.service.ts b/ui-ngx/src/app/core/http/attribute.service.ts index f568758f41..c810a0af22 100644 --- a/ui-ngx/src/app/core/http/attribute.service.ts +++ b/ui-ngx/src/app/core/http/attribute.service.ts @@ -64,14 +64,6 @@ export class AttributeService { return this.http.delete(url, defaultHttpOptionsFromConfig(config)); } - public deleteEntityLatestTimeseries(entityId: EntityId, timeseries: Array, rewrite = true, - config?: RequestConfig): Observable { - const keys = timeseries.map(attribute => encodeURIComponent(attribute.key)).join(','); - let url = `/api/plugins/telemetry/${entityId.entityType}/${entityId.id}/timeseries/latest/delete?keys=${keys}` + - `&rewrite=${rewrite}`; - return this.http.delete(url, defaultHttpOptionsFromConfig(config)); - } - public saveEntityAttributes(entityId: EntityId, attributeScope: AttributeScope, attributes: Array, config?: RequestConfig): Observable { const attributesData: {[key: string]: any} = {}; diff --git a/ui-ngx/src/app/modules/home/components/attribute/attribute-table.component.ts b/ui-ngx/src/app/modules/home/components/attribute/attribute-table.component.ts index 2969feea76..245411f2f9 100644 --- a/ui-ngx/src/app/modules/home/components/attribute/attribute-table.component.ts +++ b/ui-ngx/src/app/modules/home/components/attribute/attribute-table.component.ts @@ -386,7 +386,7 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI if ($event) { $event.stopPropagation(); } - const isMultipleDeletion = isUndefinedOrNull(attribute) && this.dataSource.selection.selected.length > 1; + const isMultipleDeletion = isUndefinedOrNull(attribute) && this.dataSource.selection.selected.length > 1; const target = $event.target || $event.srcElement || $event.currentTarget; const config = new OverlayConfig(); config.backdropClass = 'cdk-overlay-transparent-backdrop'; @@ -424,34 +424,31 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI componentRef.onDestroy(() => { if (componentRef.instance.result !== null) { const strategy = componentRef.instance.result; - const timeseries = attribute ? [attribute]: this.dataSource.selection.selected; + const deleteTimeseries = attribute ? [attribute]: this.dataSource.selection.selected; let deleteAllDataForKeys = false; let rewriteLatestIfDeleted = false; let startTs = null; let endTs = null; let deleteLatest = true; - let task: Observable; - if (strategy === TimeseriesDeleteStrategy.DELETE_ALL_DATA_INCLUDING_KEY) { + if (strategy === TimeseriesDeleteStrategy.DELETE_ALL_DATA) { deleteAllDataForKeys = true; } - if (strategy === TimeseriesDeleteStrategy.DELETE_OLD_DATA_EXCEPT_LATEST_VALUE) { + if (strategy === TimeseriesDeleteStrategy.DELETE_ALL_DATA_EXCEPT_LATEST_VALUE) { deleteAllDataForKeys = true; deleteLatest = false; } if (strategy === TimeseriesDeleteStrategy.DELETE_LATEST_VALUE) { rewriteLatestIfDeleted = componentRef.instance.rewriteLatestIfDeleted; - task = this.attributeService.deleteEntityLatestTimeseries(this.entityIdValue, timeseries, rewriteLatestIfDeleted); + startTs = deleteTimeseries[0].lastUpdateTs; + endTs = startTs + 1; } - if (strategy === TimeseriesDeleteStrategy.DELETE_DATA_FOR_TIME_PERIOD) { + if (strategy === TimeseriesDeleteStrategy.DELETE_ALL_DATA_FOR_TIME_PERIOD) { startTs = componentRef.instance.startDateTime.getTime(); endTs = componentRef.instance.endDateTime.getTime(); rewriteLatestIfDeleted = componentRef.instance.rewriteLatestIfDeleted; } - if (!task) { - task = this.attributeService.deleteEntityTimeseries(this.entityIdValue, timeseries, deleteAllDataForKeys, - startTs, endTs, rewriteLatestIfDeleted, deleteLatest); - } - task.subscribe(() => this.reloadAttributes()); + this.attributeService.deleteEntityTimeseries(this.entityIdValue, deleteTimeseries, deleteAllDataForKeys, + startTs, endTs, rewriteLatestIfDeleted, deleteLatest).subscribe(() => this.reloadAttributes()); } }); } diff --git a/ui-ngx/src/app/modules/home/components/attribute/delete-timeseries-panel.component.html b/ui-ngx/src/app/modules/home/components/attribute/delete-timeseries-panel.component.html index 0bd9ac21ef..a49f89a6cc 100644 --- a/ui-ngx/src/app/modules/home/components/attribute/delete-timeseries-panel.component.html +++ b/ui-ngx/src/app/modules/home/components/attribute/delete-timeseries-panel.component.html @@ -55,7 +55,7 @@
- {{ "attribute.delete-timeseries.rewrite-latest-value-if-deleted" | translate }} + {{ "attribute.delete-timeseries.rewrite-latest-value" | translate }}
diff --git a/ui-ngx/src/app/modules/home/components/attribute/delete-timeseries-panel.component.ts b/ui-ngx/src/app/modules/home/components/attribute/delete-timeseries-panel.component.ts index 2bf6b44859..364ecd2c9a 100644 --- a/ui-ngx/src/app/modules/home/components/attribute/delete-timeseries-panel.component.ts +++ b/ui-ngx/src/app/modules/home/components/attribute/delete-timeseries-panel.component.ts @@ -35,7 +35,7 @@ export interface DeleteTimeseriesPanelData { }) export class DeleteTimeseriesPanelComponent implements OnInit { - strategy: string = TimeseriesDeleteStrategy.DELETE_ALL_DATA_INCLUDING_KEY; + strategy: string = TimeseriesDeleteStrategy.DELETE_ALL_DATA; result: string = null; @@ -48,8 +48,8 @@ export class DeleteTimeseriesPanelComponent implements OnInit { strategiesTranslationsMap = timeseriesDeleteStrategyTranslations; multipleDeletionStrategies = [ - TimeseriesDeleteStrategy.DELETE_ALL_DATA_INCLUDING_KEY, - TimeseriesDeleteStrategy.DELETE_OLD_DATA_EXCEPT_LATEST_VALUE + TimeseriesDeleteStrategy.DELETE_ALL_DATA, + TimeseriesDeleteStrategy.DELETE_ALL_DATA_EXCEPT_LATEST_VALUE ]; constructor(@Inject(DELETE_TIMESERIES_PANEL_DATA) public data: DeleteTimeseriesPanelData, @@ -77,7 +77,7 @@ export class DeleteTimeseriesPanelComponent implements OnInit { } isPeriodStrategy(): boolean { - return this.strategy === TimeseriesDeleteStrategy.DELETE_DATA_FOR_TIME_PERIOD; + return this.strategy === TimeseriesDeleteStrategy.DELETE_ALL_DATA_FOR_TIME_PERIOD; } isDeleteLatestStrategy(): boolean { diff --git a/ui-ngx/src/app/shared/models/telemetry/telemetry.models.ts b/ui-ngx/src/app/shared/models/telemetry/telemetry.models.ts index 76f6b0f247..d93dde4530 100644 --- a/ui-ngx/src/app/shared/models/telemetry/telemetry.models.ts +++ b/ui-ngx/src/app/shared/models/telemetry/telemetry.models.ts @@ -62,10 +62,10 @@ export enum TelemetryFeature { } export enum TimeseriesDeleteStrategy { - DELETE_ALL_DATA_INCLUDING_KEY = 'DELETE_ALL_DATA_INCLUDING_KEY', - DELETE_OLD_DATA_EXCEPT_LATEST_VALUE = 'DELETE_OLD_DATA_EXCEPT_LATEST_VALUE', + DELETE_ALL_DATA = 'DELETE_ALL_DATA', + DELETE_ALL_DATA_EXCEPT_LATEST_VALUE = 'DELETE_ALL_DATA_EXCEPT_LATEST_VALUE', DELETE_LATEST_VALUE = 'DELETE_LATEST_VALUE', - DELETE_DATA_FOR_TIME_PERIOD = 'DELETE_DATA_FOR_TIME_PERIOD' + DELETE_ALL_DATA_FOR_TIME_PERIOD = 'DELETE_ALL_DATA_FOR_TIME_PERIOD' } export type TelemetryType = LatestTelemetry | AttributeScope; @@ -98,10 +98,10 @@ export const isClientSideTelemetryType = new Map( export const timeseriesDeleteStrategyTranslations = new Map( [ - [TimeseriesDeleteStrategy.DELETE_ALL_DATA_INCLUDING_KEY, 'attribute.delete-timeseries.all-data-including-key'], - [TimeseriesDeleteStrategy.DELETE_OLD_DATA_EXCEPT_LATEST_VALUE, 'attribute.delete-timeseries.old-data-except-latest'], + [TimeseriesDeleteStrategy.DELETE_ALL_DATA, 'attribute.delete-timeseries.all-data'], + [TimeseriesDeleteStrategy.DELETE_ALL_DATA_EXCEPT_LATEST_VALUE, 'attribute.delete-timeseries.all-data-except-latest-value'], [TimeseriesDeleteStrategy.DELETE_LATEST_VALUE, 'attribute.delete-timeseries.latest-value'], - [TimeseriesDeleteStrategy.DELETE_DATA_FOR_TIME_PERIOD, 'attribute.delete-timeseries.data-for-time-period'] + [TimeseriesDeleteStrategy.DELETE_ALL_DATA_FOR_TIME_PERIOD, 'attribute.delete-timeseries.all-data-for-time-period'] ] ) diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 091ee1e3bf..190a47788c 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -723,11 +723,11 @@ "ends-on": "Ends on", "strategy": "Strategy", "delete-strategy": "Delete strategy", - "all-data-including-key": "Delete all data including key", - "old-data-except-latest": "Delete old data except latest value", + "all-data": "Delete all data", + "all-data-except-latest-value": "Delete all data except latest value", "latest-value": "Delete latest value", - "data-for-time-period": "Delete data for time period", - "rewrite-latest-value-if-deleted": "Rewrite latest value if deleted" + "all-data-for-time-period": "Delete all data for time period", + "rewrite-latest-value": "Rewrite latest value" } }, "api-usage": {