|
|
|
@ -888,12 +888,22 @@ 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.status === AlarmStatus.CLEARED_UNACK || |
|
|
|
alarm.status === AlarmStatus.ACTIVE_UNACK) |
|
|
|
); |
|
|
|
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 +911,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 +952,22 @@ 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.status === AlarmStatus.ACTIVE_ACK || |
|
|
|
alarm.status === AlarmStatus.ACTIVE_UNACK) |
|
|
|
); |
|
|
|
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 +975,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 +1140,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 +1219,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 +1293,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 +1321,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); |
|
|
|
|