|
|
@ -14,7 +14,7 @@ |
|
|
/// limitations under the License.
|
|
|
/// limitations under the License.
|
|
|
///
|
|
|
///
|
|
|
|
|
|
|
|
|
import { AfterViewInit, Component, ElementRef, Input, OnDestroy, OnInit, ViewChild } from '@angular/core'; |
|
|
import { Component, ElementRef, Input, OnDestroy, OnInit, ViewChild } from '@angular/core'; |
|
|
import { PageComponent } from '@shared/components/page.component'; |
|
|
import { PageComponent } from '@shared/components/page.component'; |
|
|
import { WidgetContext } from '@home/models/widget-component.models'; |
|
|
import { WidgetContext } from '@home/models/widget-component.models'; |
|
|
import { UtilsService } from '@core/services/utils.service'; |
|
|
import { UtilsService } from '@core/services/utils.service'; |
|
|
@ -24,6 +24,7 @@ import { isDefined } from '@core/utils'; |
|
|
import { IWidgetSubscription, SubscriptionInfo, WidgetSubscriptionOptions } from '@core/api/widget-api.models'; |
|
|
import { IWidgetSubscription, SubscriptionInfo, WidgetSubscriptionOptions } from '@core/api/widget-api.models'; |
|
|
import { DatasourceType, widgetType } from '@shared/models/widget.models'; |
|
|
import { DatasourceType, widgetType } from '@shared/models/widget.models'; |
|
|
import { EntityType } from '@shared/models/entity-type.models'; |
|
|
import { EntityType } from '@shared/models/entity-type.models'; |
|
|
|
|
|
import { ResizeObserver } from '@juggle/resize-observer'; |
|
|
|
|
|
|
|
|
type RetrieveValueMethod = 'rpc' | 'attribute' | 'timeseries'; |
|
|
type RetrieveValueMethod = 'rpc' | 'attribute' | 'timeseries'; |
|
|
|
|
|
|
|
|
@ -88,7 +89,7 @@ export class RoundSwitchComponent extends PageComponent implements OnInit, OnDes |
|
|
private switchErrorContainer: JQuery<HTMLElement>; |
|
|
private switchErrorContainer: JQuery<HTMLElement>; |
|
|
private switchError: JQuery<HTMLElement>; |
|
|
private switchError: JQuery<HTMLElement>; |
|
|
|
|
|
|
|
|
private switchResizeListener: any; |
|
|
private switchResize$: ResizeObserver; |
|
|
|
|
|
|
|
|
constructor(private utils: UtilsService, |
|
|
constructor(private utils: UtilsService, |
|
|
protected store: Store<AppState>) { |
|
|
protected store: Store<AppState>) { |
|
|
@ -110,20 +111,19 @@ export class RoundSwitchComponent extends PageComponent implements OnInit, OnDes |
|
|
this.onValue(); |
|
|
this.onValue(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
this.switchResizeListener = this.resize.bind(this); |
|
|
this.switchResize$ = new ResizeObserver(() => { |
|
|
// @ts-ignore
|
|
|
this.resize(); |
|
|
addResizeListener(this.switchContainerRef.nativeElement, this.switchResizeListener); |
|
|
}); |
|
|
|
|
|
this.switchResize$.observe(this.switchContainerRef.nativeElement); |
|
|
this.init(); |
|
|
this.init(); |
|
|
// this.ctx.resize = this.resize.bind(this);
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ngOnDestroy(): void { |
|
|
ngOnDestroy(): void { |
|
|
if (this.valueSubscription) { |
|
|
if (this.valueSubscription) { |
|
|
this.ctx.subscriptionApi.removeSubscription(this.valueSubscription.id); |
|
|
this.ctx.subscriptionApi.removeSubscription(this.valueSubscription.id); |
|
|
} |
|
|
} |
|
|
if (this.switchResizeListener) { |
|
|
if (this.switchResize$) { |
|
|
// @ts-ignore
|
|
|
this.switchResize$.disconnect(); |
|
|
removeResizeListener(this.switchContainerRef.nativeElement, this.switchResizeListener); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|