Browse Source

UI: Initialize widget component in angular zone. Force detect widget changes in angular zone.

pull/12014/head
Igor Kulikov 2 years ago
parent
commit
40c5f9d66d
  1. 20
      ui-ngx/src/app/modules/home/components/widget/widget.component.ts
  2. 16
      ui-ngx/src/app/modules/home/models/widget-component.models.ts

20
ui-ngx/src/app/modules/home/components/widget/widget.component.ts

@ -956,11 +956,15 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
this.widgetContext.hiddenData = subscription.hiddenData; this.widgetContext.hiddenData = subscription.hiddenData;
this.widgetContext.timeWindow = subscription.timeWindow; this.widgetContext.timeWindow = subscription.timeWindow;
this.widgetContext.defaultSubscription = subscription; this.widgetContext.defaultSubscription = subscription;
createSubscriptionSubject.next(); this.ngZone.run(() => {
createSubscriptionSubject.complete(); createSubscriptionSubject.next();
createSubscriptionSubject.complete();
});
}, },
(err) => { (err) => {
createSubscriptionSubject.error(err); this.ngZone.run(() => {
createSubscriptionSubject.error(err);
});
} }
); );
} else if (this.widget.type === widgetType.rpc) { } else if (this.widget.type === widgetType.rpc) {
@ -1013,11 +1017,15 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
this.createSubscription(options).subscribe( this.createSubscription(options).subscribe(
(subscription) => { (subscription) => {
this.widgetContext.defaultSubscription = subscription; this.widgetContext.defaultSubscription = subscription;
createSubscriptionSubject.next(); this.ngZone.run(() => {
createSubscriptionSubject.complete(); createSubscriptionSubject.next();
createSubscriptionSubject.complete();
});
}, },
(err) => { (err) => {
createSubscriptionSubject.error(err); this.ngZone.run(() => {
createSubscriptionSubject.error(err);
});
} }
); );
this.detectChanges(); this.detectChanges();

16
ui-ngx/src/app/modules/home/models/widget-component.models.ts

@ -415,7 +415,13 @@ export class WidgetContext {
this.dashboardWidget.updateWidgetParams(); this.dashboardWidget.updateWidgetParams();
} }
try { try {
this.changeDetectorValue.detectChanges(); if (this.ngZone) {
this.ngZone.run(() => {
this.changeDetectorValue?.detectChanges();
});
} else {
this.changeDetectorValue?.detectChanges();
}
} catch (e) { } catch (e) {
// console.log(e); // console.log(e);
} }
@ -425,7 +431,13 @@ export class WidgetContext {
detectContainerChanges() { detectContainerChanges() {
if (!this.destroyed) { if (!this.destroyed) {
try { try {
this.containerChangeDetectorValue.detectChanges(); if (this.ngZone) {
this.ngZone.run(() => {
this.containerChangeDetectorValue?.detectChanges();
});
} else {
this.containerChangeDetectorValue?.detectChanges();
}
} catch (e) { } catch (e) {
// console.log(e); // console.log(e);
} }

Loading…
Cancel
Save