Change resize events to observer (#2652)
This commit is contained in:
parent
4ede9a3a4d
commit
caf91be338
5
ui-ngx/package-lock.json
generated
5
ui-ngx/package-lock.json
generated
@ -1561,6 +1561,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@juggle/resize-observer": {
|
||||||
|
"version": "3.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@juggle/resize-observer/-/resize-observer-3.1.3.tgz",
|
||||||
|
"integrity": "sha512-y7qc6SzZBlSpx8hEDfV0S9Cx6goROX/vBhS2Ru1Q78Jp1FlCMbxp7UcAN90rLgB3X8DSMBgDFxcmoG/VfdAhFA=="
|
||||||
|
},
|
||||||
"@mat-datetimepicker/core": {
|
"@mat-datetimepicker/core": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@mat-datetimepicker/core/-/core-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@mat-datetimepicker/core/-/core-4.1.0.tgz",
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
"@date-io/date-fns": "^2.6.1",
|
"@date-io/date-fns": "^2.6.1",
|
||||||
"@flowjs/flow.js": "^2.14.0",
|
"@flowjs/flow.js": "^2.14.0",
|
||||||
"@flowjs/ngx-flow": "^0.4.3",
|
"@flowjs/ngx-flow": "^0.4.3",
|
||||||
|
"@juggle/resize-observer": "^3.1.3",
|
||||||
"@mat-datetimepicker/core": "^4.1.0",
|
"@mat-datetimepicker/core": "^4.1.0",
|
||||||
"@material-ui/core": "^4.9.11",
|
"@material-ui/core": "^4.9.11",
|
||||||
"@material-ui/icons": "^4.9.1",
|
"@material-ui/icons": "^4.9.1",
|
||||||
|
|||||||
@ -53,6 +53,7 @@ import { Widget, WidgetPosition } from '@app/shared/models/widget.models';
|
|||||||
import { MatMenuTrigger } from '@angular/material/menu';
|
import { MatMenuTrigger } from '@angular/material/menu';
|
||||||
import { SafeStyle } from '@angular/platform-browser';
|
import { SafeStyle } from '@angular/platform-browser';
|
||||||
import { distinct } from 'rxjs/operators';
|
import { distinct } from 'rxjs/operators';
|
||||||
|
import { ResizeObserver } from '@juggle/resize-observer';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-dashboard',
|
selector: 'tb-dashboard',
|
||||||
@ -166,7 +167,7 @@ export class DashboardComponent extends PageComponent implements IDashboardCompo
|
|||||||
|
|
||||||
private optionsChangeNotificationsPaused = false;
|
private optionsChangeNotificationsPaused = false;
|
||||||
|
|
||||||
private gridsterResizeListener = null;
|
private gridsterResize$: ResizeObserver;
|
||||||
|
|
||||||
constructor(protected store: Store<AppState>,
|
constructor(protected store: Store<AppState>,
|
||||||
private timeService: TimeService,
|
private timeService: TimeService,
|
||||||
@ -225,9 +226,8 @@ export class DashboardComponent extends PageComponent implements IDashboardCompo
|
|||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
super.ngOnDestroy();
|
super.ngOnDestroy();
|
||||||
if (this.gridsterResizeListener) {
|
if (this.gridsterResize$) {
|
||||||
// @ts-ignore
|
this.gridsterResize$.disconnect();
|
||||||
removeResizeListener(this.gridster.el, this.gridsterResizeListener);
|
|
||||||
}
|
}
|
||||||
if (this.breakpointObserverSubscription) {
|
if (this.breakpointObserverSubscription) {
|
||||||
this.breakpointObserverSubscription.unsubscribe();
|
this.breakpointObserverSubscription.unsubscribe();
|
||||||
@ -290,9 +290,10 @@ export class DashboardComponent extends PageComponent implements IDashboardCompo
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
this.gridsterResizeListener = this.onGridsterParentResize.bind(this);
|
this.gridsterResize$ = new ResizeObserver(() => {
|
||||||
// @ts-ignore
|
this.onGridsterParentResize()
|
||||||
addResizeListener(this.gridster.el, this.gridsterResizeListener);
|
});
|
||||||
|
this.gridsterResize$.observe(this.gridster.el);
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdateTimewindow(startTimeMs: number, endTimeMs: number, interval?: number, persist?: boolean): void {
|
onUpdateTimewindow(startTimeMs: number, endTimeMs: number, interval?: number, persist?: boolean): void {
|
||||||
|
|||||||
@ -35,6 +35,7 @@ import { CustomActionDescriptor } from '@shared/models/widget.models';
|
|||||||
import * as ace from 'ace-builds';
|
import * as ace from 'ace-builds';
|
||||||
import { CancelAnimationFrame, RafService } from '@core/services/raf.service';
|
import { CancelAnimationFrame, RafService } from '@core/services/raf.service';
|
||||||
import { css_beautify, html_beautify } from 'js-beautify';
|
import { css_beautify, html_beautify } from 'js-beautify';
|
||||||
|
import { ResizeObserver } from '@juggle/resize-observer';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-custom-action-pretty-resources-tabs',
|
selector: 'tb-custom-action-pretty-resources-tabs',
|
||||||
@ -64,7 +65,7 @@ export class CustomActionPrettyResourcesTabsComponent extends PageComponent impl
|
|||||||
|
|
||||||
aceEditors: ace.Ace.Editor[] = [];
|
aceEditors: ace.Ace.Editor[] = [];
|
||||||
editorsResizeCafs: {[editorId: string]: CancelAnimationFrame} = {};
|
editorsResizeCafs: {[editorId: string]: CancelAnimationFrame} = {};
|
||||||
aceResizeListeners: { element: any, resizeListener: any }[] = [];
|
aceResizeObservers: ResizeObserver[] = [];
|
||||||
htmlEditor: ace.Ace.Editor;
|
htmlEditor: ace.Ace.Editor;
|
||||||
cssEditor: ace.Ace.Editor;
|
cssEditor: ace.Ace.Editor;
|
||||||
setValuesPending = false;
|
setValuesPending = false;
|
||||||
@ -84,9 +85,8 @@ export class CustomActionPrettyResourcesTabsComponent extends PageComponent impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.aceResizeListeners.forEach((resizeListener) => {
|
this.aceResizeObservers.forEach((resize$) => {
|
||||||
// @ts-ignore
|
resize$.disconnect();
|
||||||
removeResizeListener(resizeListener.element, resizeListener.resizeListener);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,11 +188,11 @@ export class CustomActionPrettyResourcesTabsComponent extends PageComponent impl
|
|||||||
aceEditor.session.setUseWrapMode(true);
|
aceEditor.session.setUseWrapMode(true);
|
||||||
this.aceEditors.push(aceEditor);
|
this.aceEditors.push(aceEditor);
|
||||||
|
|
||||||
const resizeListener = this.onAceEditorResize.bind(this, aceEditor);
|
const resize$ = new ResizeObserver(() => {
|
||||||
|
this.onAceEditorResize(aceEditor);
|
||||||
// @ts-ignore
|
});
|
||||||
addResizeListener(editorElement, resizeListener);
|
resize$.observe(editorElement);
|
||||||
this.aceResizeListeners.push({element: editorElement, resizeListener});
|
this.aceResizeObservers.push(resize$);
|
||||||
return aceEditor;
|
return aceEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -58,6 +58,7 @@ import { AttributeData, AttributeScope } from '@shared/models/telemetry/telemetr
|
|||||||
import { forkJoin, Observable } from 'rxjs';
|
import { forkJoin, Observable } from 'rxjs';
|
||||||
import { tap } from 'rxjs/operators';
|
import { tap } from 'rxjs/operators';
|
||||||
import { ImportExportService } from '@home/components/import-export/import-export.service';
|
import { ImportExportService } from '@home/components/import-export/import-export.service';
|
||||||
|
import { ResizeObserver } from '@juggle/resize-observer';
|
||||||
|
|
||||||
// @dynamic
|
// @dynamic
|
||||||
@Component({
|
@Component({
|
||||||
@ -93,7 +94,7 @@ export class GatewayFormComponent extends PageComponent implements OnInit, OnDes
|
|||||||
private successfulSaved: string;
|
private successfulSaved: string;
|
||||||
private gatewayNameExists: string;
|
private gatewayNameExists: string;
|
||||||
private archiveFileName: string;
|
private archiveFileName: string;
|
||||||
private formResizeListener: any;
|
private formResize$: ResizeObserver;
|
||||||
private subscribeStorageType$: any;
|
private subscribeStorageType$: any;
|
||||||
private subscribeGateway$: any;
|
private subscribeGateway$: any;
|
||||||
|
|
||||||
@ -116,15 +117,15 @@ export class GatewayFormComponent extends PageComponent implements OnInit, OnDes
|
|||||||
|
|
||||||
this.buildForm();
|
this.buildForm();
|
||||||
this.ctx.updateWidgetParams();
|
this.ctx.updateWidgetParams();
|
||||||
this.formResizeListener = this.resize.bind(this);
|
this.formResize$ = new ResizeObserver(() => {
|
||||||
// @ts-ignore
|
this.resize();
|
||||||
addResizeListener(this.formContainerRef.nativeElement, this.formResizeListener);
|
});
|
||||||
|
this.formResize$.observe(this.formContainerRef.nativeElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
if (this.formResizeListener) {
|
if (this.formResize$) {
|
||||||
// @ts-ignore
|
this.formResize$.disconnect();
|
||||||
removeResizeListener(this.formContainerRef.nativeElement, this.formResizeListener);
|
|
||||||
}
|
}
|
||||||
this.subscribeGateway$.unsubscribe();
|
this.subscribeGateway$.unsubscribe();
|
||||||
this.subscribeStorageType$.unsubscribe();
|
this.subscribeStorageType$.unsubscribe();
|
||||||
|
|||||||
@ -33,6 +33,7 @@ import { AttributeService } from '@core/http/attribute.service';
|
|||||||
import { AttributeData, AttributeScope, LatestTelemetry } from '@shared/models/telemetry/telemetry.models';
|
import { AttributeData, AttributeScope, LatestTelemetry } from '@shared/models/telemetry/telemetry.models';
|
||||||
import { forkJoin, Observable } from 'rxjs';
|
import { forkJoin, Observable } from 'rxjs';
|
||||||
import { EntityId } from '@shared/models/id/entity-id';
|
import { EntityId } from '@shared/models/id/entity-id';
|
||||||
|
import { ResizeObserver } from '@juggle/resize-observer';
|
||||||
|
|
||||||
type FieldAlignment = 'row' | 'column';
|
type FieldAlignment = 'row' | 'column';
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni
|
|||||||
@Input()
|
@Input()
|
||||||
ctx: WidgetContext;
|
ctx: WidgetContext;
|
||||||
|
|
||||||
private formResizeListener: any;
|
private formResize$: ResizeObserver;
|
||||||
private settings: MultipleInputWidgetSettings;
|
private settings: MultipleInputWidgetSettings;
|
||||||
private widgetConfig: WidgetConfig;
|
private widgetConfig: WidgetConfig;
|
||||||
private subscription: IWidgetSubscription;
|
private subscription: IWidgetSubscription;
|
||||||
@ -135,15 +136,15 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni
|
|||||||
this.updateDatasources();
|
this.updateDatasources();
|
||||||
this.buildForm();
|
this.buildForm();
|
||||||
this.ctx.updateWidgetParams();
|
this.ctx.updateWidgetParams();
|
||||||
this.formResizeListener = this.resize.bind(this);
|
this.formResize$ = new ResizeObserver(() => {
|
||||||
// @ts-ignore
|
this.resize();
|
||||||
addResizeListener(this.formContainerRef.nativeElement, this.formResizeListener);
|
});
|
||||||
|
this.formResize$.observe(this.formContainerRef.nativeElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
if (this.formResizeListener) {
|
if (this.formResize$) {
|
||||||
// @ts-ignore
|
this.formResize$.disconnect();
|
||||||
removeResizeListener(this.formContainerRef.nativeElement, this.formResizeListener);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,9 +22,9 @@ import { Store } from '@ngrx/store';
|
|||||||
import { AppState } from '@core/core.state';
|
import { AppState } from '@core/core.state';
|
||||||
import { isDefined, isNumber } from '@core/utils';
|
import { isDefined, isNumber } from '@core/utils';
|
||||||
import { CanvasDigitalGauge, CanvasDigitalGaugeOptions } from '@home/components/widget/lib/canvas-digital-gauge';
|
import { CanvasDigitalGauge, CanvasDigitalGaugeOptions } from '@home/components/widget/lib/canvas-digital-gauge';
|
||||||
import GenericOptions = CanvasGauges.GenericOptions;
|
|
||||||
import * as tinycolor_ from 'tinycolor2';
|
import * as tinycolor_ from 'tinycolor2';
|
||||||
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
|
import GenericOptions = CanvasGauges.GenericOptions;
|
||||||
|
import { ResizeObserver } from '@juggle/resize-observer';
|
||||||
|
|
||||||
const tinycolor = tinycolor_;
|
const tinycolor = tinycolor_;
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ export class KnobComponent extends PageComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
private canvasBar: CanvasDigitalGauge;
|
private canvasBar: CanvasDigitalGauge;
|
||||||
|
|
||||||
private knobResizeListener: any;
|
private knobResize$: ResizeObserver;
|
||||||
|
|
||||||
constructor(private utils: UtilsService,
|
constructor(private utils: UtilsService,
|
||||||
protected store: Store<AppState>) {
|
protected store: Store<AppState>) {
|
||||||
@ -126,16 +126,16 @@ export class KnobComponent extends PageComponent implements OnInit, OnDestroy {
|
|||||||
this.textMeasure = $(this.textMeasureRef.nativeElement);
|
this.textMeasure = $(this.textMeasureRef.nativeElement);
|
||||||
this.canvasBarElement = this.canvasBarElementRef.nativeElement;
|
this.canvasBarElement = this.canvasBarElementRef.nativeElement;
|
||||||
|
|
||||||
this.knobResizeListener = this.resize.bind(this);
|
this.knobResize$ = new ResizeObserver(() => {
|
||||||
// @ts-ignore
|
this.resize();
|
||||||
addResizeListener(this.knobContainerRef.nativeElement, this.knobResizeListener);
|
});
|
||||||
|
this.knobResize$.observe(this.knobContainerRef.nativeElement);
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
if (this.knobResizeListener) {
|
if (this.knobResize$) {
|
||||||
// @ts-ignore
|
this.knobResize$.disconnect();
|
||||||
removeResizeListener(this.knobContainerRef.nativeElement, this.knobResizeListener);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import { UtilsService } from '@core/services/utils.service';
|
|||||||
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';
|
||||||
import Timeout = NodeJS.Timeout;
|
import Timeout = NodeJS.Timeout;
|
||||||
|
|
||||||
const tinycolor = tinycolor_;
|
const tinycolor = tinycolor_;
|
||||||
@ -93,7 +94,7 @@ export class LedIndicatorComponent extends PageComponent implements OnInit, OnDe
|
|||||||
private ledErrorContainer: JQuery<HTMLElement>;
|
private ledErrorContainer: JQuery<HTMLElement>;
|
||||||
private ledError: JQuery<HTMLElement>;
|
private ledError: JQuery<HTMLElement>;
|
||||||
|
|
||||||
private ledResizeListener: any;
|
private ledResize$: ResizeObserver;
|
||||||
|
|
||||||
private subscriptionOptions: WidgetSubscriptionOptions = {
|
private subscriptionOptions: WidgetSubscriptionOptions = {
|
||||||
callbacks: {
|
callbacks: {
|
||||||
@ -122,9 +123,10 @@ export class LedIndicatorComponent extends PageComponent implements OnInit, OnDe
|
|||||||
this.ledErrorContainer = $(this.ledErrorContainerRef.nativeElement);
|
this.ledErrorContainer = $(this.ledErrorContainerRef.nativeElement);
|
||||||
this.ledError = $(this.ledErrorRef.nativeElement);
|
this.ledError = $(this.ledErrorRef.nativeElement);
|
||||||
|
|
||||||
this.ledResizeListener = this.resize.bind(this);
|
this.ledResize$ = new ResizeObserver(() => {
|
||||||
// @ts-ignore
|
this.resize();
|
||||||
addResizeListener(this.ledContainerRef.nativeElement, this.ledResizeListener);
|
});
|
||||||
|
this.ledResize$.observe(this.ledContainerRef.nativeElement);
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,9 +138,8 @@ export class LedIndicatorComponent extends PageComponent implements OnInit, OnDe
|
|||||||
if (this.subscription) {
|
if (this.subscription) {
|
||||||
this.ctx.subscriptionApi.removeSubscription(this.subscription.id);
|
this.ctx.subscriptionApi.removeSubscription(this.subscription.id);
|
||||||
}
|
}
|
||||||
if (this.ledResizeListener) {
|
if (this.ledResize$) {
|
||||||
// @ts-ignore
|
this.ledResize$.disconnect();
|
||||||
removeResizeListener(this.ledContainerRef.nativeElement, this.ledResizeListener);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import { IWidgetSubscription, SubscriptionInfo, WidgetSubscriptionOptions } from
|
|||||||
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 { MatSlideToggle } from '@angular/material/slide-toggle';
|
import { MatSlideToggle } from '@angular/material/slide-toggle';
|
||||||
|
import { ResizeObserver } from '@juggle/resize-observer';
|
||||||
|
|
||||||
const switchAspectRation = 2.7893;
|
const switchAspectRation = 2.7893;
|
||||||
|
|
||||||
@ -98,7 +99,7 @@ export class SwitchComponent extends PageComponent implements OnInit, OnDestroy
|
|||||||
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>) {
|
||||||
@ -118,9 +119,10 @@ export class SwitchComponent extends PageComponent implements OnInit, OnDestroy
|
|||||||
this.switchErrorContainer = $(this.switchErrorContainerRef.nativeElement);
|
this.switchErrorContainer = $(this.switchErrorContainerRef.nativeElement);
|
||||||
this.switchError = $(this.switchErrorRef.nativeElement);
|
this.switchError = $(this.switchErrorRef.nativeElement);
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,9 +130,8 @@ export class SwitchComponent extends PageComponent implements OnInit, OnDestroy
|
|||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -91,6 +91,7 @@ import { DatasourceService } from '@core/api/datasource.service';
|
|||||||
import { WidgetSubscription } from '@core/api/widget-subscription';
|
import { WidgetSubscription } from '@core/api/widget-subscription';
|
||||||
import { EntityService } from '@core/http/entity.service';
|
import { EntityService } from '@core/http/entity.service';
|
||||||
import { ServicesMap } from '@home/models/services.map';
|
import { ServicesMap } from '@home/models/services.map';
|
||||||
|
import { ResizeObserver } from '@juggle/resize-observer';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-widget',
|
selector: 'tb-widget',
|
||||||
@ -140,7 +141,7 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
|
|||||||
|
|
||||||
cafs: {[cafId: string]: CancelAnimationFrame} = {};
|
cafs: {[cafId: string]: CancelAnimationFrame} = {};
|
||||||
|
|
||||||
onResizeListener = null;
|
private widgetResize$: ResizeObserver;
|
||||||
|
|
||||||
private cssParser = new cssjs();
|
private cssParser = new cssjs();
|
||||||
|
|
||||||
@ -647,10 +648,8 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
|
|||||||
}
|
}
|
||||||
|
|
||||||
private destroyDynamicWidgetComponent() {
|
private destroyDynamicWidgetComponent() {
|
||||||
if (this.widgetContext.$containerParent && this.onResizeListener) {
|
if (this.widgetContext.$containerParent && this.widgetResize$) {
|
||||||
// @ts-ignore
|
this.widgetResize$.disconnect()
|
||||||
removeResizeListener(this.widgetContext.$containerParent[0], this.onResizeListener);
|
|
||||||
this.onResizeListener = null;
|
|
||||||
}
|
}
|
||||||
if (this.dynamicWidgetComponentRef) {
|
if (this.dynamicWidgetComponentRef) {
|
||||||
this.dynamicWidgetComponentRef.destroy();
|
this.dynamicWidgetComponentRef.destroy();
|
||||||
@ -709,9 +708,10 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onResizeListener = this.onResize.bind(this);
|
this.widgetResize$ = new ResizeObserver(() => {
|
||||||
// @ts-ignore
|
this.onResize();
|
||||||
addResizeListener(this.widgetContext.$containerParent[0], this.onResizeListener);
|
});
|
||||||
|
this.widgetResize$.observe(this.widgetContext.$containerParent[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private createSubscription(options: WidgetSubscriptionOptions, subscribe?: boolean): Observable<IWidgetSubscription> {
|
private createSubscription(options: WidgetSubscriptionOptions, subscribe?: boolean): Observable<IWidgetSubscription> {
|
||||||
|
|||||||
@ -14,8 +14,7 @@
|
|||||||
/// limitations under the License.
|
/// limitations under the License.
|
||||||
///
|
///
|
||||||
|
|
||||||
import { Component, OnDestroy, OnInit, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core';
|
import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||||
import { PageComponent } from '@shared/components/page.component';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-dashboard-toolbar',
|
selector: 'tb-dashboard-toolbar',
|
||||||
|
|||||||
@ -46,6 +46,7 @@ import {
|
|||||||
} from '@home/pages/widget/save-widget-type-as-dialog.component';
|
} from '@home/pages/widget/save-widget-type-as-dialog.component';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import Timeout = NodeJS.Timeout;
|
import Timeout = NodeJS.Timeout;
|
||||||
|
import { ResizeObserver } from '@juggle/resize-observer';
|
||||||
|
|
||||||
// @dynamic
|
// @dynamic
|
||||||
@Component({
|
@Component({
|
||||||
@ -124,7 +125,7 @@ export class WidgetEditorComponent extends PageComponent implements OnInit, OnDe
|
|||||||
jsonSettingsEditor: ace.Ace.Editor;
|
jsonSettingsEditor: ace.Ace.Editor;
|
||||||
dataKeyJsonSettingsEditor: ace.Ace.Editor;
|
dataKeyJsonSettingsEditor: ace.Ace.Editor;
|
||||||
jsEditor: ace.Ace.Editor;
|
jsEditor: ace.Ace.Editor;
|
||||||
aceResizeListeners: { element: any, resizeListener: any }[] = [];
|
aceResizeObservers: ResizeObserver[] = [];
|
||||||
|
|
||||||
onWindowMessageListener = this.onWindowMessage.bind(this);
|
onWindowMessageListener = this.onWindowMessage.bind(this);
|
||||||
|
|
||||||
@ -193,9 +194,8 @@ export class WidgetEditorComponent extends PageComponent implements OnInit, OnDe
|
|||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.window.removeEventListener('message', this.onWindowMessageListener);
|
this.window.removeEventListener('message', this.onWindowMessageListener);
|
||||||
this.aceResizeListeners.forEach((resizeListener) => {
|
this.aceResizeObservers.forEach((resize$) => {
|
||||||
// @ts-ignore
|
resize$.disconnect();
|
||||||
removeResizeListener(resizeListener.element, resizeListener.resizeListener);
|
|
||||||
});
|
});
|
||||||
this.rxSubscriptions.forEach((subscription) => {
|
this.rxSubscriptions.forEach((subscription) => {
|
||||||
subscription.unsubscribe();
|
subscription.unsubscribe();
|
||||||
@ -343,11 +343,11 @@ export class WidgetEditorComponent extends PageComponent implements OnInit, OnDe
|
|||||||
aceEditor.session.setUseWrapMode(true);
|
aceEditor.session.setUseWrapMode(true);
|
||||||
this.aceEditors.push(aceEditor);
|
this.aceEditors.push(aceEditor);
|
||||||
|
|
||||||
const resizeListener = this.onAceEditorResize.bind(this, aceEditor);
|
const resize$ = new ResizeObserver(() => {
|
||||||
|
this.onAceEditorResize(aceEditor);
|
||||||
// @ts-ignore
|
});
|
||||||
addResizeListener(editorElement, resizeListener);
|
resize$.observe(editorElement);
|
||||||
this.aceResizeListeners.push({element: editorElement, resizeListener});
|
this.aceResizeObservers.push(resize$);
|
||||||
return aceEditor;
|
return aceEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import {
|
|||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { WINDOW } from '@core/services/window.service';
|
import { WINDOW } from '@core/services/window.service';
|
||||||
import { CanColorCtor, mixinColor } from '@angular/material/core';
|
import { CanColorCtor, mixinColor } from '@angular/material/core';
|
||||||
|
import { ResizeObserver } from '@juggle/resize-observer';
|
||||||
|
|
||||||
export declare type FabToolbarDirection = 'left' | 'right';
|
export declare type FabToolbarDirection = 'left' | 'right';
|
||||||
|
|
||||||
@ -77,14 +78,14 @@ export class FabActionsDirective implements OnInit {
|
|||||||
})
|
})
|
||||||
export class FabToolbarComponent extends MatFabToolbarMixinBase implements OnInit, OnDestroy, AfterViewInit, OnChanges {
|
export class FabToolbarComponent extends MatFabToolbarMixinBase implements OnInit, OnDestroy, AfterViewInit, OnChanges {
|
||||||
|
|
||||||
|
private fabToolbarResize$: ResizeObserver;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
direction: FabToolbarDirection;
|
direction: FabToolbarDirection;
|
||||||
|
|
||||||
fabToolbarResizeListener = this.onFabToolbarResize.bind(this);
|
|
||||||
|
|
||||||
constructor(private el: ElementRef<HTMLElement>,
|
constructor(private el: ElementRef<HTMLElement>,
|
||||||
@Inject(WINDOW) private window: Window) {
|
@Inject(WINDOW) private window: Window) {
|
||||||
super(el);
|
super(el);
|
||||||
@ -96,13 +97,14 @@ export class FabToolbarComponent extends MatFabToolbarMixinBase implements OnIni
|
|||||||
element.find('mat-fab-trigger').find('button')
|
element.find('mat-fab-trigger').find('button')
|
||||||
.prepend('<div class="mat-fab-toolbar-background"></div>');
|
.prepend('<div class="mat-fab-toolbar-background"></div>');
|
||||||
element.addClass(`mat-${this.direction}`);
|
element.addClass(`mat-${this.direction}`);
|
||||||
// @ts-ignore
|
this.fabToolbarResize$ = new ResizeObserver(() => {
|
||||||
addResizeListener(this.el.nativeElement, this.fabToolbarResizeListener);
|
this.onFabToolbarResize();
|
||||||
|
});
|
||||||
|
this.fabToolbarResize$.observe(this.el.nativeElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
// @ts-ignore
|
this.fabToolbarResize$.disconnect();
|
||||||
removeResizeListener(this.el.nativeElement, this.fabToolbarResizeListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
|
|||||||
@ -15,11 +15,11 @@
|
|||||||
///
|
///
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ChangeDetectionStrategy,
|
|
||||||
Component,
|
Component,
|
||||||
ElementRef,
|
ElementRef,
|
||||||
forwardRef,
|
forwardRef,
|
||||||
Input, OnDestroy,
|
Input,
|
||||||
|
OnDestroy,
|
||||||
OnInit,
|
OnInit,
|
||||||
ViewChild,
|
ViewChild,
|
||||||
ViewEncapsulation
|
ViewEncapsulation
|
||||||
@ -34,6 +34,7 @@ import { UtilsService } from '@core/services/utils.service';
|
|||||||
import { guid, isUndefined } from '@app/core/utils';
|
import { guid, isUndefined } from '@app/core/utils';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { CancelAnimationFrame, RafService } from '@core/services/raf.service';
|
import { CancelAnimationFrame, RafService } from '@core/services/raf.service';
|
||||||
|
import { ResizeObserver } from '@juggle/resize-observer';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-js-func',
|
selector: 'tb-js-func',
|
||||||
@ -60,7 +61,7 @@ export class JsFuncComponent implements OnInit, OnDestroy, ControlValueAccessor,
|
|||||||
|
|
||||||
private jsEditor: ace.Ace.Editor;
|
private jsEditor: ace.Ace.Editor;
|
||||||
private editorsResizeCaf: CancelAnimationFrame;
|
private editorsResizeCaf: CancelAnimationFrame;
|
||||||
private editorResizeListener: any;
|
private editorResize$: ResizeObserver;
|
||||||
|
|
||||||
toastTargetId = `jsFuncEditor-${guid()}`;
|
toastTargetId = `jsFuncEditor-${guid()}`;
|
||||||
|
|
||||||
@ -152,16 +153,15 @@ export class JsFuncComponent implements OnInit, OnDestroy, ControlValueAccessor,
|
|||||||
this.cleanupJsErrors();
|
this.cleanupJsErrors();
|
||||||
this.updateView();
|
this.updateView();
|
||||||
});
|
});
|
||||||
this.editorResizeListener = this.onAceEditorResize.bind(this);
|
this.editorResize$ = new ResizeObserver(() => {
|
||||||
// @ts-ignore
|
this.onAceEditorResize();
|
||||||
addResizeListener(editorElement, this.editorResizeListener);
|
});
|
||||||
|
this.editorResize$.observe(editorElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
if (this.editorResizeListener) {
|
if (this.editorResize$) {
|
||||||
const editorElement = this.javascriptEditorElmRef.nativeElement;
|
this.editorResize$.disconnect();
|
||||||
// @ts-ignore
|
|
||||||
removeResizeListener(editorElement, this.editorResizeListener);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,10 +20,10 @@ import {
|
|||||||
forwardRef,
|
forwardRef,
|
||||||
Input,
|
Input,
|
||||||
OnChanges,
|
OnChanges,
|
||||||
|
OnDestroy,
|
||||||
OnInit,
|
OnInit,
|
||||||
ViewChild,
|
|
||||||
SimpleChanges,
|
SimpleChanges,
|
||||||
OnDestroy
|
ViewChild
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { ControlValueAccessor, FormControl, NG_VALIDATORS, NG_VALUE_ACCESSOR, Validator } from '@angular/forms';
|
import { ControlValueAccessor, FormControl, NG_VALIDATORS, NG_VALUE_ACCESSOR, Validator } from '@angular/forms';
|
||||||
import * as ace from 'ace-builds';
|
import * as ace from 'ace-builds';
|
||||||
@ -34,6 +34,7 @@ import { AppState } from '@core/core.state';
|
|||||||
import { ContentType, contentTypesMap } from '@shared/models/constants';
|
import { ContentType, contentTypesMap } from '@shared/models/constants';
|
||||||
import { CancelAnimationFrame, RafService } from '@core/services/raf.service';
|
import { CancelAnimationFrame, RafService } from '@core/services/raf.service';
|
||||||
import { guid } from '@core/utils';
|
import { guid } from '@core/utils';
|
||||||
|
import { ResizeObserver } from '@juggle/resize-observer';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-json-content',
|
selector: 'tb-json-content',
|
||||||
@ -59,7 +60,7 @@ export class JsonContentComponent implements OnInit, ControlValueAccessor, Valid
|
|||||||
|
|
||||||
private jsonEditor: ace.Ace.Editor;
|
private jsonEditor: ace.Ace.Editor;
|
||||||
private editorsResizeCaf: CancelAnimationFrame;
|
private editorsResizeCaf: CancelAnimationFrame;
|
||||||
private editorResizeListener: any;
|
private editorResize$: ResizeObserver;
|
||||||
|
|
||||||
toastTargetId = `jsonContentEditor-${guid()}`;
|
toastTargetId = `jsonContentEditor-${guid()}`;
|
||||||
|
|
||||||
@ -97,8 +98,6 @@ export class JsonContentComponent implements OnInit, ControlValueAccessor, Valid
|
|||||||
|
|
||||||
contentValid: boolean;
|
contentValid: boolean;
|
||||||
|
|
||||||
validationError: string;
|
|
||||||
|
|
||||||
errorShowed = false;
|
errorShowed = false;
|
||||||
|
|
||||||
private propagateChange = null;
|
private propagateChange = null;
|
||||||
@ -135,16 +134,15 @@ export class JsonContentComponent implements OnInit, ControlValueAccessor, Valid
|
|||||||
this.cleanupJsonErrors();
|
this.cleanupJsonErrors();
|
||||||
this.updateView();
|
this.updateView();
|
||||||
});
|
});
|
||||||
this.editorResizeListener = this.onAceEditorResize.bind(this);
|
this.editorResize$ = new ResizeObserver(() => {
|
||||||
// @ts-ignore
|
this.onAceEditorResize();
|
||||||
addResizeListener(editorElement, this.editorResizeListener);
|
});
|
||||||
|
this.editorResize$.observe(editorElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
if (this.editorResizeListener) {
|
if (this.editorResize$) {
|
||||||
const editorElement = this.jsonEditorElmRef.nativeElement;
|
this.editorResize$.disconnect();
|
||||||
// @ts-ignore
|
|
||||||
removeResizeListener(editorElement, this.editorResizeListener);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,16 +14,8 @@
|
|||||||
/// limitations under the License.
|
/// limitations under the License.
|
||||||
///
|
///
|
||||||
|
|
||||||
import {
|
import { Component, ElementRef, forwardRef, Input, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||||
Attribute, ChangeDetectionStrategy,
|
import { ControlValueAccessor, FormControl, NG_VALIDATORS, NG_VALUE_ACCESSOR, Validator } from '@angular/forms';
|
||||||
Component,
|
|
||||||
ElementRef,
|
|
||||||
forwardRef,
|
|
||||||
Input, OnDestroy,
|
|
||||||
OnInit,
|
|
||||||
ViewChild
|
|
||||||
} from '@angular/core';
|
|
||||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR, FormControl, Validator, NG_VALIDATORS } from '@angular/forms';
|
|
||||||
import * as ace from 'ace-builds';
|
import * as ace from 'ace-builds';
|
||||||
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
||||||
import { ActionNotificationHide, ActionNotificationShow } from '@core/notification/notification.actions';
|
import { ActionNotificationHide, ActionNotificationShow } from '@core/notification/notification.actions';
|
||||||
@ -31,6 +23,7 @@ import { Store } from '@ngrx/store';
|
|||||||
import { AppState } from '@core/core.state';
|
import { AppState } from '@core/core.state';
|
||||||
import { CancelAnimationFrame, RafService } from '@core/services/raf.service';
|
import { CancelAnimationFrame, RafService } from '@core/services/raf.service';
|
||||||
import { guid } from '@core/utils';
|
import { guid } from '@core/utils';
|
||||||
|
import { ResizeObserver } from '@juggle/resize-observer';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-json-object-edit',
|
selector: 'tb-json-object-edit',
|
||||||
@ -56,7 +49,7 @@ export class JsonObjectEditComponent implements OnInit, ControlValueAccessor, Va
|
|||||||
|
|
||||||
private jsonEditor: ace.Ace.Editor;
|
private jsonEditor: ace.Ace.Editor;
|
||||||
private editorsResizeCaf: CancelAnimationFrame;
|
private editorsResizeCaf: CancelAnimationFrame;
|
||||||
private editorResizeListener: any;
|
private editorResize$: ResizeObserver;
|
||||||
|
|
||||||
toastTargetId = `jsonObjectEditor-${guid()}`;
|
toastTargetId = `jsonObjectEditor-${guid()}`;
|
||||||
|
|
||||||
@ -128,16 +121,15 @@ export class JsonObjectEditComponent implements OnInit, ControlValueAccessor, Va
|
|||||||
this.cleanupJsonErrors();
|
this.cleanupJsonErrors();
|
||||||
this.updateView();
|
this.updateView();
|
||||||
});
|
});
|
||||||
this.editorResizeListener = this.onAceEditorResize.bind(this);
|
this.editorResize$ = new ResizeObserver(() => {
|
||||||
// @ts-ignore
|
this.onAceEditorResize();
|
||||||
addResizeListener(editorElement, this.editorResizeListener);
|
});
|
||||||
|
this.editorResize$.observe(editorElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
if (this.editorResizeListener) {
|
if (this.editorResize$) {
|
||||||
const editorElement = this.jsonEditorElmRef.nativeElement;
|
this.editorResize$.disconnect();
|
||||||
// @ts-ignore
|
|
||||||
removeResizeListener(editorElement, this.editorResizeListener);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user