Commit d29a8731cedb7a0bc827c86a5baff8be04ca6025
1 parent
2bdde375
Implement local timewindow handling.
Showing
5 changed files
with
40 additions
and
14 deletions
... | ... | @@ -321,14 +321,6 @@ export class WidgetSubscription implements IWidgetSubscription { |
321 | 321 | }); |
322 | 322 | if (this.displayLegend) { |
323 | 323 | this.legendData.keys = this.legendData.keys.sort((key1, key2) => key1.dataKey.label.localeCompare(key2.dataKey.label)); |
324 | - // TODO: | |
325 | - } | |
326 | - if (this.type === widgetType.timeseries) { | |
327 | - if (this.useDashboardTimewindow) { | |
328 | - // TODO: | |
329 | - } else { | |
330 | - // TODO: | |
331 | - } | |
332 | 324 | } |
333 | 325 | } |
334 | 326 | |
... | ... | @@ -395,6 +387,10 @@ export class WidgetSubscription implements IWidgetSubscription { |
395 | 387 | } |
396 | 388 | |
397 | 389 | updateTimewindowConfig(newTimewindow: Timewindow): void { |
390 | + if (!this.useDashboardTimewindow) { | |
391 | + this.timeWindowConfig = newTimewindow; | |
392 | + this.update(); | |
393 | + } | |
398 | 394 | } |
399 | 395 | |
400 | 396 | onResetTimewindow(): void { |
... | ... | @@ -424,14 +420,17 @@ export class WidgetSubscription implements IWidgetSubscription { |
424 | 420 | } |
425 | 421 | |
426 | 422 | sendOneWayCommand(method: string, params?: any, timeout?: number): Observable<any> { |
423 | + // TODO: | |
427 | 424 | return undefined; |
428 | 425 | } |
429 | 426 | |
430 | 427 | sendTwoWayCommand(method: string, params?: any, timeout?: number): Observable<any> { |
428 | + // TODO: | |
431 | 429 | return undefined; |
432 | 430 | } |
433 | 431 | |
434 | 432 | clearRpcError(): void { |
433 | + // TODO: | |
435 | 434 | } |
436 | 435 | |
437 | 436 | update() { |
... | ... | @@ -536,7 +535,6 @@ export class WidgetSubscription implements IWidgetSubscription { |
536 | 535 | this.cafs[cafId] = null; |
537 | 536 | } |
538 | 537 | } |
539 | - // TODO: | |
540 | 538 | } |
541 | 539 | |
542 | 540 | private notifyDataLoading() { | ... | ... |
... | ... | @@ -50,6 +50,7 @@ |
50 | 50 | {{widget.title}} |
51 | 51 | </span> |
52 | 52 | <tb-timewindow *ngIf="widget.hasTimewindow" |
53 | + #timewindowComponent | |
53 | 54 | aggregation="{{widget.hasAggregation}}" |
54 | 55 | [ngModel]="widget.widget.config.timewindow" |
55 | 56 | (ngModelChange)="widgetComponent.onTimewindowChanged($event)"> |
... | ... | @@ -98,7 +99,7 @@ |
98 | 99 | </button> |
99 | 100 | <button mat-button mat-icon-button |
100 | 101 | [fxShow]="isRemoveActionEnabled && !widget.isFullscreen" |
101 | - (click)="removeWidget($event, widget)" | |
102 | + (click)="removeWidget($event, widget);" | |
102 | 103 | matTooltip="{{ 'widget.remove' | translate }}" |
103 | 104 | matTooltipPosition="above"> |
104 | 105 | <mat-icon>close</mat-icon> | ... | ... |
... | ... | @@ -29,7 +29,8 @@ import { |
29 | 29 | ViewChild, |
30 | 30 | ViewContainerRef, |
31 | 31 | ViewEncapsulation, |
32 | - ChangeDetectorRef | |
32 | + ChangeDetectorRef, | |
33 | + ChangeDetectionStrategy, NgZone | |
33 | 34 | } from '@angular/core'; |
34 | 35 | import { DashboardWidget, IDashboardComponent } from '@home/models/dashboard-component.models'; |
35 | 36 | import { |
... | ... | @@ -86,12 +87,14 @@ import { DashboardService } from '@core/http/dashboard.service'; |
86 | 87 | import { DatasourceService } from '@core/api/datasource.service'; |
87 | 88 | import { WidgetSubscription } from '@core/api/widget-subscription'; |
88 | 89 | import { EntityService } from '@core/http/entity.service'; |
90 | +import { TimewindowComponent } from '@shared/components/time/timewindow.component'; | |
89 | 91 | |
90 | 92 | @Component({ |
91 | 93 | selector: 'tb-widget', |
92 | 94 | templateUrl: './widget.component.html', |
93 | 95 | styleUrls: ['./widget.component.scss'], |
94 | - encapsulation: ViewEncapsulation.None | |
96 | + encapsulation: ViewEncapsulation.None, | |
97 | + changeDetection: ChangeDetectionStrategy.OnPush | |
95 | 98 | }) |
96 | 99 | export class WidgetComponent extends PageComponent implements OnInit, AfterViewInit, OnChanges, OnDestroy { |
97 | 100 | |
... | ... | @@ -159,6 +162,7 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI |
159 | 162 | private datasourceService: DatasourceService, |
160 | 163 | private utils: UtilsService, |
161 | 164 | private raf: RafService, |
165 | + private ngZone: NgZone, | |
162 | 166 | private cd: ChangeDetectorRef) { |
163 | 167 | super(store); |
164 | 168 | } |
... | ... | @@ -647,6 +651,7 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI |
647 | 651 | |
648 | 652 | this.widgetContext.$container = $('> ng-component', containerElement); |
649 | 653 | this.widgetContext.$container.css('display', 'block'); |
654 | + this.widgetContext.$container.css('user-select', 'none'); | |
650 | 655 | this.widgetContext.$container.attr('id', 'container'); |
651 | 656 | this.widgetContext.$containerParent = $(containerElement); |
652 | 657 | |
... | ... | @@ -756,8 +761,9 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI |
756 | 761 | } |
757 | 762 | }, |
758 | 763 | timeWindowUpdated: (subscription, timeWindowConfig) => { |
759 | - this.widget.config.timewindow = timeWindowConfig; | |
760 | - this.cd.detectChanges(); | |
764 | + this.ngZone.run(() => { | |
765 | + this.widget.config.timewindow = timeWindowConfig; | |
766 | + }); | |
761 | 767 | } |
762 | 768 | }; |
763 | 769 | ... | ... |
... | ... | @@ -71,6 +71,8 @@ |
71 | 71 | /*************************************************************************************************** |
72 | 72 | * Zone JS is required by default for Angular itself. |
73 | 73 | */ |
74 | + | |
75 | +import './zone-flags'; | |
74 | 76 | import 'zone.js/dist/zone'; // Included with Angular CLI. |
75 | 77 | import 'core-js/es/array'; |
76 | 78 | ... | ... |
ui-ngx/src/zone-flags.ts
0 → 100644
1 | +/// | |
2 | +/// Copyright © 2016-2019 The Thingsboard Authors | |
3 | +/// | |
4 | +/// Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | +/// you may not use this file except in compliance with the License. | |
6 | +/// You may obtain a copy of the License at | |
7 | +/// | |
8 | +/// http://www.apache.org/licenses/LICENSE-2.0 | |
9 | +/// | |
10 | +/// Unless required by applicable law or agreed to in writing, software | |
11 | +/// distributed under the License is distributed on an "AS IS" BASIS, | |
12 | +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | +/// See the License for the specific language governing permissions and | |
14 | +/// limitations under the License. | |
15 | +/// | |
16 | + | |
17 | +(window as any).__Zone_disable_requestAnimationFrame = false; | |
18 | +(window as any).__Zone_disable_setTimeout = false; | |
19 | +(window as any).__Zone_disable_setInterval = false; | ... | ... |