From f7a3df27b8bc42b8320620476415ed5bd694c8b8 Mon Sep 17 00:00:00 2001 From: piotrpekala7 <31202938+piotrpekala7@users.noreply.github.com> Date: Thu, 6 May 2021 02:50:13 +0200 Subject: [PATCH] Logout action added --- .../default-layout.component.html | 4 ++++ .../default-layout/default-layout.component.ts | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/app/layouts/default-layout/default-layout.component.html b/src/app/layouts/default-layout/default-layout.component.html index f2c5559d..7efbf5e0 100644 --- a/src/app/layouts/default-layout/default-layout.component.html +++ b/src/app/layouts/default-layout/default-layout.component.html @@ -31,6 +31,10 @@ help Help + diff --git a/src/app/layouts/default-layout/default-layout.component.ts b/src/app/layouts/default-layout/default-layout.component.ts index bce4ab9e..4c5a9c00 100644 --- a/src/app/layouts/default-layout/default-layout.component.ts +++ b/src/app/layouts/default-layout/default-layout.component.ts @@ -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'])