Logout action added

This commit is contained in:
piotrpekala7 2021-05-06 02:50:13 +02:00
parent 17acd161d8
commit f7a3df27b8
2 changed files with 19 additions and 2 deletions

View File

@ -31,6 +31,10 @@
<mat-icon>help</mat-icon> <mat-icon>help</mat-icon>
<span>Help</span> <span>Help</span>
</button> </button>
<button mat-menu-item (click)="logout()">
<mat-icon>highlight_off</mat-icon>
<span>Logout</span>
</button>
</mat-menu> </mat-menu>
</mat-toolbar> </mat-toolbar>
</header> </header>

View File

@ -1,5 +1,7 @@
import { Component, HostListener, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core'; 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 { 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';
@ -7,6 +9,7 @@ import { RecentlyOpenedProjectService } from '../../services/recentlyOpenedProje
import { ServerManagementService } from '../../services/server-management.service'; import { ServerManagementService } from '../../services/server-management.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',
@ -31,7 +34,9 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
private serverManagement: ServerManagementService, private serverManagement: ServerManagementService,
private toasterService: ToasterService, private toasterService: ToasterService,
private progressService: ProgressService, private progressService: ProgressService,
private router: Router private router: Router,
private route: ActivatedRoute,
private serverService: ServerService
) {} ) {}
ngOnInit() { ngOnInit() {
@ -57,6 +62,14 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
this.shouldStopServersOnClosing = this.electronService.isElectronApp; 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() { listProjects() {
this.router this.router
.navigate(['/server', this.serverIdProjectList, 'projects']) .navigate(['/server', this.serverIdProjectList, 'projects'])