Skip to content
Permalink
5ca36ea8a5
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
43 lines (35 sloc) 1.02 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');
}
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() {
}
}