Commit cc72c4ac0fef67abfd3aedd9c6b405a8ee143f79
Committed by
GitHub
Merge pull request #3684 from vvlladd28/bug/alarm-widget/state
UI: Fixed updated Alarm widget in change entity state parameters
Showing
3 changed files
with
12 additions
and
13 deletions
... | ... | @@ -52,6 +52,7 @@ export interface AlarmDataSubscriptionOptions { |
52 | 52 | |
53 | 53 | export class AlarmDataSubscription { |
54 | 54 | |
55 | + private alarmDataSubscriptionOptions = this.listener.alarmDataSubscriptionOptions; | |
55 | 56 | private datasourceType: DatasourceType = this.alarmDataSubscriptionOptions.datasourceType; |
56 | 57 | |
57 | 58 | private history: boolean; |
... | ... | @@ -65,8 +66,7 @@ export class AlarmDataSubscription { |
65 | 66 | |
66 | 67 | private subsTw: SubscriptionTimewindow; |
67 | 68 | |
68 | - constructor(public alarmDataSubscriptionOptions: AlarmDataSubscriptionOptions, | |
69 | - private listener: AlarmDataListener, | |
69 | + constructor(private listener: AlarmDataListener, | |
70 | 70 | private telemetryService: TelemetryService) { |
71 | 71 | } |
72 | 72 | ... | ... |
... | ... | @@ -32,6 +32,7 @@ export interface AlarmDataListener { |
32 | 32 | alarmSource: Datasource; |
33 | 33 | alarmsLoaded: (pageData: PageData<AlarmData>, allowedEntities: number, totalEntities: number) => void; |
34 | 34 | alarmsUpdated: (update: Array<AlarmData>, pageData: PageData<AlarmData>) => void; |
35 | + alarmDataSubscriptionOptions?: AlarmDataSubscriptionOptions; | |
35 | 36 | subscription?: AlarmDataSubscription; |
36 | 37 | } |
37 | 38 | |
... | ... | @@ -47,11 +48,11 @@ export class AlarmDataService { |
47 | 48 | pageLink: AlarmDataPageLink, |
48 | 49 | keyFilters: KeyFilter[]) { |
49 | 50 | const alarmSource = listener.alarmSource; |
51 | + listener.alarmDataSubscriptionOptions = this.createAlarmSubscriptionOptions(listener, pageLink, keyFilters); | |
50 | 52 | if (alarmSource.type === DatasourceType.entity && (!alarmSource.entityFilter || !pageLink)) { |
51 | 53 | return; |
52 | 54 | } |
53 | - listener.subscription = this.createSubscription(listener, | |
54 | - pageLink, alarmSource.keyFilters, keyFilters); | |
55 | + listener.subscription = new AlarmDataSubscription(listener, this.telemetryService); | |
55 | 56 | return listener.subscription.subscribe(); |
56 | 57 | } |
57 | 58 | |
... | ... | @@ -61,10 +62,9 @@ export class AlarmDataService { |
61 | 62 | } |
62 | 63 | } |
63 | 64 | |
64 | - private createSubscription(listener: AlarmDataListener, | |
65 | - pageLink: AlarmDataPageLink, | |
66 | - keyFilters: KeyFilter[], | |
67 | - additionalKeyFilters: KeyFilter[]): AlarmDataSubscription { | |
65 | + private createAlarmSubscriptionOptions(listener: AlarmDataListener, | |
66 | + pageLink: AlarmDataPageLink, | |
67 | + additionalKeyFilters: KeyFilter[]): AlarmDataSubscriptionOptions { | |
68 | 68 | const alarmSource = listener.alarmSource; |
69 | 69 | const alarmSubscriptionDataKeys: Array<AlarmSubscriptionDataKey> = []; |
70 | 70 | alarmSource.dataKeys.forEach((dataKey) => { |
... | ... | @@ -82,11 +82,10 @@ export class AlarmDataService { |
82 | 82 | if (alarmDataSubscriptionOptions.datasourceType === DatasourceType.entity) { |
83 | 83 | alarmDataSubscriptionOptions.entityFilter = alarmSource.entityFilter; |
84 | 84 | alarmDataSubscriptionOptions.pageLink = pageLink; |
85 | - alarmDataSubscriptionOptions.keyFilters = keyFilters; | |
85 | + alarmDataSubscriptionOptions.keyFilters = alarmSource.keyFilters; | |
86 | 86 | alarmDataSubscriptionOptions.additionalKeyFilters = additionalKeyFilters; |
87 | 87 | } |
88 | - return new AlarmDataSubscription(alarmDataSubscriptionOptions, | |
89 | - listener, this.telemetryService); | |
88 | + return alarmDataSubscriptionOptions; | |
90 | 89 | } |
91 | 90 | |
92 | 91 | } | ... | ... |
... | ... | @@ -960,8 +960,8 @@ export class WidgetSubscription implements IWidgetSubscription { |
960 | 960 | |
961 | 961 | private updateAlarmDataSubscription() { |
962 | 962 | if (this.alarmDataListener) { |
963 | - const pageLink = this.alarmDataListener.subscription.alarmDataSubscriptionOptions.pageLink; | |
964 | - const keyFilters = this.alarmDataListener.subscription.alarmDataSubscriptionOptions.additionalKeyFilters; | |
963 | + const pageLink = this.alarmDataListener.alarmDataSubscriptionOptions.pageLink; | |
964 | + const keyFilters = this.alarmDataListener.alarmDataSubscriptionOptions.additionalKeyFilters; | |
965 | 965 | this.subscribeForAlarms(pageLink, keyFilters); |
966 | 966 | } |
967 | 967 | } | ... | ... |