This repository has been archived on 2023-08-16. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
FoodLoop-Web/src/app/layouts/full-layout.component.ts

48 lines
1.1 KiB
TypeScript
Raw Normal View History

import { Component, OnInit } from '@angular/core';
2017-06-05 18:47:34 +01:00
import { ApiService } from '../providers/api-service';
import { Router } from '@angular/router';
@Component({
selector: 'app-dashboard',
2017-06-05 18:47:34 +01:00
templateUrl: './full-layout.component.html',
})
export class FullLayoutComponent implements OnInit {
2017-09-19 11:10:56 +01:00
public displayName: string;
2017-09-19 17:22:19 +01:00
public accountType: any;
2017-09-19 11:10:56 +01:00
public disabled = false;
public status: {isopen: boolean} = {isopen: false};
2017-06-05 18:47:34 +01:00
constructor(
private api: ApiService,
private router: Router,
) {}
public toggled(open: boolean): void {
console.log('Dropdown is now: ', open);
}
public toggleDropdown($event: MouseEvent): void {
$event.preventDefault();
$event.stopPropagation();
this.status.isopen = !this.status.isopen;
}
// getDisplayName function from api didnt work
ngOnInit(): void {
this.displayName = localStorage.getItem('displayname') || 'User';
2017-09-19 17:22:19 +01:00
this.accountType = localStorage.getItem('usertype');
}
userLogout() {
console.log('logout clicked');
this.api
2017-08-15 13:51:02 +01:00
.logout()
.subscribe(
result => {
localStorage.clear();
this.router.navigate(['/login']);
}
2017-08-15 13:51:02 +01:00
);
2017-06-05 18:47:34 +01:00
}
}