@flexem/fc-gui 3.0.0-alpha.132 → 3.0.0-alpha.134

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.
@@ -64,4 +64,8 @@ export declare class ScrollAlarmElement extends ConditionalDynamicDisplayElement
64
64
  * 模拟运行时的静态内容滚动
65
65
  */
66
66
  private scrollStaticContent;
67
+ /**
68
+ * 实时替换当前滚动内容(用于告警数据变化时)
69
+ */
70
+ private replaceCurrentScrollingContent;
67
71
  }
@@ -37,8 +37,8 @@ export class ScrollAlarmElement extends ConditionalDynamicDisplayElement {
37
37
  this.variableCommunicator = variableCommunicator;
38
38
  this.autoCycle = (_b = (_a = this.model.generalSetting) === null || _a === void 0 ? void 0 : _a.autoCycle) !== null && _b !== void 0 ? _b : true;
39
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';
40
+ // 检测是否是模拟运行模式(通过检查 alarmsStore 的标记属性,不受代码混淆影响)
41
+ this.isSimulateMode = alarmsStore && alarmsStore.isSimulationStore === true;
42
42
  if (this.model.filterSetting && this.model.filterSetting.detailsData && this.model.filterSetting.detailsData.length > 0) {
43
43
  this.alarmNames = this.model.filterSetting.detailsData.map(item => item.name);
44
44
  // 如果是模拟运行模式,使用静态显示逻辑(类似设计态)
@@ -78,12 +78,8 @@ export class ScrollAlarmElement extends ConditionalDynamicDisplayElement {
78
78
  this.isWaitingForAlarmRefresh = true;
79
79
  // 设置节流定时器,1秒后执行
80
80
  this.alarmRefreshThrottleId = setTimeout(() => {
81
- // 收到新告警消息,重置到第一页并重新开始滚动
82
- this.resetToFirstPage();
83
- // 如果非自动循环模式,需要重新启动滚动
84
- if (!this.autoCycle && !this.isScrolling) {
85
- this.initScrolling();
86
- }
81
+ // 收到新告警消息,实时替换当前滚动内容,不影响滚动
82
+ this.replaceCurrentScrollingContent();
87
83
  // 重置等待刷新标志
88
84
  this.isWaitingForAlarmRefresh = false;
89
85
  }, 1000);
@@ -309,7 +305,7 @@ export class ScrollAlarmElement extends ConditionalDynamicDisplayElement {
309
305
  const textContainer = document.createElement('div');
310
306
  textContainer.style.cssText = `
311
307
  font: ${this.fontString};
312
- color: ${this.headerFont.color || '#E95F5F'};
308
+ color: ${this.headerFont.color || '#e33c39'};
313
309
  white-space: nowrap;
314
310
  overflow: visible;
315
311
  `;
@@ -384,7 +380,7 @@ export class ScrollAlarmElement extends ConditionalDynamicDisplayElement {
384
380
  if (this.displayedItems.length <= 0)
385
381
  return;
386
382
  // 每次滚动的距离
387
- const scrollStep = 2; // 减小滚动步长,使滚动更平滑
383
+ const scrollStep = 6; // 减小滚动步长,使滚动更平滑
388
384
  // 更新位置 - 从右往左滚动
389
385
  this.currentLeft -= scrollStep;
390
386
  // 检查是否需要加载下一页(只有在自动循环模式下才需要预加载)
@@ -594,7 +590,7 @@ export class ScrollAlarmElement extends ConditionalDynamicDisplayElement {
594
590
  const textContainer = document.createElement('div');
595
591
  textContainer.style.cssText = `
596
592
  font: ${this.fontString};
597
- color: ${this.headerFont.color || '#E95F5F'};
593
+ color: ${this.headerFont.color || '#e33c39'};
598
594
  white-space: nowrap;
599
595
  overflow: visible;
600
596
  `;
@@ -665,4 +661,130 @@ export class ScrollAlarmElement extends ConditionalDynamicDisplayElement {
665
661
  }
666
662
  }
667
663
  }
664
+ /**
665
+ * 实时替换当前滚动内容(用于告警数据变化时)
666
+ */
667
+ replaceCurrentScrollingContent() {
668
+ var _a, _b;
669
+ // 更新查询时间范围
670
+ this.updateQueryTimeRange();
671
+ // 查询所有当前应该显示的数据(查询足够多的数据以确保包含所有新增/删除)
672
+ const selectedStates = (_a = this.model.generalSetting) === null || _a === void 0 ? void 0 : _a.selectState;
673
+ const timeSort = (_b = this.model.generalSetting) === null || _b === void 0 ? void 0 : _b.timeSort;
674
+ // 使用一个较大的值确保能查询到所有数据,避免因新增数据导致查询不全
675
+ const queryCount = Math.max(this.displayedItems.length || this.maxResultCount, 100);
676
+ // 确定排序参数
677
+ let sorting = 'TriggeredTime ASC'; // 默认升序
678
+ if (timeSort === 0 || timeSort === '0') {
679
+ sorting = 'TriggeredTime ASC'; // 升序
680
+ }
681
+ else if (timeSort === 1 || timeSort === '1') {
682
+ sorting = 'TriggeredTime DESC'; // 降序
683
+ }
684
+ // 兼容处理:如果 selectedStates 为空数组或 undefined,传 undefined(不过滤)
685
+ const stateFilter = (selectedStates && Array.isArray(selectedStates) && selectedStates.length > 0)
686
+ ? selectedStates
687
+ : undefined;
688
+ const input = new GetAlarmsArgs(this.alarmNames, this.startTime, this.endTime, queryCount, 0, // skipCount
689
+ stateFilter, sorting);
690
+ this.alarmsStore.getHistoryAlarms(input).subscribe(result => {
691
+ var _a, _b, _c, _d, _e, _f, _g, _h;
692
+ if (!result.error && result.items) {
693
+ const newItems = result.items;
694
+ // 如果没有数据,清空显示
695
+ if (newItems.length === 0) {
696
+ this.displayedItems = [];
697
+ this.totalWidth = 0;
698
+ this.pageWidths = [];
699
+ this.currentPage = 1;
700
+ this.hasTriedFirstPage = false;
701
+ this.hasMoreData = true;
702
+ // 清空DOM
703
+ if (this.allAlarmsContainer) {
704
+ this.allAlarmsContainer.innerHTML = '';
705
+ const containerWidth = this.model.size.width;
706
+ this.currentLeft = containerWidth;
707
+ this.allAlarmsContainer.style.left = `${containerWidth}px`;
708
+ }
709
+ return;
710
+ }
711
+ // 如果是首次加载或当前没有数据,直接渲染
712
+ if (this.displayedItems.length === 0) {
713
+ this.displayedItems = newItems;
714
+ this.allAlarmsContainer.innerHTML = '';
715
+ this.totalWidth = 0;
716
+ this.pageWidths = [];
717
+ this.renderNewPage(newItems);
718
+ return;
719
+ }
720
+ // 保存当前的滚动位置
721
+ const currentScrollPosition = this.currentLeft;
722
+ // 清空所有DOM元素
723
+ this.allAlarmsContainer.innerHTML = '';
724
+ // 获取语言设置
725
+ const language = ((_c = (_b = (_a = window.abp) === null || _a === void 0 ? void 0 : _a.localization) === null || _b === void 0 ? void 0 : _b.currentLanguage) === null || _c === void 0 ? void 0 : _c.name) || 'zh-Hans';
726
+ const isChinese = language === 'zh-Hans' || language === 'zh';
727
+ // 重新创建所有新数据的DOM元素
728
+ for (let i = 0; i < newItems.length; i++) {
729
+ const alarm = newItems[i];
730
+ const textContainer = document.createElement('div');
731
+ textContainer.style.cssText = `
732
+ font: ${this.fontString};
733
+ color: ${this.headerFont.color || '#e33c39'};
734
+ white-space: nowrap;
735
+ overflow: visible;
736
+ `;
737
+ if (this.headerFont.isUnderline) {
738
+ textContainer.style.textDecoration = 'underline';
739
+ }
740
+ const contentParts = [];
741
+ // 显示触发时间
742
+ if (((_d = this.model.generalSetting) === null || _d === void 0 ? void 0 : _d.showTriggerTime) && alarm.triggeredTime) {
743
+ const formattedTime = moment(alarm.triggeredTime).format('YYYY/MM/DD HH:mm:ss');
744
+ contentParts.push(formattedTime);
745
+ }
746
+ // 显示告警等级
747
+ if (((_e = this.model.generalSetting) === null || _e === void 0 ? void 0 : _e.showAlarmLevel) && alarm.alarmLevel !== undefined) {
748
+ const levelMap = isChinese ? ['警告', '次要', '主要', '严重'] : ['Warning', 'Minor', 'Major', 'Critical'];
749
+ const alarmLevel = levelMap[alarm.alarmLevel] || (isChinese ? '警告' : 'Warning');
750
+ contentParts.push(alarmLevel);
751
+ }
752
+ // 显示告警名称
753
+ if (((_f = this.model.generalSetting) === null || _f === void 0 ? void 0 : _f.showAlarmName) && alarm.name) {
754
+ contentParts.push(alarm.name);
755
+ }
756
+ // 显示告警内容
757
+ if (((_g = this.model.generalSetting) === null || _g === void 0 ? void 0 : _g.showAlarmContent) && alarm.message) {
758
+ contentParts.push(alarm.message);
759
+ }
760
+ // 显示告警状态
761
+ if (((_h = this.model.generalSetting) === null || _h === void 0 ? void 0 : _h.showAlarmState) && alarm.state !== undefined) {
762
+ const stateMap = isChinese ? ['触发/未确认', '触发/已确认', '恢复/未确认', '恢复/已确认'] : ['Triggered/Unconfirmed', 'Triggered/Confirmed', 'Restored/Unconfirmed', 'Restored/Confirmed'];
763
+ const alarmState = stateMap[alarm.state] || (isChinese ? '触发/未确认' : 'Triggered/Unconfirmed');
764
+ contentParts.push(alarmState);
765
+ }
766
+ textContainer.textContent = contentParts.join(' ');
767
+ textContainer.setAttribute('data-index', i.toString());
768
+ this.allAlarmsContainer.appendChild(textContainer);
769
+ }
770
+ // 重新计算totalWidth
771
+ const allChildren = Array.from(this.allAlarmsContainer.children);
772
+ let newTotalWidth = 0;
773
+ allChildren.forEach(child => {
774
+ newTotalWidth += child.offsetWidth + 80;
775
+ });
776
+ if (newTotalWidth > 0) {
777
+ newTotalWidth -= 80; // 移除最后一个gap
778
+ }
779
+ // 更新状态
780
+ this.displayedItems = newItems;
781
+ this.totalWidth = newTotalWidth;
782
+ this.pageWidths = [newTotalWidth]; // 重置为单页
783
+ this.hasMoreData = result.totalCount > newItems.length;
784
+ // 保持滚动位置不变,继续滚动
785
+ this.currentLeft = currentScrollPosition;
786
+ this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
787
+ }
788
+ });
789
+ }
668
790
  }
@@ -1 +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"}]}}}}]
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"}],"replaceCurrentScrollingContent":[{"__symbolic":"method"}]}}}}]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "main": "bundles/fc-gui.umd.js",
3
- "version": "3.0.0-alpha.132",
3
+ "version": "3.0.0-alpha.134",
4
4
  "module": "public_api.js",
5
5
  "typings": "public_api.d.ts",
6
6
  "license": "UNLICENSED",