mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-03 03:26:42 +00:00
Logout action added
This commit is contained in:
parent
17acd161d8
commit
f7a3df27b8
@ -31,6 +31,10 @@
|
||||
<mat-icon>help</mat-icon>
|
||||
<span>Help</span>
|
||||
</button>
|
||||
<button mat-menu-item (click)="logout()">
|
||||
<mat-icon>highlight_off</mat-icon>
|
||||
<span>Logout</span>
|
||||
</button>
|
||||
</mat-menu>
|
||||
</mat-toolbar>
|
||||
</header>
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { Component, HostListener, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { NavigationEnd } from '@angular/router';
|
||||
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
|
||||
import { ServerService } from '../../services/server.service';
|
||||
import { ElectronService } from 'ngx-electron';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { ProgressService } from '../../common/progress/progress.service';
|
||||
@ -7,6 +9,7 @@ import { RecentlyOpenedProjectService } from '../../services/recentlyOpenedProje
|
||||
import { ServerManagementService } from '../../services/server-management.service';
|
||||
import { ToasterService } from '../../services/toaster.service';
|
||||
import { version } from './../../version';
|
||||
import { Server } from '../../models/server';
|
||||
|
||||
@Component({
|
||||
selector: 'app-default-layout',
|
||||
@ -31,7 +34,9 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
|
||||
private serverManagement: ServerManagementService,
|
||||
private toasterService: ToasterService,
|
||||
private progressService: ProgressService,
|
||||
private router: Router
|
||||
private router: Router,
|
||||
private route: ActivatedRoute,
|
||||
private serverService: ServerService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@ -57,6 +62,14 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
|
||||
this.shouldStopServersOnClosing = this.electronService.isElectronApp;
|
||||
}
|
||||
|
||||
logout() {
|
||||
let serverId = this.router.url.split("/server/")[1].split("/")[0];
|
||||
this.serverService.get(+serverId).then((server: Server) => {
|
||||
server.authToken = null;
|
||||
this.serverService.update(server).then(val => this.router.navigate(['/server', server.id, 'login']));
|
||||
});
|
||||
}
|
||||
|
||||
listProjects() {
|
||||
this.router
|
||||
.navigate(['/server', this.serverIdProjectList, 'projects'])
|
||||
|
Loading…
Reference in New Issue
Block a user