@flexem/fc-gui 3.0.0-alpha.9 → 3.0.0-alpha.90

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.
Files changed (123) hide show
  1. package/CHANGELOG.md +381 -0
  2. package/bundles/@flexem/fc-gui.umd.js +17578 -16210
  3. package/bundles/@flexem/fc-gui.umd.js.map +1 -1
  4. package/bundles/@flexem/fc-gui.umd.min.js +5 -5
  5. package/bundles/@flexem/fc-gui.umd.min.js.map +1 -1
  6. package/communication/variable/variable-communicator.d.ts +1 -0
  7. package/config/alarm/alarm.store.d.ts +6 -0
  8. package/config/alarm/alarm.store.js +0 -0
  9. package/config/alarm/alarm.store.metadata.json +1 -0
  10. package/config/alarm/get-alarms-args.d.ts +9 -0
  11. package/config/alarm/get-alarms-args.js +9 -0
  12. package/config/alarm/get-alarms-args.metadata.json +1 -0
  13. package/config/alarm/index.d.ts +2 -0
  14. package/config/alarm/index.js +1 -0
  15. package/config/alarm/index.metadata.json +1 -0
  16. package/config/config-store.d.ts +2 -0
  17. package/config/index.d.ts +1 -0
  18. package/config/index.js +1 -0
  19. package/config/index.metadata.json +1 -1
  20. package/elements/air-quality/air-quality-element.d.ts +31 -0
  21. package/elements/air-quality/air-quality-element.js +194 -0
  22. package/elements/air-quality/air-quality-element.metadata.json +1 -0
  23. package/elements/alarm/alarm-element.d.ts +44 -0
  24. package/elements/alarm/alarm-element.js +382 -0
  25. package/elements/alarm/alarm-element.metadata.json +1 -0
  26. package/elements/bar-graph-element.d.ts +7 -1
  27. package/elements/bar-graph-element.js +70 -4
  28. package/elements/bar-graph-element.metadata.json +1 -1
  29. package/elements/base/readable-element.d.ts +6 -1
  30. package/elements/base/readable-element.js +31 -2
  31. package/elements/base/readable-element.metadata.json +1 -1
  32. package/elements/historical-curve/historical-curve.element.js +116 -13
  33. package/elements/historical-curve/historical-curve.element.metadata.json +1 -1
  34. package/elements/main-element.js +25 -4
  35. package/elements/main-element.metadata.json +1 -1
  36. package/elements/meter-element.d.ts +7 -1
  37. package/elements/meter-element.js +76 -7
  38. package/elements/meter-element.metadata.json +1 -1
  39. package/elements/numerical-display/numerical-display-element.d.ts +8 -2
  40. package/elements/numerical-display/numerical-display-element.js +55 -11
  41. package/elements/numerical-display/numerical-display-element.metadata.json +1 -1
  42. package/elements/per-view-variable-communicator.d.ts +2 -0
  43. package/elements/per-view-variable-communicator.js +8 -0
  44. package/elements/per-view-variable-communicator.metadata.json +1 -1
  45. package/elements/ring-graph/ring-graph-element.d.ts +10 -1
  46. package/elements/ring-graph/ring-graph-element.js +106 -3
  47. package/elements/ring-graph/ring-graph-element.metadata.json +1 -1
  48. package/elements/shared/graph/graph-state-element.js +0 -3
  49. package/elements/shared/text/text-element.js +13 -2
  50. package/elements/shared/text/text-state-element.js +1 -1
  51. package/elements/switch-indicator-light/bit-switch-operator.d.ts +1 -0
  52. package/elements/switch-indicator-light/bit-switch-operator.js +19 -0
  53. package/elements/switch-indicator-light/bit-switch-operator.metadata.json +1 -1
  54. package/elements/switch-indicator-light/switch-indicator-light-element.d.ts +8 -0
  55. package/elements/switch-indicator-light/switch-indicator-light-element.js +93 -23
  56. package/elements/switch-indicator-light/switch-indicator-light-element.metadata.json +1 -1
  57. package/elements/switch-indicator-light/switch-operator.d.ts +1 -0
  58. package/elements/switch-indicator-light/word-switch-operator.d.ts +1 -0
  59. package/elements/switch-indicator-light/word-switch-operator.js +6 -0
  60. package/elements/switch-indicator-light/word-switch-operator.metadata.json +1 -1
  61. package/elements/video/video-element.d.ts +4 -0
  62. package/elements/video/video-element.js +69 -20
  63. package/elements/video/video-element.metadata.json +1 -1
  64. package/elements/view-operation/view-operation.element.js +8 -0
  65. package/elements/weather/weater-element.js +0 -1
  66. package/gui/gui-context.d.ts +2 -1
  67. package/gui/gui-host.d.ts +1 -1
  68. package/gui/gui.component.d.ts +3 -0
  69. package/gui/gui.component.js +15 -2
  70. package/gui/gui.component.metadata.json +1 -1
  71. package/localization/localization.service.d.ts +7 -0
  72. package/localization/localization.service.js +8 -1
  73. package/localization/localization.service.metadata.json +1 -1
  74. package/localization/localization.service.zh_CN.js +8 -1
  75. package/localization/localization.service.zh_CN.metadata.json +1 -1
  76. package/modal/write-value/write-value-modal-args.d.ts +4 -1
  77. package/modal/write-value/write-value-modal-args.js +3 -1
  78. package/modal/write-value/write-value-modal-args.metadata.json +1 -1
  79. package/modal/write-value/write-value-modal.component.d.ts +9 -7
  80. package/modal/write-value/write-value-modal.component.html +9 -4
  81. package/modal/write-value/write-value-modal.component.js +39 -22
  82. package/modal/write-value/write-value-modal.component.metadata.json +1 -1
  83. package/model/air-quality/air-quality-info.d.ts +23 -0
  84. package/model/air-quality/air-quality-info.js +4 -0
  85. package/model/air-quality/air-quality-info.metadata.json +1 -0
  86. package/model/air-quality/air-quality.model.d.ts +7 -0
  87. package/model/air-quality/air-quality.model.js +0 -0
  88. package/model/air-quality/air-quality.model.metadata.json +1 -0
  89. package/model/alarm/alarm.model.d.ts +13 -0
  90. package/model/alarm/alarm.model.js +0 -0
  91. package/model/alarm/alarm.model.metadata.json +1 -0
  92. package/model/bar-graph/bar-graph.d.ts +4 -0
  93. package/model/base/readable-model.d.ts +4 -0
  94. package/model/historical-curve/historical-curve-axis-settings.d.ts +10 -0
  95. package/model/historical-curve/historical-curve-axis-settings.js +5 -0
  96. package/model/historical-curve/historical-curve-axis-settings.metadata.json +1 -1
  97. package/model/meter/meter.d.ts +4 -0
  98. package/model/numerical-display/numerical-display.d.ts +1 -0
  99. package/model/ring-graph/ring-graph.model.d.ts +8 -0
  100. package/model/switch-indicator-light/bit-switch-operation.d.ts +2 -1
  101. package/model/switch-indicator-light/bit-switch-operation.js +1 -0
  102. package/model/switch-indicator-light/bit-switch-operation.metadata.json +1 -1
  103. package/package.json +1 -1
  104. package/remote/communication/variable/remote-variable-communicator.d.ts +4 -0
  105. package/remote/communication/variable/remote-variable-communicator.js +23 -1
  106. package/remote/communication/variable/remote-variable-communicator.metadata.json +1 -1
  107. package/remote/communication/variable/remote-variable-protocol.d.ts +3 -0
  108. package/service/index.d.ts +1 -0
  109. package/service/index.metadata.json +1 -1
  110. package/service/released-variable/index.d.ts +1 -0
  111. package/service/released-variable/index.js +0 -0
  112. package/service/released-variable/index.metadata.json +1 -0
  113. package/service/released-variable/released-variable.service.d.ts +4 -0
  114. package/service/released-variable/released-variable.service.js +0 -0
  115. package/service/released-variable/released-variable.service.metadata.json +1 -0
  116. package/service/weather.service.d.ts +1 -0
  117. package/shared/gui-consts.d.ts +2 -0
  118. package/shared/gui-consts.js +2 -0
  119. package/shared/gui-consts.metadata.json +1 -1
  120. package/utils/data-type/data-type.service.d.ts +4 -7
  121. package/utils/data-type/data-type.service.js +29 -17
  122. package/utils/data-type/fbox-data-type.service.js +40 -0
  123. package/utils/numerical-operation.service.js +2 -2
@@ -0,0 +1,382 @@
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
+ var AlaertElementStatus;
8
+ (function (AlaertElementStatus) {
9
+ AlaertElementStatus[AlaertElementStatus["Normal"] = 0] = "Normal";
10
+ AlaertElementStatus[AlaertElementStatus["Loading"] = 1] = "Loading"; // 加载中
11
+ })(AlaertElementStatus || (AlaertElementStatus = {}));
12
+ export class AlarmElement extends ConditionalDisplayElement {
13
+ constructor(element, injector, permissionChecker, variableCommunicator, variableStore, alarmsStore, signalRAppId) {
14
+ var _a;
15
+ super(element, permissionChecker, variableCommunicator, variableStore, signalRAppId);
16
+ this.alarmsStore = alarmsStore;
17
+ this.elementStatus = AlaertElementStatus.Loading;
18
+ this.displayOption = {
19
+ dataLimit: 500,
20
+ dataZoomHeight: 32,
21
+ marginLeft: 1,
22
+ marginRight: 20,
23
+ mobileMinWidth: 450,
24
+ operationAreaHeight: 32,
25
+ operationAreaMarginTop: 10,
26
+ operationSelectFontSize: '16px',
27
+ operationButtonWidth: 24,
28
+ operationButtonHeight: 24,
29
+ operationButtonMargin: 4
30
+ };
31
+ this.alarmNames = [];
32
+ this.alarmList = [];
33
+ this.currentAlarmList = [];
34
+ this.page = 0;
35
+ this.totalCount = 0;
36
+ this.pageSize = 5;
37
+ this.rootElement.selectAll('*').remove();
38
+ this.setStatusAsLoading();
39
+ this.logger = injector.get(LOGGER_SERVICE_TOKEN);
40
+ this.localization = injector.get(LOCALIZATION);
41
+ this.variableCommunicator = variableCommunicator;
42
+ this.timePeriods = this.getValidTimePeriods();
43
+ this.pageSize = this.model.generalSetting.pageSize;
44
+ localStorage.setItem('simulate-time', moment().valueOf() + '');
45
+ if (this.model.filterSetting) {
46
+ this.alarmNames = this.model.filterSetting.detailsData.map(item => item.name);
47
+ this.currentTimePeriod = (_a = this.model.filterSetting) === null || _a === void 0 ? void 0 : _a.displayPeriod;
48
+ this.updateQueryTimeRange();
49
+ if (this.model.filterSetting.alarmType) {
50
+ this.refreshIntervalId = setInterval(() => {
51
+ this.loadFirstPage();
52
+ this.logger.debug(`[GUI]Refresh Alarm Table:${d3.time.format('%x %X')(new Date())}`);
53
+ }, this.model.filterSetting.refreshCycle * 60 * 1000);
54
+ }
55
+ else {
56
+ variableCommunicator.subscribeUserDeviceAlarms(signalRAppId).subscribe(alarms => {
57
+ alarms.forEach(alarm => {
58
+ if (this.alarmNames.indexOf(alarm.name) !== -1) {
59
+ this.getAlarmData();
60
+ return;
61
+ }
62
+ });
63
+ });
64
+ }
65
+ this.getAlarmData();
66
+ }
67
+ else {
68
+ this.totalCount = 0;
69
+ this.alarmList = [];
70
+ this.renderElement();
71
+ }
72
+ }
73
+ dispose() {
74
+ clearInterval(this.refreshIntervalId);
75
+ if (this.element) {
76
+ this.element.tooltip.hidden(true);
77
+ }
78
+ this.logger.debug(`[GUI]Dispose Alarm Table Refresh Interval:${d3.time.format('%x %X')(new Date())}`);
79
+ }
80
+ getValidTimePeriods() {
81
+ const timePeriods = new Array();
82
+ timePeriods.push({ key: 6, name: this.localization.lastThirtyMinutes });
83
+ timePeriods.push({ key: 1, name: this.localization.lastOneHour });
84
+ timePeriods.push({ key: 7, name: this.localization.lastEightHour });
85
+ timePeriods.push({ key: 2, name: this.localization.lastTwentyFourHours });
86
+ timePeriods.push({ key: 3, name: this.localization.lastSevenDays });
87
+ timePeriods.push({ key: 4, name: this.localization.lastThirtyDays });
88
+ timePeriods.push({ key: 5, name: this.localization.lastOneYear });
89
+ return timePeriods;
90
+ }
91
+ getAlarmData() {
92
+ this.rootElement.selectAll('*').remove();
93
+ this.setStatusAsLoading();
94
+ clearTimeout(this.getAlarmDataId);
95
+ this.getAlarmDataId = setTimeout(() => {
96
+ if (this.model.filterSetting.alarmType) {
97
+ this.updateQueryTimeRange();
98
+ const input = new GetAlarmsArgs(this.alarmNames, this.startTime, this.endTime, this.pageSize, this.page * this.pageSize);
99
+ this.alarmsStore.getHistoryAlarms(input).subscribe(result => {
100
+ if (!result.error) {
101
+ this.totalCount = result.totalCount;
102
+ this.alarmList = result.items.map(item => [
103
+ item.name,
104
+ item.message,
105
+ item.alarmLevel,
106
+ item.triggeredTime.format('YYYY-MM-DD HH:mm:ss')
107
+ ]);
108
+ this.renderElement();
109
+ }
110
+ });
111
+ }
112
+ else {
113
+ const input = new GetAlarmsArgs(this.alarmNames, undefined, undefined, this.pageSize, this.page * this.pageSize);
114
+ this.alarmsStore.getCurrentAlarms(input).subscribe(result => {
115
+ if (!result.error) {
116
+ this.totalCount = result.totalCount;
117
+ this.currentAlarmList = result.items;
118
+ if (!result.items.length && result.totalCount) {
119
+ this.page = 0;
120
+ this.getAlarmData();
121
+ return;
122
+ }
123
+ this.alarmList = this.currentAlarmList.map(item => [
124
+ item.name,
125
+ item.message,
126
+ item.alarmLevel,
127
+ item.triggeredTime.format('YYYY-MM-DD HH:mm:ss')
128
+ ]);
129
+ this.renderElement();
130
+ }
131
+ });
132
+ }
133
+ }, 500);
134
+ }
135
+ renderElement() {
136
+ const elementHeight = this.model.size.height;
137
+ this.element = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject');
138
+ this.element.setAttribute('width', this.model.size.width.toString());
139
+ this.element.setAttribute('height', elementHeight.toString());
140
+ this.$element.append(this.element);
141
+ const table = document.createElement('table');
142
+ table.style.cssText = `border: 2px solid ${this.model.generalSetting.stroke};
143
+ height: ${elementHeight - 39}`;
144
+ let tr = document.createElement('tr');
145
+ let fontString = '';
146
+ if (this.model.generalSetting.headerFont.isItalic) {
147
+ fontString += 'italic ';
148
+ }
149
+ if (this.model.generalSetting.headerFont.isBold) {
150
+ fontString += 'bold ';
151
+ }
152
+ fontString += this.model.generalSetting.headerFont.fontSize + ' ' + this.model.generalSetting.headerFont.fontFamily;
153
+ tr.style.cssText = `height: ${this.model.heights[0]}px;
154
+ background: ${this.model.generalSetting.headerFillColor};
155
+ color: ${this.model.generalSetting.headerFont.color};
156
+ font: ${fontString};
157
+ text-align: ${this.model.generalSetting.headerFont.textAlign};
158
+ ${this.model.generalSetting.headerFont.isUnderline ? 'text-decoration: underline' : ''};
159
+ vertical-align: middle;`;
160
+ for (let row = 0; row < 4; row++) {
161
+ const th = document.createElement('th');
162
+ th.innerHTML = this.model.columLabels[row];
163
+ th.style.cssText = `width: ${this.model.widths[row] / this.model.size.width * 100}%;
164
+ border-style: solid;
165
+ border-color: ${this.model.generalSetting.splitLine};
166
+ border-left-width: ${!row || this.model.generalSetting.isHiddenColumnSplitLine ? 0 : 1}px;`;
167
+ tr.appendChild(th);
168
+ }
169
+ table.appendChild(tr);
170
+ const levelColors = ['#3695FF', '#FFE900', '#FFA800', '#E84F4F'];
171
+ for (let row = 0; row < this.pageSize; row++) {
172
+ tr = document.createElement('tr');
173
+ tr.style.cssText = `height: ${this.model.heights[row + 1]}px;
174
+ background: ${this.model.generalSetting.tableFillColor};
175
+ font: ${this.model.generalSetting.fontStyle};
176
+ color: ${this.model.generalSetting.fontColor};
177
+ text-align: ${this.model.generalSetting.textAlign};
178
+ vertical-align: middle;`;
179
+ for (let col = 0; col < 4; col++) {
180
+ const td = document.createElement('td');
181
+ td.style.cssText = `border-style: solid;
182
+ border-color: ${this.model.generalSetting.splitLine};
183
+ border-top-width: ${this.model.generalSetting.isHiddenColumnSplitLine ? 0 : 1}px;
184
+ border-left-width: ${!col || this.model.generalSetting.isHiddenColumnSplitLine ? 0 : 1}px;`;
185
+ if (this.alarmList[row]) {
186
+ if (col !== 2) {
187
+ td.innerHTML = this.alarmList[row][col];
188
+ td.style.cssText += `${this.model.generalSetting.isUnderline ? 'text-decoration: underline' : ''};`;
189
+ }
190
+ else {
191
+ const alarmLevel = document.createElement('div');
192
+ let alarmHeight = parseInt(this.model.generalSetting.fontSize) + 15;
193
+ if (alarmHeight > this.model.heights[row + 1])
194
+ alarmHeight = this.model.heights[row + 1];
195
+ let margin = '0 15px';
196
+ if (this.model.generalSetting.textAlign === 'left') {
197
+ margin = '0 30px 0 0';
198
+ }
199
+ else if (this.model.generalSetting.textAlign === 'right') {
200
+ margin = '0 0 0 30px';
201
+ }
202
+ alarmLevel.style.cssText = `margin: ${margin};
203
+ border-radius: 5px;
204
+ background: ${levelColors[this.alarmList[row][col]]};
205
+ color: #ffffff;
206
+ width: ${this.model.widths[col] - 30}px;
207
+ height: ${alarmHeight}px;
208
+ max-height: ${this.model.heights[row + 1]}px;
209
+ display: flex;
210
+ justify-content: center;
211
+ align-items: center;
212
+ ${this.model.generalSetting.isUnderline ? 'text-decoration: underline' : ''};`;
213
+ alarmLevel.innerHTML = this.model.levelText[this.alarmList[row][col]];
214
+ td.appendChild(alarmLevel);
215
+ }
216
+ }
217
+ else if (col === 2) {
218
+ const alarmLevel = document.createElement('div');
219
+ let margin = '0 15px';
220
+ if (this.model.generalSetting.textAlign === 'left') {
221
+ margin = '0 30px 0 0';
222
+ }
223
+ else if (this.model.generalSetting.textAlign === 'right') {
224
+ margin = '0 0 0 30px';
225
+ }
226
+ alarmLevel.style.cssText = `margin: ${margin};
227
+ width: ${this.model.widths[col] - 30}px;`;
228
+ td.appendChild(alarmLevel);
229
+ }
230
+ tr.appendChild(td);
231
+ }
232
+ table.appendChild(tr);
233
+ }
234
+ this.element.appendChild(table);
235
+ this.renderOperationArea(this.model.size.width, elementHeight - 39);
236
+ }
237
+ renderOperationArea(chartWidth, chartHeight) {
238
+ var _a;
239
+ const operationArea = this.rootElement.append('g').attr('transform', `translate(0,${chartHeight + this.displayOption.operationAreaMarginTop})`)
240
+ .append('foreignObject').attr('width', chartWidth).attr('height', this.displayOption.operationAreaHeight).attr('fill', 'none')
241
+ .append('xhtml:div').style('height', (this.displayOption.operationAreaHeight - 4) + 'px').style('overflow', 'hidden').style('margin-top', '4px');
242
+ if ((_a = this.model.filterSetting) === null || _a === void 0 ? void 0 : _a.alarmType) {
243
+ const selectElement = operationArea.append('select').style('margin-left', this.displayOption.marginLeft + 'px')
244
+ .style('font-size', this.displayOption.operationSelectFontSize).on('change', () => {
245
+ const displayTimePeriod = this.rootElement.select('select').property('value');
246
+ this.updateTimeRange(displayTimePeriod);
247
+ this.getAlarmData();
248
+ });
249
+ const options = selectElement.selectAll('option').data(this.timePeriods).enter().append('option');
250
+ options.text(d => d.name).attr('value', d => d.key).property('selected', d => d.key === Number(this.currentTimePeriod));
251
+ }
252
+ const buttonWidth = this.displayOption.operationButtonWidth + 'px', buttonHeight = this.displayOption.operationButtonHeight + 'px';
253
+ operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
254
+ .style('float', 'right').style('background', 'white').style('background-image', 'url(assets/img/last_page.svg)')
255
+ .on('click', () => { this.loadLastPage(); });
256
+ operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
257
+ .style('float', 'right').style('background', 'white').style('background-image', 'url(assets/img/next_page.svg)')
258
+ .style('margin', `0 ${this.displayOption.operationButtonMargin}px 0 0`)
259
+ .on('click', () => { this.loadNextPage(); });
260
+ operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
261
+ .style('float', 'right').style('background', 'white').style('background-image', 'url(assets/img/previous_page.svg)')
262
+ .style('margin', `0 ${this.displayOption.operationButtonMargin}px 0 0`)
263
+ .on('click', () => { this.loadPreviousPage(); });
264
+ operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
265
+ .style('float', 'right').style('background', 'white').style('background-image', 'url(assets/img/first_page.svg)')
266
+ .style('margin', `0 ${this.displayOption.operationButtonMargin}px 0 0`)
267
+ .on('click', () => { this.loadFirstPage(); });
268
+ this.setStatusAsNormal();
269
+ }
270
+ updateTimeRange(timePeriodType) {
271
+ this.currentTimePeriod = +timePeriodType;
272
+ this.updateQueryTimeRange();
273
+ }
274
+ updateQueryTimeRange() {
275
+ this.endTime = moment();
276
+ switch (this.currentTimePeriod) {
277
+ case 1:
278
+ this.startTime = moment().subtract(1, 'hours');
279
+ break;
280
+ case 3:
281
+ this.startTime = moment().subtract(7, 'days');
282
+ break;
283
+ case 4:
284
+ this.startTime = moment().subtract(30, 'days');
285
+ break;
286
+ case 5:
287
+ this.startTime = moment().subtract(1, 'years');
288
+ break;
289
+ case 6:
290
+ this.startTime = moment().subtract(30, 'minutes');
291
+ break;
292
+ case 7:
293
+ this.startTime = moment().subtract(8, 'hours');
294
+ break;
295
+ default:
296
+ this.startTime = moment().subtract(1, 'days');
297
+ }
298
+ }
299
+ loadFirstPage() {
300
+ if (this.page > 0) {
301
+ this.page = 0;
302
+ this.getAlarmData();
303
+ }
304
+ }
305
+ loadNextPage() {
306
+ let last_page = Math.ceil(this.totalCount / this.pageSize);
307
+ if (last_page)
308
+ last_page--;
309
+ if (this.page < last_page) {
310
+ this.page++;
311
+ this.getAlarmData();
312
+ }
313
+ }
314
+ loadPreviousPage() {
315
+ if (this.page > 0) {
316
+ this.page--;
317
+ this.getAlarmData();
318
+ }
319
+ }
320
+ loadLastPage() {
321
+ let last_page = Math.ceil(this.totalCount / this.pageSize);
322
+ if (last_page)
323
+ last_page--;
324
+ if (this.page !== last_page) {
325
+ this.page = last_page;
326
+ this.getAlarmData();
327
+ }
328
+ }
329
+ setStatusAsNormal() {
330
+ this.elementStatus = AlaertElementStatus.Normal;
331
+ this.clearStatus();
332
+ }
333
+ setStatusAsLoading() {
334
+ this.elementStatus = AlaertElementStatus.Loading;
335
+ this.renderStatus('assets/img/loading.svg', '#226abc');
336
+ }
337
+ renderStatus(icon, stroke) {
338
+ if (this.elementStatus === AlaertElementStatus.Normal) {
339
+ this.clearStatus();
340
+ return;
341
+ }
342
+ this.rootElement.append('rect').attr('id', 'StateFrame').attr('fill', 'transparent')
343
+ .attr('width', this.model.size.width)
344
+ .attr('height', this.model.size.height);
345
+ const document = this.$element[0].ownerDocument;
346
+ const currentRect = this.$element.find('rect#StateFrame').first();
347
+ if (!currentRect.length) {
348
+ return;
349
+ }
350
+ this.$element.find('image#StateImage').remove();
351
+ const imgObj = document.createElementNS('http://www.w3.org/2000/svg', 'image');
352
+ if (imgObj) {
353
+ let x = Number(currentRect[0].getAttribute('width')) - 20;
354
+ const currentRectX = currentRect[0].getAttribute('x');
355
+ if (currentRectX !== null) {
356
+ x += Number(currentRectX);
357
+ }
358
+ currentRect[0].setAttribute('stroke', stroke);
359
+ currentRect[0].setAttribute('stroke-opacity', '0.5');
360
+ imgObj.href.baseVal = icon;
361
+ imgObj.setAttributeNS(null, 'id', 'StateImage');
362
+ imgObj.setAttributeNS(null, 'x', x.toString());
363
+ imgObj.setAttributeNS(null, 'y', '0');
364
+ imgObj.setAttributeNS(null, 'height', '20px');
365
+ imgObj.setAttributeNS(null, 'width', '20px');
366
+ const titleElement = document.createElementNS('http://www.w3.org/2000/svg', 'title');
367
+ imgObj.appendChild(titleElement);
368
+ this.$element.append(imgObj);
369
+ }
370
+ }
371
+ clearStatus() {
372
+ const currentRect = this.$element.find('rect#StateFrame').first();
373
+ if (!currentRect.length) {
374
+ return;
375
+ }
376
+ const stroke = currentRect[0].getAttribute('stroke');
377
+ if (stroke) {
378
+ currentRect[0].removeAttribute('stroke');
379
+ }
380
+ this.$element.find('image#StateImage').remove();
381
+ }
382
+ }
@@ -0,0 +1 @@
1
+ [{"__symbolic":"module","version":4,"metadata":{"AlarmElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../base/conditional-display-element","name":"ConditionalDisplayElement","line":20,"character":34},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":54,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":55,"character":18},{"__symbolic":"reference","module":"../../service","name":"PermissionChecker","line":56,"character":27},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":57,"character":30},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":58,"character":23},{"__symbolic":"reference","module":"../../config","name":"AlarmsStore","line":59,"character":38},{"__symbolic":"reference","name":"string"}]}],"dispose":[{"__symbolic":"method"}],"getValidTimePeriods":[{"__symbolic":"method"}],"getAlarmData":[{"__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"}],"setStatusAsNormal":[{"__symbolic":"method"}],"setStatusAsLoading":[{"__symbolic":"method"}],"renderStatus":[{"__symbolic":"method"}],"clearStatus":[{"__symbolic":"method"}]}}}}]
@@ -5,6 +5,8 @@ import { ReadableElement } from './base/readable-element';
5
5
  import { VariableStore } from '../config';
6
6
  import { PermissionChecker } from '../service';
7
7
  export declare class BarGraphElement extends ReadableElement {
8
+ private static DEFAULT_MIN_VALUE;
9
+ private static DEFAULT_MAX_VALUE;
8
10
  readonly model: BarGraph;
9
11
  private readonly $barRect;
10
12
  private readonly barElement;
@@ -14,8 +16,12 @@ export declare class BarGraphElement extends ReadableElement {
14
16
  private defaultUpperLimitColor;
15
17
  private defaultLowerLimitColor;
16
18
  private barText;
19
+ private valueObj;
20
+ private isNeedUpdateScale;
17
21
  get readVariableName(): string;
18
22
  constructor(element: HTMLElement, permissionChecker: PermissionChecker, variableCommunicator: VariableCommunicator, variableStore: VariableStore, localization: Localization, signalRAppId: string);
19
23
  private initFrameNode;
20
- updateVariableValue(value: number): void;
24
+ private updateValueObj;
25
+ private updateScale;
26
+ updateVariableValue(value: number, variableName: any): void;
21
27
  }
@@ -2,6 +2,7 @@ import { BarGraphDirection } from '../model';
2
2
  import { ReadableElement } from './base/readable-element';
3
3
  import { calculatePercent } from './shared/math-utils';
4
4
  import { VariableUtil } from '../utils/variable-util';
5
+ import { VariableValueType } from '../model/shared/condition/variable-value-type';
5
6
  export class BarGraphElement extends ReadableElement {
6
7
  constructor(element, permissionChecker, variableCommunicator, variableStore, localization, signalRAppId) {
7
8
  super(element, permissionChecker, variableCommunicator, variableStore, localization, signalRAppId);
@@ -9,6 +10,14 @@ export class BarGraphElement extends ReadableElement {
9
10
  this.defaultUpperLimitColor = '#ff4448';
10
11
  this.defaultLowerLimitColor = '#0f60e8';
11
12
  this.barText = '';
13
+ this.valueObj = {};
14
+ this.isNeedUpdateScale = false;
15
+ if ((this.model.minValueType === VariableValueType.Constant && this.model.maxValueType === VariableValueType.Variable)
16
+ || this.model.maxValueType === VariableValueType.Constant && this.model.minValueType === VariableValueType.Variable) {
17
+ this.isNeedUpdateScale = true;
18
+ this.updateScale();
19
+ this.isNeedUpdateScale = false;
20
+ }
12
21
  this.$barRect = this.$element.find('rect');
13
22
  this.$barText = this.$element.find('text[id="text"]').last();
14
23
  if (this.model.version && this.model.version >= 1) {
@@ -41,10 +50,65 @@ export class BarGraphElement extends ReadableElement {
41
50
  const b = arcPath.getBBox(true);
42
51
  this.rootElement.append('rect').attr('id', 'StateFrame').attr('width', b.width).attr('height', b.height).attr('fill', 'transparent');
43
52
  }
44
- updateVariableValue(value) {
45
- const variableValue = Number(value).valueOf();
46
- const maxValue = Number(this.model.max).valueOf();
47
- const minValue = Number(this.model.min).valueOf();
53
+ updateValueObj(value, variableName) {
54
+ var _a, _b, _c;
55
+ if (((_a = this.model.readVariable) === null || _a === void 0 ? void 0 : _a.name) === variableName) {
56
+ this.isNeedUpdateScale = false;
57
+ this.valueObj.value = value;
58
+ }
59
+ if (((_b = this.model.minVariable) === null || _b === void 0 ? void 0 : _b.name) === variableName) {
60
+ this.isNeedUpdateScale = true;
61
+ this.valueObj.min = value;
62
+ }
63
+ if (((_c = this.model.maxVariable) === null || _c === void 0 ? void 0 : _c.name) === variableName) {
64
+ this.isNeedUpdateScale = true;
65
+ this.valueObj.max = value;
66
+ }
67
+ }
68
+ updateScale() {
69
+ if (!this.isNeedUpdateScale) {
70
+ return;
71
+ }
72
+ const textElements = this.$element.find('g:first > text');
73
+ let min = this.model.minValueType ? this.valueObj.min : this.model.min;
74
+ let max = this.model.maxValueType ? this.valueObj.max : this.model.max;
75
+ min = Number(min);
76
+ max = Number(max);
77
+ if (isNaN(min) || isNaN(max)) {
78
+ min = BarGraphElement.DEFAULT_MIN_VALUE;
79
+ max = BarGraphElement.DEFAULT_MAX_VALUE;
80
+ }
81
+ const avgSacle = ((max - min) / this.model.masterDivisionNumber).toFixed(5);
82
+ for (let i = 0; i < textElements.length; i++) {
83
+ const text = textElements[i];
84
+ if (!text.innerHTML) {
85
+ continue;
86
+ }
87
+ let sacleValue = ((Number(avgSacle) * i) + min).toFixed(0);
88
+ // 整数位和小数位格式化;
89
+ if (this.model.fractionDigits > 0) {
90
+ sacleValue = (sacleValue / Math.pow(10, this.model.fractionDigits)).toFixed(this.model.fractionDigits);
91
+ }
92
+ if (!isNaN(sacleValue)) {
93
+ text.innerHTML = sacleValue;
94
+ }
95
+ }
96
+ }
97
+ updateVariableValue(value, variableName) {
98
+ this.updateValueObj(value, variableName);
99
+ this.updateScale();
100
+ const variableValue = Number(this.valueObj.value);
101
+ let maxValue = this.model.maxValueType ? this.valueObj.max : this.model.max;
102
+ let minValue = this.model.minValueType ? this.valueObj.min : this.model.min;
103
+ minValue = Number(minValue);
104
+ maxValue = Number(maxValue);
105
+ if (isNaN(minValue) || isNaN(maxValue)) {
106
+ minValue = BarGraphElement.DEFAULT_MIN_VALUE;
107
+ maxValue = BarGraphElement.DEFAULT_MAX_VALUE;
108
+ }
109
+ if (isNaN(variableValue)) {
110
+ return;
111
+ }
48
112
  const useAlarmLimit = this.model.useAlarmLimit;
49
113
  const useAlarmUpperLimit = null != this.model.upperLimit;
50
114
  const useAlarmLowerLimit = null != this.model.lowerLimit;
@@ -112,3 +176,5 @@ export class BarGraphElement extends ReadableElement {
112
176
  }
113
177
  }
114
178
  }
179
+ BarGraphElement.DEFAULT_MIN_VALUE = 0;
180
+ BarGraphElement.DEFAULT_MAX_VALUE = 100;
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"BarGraphElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./base/readable-element","name":"ReadableElement","line":9,"character":37},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":33,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"../service","name":"PermissionChecker","line":33,"character":57},{"__symbolic":"reference","module":"../communication","name":"VariableCommunicator","line":34,"character":30},{"__symbolic":"reference","module":"../config","name":"VariableStore","line":35,"character":23},{"__symbolic":"reference","module":"../localization","name":"Localization","line":36,"character":22},{"__symbolic":"reference","name":"string"}]}],"initFrameNode":[{"__symbolic":"method"}],"updateVariableValue":[{"__symbolic":"method"}]}}}}]
1
+ [{"__symbolic":"module","version":4,"metadata":{"BarGraphElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./base/readable-element","name":"ReadableElement","line":10,"character":37},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":38,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"../service","name":"PermissionChecker","line":38,"character":57},{"__symbolic":"reference","module":"../communication","name":"VariableCommunicator","line":39,"character":30},{"__symbolic":"reference","module":"../config","name":"VariableStore","line":40,"character":23},{"__symbolic":"reference","module":"../localization","name":"Localization","line":41,"character":22},{"__symbolic":"reference","name":"string"}]}],"initFrameNode":[{"__symbolic":"method"}],"updateValueObj":[{"__symbolic":"method"}],"updateScale":[{"__symbolic":"method"}],"updateVariableValue":[{"__symbolic":"method"}]},"statics":{"DEFAULT_MIN_VALUE":0,"DEFAULT_MAX_VALUE":100}}}}]
@@ -9,7 +9,12 @@ export declare abstract class ReadableElement extends ConditionalEnableElement {
9
9
  constructor(element: HTMLElement, permissionChecker: PermissionChecker, variableCommunicator: VariableCommunicator, variableStore: VariableStore, localization: Localization, signalRAppId: string);
10
10
  init(variableName: string): void;
11
11
  get readVariableName(): string;
12
- protected abstract updateVariableValue(value: any): void;
12
+ get minVariableName(): string;
13
+ get minValueType(): any;
14
+ get maxVariableName(): string;
15
+ get maxValueType(): any;
16
+ private getVariableName;
17
+ protected abstract updateVariableValue(value: any, variableName: any): void;
13
18
  reportStateChanged(variableState: VariableState): void;
14
19
  reportValueChanged(value: VariableValue): void;
15
20
  }
@@ -36,6 +36,33 @@ export class ReadableElement extends ConditionalEnableElement {
36
36
  return VariableUtil.getConvertedVariableName(this.variableStore, variable);
37
37
  }
38
38
  }
39
+ get minVariableName() {
40
+ if (!this.model.minValueType) {
41
+ return undefined;
42
+ }
43
+ return this.getVariableName(this.model.minVariable);
44
+ }
45
+ get minValueType() {
46
+ return this.model.minValueType;
47
+ }
48
+ get maxVariableName() {
49
+ if (!this.model.maxValueType) {
50
+ return undefined;
51
+ }
52
+ return this.getVariableName(this.model.maxVariable);
53
+ }
54
+ get maxValueType() {
55
+ return this.model.maxValueType;
56
+ }
57
+ getVariableName(variable) {
58
+ if (!this.model) {
59
+ throw new Error('Model cannot be null');
60
+ }
61
+ if (!variable) {
62
+ return undefined;
63
+ }
64
+ return VariableUtil.getConvertedVariableName(this.variableStore, variable);
65
+ }
39
66
  reportStateChanged(variableState) {
40
67
  forEach(this.elementStates, elementState => {
41
68
  if (elementState.variableName === variableState.variableName) {
@@ -51,8 +78,10 @@ export class ReadableElement extends ConditionalEnableElement {
51
78
  this.changeStates();
52
79
  }
53
80
  });
54
- if (this.state === State.Normal || this.state === State.Disable) {
55
- this.updateVariableValue(value.value);
81
+ if (this.state === State.Normal || this.state === State.Disable
82
+ || value.variableName === this.minVariableName
83
+ || value.variableName === this.maxVariableName) {
84
+ this.updateVariableValue(value.value, value.variableName);
56
85
  }
57
86
  }
58
87
  }
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"ReadableElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./conditional-enable-element","name":"ConditionalEnableElement","line":9,"character":46},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":13,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"../../service","name":"PermissionChecker","line":13,"character":57},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":13,"character":98},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":14,"character":23},{"__symbolic":"reference","module":"../../localization","name":"Localization","line":14,"character":52},{"__symbolic":"reference","name":"string"}]}],"init":[{"__symbolic":"method"}],"updateVariableValue":[{"__symbolic":"method"}],"reportStateChanged":[{"__symbolic":"method"}],"reportValueChanged":[{"__symbolic":"method"}]}}}}]
1
+ [{"__symbolic":"module","version":4,"metadata":{"ReadableElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./conditional-enable-element","name":"ConditionalEnableElement","line":9,"character":46},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":13,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"../../service","name":"PermissionChecker","line":13,"character":57},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":13,"character":98},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":14,"character":23},{"__symbolic":"reference","module":"../../localization","name":"Localization","line":14,"character":52},{"__symbolic":"reference","name":"string"}]}],"init":[{"__symbolic":"method"}],"getVariableName":[{"__symbolic":"method"}],"updateVariableValue":[{"__symbolic":"method"}],"reportStateChanged":[{"__symbolic":"method"}],"reportValueChanged":[{"__symbolic":"method"}]}}}}]