mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-05-08 11:38:38 +00:00
add route
This commit is contained in:
parent
8c444059ad
commit
3bbd755d0a
@ -27,8 +27,7 @@
|
|||||||
<mat-icon>settings_applications</mat-icon>
|
<mat-icon>settings_applications</mat-icon>
|
||||||
<span>Template preferences</span>
|
<span>Template preferences</span>
|
||||||
</button>
|
</button>
|
||||||
<button mat-menu-item>
|
<button mat-menu-item (click)="goToImageManager()">
|
||||||
<!-- [routerLink]="['/controller', controller.id, 'image-manager']" -->
|
|
||||||
<mat-icon>collections</mat-icon>
|
<mat-icon>collections</mat-icon>
|
||||||
<span>Image manager</span>
|
<span>Image manager</span>
|
||||||
</button>
|
</button>
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
import { Component, HostListener, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
import { Component, HostListener, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||||
import { NavigationEnd } from '@angular/router';
|
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
|
||||||
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
|
|
||||||
import { ServerService } from '../../services/server.service';
|
|
||||||
import { ElectronService } from 'ngx-electron';
|
import { ElectronService } from 'ngx-electron';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { ProgressService } from '../../common/progress/progress.service';
|
import { ProgressService } from '../../common/progress/progress.service';
|
||||||
|
import { Server } from '../../models/server';
|
||||||
import { RecentlyOpenedProjectService } from '../../services/recentlyOpenedProject.service';
|
import { RecentlyOpenedProjectService } from '../../services/recentlyOpenedProject.service';
|
||||||
import { ServerManagementService } from '../../services/server-management.service';
|
import { ServerManagementService } from '../../services/server-management.service';
|
||||||
|
import { ServerService } from '../../services/server.service';
|
||||||
import { ToasterService } from '../../services/toaster.service';
|
import { ToasterService } from '../../services/toaster.service';
|
||||||
import { version } from './../../version';
|
import { version } from './../../version';
|
||||||
import { Server } from '../../models/server';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-default-layout',
|
selector: 'app-default-layout',
|
||||||
@ -39,8 +38,7 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
|
|||||||
private progressService: ProgressService,
|
private progressService: ProgressService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private serverService: ServerService,
|
private serverService: ServerService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute
|
||||||
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -74,21 +72,21 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
goToUserInfo() {
|
goToUserInfo() {
|
||||||
let serverId = this.router.url.split("/server/")[1].split("/")[0];
|
let serverId = this.router.url.split('/server/')[1].split('/')[0];
|
||||||
this.serverService.get(+serverId).then((server: Server) => {
|
this.serverService.get(+serverId).then((server: Server) => {
|
||||||
this.router.navigate(['/server', server.id, 'loggeduser']);
|
this.router.navigate(['/server', server.id, 'loggeduser']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
goToDocumentation() {
|
goToDocumentation() {
|
||||||
let serverId = this.router.url.split("/server/")[1].split("/")[0];
|
let serverId = this.router.url.split('/server/')[1].split('/')[0];
|
||||||
this.serverService.get(+serverId).then((server: Server) => {
|
this.serverService.get(+serverId).then((server: Server) => {
|
||||||
(window as any).open(`http://${server.host}:${server.port}/docs`);
|
(window as any).open(`http://${server.host}:${server.port}/docs`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
checkIfUserIsLoginPage() {
|
checkIfUserIsLoginPage() {
|
||||||
if (this.router.url.includes("login")) {
|
if (this.router.url.includes('login')) {
|
||||||
this.isLoginPage = true;
|
this.isLoginPage = true;
|
||||||
} else {
|
} else {
|
||||||
this.isLoginPage = false;
|
this.isLoginPage = false;
|
||||||
@ -96,10 +94,10 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
let serverId = this.router.url.split("/server/")[1].split("/")[0];
|
let serverId = this.router.url.split('/server/')[1].split('/')[0];
|
||||||
this.serverService.get(+serverId).then((server: Server) => {
|
this.serverService.get(+serverId).then((server: Server) => {
|
||||||
server.authToken = null;
|
server.authToken = null;
|
||||||
this.serverService.update(server).then(val => this.router.navigate(['/server', server.id, 'login']));
|
this.serverService.update(server).then((val) => this.router.navigate(['/server', server.id, 'login']));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,14 +114,22 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
goToPreferences() {
|
goToPreferences() {
|
||||||
|
let controllerId = this.router.url.split('/server/')[1].split('/')[0];
|
||||||
this.router
|
this.router
|
||||||
.navigate(['/controller', this.controller.id, 'preferences'])
|
.navigate(['/server', controllerId, 'preferences'])
|
||||||
.catch((error) => this.toasterService.error('Cannot navigate to the preferences'));
|
.catch((error) => this.toasterService.error('Cannot navigate to the preferences'));
|
||||||
}
|
}
|
||||||
|
|
||||||
goToSystemStatus() {
|
goToSystemStatus() {
|
||||||
|
let controllerId = this.router.url.split('/server/')[1].split('/')[0];
|
||||||
this.router
|
this.router
|
||||||
.navigate(['/controller', this.controller.id, 'systemstatus'])
|
.navigate(['/server', controllerId, 'systemstatus'])
|
||||||
|
.catch((error) => this.toasterService.error('Cannot navigate to the system status'));
|
||||||
|
}
|
||||||
|
goToImageManager() {
|
||||||
|
let controllerId = this.router.url.split('/server/')[1].split('/')[0];
|
||||||
|
this.router
|
||||||
|
.navigate(['/server', controllerId, 'image-manager'])
|
||||||
.catch((error) => this.toasterService.error('Cannot navigate to the system status'));
|
.catch((error) => this.toasterService.error('Cannot navigate to the system status'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +148,6 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.serverStatusSubscription.unsubscribe();
|
this.serverStatusSubscription.unsubscribe();
|
||||||
this.routeSubscription.unsubscribe();
|
this.routeSubscription.unsubscribe();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user