@flexem/fc-gui 3.0.0-alpha.11 → 3.0.0-alpha.111

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 (131) hide show
  1. package/CHANGELOG.md +445 -0
  2. package/assets/img/black_first_page.png +0 -0
  3. package/assets/img/black_last_page.png +0 -0
  4. package/assets/img/black_next_page.png +0 -0
  5. package/assets/img/black_previous_page.png +0 -0
  6. package/bundles/@flexem/fc-gui.umd.js +19414 -17248
  7. package/bundles/@flexem/fc-gui.umd.js.map +1 -1
  8. package/bundles/@flexem/fc-gui.umd.min.js +5 -5
  9. package/bundles/@flexem/fc-gui.umd.min.js.map +1 -1
  10. package/communication/variable/variable-communicator.d.ts +1 -0
  11. package/config/alarm/alarm.store.d.ts +6 -0
  12. package/config/alarm/alarm.store.js +0 -0
  13. package/config/alarm/alarm.store.metadata.json +1 -0
  14. package/config/alarm/get-alarms-args.d.ts +9 -0
  15. package/config/alarm/get-alarms-args.js +9 -0
  16. package/config/alarm/get-alarms-args.metadata.json +1 -0
  17. package/config/alarm/index.d.ts +2 -0
  18. package/config/alarm/index.js +1 -0
  19. package/config/alarm/index.metadata.json +1 -0
  20. package/config/config-store.d.ts +2 -0
  21. package/config/index.d.ts +1 -0
  22. package/config/index.js +1 -0
  23. package/config/index.metadata.json +1 -1
  24. package/elements/air-quality/air-quality-element.d.ts +31 -0
  25. package/elements/air-quality/air-quality-element.js +194 -0
  26. package/elements/air-quality/air-quality-element.metadata.json +1 -0
  27. package/elements/alarm/alarm-element.d.ts +44 -0
  28. package/elements/alarm/alarm-element.js +386 -0
  29. package/elements/alarm/alarm-element.metadata.json +1 -0
  30. package/elements/bar-graph-element.d.ts +10 -2
  31. package/elements/bar-graph-element.js +135 -5
  32. package/elements/bar-graph-element.metadata.json +1 -1
  33. package/elements/base/readable-element.d.ts +6 -1
  34. package/elements/base/readable-element.js +31 -2
  35. package/elements/base/readable-element.metadata.json +1 -1
  36. package/elements/datetime-display/datetime-display-element.d.ts +1 -0
  37. package/elements/datetime-display/datetime-display-element.js +10 -2
  38. package/elements/datetime-display/datetime-display-element.metadata.json +1 -1
  39. package/elements/datetime-display/time-zone-select-json.d.ts +8 -0
  40. package/elements/datetime-display/time-zone-select-json.js +558 -0
  41. package/elements/historical-curve/historical-curve.element.d.ts +8 -0
  42. package/elements/historical-curve/historical-curve.element.js +224 -19
  43. package/elements/historical-curve/historical-curve.element.metadata.json +1 -1
  44. package/elements/main-element.js +25 -4
  45. package/elements/main-element.metadata.json +1 -1
  46. package/elements/meter-element.d.ts +7 -1
  47. package/elements/meter-element.js +76 -7
  48. package/elements/meter-element.metadata.json +1 -1
  49. package/elements/numerical-display/numerical-display-element.d.ts +8 -2
  50. package/elements/numerical-display/numerical-display-element.js +55 -11
  51. package/elements/numerical-display/numerical-display-element.metadata.json +1 -1
  52. package/elements/per-view-variable-communicator.d.ts +2 -0
  53. package/elements/per-view-variable-communicator.js +8 -0
  54. package/elements/per-view-variable-communicator.metadata.json +1 -1
  55. package/elements/ring-graph/ring-graph-element.d.ts +13 -1
  56. package/elements/ring-graph/ring-graph-element.js +164 -3
  57. package/elements/ring-graph/ring-graph-element.metadata.json +1 -1
  58. package/elements/shared/graph/graph-state-element.js +0 -3
  59. package/elements/shared/text/text-element.js +13 -2
  60. package/elements/shared/text/text-state-element.js +1 -1
  61. package/elements/switch-indicator-light/bit-switch-operator.d.ts +1 -0
  62. package/elements/switch-indicator-light/bit-switch-operator.js +19 -0
  63. package/elements/switch-indicator-light/bit-switch-operator.metadata.json +1 -1
  64. package/elements/switch-indicator-light/switch-indicator-light-element.d.ts +8 -0
  65. package/elements/switch-indicator-light/switch-indicator-light-element.js +93 -23
  66. package/elements/switch-indicator-light/switch-indicator-light-element.metadata.json +1 -1
  67. package/elements/switch-indicator-light/switch-operator.d.ts +1 -0
  68. package/elements/switch-indicator-light/word-switch-operator.d.ts +1 -0
  69. package/elements/switch-indicator-light/word-switch-operator.js +6 -0
  70. package/elements/switch-indicator-light/word-switch-operator.metadata.json +1 -1
  71. package/elements/video/video-element.d.ts +4 -0
  72. package/elements/video/video-element.js +74 -20
  73. package/elements/video/video-element.metadata.json +1 -1
  74. package/elements/view-operation/view-operation.element.js +8 -0
  75. package/elements/weather/weater-element.js +0 -1
  76. package/gui/gui-context.d.ts +2 -1
  77. package/gui/gui-host.d.ts +1 -1
  78. package/gui/gui.component.d.ts +3 -0
  79. package/gui/gui.component.js +15 -2
  80. package/gui/gui.component.metadata.json +1 -1
  81. package/localization/localization.service.d.ts +7 -0
  82. package/localization/localization.service.js +10 -3
  83. package/localization/localization.service.metadata.json +1 -1
  84. package/localization/localization.service.zh_CN.js +8 -1
  85. package/localization/localization.service.zh_CN.metadata.json +1 -1
  86. package/modal/write-value/write-value-modal-args.d.ts +3 -1
  87. package/modal/write-value/write-value-modal-args.js +2 -1
  88. package/modal/write-value/write-value-modal-args.metadata.json +1 -1
  89. package/modal/write-value/write-value-modal.component.d.ts +8 -7
  90. package/modal/write-value/write-value-modal.component.html +9 -4
  91. package/modal/write-value/write-value-modal.component.js +42 -15
  92. package/modal/write-value/write-value-modal.component.metadata.json +1 -1
  93. package/model/air-quality/air-quality-info.d.ts +23 -0
  94. package/model/air-quality/air-quality-info.js +4 -0
  95. package/model/air-quality/air-quality-info.metadata.json +1 -0
  96. package/model/air-quality/air-quality.model.d.ts +7 -0
  97. package/model/air-quality/air-quality.model.js +0 -0
  98. package/model/air-quality/air-quality.model.metadata.json +1 -0
  99. package/model/alarm/alarm.model.d.ts +13 -0
  100. package/model/alarm/alarm.model.js +0 -0
  101. package/model/alarm/alarm.model.metadata.json +1 -0
  102. package/model/bar-graph/bar-graph.d.ts +4 -0
  103. package/model/base/readable-model.d.ts +4 -0
  104. package/model/datetime-display/datetime-display.d.ts +1 -0
  105. package/model/historical-curve/historical-curve-axis-settings.d.ts +11 -0
  106. package/model/historical-curve/historical-curve-axis-settings.js +5 -0
  107. package/model/historical-curve/historical-curve-axis-settings.metadata.json +1 -1
  108. package/model/historical-curve/historical-curve-chanel.model.d.ts +8 -0
  109. package/model/meter/meter.d.ts +4 -0
  110. package/model/ring-graph/ring-graph.model.d.ts +8 -0
  111. package/model/switch-indicator-light/bit-switch-operation.d.ts +2 -1
  112. package/model/switch-indicator-light/bit-switch-operation.js +1 -0
  113. package/model/switch-indicator-light/bit-switch-operation.metadata.json +1 -1
  114. package/package.json +1 -1
  115. package/remote/communication/variable/remote-variable-communicator.d.ts +4 -0
  116. package/remote/communication/variable/remote-variable-communicator.js +23 -1
  117. package/remote/communication/variable/remote-variable-communicator.metadata.json +1 -1
  118. package/remote/communication/variable/remote-variable-protocol.d.ts +3 -0
  119. package/service/index.d.ts +1 -0
  120. package/service/index.metadata.json +1 -1
  121. package/service/released-variable/index.d.ts +1 -0
  122. package/service/released-variable/index.js +0 -0
  123. package/service/released-variable/index.metadata.json +1 -0
  124. package/service/released-variable/released-variable.service.d.ts +4 -0
  125. package/service/released-variable/released-variable.service.js +0 -0
  126. package/service/released-variable/released-variable.service.metadata.json +1 -0
  127. package/service/weather.service.d.ts +1 -0
  128. package/shared/gui-consts.d.ts +2 -0
  129. package/shared/gui-consts.js +2 -0
  130. package/shared/gui-consts.metadata.json +1 -1
  131. package/utils/data-type/fbox-data-type.service.js +40 -0
@@ -0,0 +1,386 @@
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-image', 'url(assets/img/last_page.svg)')
255
+ .style('background-color', 'inherit')
256
+ .on('click', () => { this.loadLastPage(); });
257
+ operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
258
+ .style('float', 'right').style('background-image', 'url(assets/img/next_page.svg)')
259
+ .style('margin', `0 ${this.displayOption.operationButtonMargin}px 0 0`)
260
+ .style('background-color', 'inherit')
261
+ .on('click', () => { this.loadNextPage(); });
262
+ operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
263
+ .style('float', 'right').style('background-image', 'url(assets/img/previous_page.svg)')
264
+ .style('margin', `0 ${this.displayOption.operationButtonMargin}px 0 0`)
265
+ .style('background-color', 'inherit')
266
+ .on('click', () => { this.loadPreviousPage(); });
267
+ operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
268
+ .style('float', 'right').style('background-image', 'url(assets/img/first_page.svg)')
269
+ .style('margin', `0 ${this.displayOption.operationButtonMargin}px 0 0`)
270
+ .style('background-color', 'inherit')
271
+ .on('click', () => { this.loadFirstPage(); });
272
+ this.setStatusAsNormal();
273
+ }
274
+ updateTimeRange(timePeriodType) {
275
+ this.currentTimePeriod = +timePeriodType;
276
+ this.updateQueryTimeRange();
277
+ }
278
+ updateQueryTimeRange() {
279
+ this.endTime = moment();
280
+ switch (this.currentTimePeriod) {
281
+ case 1:
282
+ this.startTime = moment().subtract(1, 'hours');
283
+ break;
284
+ case 3:
285
+ this.startTime = moment().subtract(7, 'days');
286
+ break;
287
+ case 4:
288
+ this.startTime = moment().subtract(30, 'days');
289
+ break;
290
+ case 5:
291
+ this.startTime = moment().subtract(1, 'years');
292
+ break;
293
+ case 6:
294
+ this.startTime = moment().subtract(30, 'minutes');
295
+ break;
296
+ case 7:
297
+ this.startTime = moment().subtract(8, 'hours');
298
+ break;
299
+ default:
300
+ this.startTime = moment().subtract(1, 'days');
301
+ }
302
+ }
303
+ loadFirstPage() {
304
+ if (this.page > 0) {
305
+ this.page = 0;
306
+ this.getAlarmData();
307
+ }
308
+ }
309
+ loadNextPage() {
310
+ let last_page = Math.ceil(this.totalCount / this.pageSize);
311
+ if (last_page)
312
+ last_page--;
313
+ if (this.page < last_page) {
314
+ this.page++;
315
+ this.getAlarmData();
316
+ }
317
+ }
318
+ loadPreviousPage() {
319
+ if (this.page > 0) {
320
+ this.page--;
321
+ this.getAlarmData();
322
+ }
323
+ }
324
+ loadLastPage() {
325
+ let last_page = Math.ceil(this.totalCount / this.pageSize);
326
+ if (last_page)
327
+ last_page--;
328
+ if (this.page !== last_page) {
329
+ this.page = last_page;
330
+ this.getAlarmData();
331
+ }
332
+ }
333
+ setStatusAsNormal() {
334
+ this.elementStatus = AlaertElementStatus.Normal;
335
+ this.clearStatus();
336
+ }
337
+ setStatusAsLoading() {
338
+ this.elementStatus = AlaertElementStatus.Loading;
339
+ this.renderStatus('assets/img/loading.svg', '#226abc');
340
+ }
341
+ renderStatus(icon, stroke) {
342
+ if (this.elementStatus === AlaertElementStatus.Normal) {
343
+ this.clearStatus();
344
+ return;
345
+ }
346
+ this.rootElement.append('rect').attr('id', 'StateFrame').attr('fill', 'transparent')
347
+ .attr('width', this.model.size.width)
348
+ .attr('height', this.model.size.height);
349
+ const document = this.$element[0].ownerDocument;
350
+ const currentRect = this.$element.find('rect#StateFrame').first();
351
+ if (!currentRect.length) {
352
+ return;
353
+ }
354
+ this.$element.find('image#StateImage').remove();
355
+ const imgObj = document.createElementNS('http://www.w3.org/2000/svg', 'image');
356
+ if (imgObj) {
357
+ let x = Number(currentRect[0].getAttribute('width')) - 20;
358
+ const currentRectX = currentRect[0].getAttribute('x');
359
+ if (currentRectX !== null) {
360
+ x += Number(currentRectX);
361
+ }
362
+ currentRect[0].setAttribute('stroke', stroke);
363
+ currentRect[0].setAttribute('stroke-opacity', '0.5');
364
+ imgObj.href.baseVal = icon;
365
+ imgObj.setAttributeNS(null, 'id', 'StateImage');
366
+ imgObj.setAttributeNS(null, 'x', x.toString());
367
+ imgObj.setAttributeNS(null, 'y', '0');
368
+ imgObj.setAttributeNS(null, 'height', '20px');
369
+ imgObj.setAttributeNS(null, 'width', '20px');
370
+ const titleElement = document.createElementNS('http://www.w3.org/2000/svg', 'title');
371
+ imgObj.appendChild(titleElement);
372
+ this.$element.append(imgObj);
373
+ }
374
+ }
375
+ clearStatus() {
376
+ const currentRect = this.$element.find('rect#StateFrame').first();
377
+ if (!currentRect.length) {
378
+ return;
379
+ }
380
+ const stroke = currentRect[0].getAttribute('stroke');
381
+ if (stroke) {
382
+ currentRect[0].removeAttribute('stroke');
383
+ }
384
+ this.$element.find('image#StateImage').remove();
385
+ }
386
+ }
@@ -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,17 +5,25 @@ 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;
11
13
  private readonly $barText;
12
- private readonly defaultTransform;
14
+ private defaultTransform;
13
15
  private defaultBarColor;
14
16
  private defaultUpperLimitColor;
15
17
  private defaultLowerLimitColor;
16
18
  private barText;
19
+ private valueObj;
20
+ private isNeedUpdateScale;
21
+ private needAddNumber;
17
22
  get readVariableName(): string;
18
23
  constructor(element: HTMLElement, permissionChecker: PermissionChecker, variableCommunicator: VariableCommunicator, variableStore: VariableStore, localization: Localization, signalRAppId: string);
24
+ private initTransform;
19
25
  private initFrameNode;
20
- updateVariableValue(value: number): void;
26
+ private updateValueObj;
27
+ private updateScale;
28
+ updateVariableValue(value: number, variableName: any): void;
21
29
  }
@@ -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,15 @@ 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
+ this.needAddNumber = 0;
16
+ if ((this.model.minValueType === VariableValueType.Constant && this.model.maxValueType === VariableValueType.Variable)
17
+ || this.model.maxValueType === VariableValueType.Constant && this.model.minValueType === VariableValueType.Variable) {
18
+ this.isNeedUpdateScale = true;
19
+ this.updateScale();
20
+ this.isNeedUpdateScale = false;
21
+ }
12
22
  this.$barRect = this.$element.find('rect');
13
23
  this.$barText = this.$element.find('text[id="text"]').last();
14
24
  if (this.model.version && this.model.version >= 1) {
@@ -19,7 +29,7 @@ export class BarGraphElement extends ReadableElement {
19
29
  }
20
30
  setTimeout(() => {
21
31
  this.initFrameNode();
22
- }, 0);
32
+ });
23
33
  }
24
34
  get readVariableName() {
25
35
  if (!this.model) {
@@ -36,15 +46,133 @@ export class BarGraphElement extends ReadableElement {
36
46
  return VariableUtil.getConvertedVariableName(this.variableStore, variable);
37
47
  }
38
48
  }
49
+ initTransform() {
50
+ if (this.needAddNumber <= 3)
51
+ return;
52
+ this.$element[0].childNodes.forEach((node, index) => {
53
+ // const matrixE = node.transform.baseVal[0].matrix.e;
54
+ // node.transform.baseVal[0].matrix.e = matrixE + (this.needAddNumber - 3) * 7;
55
+ if (!node.transform.baseVal[0])
56
+ return;
57
+ if (node.nodeName === 'g') {
58
+ const nodeValue = node.attributes['clip-path'].value.replace('url(#', '').replace(')', '');
59
+ const rootNode = node.parentNode.parentNode.parentElement;
60
+ const clipPath = $(rootNode).find(`clipPath[id="${nodeValue}"]`);
61
+ const demoPath = clipPath.find('path');
62
+ const dValues = demoPath.attr('d').split(',');
63
+ const retValues = [];
64
+ dValues.forEach((line) => {
65
+ const values = [];
66
+ line.split(' ').forEach((item) => {
67
+ const nItem = Number(item);
68
+ if (nItem === -1) {
69
+ item = nItem - (this.needAddNumber - 3) * 7;
70
+ }
71
+ values.push(item);
72
+ });
73
+ retValues.push(values.join(' '));
74
+ });
75
+ demoPath.attr('d', retValues.join(','));
76
+ }
77
+ else if (index === this.$element[0].childNodes.length - 1) {
78
+ this.defaultTransform = node.attributes['transform'].value;
79
+ }
80
+ });
81
+ }
39
82
  initFrameNode() {
40
83
  const arcPath = Snap(this.$element[0]);
41
84
  const b = arcPath.getBBox(true);
42
85
  this.rootElement.append('rect').attr('id', 'StateFrame').attr('width', b.width).attr('height', b.height).attr('fill', 'transparent');
43
86
  }
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();
87
+ updateValueObj(value, variableName) {
88
+ var _a, _b, _c;
89
+ if (((_a = this.model.readVariable) === null || _a === void 0 ? void 0 : _a.name) === variableName) {
90
+ this.isNeedUpdateScale = false;
91
+ this.valueObj.value = value;
92
+ }
93
+ if (((_b = this.model.minVariable) === null || _b === void 0 ? void 0 : _b.name) === variableName) {
94
+ this.isNeedUpdateScale = true;
95
+ this.valueObj.min = value;
96
+ }
97
+ if (((_c = this.model.maxVariable) === null || _c === void 0 ? void 0 : _c.name) === variableName) {
98
+ this.isNeedUpdateScale = true;
99
+ this.valueObj.max = value;
100
+ }
101
+ }
102
+ updateScale() {
103
+ if (!this.isNeedUpdateScale) {
104
+ return;
105
+ }
106
+ const textElements = this.$element.find('g:first > text');
107
+ let min = this.model.minValueType ? this.valueObj.min : this.model.min;
108
+ let max = this.model.maxValueType ? this.valueObj.max : this.model.max;
109
+ min = Number(min);
110
+ max = Number(max);
111
+ if (isNaN(min) || isNaN(max)) {
112
+ min = BarGraphElement.DEFAULT_MIN_VALUE;
113
+ max = BarGraphElement.DEFAULT_MAX_VALUE;
114
+ }
115
+ if (this.model.maxValueType === VariableValueType.Variable || this.model.minValueType === VariableValueType.Variable) {
116
+ this.needAddNumber = max.toString().length > min.toString().length ? max.toString().length : min.toString().length;
117
+ this.initTransform();
118
+ }
119
+ const avgSacle = ((max - min) / this.model.masterDivisionNumber).toFixed(5);
120
+ for (let i = 0; i < textElements.length; i++) {
121
+ const text = textElements[i];
122
+ if (!text.innerHTML) {
123
+ continue;
124
+ }
125
+ let sacleValue = ((Number(avgSacle) * i) + min).toFixed(0);
126
+ // 整数位和小数位格式化;
127
+ if (this.model.fractionDigits > 0) {
128
+ sacleValue = (sacleValue / Math.pow(10, this.model.fractionDigits)).toFixed(this.model.fractionDigits);
129
+ }
130
+ if (!isNaN(sacleValue)) {
131
+ text.innerHTML = sacleValue;
132
+ if (this.model.minValueType !== VariableValueType.Constant || this.model.maxValueType !== VariableValueType.Constant) {
133
+ // FLEXCLOUD-2619 刻度未对齐问题
134
+ let translateX = 0;
135
+ const sacleLen = sacleValue.toString().length;
136
+ switch (sacleLen) {
137
+ case 1:
138
+ translateX = 13;
139
+ break;
140
+ case 2:
141
+ translateX = 7;
142
+ break;
143
+ case 3:
144
+ translateX = this.model.fractionDigits ? 5 : 0;
145
+ break;
146
+ default:
147
+ if (sacleLen > 3 && this.needAddNumber > 3) {
148
+ translateX = -(sacleLen - 3) * 7;
149
+ }
150
+ break;
151
+ }
152
+ if (this.model.minValueType !== VariableValueType.Constant && this.model.maxValueType === VariableValueType.Constant) {
153
+ const maxLen = this.model.max && this.model.max.toString().length;
154
+ translateX += maxLen > 2 ? (maxLen - 3) * 7 : 0;
155
+ }
156
+ text.transform.baseVal[0].matrix.e = translateX;
157
+ }
158
+ }
159
+ }
160
+ }
161
+ updateVariableValue(value, variableName) {
162
+ this.updateValueObj(value, variableName);
163
+ this.updateScale();
164
+ const variableValue = Number(this.valueObj.value);
165
+ let maxValue = this.model.maxValueType ? this.valueObj.max : this.model.max;
166
+ let minValue = this.model.minValueType ? this.valueObj.min : this.model.min;
167
+ minValue = Number(minValue);
168
+ maxValue = Number(maxValue);
169
+ if (isNaN(minValue) || isNaN(maxValue)) {
170
+ minValue = BarGraphElement.DEFAULT_MIN_VALUE;
171
+ maxValue = BarGraphElement.DEFAULT_MAX_VALUE;
172
+ }
173
+ if (isNaN(variableValue)) {
174
+ return;
175
+ }
48
176
  const useAlarmLimit = this.model.useAlarmLimit;
49
177
  const useAlarmUpperLimit = null != this.model.upperLimit;
50
178
  const useAlarmLowerLimit = null != this.model.lowerLimit;
@@ -112,3 +240,5 @@ export class BarGraphElement extends ReadableElement {
112
240
  }
113
241
  }
114
242
  }
243
+ BarGraphElement.DEFAULT_MIN_VALUE = 0;
244
+ 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":39,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"../service","name":"PermissionChecker","line":39,"character":57},{"__symbolic":"reference","module":"../communication","name":"VariableCommunicator","line":40,"character":30},{"__symbolic":"reference","module":"../config","name":"VariableStore","line":41,"character":23},{"__symbolic":"reference","module":"../localization","name":"Localization","line":42,"character":22},{"__symbolic":"reference","name":"string"}]}],"initTransform":[{"__symbolic":"method"}],"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
  }