From 9b76d785b1a25388d1986cdddb03b70108659bac Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Mon, 3 Aug 2020 12:41:36 +0300 Subject: [PATCH] UI: Fix unresolved alias processing --- ui-ngx/package-lock.json | 4 +- .../app/core/api/entity-data-subscription.ts | 4 +- .../src/app/core/api/entity-data.service.ts | 48 ++++++++++++------- .../src/app/core/api/widget-subscription.ts | 12 +++-- .../components/widget/lib/maps/schemes.ts | 4 +- 5 files changed, 43 insertions(+), 29 deletions(-) diff --git a/ui-ngx/package-lock.json b/ui-ngx/package-lock.json index 82d003e41e..0478e37ac8 100644 --- a/ui-ngx/package-lock.json +++ b/ui-ngx/package-lock.json @@ -8997,10 +8997,10 @@ "integrity": "sha512-4O3GWAYJaauMCILm07weko2rHA8a4kjn7+8Lg4s1d7SxwS/3IpkVD/GljbRrIJ1c1W/XGJ3GbuK7RyYZEJChhw==" }, "ngx-flowchart": { - "version": "git://github.com/thingsboard/ngx-flowchart.git#a4157b0eef2eb3646ef920447c7b06b39d54f87f", + "version": "git://github.com/thingsboard/ngx-flowchart.git#7a02f4748b5e7821a883c903107af5f20415d026", "from": "git://github.com/thingsboard/ngx-flowchart.git#master", "requires": { - "tslib": "^1.10.0" + "tslib": "^1.13.0" }, "dependencies": { "tslib": { diff --git a/ui-ngx/src/app/core/api/entity-data-subscription.ts b/ui-ngx/src/app/core/api/entity-data-subscription.ts index 401adea879..e9d7256520 100644 --- a/ui-ngx/src/app/core/api/entity-data-subscription.ts +++ b/ui-ngx/src/app/core/api/entity-data-subscription.ts @@ -74,6 +74,7 @@ export interface EntityDataSubscriptionOptions { export class EntityDataSubscription { + private entityDataSubscriptionOptions = this.listener.subscriptionOptions; private datasourceType: DatasourceType = this.entityDataSubscriptionOptions.datasourceType; private history: boolean; private realtime: boolean; @@ -103,8 +104,7 @@ export class EntityDataSubscription { private dataResolved = false; private started = false; - constructor(public entityDataSubscriptionOptions: EntityDataSubscriptionOptions, - private listener: EntityDataListener, + constructor(private listener: EntityDataListener, private telemetryService: TelemetryService, private utils: UtilsService) { this.initializeSubscription(); diff --git a/ui-ngx/src/app/core/api/entity-data.service.ts b/ui-ngx/src/app/core/api/entity-data.service.ts index 22f3bfcd15..a5ef7c2c02 100644 --- a/ui-ngx/src/app/core/api/entity-data.service.ts +++ b/ui-ngx/src/app/core/api/entity-data.service.ts @@ -17,7 +17,7 @@ import { DataSetHolder, Datasource, DatasourceType, widgetType } from '@shared/models/widget.models'; import { SubscriptionTimewindow } from '@shared/models/time/time.models'; import { EntityData, EntityDataPageLink, KeyFilter } from '@shared/models/query/query.models'; -import { PageData } from '@shared/models/page/page-data'; +import { emptyPageData, PageData } from '@shared/models/page/page-data'; import { Injectable } from '@angular/core'; import { TelemetryWebsocketService } from '@core/ws/telemetry-websocket.service'; import { UtilsService } from '@core/services/utils.service'; @@ -41,6 +41,7 @@ export interface EntityDataListener { initialPageDataChanged?: (nextPageData: PageData) => void; updateRealtimeSubscription?: () => SubscriptionTimewindow; setRealtimeSubscription?: (subscriptionTimewindow: SubscriptionTimewindow) => void; + subscriptionOptions?: EntityDataSubscriptionOptions; subscription?: EntityDataSubscription; } @@ -61,19 +62,24 @@ export class EntityDataService { public prepareSubscription(listener: EntityDataListener): Observable { const datasource = listener.configDatasource; + listener.subscriptionOptions = this.createSubscriptionOptions( + datasource, + listener.subscriptionType, + datasource.pageLink, + datasource.keyFilters, + null, + false); if (datasource.type === DatasourceType.entity && (!datasource.entityFilter || !datasource.pageLink)) { return of(null); } - listener.subscription = this.createSubscription(listener, - datasource.pageLink, datasource.keyFilters, null, - false); + listener.subscription = new EntityDataSubscription(listener, this.telemetryService, this.utils); return listener.subscription.subscribe(); } public startSubscription(listener: EntityDataListener) { if (listener.subscription) { if (listener.subscriptionType === widgetType.timeseries) { - listener.subscription.entityDataSubscriptionOptions.subscriptionTimewindow = deepClone(listener.subscriptionTimewindow); + listener.subscriptionOptions.subscriptionTimewindow = deepClone(listener.subscriptionTimewindow); } listener.subscription.start(); } @@ -83,13 +89,21 @@ export class EntityDataService { pageLink: EntityDataPageLink, keyFilters: KeyFilter[]): Observable { const datasource = listener.configDatasource; + listener.subscriptionOptions = this.createSubscriptionOptions( + datasource, + listener.subscriptionType, + pageLink, + datasource.keyFilters, + keyFilters, + true); if (datasource.type === DatasourceType.entity && (!datasource.entityFilter || !pageLink)) { + listener.dataLoaded(emptyPageData(), [], + listener.configDatasourceIndex, listener.subscriptionOptions.pageLink); return of(null); } - listener.subscription = this.createSubscription(listener, - pageLink, datasource.keyFilters, keyFilters,true); + listener.subscription = new EntityDataSubscription(listener, this.telemetryService, this.utils); if (listener.subscriptionType === widgetType.timeseries) { - listener.subscription.entityDataSubscriptionOptions.subscriptionTimewindow = deepClone(listener.subscriptionTimewindow); + listener.subscriptionOptions.subscriptionTimewindow = deepClone(listener.subscriptionTimewindow); } return listener.subscription.subscribe(); } @@ -100,12 +114,12 @@ export class EntityDataService { } } - private createSubscription(listener: EntityDataListener, - pageLink: EntityDataPageLink, - keyFilters: KeyFilter[], - additionalKeyFilters: KeyFilter[], - isPaginatedDataSubscription: boolean): EntityDataSubscription { - const datasource = listener.configDatasource; + private createSubscriptionOptions(datasource: Datasource, + subscriptionType: widgetType, + pageLink: EntityDataPageLink, + keyFilters: KeyFilter[], + additionalKeyFilters: KeyFilter[], + isPaginatedDataSubscription: boolean): EntityDataSubscriptionOptions { const subscriptionDataKeys: Array = []; datasource.dataKeys.forEach((dataKey) => { const subscriptionDataKey: SubscriptionDataKey = { @@ -119,7 +133,7 @@ export class EntityDataService { const entityDataSubscriptionOptions: EntityDataSubscriptionOptions = { datasourceType: datasource.type, dataKeys: subscriptionDataKeys, - type: listener.subscriptionType + type: subscriptionType }; if (entityDataSubscriptionOptions.datasourceType === DatasourceType.entity) { entityDataSubscriptionOptions.entityFilter = datasource.entityFilter; @@ -128,8 +142,6 @@ export class EntityDataService { entityDataSubscriptionOptions.additionalKeyFilters = additionalKeyFilters; } entityDataSubscriptionOptions.isPaginatedDataSubscription = isPaginatedDataSubscription; - return new EntityDataSubscription(entityDataSubscriptionOptions, - listener, this.telemetryService, this.utils); + return entityDataSubscriptionOptions; } - } diff --git a/ui-ngx/src/app/core/api/widget-subscription.ts b/ui-ngx/src/app/core/api/widget-subscription.ts index 47ea205db6..d664e06a5e 100644 --- a/ui-ngx/src/app/core/api/widget-subscription.ts +++ b/ui-ngx/src/app/core/api/widget-subscription.ts @@ -735,8 +735,12 @@ export class WidgetSubscription implements IWidgetSubscription { if (this.type === widgetType.alarm) { this.updateAlarmDataSubscription(); } else { - this.notifyDataLoading(); - this.dataSubscribe(); + if (this.hasDataPageLink) { + this.updateDataSubscriptions(); + } else { + this.notifyDataLoading(); + this.dataSubscribe(); + } } } } @@ -1017,8 +1021,8 @@ export class WidgetSubscription implements IWidgetSubscription { for (let datasourceIndex = 0; datasourceIndex < this.entityDataListeners.length; datasourceIndex++) { const entityDataListener = this.entityDataListeners[datasourceIndex]; if (entityDataListener) { - const pageLink = entityDataListener.subscription.entityDataSubscriptionOptions.pageLink; - const keyFilters = entityDataListener.subscription.entityDataSubscriptionOptions.additionalKeyFilters; + const pageLink = entityDataListener.subscriptionOptions.pageLink; + const keyFilters = entityDataListener.subscriptionOptions.additionalKeyFilters; this.subscribeForPaginatedData(datasourceIndex, pageLink, keyFilters); } } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/schemes.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/schemes.ts index 73445707bf..4adc5aacc1 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/schemes.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/schemes.ts @@ -14,8 +14,6 @@ /// limitations under the License. /// -import { DEFAULT_MAP_PAGE_SIZE } from '@home/components/widget/lib/maps/map-models'; - export const googleMapSettingsSchema = { schema: { @@ -247,7 +245,7 @@ export const commonMapSettingsSchema = mapPageSize: { title: 'Map page size load entities', type: 'number', - default: DEFAULT_MAP_PAGE_SIZE + default: 16384 }, defaultCenterPosition: { title: 'Default map center position (0,0)',