@flexem/fc-gui 3.0.0-alpha.19 → 3.0.0-alpha.190
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.
- package/CHANGELOG.md +413 -0
- package/assets/img/black_first_page.png +0 -0
- package/assets/img/black_last_page.png +0 -0
- package/assets/img/black_next_page.png +0 -0
- package/assets/img/black_previous_page.png +0 -0
- package/assets/img/exclamation-outline-circle.png +0 -0
- package/bundles/@flexem/fc-gui.umd.js +37817 -32408
- package/bundles/@flexem/fc-gui.umd.js.map +1 -1
- package/bundles/@flexem/fc-gui.umd.min.js +5 -5
- package/bundles/@flexem/fc-gui.umd.min.js.map +1 -1
- package/communication/variable/variable-communicator.d.ts +5 -0
- package/communication/variable/variable-state-enum.d.ts +1 -0
- package/communication/variable/variable-state-enum.js +1 -0
- package/communication/variable/variable-state-enum.metadata.json +1 -1
- package/communication/variable/variable-value.d.ts +4 -1
- package/communication/variable/variable-value.js +4 -1
- package/communication/variable/variable-value.metadata.json +1 -1
- package/config/alarm/alarm.store.d.ts +6 -0
- package/config/alarm/alarm.store.js +0 -0
- package/config/alarm/alarm.store.metadata.json +1 -0
- package/config/alarm/get-alarms-args.d.ts +12 -0
- package/config/alarm/get-alarms-args.js +13 -0
- package/config/alarm/get-alarms-args.metadata.json +1 -0
- package/config/alarm/index.d.ts +2 -0
- package/config/alarm/index.js +1 -0
- package/config/alarm/index.metadata.json +1 -0
- package/config/config-store.d.ts +2 -0
- package/config/gui-feature-config.d.ts +3 -0
- package/config/gui-feature-config.js +3 -0
- package/config/gui-feature-config.metadata.json +1 -0
- package/config/index.d.ts +2 -0
- package/config/index.js +2 -0
- package/config/index.metadata.json +1 -1
- package/config/variable/variable-store.d.ts +5 -0
- package/elements/air-quality/air-quality-element.js +3 -4
- package/elements/alarm/alarm-element.d.ts +106 -0
- package/elements/alarm/alarm-element.js +836 -0
- package/elements/alarm/alarm-element.metadata.json +1 -0
- package/elements/alarm/alarm-table-scrollbar.d.ts +35 -0
- package/elements/alarm/alarm-table-scrollbar.js +170 -0
- package/elements/alarm/alarm-table-scrollbar.metadata.json +1 -0
- package/elements/bar-graph-element.d.ts +10 -2
- package/elements/bar-graph-element.js +135 -5
- package/elements/bar-graph-element.metadata.json +1 -1
- package/elements/base/readable-element.d.ts +6 -1
- package/elements/base/readable-element.js +69 -2
- package/elements/base/readable-element.metadata.json +1 -1
- package/elements/base/state-control-element.d.ts +13 -1
- package/elements/base/state-control-element.js +42 -8
- package/elements/base/state-control-element.metadata.json +1 -1
- package/elements/character-display/character-display-element.d.ts +12 -2
- package/elements/character-display/character-display-element.js +35 -7
- package/elements/character-display/character-display-element.metadata.json +1 -1
- package/elements/datetime-display/datetime-display-element.d.ts +1 -0
- package/elements/datetime-display/datetime-display-element.js +10 -2
- package/elements/datetime-display/datetime-display-element.metadata.json +1 -1
- package/elements/datetime-display/time-zone-select-json.d.ts +8 -0
- package/elements/datetime-display/time-zone-select-json.js +558 -0
- package/elements/historical-curve/historical-curve.element.d.ts +45 -3
- package/elements/historical-curve/historical-curve.element.js +707 -45
- package/elements/historical-curve/historical-curve.element.metadata.json +1 -1
- package/elements/main-element.d.ts +1 -0
- package/elements/main-element.js +72 -10
- package/elements/main-element.metadata.json +1 -1
- package/elements/meter-element.d.ts +7 -1
- package/elements/meter-element.js +76 -7
- package/elements/meter-element.metadata.json +1 -1
- package/elements/numerical-display/numerical-display-element.d.ts +31 -3
- package/elements/numerical-display/numerical-display-element.js +166 -15
- package/elements/numerical-display/numerical-display-element.metadata.json +1 -1
- package/elements/per-view-variable-communicator.d.ts +4 -0
- package/elements/per-view-variable-communicator.js +21 -1
- package/elements/per-view-variable-communicator.metadata.json +1 -1
- package/elements/ring-graph/ring-graph-element.d.ts +13 -1
- package/elements/ring-graph/ring-graph-element.js +164 -3
- package/elements/ring-graph/ring-graph-element.metadata.json +1 -1
- package/elements/scroll-alarm/scroll-alarm-element.d.ts +79 -0
- package/elements/scroll-alarm/scroll-alarm-element.js +845 -0
- package/elements/scroll-alarm/scroll-alarm-element.metadata.json +1 -0
- package/elements/shared/graph/graph-state-element.d.ts +1 -0
- package/elements/shared/graph/graph-state-element.js +30 -1
- package/elements/shared/graph/graph-state-element.metadata.json +1 -1
- package/elements/shared/text/text-element.d.ts +14 -0
- package/elements/shared/text/text-element.js +38 -6
- package/elements/shared/text/text-element.metadata.json +1 -1
- package/elements/shared/text/text-state-element.d.ts +39 -2
- package/elements/shared/text/text-state-element.js +242 -67
- package/elements/shared/text/text-state-element.metadata.json +1 -1
- package/elements/static-elements/hyperlink-element.d.ts +28 -2
- package/elements/static-elements/hyperlink-element.js +153 -4
- package/elements/static-elements/hyperlink-element.metadata.json +1 -1
- package/elements/static-elements/text-element.d.ts +28 -2
- package/elements/static-elements/text-element.js +162 -12
- package/elements/static-elements/text-element.metadata.json +1 -1
- package/elements/switch-indicator-light/bit-indicator-light-operator.d.ts +1 -0
- package/elements/switch-indicator-light/bit-indicator-light-operator.js +10 -3
- package/elements/switch-indicator-light/bit-indicator-light-operator.metadata.json +1 -1
- package/elements/switch-indicator-light/switch-indicator-light-element.d.ts +20 -2
- package/elements/switch-indicator-light/switch-indicator-light-element.js +92 -15
- package/elements/switch-indicator-light/switch-indicator-light-element.metadata.json +1 -1
- package/elements/switch-indicator-light/word-indicator-light-operator.d.ts +1 -0
- package/elements/switch-indicator-light/word-indicator-light-operator.js +10 -3
- package/elements/switch-indicator-light/word-indicator-light-operator.metadata.json +1 -1
- package/elements/video/video-element.d.ts +10 -0
- package/elements/video/video-element.js +139 -21
- package/elements/video/video-element.metadata.json +1 -1
- package/elements/view-operation/view-operation.element.d.ts +28 -2
- package/elements/view-operation/view-operation.element.js +172 -8
- package/elements/view-operation/view-operation.element.metadata.json +1 -1
- package/elements/weather/weater-element.js +0 -1
- package/gui/gui-context.d.ts +25 -2
- package/gui/gui-host.d.ts +1 -1
- package/gui/gui-view.d.ts +19 -2
- package/gui/gui-view.js +147 -12
- package/gui/gui-view.metadata.json +1 -1
- package/gui/gui.component.d.ts +3 -0
- package/gui/gui.component.js +15 -2
- package/gui/gui.component.metadata.json +1 -1
- package/localization/localization.service.d.ts +11 -0
- package/localization/localization.service.js +16 -5
- package/localization/localization.service.metadata.json +1 -1
- package/localization/localization.service.zh_CN.js +12 -1
- package/localization/localization.service.zh_CN.metadata.json +1 -1
- package/modal/alert/alert-modal.component.js +1 -1
- package/modal/alert/alert-modal.component.less +13 -5
- package/modal/alert/alert-modal.component.metadata.json +1 -1
- package/modal/confirm-operation/confirm-operation-modal.component.html +2 -2
- package/modal/confirm-operation/confirm-operation-modal.component.js +2 -2
- package/modal/confirm-operation/confirm-operation-modal.component.less +10 -7
- package/modal/confirm-operation/confirm-operation-modal.component.metadata.json +1 -1
- package/modal/verify-password/verify-password-modal.component.d.ts +6 -2
- package/modal/verify-password/verify-password-modal.component.html +2 -2
- package/modal/verify-password/verify-password-modal.component.js +11 -5
- package/modal/verify-password/verify-password-modal.component.less +9 -0
- package/modal/verify-password/verify-password-modal.component.metadata.json +1 -1
- package/modal/write-character/write-character-modal-args.d.ts +3 -1
- package/modal/write-character/write-character-modal-args.js +2 -1
- package/modal/write-character/write-character-modal-args.metadata.json +1 -1
- package/modal/write-character/write-character-modal.component.d.ts +4 -2
- package/modal/write-character/write-character-modal.component.html +4 -4
- package/modal/write-character/write-character-modal.component.js +11 -5
- package/modal/write-character/write-character-modal.component.less +15 -0
- package/modal/write-character/write-character-modal.component.metadata.json +1 -1
- package/modal/write-value/write-value-modal-args.d.ts +5 -1
- package/modal/write-value/write-value-modal-args.js +3 -1
- package/modal/write-value/write-value-modal-args.metadata.json +1 -1
- package/modal/write-value/write-value-modal.component.d.ts +16 -8
- package/modal/write-value/write-value-modal.component.html +10 -5
- package/modal/write-value/write-value-modal.component.js +103 -21
- package/modal/write-value/write-value-modal.component.less +16 -1
- package/modal/write-value/write-value-modal.component.metadata.json +1 -1
- package/model/alarm/alarm.model.d.ts +14 -0
- package/model/alarm/alarm.model.js +0 -0
- package/model/alarm/alarm.model.metadata.json +1 -0
- package/model/bar-graph/bar-graph.d.ts +4 -0
- package/model/base/font-setting-model.d.ts +22 -1
- package/model/base/font-setting-model.metadata.json +1 -1
- package/model/base/readable-model.d.ts +4 -0
- package/model/character-display/character-display.d.ts +1 -0
- package/model/datetime-display/datetime-display.d.ts +1 -0
- package/model/historical-curve/historical-curve-axis-settings.d.ts +11 -0
- package/model/historical-curve/historical-curve-axis-settings.js +5 -0
- package/model/historical-curve/historical-curve-axis-settings.metadata.json +1 -1
- package/model/historical-curve/historical-curve-chanel.model.d.ts +8 -0
- package/model/historical-curve/historical-curve.display-settings.d.ts +1 -0
- package/model/meter/meter.d.ts +4 -0
- package/model/numerical-display/numerical-display.d.ts +1 -0
- package/model/numerical-display/numerical-operation.d.ts +10 -2
- package/model/ring-graph/ring-graph.model.d.ts +8 -0
- package/model/scroll-alarm/scroll-alarm.model.d.ts +21 -0
- package/model/scroll-alarm/scroll-alarm.model.js +0 -0
- package/model/scroll-alarm/scroll-alarm.model.metadata.json +1 -0
- package/model/settings/popup/view-popup-location-type.d.ts +2 -1
- package/model/settings/popup/view-popup-location-type.js +1 -0
- package/model/settings/popup/view-popup-location-type.metadata.json +1 -1
- package/model/shared/state/state.d.ts +1 -0
- package/model/shared/state/state.js +1 -0
- package/model/shared/state/state.metadata.json +1 -1
- package/model/shared/text/font.d.ts +1 -1
- package/model/shared/text/text.d.ts +3 -0
- package/model/switch-indicator-light/switch-indicator-light.d.ts +3 -0
- package/model/view-operation/view-operation-element.model.d.ts +7 -1
- package/package.json +1 -1
- package/public_api.js +1 -0
- package/remote/communication/variable/remote-variable-communicator.d.ts +30 -0
- package/remote/communication/variable/remote-variable-communicator.js +193 -3
- package/remote/communication/variable/remote-variable-communicator.metadata.json +1 -1
- package/remote/communication/variable/remote-variable-protocol.d.ts +8 -0
- package/service/index.d.ts +4 -0
- package/service/index.js +1 -0
- package/service/index.metadata.json +1 -1
- package/service/language.service.d.ts +37 -0
- package/service/language.service.js +0 -0
- package/service/language.service.metadata.json +1 -0
- package/service/released-variable/index.d.ts +1 -0
- package/service/released-variable/index.js +0 -0
- package/service/released-variable/index.metadata.json +1 -0
- package/service/released-variable/released-variable.service.d.ts +4 -0
- package/service/released-variable/released-variable.service.js +0 -0
- package/service/released-variable/released-variable.service.metadata.json +1 -0
- package/service/system-text-library.service.d.ts +77 -0
- package/service/system-text-library.service.js +29 -0
- package/service/system-text-library.service.metadata.json +1 -0
- package/service/text-library.service.d.ts +49 -0
- package/service/text-library.service.js +0 -0
- package/service/text-library.service.metadata.json +1 -0
- package/shared/gui-consts.d.ts +2 -0
- package/shared/gui-consts.js +3 -1
- package/shared/gui-consts.metadata.json +1 -1
- package/utils/data-type/fbox-data-type.service.js +40 -0
- package/utils/numerical-operation.service.js +28 -4
- package/view/popup-view.service.d.ts +1 -1
|
@@ -0,0 +1,836 @@
|
|
|
1
|
+
import * as d3 from 'd3';
|
|
2
|
+
import { SYSTEM_TEXT_LIBRARY_TYPES, ALARM_TABLE_HEADER_KEYS, TIME_PERIOD_KEYS } from '../../service';
|
|
3
|
+
import { ConditionalDisplayElement } from '../base/conditional-display-element';
|
|
4
|
+
import { GetAlarmsArgs } from '../../config';
|
|
5
|
+
import * as moment from 'moment';
|
|
6
|
+
import { LOGGER_SERVICE_TOKEN } from '../../logger';
|
|
7
|
+
import { AlarmTableScrollbar } from './alarm-table-scrollbar';
|
|
8
|
+
var AlaertElementStatus;
|
|
9
|
+
(function (AlaertElementStatus) {
|
|
10
|
+
AlaertElementStatus[AlaertElementStatus["Normal"] = 0] = "Normal";
|
|
11
|
+
AlaertElementStatus[AlaertElementStatus["Loading"] = 1] = "Loading"; // 加载中
|
|
12
|
+
})(AlaertElementStatus || (AlaertElementStatus = {}));
|
|
13
|
+
export class AlarmElement extends ConditionalDisplayElement {
|
|
14
|
+
constructor(element, injector, permissionChecker, variableCommunicator, variableStore, alarmsStore, signalRAppId, systemTextLibraryService, languageService, guiContext) {
|
|
15
|
+
var _a;
|
|
16
|
+
super(element, permissionChecker, variableCommunicator, variableStore, signalRAppId);
|
|
17
|
+
this.alarmsStore = alarmsStore;
|
|
18
|
+
this.systemTextLibraryService = systemTextLibraryService;
|
|
19
|
+
this.languageService = languageService;
|
|
20
|
+
this.guiContext = guiContext;
|
|
21
|
+
this.elementStatus = AlaertElementStatus.Loading;
|
|
22
|
+
this.displayOption = {
|
|
23
|
+
dataLimit: 500,
|
|
24
|
+
dataZoomHeight: 32,
|
|
25
|
+
marginLeft: 1,
|
|
26
|
+
marginRight: 20,
|
|
27
|
+
mobileMinWidth: 450,
|
|
28
|
+
operationAreaHeight: 32,
|
|
29
|
+
operationAreaMarginTop: 10,
|
|
30
|
+
operationSelectFontSize: '16px',
|
|
31
|
+
operationButtonWidth: 24,
|
|
32
|
+
operationButtonHeight: 24,
|
|
33
|
+
operationButtonMargin: 4
|
|
34
|
+
};
|
|
35
|
+
this.alarmNames = [];
|
|
36
|
+
this.alarmList = [];
|
|
37
|
+
this.currentAlarmList = [];
|
|
38
|
+
this.page = 0;
|
|
39
|
+
this.totalCount = 0;
|
|
40
|
+
this.pageSize = 5;
|
|
41
|
+
this.maxVisibleRows = 15;
|
|
42
|
+
this.scrollWindowStart = 0;
|
|
43
|
+
this.rowHeight = 0;
|
|
44
|
+
this.touchStartY = 0;
|
|
45
|
+
this.touchScrollAccumulator = 0;
|
|
46
|
+
this.scrollHovered = false;
|
|
47
|
+
this.touchScrolling = false;
|
|
48
|
+
this.isDisposed = false;
|
|
49
|
+
this.handleScrollWheel = (event) => {
|
|
50
|
+
if (!this.rowHeight || !this.getMaxWindowStart())
|
|
51
|
+
return;
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
event.stopPropagation();
|
|
54
|
+
const screenRowHeight = this.getScreenRowHeight();
|
|
55
|
+
const delta = event.deltaMode === 1 ? event.deltaY * screenRowHeight
|
|
56
|
+
: event.deltaMode === 2 ? event.deltaY * screenRowHeight * this.maxVisibleRows : event.deltaY;
|
|
57
|
+
this.touchScrollAccumulator += delta;
|
|
58
|
+
const rowDelta = Math.trunc(this.touchScrollAccumulator / screenRowHeight);
|
|
59
|
+
if (rowDelta !== 0) {
|
|
60
|
+
this.touchScrollAccumulator -= rowDelta * screenRowHeight;
|
|
61
|
+
this.moveScrollWindowBy(rowDelta);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
this.handleScrollTouchStart = (event) => {
|
|
65
|
+
if (event.touches.length !== 1 || !this.getMaxWindowStart())
|
|
66
|
+
return;
|
|
67
|
+
this.touchScrolling = true;
|
|
68
|
+
clearInterval(this.scrollIntervalId);
|
|
69
|
+
event.stopPropagation();
|
|
70
|
+
this.touchStartY = event.touches[0].clientY;
|
|
71
|
+
this.touchScrollAccumulator = 0;
|
|
72
|
+
};
|
|
73
|
+
this.handleScrollTouchMove = (event) => {
|
|
74
|
+
if (!this.touchScrolling || event.touches.length !== 1)
|
|
75
|
+
return;
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
event.stopPropagation();
|
|
78
|
+
const currentY = event.touches[0].clientY;
|
|
79
|
+
const deltaY = this.touchStartY - currentY;
|
|
80
|
+
this.touchStartY = currentY;
|
|
81
|
+
this.touchScrollAccumulator += deltaY;
|
|
82
|
+
const screenRowHeight = this.getScreenRowHeight();
|
|
83
|
+
const rowDelta = Math.trunc(this.touchScrollAccumulator / screenRowHeight);
|
|
84
|
+
if (rowDelta !== 0) {
|
|
85
|
+
this.touchScrollAccumulator -= rowDelta * screenRowHeight;
|
|
86
|
+
this.moveScrollWindowBy(rowDelta);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
this.handleScrollMouseEnter = () => {
|
|
90
|
+
if (!this.supportsMouseHover())
|
|
91
|
+
return;
|
|
92
|
+
this.scrollHovered = true;
|
|
93
|
+
clearInterval(this.scrollIntervalId);
|
|
94
|
+
};
|
|
95
|
+
this.handleScrollMouseLeave = () => {
|
|
96
|
+
this.scrollHovered = false;
|
|
97
|
+
this.startAutoScroll();
|
|
98
|
+
};
|
|
99
|
+
this.handleScrollTouchEnd = () => {
|
|
100
|
+
this.touchScrolling = false;
|
|
101
|
+
this.startAutoScroll();
|
|
102
|
+
};
|
|
103
|
+
this.rootElement.selectAll('*').remove();
|
|
104
|
+
this.setStatusAsLoading();
|
|
105
|
+
this.logger = injector.get(LOGGER_SERVICE_TOKEN);
|
|
106
|
+
this.variableCommunicator = variableCommunicator;
|
|
107
|
+
this.pageSize = this.model.generalSetting.pageSize;
|
|
108
|
+
localStorage.setItem('simulate-time', moment().valueOf() + '');
|
|
109
|
+
// 订阅语种变化事件
|
|
110
|
+
this.subscribeLanguageChange();
|
|
111
|
+
if (this.model.filterSetting) {
|
|
112
|
+
this.alarmNames = this.model.filterSetting.detailsData.map(item => item.name);
|
|
113
|
+
this.currentTimePeriod = (_a = this.model.filterSetting) === null || _a === void 0 ? void 0 : _a.displayPeriod;
|
|
114
|
+
this.updateQueryTimeRange();
|
|
115
|
+
if (this.model.filterSetting.alarmType) {
|
|
116
|
+
this.refreshIntervalId = setInterval(() => {
|
|
117
|
+
if (this.model.generalSetting.autoScroll) {
|
|
118
|
+
// 开启滚动时,仅更新数据不重渲染,保持滚动进度
|
|
119
|
+
this.refreshCurrentPageData();
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
// 未开启滚动时,返回第一页
|
|
123
|
+
this.loadFirstPage();
|
|
124
|
+
}
|
|
125
|
+
this.logger.debug(`[GUI]Refresh Alarm Table:${d3.time.format('%x %X')(new Date())}`);
|
|
126
|
+
}, this.model.filterSetting.refreshCycle * 60 * 1000);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
variableCommunicator.subscribeUserDeviceAlarms(signalRAppId).subscribe(alarms => {
|
|
130
|
+
alarms.forEach(alarm => {
|
|
131
|
+
if (this.alarmNames.indexOf(alarm.name) !== -1) {
|
|
132
|
+
if (this.model.generalSetting.autoScroll) {
|
|
133
|
+
// 开启滚动时,刷新当前页并保持滚动进度
|
|
134
|
+
this.refreshCurrentPageData();
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
// 未开启滚动时,刷新当前页(原有逻辑)
|
|
138
|
+
this.getAlarmData();
|
|
139
|
+
}
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
this.getAlarmData();
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
this.totalCount = 0;
|
|
149
|
+
this.alarmList = [];
|
|
150
|
+
this.renderElement();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
dispose() {
|
|
154
|
+
this.isDisposed = true;
|
|
155
|
+
clearInterval(this.refreshIntervalId);
|
|
156
|
+
clearInterval(this.scrollIntervalId);
|
|
157
|
+
clearTimeout(this.getAlarmDataId);
|
|
158
|
+
this.unbindScrollHoverEvents();
|
|
159
|
+
// 取消语种变化订阅
|
|
160
|
+
if (this.languageChangeSubscription) {
|
|
161
|
+
this.languageChangeSubscription.unsubscribe();
|
|
162
|
+
this.languageChangeSubscription = undefined;
|
|
163
|
+
}
|
|
164
|
+
this.logger.debug(`[GUI]Dispose Alarm Table Refresh Interval:${d3.time.format('%x %X')(new Date())}`);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* 订阅语种变化事件
|
|
168
|
+
*/
|
|
169
|
+
subscribeLanguageChange() {
|
|
170
|
+
if (this.guiContext && this.guiContext.languageChanged$) {
|
|
171
|
+
this.languageChangeSubscription = this.guiContext.languageChanged$.subscribe(() => {
|
|
172
|
+
// 只更新文案,不重新查询数据
|
|
173
|
+
this.updateLanguageTexts();
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* 更新语种相关的文案(表头和时间段选择器)
|
|
179
|
+
*/
|
|
180
|
+
updateLanguageTexts() {
|
|
181
|
+
var _a;
|
|
182
|
+
// 更新表头文本
|
|
183
|
+
const headerCells = this.$element.find('table th');
|
|
184
|
+
for (let col = 0; col < 4 && col < headerCells.length; col++) {
|
|
185
|
+
headerCells.eq(col).text(this.getHeaderTextByColumn(col));
|
|
186
|
+
}
|
|
187
|
+
// 更新时间段选择器选项
|
|
188
|
+
if ((_a = this.model.filterSetting) === null || _a === void 0 ? void 0 : _a.alarmType) {
|
|
189
|
+
const selectElement = this.rootElement.select('select');
|
|
190
|
+
if (!selectElement.empty()) {
|
|
191
|
+
// 重新生成时间段数据
|
|
192
|
+
const updatedTimePeriods = this.getValidTimePeriods();
|
|
193
|
+
this.timePeriods = updatedTimePeriods;
|
|
194
|
+
// 更新选项文本
|
|
195
|
+
const options = selectElement.selectAll('option');
|
|
196
|
+
options.each(function (_d, i) {
|
|
197
|
+
if (i < updatedTimePeriods.length) {
|
|
198
|
+
d3.select(this).text(updatedTimePeriods[i].name);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* 获取当前语种的 culture 代码
|
|
206
|
+
*/
|
|
207
|
+
getCurrentCulture() {
|
|
208
|
+
var _a, _b, _c, _e, _f, _g;
|
|
209
|
+
// 获取当前语种ID
|
|
210
|
+
const currentLanguageId = (_c = (_b = (_a = this.guiContext) === null || _a === void 0 ? void 0 : _a.getCurrentLanguageId) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : null;
|
|
211
|
+
// 确定要使用的语种代码(culture)
|
|
212
|
+
const defaultLanguage = ((_e = this.languageService) === null || _e === void 0 ? void 0 : _e.getDefaultLanguage()) || 'zh-CN';
|
|
213
|
+
if (currentLanguageId === null || currentLanguageId === undefined) {
|
|
214
|
+
// 设备未设置当前语种,使用默认语种
|
|
215
|
+
return defaultLanguage;
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
// 设备已设置当前语种,获取对应的语种代码
|
|
219
|
+
const currentLanguage = (_g = (_f = this.guiContext) === null || _f === void 0 ? void 0 : _f.getLanguageCultureById) === null || _g === void 0 ? void 0 : _g.call(_f, currentLanguageId);
|
|
220
|
+
if (currentLanguage) {
|
|
221
|
+
return currentLanguage;
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
// 无法获取语种代码,使用默认语种
|
|
225
|
+
return defaultLanguage;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* 根据列索引获取表头翻译(从系统文本库获取多语种翻译)
|
|
231
|
+
* 固定4项表头,按列索引顺序:告警名称、告警内容、告警等级、时间
|
|
232
|
+
*/
|
|
233
|
+
getHeaderTextByColumn(columnIndex) {
|
|
234
|
+
if (columnIndex < 0 || columnIndex > 3) {
|
|
235
|
+
return '';
|
|
236
|
+
}
|
|
237
|
+
const currentCulture = this.getCurrentCulture();
|
|
238
|
+
const systemType = SYSTEM_TEXT_LIBRARY_TYPES.COMPONENT_BUILTIN;
|
|
239
|
+
const headerKeys = [
|
|
240
|
+
ALARM_TABLE_HEADER_KEYS.ALARM_NAME,
|
|
241
|
+
ALARM_TABLE_HEADER_KEYS.ALARM_MESSAGE,
|
|
242
|
+
ALARM_TABLE_HEADER_KEYS.ALARM_LEVEL,
|
|
243
|
+
ALARM_TABLE_HEADER_KEYS.TIME
|
|
244
|
+
];
|
|
245
|
+
// 尝试从系统文本库获取翻译
|
|
246
|
+
if (this.systemTextLibraryService) {
|
|
247
|
+
const translation = this.systemTextLibraryService.getSystemTextValue(systemType, headerKeys[columnIndex], currentCulture);
|
|
248
|
+
if (translation) {
|
|
249
|
+
return translation;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return '';
|
|
253
|
+
}
|
|
254
|
+
getValidTimePeriods() {
|
|
255
|
+
const timePeriods = new Array();
|
|
256
|
+
timePeriods.push({ key: 6, name: this.getTimePeriodText(TIME_PERIOD_KEYS.LAST_THIRTY_MINUTES) });
|
|
257
|
+
timePeriods.push({ key: 1, name: this.getTimePeriodText(TIME_PERIOD_KEYS.LAST_ONE_HOUR) });
|
|
258
|
+
timePeriods.push({ key: 7, name: this.getTimePeriodText(TIME_PERIOD_KEYS.LAST_EIGHT_HOURS) });
|
|
259
|
+
timePeriods.push({ key: 2, name: this.getTimePeriodText(TIME_PERIOD_KEYS.LAST_TWENTY_FOUR_HOURS) });
|
|
260
|
+
timePeriods.push({ key: 3, name: this.getTimePeriodText(TIME_PERIOD_KEYS.LAST_SEVEN_DAYS) });
|
|
261
|
+
timePeriods.push({ key: 4, name: this.getTimePeriodText(TIME_PERIOD_KEYS.LAST_THIRTY_DAYS) });
|
|
262
|
+
timePeriods.push({ key: 5, name: this.getTimePeriodText(TIME_PERIOD_KEYS.LAST_ONE_YEAR) });
|
|
263
|
+
return timePeriods;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* 获取时间段文案(从系统文本库获取多语种翻译)
|
|
267
|
+
*/
|
|
268
|
+
getTimePeriodText(textKey) {
|
|
269
|
+
const currentCulture = this.getCurrentCulture();
|
|
270
|
+
const systemType = SYSTEM_TEXT_LIBRARY_TYPES.COMPONENT_BUILTIN;
|
|
271
|
+
if (this.systemTextLibraryService) {
|
|
272
|
+
const translation = this.systemTextLibraryService.getSystemTextValue(systemType, textKey, currentCulture);
|
|
273
|
+
if (translation) {
|
|
274
|
+
return translation;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return '';
|
|
278
|
+
}
|
|
279
|
+
getAlarmData() {
|
|
280
|
+
clearInterval(this.scrollIntervalId);
|
|
281
|
+
this.unbindScrollHoverEvents();
|
|
282
|
+
this.rootElement.selectAll('*').remove();
|
|
283
|
+
this.setStatusAsLoading();
|
|
284
|
+
clearTimeout(this.getAlarmDataId);
|
|
285
|
+
this.getAlarmDataId = setTimeout(() => {
|
|
286
|
+
if (this.isDisposed)
|
|
287
|
+
return;
|
|
288
|
+
this.timePeriods = this.getValidTimePeriods();
|
|
289
|
+
if (this.model.filterSetting.alarmType) {
|
|
290
|
+
this.updateQueryTimeRange();
|
|
291
|
+
const input = new GetAlarmsArgs(this.alarmNames, this.startTime, this.endTime, this.pageSize, this.page * this.pageSize);
|
|
292
|
+
this.alarmsStore.getHistoryAlarms(input).subscribe(result => {
|
|
293
|
+
if (this.isDisposed)
|
|
294
|
+
return;
|
|
295
|
+
if (!result.error) {
|
|
296
|
+
this.totalCount = result.totalCount;
|
|
297
|
+
this.alarmList = result.items.map(item => [
|
|
298
|
+
item.name,
|
|
299
|
+
item.message,
|
|
300
|
+
item.alarmLevel,
|
|
301
|
+
item.triggeredTime.format('YYYY-MM-DD HH:mm:ss')
|
|
302
|
+
]);
|
|
303
|
+
this.renderElement();
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
const input = new GetAlarmsArgs(this.alarmNames, undefined, undefined, this.pageSize, this.page * this.pageSize);
|
|
309
|
+
this.alarmsStore.getCurrentAlarms(input).subscribe(result => {
|
|
310
|
+
if (this.isDisposed)
|
|
311
|
+
return;
|
|
312
|
+
if (!result.error) {
|
|
313
|
+
this.totalCount = result.totalCount;
|
|
314
|
+
this.currentAlarmList = result.items;
|
|
315
|
+
if (!result.items.length && result.totalCount) {
|
|
316
|
+
this.page = 0;
|
|
317
|
+
this.getAlarmData();
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
this.alarmList = this.currentAlarmList.map(item => [
|
|
321
|
+
item.name,
|
|
322
|
+
item.message,
|
|
323
|
+
item.alarmLevel,
|
|
324
|
+
item.triggeredTime.format('YYYY-MM-DD HH:mm:ss')
|
|
325
|
+
]);
|
|
326
|
+
this.renderElement();
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}, 500);
|
|
331
|
+
}
|
|
332
|
+
refreshCurrentPageData() {
|
|
333
|
+
if (this.isDisposed)
|
|
334
|
+
return;
|
|
335
|
+
if (this.model.filterSetting.alarmType) {
|
|
336
|
+
this.updateQueryTimeRange();
|
|
337
|
+
const input = new GetAlarmsArgs(this.alarmNames, this.startTime, this.endTime, this.pageSize, this.page * this.pageSize);
|
|
338
|
+
this.alarmsStore.getHistoryAlarms(input).subscribe(result => {
|
|
339
|
+
if (this.isDisposed)
|
|
340
|
+
return;
|
|
341
|
+
if (!result.error) {
|
|
342
|
+
this.totalCount = result.totalCount;
|
|
343
|
+
this.alarmList = result.items.map(item => [
|
|
344
|
+
item.name,
|
|
345
|
+
item.message,
|
|
346
|
+
item.alarmLevel,
|
|
347
|
+
item.triggeredTime.format('YYYY-MM-DD HH:mm:ss')
|
|
348
|
+
]);
|
|
349
|
+
this.updateTableContent();
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
const input = new GetAlarmsArgs(this.alarmNames, undefined, undefined, this.pageSize, this.page * this.pageSize);
|
|
355
|
+
this.alarmsStore.getCurrentAlarms(input).subscribe(result => {
|
|
356
|
+
if (this.isDisposed)
|
|
357
|
+
return;
|
|
358
|
+
if (!result.error) {
|
|
359
|
+
this.totalCount = result.totalCount;
|
|
360
|
+
this.currentAlarmList = result.items;
|
|
361
|
+
if (!result.items.length && result.totalCount) {
|
|
362
|
+
this.page = 0;
|
|
363
|
+
this.refreshCurrentPageData();
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
this.alarmList = this.currentAlarmList.map(item => [
|
|
367
|
+
item.name,
|
|
368
|
+
item.message,
|
|
369
|
+
item.alarmLevel,
|
|
370
|
+
item.triggeredTime.format('YYYY-MM-DD HH:mm:ss')
|
|
371
|
+
]);
|
|
372
|
+
this.updateTableContent();
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
updateTableContent() {
|
|
378
|
+
if (!this.element)
|
|
379
|
+
return;
|
|
380
|
+
const useScroll = this.pageSize > this.maxVisibleRows;
|
|
381
|
+
if (useScroll) {
|
|
382
|
+
if (!this.scrollContent)
|
|
383
|
+
return;
|
|
384
|
+
this.scrollWindowStart = Math.min(this.scrollWindowStart, this.getMaxWindowStart());
|
|
385
|
+
this.renderScrollWindow(this.scrollWindowStart);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
const table = this.element.querySelector('table');
|
|
389
|
+
if (!table)
|
|
390
|
+
return;
|
|
391
|
+
// 清除现有数据行(保留表头)
|
|
392
|
+
const rows = Array.from(table.querySelectorAll('tr'));
|
|
393
|
+
rows.forEach((row, index) => {
|
|
394
|
+
if (index > 0) {
|
|
395
|
+
row.remove();
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
// 重新生成数据行
|
|
399
|
+
for (let row = 0; row < this.pageSize; row++) {
|
|
400
|
+
table.appendChild(this.buildDataRow(row, this.model.heights[row + 1]));
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
renderScrollWindow(startRow) {
|
|
404
|
+
const table = this.scrollContent;
|
|
405
|
+
if (!table)
|
|
406
|
+
return;
|
|
407
|
+
// 清除现有数据行(保留表头,即第一个 <tr>)
|
|
408
|
+
const rows = Array.from(table.querySelectorAll('tr'));
|
|
409
|
+
rows.forEach((row, index) => {
|
|
410
|
+
if (index > 0) {
|
|
411
|
+
row.remove();
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
for (let i = 0; i < this.maxVisibleRows; i++) {
|
|
415
|
+
table.appendChild(this.buildDataRow(startRow + i, this.rowHeight));
|
|
416
|
+
}
|
|
417
|
+
this.updateScrollThumb();
|
|
418
|
+
}
|
|
419
|
+
updateScrollThumb() {
|
|
420
|
+
if (this.scrollbar)
|
|
421
|
+
this.scrollbar.update(this.scrollWindowStart, this.pageSize);
|
|
422
|
+
}
|
|
423
|
+
getMaxWindowStart() {
|
|
424
|
+
return Math.max(0, this.pageSize - this.maxVisibleRows);
|
|
425
|
+
}
|
|
426
|
+
getIconScale() {
|
|
427
|
+
const initSize = this.model.initSize;
|
|
428
|
+
if (!initSize || !initSize.width || !initSize.height) {
|
|
429
|
+
return 1;
|
|
430
|
+
}
|
|
431
|
+
const scaleX = this.model.size.width / initSize.width;
|
|
432
|
+
const scaleY = this.model.size.height / initSize.height;
|
|
433
|
+
return Math.min(scaleX, scaleY);
|
|
434
|
+
}
|
|
435
|
+
renderElement() {
|
|
436
|
+
const elementHeight = this.model.size.height;
|
|
437
|
+
this.element = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject');
|
|
438
|
+
this.element.setAttribute('width', this.model.size.width.toString());
|
|
439
|
+
this.element.setAttribute('height', elementHeight.toString());
|
|
440
|
+
this.$element.append(this.element);
|
|
441
|
+
const scale = this.getIconScale();
|
|
442
|
+
// 表格与底部操作区之间的预留高度,需要与操作区渲染时使用的同一个 scale 保持一致,
|
|
443
|
+
// 否则表格按未缩放高度占满后,缩放后的操作区会超出元件整体高度
|
|
444
|
+
const operationAreaReservedHeight = 39 * scale;
|
|
445
|
+
const useScroll = this.pageSize > this.maxVisibleRows;
|
|
446
|
+
if (useScroll) {
|
|
447
|
+
this.renderScrollableTable(elementHeight, operationAreaReservedHeight);
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
this.renderPlainTable(elementHeight, operationAreaReservedHeight);
|
|
451
|
+
}
|
|
452
|
+
this.renderOperationArea(this.model.size.width, elementHeight - operationAreaReservedHeight, scale);
|
|
453
|
+
}
|
|
454
|
+
buildHeaderRow() {
|
|
455
|
+
const tr = document.createElement('tr');
|
|
456
|
+
let fontString = '';
|
|
457
|
+
if (this.model.generalSetting.headerFont.isItalic) {
|
|
458
|
+
fontString += 'italic ';
|
|
459
|
+
}
|
|
460
|
+
if (this.model.generalSetting.headerFont.isBold) {
|
|
461
|
+
fontString += 'bold ';
|
|
462
|
+
}
|
|
463
|
+
fontString += this.model.generalSetting.headerFont.fontSize + ' ' + this.model.generalSetting.headerFont.fontFamily;
|
|
464
|
+
tr.style.cssText = `height: ${this.model.heights[0]}px;
|
|
465
|
+
background: ${this.model.generalSetting.headerFillColor};
|
|
466
|
+
color: ${this.model.generalSetting.headerFont.color};
|
|
467
|
+
font: ${fontString};
|
|
468
|
+
text-align: ${this.model.generalSetting.headerFont.textAlign};
|
|
469
|
+
${this.model.generalSetting.headerFont.isUnderline ? 'text-decoration: underline' : ''};
|
|
470
|
+
vertical-align: middle;`;
|
|
471
|
+
for (let col = 0; col < 4; col++) {
|
|
472
|
+
const th = document.createElement('th');
|
|
473
|
+
th.textContent = this.getHeaderTextByColumn(col);
|
|
474
|
+
th.style.cssText = `width: ${this.model.widths[col] / this.model.size.width * 100}%;
|
|
475
|
+
border-style: solid;
|
|
476
|
+
border-color: ${this.model.generalSetting.splitLine};
|
|
477
|
+
border-left-width: ${!col || this.model.generalSetting.isHiddenColumnSplitLine ? 0 : 1}px;`;
|
|
478
|
+
tr.appendChild(th);
|
|
479
|
+
}
|
|
480
|
+
return tr;
|
|
481
|
+
}
|
|
482
|
+
buildDataRow(row, rowHeight) {
|
|
483
|
+
const levelColors = ['#3695FF', '#FFE900', '#FFA800', '#E84F4F'];
|
|
484
|
+
const tr = document.createElement('tr');
|
|
485
|
+
tr.style.cssText = `height: ${rowHeight}px;
|
|
486
|
+
background: ${this.model.generalSetting.tableFillColor};
|
|
487
|
+
font: ${this.model.generalSetting.fontStyle};
|
|
488
|
+
color: ${this.model.generalSetting.fontColor};
|
|
489
|
+
text-align: ${this.model.generalSetting.textAlign};
|
|
490
|
+
vertical-align: middle;`;
|
|
491
|
+
for (let col = 0; col < 4; col++) {
|
|
492
|
+
const td = document.createElement('td');
|
|
493
|
+
td.style.cssText = `width: ${this.model.widths[col] / this.model.size.width * 100}%;
|
|
494
|
+
border-style: solid;
|
|
495
|
+
border-color: ${this.model.generalSetting.splitLine};
|
|
496
|
+
border-top-width: ${this.model.generalSetting.isHiddenColumnSplitLine ? 0 : 1}px;
|
|
497
|
+
border-left-width: ${!col || this.model.generalSetting.isHiddenColumnSplitLine ? 0 : 1}px;`;
|
|
498
|
+
if (this.alarmList[row]) {
|
|
499
|
+
if (col !== 2) {
|
|
500
|
+
td.textContent = this.alarmList[row][col];
|
|
501
|
+
td.style.cssText += `${this.model.generalSetting.isUnderline ? 'text-decoration: underline' : ''};`;
|
|
502
|
+
}
|
|
503
|
+
else {
|
|
504
|
+
const alarmLevel = document.createElement('div');
|
|
505
|
+
let alarmHeight = parseInt(this.model.generalSetting.fontSize) + 15;
|
|
506
|
+
if (alarmHeight > rowHeight)
|
|
507
|
+
alarmHeight = rowHeight;
|
|
508
|
+
let margin = '0 15px';
|
|
509
|
+
if (this.model.generalSetting.textAlign === 'left') {
|
|
510
|
+
margin = '0 30px 0 0';
|
|
511
|
+
}
|
|
512
|
+
else if (this.model.generalSetting.textAlign === 'right') {
|
|
513
|
+
margin = '0 0 0 30px';
|
|
514
|
+
}
|
|
515
|
+
alarmLevel.style.cssText = `margin: ${margin};
|
|
516
|
+
border-radius: 5px;
|
|
517
|
+
background: ${levelColors[this.alarmList[row][col]]};
|
|
518
|
+
color: #ffffff;
|
|
519
|
+
width: calc(100% - 30px);
|
|
520
|
+
height: ${alarmHeight}px;
|
|
521
|
+
max-height: ${rowHeight}px;
|
|
522
|
+
display: flex;
|
|
523
|
+
justify-content: center;
|
|
524
|
+
align-items: center;
|
|
525
|
+
${this.model.generalSetting.isUnderline ? 'text-decoration: underline' : ''};`;
|
|
526
|
+
alarmLevel.textContent = this.model.levelText[this.alarmList[row][col]];
|
|
527
|
+
td.appendChild(alarmLevel);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
else if (col === 2) {
|
|
531
|
+
const alarmLevel = document.createElement('div');
|
|
532
|
+
let margin = '0 15px';
|
|
533
|
+
if (this.model.generalSetting.textAlign === 'left') {
|
|
534
|
+
margin = '0 30px 0 0';
|
|
535
|
+
}
|
|
536
|
+
else if (this.model.generalSetting.textAlign === 'right') {
|
|
537
|
+
margin = '0 0 0 30px';
|
|
538
|
+
}
|
|
539
|
+
alarmLevel.style.cssText = `margin: ${margin};
|
|
540
|
+
width: ${this.model.widths[col] - 30}px;`;
|
|
541
|
+
td.appendChild(alarmLevel);
|
|
542
|
+
}
|
|
543
|
+
tr.appendChild(td);
|
|
544
|
+
}
|
|
545
|
+
return tr;
|
|
546
|
+
}
|
|
547
|
+
renderPlainTable(elementHeight, operationAreaReservedHeight) {
|
|
548
|
+
this.scrollContent = null;
|
|
549
|
+
this.scrollWindowStart = 0;
|
|
550
|
+
const table = document.createElement('table');
|
|
551
|
+
table.style.cssText = `border: 2px solid ${this.model.generalSetting.stroke};
|
|
552
|
+
height: ${elementHeight - operationAreaReservedHeight}px;`;
|
|
553
|
+
table.appendChild(this.buildHeaderRow());
|
|
554
|
+
for (let row = 0; row < this.pageSize; row++) {
|
|
555
|
+
table.appendChild(this.buildDataRow(row, this.model.heights[row + 1]));
|
|
556
|
+
}
|
|
557
|
+
this.element.appendChild(table);
|
|
558
|
+
this.hoverTarget = table;
|
|
559
|
+
this.bindScrollHoverEvents();
|
|
560
|
+
this.startAutoScroll();
|
|
561
|
+
}
|
|
562
|
+
renderScrollableTable(elementHeight, operationAreaReservedHeight) {
|
|
563
|
+
const dataRowHeight = this.model.heights[1] || this.model.heights[0];
|
|
564
|
+
this.rowHeight = dataRowHeight;
|
|
565
|
+
this.scrollWindowStart = 0;
|
|
566
|
+
// WKWebView can paint positioned HTML descendants outside the SVG scale.
|
|
567
|
+
// Keep a single unpositioned table directly in foreignObject. The sibling
|
|
568
|
+
// SVG scrollbar sits inside the table's right border without an HTML scrolling layer.
|
|
569
|
+
const scrollbarWidth = Math.min(12, this.model.size.width * 0.04);
|
|
570
|
+
const tableHeight = elementHeight - operationAreaReservedHeight;
|
|
571
|
+
const table = document.createElement('table');
|
|
572
|
+
table.style.cssText = `border: 2px solid ${this.model.generalSetting.stroke};
|
|
573
|
+
height: ${tableHeight}px; width: 100%; table-layout: fixed;
|
|
574
|
+
overflow-wrap: break-word; -webkit-text-size-adjust: none; text-size-adjust: none;`;
|
|
575
|
+
table.appendChild(this.buildHeaderRow());
|
|
576
|
+
this.element.appendChild(table);
|
|
577
|
+
this.scrollContent = table;
|
|
578
|
+
this.renderScrollWindow(0);
|
|
579
|
+
const canvasScaleY = this.getCanvasScaleY();
|
|
580
|
+
const renderedTableHeight = table.getBoundingClientRect().height / canvasScaleY || tableHeight;
|
|
581
|
+
const renderedHeaderHeight = table.rows[0].getBoundingClientRect().height / canvasScaleY || this.model.heights[0];
|
|
582
|
+
const scrollbarInset = 2;
|
|
583
|
+
this.scrollbar = new AlarmTableScrollbar(this.element.parentNode, this.model.size.width - scrollbarWidth - scrollbarInset, renderedHeaderHeight + scrollbarInset, scrollbarWidth, Math.max(0, renderedTableHeight - renderedHeaderHeight - scrollbarInset * 2), this.maxVisibleRows, start => this.moveScrollWindowBy(start - this.scrollWindowStart), () => clearInterval(this.scrollIntervalId), () => this.startAutoScroll());
|
|
584
|
+
this.updateScrollThumb();
|
|
585
|
+
this.hoverTarget = table;
|
|
586
|
+
this.bindScrollHoverEvents();
|
|
587
|
+
this.startAutoScroll();
|
|
588
|
+
}
|
|
589
|
+
bindScrollHoverEvents() {
|
|
590
|
+
if (!this.hoverTarget)
|
|
591
|
+
return;
|
|
592
|
+
this.hoverTarget.addEventListener('mouseenter', this.handleScrollMouseEnter);
|
|
593
|
+
this.hoverTarget.addEventListener('mouseleave', this.handleScrollMouseLeave);
|
|
594
|
+
if (this.scrollContent) {
|
|
595
|
+
this.hoverTarget.addEventListener('wheel', this.handleScrollWheel, { passive: false });
|
|
596
|
+
this.hoverTarget.addEventListener('touchstart', this.handleScrollTouchStart, { passive: true });
|
|
597
|
+
this.hoverTarget.addEventListener('touchmove', this.handleScrollTouchMove, { passive: false });
|
|
598
|
+
this.hoverTarget.addEventListener('touchend', this.handleScrollTouchEnd);
|
|
599
|
+
this.hoverTarget.addEventListener('touchcancel', this.handleScrollTouchEnd);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
unbindScrollHoverEvents() {
|
|
603
|
+
if (this.scrollbar)
|
|
604
|
+
this.scrollbar.dispose();
|
|
605
|
+
this.scrollbar = null;
|
|
606
|
+
this.scrollHovered = false;
|
|
607
|
+
this.touchScrolling = false;
|
|
608
|
+
if (!this.hoverTarget)
|
|
609
|
+
return;
|
|
610
|
+
this.hoverTarget.removeEventListener('mouseenter', this.handleScrollMouseEnter);
|
|
611
|
+
this.hoverTarget.removeEventListener('mouseleave', this.handleScrollMouseLeave);
|
|
612
|
+
this.hoverTarget.removeEventListener('wheel', this.handleScrollWheel);
|
|
613
|
+
this.hoverTarget.removeEventListener('touchstart', this.handleScrollTouchStart);
|
|
614
|
+
this.hoverTarget.removeEventListener('touchmove', this.handleScrollTouchMove);
|
|
615
|
+
this.hoverTarget.removeEventListener('touchend', this.handleScrollTouchEnd);
|
|
616
|
+
this.hoverTarget.removeEventListener('touchcancel', this.handleScrollTouchEnd);
|
|
617
|
+
this.hoverTarget = null;
|
|
618
|
+
}
|
|
619
|
+
// 手动滚动只在当前可见窗口范围内移动(不触发翻页),到顶/到底停住,
|
|
620
|
+
// 和自动滚动定时器(会在到底后自动翻页)职责区分开
|
|
621
|
+
moveScrollWindowBy(rowDelta) {
|
|
622
|
+
if (!this.scrollContent)
|
|
623
|
+
return;
|
|
624
|
+
const maxWindowStart = this.getMaxWindowStart();
|
|
625
|
+
const nextStart = Math.min(maxWindowStart, Math.max(0, this.scrollWindowStart + rowDelta));
|
|
626
|
+
if (nextStart === this.scrollWindowStart)
|
|
627
|
+
return;
|
|
628
|
+
this.scrollWindowStart = nextStart;
|
|
629
|
+
this.renderScrollWindow(this.scrollWindowStart);
|
|
630
|
+
}
|
|
631
|
+
getCanvasScaleY() {
|
|
632
|
+
const matrix = this.element.getScreenCTM();
|
|
633
|
+
return matrix ? Math.sqrt(matrix.c * matrix.c + matrix.d * matrix.d) || 1 : 1;
|
|
634
|
+
}
|
|
635
|
+
getScreenRowHeight() {
|
|
636
|
+
var _a;
|
|
637
|
+
const row = (_a = this.scrollContent) === null || _a === void 0 ? void 0 : _a.querySelectorAll('tr')[1];
|
|
638
|
+
return (row === null || row === void 0 ? void 0 : row.getBoundingClientRect().height) || this.rowHeight * this.getCanvasScaleY();
|
|
639
|
+
}
|
|
640
|
+
supportsMouseHover() {
|
|
641
|
+
var _a, _b;
|
|
642
|
+
const view = (_b = (_a = this.element) === null || _a === void 0 ? void 0 : _a.ownerDocument) === null || _b === void 0 ? void 0 : _b.defaultView;
|
|
643
|
+
return !!view && (!view.matchMedia || view.matchMedia('(hover: hover) and (pointer: fine)').matches);
|
|
644
|
+
}
|
|
645
|
+
startAutoScroll() {
|
|
646
|
+
var _a;
|
|
647
|
+
clearInterval(this.scrollIntervalId);
|
|
648
|
+
if (this.isDisposed || this.scrollHovered || this.touchScrolling || ((_a = this.scrollbar) === null || _a === void 0 ? void 0 : _a.isInteracting) || !this.model.generalSetting.autoScroll)
|
|
649
|
+
return;
|
|
650
|
+
const totalPages = Math.max(1, Math.ceil(this.totalCount / this.pageSize));
|
|
651
|
+
if (totalPages <= 1 && !this.scrollContent)
|
|
652
|
+
return;
|
|
653
|
+
const duration = (this.model.generalSetting.scrollDuration || 10) * 1000;
|
|
654
|
+
this.scrollIntervalId = setInterval(() => this.scrollOneRow(), duration);
|
|
655
|
+
}
|
|
656
|
+
scrollOneRow() {
|
|
657
|
+
if (!this.scrollContent) {
|
|
658
|
+
this.autoNextPage();
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
const maxWindowStart = this.getMaxWindowStart();
|
|
662
|
+
if (maxWindowStart <= 0 || this.scrollWindowStart >= maxWindowStart) {
|
|
663
|
+
this.autoNextPage();
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
this.scrollWindowStart += 1;
|
|
667
|
+
this.renderScrollWindow(this.scrollWindowStart);
|
|
668
|
+
}
|
|
669
|
+
autoNextPage() {
|
|
670
|
+
const totalPages = Math.max(1, Math.ceil(this.totalCount / this.pageSize));
|
|
671
|
+
if (totalPages <= 1) {
|
|
672
|
+
// 只有一页数据:没有下一页可翻,循环回本页顶部继续滚动
|
|
673
|
+
if (this.scrollContent) {
|
|
674
|
+
this.scrollWindowStart = 0;
|
|
675
|
+
this.renderScrollWindow(0);
|
|
676
|
+
}
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
const lastPage = totalPages - 1;
|
|
680
|
+
this.page = this.page < lastPage ? this.page + 1 : 0;
|
|
681
|
+
this.getAlarmData();
|
|
682
|
+
}
|
|
683
|
+
renderOperationArea(chartWidth, chartHeight, scale = 1) {
|
|
684
|
+
var _a;
|
|
685
|
+
const operationArea = this.rootElement.append('g').attr('transform', `translate(0,${chartHeight + this.displayOption.operationAreaMarginTop * scale})`)
|
|
686
|
+
.append('foreignObject').attr('width', chartWidth).attr('height', this.displayOption.operationAreaHeight * scale).attr('fill', 'none')
|
|
687
|
+
.append('xhtml:div').style('height', (this.displayOption.operationAreaHeight * scale - 4) + 'px').style('overflow', 'hidden').style('margin-top', '4px');
|
|
688
|
+
if ((_a = this.model.filterSetting) === null || _a === void 0 ? void 0 : _a.alarmType) {
|
|
689
|
+
const selectElement = operationArea.append('select').style('margin-left', (this.displayOption.marginLeft * scale) + 'px')
|
|
690
|
+
.style('font-size', (parseFloat(this.displayOption.operationSelectFontSize) * scale) + 'px').on('change', () => {
|
|
691
|
+
const displayTimePeriod = this.rootElement.select('select').property('value');
|
|
692
|
+
this.updateTimeRange(displayTimePeriod);
|
|
693
|
+
this.getAlarmData();
|
|
694
|
+
});
|
|
695
|
+
const options = selectElement.selectAll('option').data(this.timePeriods).enter().append('option');
|
|
696
|
+
options.text(d => d.name).attr('value', d => d.key).property('selected', d => d.key === Number(this.currentTimePeriod));
|
|
697
|
+
}
|
|
698
|
+
const buttonWidth = (this.displayOption.operationButtonWidth * scale) + 'px', buttonHeight = (this.displayOption.operationButtonHeight * scale) + 'px';
|
|
699
|
+
operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
|
|
700
|
+
.style('float', 'right').style('background-image', 'url(assets/img/last_page.svg)')
|
|
701
|
+
.style('background-size', 'contain').style('background-repeat', 'no-repeat').style('background-position', 'center')
|
|
702
|
+
.style('background-color', 'inherit')
|
|
703
|
+
.on('click', () => { this.loadLastPage(); });
|
|
704
|
+
operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
|
|
705
|
+
.style('float', 'right').style('background-image', 'url(assets/img/next_page.svg)')
|
|
706
|
+
.style('background-size', 'contain').style('background-repeat', 'no-repeat').style('background-position', 'center')
|
|
707
|
+
.style('margin', `0 ${this.displayOption.operationButtonMargin * scale}px 0 0`)
|
|
708
|
+
.style('background-color', 'inherit')
|
|
709
|
+
.on('click', () => { this.loadNextPage(); });
|
|
710
|
+
operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
|
|
711
|
+
.style('float', 'right').style('background-image', 'url(assets/img/previous_page.svg)')
|
|
712
|
+
.style('background-size', 'contain').style('background-repeat', 'no-repeat').style('background-position', 'center')
|
|
713
|
+
.style('margin', `0 ${this.displayOption.operationButtonMargin * scale}px 0 0`)
|
|
714
|
+
.style('background-color', 'inherit')
|
|
715
|
+
.on('click', () => { this.loadPreviousPage(); });
|
|
716
|
+
operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
|
|
717
|
+
.style('float', 'right').style('background-image', 'url(assets/img/first_page.svg)')
|
|
718
|
+
.style('background-size', 'contain').style('background-repeat', 'no-repeat').style('background-position', 'center')
|
|
719
|
+
.style('margin', `0 ${this.displayOption.operationButtonMargin * scale}px 0 0`)
|
|
720
|
+
.style('background-color', 'inherit')
|
|
721
|
+
.on('click', () => { this.loadFirstPage(); });
|
|
722
|
+
this.setStatusAsNormal();
|
|
723
|
+
}
|
|
724
|
+
updateTimeRange(timePeriodType) {
|
|
725
|
+
this.currentTimePeriod = +timePeriodType;
|
|
726
|
+
this.updateQueryTimeRange();
|
|
727
|
+
}
|
|
728
|
+
updateQueryTimeRange() {
|
|
729
|
+
this.endTime = moment();
|
|
730
|
+
switch (this.currentTimePeriod) {
|
|
731
|
+
case 1:
|
|
732
|
+
this.startTime = moment().subtract(1, 'hours');
|
|
733
|
+
break;
|
|
734
|
+
case 3:
|
|
735
|
+
this.startTime = moment().subtract(7, 'days');
|
|
736
|
+
break;
|
|
737
|
+
case 4:
|
|
738
|
+
this.startTime = moment().subtract(30, 'days');
|
|
739
|
+
break;
|
|
740
|
+
case 5:
|
|
741
|
+
this.startTime = moment().subtract(1, 'years');
|
|
742
|
+
break;
|
|
743
|
+
case 6:
|
|
744
|
+
this.startTime = moment().subtract(30, 'minutes');
|
|
745
|
+
break;
|
|
746
|
+
case 7:
|
|
747
|
+
this.startTime = moment().subtract(8, 'hours');
|
|
748
|
+
break;
|
|
749
|
+
default:
|
|
750
|
+
this.startTime = moment().subtract(1, 'days');
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
loadFirstPage() {
|
|
754
|
+
if (this.page > 0) {
|
|
755
|
+
this.page = 0;
|
|
756
|
+
this.getAlarmData();
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
loadNextPage() {
|
|
760
|
+
let last_page = Math.ceil(this.totalCount / this.pageSize);
|
|
761
|
+
if (last_page)
|
|
762
|
+
last_page--;
|
|
763
|
+
if (this.page < last_page) {
|
|
764
|
+
this.page++;
|
|
765
|
+
this.getAlarmData();
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
loadPreviousPage() {
|
|
769
|
+
if (this.page > 0) {
|
|
770
|
+
this.page--;
|
|
771
|
+
this.getAlarmData();
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
loadLastPage() {
|
|
775
|
+
let last_page = Math.ceil(this.totalCount / this.pageSize);
|
|
776
|
+
if (last_page)
|
|
777
|
+
last_page--;
|
|
778
|
+
if (this.page !== last_page) {
|
|
779
|
+
this.page = last_page;
|
|
780
|
+
this.getAlarmData();
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
setStatusAsNormal() {
|
|
784
|
+
this.elementStatus = AlaertElementStatus.Normal;
|
|
785
|
+
this.clearStatus();
|
|
786
|
+
}
|
|
787
|
+
setStatusAsLoading() {
|
|
788
|
+
this.elementStatus = AlaertElementStatus.Loading;
|
|
789
|
+
this.renderStatus('assets/img/loading.svg', '#226abc');
|
|
790
|
+
}
|
|
791
|
+
renderStatus(icon, stroke) {
|
|
792
|
+
if (this.elementStatus === AlaertElementStatus.Normal) {
|
|
793
|
+
this.clearStatus();
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
this.rootElement.append('rect').attr('id', 'StateFrame').attr('fill', 'transparent')
|
|
797
|
+
.attr('width', this.model.size.width)
|
|
798
|
+
.attr('height', this.model.size.height);
|
|
799
|
+
const document = this.$element[0].ownerDocument;
|
|
800
|
+
const currentRect = this.$element.find('rect#StateFrame').first();
|
|
801
|
+
if (!currentRect.length) {
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
this.$element.find('image#StateImage').remove();
|
|
805
|
+
const imgObj = document.createElementNS('http://www.w3.org/2000/svg', 'image');
|
|
806
|
+
if (imgObj) {
|
|
807
|
+
let x = Number(currentRect[0].getAttribute('width')) - 20;
|
|
808
|
+
const currentRectX = currentRect[0].getAttribute('x');
|
|
809
|
+
if (currentRectX !== null) {
|
|
810
|
+
x += Number(currentRectX);
|
|
811
|
+
}
|
|
812
|
+
currentRect[0].setAttribute('stroke', stroke);
|
|
813
|
+
currentRect[0].setAttribute('stroke-opacity', '0.5');
|
|
814
|
+
imgObj.href.baseVal = icon;
|
|
815
|
+
imgObj.setAttributeNS(null, 'id', 'StateImage');
|
|
816
|
+
imgObj.setAttributeNS(null, 'x', x.toString());
|
|
817
|
+
imgObj.setAttributeNS(null, 'y', '0');
|
|
818
|
+
imgObj.setAttributeNS(null, 'height', '20px');
|
|
819
|
+
imgObj.setAttributeNS(null, 'width', '20px');
|
|
820
|
+
const titleElement = document.createElementNS('http://www.w3.org/2000/svg', 'title');
|
|
821
|
+
imgObj.appendChild(titleElement);
|
|
822
|
+
this.$element.append(imgObj);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
clearStatus() {
|
|
826
|
+
const currentRect = this.$element.find('rect#StateFrame').first();
|
|
827
|
+
if (!currentRect.length) {
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
const stroke = currentRect[0].getAttribute('stroke');
|
|
831
|
+
if (stroke) {
|
|
832
|
+
currentRect[0].removeAttribute('stroke');
|
|
833
|
+
}
|
|
834
|
+
this.$element.find('image#StateImage').remove();
|
|
835
|
+
}
|
|
836
|
+
}
|