@flexem/fc-gui 3.0.0-alpha.66 → 3.0.0-alpha.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,6 +8,7 @@ import { find, isNil, pull, remove } from 'lodash';
|
|
|
8
8
|
import { AlarmState } from './alarm-state-enum';
|
|
9
9
|
export class AlarmElement extends ConditionalDisplayElement {
|
|
10
10
|
constructor(element, injector, permissionChecker, variableCommunicator, variableStore, alarmsStore, signalRAppId) {
|
|
11
|
+
var _a, _b;
|
|
11
12
|
super(element, permissionChecker, variableCommunicator, variableStore, signalRAppId);
|
|
12
13
|
this.alarmsStore = alarmsStore;
|
|
13
14
|
this.displayOption = {
|
|
@@ -28,58 +29,66 @@ export class AlarmElement extends ConditionalDisplayElement {
|
|
|
28
29
|
this.page = 0;
|
|
29
30
|
this.totalCount = 0;
|
|
30
31
|
this.pageSize = 5;
|
|
32
|
+
this.rootElement.selectAll('*').remove();
|
|
31
33
|
this.logger = injector.get(LOGGER_SERVICE_TOKEN);
|
|
32
34
|
this.localization = injector.get(LOCALIZATION);
|
|
33
35
|
this.variableCommunicator = variableCommunicator;
|
|
34
36
|
this.timePeriods = this.getValidTimePeriods();
|
|
35
|
-
this.currentTimePeriod = this.model.filterSetting.refreshCycle;
|
|
36
37
|
this.pageSize = this.model.generalSetting.pageSize;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.
|
|
41
|
-
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const alarm = alarmWithAppId.alarm;
|
|
51
|
-
if (!find(this.model.filterSetting.detailsData, alarmName => alarmName === alarm.name)) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const currentAlarm = this.currentAlarmList.find(re => re.name === alarm.name);
|
|
55
|
-
if (alarm.state === AlarmState.AlarmStateTriggered.valueOf()) {
|
|
56
|
-
if (!isNil(currentAlarm)) {
|
|
38
|
+
if (this.model.filterSetting) {
|
|
39
|
+
this.currentTimePeriod = (_a = this.model.filterSetting) === null || _a === void 0 ? void 0 : _a.refreshCycle;
|
|
40
|
+
this.currentTimePeriod = (_b = this.model.filterSetting) === null || _b === void 0 ? void 0 : _b.displayPeriod;
|
|
41
|
+
this.updateQueryTimeRange();
|
|
42
|
+
if (this.model.filterSetting.alarmType) {
|
|
43
|
+
this.refreshIntervalId = setInterval(() => {
|
|
44
|
+
this.loadFirstPage();
|
|
45
|
+
this.logger.debug(`[GUI]Refresh Alarm Table:${d3.time.format('%x %X')(new Date())}`);
|
|
46
|
+
}, this.model.filterSetting.refreshCycle * 60 * 1000);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
variableCommunicator.subscribeUserDeviceAlarms(signalRAppId).subscribe(alarmWithAppId => {
|
|
50
|
+
if (alarmWithAppId.appId !== this.signalRAppId) {
|
|
57
51
|
return;
|
|
58
52
|
}
|
|
59
|
-
|
|
60
|
-
this.
|
|
61
|
-
this.totalCount += 1;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
if (isNil(currentAlarm)) {
|
|
53
|
+
const alarm = alarmWithAppId.alarm;
|
|
54
|
+
if (!find(this.model.filterSetting.detailsData, alarmName => alarmName === alarm.name)) {
|
|
65
55
|
return;
|
|
66
56
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
57
|
+
const currentAlarm = this.currentAlarmList.find(re => re.name === alarm.name);
|
|
58
|
+
if (alarm.state === AlarmState.AlarmStateTriggered.valueOf()) {
|
|
59
|
+
if (!isNil(currentAlarm)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
pull(this.currentAlarmList, this.currentAlarmList.find(record => alarm.name === record.name));
|
|
63
|
+
this.currentAlarmList.unshift(alarm);
|
|
64
|
+
this.totalCount += 1;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
if (isNil(currentAlarm)) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
remove(this.currentAlarmList, currentAlarm);
|
|
71
|
+
this.totalCount -= 1;
|
|
72
|
+
}
|
|
73
|
+
this.alarmList = [];
|
|
74
|
+
this.currentAlarmList.forEach(item => {
|
|
75
|
+
this.alarmList.push([
|
|
76
|
+
item.name,
|
|
77
|
+
item.message,
|
|
78
|
+
item.alarmLevel,
|
|
79
|
+
moment(item.triggeredTime).format('YYYY-MM-DD HH:mm:ss')
|
|
80
|
+
]);
|
|
81
|
+
});
|
|
82
|
+
this.renderElement();
|
|
78
83
|
});
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
}
|
|
85
|
+
this.init();
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
this.totalCount = 0;
|
|
89
|
+
this.alarmList = [];
|
|
90
|
+
this.renderElement();
|
|
81
91
|
}
|
|
82
|
-
this.init();
|
|
83
92
|
}
|
|
84
93
|
dispose() {
|
|
85
94
|
clearInterval(this.refreshIntervalId);
|
|
@@ -103,37 +112,41 @@ export class AlarmElement extends ConditionalDisplayElement {
|
|
|
103
112
|
if (this.model.filterSetting.alarmType) {
|
|
104
113
|
const input = new GetAlarmsArgs(this.model.filterSetting.detailsData, this.startTime, this.endTime, this.pageSize, this.page * this.pageSize);
|
|
105
114
|
this.alarmsStore.getHistoryAlarms(input).subscribe(result => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
item
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
if (!result.error) {
|
|
116
|
+
this.totalCount = result.totalCount;
|
|
117
|
+
this.alarmList = result.items.map(item => [
|
|
118
|
+
item.name,
|
|
119
|
+
item.message,
|
|
120
|
+
item.alarmLevel,
|
|
121
|
+
item.triggeredTime.format('YYYY-MM-DD HH:mm:ss')
|
|
122
|
+
]);
|
|
123
|
+
this.renderElement();
|
|
124
|
+
}
|
|
114
125
|
});
|
|
115
126
|
}
|
|
116
127
|
else {
|
|
117
128
|
const input = new GetAlarmsArgs(this.model.filterSetting.detailsData, undefined, undefined, this.pageSize, this.page * this.pageSize);
|
|
118
129
|
this.alarmsStore.getCurrentAlarms(input).subscribe(result => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
item
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
130
|
+
if (!result.error) {
|
|
131
|
+
this.totalCount = result.totalCount;
|
|
132
|
+
this.currentAlarmList = result.items;
|
|
133
|
+
this.alarmList = this.currentAlarmList.map(item => [
|
|
134
|
+
item.name,
|
|
135
|
+
item.message,
|
|
136
|
+
item.alarmLevel,
|
|
137
|
+
item.triggeredTime.format('YYYY-MM-DD HH:mm:ss')
|
|
138
|
+
]);
|
|
139
|
+
this.renderElement();
|
|
140
|
+
}
|
|
128
141
|
});
|
|
129
142
|
}
|
|
130
143
|
}
|
|
131
144
|
renderElement() {
|
|
132
|
-
this.rootElement.selectAll('*').remove();
|
|
133
145
|
const elementHeight = this.model.size.height;
|
|
134
146
|
this.element = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject');
|
|
135
147
|
this.element.setAttribute('width', this.model.size.width.toString());
|
|
136
148
|
this.element.setAttribute('height', elementHeight.toString());
|
|
149
|
+
this.$element.append(this.element);
|
|
137
150
|
const table = document.createElement('table');
|
|
138
151
|
table.style.cssText = `border: 2px solid ${this.model.generalSetting.stroke};
|
|
139
152
|
height: ${elementHeight - 39}`;
|
|
@@ -215,14 +228,14 @@ export class AlarmElement extends ConditionalDisplayElement {
|
|
|
215
228
|
table.appendChild(tr);
|
|
216
229
|
}
|
|
217
230
|
this.element.appendChild(table);
|
|
218
|
-
this.$element.append(this.element);
|
|
219
231
|
this.renderOperationArea(this.model.size.width, elementHeight - 39);
|
|
220
232
|
}
|
|
221
233
|
renderOperationArea(chartWidth, chartHeight) {
|
|
234
|
+
var _a;
|
|
222
235
|
const operationArea = this.rootElement.append('g').attr('transform', `translate(0,${chartHeight + this.displayOption.operationAreaMarginTop})`)
|
|
223
236
|
.append('foreignObject').attr('width', chartWidth).attr('height', this.displayOption.operationAreaHeight).attr('fill', 'none')
|
|
224
237
|
.append('xhtml:div').style('height', (this.displayOption.operationAreaHeight - 4) + 'px').style('overflow', 'hidden').style('margin-top', '4px');
|
|
225
|
-
if (this.model.filterSetting.alarmType) {
|
|
238
|
+
if ((_a = this.model.filterSetting) === null || _a === void 0 ? void 0 : _a.alarmType) {
|
|
226
239
|
const selectElement = operationArea.append('select').style('margin-left', this.displayOption.marginLeft + 'px')
|
|
227
240
|
.style('font-size', this.displayOption.operationSelectFontSize).on('change', () => {
|
|
228
241
|
const displayTimePeriod = this.rootElement.select('select').property('value');
|
|
@@ -283,7 +296,9 @@ export class AlarmElement extends ConditionalDisplayElement {
|
|
|
283
296
|
this.init();
|
|
284
297
|
}
|
|
285
298
|
loadNextPage() {
|
|
286
|
-
|
|
299
|
+
let last_page = Math.ceil(this.totalCount / this.pageSize);
|
|
300
|
+
if (last_page)
|
|
301
|
+
last_page--;
|
|
287
302
|
if (this.page < last_page) {
|
|
288
303
|
this.page++;
|
|
289
304
|
}
|
|
@@ -296,7 +311,10 @@ export class AlarmElement extends ConditionalDisplayElement {
|
|
|
296
311
|
this.init();
|
|
297
312
|
}
|
|
298
313
|
loadLastPage() {
|
|
299
|
-
|
|
314
|
+
let last_page = Math.ceil(this.totalCount / this.pageSize);
|
|
315
|
+
if (last_page)
|
|
316
|
+
last_page--;
|
|
317
|
+
this.page = last_page;
|
|
300
318
|
this.init();
|
|
301
319
|
}
|
|
302
320
|
}
|