@flexem/fc-gui 3.0.0-alpha.70 → 3.0.0-alpha.72

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.
@@ -23,6 +23,7 @@ export declare class AlarmElement extends ConditionalDisplayElement {
23
23
  private page;
24
24
  private totalCount;
25
25
  private pageSize;
26
+ private getAlarmDataId;
26
27
  constructor(element: HTMLElement, injector: Injector, permissionChecker: PermissionChecker, variableCommunicator: VariableCommunicator, variableStore: VariableStore, alarmsStore: AlarmsStore, signalRAppId: string);
27
28
  dispose(): void;
28
29
  private getValidTimePeriods;
@@ -4,8 +4,6 @@ import { GetAlarmsArgs } from '../../config';
4
4
  import * as moment from 'moment';
5
5
  import { LOGGER_SERVICE_TOKEN } from '../../logger';
6
6
  import { LOCALIZATION } from '../../localization';
7
- import { find, isNil, pull, remove } from 'lodash';
8
- import { AlarmState } from './alarm-state-enum';
9
7
  export class AlarmElement extends ConditionalDisplayElement {
10
8
  constructor(element, injector, permissionChecker, variableCommunicator, variableStore, alarmsStore, signalRAppId) {
11
9
  var _a;
@@ -47,40 +45,13 @@ export class AlarmElement extends ConditionalDisplayElement {
47
45
  }, this.model.filterSetting.refreshCycle * 60 * 1000);
48
46
  }
49
47
  else {
50
- variableCommunicator.subscribeUserDeviceAlarms(signalRAppId).subscribe(alarmWithAppId => {
51
- if (alarmWithAppId.appId !== this.signalRAppId) {
52
- return;
53
- }
54
- const alarm = alarmWithAppId.alarm;
55
- if (!find(this.alarmNames, itemName => itemName === alarm.name)) {
56
- return;
57
- }
58
- const currentAlarm = this.currentAlarmList.find(re => re.name === alarm.name);
59
- if (alarm.state === AlarmState.AlarmStateTriggered.valueOf()) {
60
- if (!isNil(currentAlarm)) {
48
+ variableCommunicator.subscribeUserDeviceAlarms(signalRAppId).subscribe(alarms => {
49
+ alarms.forEach(alarm => {
50
+ if (this.alarmNames.indexOf(alarm.name) !== -1) {
51
+ this.init();
61
52
  return;
62
53
  }
63
- pull(this.currentAlarmList, this.currentAlarmList.find(record => alarm.name === record.name));
64
- this.currentAlarmList.unshift(alarm);
65
- this.totalCount += 1;
66
- }
67
- else {
68
- if (isNil(currentAlarm)) {
69
- return;
70
- }
71
- remove(this.currentAlarmList, currentAlarm);
72
- this.totalCount -= 1;
73
- }
74
- this.alarmList = [];
75
- this.currentAlarmList.forEach(item => {
76
- this.alarmList.push([
77
- item.name,
78
- item.message,
79
- item.alarmLevel,
80
- moment(item.triggeredTime).format('YYYY-MM-DD HH:mm:ss')
81
- ]);
82
54
  });
83
- this.renderElement();
84
55
  });
85
56
  }
86
57
  this.init();
@@ -110,38 +81,41 @@ export class AlarmElement extends ConditionalDisplayElement {
110
81
  return timePeriods;
111
82
  }
112
83
  init() {
113
- if (this.model.filterSetting.alarmType) {
114
- this.updateQueryTimeRange();
115
- const input = new GetAlarmsArgs(this.alarmNames, this.startTime, this.endTime, this.pageSize, this.page * this.pageSize);
116
- this.alarmsStore.getHistoryAlarms(input).subscribe(result => {
117
- if (!result.error) {
118
- this.totalCount = result.totalCount;
119
- this.alarmList = result.items.map(item => [
120
- item.name,
121
- item.message,
122
- item.alarmLevel,
123
- item.triggeredTime.format('YYYY-MM-DD HH:mm:ss')
124
- ]);
125
- this.renderElement();
126
- }
127
- });
128
- }
129
- else {
130
- const input = new GetAlarmsArgs(this.alarmNames, undefined, undefined, this.pageSize, this.page * this.pageSize);
131
- this.alarmsStore.getCurrentAlarms(input).subscribe(result => {
132
- if (!result.error) {
133
- this.totalCount = result.totalCount;
134
- this.currentAlarmList = result.items;
135
- this.alarmList = this.currentAlarmList.map(item => [
136
- item.name,
137
- item.message,
138
- item.alarmLevel,
139
- item.triggeredTime.format('YYYY-MM-DD HH:mm:ss')
140
- ]);
141
- this.renderElement();
142
- }
143
- });
144
- }
84
+ clearTimeout(this.getAlarmDataId);
85
+ this.getAlarmDataId = setTimeout(() => {
86
+ if (this.model.filterSetting.alarmType) {
87
+ this.updateQueryTimeRange();
88
+ const input = new GetAlarmsArgs(this.alarmNames, this.startTime, this.endTime, this.pageSize, this.page * this.pageSize);
89
+ this.alarmsStore.getHistoryAlarms(input).subscribe(result => {
90
+ if (!result.error) {
91
+ this.totalCount = result.totalCount;
92
+ this.alarmList = result.items.map(item => [
93
+ item.name,
94
+ item.message,
95
+ item.alarmLevel,
96
+ item.triggeredTime.format('YYYY-MM-DD HH:mm:ss')
97
+ ]);
98
+ this.renderElement();
99
+ }
100
+ });
101
+ }
102
+ else {
103
+ const input = new GetAlarmsArgs(this.alarmNames, undefined, undefined, this.pageSize, this.page * this.pageSize);
104
+ this.alarmsStore.getCurrentAlarms(input).subscribe(result => {
105
+ if (!result.error) {
106
+ this.totalCount = result.totalCount;
107
+ this.currentAlarmList = result.items;
108
+ this.alarmList = this.currentAlarmList.map(item => [
109
+ item.name,
110
+ item.message,
111
+ item.alarmLevel,
112
+ item.triggeredTime.format('YYYY-MM-DD HH:mm:ss')
113
+ ]);
114
+ this.renderElement();
115
+ }
116
+ });
117
+ }
118
+ }, 500);
145
119
  }
146
120
  renderElement() {
147
121
  this.rootElement.selectAll('*').remove();
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"AlarmElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../base/conditional-display-element","name":"ConditionalDisplayElement","line":17,"character":34},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":49,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":50,"character":18},{"__symbolic":"reference","module":"../../service","name":"PermissionChecker","line":51,"character":27},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":52,"character":30},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":53,"character":23},{"__symbolic":"reference","module":"../../config","name":"AlarmsStore","line":54,"character":38},{"__symbolic":"reference","name":"string"}]}],"dispose":[{"__symbolic":"method"}],"getValidTimePeriods":[{"__symbolic":"method"}],"init":[{"__symbolic":"method"}],"renderElement":[{"__symbolic":"method"}],"renderOperationArea":[{"__symbolic":"method"}],"updateTimeRange":[{"__symbolic":"method"}],"updateQueryTimeRange":[{"__symbolic":"method"}],"loadFirstPage":[{"__symbolic":"method"}],"loadNextPage":[{"__symbolic":"method"}],"loadPreviousPage":[{"__symbolic":"method"}],"loadLastPage":[{"__symbolic":"method"}]}}}}]
1
+ [{"__symbolic":"module","version":4,"metadata":{"AlarmElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../base/conditional-display-element","name":"ConditionalDisplayElement","line":15,"character":34},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":48,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":49,"character":18},{"__symbolic":"reference","module":"../../service","name":"PermissionChecker","line":50,"character":27},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":51,"character":30},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":52,"character":23},{"__symbolic":"reference","module":"../../config","name":"AlarmsStore","line":53,"character":38},{"__symbolic":"reference","name":"string"}]}],"dispose":[{"__symbolic":"method"}],"getValidTimePeriods":[{"__symbolic":"method"}],"init":[{"__symbolic":"method"}],"renderElement":[{"__symbolic":"method"}],"renderOperationArea":[{"__symbolic":"method"}],"updateTimeRange":[{"__symbolic":"method"}],"updateQueryTimeRange":[{"__symbolic":"method"}],"loadFirstPage":[{"__symbolic":"method"}],"loadNextPage":[{"__symbolic":"method"}],"loadPreviousPage":[{"__symbolic":"method"}],"loadLastPage":[{"__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.70",
3
+ "version": "3.0.0-alpha.72",
4
4
  "module": "public_api.js",
5
5
  "typings": "public_api.d.ts",
6
6
  "license": "UNLICENSED",
@@ -30,9 +30,9 @@ export class RemoteVariableCommunicator {
30
30
  if (this.alarmChangedSubscription !== undefined) {
31
31
  this.alarmChangedSubscription.unsubscribe();
32
32
  }
33
- this.alarmChangedSubscription = this.remoteVariableProtocol.historyAlarmChanged.subscribe((alarmWithAppId) => {
33
+ this.alarmChangedSubscription = this.remoteVariableProtocol.virtualDeviceAlarmsChanged.subscribe((alarms) => {
34
34
  each(this.alarmObservers, ob => {
35
- ob.next(alarmWithAppId);
35
+ ob.next(alarms);
36
36
  });
37
37
  });
38
38
  }
@@ -218,9 +218,9 @@ export class RemoteVariableCommunicator {
218
218
  subscribeUserDeviceAlarms(appId = '') {
219
219
  return new Observable(observer => {
220
220
  this.alarmObservers.push(observer);
221
- this.remoteVariableProtocol.subscribeUserDeviceAlarms(appId);
221
+ this.remoteVariableProtocol.subscribeVirtualDeviceAlarms(appId);
222
222
  return () => {
223
- this.remoteVariableProtocol.unSubscribeUserDeviceAlarms(appId);
223
+ this.remoteVariableProtocol.unsubscribeVirtualDeviceAlarms(appId);
224
224
  };
225
225
  });
226
226
  }
@@ -4,13 +4,13 @@ export interface RemoteVariableProtocol {
4
4
  connected: Observable<void>;
5
5
  variableStatesChanged: Observable<VariableValue[]>;
6
6
  variableValuesChanged: Observable<VariableValue[]>;
7
- historyAlarmChanged: Observable<any>;
7
+ virtualDeviceAlarmsChanged: Observable<any>;
8
8
  tryOpenVariables(variableNames: string[], appId: string): Observable<void>;
9
9
  tryStopVariables(variableNames: string[], appId: string): Observable<void>;
10
10
  writeVariable(variableName: string, value: any): Observable<void>;
11
11
  writeVariableWordByBit(variableName: string, index: number, value: number): Observable<void>;
12
12
  subscribeVariableStates(variableNames: string[]): Observable<void>;
13
13
  unsubscribeVariableStates(variableNames: string[]): Observable<void>;
14
- subscribeUserDeviceAlarms(appId: string): any;
15
- unSubscribeUserDeviceAlarms(appId: string): any;
14
+ subscribeVirtualDeviceAlarms(appId: string): any;
15
+ unsubscribeVirtualDeviceAlarms(appId: string): any;
16
16
  }
@@ -1,4 +0,0 @@
1
- export declare enum AlarmState {
2
- AlarmStateTriggered = 1,
3
- AlarmStateRecovered = 0
4
- }
@@ -1,5 +0,0 @@
1
- export var AlarmState;
2
- (function (AlarmState) {
3
- AlarmState[AlarmState["AlarmStateTriggered"] = 1] = "AlarmStateTriggered";
4
- AlarmState[AlarmState["AlarmStateRecovered"] = 0] = "AlarmStateRecovered";
5
- })(AlarmState || (AlarmState = {}));
@@ -1 +0,0 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"AlarmState":{"AlarmStateTriggered":1,"AlarmStateRecovered":0}}}]