@flexem/fc-gui 3.0.0-alpha.12 → 3.0.0-alpha.121

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 (148) hide show
  1. package/CHANGELOG.md +444 -1
  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 +16071 -13357
  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 +2 -0
  11. package/communication/variable/variable-value.d.ts +4 -1
  12. package/communication/variable/variable-value.js +4 -1
  13. package/communication/variable/variable-value.metadata.json +1 -1
  14. package/config/alarm/alarm.store.d.ts +6 -0
  15. package/config/alarm/alarm.store.js +0 -0
  16. package/config/alarm/alarm.store.metadata.json +1 -0
  17. package/config/alarm/get-alarms-args.d.ts +9 -0
  18. package/config/alarm/get-alarms-args.js +9 -0
  19. package/config/alarm/get-alarms-args.metadata.json +1 -0
  20. package/config/alarm/index.d.ts +2 -0
  21. package/config/alarm/index.js +1 -0
  22. package/config/alarm/index.metadata.json +1 -0
  23. package/config/config-store.d.ts +2 -0
  24. package/config/index.d.ts +1 -0
  25. package/config/index.js +1 -0
  26. package/config/index.metadata.json +1 -1
  27. package/elements/air-quality/air-quality-element.d.ts +31 -0
  28. package/elements/air-quality/air-quality-element.js +194 -0
  29. package/elements/air-quality/air-quality-element.metadata.json +1 -0
  30. package/elements/alarm/alarm-element.d.ts +44 -0
  31. package/elements/alarm/alarm-element.js +386 -0
  32. package/elements/alarm/alarm-element.metadata.json +1 -0
  33. package/elements/bar-graph-element.d.ts +10 -2
  34. package/elements/bar-graph-element.js +135 -5
  35. package/elements/bar-graph-element.metadata.json +1 -1
  36. package/elements/base/readable-element.d.ts +6 -1
  37. package/elements/base/readable-element.js +55 -2
  38. package/elements/base/readable-element.metadata.json +1 -1
  39. package/elements/base/state-control-element.d.ts +3 -1
  40. package/elements/base/state-control-element.js +3 -0
  41. package/elements/datetime-display/datetime-display-element.d.ts +1 -0
  42. package/elements/datetime-display/datetime-display-element.js +10 -2
  43. package/elements/datetime-display/datetime-display-element.metadata.json +1 -1
  44. package/elements/datetime-display/time-zone-select-json.d.ts +8 -0
  45. package/elements/datetime-display/time-zone-select-json.js +558 -0
  46. package/elements/historical-curve/historical-curve.element.d.ts +9 -0
  47. package/elements/historical-curve/historical-curve.element.js +252 -13
  48. package/elements/historical-curve/historical-curve.element.metadata.json +1 -1
  49. package/elements/main-element.d.ts +1 -0
  50. package/elements/main-element.js +54 -4
  51. package/elements/main-element.metadata.json +1 -1
  52. package/elements/meter-element.d.ts +7 -1
  53. package/elements/meter-element.js +76 -7
  54. package/elements/meter-element.metadata.json +1 -1
  55. package/elements/numerical-display/numerical-display-element.d.ts +8 -2
  56. package/elements/numerical-display/numerical-display-element.js +55 -11
  57. package/elements/numerical-display/numerical-display-element.metadata.json +1 -1
  58. package/elements/per-view-variable-communicator.d.ts +3 -0
  59. package/elements/per-view-variable-communicator.js +11 -0
  60. package/elements/per-view-variable-communicator.metadata.json +1 -1
  61. package/elements/ring-graph/ring-graph-element.d.ts +13 -1
  62. package/elements/ring-graph/ring-graph-element.js +164 -3
  63. package/elements/ring-graph/ring-graph-element.metadata.json +1 -1
  64. package/elements/scroll-alarm/scroll-alarm-element.d.ts +50 -0
  65. package/elements/scroll-alarm/scroll-alarm-element.js +421 -0
  66. package/elements/scroll-alarm/scroll-alarm-element.metadata.json +1 -0
  67. package/elements/shared/graph/graph-state-element.js +0 -3
  68. package/elements/shared/text/text-element.js +13 -2
  69. package/elements/shared/text/text-state-element.d.ts +0 -1
  70. package/elements/shared/text/text-state-element.js +39 -61
  71. package/elements/shared/text/text-state-element.metadata.json +1 -1
  72. package/elements/switch-indicator-light/bit-switch-operator.d.ts +1 -0
  73. package/elements/switch-indicator-light/bit-switch-operator.js +19 -0
  74. package/elements/switch-indicator-light/bit-switch-operator.metadata.json +1 -1
  75. package/elements/switch-indicator-light/switch-indicator-light-element.d.ts +8 -0
  76. package/elements/switch-indicator-light/switch-indicator-light-element.js +93 -23
  77. package/elements/switch-indicator-light/switch-indicator-light-element.metadata.json +1 -1
  78. package/elements/switch-indicator-light/switch-operator.d.ts +1 -0
  79. package/elements/switch-indicator-light/word-switch-operator.d.ts +1 -0
  80. package/elements/switch-indicator-light/word-switch-operator.js +6 -0
  81. package/elements/switch-indicator-light/word-switch-operator.metadata.json +1 -1
  82. package/elements/video/video-element.d.ts +4 -0
  83. package/elements/video/video-element.js +81 -21
  84. package/elements/video/video-element.metadata.json +1 -1
  85. package/elements/view-operation/view-operation.element.js +8 -0
  86. package/elements/weather/weater-element.js +0 -1
  87. package/gui/gui-context.d.ts +2 -1
  88. package/gui/gui-host.d.ts +1 -1
  89. package/gui/gui-view.d.ts +2 -0
  90. package/gui/gui-view.js +20 -0
  91. package/gui/gui-view.metadata.json +1 -1
  92. package/gui/gui.component.d.ts +3 -0
  93. package/gui/gui.component.js +15 -2
  94. package/gui/gui.component.metadata.json +1 -1
  95. package/localization/localization.service.d.ts +7 -0
  96. package/localization/localization.service.js +10 -3
  97. package/localization/localization.service.metadata.json +1 -1
  98. package/localization/localization.service.zh_CN.js +8 -1
  99. package/localization/localization.service.zh_CN.metadata.json +1 -1
  100. package/modal/write-value/write-value-modal-args.d.ts +3 -1
  101. package/modal/write-value/write-value-modal-args.js +2 -1
  102. package/modal/write-value/write-value-modal-args.metadata.json +1 -1
  103. package/modal/write-value/write-value-modal.component.d.ts +8 -7
  104. package/modal/write-value/write-value-modal.component.html +9 -4
  105. package/modal/write-value/write-value-modal.component.js +42 -15
  106. package/modal/write-value/write-value-modal.component.metadata.json +1 -1
  107. package/model/air-quality/air-quality-info.d.ts +23 -0
  108. package/model/air-quality/air-quality-info.js +4 -0
  109. package/model/air-quality/air-quality-info.metadata.json +1 -0
  110. package/model/air-quality/air-quality.model.d.ts +7 -0
  111. package/model/air-quality/air-quality.model.js +0 -0
  112. package/model/air-quality/air-quality.model.metadata.json +1 -0
  113. package/model/alarm/alarm.model.d.ts +13 -0
  114. package/model/alarm/alarm.model.js +0 -0
  115. package/model/alarm/alarm.model.metadata.json +1 -0
  116. package/model/bar-graph/bar-graph.d.ts +4 -0
  117. package/model/base/readable-model.d.ts +4 -0
  118. package/model/datetime-display/datetime-display.d.ts +1 -0
  119. package/model/historical-curve/historical-curve-axis-settings.d.ts +11 -0
  120. package/model/historical-curve/historical-curve-axis-settings.js +5 -0
  121. package/model/historical-curve/historical-curve-axis-settings.metadata.json +1 -1
  122. package/model/historical-curve/historical-curve-chanel.model.d.ts +8 -0
  123. package/model/meter/meter.d.ts +4 -0
  124. package/model/ring-graph/ring-graph.model.d.ts +8 -0
  125. package/model/scroll-alarm/scroll-alarm.model.d.ts +21 -0
  126. package/model/scroll-alarm/scroll-alarm.model.js +0 -0
  127. package/model/scroll-alarm/scroll-alarm.model.metadata.json +1 -0
  128. package/model/switch-indicator-light/bit-switch-operation.d.ts +2 -1
  129. package/model/switch-indicator-light/bit-switch-operation.js +1 -0
  130. package/model/switch-indicator-light/bit-switch-operation.metadata.json +1 -1
  131. package/package.json +1 -1
  132. package/remote/communication/variable/remote-variable-communicator.d.ts +7 -0
  133. package/remote/communication/variable/remote-variable-communicator.js +47 -1
  134. package/remote/communication/variable/remote-variable-communicator.metadata.json +1 -1
  135. package/remote/communication/variable/remote-variable-protocol.d.ts +5 -0
  136. package/service/index.d.ts +1 -0
  137. package/service/index.metadata.json +1 -1
  138. package/service/released-variable/index.d.ts +1 -0
  139. package/service/released-variable/index.js +0 -0
  140. package/service/released-variable/index.metadata.json +1 -0
  141. package/service/released-variable/released-variable.service.d.ts +4 -0
  142. package/service/released-variable/released-variable.service.js +0 -0
  143. package/service/released-variable/released-variable.service.metadata.json +1 -0
  144. package/service/weather.service.d.ts +1 -0
  145. package/shared/gui-consts.d.ts +3 -0
  146. package/shared/gui-consts.js +3 -0
  147. package/shared/gui-consts.metadata.json +1 -1
  148. package/utils/data-type/fbox-data-type.service.js +40 -0
@@ -0,0 +1,421 @@
1
+ import * as d3 from 'd3';
2
+ import { ConditionalDynamicDisplayElement } from '../base/conditional-dynamic-display-element';
3
+ import { GetAlarmsArgs } from '../../config';
4
+ import * as moment from 'moment';
5
+ import { LOGGER_SERVICE_TOKEN } from '../../logger';
6
+ var ScrollAlarmElementStatus;
7
+ (function (ScrollAlarmElementStatus) {
8
+ ScrollAlarmElementStatus[ScrollAlarmElementStatus["Normal"] = 0] = "Normal";
9
+ ScrollAlarmElementStatus[ScrollAlarmElementStatus["Loading"] = 1] = "Loading"; // 加载中
10
+ })(ScrollAlarmElementStatus || (ScrollAlarmElementStatus = {}));
11
+ export class ScrollAlarmElement extends ConditionalDynamicDisplayElement {
12
+ constructor(element, injector, permissionChecker, variableCommunicator, variableStore, alarmsStore, signalRAppId) {
13
+ var _a, _b, _c, _d, _e;
14
+ super(element, permissionChecker, variableCommunicator, variableStore, signalRAppId);
15
+ this.alarmsStore = alarmsStore;
16
+ this.elementStatus = ScrollAlarmElementStatus.Loading;
17
+ this.alarmNames = [];
18
+ this.isScrolling = false;
19
+ this.isDisposed = false;
20
+ // 新的分页和滚动逻辑变量
21
+ this.currentPage = 1;
22
+ this.maxResultCount = 3; // 每页数据量
23
+ this.displayedItems = []; // 当前显示的所有数据
24
+ this.pageWidths = []; // 存储每页的宽度
25
+ this.totalWidth = 0; // 所有显示数据的总宽度
26
+ this.currentLeft = 0;
27
+ this.autoCycle = true;
28
+ this.hasMoreData = true;
29
+ this.isLoadingNextPage = false;
30
+ this.rootElement.selectAll('*').remove();
31
+ this.setStatusAsLoading();
32
+ this.logger = injector.get(LOGGER_SERVICE_TOKEN);
33
+ this.variableCommunicator = variableCommunicator;
34
+ this.autoCycle = (_b = (_a = this.model.generalSetting) === null || _a === void 0 ? void 0 : _a.autoCycle) !== null && _b !== void 0 ? _b : true;
35
+ this.maxResultCount = (_d = (_c = this.model.generalSetting) === null || _c === void 0 ? void 0 : _c.pageSize) !== null && _d !== void 0 ? _d : 3;
36
+ if (this.model.filterSetting) {
37
+ this.alarmNames = this.model.filterSetting.detailsData.map(item => item.name);
38
+ this.updateQueryTimeRange();
39
+ // 监听告警更新
40
+ // variableCommunicator.subscribeUserDeviceAlarms(signalRAppId).subscribe(alarms => {
41
+ // alarms.forEach(alarm => {
42
+ // if (this.alarmNames.indexOf(alarm.name) !== -1) {
43
+ // this.getAlarmData();
44
+ // return;
45
+ // }
46
+ // });
47
+ // });
48
+ // 初始化显示容器
49
+ this.initDisplayContainer();
50
+ // 获取字体设置
51
+ this.headerFont = ((_e = this.model.generalSetting) === null || _e === void 0 ? void 0 : _e.headerFont) || {};
52
+ const fontStyle = [];
53
+ if (this.headerFont.isBold)
54
+ fontStyle.push('bold');
55
+ if (this.headerFont.isItalic)
56
+ fontStyle.push('italic');
57
+ if (this.headerFont.isUnderline)
58
+ fontStyle.push('underline');
59
+ fontStyle.push(`${this.headerFont.fontSize || '16px'}`);
60
+ fontStyle.push(`${this.headerFont.fontFamily || 'Microsoft YaHei'}`);
61
+ this.fontString = fontStyle.join(' ');
62
+ this.getAlarmData();
63
+ }
64
+ else {
65
+ this.displayedItems = [];
66
+ if (this.allAlarmsContainer) {
67
+ this.allAlarmsContainer.innerHTML = '';
68
+ this.totalWidth = 0;
69
+ this.pageWidths = [];
70
+ }
71
+ }
72
+ }
73
+ dispose() {
74
+ this.isDisposed = true;
75
+ clearInterval(this.scrollIntervalId);
76
+ clearTimeout(this.getAlarmDataId);
77
+ if (this.element && this.element.tooltip) {
78
+ this.element.tooltip.hidden(true);
79
+ }
80
+ this.logger.debug(`[GUI]Dispose Scroll Alarm Refresh Interval:${d3.time.format('%x %X')(new Date())}`);
81
+ // 重置所有状态
82
+ this.isScrolling = false;
83
+ }
84
+ getAlarmData() {
85
+ if (this.isDisposed || this.isLoadingNextPage)
86
+ return;
87
+ this.isLoadingNextPage = true;
88
+ // Only show loading for the first page load
89
+ if (this.currentPage === 1 && this.displayedItems.length === 0) {
90
+ this.setStatusAsLoading();
91
+ }
92
+ clearTimeout(this.getAlarmDataId);
93
+ this.getAlarmDataId = setTimeout(() => {
94
+ this.updateQueryTimeRange();
95
+ const skipCount = (this.currentPage - 1) * this.maxResultCount;
96
+ const input = new GetAlarmsArgs(this.alarmNames, this.startTime, this.endTime, this.maxResultCount, skipCount);
97
+ this.alarmsStore.getHistoryAlarms(input).subscribe(result => {
98
+ this.isLoadingNextPage = false;
99
+ if (!result.error && result.items && result.items.length > 0) {
100
+ const newPage = result.items;
101
+ // 检查是否还有更多数据
102
+ if (!this.autoCycle && newPage.length < this.maxResultCount) {
103
+ this.hasMoreData = false;
104
+ }
105
+ else {
106
+ this.hasMoreData = true;
107
+ }
108
+ // 添加新页数据
109
+ this.displayedItems = this.displayedItems.concat(newPage);
110
+ // 渲染新页
111
+ this.renderNewPage(newPage);
112
+ // 更新页码
113
+ this.currentPage++;
114
+ // 检查是否需要删除旧页(保持最多3页)
115
+ if (this.currentPage > 4) {
116
+ this.removeOldestPage();
117
+ }
118
+ // 如果是首次加载或还没有开始滚动,初始化滚动
119
+ if (!this.isScrolling && this.displayedItems.length > 0) {
120
+ this.initScrolling();
121
+ }
122
+ this.setStatusAsNormal();
123
+ }
124
+ else {
125
+ // 如果没有数据且自动循环开启,循环回到第一页而不清空数据
126
+ if (this.autoCycle) {
127
+ // 直接跳转到第一页
128
+ this.currentPage = 1;
129
+ // 继续加载数据(会自动添加到末尾)
130
+ this.getAlarmData();
131
+ }
132
+ else {
133
+ this.hasMoreData = false;
134
+ this.setStatusAsNormal();
135
+ }
136
+ }
137
+ }, error => {
138
+ this.isLoadingNextPage = false;
139
+ this.setStatusAsNormal();
140
+ this.logger.error('Failed to get alarm data:', error);
141
+ });
142
+ }, 500);
143
+ }
144
+ initDisplayContainer() {
145
+ var _a;
146
+ const elementHeight = this.model.size.height;
147
+ const elementWidth = this.model.size.width;
148
+ // 创建foreignObject作为容器
149
+ this.element = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject');
150
+ this.element.setAttribute('width', elementWidth.toString());
151
+ this.element.setAttribute('height', elementHeight.toString());
152
+ this.$element.append(this.element);
153
+ // 创建背景容器,应用headerFillColor背景色
154
+ this.container = document.createElement('div');
155
+ this.container.style.cssText = `
156
+ height: ${elementHeight}px;
157
+ width: 100%;
158
+ background-color: ${((_a = this.model.generalSetting) === null || _a === void 0 ? void 0 : _a.headerFillColor) || '#ffffff'};
159
+ display: flex;
160
+ align-items: center;
161
+ overflow: hidden;
162
+ position: relative;
163
+ border: 1px solid #8ea0aa;
164
+ `;
165
+ this.element.appendChild(this.container);
166
+ // 创建一个大容器来包含所有告警项,初始位置在左侧
167
+ this.allAlarmsContainer = document.createElement('div');
168
+ this.allAlarmsContainer.style.cssText = `
169
+ position: absolute;
170
+ left: 0px;
171
+ top: 50%;
172
+ transform: translateY(-50%);
173
+ display: flex;
174
+ align-items: center;
175
+ gap: 80px;
176
+ `;
177
+ this.container.appendChild(this.allAlarmsContainer);
178
+ // 添加鼠标悬停暂停和恢复滚动功能
179
+ this.container.addEventListener('mouseenter', () => this.pauseScroll());
180
+ this.container.addEventListener('mouseleave', () => this.resumeScroll());
181
+ }
182
+ renderNewPage(pageData) {
183
+ let pageWidth = 0;
184
+ // 为每个告警数据创建文本容器
185
+ pageData.forEach((alarm) => {
186
+ var _a, _b, _c, _d, _e, _f, _g, _h;
187
+ // 创建告警文本容器
188
+ const textContainer = document.createElement('div');
189
+ textContainer.style.cssText = `
190
+ font: ${this.fontString};
191
+ color: ${this.headerFont.color || '#E95F5F'};
192
+ white-space: nowrap;
193
+ overflow: visible;
194
+ `;
195
+ // 构建告警信息内容,根据配置决定显示哪些字段
196
+ const contentParts = [];
197
+ // 显示触发时间
198
+ if (((_a = this.model.generalSetting) === null || _a === void 0 ? void 0 : _a.showTriggerTime) && alarm.triggeredTime) {
199
+ const formattedTime = moment(alarm.triggeredTime).format('YYYY/MM/DD HH:mm:ss');
200
+ contentParts.push(formattedTime);
201
+ }
202
+ // 获取当前语言环境
203
+ const language = ((_d = (_c = (_b = window.abp) === null || _b === void 0 ? void 0 : _b.localization) === null || _c === void 0 ? void 0 : _c.currentLanguage) === null || _d === void 0 ? void 0 : _d.name) || 'zh-Hans';
204
+ const isChinese = language === 'zh-Hans' || language === 'zh';
205
+ // 显示告警等级
206
+ if (((_e = this.model.generalSetting) === null || _e === void 0 ? void 0 : _e.showAlarmLevel) && alarm.alarmLevel !== undefined) {
207
+ const levelMap = isChinese ? ['警告', '次要', '主要', '严重'] : ['Warning', 'Minor', 'Major', 'Critical'];
208
+ const alarmLevel = levelMap[alarm.alarmLevel] || (isChinese ? '警告' : 'Warning');
209
+ contentParts.push(alarmLevel);
210
+ }
211
+ // 显示告警名称
212
+ if (((_f = this.model.generalSetting) === null || _f === void 0 ? void 0 : _f.showAlarmName) && alarm.name) {
213
+ contentParts.push(alarm.name);
214
+ }
215
+ // 显示告警状态
216
+ if (((_g = this.model.generalSetting) === null || _g === void 0 ? void 0 : _g.showAlarmState) && alarm.state !== undefined) {
217
+ const stateMap = isChinese ? ['触发/未确认', '触发/已确认', '恢复/未确认', '恢复/已确认'] : ['Triggered/Unconfirmed', 'Triggered/Confirmed', 'Restored/Unconfirmed', 'Restored/Confirmed'];
218
+ const alarmState = stateMap[alarm.state] || (isChinese ? '触发/未确认' : 'Triggered/Unconfirmed');
219
+ contentParts.push(alarmState);
220
+ }
221
+ // 显示告警内容
222
+ if (((_h = this.model.generalSetting) === null || _h === void 0 ? void 0 : _h.showAlarmContent) && alarm.message) {
223
+ contentParts.push(alarm.message);
224
+ }
225
+ // 将所有显示字段用空格连接,确保一行显示
226
+ const textContent = contentParts.join(' ');
227
+ textContainer.textContent = textContent;
228
+ this.allAlarmsContainer.appendChild(textContainer);
229
+ // 计算文本宽度
230
+ const textWidth = textContainer.offsetWidth;
231
+ pageWidth += textWidth + 80; // 80是gap大小
232
+ });
233
+ // 移除最后一个gap
234
+ if (pageWidth > 0) {
235
+ pageWidth -= 80;
236
+ }
237
+ // 保存页宽度
238
+ this.pageWidths.push(pageWidth);
239
+ this.totalWidth += pageWidth;
240
+ }
241
+ removeOldestPage() {
242
+ // 移除最旧的一页数据
243
+ this.displayedItems.splice(0, this.maxResultCount);
244
+ const oldPageWidth = this.pageWidths.shift() || 0;
245
+ // 更新总宽度
246
+ this.totalWidth -= oldPageWidth;
247
+ // 从DOM中移除最旧的元素
248
+ const elementsToRemove = Array.from(this.allAlarmsContainer.children).slice(0, this.maxResultCount);
249
+ elementsToRemove.forEach(element => {
250
+ this.allAlarmsContainer.removeChild(element);
251
+ });
252
+ // 调整当前left位置(保持视觉位置不变)- 这里需要等DOM更新完成后再调整
253
+ requestAnimationFrame(() => {
254
+ this.currentLeft += oldPageWidth;
255
+ this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
256
+ });
257
+ }
258
+ resetToFirstPage() {
259
+ // 重置到第一页,但保持现有数据和位置(无缝循环)
260
+ this.currentPage = 1;
261
+ this.hasMoreData = true;
262
+ // 直接加载第一页数据,不需要清空现有内容
263
+ this.getAlarmData();
264
+ }
265
+ scrollContent() {
266
+ if (this.displayedItems.length <= 0)
267
+ return;
268
+ // 每次滚动的距离
269
+ const scrollStep = 2; // 减小滚动步长,使滚动更平滑
270
+ // 更新位置 - 从右往左滚动
271
+ this.currentLeft -= scrollStep;
272
+ // 检查是否需要加载下一页
273
+ if (this.hasMoreData && !this.isLoadingNextPage) {
274
+ const currentPosition = Math.abs(this.currentLeft);
275
+ const loadedWidth = this.totalWidth - (this.pageWidths[this.pageWidths.length - 1] || 0);
276
+ // 当滚动到已加载内容的60%时,加载下一页(提前预加载,确保无缝衔接)
277
+ if (currentPosition > loadedWidth * 0.6) {
278
+ this.getAlarmData();
279
+ }
280
+ }
281
+ // 如果所有内容完全滚动出容器左侧,根据autoCycle决定是否重置
282
+ // 添加额外的偏移量(比如100px),确保最后两个字也能完全滚出视图
283
+ if (Math.abs(this.currentLeft) > this.totalWidth + 100) {
284
+ if (this.autoCycle) {
285
+ if (this.hasMoreData) {
286
+ // 加载下一页
287
+ this.getAlarmData();
288
+ }
289
+ else {
290
+ // 重置到第一页
291
+ this.resetToFirstPage();
292
+ }
293
+ // 计算新加载页面的宽度(如果有)
294
+ const newPageWidth = this.pageWidths[this.pageWidths.length - 1] || 0;
295
+ // 设置位置到新加载页面的起始位置,实现无缝衔接
296
+ this.currentLeft = -(this.totalWidth - newPageWidth);
297
+ this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
298
+ }
299
+ else {
300
+ // 非循环滚动:停止滚动
301
+ clearInterval(this.scrollIntervalId);
302
+ this.isScrolling = false;
303
+ }
304
+ }
305
+ else {
306
+ this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
307
+ }
308
+ }
309
+ initScrolling() {
310
+ clearInterval(this.scrollIntervalId);
311
+ // 如果没有滚动设置或自动播放为false,则不启动滚动
312
+ if (this.displayedItems.length === 0) {
313
+ return;
314
+ }
315
+ const scrollInterval = 100; // 默认100ms,滚动更流畅
316
+ // 如果当前位置在容器右侧,延迟启动滚动确保内容渲染完成
317
+ if (this.currentLeft > this.container.clientWidth * 0.5) {
318
+ setTimeout(() => {
319
+ this.isScrolling = true;
320
+ this.scrollIntervalId = setInterval(() => {
321
+ if (this.isScrolling) {
322
+ this.scrollContent();
323
+ }
324
+ }, scrollInterval);
325
+ }, 500);
326
+ }
327
+ else {
328
+ this.isScrolling = true;
329
+ this.scrollIntervalId = setInterval(() => {
330
+ if (this.isScrolling) {
331
+ this.scrollContent();
332
+ }
333
+ }, scrollInterval);
334
+ }
335
+ }
336
+ pauseScroll() {
337
+ this.isScrolling = false;
338
+ }
339
+ resumeScroll() {
340
+ this.isScrolling = true;
341
+ }
342
+ updateQueryTimeRange() {
343
+ this.endTime = moment();
344
+ console.log(this.model.generalSetting, 1);
345
+ switch (this.model.generalSetting.displayPeriod) {
346
+ case 1:
347
+ this.startTime = moment().subtract(1, 'hours');
348
+ break;
349
+ case 3:
350
+ this.startTime = moment().subtract(7, 'days');
351
+ break;
352
+ case 4:
353
+ this.startTime = moment().subtract(30, 'days');
354
+ break;
355
+ case 5:
356
+ this.startTime = moment().subtract(1, 'years');
357
+ break;
358
+ case 6:
359
+ this.startTime = moment().subtract(30, 'minutes');
360
+ break;
361
+ case 7:
362
+ this.startTime = moment().subtract(8, 'hours');
363
+ break;
364
+ default:
365
+ this.startTime = moment().subtract(1, 'days');
366
+ }
367
+ }
368
+ setStatusAsNormal() {
369
+ this.elementStatus = ScrollAlarmElementStatus.Normal;
370
+ this.clearStatus();
371
+ }
372
+ setStatusAsLoading() {
373
+ this.elementStatus = ScrollAlarmElementStatus.Loading;
374
+ this.renderStatus('assets/img/loading.svg', '#226abc');
375
+ }
376
+ renderStatus(icon, stroke) {
377
+ if (this.elementStatus === ScrollAlarmElementStatus.Normal) {
378
+ this.clearStatus();
379
+ return;
380
+ }
381
+ this.rootElement.append('rect').attr('id', 'StateFrame').attr('fill', 'transparent')
382
+ .attr('width', this.model.size.width)
383
+ .attr('height', this.model.size.height);
384
+ const document = this.$element[0].ownerDocument;
385
+ const currentRect = this.$element.find('rect#StateFrame').first();
386
+ if (!currentRect.length) {
387
+ return;
388
+ }
389
+ this.$element.find('image#StateImage').remove();
390
+ const imgObj = document.createElementNS('http://www.w3.org/2000/svg', 'image');
391
+ if (imgObj) {
392
+ let x = Number(currentRect[0].getAttribute('width')) - 20;
393
+ const currentRectX = currentRect[0].getAttribute('x');
394
+ if (currentRectX !== null) {
395
+ x += Number(currentRectX);
396
+ }
397
+ currentRect[0].setAttribute('stroke', stroke);
398
+ currentRect[0].setAttribute('stroke-opacity', '0.5');
399
+ imgObj.href.baseVal = icon;
400
+ imgObj.setAttributeNS(null, 'id', 'StateImage');
401
+ imgObj.setAttributeNS(null, 'x', x.toString());
402
+ imgObj.setAttributeNS(null, 'y', '0');
403
+ imgObj.setAttributeNS(null, 'height', '20px');
404
+ imgObj.setAttributeNS(null, 'width', '20px');
405
+ const titleElement = document.createElementNS('http://www.w3.org/2000/svg', 'title');
406
+ imgObj.appendChild(titleElement);
407
+ this.$element.append(imgObj);
408
+ }
409
+ }
410
+ clearStatus() {
411
+ const currentRect = this.$element.find('rect#StateFrame').first();
412
+ if (!currentRect.length) {
413
+ return;
414
+ }
415
+ const stroke = currentRect[0].getAttribute('stroke');
416
+ if (stroke) {
417
+ currentRect[0].removeAttribute('stroke');
418
+ }
419
+ this.$element.find('image#StateImage').remove();
420
+ }
421
+ }
@@ -0,0 +1 @@
1
+ [{"__symbolic":"module","version":4,"metadata":{"ScrollAlarmElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../base/conditional-dynamic-display-element","name":"ConditionalDynamicDisplayElement","line":17,"character":40},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":47,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":48,"character":18},{"__symbolic":"reference","module":"../../service","name":"PermissionChecker","line":49,"character":27},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":50,"character":30},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":51,"character":23},{"__symbolic":"reference","module":"../../config","name":"AlarmsStore","line":52,"character":38},{"__symbolic":"reference","name":"string"}]}],"dispose":[{"__symbolic":"method"}],"getAlarmData":[{"__symbolic":"method"}],"initDisplayContainer":[{"__symbolic":"method"}],"renderNewPage":[{"__symbolic":"method"}],"removeOldestPage":[{"__symbolic":"method"}],"resetToFirstPage":[{"__symbolic":"method"}],"scrollContent":[{"__symbolic":"method"}],"initScrolling":[{"__symbolic":"method"}],"pauseScroll":[{"__symbolic":"method"}],"resumeScroll":[{"__symbolic":"method"}],"updateQueryTimeRange":[{"__symbolic":"method"}],"setStatusAsNormal":[{"__symbolic":"method"}],"setStatusAsLoading":[{"__symbolic":"method"}],"renderStatus":[{"__symbolic":"method"}],"clearStatus":[{"__symbolic":"method"}]}}}}]
@@ -62,9 +62,6 @@ export class GraphStateElement {
62
62
  }
63
63
  }
64
64
  getImageElement() {
65
- if (this.imageElement && /iPhone|iPod/i.test(navigator.userAgent)) {
66
- this.removeImageElement();
67
- }
68
65
  if (!this.imageElement) {
69
66
  this.imageElement = document.createElementNS('http://www.w3.org/2000/svg', 'image');
70
67
  this.imageElement.setAttribute('width', this.width + '');
@@ -19,7 +19,7 @@ export class TextElementModal {
19
19
  return textElement;
20
20
  }
21
21
  createNewForeignObjectText(content, font, width, height, isVariableText) {
22
- if (font) {
22
+ if (font && !font.fontFamily.includes(',msyh')) {
23
23
  font.fontFamily += ',msyh';
24
24
  }
25
25
  const bodyDiv = document.createElement('div');
@@ -36,7 +36,7 @@ export class TextElementModal {
36
36
  for (let index = 0; index < textArray.length; index++) {
37
37
  const textDiv = document.createElement('div');
38
38
  textDiv.className = 'text-list';
39
- textDiv.innerHTML = textArray[index] ? textArray[index] : '&nbsp;';
39
+ const innerHTML = textArray[index] ? textArray[index] : '&nbsp;';
40
40
  let fontString = '';
41
41
  if (font.isItalic) {
42
42
  fontString += 'italic ';
@@ -45,12 +45,23 @@ export class TextElementModal {
45
45
  fontString += 'bold ';
46
46
  }
47
47
  let lineHeight = 0;
48
+ // chrome支持可显示最小字体大小为12px, 更小字体通过缩放实现
49
+ const minFontSize = 12;
48
50
  lineHeight = parseInt(font.fontSize, 10) + 5;
49
51
  fontString += font.fontSize + '/' + lineHeight.toString() + 'px ' + font.fontFamily;
50
52
  textDiv.style.cssText = `color: ${font.color};word-break: break-all;font: ${fontString};`;
51
53
  if (font.isUnderline) {
52
54
  textDiv.style.textDecoration = 'underline';
53
55
  }
56
+ const spanText = document.createElement('span');
57
+ spanText.style.cssText = `
58
+ display: contents;
59
+ transform: scale(${parseInt(font.fontSize, 10) > minFontSize ? 1 : parseInt(font.fontSize, 10) / minFontSize});
60
+ width: 100%;
61
+ height: 100%;
62
+ `;
63
+ spanText.innerHTML = innerHTML;
64
+ textDiv.appendChild(spanText);
54
65
  fragment.appendChild(textDiv);
55
66
  }
56
67
  bodyDiv.appendChild(fragment);
@@ -16,7 +16,6 @@ export declare class TextStateElement {
16
16
  constructor(textStates: TextState[], width: number, height: number, logger: LoggerService, version?: number, faultFlickers?: IndicatorLightFaultFlicker[]);
17
17
  switchToState(stateId: number): void;
18
18
  private getforeignObjectElement;
19
- private createNewForeignObjectText;
20
19
  private removeForeignObjectlement;
21
20
  private doFaultFlicker;
22
21
  private clearFlickerInterval;
@@ -1,5 +1,4 @@
1
1
  import { Flicker } from '../../../model';
2
- import { isNil } from 'lodash';
3
2
  export class TextStateElement {
4
3
  constructor(textStates, width, height, logger, version, faultFlickers) {
5
4
  this.textStates = textStates;
@@ -23,7 +22,7 @@ export class TextStateElement {
23
22
  return;
24
23
  }
25
24
  const content = textState.text.content;
26
- if (content === '') {
25
+ if (content === '' || content == null) {
27
26
  this.removeForeignObjectlement();
28
27
  return;
29
28
  }
@@ -33,72 +32,51 @@ export class TextStateElement {
33
32
  this.logger.debug('The font is undefined.');
34
33
  return;
35
34
  }
36
- const foreignObjectElement = this.getforeignObjectElement();
37
- foreignObjectElement.innerHTML = '';
38
- const text = this.createNewForeignObjectText(content, font);
39
- foreignObjectElement.appendChild(text);
40
- this.doFaultFlicker(foreignObjectElement, stateId);
35
+ const textElement = this.getforeignObjectElement();
36
+ // 清空旧内容
37
+ textElement.textContent = '';
38
+ // 设置 text-anchor 和 dominant-baseline
39
+ textElement.setAttribute('text-anchor', 'middle');
40
+ textElement.setAttribute('dominant-baseline', 'middle');
41
+ textElement.setAttribute('pointer-events', 'auto');
42
+ // 拆分换行
43
+ const lines = content.split('\n');
44
+ const fontSize = parseInt(font.fontSize, 10);
45
+ const lineHeight = fontSize + 4;
46
+ // 总高度 = 行数 * 行高
47
+ const totalHeight = lines.length * lineHeight;
48
+ // 调整文本整体垂直居中(通过 dy)
49
+ const startY = (this.height / 2) - (totalHeight / 2) + (lineHeight / 2);
50
+ // 添加每行文本
51
+ for (let i = 0; i < lines.length; i++) {
52
+ const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');
53
+ tspan.setAttribute('x', (this.width / 2).toString());
54
+ tspan.setAttribute('y', startY + i * lineHeight + 'px');
55
+ tspan.textContent = lines[i].replace(/ /g, '\u00A0');
56
+ tspan.setAttribute('font-size', font.fontSize);
57
+ tspan.setAttribute('fill', font.color);
58
+ tspan.setAttribute('font-family', font.fontFamily);
59
+ tspan.setAttribute('font-weight', font.isBold ? 'bold' : 'normal');
60
+ tspan.setAttribute('font-style', font.isItalic ? 'italic' : 'normal');
61
+ tspan.setAttribute('text-decoration', font.isUnderline ? 'underline' : 'none');
62
+ tspan.setAttribute('text-anchor', 'middle');
63
+ tspan.setAttribute('dominant-baseline', 'middle');
64
+ textElement.appendChild(tspan);
65
+ }
66
+ this.doFaultFlicker(textElement, stateId);
41
67
  }
42
68
  getforeignObjectElement() {
43
69
  if (!this.textElement) {
44
- this.textElement = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject');
45
- this.textElement.setAttribute('width', this.width.toString());
46
- this.textElement.setAttribute('height', this.height.toString());
70
+ this.textElement = document.createElementNS('http://www.w3.org/2000/svg', 'text');
71
+ this.textElement.setAttribute('x', (this.width / 2).toString());
72
+ this.textElement.setAttribute('y', (this.height / 2).toString());
73
+ this.textElement.setAttribute('text-anchor', 'middle');
74
+ this.textElement.setAttribute('dominant-baseline', 'middle');
75
+ this.textElement.setAttribute('pointer-events', 'auto'); // 确保能接收事件
47
76
  this._element.appendChild(this.textElement);
48
77
  }
49
78
  return this.textElement;
50
79
  }
51
- createNewForeignObjectText(content, font) {
52
- if (font) {
53
- font.fontFamily += ',msyh';
54
- }
55
- const bodyDiv = document.createElement('div');
56
- bodyDiv.style.textAlign = font.textAlign ? font.textAlign : 'center';
57
- bodyDiv.style.userSelect = 'none';
58
- bodyDiv.style.display = 'table-cell';
59
- bodyDiv.style.verticalAlign = 'middle';
60
- if (isNil(content)) {
61
- content = '';
62
- }
63
- let textArray = content.toString().split('\n');
64
- textArray = textArray.map(item => {
65
- return item.toString().replace(/\s/g, '&nbsp;');
66
- });
67
- const fragment = document.createDocumentFragment();
68
- for (let index = 0; index < textArray.length; index++) {
69
- const textDiv = document.createElement('div');
70
- textDiv.innerHTML = textArray[index] ? textArray[index] : '&nbsp;';
71
- let fontString = '';
72
- if (font.isItalic) {
73
- fontString += 'italic ';
74
- }
75
- if (font.isBold) {
76
- fontString += 'bold ';
77
- }
78
- textDiv.style.wordBreak = 'break-word';
79
- textDiv.style.color = font.color;
80
- let lineHeight = 0;
81
- lineHeight = parseInt(font.fontSize, 10) + 5;
82
- fontString += font.fontSize + 'px/' + lineHeight + 'px ' + font.fontFamily;
83
- textDiv.style.font = fontString;
84
- if (font.isUnderline) {
85
- textDiv.style.textDecoration = 'underline';
86
- }
87
- fragment.appendChild(textDiv);
88
- }
89
- bodyDiv.appendChild(fragment);
90
- const contentDiv = document.createElement('div');
91
- contentDiv.style.display = 'table';
92
- contentDiv.style.width = '100%';
93
- contentDiv.style.height = '100%';
94
- contentDiv.appendChild(bodyDiv);
95
- const containerDiv = document.createElement('div');
96
- containerDiv.style.overflow = 'hidden';
97
- containerDiv.style.width = this.width.toString() + 'px';
98
- containerDiv.style.height = this.height.toString() + 'px';
99
- containerDiv.appendChild(contentDiv);
100
- return containerDiv;
101
- }
102
80
  removeForeignObjectlement() {
103
81
  if (this.textElement) {
104
82
  this._element.removeChild(this.textElement);
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"TextStateElement":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","module":"./text-state.model","name":"TextState","line":18,"character":45}]},{"__symbolic":"reference","name":"number"},{"__symbolic":"reference","name":"number"},{"__symbolic":"reference","module":"../../../logger","name":"LoggerService","line":21,"character":33},{"__symbolic":"reference","name":"number"},{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","module":"../../../model/switch-indicator-light/indicator-light-fault-flicker","name":"IndicatorLightFaultFlicker","line":23,"character":41}]}]}],"switchToState":[{"__symbolic":"method"}],"getforeignObjectElement":[{"__symbolic":"method"}],"createNewForeignObjectText":[{"__symbolic":"method"}],"removeForeignObjectlement":[{"__symbolic":"method"}],"doFaultFlicker":[{"__symbolic":"method"}],"clearFlickerInterval":[{"__symbolic":"method"}]}}}}]
1
+ [{"__symbolic":"module","version":4,"metadata":{"TextStateElement":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","module":"./text-state.model","name":"TextState","line":17,"character":45}]},{"__symbolic":"reference","name":"number"},{"__symbolic":"reference","name":"number"},{"__symbolic":"reference","module":"../../../logger","name":"LoggerService","line":20,"character":33},{"__symbolic":"reference","name":"number"},{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","module":"../../../model/switch-indicator-light/indicator-light-fault-flicker","name":"IndicatorLightFaultFlicker","line":22,"character":41}]}]}],"switchToState":[{"__symbolic":"method"}],"getforeignObjectElement":[{"__symbolic":"method"}],"removeForeignObjectlement":[{"__symbolic":"method"}],"doFaultFlicker":[{"__symbolic":"method"}],"clearFlickerInterval":[{"__symbolic":"method"}]}}}}]
@@ -15,4 +15,5 @@ export declare class BitSwitchOperator implements SwitchOperator {
15
15
  constructor(settings: BitSwitchSettings, variableCommunicator: VariableCommunicator, variableStore: VariableStore, signalRAppId: string);
16
16
  canExecute(): boolean;
17
17
  execute(): Promise<VariableOptionModel>;
18
+ writeValue(value: any): Promise<VariableOptionModel>;
18
19
  }
@@ -72,6 +72,8 @@ export class BitSwitchOperator {
72
72
  }
73
73
  }
74
74
  break;
75
+ case BitSwitchOperation.Restoration:
76
+ break;
75
77
  default:
76
78
  throw new Error(`Unknown BitSwitchOperation:${settings.operation}`);
77
79
  }
@@ -85,4 +87,21 @@ export class BitSwitchOperator {
85
87
  newValue: newValue
86
88
  });
87
89
  }
90
+ writeValue(value) {
91
+ if (this.settings.isBitwiseIndex) {
92
+ this.variableCommunicator.writeWordByBit(this.variableName, this.settings.bitIndex, value).subscribe();
93
+ }
94
+ else {
95
+ this.variableCommunicator.write(this.variableName, value).subscribe();
96
+ }
97
+ let originValue;
98
+ if (this.currentValue && this.currentValue.value !== undefined) {
99
+ originValue = this.currentValue.value;
100
+ }
101
+ return Promise.resolve({
102
+ variableName: this.variableName,
103
+ originValue: originValue,
104
+ newValue: value
105
+ });
106
+ }
88
107
  }