Skip to content
Permalink
c23ef5d585
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
46 lines (38 sloc) 1.1 KB
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import {LoginService} from '../services/login.service';
@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.css']
})
export class HeaderComponent implements OnInit {
constructor(private router: Router, private login: LoginService) { }
resetAndClear() {
this.router.navigateByUrl('#');
localStorage.clear();
}
resetGenerator() {
this.resetAndRedirect('/generator-search');
}
resetGenAndVisualize() {
this.resetAndRedirect('/visualize-all');
}
isLoggedIn(): boolean {
return (localStorage.getItem('auth_token') !== null);
}
resetAndRedirect(url: string) {
this.login.getToken().then(() => {
this.router.navigateByUrl(url);
localStorage.removeItem('gen_id');
localStorage.removeItem('org_id');
localStorage.removeItem('gen_name');
localStorage.removeItem('data_type');
}, () => {
console.log('You need to log in');
this.router.navigateByUrl('#');
});
}
ngOnInit() {
}
}