From 9b8cf75c1a5ba5ba064ad70217e9221b1a127df1 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Thu, 21 Jan 2021 18:03:36 +0200 Subject: [PATCH] UI: Refactor dashboard page. Add ability to open dashboard state in separate dialog. --- ui-ngx/src/app/core/api/widget-api.models.ts | 2 + .../dashboard/dashboard-pages.module.ts | 2 - .../dashboard-pages.routing.module.ts | 2 +- .../add-widget-dialog.component.html | 0 .../add-widget-dialog.component.ts | 0 .../dashboard-page.component.html | 8 +- .../dashboard-page.component.scss | 0 .../dashboard-page.component.ts | 19 +++-- .../dashboard-page}/dashboard-page.models.ts | 1 + .../dashboard-settings-dialog.component.html | 0 .../dashboard-settings-dialog.component.scss | 0 .../dashboard-settings-dialog.component.ts | 0 .../dashboard-toolbar.component.html | 0 .../dashboard-toolbar.component.scss | 0 .../dashboard-toolbar.component.ts | 0 .../dashboard-widget-select.component.html | 0 .../dashboard-widget-select.component.scss | 0 .../dashboard-widget-select.component.ts | 0 .../edit-widget.component.html | 0 .../dashboard-page}/edit-widget.component.ts | 0 .../layout/dashboard-layout.component.html | 0 .../layout/dashboard-layout.component.scss | 0 .../layout/dashboard-layout.component.ts | 4 +- .../dashboard-page}/layout/layout.models.ts | 0 ...ge-dashboard-layouts-dialog.component.html | 0 ...nage-dashboard-layouts-dialog.component.ts | 2 +- .../dashboard-state-dialog.component.html | 0 .../dashboard-state-dialog.component.ts | 2 +- .../default-state-controller.component.html | 0 .../default-state-controller.component.scss | 0 .../default-state-controller.component.ts | 2 +- .../entity-state-controller.component.html | 0 .../entity-state-controller.component.scss | 0 .../entity-state-controller.component.ts | 2 +- ...age-dashboard-states-dialog.component.html | 0 ...ashboard-states-dialog.component.models.ts | 0 ...age-dashboard-states-dialog.component.scss | 0 ...anage-dashboard-states-dialog.component.ts | 4 +- .../states/state-controller.component.ts | 8 +- .../states/state-controller.models.ts | 5 +- .../states/states-component.directive.ts | 16 +++- .../states/states-controller.module.ts | 4 +- .../states/states-controller.service.ts | 19 +++-- .../home/components/home-components.module.ts | 45 ++++++++++- .../widget-action-dialog.component.html | 35 ++++++++ .../action/widget-action-dialog.component.ts | 23 ++++++ .../dialog/embed-dashboard-dialog-token.ts | 22 ++++++ .../embed-dashboard-dialog.component.html | 40 ++++++++++ .../embed-dashboard-dialog.component.scss | 42 ++++++++++ .../embed-dashboard-dialog.component.ts | 79 +++++++++++++++++++ .../components/widget/widget.component.ts | 70 +++++++++++++++- .../home/pages/api-usage/api-usage.module.ts | 2 - .../pages/customer/customer-routing.module.ts | 2 +- .../dashboard/dashboard-routing.module.ts | 2 +- .../home/pages/dashboard/dashboard.module.ts | 27 +------ ui-ngx/src/app/shared/models/widget.models.ts | 5 ++ .../assets/locale/locale.constant-en_US.json | 6 ++ 57 files changed, 424 insertions(+), 78 deletions(-) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/add-widget-dialog.component.html (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/add-widget-dialog.component.ts (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/dashboard-page.component.html (97%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/dashboard-page.component.scss (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/dashboard-page.component.ts (98%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/dashboard-page.models.ts (99%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/dashboard-settings-dialog.component.html (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/dashboard-settings-dialog.component.scss (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/dashboard-settings-dialog.component.ts (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/dashboard-toolbar.component.html (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/dashboard-toolbar.component.scss (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/dashboard-toolbar.component.ts (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/dashboard-widget-select.component.html (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/dashboard-widget-select.component.scss (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/dashboard-widget-select.component.ts (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/edit-widget.component.html (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/edit-widget.component.ts (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/layout/dashboard-layout.component.html (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/layout/dashboard-layout.component.scss (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/layout/dashboard-layout.component.ts (98%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/layout/layout.models.ts (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/layout/manage-dashboard-layouts-dialog.component.html (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/layout/manage-dashboard-layouts-dialog.component.ts (98%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/states/dashboard-state-dialog.component.html (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/states/dashboard-state-dialog.component.ts (97%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/states/default-state-controller.component.html (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/states/default-state-controller.component.scss (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/states/default-state-controller.component.ts (98%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/states/entity-state-controller.component.html (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/states/entity-state-controller.component.scss (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/states/entity-state-controller.component.ts (98%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/states/manage-dashboard-states-dialog.component.html (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/states/manage-dashboard-states-dialog.component.models.ts (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/states/manage-dashboard-states-dialog.component.scss (100%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/states/manage-dashboard-states-dialog.component.ts (97%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/states/state-controller.component.ts (95%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/states/state-controller.models.ts (87%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/states/states-component.directive.ts (82%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/states/states-controller.module.ts (88%) rename ui-ngx/src/app/modules/home/{pages/dashboard => components/dashboard-page}/states/states-controller.service.ts (74%) create mode 100644 ui-ngx/src/app/modules/home/components/widget/dialog/embed-dashboard-dialog-token.ts create mode 100644 ui-ngx/src/app/modules/home/components/widget/dialog/embed-dashboard-dialog.component.html create mode 100644 ui-ngx/src/app/modules/home/components/widget/dialog/embed-dashboard-dialog.component.scss create mode 100644 ui-ngx/src/app/modules/home/components/widget/dialog/embed-dashboard-dialog.component.ts diff --git a/ui-ngx/src/app/core/api/widget-api.models.ts b/ui-ngx/src/app/core/api/widget-api.models.ts index b26abdb320..1579ae8d1e 100644 --- a/ui-ngx/src/app/core/api/widget-api.models.ts +++ b/ui-ngx/src/app/core/api/widget-api.models.ts @@ -53,6 +53,7 @@ import { EntityDataService } from '@core/api/entity-data.service'; import { PageData } from '@shared/models/page/page-data'; import { TranslateService } from '@ngx-translate/core'; import { AlarmDataService } from '@core/api/alarm-data.service'; +import { IDashboardController } from '@home/components/dashboard-page/dashboard-page.models'; export interface TimewindowFunctions { onUpdateTimewindow: (startTimeMs: number, endTimeMs: number, interval?: number) => void; @@ -137,6 +138,7 @@ export interface StateParams { export type StateControllerHolder = () => IStateController; export interface IStateController { + dashboardCtrl: IDashboardController; getStateParams(): StateParams; getStateParamsByStateId(stateId: string): StateParams; openState(id: string, params?: StateParams, openRightLayout?: boolean): void; diff --git a/ui-ngx/src/app/modules/dashboard/dashboard-pages.module.ts b/ui-ngx/src/app/modules/dashboard/dashboard-pages.module.ts index f09c80fea4..b7e11982f9 100644 --- a/ui-ngx/src/app/modules/dashboard/dashboard-pages.module.ts +++ b/ui-ngx/src/app/modules/dashboard/dashboard-pages.module.ts @@ -19,7 +19,6 @@ import { CommonModule } from '@angular/common'; import { SharedModule } from '@shared/shared.module'; import { HomeComponentsModule } from '@modules/home/components/home-components.module'; import { HomeDialogsModule } from '@app/modules/home/dialogs/home-dialogs.module'; -import { DashboardModule } from '@home/pages/dashboard/dashboard.module'; import { DashboardPagesRoutingModule } from './dashboard-pages.routing.module'; @NgModule({ @@ -28,7 +27,6 @@ import { DashboardPagesRoutingModule } from './dashboard-pages.routing.module'; SharedModule, HomeComponentsModule, HomeDialogsModule, - DashboardModule, DashboardPagesRoutingModule ] }) diff --git a/ui-ngx/src/app/modules/dashboard/dashboard-pages.routing.module.ts b/ui-ngx/src/app/modules/dashboard/dashboard-pages.routing.module.ts index 1354f9ef2b..2d500f1da4 100644 --- a/ui-ngx/src/app/modules/dashboard/dashboard-pages.routing.module.ts +++ b/ui-ngx/src/app/modules/dashboard/dashboard-pages.routing.module.ts @@ -18,7 +18,7 @@ import { Injectable, NgModule } from '@angular/core'; import { ActivatedRouteSnapshot, Resolve, RouterModule, Routes } from '@angular/router'; import { Authority } from '@shared/models/authority.enum'; -import { DashboardPageComponent } from '@home/pages/dashboard/dashboard-page.component'; +import { DashboardPageComponent } from '@home/components/dashboard-page/dashboard-page.component'; import { Dashboard } from '@app/shared/models/dashboard.models'; import { DashboardService } from '@core/http/dashboard.service'; import { DashboardUtilsService } from '@core/services/dashboard-utils.service'; diff --git a/ui-ngx/src/app/modules/home/pages/dashboard/add-widget-dialog.component.html b/ui-ngx/src/app/modules/home/components/dashboard-page/add-widget-dialog.component.html similarity index 100% rename from ui-ngx/src/app/modules/home/pages/dashboard/add-widget-dialog.component.html rename to ui-ngx/src/app/modules/home/components/dashboard-page/add-widget-dialog.component.html diff --git a/ui-ngx/src/app/modules/home/pages/dashboard/add-widget-dialog.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/add-widget-dialog.component.ts similarity index 100% rename from ui-ngx/src/app/modules/home/pages/dashboard/add-widget-dialog.component.ts rename to ui-ngx/src/app/modules/home/components/dashboard-page/add-widget-dialog.component.ts diff --git a/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-page.component.html b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.html similarity index 97% rename from ui-ngx/src/app/modules/home/pages/dashboard/dashboard-page.component.html rename to ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.html index 5aae43bec6..97f5071955 100644 --- a/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-page.component.html +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.html @@ -21,7 +21,7 @@
-
@@ -52,6 +52,7 @@ [dashboardId]="dashboard.id ? dashboard.id.id : ''" [isMobile]="isMobile" [state]="dashboardCtx.state" + [currentState]="currentState" [states]="dashboardConfiguration.states">
@@ -183,11 +184,12 @@