| /* |
| ****************************************************************************** |
| * Copyright © 2018 PTA GmbH. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| ****************************************************************************** |
| */ |
| import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; |
| import { Router } from '@angular/router'; |
| import { MessageDefines, MessageService } from '../../services/message.service'; |
| import { AuthenticationService } from '../../services/authentication.service'; |
| import { SessionContext } from '../../common/session-context'; |
| |
| @Component({ |
| selector: 'app-logout', |
| templateUrl: './logout.component.html', |
| styleUrls: ['./logout.component.css'] |
| }) |
| export class LogoutPageComponent implements OnInit { |
| |
| @ViewChild('yesBtn') button: ElementRef; |
| loggedOut = false; |
| |
| ngOnInit() { |
| this.button.nativeElement.focus(); |
| } |
| |
| |
| constructor( |
| private msgService: MessageService, |
| private authService: AuthenticationService, |
| private router: Router, |
| private sessionContext: SessionContext |
| ) { } |
| |
| logout() { |
| this.authService.logout().subscribe(res => { |
| this.msgService.loginLogoff$.emit(MessageDefines.MSG_LOG_OFF); |
| this.loggedOut = true; |
| this.router.navigate(['/loggedout']); |
| this.sessionContext.clearStorage(); |
| }, |
| error => { |
| console.log(error); |
| this.router.navigate(['/loggedout']); |
| } |
| ); |
| } |
| |
| goToOverview(): void { |
| this.router.navigate(['/overview']); |
| } |
| } |