|
|
|
@ -503,17 +503,16 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, |
|
|
|
$event.stopPropagation(); |
|
|
|
} |
|
|
|
const target = $event.target || $event.srcElement || $event.currentTarget; |
|
|
|
const config = new OverlayConfig(); |
|
|
|
config.backdropClass = 'cdk-overlay-transparent-backdrop'; |
|
|
|
config.hasBackdrop = true; |
|
|
|
const connectedPosition: ConnectedPosition = { |
|
|
|
originX: 'end', |
|
|
|
originY: 'bottom', |
|
|
|
overlayX: 'end', |
|
|
|
overlayY: 'top' |
|
|
|
}; |
|
|
|
config.positionStrategy = this.overlay.position().flexibleConnectedTo(target as HTMLElement) |
|
|
|
.withPositions([connectedPosition]); |
|
|
|
const config = new OverlayConfig({ |
|
|
|
panelClass: 'tb-panel-container', |
|
|
|
backdropClass: 'cdk-overlay-transparent-backdrop', |
|
|
|
hasBackdrop: true, |
|
|
|
height: 'fit-content', |
|
|
|
maxHeight: '75vh' |
|
|
|
}); |
|
|
|
config.positionStrategy = this.overlay.position() |
|
|
|
.flexibleConnectedTo(target as HTMLElement) |
|
|
|
.withPositions(DEFAULT_OVERLAY_POSITIONS); |
|
|
|
|
|
|
|
const overlayRef = this.overlay.create(config); |
|
|
|
overlayRef.backdropClick().subscribe(() => { |
|
|
|
@ -549,9 +548,18 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, |
|
|
|
useValue: overlayRef |
|
|
|
} |
|
|
|
]; |
|
|
|
|
|
|
|
const injector = Injector.create({parent: this.viewContainerRef.injector, providers}); |
|
|
|
overlayRef.attach(new ComponentPortal(DisplayColumnsPanelComponent, |
|
|
|
const componentRef = overlayRef.attach(new ComponentPortal(DisplayColumnsPanelComponent, |
|
|
|
this.viewContainerRef, injector)); |
|
|
|
|
|
|
|
const resizeWindows$ = fromEvent(window, 'resize').subscribe(() => { |
|
|
|
overlayRef.updatePosition(); |
|
|
|
}); |
|
|
|
componentRef.onDestroy(() => { |
|
|
|
resizeWindows$.unsubscribe(); |
|
|
|
}); |
|
|
|
|
|
|
|
this.ctx.detectChanges(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -888,12 +896,21 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, |
|
|
|
$event.stopPropagation(); |
|
|
|
} |
|
|
|
if (this.alarmsDatasource.selection.hasValue()) { |
|
|
|
const alarmIds = this.alarmsDatasource.selection.selected.filter( |
|
|
|
(alarmId) => alarmId !== NULL_UUID |
|
|
|
const unacknowledgedAlarms = this.alarmsDatasource.selection.selected.filter( |
|
|
|
alarm => alarm.id.id !== NULL_UUID && !alarm.acknowledged |
|
|
|
); |
|
|
|
if (alarmIds.length) { |
|
|
|
const title = this.translate.instant('alarm.aknowledge-alarms-title', {count: alarmIds.length}); |
|
|
|
const content = this.translate.instant('alarm.aknowledge-alarms-text', {count: alarmIds.length}); |
|
|
|
let title = ''; |
|
|
|
let content = ''; |
|
|
|
if (!unacknowledgedAlarms.length) { |
|
|
|
title = this.translate.instant('alarm.selected-alarms', {count: unacknowledgedAlarms.length}); |
|
|
|
content = this.translate.instant('alarm.selected-alarms-are-acknowledged'); |
|
|
|
this.dialogService.alert( |
|
|
|
title, |
|
|
|
content |
|
|
|
).subscribe(); |
|
|
|
} else { |
|
|
|
title = this.translate.instant('alarm.aknowledge-alarms-title', {count: unacknowledgedAlarms.length}); |
|
|
|
content = this.translate.instant('alarm.aknowledge-alarms-text', {count: unacknowledgedAlarms.length}); |
|
|
|
this.dialogService.confirm( |
|
|
|
title, |
|
|
|
content, |
|
|
|
@ -901,16 +918,14 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, |
|
|
|
this.translate.instant('action.yes') |
|
|
|
).subscribe((res) => { |
|
|
|
if (res) { |
|
|
|
if (res) { |
|
|
|
const tasks: Observable<AlarmInfo>[] = []; |
|
|
|
for (const alarmId of alarmIds) { |
|
|
|
tasks.push(this.alarmService.ackAlarm(alarmId)); |
|
|
|
} |
|
|
|
forkJoin(tasks).subscribe(() => { |
|
|
|
this.alarmsDatasource.clearSelection(); |
|
|
|
this.subscription.update(); |
|
|
|
}); |
|
|
|
const tasks: Observable<AlarmInfo>[] = []; |
|
|
|
for (const alarm of unacknowledgedAlarms) { |
|
|
|
tasks.push(this.alarmService.ackAlarm(alarm.id.id)); |
|
|
|
} |
|
|
|
forkJoin(tasks).subscribe(() => { |
|
|
|
this.alarmsDatasource.clearSelection(); |
|
|
|
this.subscription.update(); |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
@ -944,12 +959,21 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, |
|
|
|
$event.stopPropagation(); |
|
|
|
} |
|
|
|
if (this.alarmsDatasource.selection.hasValue()) { |
|
|
|
const alarmIds = this.alarmsDatasource.selection.selected.filter( |
|
|
|
(alarmId) => alarmId !== NULL_UUID |
|
|
|
const activeAlarms = this.alarmsDatasource.selection.selected.filter( |
|
|
|
alarm => alarm.id.id !== NULL_UUID && !alarm.cleared |
|
|
|
); |
|
|
|
if (alarmIds.length) { |
|
|
|
const title = this.translate.instant('alarm.clear-alarms-title', {count: alarmIds.length}); |
|
|
|
const content = this.translate.instant('alarm.clear-alarms-text', {count: alarmIds.length}); |
|
|
|
let title = ''; |
|
|
|
let content = ''; |
|
|
|
if (!activeAlarms.length) { |
|
|
|
title = this.translate.instant('alarm.selected-alarms', {count: activeAlarms.length}); |
|
|
|
content = this.translate.instant('alarm.selected-alarms-are-cleared'); |
|
|
|
this.dialogService.alert( |
|
|
|
title, |
|
|
|
content |
|
|
|
).subscribe(); |
|
|
|
} else { |
|
|
|
title = this.translate.instant('alarm.clear-alarms-title', {count: activeAlarms.length}); |
|
|
|
content = this.translate.instant('alarm.clear-alarms-text', {count: activeAlarms.length}); |
|
|
|
this.dialogService.confirm( |
|
|
|
title, |
|
|
|
content, |
|
|
|
@ -957,16 +981,14 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, |
|
|
|
this.translate.instant('action.yes') |
|
|
|
).subscribe((res) => { |
|
|
|
if (res) { |
|
|
|
if (res) { |
|
|
|
const tasks: Observable<AlarmInfo>[] = []; |
|
|
|
for (const alarmId of alarmIds) { |
|
|
|
tasks.push(this.alarmService.clearAlarm(alarmId)); |
|
|
|
} |
|
|
|
forkJoin(tasks).subscribe(() => { |
|
|
|
this.alarmsDatasource.clearSelection(); |
|
|
|
this.subscription.update(); |
|
|
|
}); |
|
|
|
const tasks: Observable<AlarmInfo>[] = []; |
|
|
|
for (const alarm of activeAlarms) { |
|
|
|
tasks.push(this.alarmService.clearAlarm(alarm.id.id)); |
|
|
|
} |
|
|
|
forkJoin(tasks).subscribe(() => { |
|
|
|
this.alarmsDatasource.clearSelection(); |
|
|
|
this.subscription.update(); |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
@ -1124,7 +1146,8 @@ class AlarmsDatasource implements DataSource<AlarmDataInfo> { |
|
|
|
private alarmsSubject = new BehaviorSubject<AlarmDataInfo[]>([]); |
|
|
|
private pageDataSubject = new BehaviorSubject<PageData<AlarmDataInfo>>(emptyPageData<AlarmDataInfo>()); |
|
|
|
|
|
|
|
public selection = new SelectionModel<string>(true, [], false); |
|
|
|
public selection = new SelectionModel<AlarmDataInfo>(true, [], false, |
|
|
|
(alarm1: AlarmDataInfo, alarm2: AlarmDataInfo) => alarm1.id.id === alarm2.id.id); |
|
|
|
|
|
|
|
private selectionModeChanged = new EventEmitter<boolean>(); |
|
|
|
|
|
|
|
@ -1202,7 +1225,7 @@ class AlarmsDatasource implements DataSource<AlarmDataInfo> { |
|
|
|
} |
|
|
|
if (this.selection.hasValue()) { |
|
|
|
const alarmIds = alarms.map((alarm) => alarm.id.id); |
|
|
|
const toRemove = this.selection.selected.filter(alarmId => alarmIds.indexOf(alarmId) === -1); |
|
|
|
const toRemove = this.selection.selected.filter(alarm => alarmIds.indexOf(alarm.id.id) === -1); |
|
|
|
this.selection.deselect(...toRemove); |
|
|
|
if (this.selection.isEmpty()) { |
|
|
|
isEmptySelection = true; |
|
|
|
@ -1276,14 +1299,14 @@ class AlarmsDatasource implements DataSource<AlarmDataInfo> { |
|
|
|
|
|
|
|
toggleSelection(alarm: AlarmDataInfo) { |
|
|
|
const hasValue = this.selection.hasValue(); |
|
|
|
this.selection.toggle(alarm.id.id); |
|
|
|
this.selection.toggle(alarm); |
|
|
|
if (hasValue !== this.selection.hasValue()) { |
|
|
|
this.onSelectionModeChanged(this.selection.hasValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
isSelected(alarm: AlarmDataInfo): boolean { |
|
|
|
return this.selection.isSelected(alarm.id.id); |
|
|
|
return this.selection.isSelected(alarm); |
|
|
|
} |
|
|
|
|
|
|
|
clearSelection() { |
|
|
|
@ -1304,7 +1327,7 @@ class AlarmsDatasource implements DataSource<AlarmDataInfo> { |
|
|
|
} |
|
|
|
} else { |
|
|
|
alarms.forEach(row => { |
|
|
|
this.selection.select(row.id.id); |
|
|
|
this.selection.select(row); |
|
|
|
}); |
|
|
|
if (numSelected === 0) { |
|
|
|
this.onSelectionModeChanged(true); |
|
|
|
|