@flexem/fc-gui 3.0.0-alpha.13 → 3.0.0-alpha.131

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 (184) hide show
  1. package/CHANGELOG.md +439 -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 +38522 -34542
  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 +4 -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 +12 -0
  18. package/config/alarm/get-alarms-args.js +13 -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/history-data/get-history-data-args.d.ts +14 -3
  25. package/config/history-data/get-history-data-args.js +5 -3
  26. package/config/history-data/get-history-data-args.metadata.json +1 -1
  27. package/config/history-data/history-data.model.d.ts +7 -1
  28. package/config/history-data/history-data.model.js +9 -1
  29. package/config/history-data/history-data.model.metadata.json +1 -1
  30. package/config/history-data/index.d.ts +1 -1
  31. package/config/history-data/index.js +1 -1
  32. package/config/history-data/index.metadata.json +1 -1
  33. package/config/index.d.ts +1 -0
  34. package/config/index.js +1 -0
  35. package/config/index.metadata.json +1 -1
  36. package/elements/air-quality/air-quality-element.d.ts +31 -0
  37. package/elements/air-quality/air-quality-element.js +194 -0
  38. package/elements/air-quality/air-quality-element.metadata.json +1 -0
  39. package/elements/alarm/alarm-element.d.ts +69 -0
  40. package/elements/alarm/alarm-element.js +497 -0
  41. package/elements/alarm/alarm-element.metadata.json +1 -0
  42. package/elements/bar-graph-element.d.ts +10 -2
  43. package/elements/bar-graph-element.js +135 -5
  44. package/elements/bar-graph-element.metadata.json +1 -1
  45. package/elements/base/readable-element.d.ts +6 -1
  46. package/elements/base/readable-element.js +64 -2
  47. package/elements/base/readable-element.metadata.json +1 -1
  48. package/elements/base/state-control-element.d.ts +3 -1
  49. package/elements/base/state-control-element.js +3 -0
  50. package/elements/datetime-display/datetime-display-element.d.ts +1 -0
  51. package/elements/datetime-display/datetime-display-element.js +10 -2
  52. package/elements/datetime-display/datetime-display-element.metadata.json +1 -1
  53. package/elements/datetime-display/time-zone-select-json.d.ts +8 -0
  54. package/elements/datetime-display/time-zone-select-json.js +558 -0
  55. package/elements/historical-curve/historical-curve.element.d.ts +39 -3
  56. package/elements/historical-curve/historical-curve.element.js +509 -43
  57. package/elements/historical-curve/historical-curve.element.metadata.json +1 -1
  58. package/elements/main-element.d.ts +1 -0
  59. package/elements/main-element.js +59 -9
  60. package/elements/main-element.metadata.json +1 -1
  61. package/elements/meter-element.d.ts +7 -1
  62. package/elements/meter-element.js +76 -7
  63. package/elements/meter-element.metadata.json +1 -1
  64. package/elements/numerical-display/numerical-display-element.d.ts +16 -3
  65. package/elements/numerical-display/numerical-display-element.js +83 -11
  66. package/elements/numerical-display/numerical-display-element.metadata.json +1 -1
  67. package/elements/per-view-variable-communicator.d.ts +3 -0
  68. package/elements/per-view-variable-communicator.js +11 -0
  69. package/elements/per-view-variable-communicator.metadata.json +1 -1
  70. package/elements/ring-graph/ring-graph-element.d.ts +13 -1
  71. package/elements/ring-graph/ring-graph-element.js +164 -3
  72. package/elements/ring-graph/ring-graph-element.metadata.json +1 -1
  73. package/elements/scroll-alarm/scroll-alarm-element.d.ts +67 -0
  74. package/elements/scroll-alarm/scroll-alarm-element.js +663 -0
  75. package/elements/scroll-alarm/scroll-alarm-element.metadata.json +1 -0
  76. package/elements/shared/graph/graph-state-element.js +0 -3
  77. package/elements/shared/text/text-element.d.ts +9 -0
  78. package/elements/shared/text/text-element.js +33 -2
  79. package/elements/shared/text/text-element.metadata.json +1 -1
  80. package/elements/shared/text/text-state-element.d.ts +25 -2
  81. package/elements/shared/text/text-state-element.js +138 -63
  82. package/elements/shared/text/text-state-element.metadata.json +1 -1
  83. package/elements/static-elements/hyperlink-element.d.ts +24 -2
  84. package/elements/static-elements/hyperlink-element.js +101 -3
  85. package/elements/static-elements/hyperlink-element.metadata.json +1 -1
  86. package/elements/static-elements/text-element.d.ts +23 -2
  87. package/elements/static-elements/text-element.js +96 -3
  88. package/elements/static-elements/text-element.metadata.json +1 -1
  89. package/elements/switch-indicator-light/bit-switch-operator.d.ts +1 -0
  90. package/elements/switch-indicator-light/bit-switch-operator.js +19 -0
  91. package/elements/switch-indicator-light/bit-switch-operator.metadata.json +1 -1
  92. package/elements/switch-indicator-light/switch-indicator-light-element.d.ts +18 -2
  93. package/elements/switch-indicator-light/switch-indicator-light-element.js +120 -25
  94. package/elements/switch-indicator-light/switch-indicator-light-element.metadata.json +1 -1
  95. package/elements/switch-indicator-light/switch-operator.d.ts +1 -0
  96. package/elements/switch-indicator-light/word-switch-operator.d.ts +1 -0
  97. package/elements/switch-indicator-light/word-switch-operator.js +6 -0
  98. package/elements/switch-indicator-light/word-switch-operator.metadata.json +1 -1
  99. package/elements/video/video-element.d.ts +4 -0
  100. package/elements/video/video-element.js +81 -21
  101. package/elements/video/video-element.metadata.json +1 -1
  102. package/elements/view-operation/view-operation.element.d.ts +23 -2
  103. package/elements/view-operation/view-operation.element.js +103 -1
  104. package/elements/view-operation/view-operation.element.metadata.json +1 -1
  105. package/elements/weather/weater-element.js +0 -1
  106. package/gui/gui-context.d.ts +12 -2
  107. package/gui/gui-host.d.ts +1 -1
  108. package/gui/gui-view.d.ts +2 -0
  109. package/gui/gui-view.js +38 -2
  110. package/gui/gui-view.metadata.json +1 -1
  111. package/gui/gui.component.d.ts +3 -0
  112. package/gui/gui.component.js +15 -2
  113. package/gui/gui.component.metadata.json +1 -1
  114. package/localization/localization.service.d.ts +7 -0
  115. package/localization/localization.service.js +10 -3
  116. package/localization/localization.service.metadata.json +1 -1
  117. package/localization/localization.service.zh_CN.js +8 -1
  118. package/localization/localization.service.zh_CN.metadata.json +1 -1
  119. package/modal/write-value/write-value-modal-args.d.ts +5 -1
  120. package/modal/write-value/write-value-modal-args.js +3 -1
  121. package/modal/write-value/write-value-modal-args.metadata.json +1 -1
  122. package/modal/write-value/write-value-modal.component.d.ts +12 -7
  123. package/modal/write-value/write-value-modal.component.html +9 -4
  124. package/modal/write-value/write-value-modal.component.js +73 -15
  125. package/modal/write-value/write-value-modal.component.metadata.json +1 -1
  126. package/model/air-quality/air-quality-info.d.ts +23 -0
  127. package/model/air-quality/air-quality-info.js +4 -0
  128. package/model/air-quality/air-quality-info.metadata.json +1 -0
  129. package/model/air-quality/air-quality.model.d.ts +7 -0
  130. package/model/air-quality/air-quality.model.js +0 -0
  131. package/model/air-quality/air-quality.model.metadata.json +1 -0
  132. package/model/alarm/alarm.model.d.ts +13 -0
  133. package/model/alarm/alarm.model.js +0 -0
  134. package/model/alarm/alarm.model.metadata.json +1 -0
  135. package/model/bar-graph/bar-graph.d.ts +4 -0
  136. package/model/base/font-setting-model.d.ts +6 -0
  137. package/model/base/font-setting-model.metadata.json +1 -1
  138. package/model/base/readable-model.d.ts +4 -0
  139. package/model/datetime-display/datetime-display.d.ts +1 -0
  140. package/model/historical-curve/historical-curve-axis-settings.d.ts +11 -0
  141. package/model/historical-curve/historical-curve-axis-settings.js +5 -0
  142. package/model/historical-curve/historical-curve-axis-settings.metadata.json +1 -1
  143. package/model/historical-curve/historical-curve-chanel.model.d.ts +8 -0
  144. package/model/historical-curve/historical-curve.data-settings.d.ts +18 -1
  145. package/model/historical-curve/historical-curve.data-settings.metadata.json +1 -1
  146. package/model/meter/meter.d.ts +4 -0
  147. package/model/ring-graph/ring-graph.model.d.ts +8 -0
  148. package/model/scroll-alarm/scroll-alarm.model.d.ts +21 -0
  149. package/model/scroll-alarm/scroll-alarm.model.js +0 -0
  150. package/model/scroll-alarm/scroll-alarm.model.metadata.json +1 -0
  151. package/model/switch-indicator-light/bit-switch-operation.d.ts +2 -1
  152. package/model/switch-indicator-light/bit-switch-operation.js +1 -0
  153. package/model/switch-indicator-light/bit-switch-operation.metadata.json +1 -1
  154. package/model/switch-indicator-light/switch-indicator-light.d.ts +2 -0
  155. package/model/view-operation/view-operation-element.model.d.ts +7 -1
  156. package/package.json +1 -1
  157. package/public_api.js +1 -0
  158. package/remote/communication/variable/remote-variable-communicator.d.ts +22 -0
  159. package/remote/communication/variable/remote-variable-communicator.js +122 -2
  160. package/remote/communication/variable/remote-variable-communicator.metadata.json +1 -1
  161. package/remote/communication/variable/remote-variable-protocol.d.ts +5 -0
  162. package/service/index.d.ts +4 -0
  163. package/service/index.js +1 -0
  164. package/service/index.metadata.json +1 -1
  165. package/service/language.service.d.ts +37 -0
  166. package/service/language.service.js +0 -0
  167. package/service/language.service.metadata.json +1 -0
  168. package/service/released-variable/index.d.ts +1 -0
  169. package/service/released-variable/index.js +0 -0
  170. package/service/released-variable/index.metadata.json +1 -0
  171. package/service/released-variable/released-variable.service.d.ts +4 -0
  172. package/service/released-variable/released-variable.service.js +0 -0
  173. package/service/released-variable/released-variable.service.metadata.json +1 -0
  174. package/service/system-text-library.service.d.ts +76 -0
  175. package/service/system-text-library.service.js +28 -0
  176. package/service/system-text-library.service.metadata.json +1 -0
  177. package/service/text-library.service.d.ts +49 -0
  178. package/service/text-library.service.js +0 -0
  179. package/service/text-library.service.metadata.json +1 -0
  180. package/service/weather.service.d.ts +1 -0
  181. package/shared/gui-consts.d.ts +3 -0
  182. package/shared/gui-consts.js +3 -0
  183. package/shared/gui-consts.metadata.json +1 -1
  184. package/utils/data-type/fbox-data-type.service.js +40 -0
@@ -0,0 +1,663 @@
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, _f;
14
+ super(element, permissionChecker, variableCommunicator, variableStore, signalRAppId);
15
+ this.alarmsStore = alarmsStore;
16
+ this.elementStatus = ScrollAlarmElementStatus.Loading;
17
+ this.alarmNames = [];
18
+ this.isWaitingForAlarmRefresh = false; // 是否正在等待刷新(节流期间)
19
+ this.isScrolling = false;
20
+ this.isDisposed = false;
21
+ this.isRefreshingCurrentPage = false; // 标记是否正在刷新当前页(而不是加载新页)
22
+ // 新的分页和滚动逻辑变量
23
+ this.currentPage = 1;
24
+ this.maxResultCount = 500; // 每页数据量
25
+ this.displayedItems = []; // 当前显示的所有数据
26
+ this.pageWidths = []; // 存储每页的宽度
27
+ this.totalWidth = 0; // 所有显示数据的总宽度
28
+ this.currentLeft = 0;
29
+ this.autoCycle = true;
30
+ this.hasMoreData = true;
31
+ this.isLoadingNextPage = false;
32
+ this.hasTriedFirstPage = false; // 是否已经尝试加载过第一页
33
+ this.isSimulateMode = false; // 是否是模拟运行模式
34
+ this.rootElement.selectAll('*').remove();
35
+ this.setStatusAsLoading();
36
+ this.logger = injector.get(LOGGER_SERVICE_TOKEN);
37
+ this.variableCommunicator = variableCommunicator;
38
+ this.autoCycle = (_b = (_a = this.model.generalSetting) === null || _a === void 0 ? void 0 : _a.autoCycle) !== null && _b !== void 0 ? _b : true;
39
+ this.maxResultCount = (_d = (_c = this.model.generalSetting) === null || _c === void 0 ? void 0 : _c.pageSize) !== null && _d !== void 0 ? _d : 500;
40
+ // 检测是否是模拟运行模式(通过检查 alarmsStore 的类型)
41
+ this.isSimulateMode = alarmsStore && alarmsStore.constructor.name === 'SimulateAlarmDataStore';
42
+ if (this.model.filterSetting && this.model.filterSetting.detailsData && this.model.filterSetting.detailsData.length > 0) {
43
+ this.alarmNames = this.model.filterSetting.detailsData.map(item => item.name);
44
+ // 如果是模拟运行模式,使用静态显示逻辑(类似设计态)
45
+ if (this.isSimulateMode) {
46
+ // 初始化显示容器
47
+ this.initDisplayContainer();
48
+ // 获取字体设置
49
+ this.headerFont = ((_e = this.model.generalSetting) === null || _e === void 0 ? void 0 : _e.headerFont) || {};
50
+ // 构建符合 CSS font 属性规范的字符串
51
+ let fontString = '';
52
+ if (this.headerFont.isItalic) {
53
+ fontString += 'italic ';
54
+ }
55
+ if (this.headerFont.isBold) {
56
+ fontString += 'bold ';
57
+ }
58
+ const fontSize = this.headerFont.fontSize || '16px';
59
+ const lineHeight = parseInt(fontSize, 10) + 5;
60
+ fontString += `${fontSize}/${lineHeight}px ${this.headerFont.fontFamily || 'Microsoft YaHei'}`;
61
+ this.fontString = fontString;
62
+ // 使用静态显示逻辑:只显示字段标签
63
+ this.renderStaticDisplay();
64
+ this.setStatusAsNormal();
65
+ }
66
+ else {
67
+ // 真实运行模式:使用原有的数据查询逻辑
68
+ this.updateQueryTimeRange();
69
+ // 监听告警更新 (带节流,1秒内只执行一次)
70
+ variableCommunicator.subscribeUserDeviceAlarms(signalRAppId).subscribe(alarms => {
71
+ alarms.forEach(alarm => {
72
+ if (this.alarmNames.indexOf(alarm.name) !== -1) {
73
+ // 如果已经在等待刷新,直接返回,避免重复清理和创建定时器
74
+ if (this.isWaitingForAlarmRefresh) {
75
+ return;
76
+ }
77
+ // 标记为等待刷新状态
78
+ this.isWaitingForAlarmRefresh = true;
79
+ // 设置节流定时器,1秒后执行
80
+ this.alarmRefreshThrottleId = setTimeout(() => {
81
+ // 收到新告警消息,重置到第一页并重新开始滚动
82
+ this.resetToFirstPage();
83
+ // 如果非自动循环模式,需要重新启动滚动
84
+ if (!this.autoCycle && !this.isScrolling) {
85
+ this.initScrolling();
86
+ }
87
+ // 重置等待刷新标志
88
+ this.isWaitingForAlarmRefresh = false;
89
+ }, 1000);
90
+ return;
91
+ }
92
+ });
93
+ });
94
+ // 初始化显示容器
95
+ this.initDisplayContainer();
96
+ // 获取字体设置 - 参考 text-element.ts 的实现方式
97
+ this.headerFont = ((_f = this.model.generalSetting) === null || _f === void 0 ? void 0 : _f.headerFont) || {};
98
+ // 构建符合 CSS font 属性规范的字符串
99
+ // 格式:font-style font-weight font-size/line-height font-family
100
+ let fontString = '';
101
+ if (this.headerFont.isItalic) {
102
+ fontString += 'italic ';
103
+ }
104
+ if (this.headerFont.isBold) {
105
+ fontString += 'bold ';
106
+ }
107
+ const fontSize = this.headerFont.fontSize || '16px';
108
+ const lineHeight = parseInt(fontSize, 10) + 5;
109
+ fontString += `${fontSize}/${lineHeight}px ${this.headerFont.fontFamily || 'Microsoft YaHei'}`;
110
+ this.fontString = fontString;
111
+ this.getAlarmData();
112
+ }
113
+ }
114
+ else {
115
+ // 未配置告警(没有勾选过告警),不执行,直接展示空
116
+ this.displayedItems = [];
117
+ // 初始化显示容器以显示空内容
118
+ this.initDisplayContainer();
119
+ if (this.allAlarmsContainer) {
120
+ this.allAlarmsContainer.innerHTML = '';
121
+ this.totalWidth = 0;
122
+ this.pageWidths = [];
123
+ }
124
+ this.setStatusAsNormal();
125
+ }
126
+ }
127
+ dispose() {
128
+ this.isDisposed = true;
129
+ clearInterval(this.scrollIntervalId);
130
+ clearTimeout(this.getAlarmDataId);
131
+ clearTimeout(this.alarmRefreshThrottleId);
132
+ if (this.element && this.element.tooltip) {
133
+ this.element.tooltip.hidden(true);
134
+ }
135
+ this.logger.debug(`[GUI]Dispose Scroll Alarm Refresh Interval:${d3.time.format('%x %X')(new Date())}`);
136
+ // 重置所有状态
137
+ this.isScrolling = false;
138
+ }
139
+ getAlarmData() {
140
+ if (this.isDisposed || this.isLoadingNextPage)
141
+ return;
142
+ this.isLoadingNextPage = true;
143
+ // Only show loading for the first page load
144
+ if (this.currentPage === 1 && this.displayedItems.length === 0) {
145
+ this.setStatusAsLoading();
146
+ }
147
+ clearTimeout(this.getAlarmDataId);
148
+ this.getAlarmDataId = setTimeout(() => {
149
+ var _a, _b;
150
+ this.updateQueryTimeRange();
151
+ const skipCount = (this.currentPage - 1) * this.maxResultCount;
152
+ // 从配置中获取状态和排序设置
153
+ const selectedStates = (_a = this.model.generalSetting) === null || _a === void 0 ? void 0 : _a.selectState; // 前端使用的字段名
154
+ const timeSort = (_b = this.model.generalSetting) === null || _b === void 0 ? void 0 : _b.timeSort; // 前端使用的字段名
155
+ // 构建排序字符串 - API 字段名是 sorting
156
+ let sorting;
157
+ if (timeSort === '0') {
158
+ sorting = 'TriggeredTime ASC'; // 升序
159
+ }
160
+ else if (timeSort === '1') {
161
+ sorting = 'TriggeredTime DESC'; // 降序
162
+ }
163
+ // 后端 API 的 state 参数现已支持数组,直接传递 selectedStates
164
+ // 兼容处理:如果 selectedStates 为空数组或 undefined,传 undefined(不过滤)
165
+ const stateFilter = (selectedStates && Array.isArray(selectedStates) && selectedStates.length > 0)
166
+ ? selectedStates
167
+ : undefined;
168
+ const input = new GetAlarmsArgs(this.alarmNames, this.startTime, this.endTime, this.maxResultCount, skipCount, stateFilter, // 传递状态数组到后端,后端已支持数组过滤
169
+ sorting // 传递排序参数
170
+ );
171
+ this.alarmsStore.getHistoryAlarms(input).subscribe(result => {
172
+ this.isLoadingNextPage = false;
173
+ if (!result.error && result.items && result.items.length > 0) {
174
+ const newPage = result.items;
175
+ // 检查是否还有更多数据
176
+ // 如果是第一页且数据量少于 maxResultCount,说明总数据不超过一页
177
+ if (this.currentPage === 1 && newPage.length < this.maxResultCount) {
178
+ // 总数据不超过一页,不需要加载更多数据
179
+ this.hasMoreData = false;
180
+ }
181
+ else if (!this.autoCycle && newPage.length < this.maxResultCount) {
182
+ // 非自动循环模式,且当前页数据不足,说明没有更多数据
183
+ this.hasMoreData = false;
184
+ }
185
+ else {
186
+ this.hasMoreData = true;
187
+ }
188
+ if (this.isRefreshingCurrentPage) {
189
+ // 刷新当前页模式:替换最后一页的数据,保持滚动位置
190
+ const itemsPerPage = this.maxResultCount;
191
+ const startIndex = (this.currentPage - 1) * itemsPerPage;
192
+ // 移除当前页的旧数据
193
+ this.displayedItems.splice(startIndex, itemsPerPage);
194
+ // 移除当前页的DOM元素
195
+ const oldPageWidth = this.pageWidths.pop() || 0;
196
+ this.totalWidth -= oldPageWidth;
197
+ const elementsToRemove = Array.from(this.allAlarmsContainer.children).slice(startIndex, startIndex + itemsPerPage);
198
+ elementsToRemove.forEach(element => {
199
+ this.allAlarmsContainer.removeChild(element);
200
+ });
201
+ // 插入新的当前页数据
202
+ this.displayedItems.splice(startIndex, 0, ...newPage);
203
+ // 渲染新页(会追加到末尾)
204
+ this.renderNewPage(newPage);
205
+ // 更新页码
206
+ this.currentPage++;
207
+ // 重置标志
208
+ this.isRefreshingCurrentPage = false;
209
+ }
210
+ else {
211
+ // 正常加载新页模式:追加数据
212
+ this.displayedItems = this.displayedItems.concat(newPage);
213
+ // 渲染新页
214
+ this.renderNewPage(newPage);
215
+ // 更新页码
216
+ this.currentPage++;
217
+ }
218
+ // 检查是否需要删除旧页(保持最多3页)
219
+ if (this.currentPage > 4) {
220
+ this.removeOldestPage();
221
+ }
222
+ // 如果是首次加载或还没有开始滚动,初始化滚动
223
+ if (!this.isScrolling && this.displayedItems.length > 0) {
224
+ this.initScrolling();
225
+ }
226
+ this.setStatusAsNormal();
227
+ this.hasTriedFirstPage = true;
228
+ }
229
+ else {
230
+ // 如果没有数据
231
+ if (this.currentPage === 1 && !this.hasTriedFirstPage) {
232
+ // 第一次加载就没有数据,设置为正常状态,停止加载
233
+ this.hasTriedFirstPage = true;
234
+ this.hasMoreData = false;
235
+ this.setStatusAsNormal();
236
+ // 清空显示
237
+ this.displayedItems = [];
238
+ if (this.allAlarmsContainer) {
239
+ this.allAlarmsContainer.innerHTML = '';
240
+ this.totalWidth = 0;
241
+ this.pageWidths = [];
242
+ }
243
+ }
244
+ else if (this.autoCycle && this.hasTriedFirstPage && this.displayedItems.length > 0) {
245
+ // 不是第一页,且之前有数据,自动循环开启,循环回到第一页
246
+ this.currentPage = 1;
247
+ this.getAlarmData();
248
+ }
249
+ else {
250
+ // 其他情况:停止加载
251
+ this.hasMoreData = false;
252
+ this.setStatusAsNormal();
253
+ }
254
+ }
255
+ }, error => {
256
+ this.isLoadingNextPage = false;
257
+ this.setStatusAsNormal();
258
+ this.logger.error('Failed to get alarm data:', error);
259
+ });
260
+ }, 500);
261
+ }
262
+ initDisplayContainer() {
263
+ var _a;
264
+ const elementHeight = this.model.size.height;
265
+ const elementWidth = this.model.size.width;
266
+ // 创建foreignObject作为容器
267
+ this.element = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject');
268
+ this.element.setAttribute('width', elementWidth.toString());
269
+ this.element.setAttribute('height', elementHeight.toString());
270
+ this.$element.append(this.element);
271
+ // 创建背景容器,应用headerFillColor背景色
272
+ this.container = document.createElement('div');
273
+ this.container.style.cssText = `
274
+ height: ${elementHeight}px;
275
+ width: 100%;
276
+ background-color: ${((_a = this.model.generalSetting) === null || _a === void 0 ? void 0 : _a.headerFillColor) || '#ffffff'};
277
+ display: flex;
278
+ align-items: center;
279
+ overflow: hidden;
280
+ position: relative;
281
+ border: 1px solid #8ea0aa;
282
+ border-radius: 2px;
283
+ `;
284
+ this.element.appendChild(this.container);
285
+ // 创建一个大容器来包含所有告警项,初始位置在容器右侧(从右边开始滚入)
286
+ this.allAlarmsContainer = document.createElement('div');
287
+ this.allAlarmsContainer.style.cssText = `
288
+ position: absolute;
289
+ left: ${elementWidth}px;
290
+ top: 50%;
291
+ transform: translateY(-50%);
292
+ display: flex;
293
+ align-items: center;
294
+ gap: 80px;
295
+ `;
296
+ this.container.appendChild(this.allAlarmsContainer);
297
+ // 设置初始位置为容器宽度,让内容从右侧滚入
298
+ this.currentLeft = elementWidth;
299
+ // 添加鼠标悬停暂停和恢复滚动功能
300
+ this.container.addEventListener('mouseenter', () => this.pauseScroll());
301
+ this.container.addEventListener('mouseleave', () => this.resumeScroll());
302
+ }
303
+ renderNewPage(pageData) {
304
+ let pageWidth = 0;
305
+ // 为每个告警数据创建文本容器
306
+ pageData.forEach((alarm) => {
307
+ var _a, _b, _c, _d, _e, _f, _g, _h;
308
+ // 创建告警文本容器
309
+ const textContainer = document.createElement('div');
310
+ textContainer.style.cssText = `
311
+ font: ${this.fontString};
312
+ color: ${this.headerFont.color || '#E95F5F'};
313
+ white-space: nowrap;
314
+ overflow: visible;
315
+ `;
316
+ // 应用下划线样式(参考 text-element.ts 的实现)
317
+ if (this.headerFont.isUnderline) {
318
+ textContainer.style.textDecoration = 'underline';
319
+ }
320
+ // 构建告警信息内容,根据配置决定显示哪些字段
321
+ const contentParts = [];
322
+ // 显示触发时间
323
+ if (((_a = this.model.generalSetting) === null || _a === void 0 ? void 0 : _a.showTriggerTime) && alarm.triggeredTime) {
324
+ const formattedTime = moment(alarm.triggeredTime).format('YYYY/MM/DD HH:mm:ss');
325
+ contentParts.push(formattedTime);
326
+ }
327
+ // 获取当前语言环境
328
+ 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';
329
+ const isChinese = language === 'zh-Hans' || language === 'zh';
330
+ // 显示告警等级
331
+ if (((_e = this.model.generalSetting) === null || _e === void 0 ? void 0 : _e.showAlarmLevel) && alarm.alarmLevel !== undefined) {
332
+ const levelMap = isChinese ? ['警告', '次要', '主要', '严重'] : ['Warning', 'Minor', 'Major', 'Critical'];
333
+ const alarmLevel = levelMap[alarm.alarmLevel] || (isChinese ? '警告' : 'Warning');
334
+ contentParts.push(alarmLevel);
335
+ }
336
+ // 显示告警名称
337
+ if (((_f = this.model.generalSetting) === null || _f === void 0 ? void 0 : _f.showAlarmName) && alarm.name) {
338
+ contentParts.push(alarm.name);
339
+ }
340
+ // 显示告警内容
341
+ if (((_g = this.model.generalSetting) === null || _g === void 0 ? void 0 : _g.showAlarmContent) && alarm.message) {
342
+ contentParts.push(alarm.message);
343
+ }
344
+ // 显示告警状态
345
+ if (((_h = this.model.generalSetting) === null || _h === void 0 ? void 0 : _h.showAlarmState) && alarm.state !== undefined) {
346
+ const stateMap = isChinese ? ['触发/未确认', '触发/已确认', '恢复/未确认', '恢复/已确认'] : ['Triggered/Unconfirmed', 'Triggered/Confirmed', 'Restored/Unconfirmed', 'Restored/Confirmed'];
347
+ const alarmState = stateMap[alarm.state] || (isChinese ? '触发/未确认' : 'Triggered/Unconfirmed');
348
+ contentParts.push(alarmState);
349
+ }
350
+ // 将所有显示字段用空格连接,确保一行显示
351
+ const textContent = contentParts.join(' ');
352
+ textContainer.textContent = textContent;
353
+ this.allAlarmsContainer.appendChild(textContainer);
354
+ // 计算文本宽度
355
+ const textWidth = textContainer.offsetWidth;
356
+ pageWidth += textWidth + 80; // 80是gap大小
357
+ });
358
+ // 移除最后一个gap
359
+ if (pageWidth > 0) {
360
+ pageWidth -= 80;
361
+ }
362
+ // 保存页宽度
363
+ this.pageWidths.push(pageWidth);
364
+ this.totalWidth += pageWidth;
365
+ }
366
+ removeOldestPage() {
367
+ // 移除最旧的一页数据
368
+ this.displayedItems.splice(0, this.maxResultCount);
369
+ const oldPageWidth = this.pageWidths.shift() || 0;
370
+ // 更新总宽度
371
+ this.totalWidth -= oldPageWidth;
372
+ // 从DOM中移除最旧的元素
373
+ const elementsToRemove = Array.from(this.allAlarmsContainer.children).slice(0, this.maxResultCount);
374
+ elementsToRemove.forEach(element => {
375
+ this.allAlarmsContainer.removeChild(element);
376
+ });
377
+ // 调整当前left位置(保持视觉位置不变)- 这里需要等DOM更新完成后再调整
378
+ requestAnimationFrame(() => {
379
+ this.currentLeft += oldPageWidth;
380
+ this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
381
+ });
382
+ }
383
+ scrollContent() {
384
+ if (this.displayedItems.length <= 0)
385
+ return;
386
+ // 每次滚动的距离
387
+ const scrollStep = 2; // 减小滚动步长,使滚动更平滑
388
+ // 更新位置 - 从右往左滚动
389
+ this.currentLeft -= scrollStep;
390
+ // 检查是否需要加载下一页(只有在自动循环模式下才需要预加载)
391
+ if (this.autoCycle && this.hasMoreData && !this.isLoadingNextPage) {
392
+ const currentPosition = Math.abs(this.currentLeft);
393
+ const loadedWidth = this.totalWidth - (this.pageWidths[this.pageWidths.length - 1] || 0);
394
+ // 当滚动到已加载内容的60%时,加载下一页(提前预加载,确保无缝衔接)
395
+ if (currentPosition > loadedWidth * 0.6) {
396
+ this.getAlarmData();
397
+ }
398
+ }
399
+ // 当内容完全滚出容器左侧时(currentLeft + totalWidth < 0)
400
+ // 说明所有内容都已经滚出视图,需要重置或停止
401
+ if (this.currentLeft + this.totalWidth < 0) {
402
+ if (this.autoCycle) {
403
+ // 自动循环模式:无缝衔接回到容器右侧
404
+ if (this.hasMoreData) {
405
+ // 有更多数据:继续加载(但实际上已经在上面预加载了)
406
+ // 重置到容器宽度,让内容从右侧重新滚入
407
+ this.currentLeft = this.container.clientWidth;
408
+ }
409
+ else {
410
+ // 没有更多数据了:重置
411
+ if (this.currentPage > 2) {
412
+ // 数据总数超过一页:重置到第一页并重新查询
413
+ this.resetToFirstPage();
414
+ }
415
+ else {
416
+ // 数据总数只有一页:直接重置到容器右侧,循环滚动当前数据
417
+ this.currentLeft = this.container.clientWidth;
418
+ }
419
+ }
420
+ }
421
+ else {
422
+ // 非循环滚动:停止滚动
423
+ clearInterval(this.scrollIntervalId);
424
+ this.isScrolling = false;
425
+ return; // 提前返回,不再更新位置
426
+ }
427
+ }
428
+ // 更新显示位置
429
+ this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
430
+ }
431
+ initScrolling() {
432
+ clearInterval(this.scrollIntervalId);
433
+ // 如果没有数据,则不启动滚动
434
+ if (this.displayedItems.length === 0) {
435
+ return;
436
+ }
437
+ // 确保初始位置在容器右侧(从右边滚入)
438
+ if (this.currentPage === 1 && this.displayedItems.length <= this.maxResultCount) {
439
+ // 第一页初始加载时,确保从右侧开始
440
+ this.currentLeft = this.container.clientWidth;
441
+ this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
442
+ }
443
+ const scrollInterval = 100; // 默认100ms,滚动更流畅
444
+ // 延迟启动滚动确保内容渲染完成
445
+ setTimeout(() => {
446
+ this.isScrolling = true;
447
+ this.scrollIntervalId = setInterval(() => {
448
+ if (this.isScrolling) {
449
+ this.scrollContent();
450
+ }
451
+ }, scrollInterval);
452
+ }, 500);
453
+ }
454
+ pauseScroll() {
455
+ this.isScrolling = false;
456
+ }
457
+ resumeScroll() {
458
+ this.isScrolling = true;
459
+ }
460
+ resetToFirstPage() {
461
+ // 重置到第一页并重新查询数据
462
+ this.currentPage = 1;
463
+ this.hasMoreData = true;
464
+ this.hasTriedFirstPage = false;
465
+ this.displayedItems = [];
466
+ if (this.allAlarmsContainer) {
467
+ this.allAlarmsContainer.innerHTML = '';
468
+ this.totalWidth = 0;
469
+ this.pageWidths = [];
470
+ }
471
+ // 重置到容器右侧,让内容从右边滚入
472
+ this.currentLeft = this.container.clientWidth;
473
+ this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
474
+ this.getAlarmData();
475
+ }
476
+ updateQueryTimeRange() {
477
+ this.endTime = moment();
478
+ switch (this.model.generalSetting.displayPeriod) {
479
+ case 1:
480
+ this.startTime = moment().subtract(1, 'hours');
481
+ break;
482
+ case 3:
483
+ this.startTime = moment().subtract(7, 'days');
484
+ break;
485
+ case 4:
486
+ this.startTime = moment().subtract(30, 'days');
487
+ break;
488
+ case 5:
489
+ this.startTime = moment().subtract(6, 'months');
490
+ break;
491
+ case 6:
492
+ this.startTime = moment().subtract(30, 'minutes');
493
+ break;
494
+ case 7:
495
+ this.startTime = moment().subtract(8, 'hours');
496
+ break;
497
+ default:
498
+ this.startTime = moment().subtract(1, 'days');
499
+ }
500
+ }
501
+ setStatusAsNormal() {
502
+ this.elementStatus = ScrollAlarmElementStatus.Normal;
503
+ this.clearStatus();
504
+ }
505
+ setStatusAsLoading() {
506
+ this.elementStatus = ScrollAlarmElementStatus.Loading;
507
+ this.renderStatus('assets/img/loading.svg', '#226abc');
508
+ }
509
+ renderStatus(icon, stroke) {
510
+ if (this.elementStatus === ScrollAlarmElementStatus.Normal) {
511
+ this.clearStatus();
512
+ return;
513
+ }
514
+ // 确保宽度和高度为正值,避免 SVG 错误
515
+ const width = Math.max(this.model.size.width || 100, 0);
516
+ const height = Math.max(this.model.size.height || 50, 0);
517
+ this.rootElement.append('rect').attr('id', 'StateFrame').attr('fill', 'transparent')
518
+ .attr('width', width)
519
+ .attr('height', height);
520
+ const document = this.$element[0].ownerDocument;
521
+ const currentRect = this.$element.find('rect#StateFrame').first();
522
+ if (!currentRect.length) {
523
+ return;
524
+ }
525
+ this.$element.find('image#StateImage').remove();
526
+ const imgObj = document.createElementNS('http://www.w3.org/2000/svg', 'image');
527
+ if (imgObj) {
528
+ let x = Number(currentRect[0].getAttribute('width')) - 20;
529
+ const currentRectX = currentRect[0].getAttribute('x');
530
+ if (currentRectX !== null) {
531
+ x += Number(currentRectX);
532
+ }
533
+ currentRect[0].setAttribute('stroke', stroke);
534
+ currentRect[0].setAttribute('stroke-opacity', '0.5');
535
+ imgObj.href.baseVal = icon;
536
+ imgObj.setAttributeNS(null, 'id', 'StateImage');
537
+ imgObj.setAttributeNS(null, 'x', x.toString());
538
+ imgObj.setAttributeNS(null, 'y', '0');
539
+ imgObj.setAttributeNS(null, 'height', '20px');
540
+ imgObj.setAttributeNS(null, 'width', '20px');
541
+ const titleElement = document.createElementNS('http://www.w3.org/2000/svg', 'title');
542
+ imgObj.appendChild(titleElement);
543
+ this.$element.append(imgObj);
544
+ }
545
+ }
546
+ clearStatus() {
547
+ const currentRect = this.$element.find('rect#StateFrame').first();
548
+ if (!currentRect.length) {
549
+ return;
550
+ }
551
+ const stroke = currentRect[0].getAttribute('stroke');
552
+ if (stroke) {
553
+ currentRect[0].removeAttribute('stroke');
554
+ }
555
+ this.$element.find('image#StateImage').remove();
556
+ }
557
+ /**
558
+ * 模拟运行时的静态显示逻辑:只显示字段标签,不查询数据
559
+ */
560
+ renderStaticDisplay() {
561
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
562
+ // 根据配置构建显示的字段标签
563
+ const textParts = [];
564
+ if (((_a = this.model.generalSetting) === null || _a === void 0 ? void 0 : _a.showTriggerTime) !== false) {
565
+ // 使用moment.format方法格式化日期时间
566
+ const timeStr = moment().format('YYYY/MM/DD HH:mm:ss');
567
+ textParts.push(timeStr);
568
+ }
569
+ if (((_b = this.model.generalSetting) === null || _b === void 0 ? void 0 : _b.showAlarmLevel) !== false) {
570
+ // 获取当前语言环境
571
+ const language = ((_e = (_d = (_c = window.abp) === null || _c === void 0 ? void 0 : _c.localization) === null || _d === void 0 ? void 0 : _d.currentLanguage) === null || _e === void 0 ? void 0 : _e.name) || 'zh-Hans';
572
+ const isChinese = language === 'zh-Hans' || language === 'zh';
573
+ textParts.push(isChinese ? '严重' : 'Critical');
574
+ }
575
+ if (((_f = this.model.generalSetting) === null || _f === void 0 ? void 0 : _f.showAlarmName) === true) {
576
+ // 获取当前语言环境
577
+ const language = ((_j = (_h = (_g = window.abp) === null || _g === void 0 ? void 0 : _g.localization) === null || _h === void 0 ? void 0 : _h.currentLanguage) === null || _j === void 0 ? void 0 : _j.name) || 'zh-Hans';
578
+ const isChinese = language === 'zh-Hans' || language === 'zh';
579
+ textParts.push(isChinese ? '室内温度' : 'Indoor Temperature');
580
+ }
581
+ if (((_k = this.model.generalSetting) === null || _k === void 0 ? void 0 : _k.showAlarmContent) !== false) {
582
+ // 获取当前语言环境
583
+ const language = ((_o = (_m = (_l = window.abp) === null || _l === void 0 ? void 0 : _l.localization) === null || _m === void 0 ? void 0 : _m.currentLanguage) === null || _o === void 0 ? void 0 : _o.name) || 'zh-Hans';
584
+ const isChinese = language === 'zh-Hans' || language === 'zh';
585
+ textParts.push(isChinese ? '室内温度高于30°C或小于10°C' : 'Indoor temperature is higher than 30℃ or lower than 10℃');
586
+ }
587
+ if (((_p = this.model.generalSetting) === null || _p === void 0 ? void 0 : _p.showAlarmState) === true) {
588
+ // 获取当前语言环境
589
+ const language = ((_s = (_r = (_q = window.abp) === null || _q === void 0 ? void 0 : _q.localization) === null || _r === void 0 ? void 0 : _r.currentLanguage) === null || _s === void 0 ? void 0 : _s.name) || 'zh-Hans';
590
+ const isChinese = language === 'zh-Hans' || language === 'zh';
591
+ textParts.push(isChinese ? '触发/未确认' : 'Triggered/Unconfirmed');
592
+ }
593
+ // 创建文本容器
594
+ const textContainer = document.createElement('div');
595
+ textContainer.style.cssText = `
596
+ font: ${this.fontString};
597
+ color: ${this.headerFont.color || '#E95F5F'};
598
+ white-space: nowrap;
599
+ overflow: visible;
600
+ `;
601
+ // 应用下划线样式
602
+ if (this.headerFont.isUnderline) {
603
+ textContainer.style.textDecoration = 'underline';
604
+ }
605
+ // 设置文本内容
606
+ textContainer.textContent = textParts.join(' ');
607
+ this.allAlarmsContainer.appendChild(textContainer);
608
+ // 计算文本宽度
609
+ const textWidth = textContainer.offsetWidth;
610
+ this.totalWidth = textWidth;
611
+ this.pageWidths.push(textWidth);
612
+ // 设置初始位置为容器宽度(从右侧滚入)
613
+ this.currentLeft = this.container.clientWidth;
614
+ this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
615
+ // 根据 autoCycle 配置决定是否启动滚动
616
+ if (this.autoCycle) {
617
+ this.initStaticScrolling();
618
+ }
619
+ }
620
+ /**
621
+ * 模拟运行时的静态滚动逻辑
622
+ */
623
+ initStaticScrolling() {
624
+ clearInterval(this.scrollIntervalId);
625
+ // 确保初始位置在容器右侧
626
+ this.currentLeft = this.container.clientWidth;
627
+ this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
628
+ const scrollInterval = 100;
629
+ // 延迟启动滚动确保内容渲染完成
630
+ setTimeout(() => {
631
+ this.isScrolling = true;
632
+ this.scrollIntervalId = setInterval(() => {
633
+ if (this.isScrolling) {
634
+ this.scrollStaticContent();
635
+ }
636
+ }, scrollInterval);
637
+ }, 500);
638
+ }
639
+ /**
640
+ * 模拟运行时的静态内容滚动
641
+ */
642
+ scrollStaticContent() {
643
+ // 每次滚动的距离
644
+ const scrollStep = 2;
645
+ // 更新位置 - 从右往左滚动
646
+ this.currentLeft -= scrollStep;
647
+ // 当内容完全滚出容器左侧时
648
+ if (this.currentLeft + this.totalWidth < 0) {
649
+ if (this.autoCycle) {
650
+ // 自动循环模式:重置到容器右侧
651
+ this.currentLeft = this.container.clientWidth;
652
+ }
653
+ else {
654
+ // 非循环模式:停止滚动
655
+ clearInterval(this.scrollIntervalId);
656
+ this.isScrolling = false;
657
+ return;
658
+ }
659
+ }
660
+ // 更新显示位置
661
+ this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
662
+ }
663
+ }
@@ -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":52,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":53,"character":18},{"__symbolic":"reference","module":"../../service","name":"PermissionChecker","line":54,"character":27},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":55,"character":30},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":56,"character":23},{"__symbolic":"reference","module":"../../config","name":"AlarmsStore","line":57,"character":38},{"__symbolic":"reference","name":"string"}]}],"dispose":[{"__symbolic":"method"}],"getAlarmData":[{"__symbolic":"method"}],"initDisplayContainer":[{"__symbolic":"method"}],"renderNewPage":[{"__symbolic":"method"}],"removeOldestPage":[{"__symbolic":"method"}],"scrollContent":[{"__symbolic":"method"}],"initScrolling":[{"__symbolic":"method"}],"pauseScroll":[{"__symbolic":"method"}],"resumeScroll":[{"__symbolic":"method"}],"resetToFirstPage":[{"__symbolic":"method"}],"updateQueryTimeRange":[{"__symbolic":"method"}],"setStatusAsNormal":[{"__symbolic":"method"}],"setStatusAsLoading":[{"__symbolic":"method"}],"renderStatus":[{"__symbolic":"method"}],"clearStatus":[{"__symbolic":"method"}],"renderStaticDisplay":[{"__symbolic":"method"}],"initStaticScrolling":[{"__symbolic":"method"}],"scrollStaticContent":[{"__symbolic":"method"}]}}}}]