You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2020/08/11 21:23:04 UTC

[incubator-streampipes] 03/03: [STREAMPIPES-193] Add router to standalone dashboard

This is an automated email from the ASF dual-hosted git repository.

riemer pushed a commit to branch STREAMPIPES-193
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git

commit 4f8ec903f8ac6febd45d8f3553563e0df37ed875
Author: Dominik Riemer <ri...@fzi.de>
AuthorDate: Tue Aug 11 23:22:37 2020 +0200

    [STREAMPIPES-193] Add router to standalone dashboard
---
 ui/src/app/app-routing.module.ts                      |  2 ++
 .../overview/dashboard-overview.component.ts          | 12 +++++++-----
 .../standalone/standalone-dashboard.component.ts      | 19 ++++++++++++-------
 ui/src/app/dashboard/dashboard.module.ts              | 10 ----------
 4 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/ui/src/app/app-routing.module.ts b/ui/src/app/app-routing.module.ts
index 15e4bcc..9aa0fe3 100644
--- a/ui/src/app/app-routing.module.ts
+++ b/ui/src/app/app-routing.module.ts
@@ -31,10 +31,12 @@ import {AppOverviewComponent} from "./app-overview/app-overview.component";
 import {AddComponent} from "./add/add.component";
 import {ConfigurationComponent} from "./configuration/configuration.component";
 import {PipelineDetailsComponent} from "./pipeline-details/pipeline-details.component";
+import {StandaloneDashboardComponent} from "./dashboard/components/standalone/standalone-dashboard.component";
 
 const routes: Routes = [
   { path: 'login', component: LoginComponent },
   { path: 'setup', component: SetupComponent },
+  { path: 'standalone/:dashboardId', component: StandaloneDashboardComponent },
   { path: '', component: StreampipesComponent, children: [
       { path: '', component: HomeComponent },
       { path: 'add', component: AddComponent },
diff --git a/ui/src/app/dashboard/components/overview/dashboard-overview.component.ts b/ui/src/app/dashboard/components/overview/dashboard-overview.component.ts
index 3c47866..5158bc1 100644
--- a/ui/src/app/dashboard/components/overview/dashboard-overview.component.ts
+++ b/ui/src/app/dashboard/components/overview/dashboard-overview.component.ts
@@ -23,6 +23,7 @@ import {MatDialog} from "@angular/material/dialog";
 import {DashboardService} from "../../services/dashboard.service";
 import {EditDashboardDialogComponent} from "../../dialogs/edit-dashboard/edit-dashboard-dialog.component";
 import {Tuple2} from "../../../core-model/base/Tuple2";
+import {Router} from "@angular/router";
 
 @Component({
     selector: 'dashboard-overview',
@@ -38,9 +39,9 @@ export class DashboardOverviewComponent implements OnInit {
     dataSource = new MatTableDataSource<Dashboard>();
     displayedColumns: string[] = ['name', 'open', 'openWindow', 'settings', 'edit', 'delete'];
 
-    constructor(@Inject('$state') private $state: any,
-                private dashboardService: DashboardService,
-                public dialog: MatDialog) {
+    constructor(private dashboardService: DashboardService,
+                public dialog: MatDialog,
+                private Router: Router) {
 
     }
 
@@ -87,8 +88,9 @@ export class DashboardOverviewComponent implements OnInit {
     }
 
     openExternalDashboard(dashboard: Dashboard) {
-        let href = this.$state.href('standalone', {dashboardId: dashboard._id});
-        window.open(href, "_blank");
+        let href = this.Router.createUrlTree(['standalone', dashboard._id]);
+        // TODO fixes bug that hashing strategy is ignored by createUrlTree
+        window.open("#" + href.toString(), "_blank");
     }
 
 }
\ No newline at end of file
diff --git a/ui/src/app/dashboard/components/standalone/standalone-dashboard.component.ts b/ui/src/app/dashboard/components/standalone/standalone-dashboard.component.ts
index c162897..40c760b 100644
--- a/ui/src/app/dashboard/components/standalone/standalone-dashboard.component.ts
+++ b/ui/src/app/dashboard/components/standalone/standalone-dashboard.component.ts
@@ -19,6 +19,7 @@ import {Component, OnInit} from "@angular/core";
 import {Dashboard} from "../../models/dashboard.model";
 import {UIRouter} from "@uirouter/core";
 import {DashboardService} from "../../services/dashboard.service";
+import {ActivatedRoute} from "@angular/router";
 
 @Component({
     templateUrl: './standalone-dashboard.component.html',
@@ -29,16 +30,20 @@ export class StandaloneDashboardComponent implements OnInit {
     dashboard: Dashboard;
     dashboardReady: boolean = false;
 
-    constructor(private uiRouter: UIRouter,
+    constructor(private ActivatedRoute: ActivatedRoute,
                 private dashboardService: DashboardService) {
     }
 
     ngOnInit(): void {
-        let dashboardId = this.uiRouter.globals.params.dashboardId;
-        this.dashboardService.getDashboard(dashboardId).subscribe(dashboard => {
-            this.dashboard = dashboard;
-            this.dashboardReady = true;
-        })
+        this.ActivatedRoute.params.subscribe(params => {
+            if (params['dashboardId']) {
+                let dashboardId = params['dashboardId'];
+                console.log(dashboardId);
+                this.dashboardService.getDashboard(dashboardId).subscribe(dashboard => {
+                    this.dashboard = dashboard;
+                    this.dashboardReady = true;
+                })
+            }
+        });
     }
-
 }
\ No newline at end of file
diff --git a/ui/src/app/dashboard/dashboard.module.ts b/ui/src/app/dashboard/dashboard.module.ts
index 787a412..f4d2e32 100644
--- a/ui/src/app/dashboard/dashboard.module.ts
+++ b/ui/src/app/dashboard/dashboard.module.ts
@@ -107,11 +107,6 @@ const dashboardWidgets = [
         ResizeService,
         RefreshDashboardService,
         SemanticTypeUtilsService,
-        {
-            provide: 'RestApi',
-            useFactory: ($injector: any) => $injector.get('RestApi'),
-            deps: ['$injector'],
-        },
         ElementIconText,
         {
             provide: InjectableRxStompConfig,
@@ -122,11 +117,6 @@ const dashboardWidgets = [
             useFactory: rxStompServiceFactory,
             deps: [InjectableRxStompConfig]
         },
-        {
-            provide: '$state',
-            useFactory: ($injector: any) => $injector.get('$state'),
-            deps: ['$injector']
-        }
     ],
     exports: [
         DashboardComponent