@flexem/fc-gui 3.0.0-alpha.133 → 3.0.0-alpha.135

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
  }
@@ -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
  // 检查是否需要加载下一页(只有在自动循环模式下才需要预加载)
@@ -396,9 +392,9 @@ export class ScrollAlarmElement extends ConditionalDynamicDisplayElement {
396
392
  this.getAlarmData();
397
393
  }
398
394
  }
399
- // 当内容完全滚出容器左侧时(currentLeft + totalWidth < 0
400
- // 说明所有内容都已经滚出视图,需要重置或停止
401
- if (this.currentLeft + this.totalWidth < 0) {
395
+ // 当内容完全滚出容器左侧时(currentLeft + totalWidth < -50
396
+ // 说明所有内容都已经滚出视图(不开启自动循环时多滚动50px确保最后一个字完全滚出)
397
+ if (this.currentLeft + this.totalWidth < -50) {
402
398
  if (this.autoCycle) {
403
399
  // 自动循环模式:无缝衔接回到容器右侧
404
400
  if (this.hasMoreData) {
@@ -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
  `;
@@ -649,9 +645,9 @@ export class ScrollAlarmElement extends ConditionalDynamicDisplayElement {
649
645
  this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
650
646
  // 当内容完全滚出容器左侧时(内容右边缘完全移出容器左边缘)
651
647
  // currentLeft + totalWidth 表示内容右边缘的位置
652
- // 当这个值 <= 0 时,表示内容右边缘已经到达或超过容器左边缘,内容完全不可见
648
+ // 当这个值 <= -50 时,表示内容完全不可见(不开启自动循环时多滚动50px确保最后一个字完全滚出)
653
649
  const rightEdge = this.currentLeft + this.totalWidth;
654
- if (rightEdge <= 0) {
650
+ if (rightEdge <= -50) {
655
651
  if (this.autoCycle) {
656
652
  // 自动循环模式:重置到容器右侧(使用配置宽度)
657
653
  this.currentLeft = this.model.size.width;
@@ -665,4 +661,137 @@ 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
+ // 设置 hasMoreData 状态,防止滚动时误触发 getAlarmData
718
+ this.hasMoreData = result.totalCount > newItems.length;
719
+ // 设置初始位置到容器右侧
720
+ this.currentLeft = this.container.clientWidth;
721
+ this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
722
+ this.renderNewPage(newItems);
723
+ // 启动滚动
724
+ if (!this.isScrolling) {
725
+ this.initScrolling();
726
+ }
727
+ return;
728
+ }
729
+ // 清空所有DOM元素
730
+ this.allAlarmsContainer.innerHTML = '';
731
+ // 获取语言设置
732
+ 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';
733
+ const isChinese = language === 'zh-Hans' || language === 'zh';
734
+ // 重新创建所有新数据的DOM元素
735
+ for (let i = 0; i < newItems.length; i++) {
736
+ const alarm = newItems[i];
737
+ const textContainer = document.createElement('div');
738
+ textContainer.style.cssText = `
739
+ font: ${this.fontString};
740
+ color: ${this.headerFont.color || '#e33c39'};
741
+ white-space: nowrap;
742
+ overflow: visible;
743
+ `;
744
+ if (this.headerFont.isUnderline) {
745
+ textContainer.style.textDecoration = 'underline';
746
+ }
747
+ const contentParts = [];
748
+ // 显示触发时间
749
+ if (((_d = this.model.generalSetting) === null || _d === void 0 ? void 0 : _d.showTriggerTime) && alarm.triggeredTime) {
750
+ const formattedTime = moment(alarm.triggeredTime).format('YYYY/MM/DD HH:mm:ss');
751
+ contentParts.push(formattedTime);
752
+ }
753
+ // 显示告警等级
754
+ if (((_e = this.model.generalSetting) === null || _e === void 0 ? void 0 : _e.showAlarmLevel) && alarm.alarmLevel !== undefined) {
755
+ const levelMap = isChinese ? ['警告', '次要', '主要', '严重'] : ['Warning', 'Minor', 'Major', 'Critical'];
756
+ const alarmLevel = levelMap[alarm.alarmLevel] || (isChinese ? '警告' : 'Warning');
757
+ contentParts.push(alarmLevel);
758
+ }
759
+ // 显示告警名称
760
+ if (((_f = this.model.generalSetting) === null || _f === void 0 ? void 0 : _f.showAlarmName) && alarm.name) {
761
+ contentParts.push(alarm.name);
762
+ }
763
+ // 显示告警内容
764
+ if (((_g = this.model.generalSetting) === null || _g === void 0 ? void 0 : _g.showAlarmContent) && alarm.message) {
765
+ contentParts.push(alarm.message);
766
+ }
767
+ // 显示告警状态
768
+ if (((_h = this.model.generalSetting) === null || _h === void 0 ? void 0 : _h.showAlarmState) && alarm.state !== undefined) {
769
+ const stateMap = isChinese ? ['触发/未确认', '触发/已确认', '恢复/未确认', '恢复/已确认'] : ['Triggered/Unconfirmed', 'Triggered/Confirmed', 'Restored/Unconfirmed', 'Restored/Confirmed'];
770
+ const alarmState = stateMap[alarm.state] || (isChinese ? '触发/未确认' : 'Triggered/Unconfirmed');
771
+ contentParts.push(alarmState);
772
+ }
773
+ textContainer.textContent = contentParts.join(' ');
774
+ textContainer.setAttribute('data-index', i.toString());
775
+ this.allAlarmsContainer.appendChild(textContainer);
776
+ }
777
+ // 重新计算totalWidth
778
+ const allChildren = Array.from(this.allAlarmsContainer.children);
779
+ let newTotalWidth = 0;
780
+ allChildren.forEach(child => {
781
+ newTotalWidth += child.offsetWidth + 80;
782
+ });
783
+ if (newTotalWidth > 0) {
784
+ newTotalWidth -= 80; // 移除最后一个gap
785
+ }
786
+ // 更新状态
787
+ this.displayedItems = newItems;
788
+ this.totalWidth = newTotalWidth;
789
+ this.pageWidths = [newTotalWidth]; // 重置为单页
790
+ this.hasMoreData = result.totalCount > newItems.length;
791
+ // 收到新告警时,重置滚动位置到容器右侧,确保新内容能被滚动出来显示
792
+ this.currentLeft = this.container.clientWidth;
793
+ this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
794
+ }
795
+ });
796
+ }
668
797
  }
@@ -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.133",
3
+ "version": "3.0.0-alpha.135",
4
4
  "module": "public_api.js",
5
5
  "typings": "public_api.d.ts",
6
6
  "license": "UNLICENSED",