@flexem/fc-gui 3.0.0-alpha.61 → 3.0.0-alpha.62
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.
- package/CHANGELOG.md +6 -1
- package/bundles/@flexem/fc-gui.umd.js +17081 -17002
- package/bundles/@flexem/fc-gui.umd.js.map +1 -1
- package/bundles/@flexem/fc-gui.umd.min.js +5 -5
- package/bundles/@flexem/fc-gui.umd.min.js.map +1 -1
- package/communication/variable/variable-communicator.d.ts +3 -0
- package/config/alarm/alarm.store.d.ts +6 -0
- package/config/alarm/alarm.store.js +0 -0
- package/config/alarm/alarm.store.metadata.json +1 -0
- package/config/alarm/get-alarms-args.d.ts +9 -0
- package/config/alarm/get-alarms-args.js +9 -0
- package/config/alarm/get-alarms-args.metadata.json +1 -0
- package/config/alarm/index.d.ts +2 -0
- package/config/alarm/index.js +1 -0
- package/config/alarm/index.metadata.json +1 -0
- package/config/config-store.d.ts +2 -0
- package/config/index.d.ts +1 -0
- package/config/index.js +1 -0
- package/config/index.metadata.json +1 -1
- package/elements/alarm/alarm-element.d.ts +38 -0
- package/elements/alarm/alarm-element.js +307 -0
- package/elements/alarm/alarm-element.metadata.json +1 -0
- package/elements/alarm/alarm-state-enum.d.ts +4 -0
- package/elements/alarm/alarm-state-enum.js +5 -0
- package/elements/alarm/alarm-state-enum.metadata.json +1 -0
- package/elements/main-element.js +4 -0
- package/elements/main-element.metadata.json +1 -1
- package/elements/per-view-variable-communicator.d.ts +3 -0
- package/elements/per-view-variable-communicator.js +8 -0
- package/elements/per-view-variable-communicator.metadata.json +1 -1
- package/model/alarm/alarm.model.d.ts +13 -0
- package/model/alarm/alarm.model.js +0 -0
- package/model/alarm/alarm.model.metadata.json +1 -0
- package/package.json +1 -1
- package/remote/communication/variable/remote-variable-communicator.d.ts +3 -0
- package/remote/communication/variable/remote-variable-communicator.js +8 -0
- package/remote/communication/variable/remote-variable-communicator.metadata.json +1 -1
- package/remote/communication/variable/remote-variable-protocol.d.ts +3 -0
- package/shared/gui-consts.d.ts +1 -0
- package/shared/gui-consts.js +2 -1
- package/shared/gui-consts.metadata.json +1 -1
|
@@ -2,11 +2,14 @@ import { Observable } from 'rxjs';
|
|
|
2
2
|
import { VariableValue } from './variable-value';
|
|
3
3
|
import { VariableState } from './variable-state';
|
|
4
4
|
export interface VariableCommunicator {
|
|
5
|
+
historyAlarmChanged: any;
|
|
5
6
|
openVariable(variableName: string, appId: string): Observable<VariableValue>;
|
|
6
7
|
openVariables(variableNames: Array<string>, appId: string): Observable<Array<VariableValue>>;
|
|
7
8
|
write(variableName: string, value: any): Observable<VariableValue>;
|
|
8
9
|
writeWordByBit(variableName: string, index: number, value: number): Observable<VariableValue>;
|
|
9
10
|
subscribeVariableState(variableName: string): Observable<VariableState>;
|
|
10
11
|
subscribeVariableStates(variableNames: Array<string>): Observable<Array<VariableState>>;
|
|
12
|
+
subscribeUserDeviceAlarms(appId: string): Observable<any>;
|
|
13
|
+
unSubscribeUserDeviceAlarms(appId: string): any;
|
|
11
14
|
dispose(): any;
|
|
12
15
|
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"AlarmsStore":{"__symbolic":"interface"}}}]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as moment from 'moment';
|
|
2
|
+
export declare class GetAlarmsArgs {
|
|
3
|
+
readonly alarmNames: string[];
|
|
4
|
+
readonly triggeredStartTime: moment.Moment;
|
|
5
|
+
readonly triggeredEndTime: moment.Moment;
|
|
6
|
+
readonly maxResultCount: number;
|
|
7
|
+
readonly skipCount: number;
|
|
8
|
+
constructor(alarmNames: string[], triggeredStartTime: moment.Moment, triggeredEndTime: moment.Moment, maxResultCount: number, skipCount: number);
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export class GetAlarmsArgs {
|
|
2
|
+
constructor(alarmNames, triggeredStartTime, triggeredEndTime, maxResultCount, skipCount) {
|
|
3
|
+
this.alarmNames = alarmNames;
|
|
4
|
+
this.triggeredStartTime = triggeredStartTime;
|
|
5
|
+
this.triggeredEndTime = triggeredEndTime;
|
|
6
|
+
this.maxResultCount = maxResultCount;
|
|
7
|
+
this.skipCount = skipCount;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"GetAlarmsArgs":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","name":"string"}]},{"__symbolic":"reference","module":"moment","name":"Moment","line":5,"character":37},{"__symbolic":"reference","module":"moment","name":"Moment","line":6,"character":35},{"__symbolic":"reference","name":"number"},{"__symbolic":"reference","name":"number"}]}]}}}}]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GetAlarmsArgs } from './get-alarms-args';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{},"exports":[{"from":"./alarm.store","export":["AlarmsStore"]},{"from":"./get-alarms-args","export":["GetAlarmsArgs"]}]}]
|
package/config/config-store.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { ViewStore } from './view/view-store';
|
|
|
3
3
|
import { ImageStore } from './image/image-store';
|
|
4
4
|
import { HistoryDataStore } from './history-data/history-data.store';
|
|
5
5
|
import { VariableStore } from './variable/variable-store';
|
|
6
|
+
import { AlarmsStore } from './alarm';
|
|
6
7
|
/**
|
|
7
8
|
* 配置仓储
|
|
8
9
|
*/
|
|
@@ -11,5 +12,6 @@ export interface ConfigStore {
|
|
|
11
12
|
readonly graphStore: GraphStore;
|
|
12
13
|
readonly imageStore: ImageStore;
|
|
13
14
|
readonly historyDataStore: HistoryDataStore;
|
|
15
|
+
readonly alarmsStore: AlarmsStore;
|
|
14
16
|
readonly variableStore: VariableStore;
|
|
15
17
|
}
|
package/config/index.d.ts
CHANGED
package/config/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{},"exports":[{"from":"./config-store","export":["ConfigStore"]},{"from":"./graph/graph","export":["Graph"]},{"from":"./graph/graph-result","export":["GraphResult"]},{"from":"./graph/graph-type","export":["GraphType"]},{"from":"./graph/graph-store","export":["GraphStore"]},{"from":"./view/view-store","export":["ViewStore"]},{"from":"./view/view.model","export":["ViewModel"]},{"from":"./image/image-store","export":["ImageStore"]},{"from":"./history-data"},{"from":"./variable"}]}]
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{},"exports":[{"from":"./config-store","export":["ConfigStore"]},{"from":"./graph/graph","export":["Graph"]},{"from":"./graph/graph-result","export":["GraphResult"]},{"from":"./graph/graph-type","export":["GraphType"]},{"from":"./graph/graph-store","export":["GraphStore"]},{"from":"./view/view-store","export":["ViewStore"]},{"from":"./view/view.model","export":["ViewModel"]},{"from":"./image/image-store","export":["ImageStore"]},{"from":"./history-data"},{"from":"./variable"},{"from":"./alarm"}]}]
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Injector } from '@angular/core';
|
|
2
|
+
import { PermissionChecker } from '../../service';
|
|
3
|
+
import { VariableCommunicator } from '../../communication';
|
|
4
|
+
import { ConditionalDisplayElement } from '../base/conditional-display-element';
|
|
5
|
+
import { AlarmModel } from '../../model/alarm/alarm.model';
|
|
6
|
+
import { AlarmsStore, VariableStore } from '../../config';
|
|
7
|
+
export declare class AlarmElement extends ConditionalDisplayElement {
|
|
8
|
+
private readonly alarmsStore;
|
|
9
|
+
readonly model: AlarmModel;
|
|
10
|
+
private readonly logger;
|
|
11
|
+
readonly variableCommunicator: VariableCommunicator;
|
|
12
|
+
private readonly localization;
|
|
13
|
+
private readonly timePeriods;
|
|
14
|
+
private element;
|
|
15
|
+
private refreshIntervalId;
|
|
16
|
+
private readonly displayOption;
|
|
17
|
+
private startTime;
|
|
18
|
+
private endTime;
|
|
19
|
+
private currentTimePeriod;
|
|
20
|
+
private alarmList;
|
|
21
|
+
private currentAlarmList;
|
|
22
|
+
private page;
|
|
23
|
+
private totalCount;
|
|
24
|
+
private pageSize;
|
|
25
|
+
constructor(element: HTMLElement, injector: Injector, permissionChecker: PermissionChecker, variableCommunicator: VariableCommunicator, variableStore: VariableStore, alarmsStore: AlarmsStore, signalRAppId: string);
|
|
26
|
+
ngOnDestroy(): void;
|
|
27
|
+
dispose(): void;
|
|
28
|
+
private getValidTimePeriods;
|
|
29
|
+
private init;
|
|
30
|
+
private renderElement;
|
|
31
|
+
private renderOperationArea;
|
|
32
|
+
private updateTimeRange;
|
|
33
|
+
private updateQueryTimeRange;
|
|
34
|
+
private loadFirstPage;
|
|
35
|
+
private loadNextPage;
|
|
36
|
+
private loadPreviousPage;
|
|
37
|
+
private loadLastPage;
|
|
38
|
+
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import * as d3 from 'd3';
|
|
2
|
+
import { ConditionalDisplayElement } from '../base/conditional-display-element';
|
|
3
|
+
import { GetAlarmsArgs } from '../../config';
|
|
4
|
+
import * as moment from 'moment';
|
|
5
|
+
import { LOGGER_SERVICE_TOKEN } from '../../logger';
|
|
6
|
+
import { LOCALIZATION } from '../../localization';
|
|
7
|
+
import { find, isNil, pull, remove } from 'lodash';
|
|
8
|
+
import { AlarmState } from './alarm-state-enum';
|
|
9
|
+
export class AlarmElement extends ConditionalDisplayElement {
|
|
10
|
+
constructor(element, injector, permissionChecker, variableCommunicator, variableStore, alarmsStore, signalRAppId) {
|
|
11
|
+
super(element, permissionChecker, variableCommunicator, variableStore, signalRAppId);
|
|
12
|
+
this.alarmsStore = alarmsStore;
|
|
13
|
+
this.displayOption = {
|
|
14
|
+
dataLimit: 500,
|
|
15
|
+
dataZoomHeight: 32,
|
|
16
|
+
marginLeft: 1,
|
|
17
|
+
marginRight: 20,
|
|
18
|
+
mobileMinWidth: 450,
|
|
19
|
+
operationAreaHeight: 32,
|
|
20
|
+
operationAreaMarginTop: 10,
|
|
21
|
+
operationSelectFontSize: '16px',
|
|
22
|
+
operationButtonWidth: 24,
|
|
23
|
+
operationButtonHeight: 24,
|
|
24
|
+
operationButtonMargin: 4
|
|
25
|
+
};
|
|
26
|
+
this.alarmList = [];
|
|
27
|
+
this.currentAlarmList = [];
|
|
28
|
+
this.page = 0;
|
|
29
|
+
this.totalCount = 0;
|
|
30
|
+
this.pageSize = 5;
|
|
31
|
+
this.logger = injector.get(LOGGER_SERVICE_TOKEN);
|
|
32
|
+
this.localization = injector.get(LOCALIZATION);
|
|
33
|
+
this.variableCommunicator = variableCommunicator;
|
|
34
|
+
this.timePeriods = this.getValidTimePeriods();
|
|
35
|
+
this.currentTimePeriod = this.model.filterSetting.refreshCycle;
|
|
36
|
+
this.pageSize = this.model.generalSetting.pageSize;
|
|
37
|
+
this.currentTimePeriod = this.model.filterSetting.displayPeriod;
|
|
38
|
+
this.updateQueryTimeRange();
|
|
39
|
+
if (this.model.filterSetting.alarmType) {
|
|
40
|
+
this.refreshIntervalId = setInterval(() => {
|
|
41
|
+
this.loadFirstPage();
|
|
42
|
+
this.logger.debug(`[GUI]Refresh Alarm Table:${d3.time.format('%x %X')(new Date())}`);
|
|
43
|
+
}, this.model.filterSetting.refreshCycle * 60 * 1000);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
variableCommunicator.subscribeUserDeviceAlarms(signalRAppId).subscribe(alarmWithAppId => {
|
|
47
|
+
if (alarmWithAppId.appId !== this.signalRAppId) {
|
|
48
|
+
return;
|
|
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)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
pull(this.currentAlarmList, this.currentAlarmList.find(record => alarm.name === record.name));
|
|
60
|
+
this.currentAlarmList.unshift(alarm);
|
|
61
|
+
this.totalCount += 1;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
if (isNil(currentAlarm)) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
remove(this.currentAlarmList, currentAlarm);
|
|
68
|
+
this.totalCount -= 1;
|
|
69
|
+
}
|
|
70
|
+
this.alarmList = [];
|
|
71
|
+
this.currentAlarmList.forEach(item => {
|
|
72
|
+
this.alarmList.push([
|
|
73
|
+
item.name,
|
|
74
|
+
item.message,
|
|
75
|
+
item.alarmLevel,
|
|
76
|
+
moment(item.triggeredTime).format('YYYY-MM-DD HH:mm:ss')
|
|
77
|
+
]);
|
|
78
|
+
});
|
|
79
|
+
this.renderElement();
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
this.init();
|
|
83
|
+
}
|
|
84
|
+
ngOnDestroy() {
|
|
85
|
+
if (!this.model.filterSetting.alarmType) {
|
|
86
|
+
this.variableCommunicator.unSubscribeUserDeviceAlarms(this.signalRAppId);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
dispose() {
|
|
90
|
+
clearInterval(this.refreshIntervalId);
|
|
91
|
+
if (this.element) {
|
|
92
|
+
this.element.tooltip.hidden(true);
|
|
93
|
+
}
|
|
94
|
+
this.logger.debug(`[GUI]Dispose Alarm Table Refresh Interval:${d3.time.format('%x %X')(new Date())}`);
|
|
95
|
+
}
|
|
96
|
+
getValidTimePeriods() {
|
|
97
|
+
const timePeriods = new Array();
|
|
98
|
+
timePeriods.push({ key: 6, name: this.localization.lastThirtyMinutes });
|
|
99
|
+
timePeriods.push({ key: 1, name: this.localization.lastOneHour });
|
|
100
|
+
timePeriods.push({ key: 7, name: this.localization.lastEightHour });
|
|
101
|
+
timePeriods.push({ key: 2, name: this.localization.lastTwentyFourHours });
|
|
102
|
+
timePeriods.push({ key: 3, name: this.localization.lastSevenDays });
|
|
103
|
+
timePeriods.push({ key: 4, name: this.localization.lastThirtyDays });
|
|
104
|
+
timePeriods.push({ key: 5, name: this.localization.lastOneYear });
|
|
105
|
+
return timePeriods;
|
|
106
|
+
}
|
|
107
|
+
init() {
|
|
108
|
+
if (this.model.filterSetting.alarmType) {
|
|
109
|
+
const input = new GetAlarmsArgs(this.model.filterSetting.detailsData, this.startTime, this.endTime, this.pageSize, this.page * this.pageSize);
|
|
110
|
+
this.alarmsStore.getHistoryAlarms(input).subscribe(result => {
|
|
111
|
+
this.totalCount = result.totalCount;
|
|
112
|
+
this.alarmList = result.items.map(item => [
|
|
113
|
+
item.name,
|
|
114
|
+
item.message,
|
|
115
|
+
item.alarmLevel,
|
|
116
|
+
item.triggeredTime.format('YYYY-MM-DD HH:mm:ss')
|
|
117
|
+
]);
|
|
118
|
+
this.renderElement();
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
const input = new GetAlarmsArgs(this.model.filterSetting.detailsData, undefined, undefined, this.pageSize, this.page * this.pageSize);
|
|
123
|
+
this.alarmsStore.getCurrentAlarms(input).subscribe(result => {
|
|
124
|
+
this.totalCount = result.totalCount;
|
|
125
|
+
this.currentAlarmList = result.items;
|
|
126
|
+
this.alarmList = this.currentAlarmList.map(item => [
|
|
127
|
+
item.name,
|
|
128
|
+
item.message,
|
|
129
|
+
item.alarmLevel,
|
|
130
|
+
item.triggeredTime.format('YYYY-MM-DD HH:mm:ss')
|
|
131
|
+
]);
|
|
132
|
+
this.renderElement();
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
renderElement() {
|
|
137
|
+
this.rootElement.selectAll('*').remove();
|
|
138
|
+
const elementHeight = this.model.size.height;
|
|
139
|
+
this.element = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject');
|
|
140
|
+
this.element.setAttribute('width', this.model.size.width.toString());
|
|
141
|
+
this.element.setAttribute('height', elementHeight.toString());
|
|
142
|
+
const table = document.createElement('table');
|
|
143
|
+
table.style.cssText = `border: 2px solid ${this.model.generalSetting.stroke};
|
|
144
|
+
height: ${elementHeight - 39}`;
|
|
145
|
+
let tr = document.createElement('tr');
|
|
146
|
+
let fontString = '';
|
|
147
|
+
if (this.model.generalSetting.headerFont.isItalic) {
|
|
148
|
+
fontString += 'italic ';
|
|
149
|
+
}
|
|
150
|
+
if (this.model.generalSetting.headerFont.isBold) {
|
|
151
|
+
fontString += 'bold ';
|
|
152
|
+
}
|
|
153
|
+
fontString += this.model.generalSetting.headerFont.fontSize + ' ' + this.model.generalSetting.headerFont.fontFamily;
|
|
154
|
+
tr.style.cssText = `height: ${this.model.heights[0]}px;
|
|
155
|
+
background: ${this.model.generalSetting.headerFillColor};
|
|
156
|
+
color: ${this.model.generalSetting.headerFont.color};
|
|
157
|
+
font: ${fontString};
|
|
158
|
+
text-align: ${this.model.generalSetting.headerFont.textAlign};
|
|
159
|
+
${this.model.generalSetting.headerFont.isUnderline ? 'text-decoration: underline' : ''};
|
|
160
|
+
vertical-align: middle;`;
|
|
161
|
+
for (let i = 0; i < 4; i++) {
|
|
162
|
+
const th = document.createElement('th');
|
|
163
|
+
th.innerHTML = this.model.columLables[i];
|
|
164
|
+
th.style.cssText = `width: ${this.model.widths[i] / this.model.size.width * 100}%;
|
|
165
|
+
border-style: solid;
|
|
166
|
+
border-color: ${this.model.generalSetting.splitLine};
|
|
167
|
+
border-left-width: ${!i || this.model.generalSetting.isHiddenColumnSplitLine ? 0 : 1}px;`;
|
|
168
|
+
tr.appendChild(th);
|
|
169
|
+
}
|
|
170
|
+
table.appendChild(tr);
|
|
171
|
+
const levelColors = ['#3695FF', '#FFE900', '#FFA800', '#E84F4F'];
|
|
172
|
+
for (let i = 0; i < this.pageSize; i++) {
|
|
173
|
+
tr = document.createElement('tr');
|
|
174
|
+
tr.style.cssText = `height: ${this.model.heights[i + 1]}px;
|
|
175
|
+
background: ${this.model.generalSetting.tableFillColor};
|
|
176
|
+
font: ${this.model.generalSetting.fontStyle};
|
|
177
|
+
color: ${this.model.generalSetting.fontColor};
|
|
178
|
+
text-align: ${this.model.generalSetting.textAlign};
|
|
179
|
+
vertical-align: middle;`;
|
|
180
|
+
for (let j = 0; j < 4; j++) {
|
|
181
|
+
const td = document.createElement('td');
|
|
182
|
+
td.style.cssText = `border-style: solid;
|
|
183
|
+
border-color: ${this.model.generalSetting.splitLine};
|
|
184
|
+
border-top-width: ${this.model.generalSetting.isHiddenColumnSplitLine ? 0 : 1}px;
|
|
185
|
+
border-left-width: ${!j || this.model.generalSetting.isHiddenColumnSplitLine ? 0 : 1}px;`;
|
|
186
|
+
if (this.alarmList[i]) {
|
|
187
|
+
if (j !== 2) {
|
|
188
|
+
td.innerHTML = this.alarmList[i][j];
|
|
189
|
+
td.style.cssText += `${this.model.generalSetting.isUnderline ? 'text-decoration: underline' : ''};`;
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
const alarmLevel = document.createElement('div');
|
|
193
|
+
let alarmHeight = parseInt(this.model.generalSetting.fontSize) + 15;
|
|
194
|
+
if (alarmHeight > this.model.heights[i + 1])
|
|
195
|
+
alarmHeight = this.model.heights[i + 1];
|
|
196
|
+
let margin = '0 15px';
|
|
197
|
+
if (this.model.generalSetting.textAlign === 'left') {
|
|
198
|
+
margin = '0 30px 0 0';
|
|
199
|
+
}
|
|
200
|
+
else if (this.model.generalSetting.textAlign === 'right') {
|
|
201
|
+
margin = '0 0 0 30px';
|
|
202
|
+
}
|
|
203
|
+
alarmLevel.style.cssText = `margin: ${margin};
|
|
204
|
+
border-radius: 5px;
|
|
205
|
+
background: ${levelColors[this.alarmList[i][j]]};
|
|
206
|
+
color: #ffffff;
|
|
207
|
+
width: ${this.model.widths[j] - 30}px;
|
|
208
|
+
height: ${alarmHeight}px;
|
|
209
|
+
max-height: ${this.model.heights[i + 1]}px;
|
|
210
|
+
display: flex;
|
|
211
|
+
justify-content: center;
|
|
212
|
+
align-items: center;
|
|
213
|
+
${this.model.generalSetting.isUnderline ? 'text-decoration: underline' : ''};`;
|
|
214
|
+
alarmLevel.innerHTML = this.model.levelText[this.alarmList[i][j]];
|
|
215
|
+
td.appendChild(alarmLevel);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
tr.appendChild(td);
|
|
219
|
+
}
|
|
220
|
+
table.appendChild(tr);
|
|
221
|
+
}
|
|
222
|
+
this.element.appendChild(table);
|
|
223
|
+
this.$element.append(this.element);
|
|
224
|
+
this.renderOperationArea(this.model.size.width, elementHeight);
|
|
225
|
+
}
|
|
226
|
+
renderOperationArea(chartWidth, chartHeight) {
|
|
227
|
+
const operationArea = this.rootElement.append('g').attr('transform', `translate(0,${chartHeight + this.displayOption.operationAreaMarginTop})`)
|
|
228
|
+
.append('foreignObject').attr('width', chartWidth).attr('height', this.displayOption.operationAreaHeight).attr('fill', 'none')
|
|
229
|
+
.append('xhtml:div').style('height', (this.displayOption.operationAreaHeight - 4) + 'px').style('overflow', 'hidden').style('margin-top', '4px');
|
|
230
|
+
if (this.model.filterSetting.alarmType) {
|
|
231
|
+
const selectElement = operationArea.append('select').style('margin-left', this.displayOption.marginLeft + 'px')
|
|
232
|
+
.style('font-size', this.displayOption.operationSelectFontSize).on('change', () => {
|
|
233
|
+
const displayTimePeriod = this.rootElement.select('select').property('value');
|
|
234
|
+
this.updateTimeRange(displayTimePeriod);
|
|
235
|
+
this.init();
|
|
236
|
+
});
|
|
237
|
+
const options = selectElement.selectAll('option').data(this.timePeriods).enter().append('option');
|
|
238
|
+
options.text(d => d.name).attr('value', d => d.key).property('selected', d => d.key === Number(this.currentTimePeriod));
|
|
239
|
+
}
|
|
240
|
+
const buttonWidth = this.displayOption.operationButtonWidth + 'px', buttonHeight = this.displayOption.operationButtonHeight + 'px';
|
|
241
|
+
operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
|
|
242
|
+
.style('float', 'right').style('background', 'white').style('background-image', 'url(assets/img/last_page.svg)')
|
|
243
|
+
.on('click', () => { this.loadLastPage(); });
|
|
244
|
+
operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
|
|
245
|
+
.style('float', 'right').style('background', 'white').style('background-image', 'url(assets/img/next_page.svg)')
|
|
246
|
+
.style('margin', `0 ${this.displayOption.operationButtonMargin}px 0 0`)
|
|
247
|
+
.on('click', () => { this.loadNextPage(); });
|
|
248
|
+
operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
|
|
249
|
+
.style('float', 'right').style('background', 'white').style('background-image', 'url(assets/img/previous_page.svg)')
|
|
250
|
+
.style('margin', `0 ${this.displayOption.operationButtonMargin}px 0 0`)
|
|
251
|
+
.on('click', () => { this.loadPreviousPage(); });
|
|
252
|
+
operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
|
|
253
|
+
.style('float', 'right').style('background', 'white').style('background-image', 'url(assets/img/first_page.svg)')
|
|
254
|
+
.style('margin', `0 ${this.displayOption.operationButtonMargin}px 0 0`)
|
|
255
|
+
.on('click', () => { this.loadFirstPage(); });
|
|
256
|
+
}
|
|
257
|
+
updateTimeRange(timePeriodType) {
|
|
258
|
+
this.currentTimePeriod = +timePeriodType;
|
|
259
|
+
this.updateQueryTimeRange();
|
|
260
|
+
}
|
|
261
|
+
updateQueryTimeRange() {
|
|
262
|
+
this.endTime = moment();
|
|
263
|
+
switch (this.currentTimePeriod) {
|
|
264
|
+
case 1:
|
|
265
|
+
this.startTime = moment().subtract(1, 'hours');
|
|
266
|
+
break;
|
|
267
|
+
case 3:
|
|
268
|
+
this.startTime = moment().subtract(7, 'days');
|
|
269
|
+
break;
|
|
270
|
+
case 4:
|
|
271
|
+
this.startTime = moment().subtract(30, 'days');
|
|
272
|
+
break;
|
|
273
|
+
case 5:
|
|
274
|
+
this.startTime = moment().subtract(1, 'years');
|
|
275
|
+
break;
|
|
276
|
+
case 6:
|
|
277
|
+
this.startTime = moment().subtract(30, 'minutes');
|
|
278
|
+
break;
|
|
279
|
+
case 7:
|
|
280
|
+
this.startTime = moment().subtract(8, 'hours');
|
|
281
|
+
break;
|
|
282
|
+
default:
|
|
283
|
+
this.startTime = moment().subtract(1, 'days');
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
loadFirstPage() {
|
|
287
|
+
this.page = 0;
|
|
288
|
+
this.init();
|
|
289
|
+
}
|
|
290
|
+
loadNextPage() {
|
|
291
|
+
const last_page = Math.ceil(this.totalCount / this.pageSize) - 1;
|
|
292
|
+
if (this.page < last_page) {
|
|
293
|
+
this.page++;
|
|
294
|
+
}
|
|
295
|
+
this.init();
|
|
296
|
+
}
|
|
297
|
+
loadPreviousPage() {
|
|
298
|
+
if (this.page > 0) {
|
|
299
|
+
this.page--;
|
|
300
|
+
}
|
|
301
|
+
this.init();
|
|
302
|
+
}
|
|
303
|
+
loadLastPage() {
|
|
304
|
+
this.page = Math.ceil(this.totalCount / this.pageSize) - 1;
|
|
305
|
+
this.init();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"AlarmElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../base/conditional-display-element","name":"ConditionalDisplayElement","line":17,"character":34},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":48,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":49,"character":18},{"__symbolic":"reference","module":"../../service","name":"PermissionChecker","line":50,"character":27},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":51,"character":30},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":52,"character":23},{"__symbolic":"reference","module":"../../config","name":"AlarmsStore","line":53,"character":38},{"__symbolic":"reference","name":"string"}]}],"ngOnDestroy":[{"__symbolic":"method"}],"dispose":[{"__symbolic":"method"}],"getValidTimePeriods":[{"__symbolic":"method"}],"init":[{"__symbolic":"method"}],"renderElement":[{"__symbolic":"method"}],"renderOperationArea":[{"__symbolic":"method"}],"updateTimeRange":[{"__symbolic":"method"}],"updateQueryTimeRange":[{"__symbolic":"method"}],"loadFirstPage":[{"__symbolic":"method"}],"loadNextPage":[{"__symbolic":"method"}],"loadPreviousPage":[{"__symbolic":"method"}],"loadLastPage":[{"__symbolic":"method"}]}}}}]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"AlarmState":{"AlarmStateTriggered":1,"AlarmStateRecovered":0}}}]
|
package/elements/main-element.js
CHANGED
|
@@ -28,6 +28,7 @@ import { HyperlinkElement } from './static-elements/hyperlink-element';
|
|
|
28
28
|
import { VideoElement } from './video/video-element';
|
|
29
29
|
import { WeatherElement } from './weather/weater-element';
|
|
30
30
|
import { AirQualityElement } from './air-quality/air-quality-element';
|
|
31
|
+
import { AlarmElement } from './alarm/alarm-element';
|
|
31
32
|
export class MainElement {
|
|
32
33
|
constructor(injector, bsModalService, context, variableCommunicator, popupViewService, signalRAppId) {
|
|
33
34
|
this.injector = injector;
|
|
@@ -129,6 +130,9 @@ export class MainElement {
|
|
|
129
130
|
case GuiConsts.components.airQualityKey:
|
|
130
131
|
this.elements.push(new AirQualityElement(element, this.injector, this.context.permissionChecker, this.variableCommunicator, this.context.configStore.variableStore, this.context.weatherService, this.signalRAppId));
|
|
131
132
|
break;
|
|
133
|
+
case GuiConsts.components.alarmKey:
|
|
134
|
+
this.elements.push(new AlarmElement(element, this.injector, this.context.permissionChecker, this.variableCommunicator, this.context.configStore.variableStore, this.context.configStore.alarmsStore, this.signalRAppId));
|
|
135
|
+
break;
|
|
132
136
|
}
|
|
133
137
|
});
|
|
134
138
|
this.initBackground();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"MainElement":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"MainElement":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":55,"character":43},{"__symbolic":"reference","module":"ngx-bootstrap/modal","name":"BsModalService","line":56,"character":41},{"__symbolic":"reference","module":"../gui/gui-context","name":"GuiContext","line":57,"character":34},{"__symbolic":"reference","module":"../communication","name":"VariableCommunicator","line":58,"character":47},{"__symbolic":"reference","module":"../view/popup-view.service","name":"PopupViewService","line":59,"character":43},null]}],"load":[{"__symbolic":"method"}],"uniformStretch":[{"__symbolic":"method"}],"changeVideoStyle":[{"__symbolic":"method"}],"horizontalStretch":[{"__symbolic":"method"}],"initElementState":[{"__symbolic":"method"}],"getVariableNames":[{"__symbolic":"method"}],"reportVariableStates":[{"__symbolic":"method"}],"reportVariableValues":[{"__symbolic":"method"}],"dispose":[{"__symbolic":"method"}],"checkIsLoaded":[{"__symbolic":"method"}],"initBackground":[{"__symbolic":"method"}],"getImageEl":[{"__symbolic":"method"}]}}}}]
|
|
@@ -6,6 +6,7 @@ export declare class PerViewVariableCommunicator implements VariableCommunicator
|
|
|
6
6
|
private observers;
|
|
7
7
|
private variableValuesChangedSubscriptions;
|
|
8
8
|
private variableStatesChangedSubscription;
|
|
9
|
+
historyAlarmChanged: any;
|
|
9
10
|
constructor(variableCommunicator: VariableCommunicator);
|
|
10
11
|
openVariable(variableName: string, appId: string): Observable<VariableValue>;
|
|
11
12
|
openVariables(variableNames: Array<string>, appId?: string): Observable<Array<VariableValue>>;
|
|
@@ -13,5 +14,7 @@ export declare class PerViewVariableCommunicator implements VariableCommunicator
|
|
|
13
14
|
writeWordByBit(variableName: string, index: number, value: number): Observable<VariableValue>;
|
|
14
15
|
subscribeVariableState(variableName: string): Observable<VariableState>;
|
|
15
16
|
subscribeVariableStates(variableNames: string[]): Observable<Array<VariableState>>;
|
|
17
|
+
subscribeUserDeviceAlarms(appId?: string): Observable<any>;
|
|
18
|
+
unSubscribeUserDeviceAlarms(appId?: string): void;
|
|
16
19
|
dispose(): void;
|
|
17
20
|
}
|
|
@@ -7,6 +7,7 @@ export class PerViewVariableCommunicator {
|
|
|
7
7
|
this.variableValuesChangedSubscriptions = new Array();
|
|
8
8
|
this.variableStatesChangedSubscription = new Array();
|
|
9
9
|
this._rawVariableCommunicator = variableCommunicator;
|
|
10
|
+
this.historyAlarmChanged = variableCommunicator.historyAlarmChanged;
|
|
10
11
|
}
|
|
11
12
|
openVariable(variableName, appId) {
|
|
12
13
|
return this.openVariables([variableName], appId).pipe(map(values => values[0]));
|
|
@@ -38,6 +39,13 @@ export class PerViewVariableCommunicator {
|
|
|
38
39
|
this.variableStatesChangedSubscription.push(subscription);
|
|
39
40
|
});
|
|
40
41
|
}
|
|
42
|
+
subscribeUserDeviceAlarms(appId = '') {
|
|
43
|
+
this._rawVariableCommunicator.subscribeUserDeviceAlarms(appId);
|
|
44
|
+
return this._rawVariableCommunicator.historyAlarmChanged;
|
|
45
|
+
}
|
|
46
|
+
unSubscribeUserDeviceAlarms(appId = '') {
|
|
47
|
+
this._rawVariableCommunicator.unSubscribeUserDeviceAlarms(appId);
|
|
48
|
+
}
|
|
41
49
|
dispose() {
|
|
42
50
|
forEach(this.variableValuesChangedSubscriptions, s => s.unsubscribe());
|
|
43
51
|
forEach(this.variableStatesChangedSubscription, s => s.unsubscribe());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"PerViewVariableCommunicator":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../communication","name":"VariableCommunicator","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"PerViewVariableCommunicator":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../communication","name":"VariableCommunicator","line":16,"character":38}]}],"openVariable":[{"__symbolic":"method"}],"openVariables":[{"__symbolic":"method"}],"write":[{"__symbolic":"method"}],"writeWordByBit":[{"__symbolic":"method"}],"subscribeVariableState":[{"__symbolic":"method"}],"subscribeVariableStates":[{"__symbolic":"method"}],"subscribeUserDeviceAlarms":[{"__symbolic":"method"}],"unSubscribeUserDeviceAlarms":[{"__symbolic":"method"}],"dispose":[{"__symbolic":"method"}]}}}}]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ConditionalDisplayModel } from '../base/conditional-display-model';
|
|
2
|
+
import { Point, Size } from '../shared';
|
|
3
|
+
export interface AlarmModel extends ConditionalDisplayModel {
|
|
4
|
+
readonly version: number;
|
|
5
|
+
readonly size: Size;
|
|
6
|
+
readonly location: Point;
|
|
7
|
+
readonly generalSetting?: any;
|
|
8
|
+
readonly filterSetting?: any;
|
|
9
|
+
readonly widths: number[];
|
|
10
|
+
readonly heights: number[];
|
|
11
|
+
readonly columLables: string[];
|
|
12
|
+
readonly levelText: string[];
|
|
13
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"AlarmModel":{"__symbolic":"interface"}}}]
|
package/package.json
CHANGED
|
@@ -17,6 +17,7 @@ export declare class RemoteVariableCommunicator implements VariableCommunicator
|
|
|
17
17
|
private variableStateCache;
|
|
18
18
|
private variableStatesToBeOpened;
|
|
19
19
|
private variableStatesToBeClosed;
|
|
20
|
+
historyAlarmChanged: any;
|
|
20
21
|
constructor(remoteVariableProtocol: RemoteVariableProtocol, logger: LoggerService);
|
|
21
22
|
private doVariableValuesChanged;
|
|
22
23
|
private doVariableStatesChanged;
|
|
@@ -26,5 +27,7 @@ export declare class RemoteVariableCommunicator implements VariableCommunicator
|
|
|
26
27
|
openVariable(variableName: string, appId?: string): Observable<VariableValue>;
|
|
27
28
|
write(variableName: string, value: any): Observable<VariableValue>;
|
|
28
29
|
writeWordByBit(variableName: string, index: number, value: number): Observable<VariableValue>;
|
|
30
|
+
subscribeUserDeviceAlarms(appId?: string): Observable<any>;
|
|
31
|
+
unSubscribeUserDeviceAlarms(appId?: string): void;
|
|
29
32
|
dispose(): void;
|
|
30
33
|
}
|
|
@@ -10,6 +10,7 @@ export class RemoteVariableCommunicator {
|
|
|
10
10
|
this.appIdVariablesMap = new Map();
|
|
11
11
|
this.variableStateObservers = new Map();
|
|
12
12
|
this.variableStateCache = new Map();
|
|
13
|
+
this.historyAlarmChanged = remoteVariableProtocol.historyAlarmChanged;
|
|
13
14
|
this.variableValueCache = new StringifyingMap(k => JSON.stringify(k));
|
|
14
15
|
this.connectedSubscription = this.remoteVariableProtocol.connected.subscribe(() => {
|
|
15
16
|
const variableNamesToStart = [];
|
|
@@ -203,6 +204,13 @@ export class RemoteVariableCommunicator {
|
|
|
203
204
|
observer.next(new VariableValue(variable, VariableStateEnum.DataNormal, value))*/
|
|
204
205
|
});
|
|
205
206
|
}
|
|
207
|
+
subscribeUserDeviceAlarms(appId = '') {
|
|
208
|
+
this.remoteVariableProtocol.subscribeUserDeviceAlarms(appId);
|
|
209
|
+
return this.remoteVariableProtocol.historyAlarmChanged;
|
|
210
|
+
}
|
|
211
|
+
unSubscribeUserDeviceAlarms(appId = '') {
|
|
212
|
+
this.remoteVariableProtocol.unSubscribeUserDeviceAlarms(appId);
|
|
213
|
+
}
|
|
206
214
|
dispose() {
|
|
207
215
|
// TODO调用所有的ob.complete()。
|
|
208
216
|
this.connectedSubscription.unsubscribe();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"RemoteVariableCommunicator":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./remote-variable-protocol","name":"RemoteVariableProtocol","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"RemoteVariableCommunicator":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./remote-variable-protocol","name":"RemoteVariableProtocol","line":26,"character":57},{"__symbolic":"reference","module":"../../../logger","name":"LoggerService","line":26,"character":106}]}],"doVariableValuesChanged":[{"__symbolic":"method"}],"doVariableStatesChanged":[{"__symbolic":"method"}],"subscribeVariableStates":[{"__symbolic":"method"}],"subscribeVariableState":[{"__symbolic":"method"}],"openVariables":[{"__symbolic":"method"}],"openVariable":[{"__symbolic":"method"}],"write":[{"__symbolic":"method"}],"writeWordByBit":[{"__symbolic":"method"}],"subscribeUserDeviceAlarms":[{"__symbolic":"method"}],"unSubscribeUserDeviceAlarms":[{"__symbolic":"method"}],"dispose":[{"__symbolic":"method"}]}}}}]
|