Commit d29a8731cedb7a0bc827c86a5baff8be04ca6025

Authored by Igor Kulikov
1 parent 2bdde375

Implement local timewindow handling.

@@ -321,14 +321,6 @@ export class WidgetSubscription implements IWidgetSubscription { @@ -321,14 +321,6 @@ export class WidgetSubscription implements IWidgetSubscription {
321 }); 321 });
322 if (this.displayLegend) { 322 if (this.displayLegend) {
323 this.legendData.keys = this.legendData.keys.sort((key1, key2) => key1.dataKey.label.localeCompare(key2.dataKey.label)); 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,6 +387,10 @@ export class WidgetSubscription implements IWidgetSubscription {
395 } 387 }
396 388
397 updateTimewindowConfig(newTimewindow: Timewindow): void { 389 updateTimewindowConfig(newTimewindow: Timewindow): void {
  390 + if (!this.useDashboardTimewindow) {
  391 + this.timeWindowConfig = newTimewindow;
  392 + this.update();
  393 + }
398 } 394 }
399 395
400 onResetTimewindow(): void { 396 onResetTimewindow(): void {
@@ -424,14 +420,17 @@ export class WidgetSubscription implements IWidgetSubscription { @@ -424,14 +420,17 @@ export class WidgetSubscription implements IWidgetSubscription {
424 } 420 }
425 421
426 sendOneWayCommand(method: string, params?: any, timeout?: number): Observable<any> { 422 sendOneWayCommand(method: string, params?: any, timeout?: number): Observable<any> {
  423 + // TODO:
427 return undefined; 424 return undefined;
428 } 425 }
429 426
430 sendTwoWayCommand(method: string, params?: any, timeout?: number): Observable<any> { 427 sendTwoWayCommand(method: string, params?: any, timeout?: number): Observable<any> {
  428 + // TODO:
431 return undefined; 429 return undefined;
432 } 430 }
433 431
434 clearRpcError(): void { 432 clearRpcError(): void {
  433 + // TODO:
435 } 434 }
436 435
437 update() { 436 update() {
@@ -536,7 +535,6 @@ export class WidgetSubscription implements IWidgetSubscription { @@ -536,7 +535,6 @@ export class WidgetSubscription implements IWidgetSubscription {
536 this.cafs[cafId] = null; 535 this.cafs[cafId] = null;
537 } 536 }
538 } 537 }
539 - // TODO:  
540 } 538 }
541 539
542 private notifyDataLoading() { 540 private notifyDataLoading() {
@@ -50,6 +50,7 @@ @@ -50,6 +50,7 @@
50 {{widget.title}} 50 {{widget.title}}
51 </span> 51 </span>
52 <tb-timewindow *ngIf="widget.hasTimewindow" 52 <tb-timewindow *ngIf="widget.hasTimewindow"
  53 + #timewindowComponent
53 aggregation="{{widget.hasAggregation}}" 54 aggregation="{{widget.hasAggregation}}"
54 [ngModel]="widget.widget.config.timewindow" 55 [ngModel]="widget.widget.config.timewindow"
55 (ngModelChange)="widgetComponent.onTimewindowChanged($event)"> 56 (ngModelChange)="widgetComponent.onTimewindowChanged($event)">
@@ -98,7 +99,7 @@ @@ -98,7 +99,7 @@
98 </button> 99 </button>
99 <button mat-button mat-icon-button 100 <button mat-button mat-icon-button
100 [fxShow]="isRemoveActionEnabled && !widget.isFullscreen" 101 [fxShow]="isRemoveActionEnabled && !widget.isFullscreen"
101 - (click)="removeWidget($event, widget)" 102 + (click)="removeWidget($event, widget);"
102 matTooltip="{{ 'widget.remove' | translate }}" 103 matTooltip="{{ 'widget.remove' | translate }}"
103 matTooltipPosition="above"> 104 matTooltipPosition="above">
104 <mat-icon>close</mat-icon> 105 <mat-icon>close</mat-icon>
@@ -29,7 +29,8 @@ import { @@ -29,7 +29,8 @@ import {
29 ViewChild, 29 ViewChild,
30 ViewContainerRef, 30 ViewContainerRef,
31 ViewEncapsulation, 31 ViewEncapsulation,
32 - ChangeDetectorRef 32 + ChangeDetectorRef,
  33 + ChangeDetectionStrategy, NgZone
33 } from '@angular/core'; 34 } from '@angular/core';
34 import { DashboardWidget, IDashboardComponent } from '@home/models/dashboard-component.models'; 35 import { DashboardWidget, IDashboardComponent } from '@home/models/dashboard-component.models';
35 import { 36 import {
@@ -86,12 +87,14 @@ import { DashboardService } from '@core/http/dashboard.service'; @@ -86,12 +87,14 @@ import { DashboardService } from '@core/http/dashboard.service';
86 import { DatasourceService } from '@core/api/datasource.service'; 87 import { DatasourceService } from '@core/api/datasource.service';
87 import { WidgetSubscription } from '@core/api/widget-subscription'; 88 import { WidgetSubscription } from '@core/api/widget-subscription';
88 import { EntityService } from '@core/http/entity.service'; 89 import { EntityService } from '@core/http/entity.service';
  90 +import { TimewindowComponent } from '@shared/components/time/timewindow.component';
89 91
90 @Component({ 92 @Component({
91 selector: 'tb-widget', 93 selector: 'tb-widget',
92 templateUrl: './widget.component.html', 94 templateUrl: './widget.component.html',
93 styleUrls: ['./widget.component.scss'], 95 styleUrls: ['./widget.component.scss'],
94 - encapsulation: ViewEncapsulation.None 96 + encapsulation: ViewEncapsulation.None,
  97 + changeDetection: ChangeDetectionStrategy.OnPush
95 }) 98 })
96 export class WidgetComponent extends PageComponent implements OnInit, AfterViewInit, OnChanges, OnDestroy { 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,6 +162,7 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
159 private datasourceService: DatasourceService, 162 private datasourceService: DatasourceService,
160 private utils: UtilsService, 163 private utils: UtilsService,
161 private raf: RafService, 164 private raf: RafService,
  165 + private ngZone: NgZone,
162 private cd: ChangeDetectorRef) { 166 private cd: ChangeDetectorRef) {
163 super(store); 167 super(store);
164 } 168 }
@@ -647,6 +651,7 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI @@ -647,6 +651,7 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
647 651
648 this.widgetContext.$container = $('> ng-component', containerElement); 652 this.widgetContext.$container = $('> ng-component', containerElement);
649 this.widgetContext.$container.css('display', 'block'); 653 this.widgetContext.$container.css('display', 'block');
  654 + this.widgetContext.$container.css('user-select', 'none');
650 this.widgetContext.$container.attr('id', 'container'); 655 this.widgetContext.$container.attr('id', 'container');
651 this.widgetContext.$containerParent = $(containerElement); 656 this.widgetContext.$containerParent = $(containerElement);
652 657
@@ -756,8 +761,9 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI @@ -756,8 +761,9 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
756 } 761 }
757 }, 762 },
758 timeWindowUpdated: (subscription, timeWindowConfig) => { 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,6 +71,8 @@
71 /*************************************************************************************************** 71 /***************************************************************************************************
72 * Zone JS is required by default for Angular itself. 72 * Zone JS is required by default for Angular itself.
73 */ 73 */
  74 +
  75 +import './zone-flags';
74 import 'zone.js/dist/zone'; // Included with Angular CLI. 76 import 'zone.js/dist/zone'; // Included with Angular CLI.
75 import 'core-js/es/array'; 77 import 'core-js/es/array';
76 78
  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;