UI: enabled all delete strategies for multiple deleterion of timeseries
This commit is contained in:
parent
3ab6b0e2b7
commit
8edab0a5cd
@ -39,7 +39,7 @@ import { TranslateService } from '@ngx-translate/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { DialogService } from '@core/services/dialog.service';
|
||||
import { Direction, SortOrder } from '@shared/models/page/sort-order';
|
||||
import { merge, Subject } from 'rxjs';
|
||||
import { forkJoin, merge, Observable, Subject } from 'rxjs';
|
||||
import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators';
|
||||
import { EntityId } from '@shared/models/id/entity-id';
|
||||
import {
|
||||
@ -84,15 +84,11 @@ import {
|
||||
AddWidgetToDashboardDialogComponent,
|
||||
AddWidgetToDashboardDialogData
|
||||
} from '@home/components/attribute/add-widget-to-dashboard-dialog.component';
|
||||
import { deepClone, isUndefinedOrNull } from '@core/utils';
|
||||
import { deepClone } from '@core/utils';
|
||||
import { Filters } from '@shared/models/query/query.models';
|
||||
import { hidePageSizePixelValue } from '@shared/models/constants';
|
||||
import { ResizeObserver } from '@juggle/resize-observer';
|
||||
import {
|
||||
DELETE_TIMESERIES_PANEL_DATA,
|
||||
DeleteTimeseriesPanelComponent,
|
||||
DeleteTimeseriesPanelData
|
||||
} from '@home/components/attribute/delete-timeseries-panel.component';
|
||||
import { DeleteTimeseriesPanelComponent } from '@home/components/attribute/delete-timeseries-panel.component';
|
||||
import { FormBuilder } from '@angular/forms';
|
||||
|
||||
|
||||
@ -392,7 +388,6 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI
|
||||
if ($event) {
|
||||
$event.stopPropagation();
|
||||
}
|
||||
const isMultipleDeletion = isUndefinedOrNull(telemetry) && this.dataSource.selection.selected.length > 1;
|
||||
const target = $event.target || $event.srcElement || $event.currentTarget;
|
||||
const config = new OverlayConfig({
|
||||
panelClass: 'tb-filter-panel',
|
||||
@ -415,12 +410,6 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI
|
||||
});
|
||||
|
||||
const providers: StaticProvider[] = [
|
||||
{
|
||||
provide: DELETE_TIMESERIES_PANEL_DATA,
|
||||
useValue: {
|
||||
isMultipleDeletion
|
||||
} as DeleteTimeseriesPanelData
|
||||
},
|
||||
{
|
||||
provide: OverlayRef,
|
||||
useValue: overlayRef
|
||||
@ -433,6 +422,7 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI
|
||||
if (componentRef.instance.result !== null) {
|
||||
const result = componentRef.instance.result;
|
||||
const deleteTimeseries = telemetry ? [telemetry]: this.dataSource.selection.selected;
|
||||
const tasks: Observable<any>[] = [];
|
||||
let deleteAllDataForKeys = false;
|
||||
let rewriteLatestIfDeleted = false;
|
||||
let startTs = null;
|
||||
@ -448,8 +438,12 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI
|
||||
break;
|
||||
case TimeseriesDeleteStrategy.DELETE_LATEST_VALUE:
|
||||
rewriteLatestIfDeleted = result.rewriteLatest;
|
||||
startTs = deleteTimeseries[0].lastUpdateTs;
|
||||
endTs = startTs + 1;
|
||||
for (const ts of deleteTimeseries) {
|
||||
startTs = ts.lastUpdateTs;
|
||||
endTs = startTs + 1;
|
||||
tasks.push(this.attributeService.deleteEntityTimeseries(this.entityIdValue, [ts],
|
||||
deleteAllDataForKeys, startTs, endTs, rewriteLatestIfDeleted, deleteLatest));
|
||||
}
|
||||
break;
|
||||
case TimeseriesDeleteStrategy.DELETE_ALL_DATA_FOR_TIME_PERIOD:
|
||||
startTs = result.startDateTime.getTime();
|
||||
@ -457,9 +451,13 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI
|
||||
rewriteLatestIfDeleted = result.rewriteLatest;
|
||||
break;
|
||||
}
|
||||
this.attributeService.deleteEntityTimeseries(this.entityIdValue, deleteTimeseries, deleteAllDataForKeys,
|
||||
startTs, endTs, rewriteLatestIfDeleted, deleteLatest)
|
||||
.subscribe(() => this.reloadAttributes());
|
||||
if (tasks.length) {
|
||||
forkJoin(tasks).subscribe(() => this.reloadAttributes());
|
||||
} else {
|
||||
this.attributeService.deleteEntityTimeseries(this.entityIdValue, deleteTimeseries, deleteAllDataForKeys,
|
||||
startTs, endTs, rewriteLatestIfDeleted, deleteLatest)
|
||||
.subscribe(() => this.reloadAttributes());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
/// limitations under the License.
|
||||
///
|
||||
|
||||
import { Component, Inject, InjectionToken, OnDestroy, OnInit } from '@angular/core';
|
||||
import { Component, InjectionToken, OnDestroy, OnInit } from '@angular/core';
|
||||
import { OverlayRef } from '@angular/cdk/overlay';
|
||||
import {
|
||||
TimeseriesDeleteStrategy,
|
||||
@ -27,9 +27,6 @@ import { takeUntil } from 'rxjs/operators';
|
||||
|
||||
export const DELETE_TIMESERIES_PANEL_DATA = new InjectionToken<any>('DeleteTimeseriesPanelData');
|
||||
|
||||
export interface DeleteTimeseriesPanelData {
|
||||
isMultipleDeletion: boolean;
|
||||
}
|
||||
|
||||
export interface DeleteTimeseriesPanelResult {
|
||||
strategy: TimeseriesDeleteStrategy;
|
||||
@ -51,23 +48,13 @@ export class DeleteTimeseriesPanelComponent implements OnInit, OnDestroy {
|
||||
|
||||
strategiesTranslationsMap = timeseriesDeleteStrategyTranslations;
|
||||
|
||||
private multipleDeletionStrategies = new Set<TimeseriesDeleteStrategy>([
|
||||
TimeseriesDeleteStrategy.DELETE_ALL_DATA,
|
||||
TimeseriesDeleteStrategy.DELETE_ALL_DATA_EXCEPT_LATEST_VALUE
|
||||
]);
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
constructor(@Inject(DELETE_TIMESERIES_PANEL_DATA) private data: DeleteTimeseriesPanelData,
|
||||
private overlayRef: OverlayRef,
|
||||
constructor(private overlayRef: OverlayRef,
|
||||
private fb: FormBuilder) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
const today = new Date();
|
||||
if (this.data.isMultipleDeletion) {
|
||||
this.strategiesTranslationsMap = new Map(Array.from(this.strategiesTranslationsMap)
|
||||
.filter(([strategy]) => this.multipleDeletionStrategies.has(strategy)))
|
||||
}
|
||||
this.deleteTimeseriesFormGroup = this.fb.group({
|
||||
strategy: [TimeseriesDeleteStrategy.DELETE_ALL_DATA],
|
||||
startDateTime: [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user