Browse Source

Removed deleteEntityLatestTimeseries, edited strategies names (#8948)

* added rewrite param to delete latest timeseries, enabled single selection deletion

* Removed deleteEntityLatestTimeseries, edited strategies names
pull/9020/head
Ruslan Vasylkiv 3 years ago
committed by GitHub
parent
commit
78235deb7d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      ui-ngx/src/app/core/http/attribute.service.ts
  2. 21
      ui-ngx/src/app/modules/home/components/attribute/attribute-table.component.ts
  3. 2
      ui-ngx/src/app/modules/home/components/attribute/delete-timeseries-panel.component.html
  4. 8
      ui-ngx/src/app/modules/home/components/attribute/delete-timeseries-panel.component.ts
  5. 12
      ui-ngx/src/app/shared/models/telemetry/telemetry.models.ts
  6. 8
      ui-ngx/src/assets/locale/locale.constant-en_US.json

8
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<AttributeData>, rewrite = true,
config?: RequestConfig): Observable<any> {
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<AttributeData>,
config?: RequestConfig): Observable<any> {
const attributesData: {[key: string]: any} = {};

21
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<any>;
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());
}
});
}

2
ui-ngx/src/app/modules/home/components/attribute/delete-timeseries-panel.component.html

@ -55,7 +55,7 @@
</div>
<div *ngIf="isPeriodStrategy() || isDeleteLatestStrategy()">
<mat-slide-toggle [(ngModel)]="rewriteLatestIfDeleted">
{{ "attribute.delete-timeseries.rewrite-latest-value-if-deleted" | translate }}
{{ "attribute.delete-timeseries.rewrite-latest-value" | translate }}
</mat-slide-toggle>
</div>
</div>

8
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 {

12
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<TelemetryType, boolean>(
export const timeseriesDeleteStrategyTranslations = new Map<TimeseriesDeleteStrategy, string>(
[
[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']
]
)

8
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": {

Loading…
Cancel
Save