From ff1b991d2a56f6d65f23c62ad80db9fe1cd89d16 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sat, 23 Jul 2022 00:01:17 +0200 Subject: [PATCH] Add missing code --- .../default-layout.component.ts | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/app/layouts/default-layout/default-layout.component.ts b/src/app/layouts/default-layout/default-layout.component.ts index 9ab73899..d0940b74 100644 --- a/src/app/layouts/default-layout/default-layout.component.ts +++ b/src/app/layouts/default-layout/default-layout.component.ts @@ -25,11 +25,10 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy { controllerStatusSubscription: Subscription; shouldStopControllersOnClosing = true; - recentlyOpenedcontrollerId: string; recentlyOpenedProjectId: string; - controllerIdProjectList: string; + controllerId: string | undefined | null; constructor( private electronService: ElectronService, @@ -38,8 +37,15 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy { private toasterService: ToasterService, private progressService: ProgressService, public router: Router, + private route: ActivatedRoute, private controllerService: ControllerService - ) {} + ) { + this.router.events.subscribe((data) => { + if (data instanceof NavigationEnd) { + this.controllerId = this.route.children[0].snapshot.paramMap.get("controller_id"); + } + }); + } ngOnInit() { @@ -70,16 +76,8 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy { this.shouldStopControllersOnClosing = this.electronService.isElectronApp; } - goToUserInfo() { - let controllerId = this.router.url.split("/controller/")[1].split("/")[0]; - this.controllerService.get(+controllerId).then((controller:Controller ) => { - this.router.navigate(['/controller', controller.id, 'loggeduser']); - }); - } - goToDocumentation() { - let controllerId = this.router.url.split("/controller/")[1].split("/")[0]; - this.controllerService.get(+controllerId).then((controller:Controller ) => { + this.controllerService.get(+this.controllerId).then((controller: Controller) => { (window as any).open(`http://${controller.host}:${controller.port}/docs`); }); } @@ -93,8 +91,7 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy { } logout() { - let controllerId = this.router.url.split("/controller/")[1].split("/")[0]; - this.controllerService.get(+controllerId).then((controller:Controller ) => { + this.controllerService.get(+this.controllerId).then((controller: Controller) => { controller.authToken = null; this.controllerService.update(controller).then(val => this.router.navigate(['/controller', controller.id, 'login'])); });