66 lines
1.9 KiB
TypeScript
66 lines
1.9 KiB
TypeScript
import { Component } from '@angular/core';
|
|
import { MatDialog } from '@angular/material/dialog';
|
|
import { UserGroupDirImportComponent } from '../components/user-group-dir-import/user-group-dir-import.component';
|
|
import { GroupDirImportComponent } from '../components/group-dir-import/group-dir-import.component';
|
|
import { AuthenticationService, IsLogedIn } from '../services/authentication.service';
|
|
import { LoginComponent } from '../login/login.component';
|
|
import { RouterModule } from '@angular/router';
|
|
import { CommonModule } from '@angular/common';
|
|
import { ColorModeBttnComponent } from '../components/common/color-mode-bttn/color-mode-bttn.component';
|
|
|
|
@Component({
|
|
standalone: true,
|
|
imports: [RouterModule, CommonModule, ColorModeBttnComponent],
|
|
selector: 'app-nav-menu',
|
|
templateUrl: './nav-menu.component.html',
|
|
styleUrls: ['./nav-menu.component.css']
|
|
})
|
|
export class NavMenuComponent {
|
|
isLogedIn() {
|
|
return IsLogedIn();
|
|
}
|
|
isExpanded = false;
|
|
|
|
constructor(public dialog: MatDialog, private authService: AuthenticationService) {
|
|
this.authService.isAuthenticated().then(console.log).catch(console.log)
|
|
}
|
|
|
|
get isDarkTheme(): boolean {
|
|
return true;
|
|
}
|
|
|
|
collapse() {
|
|
this.isExpanded = false;
|
|
}
|
|
|
|
toggle() {
|
|
this.isExpanded = !this.isExpanded;
|
|
}
|
|
|
|
importUser() {
|
|
const dialogRef = this.dialog.open(UserGroupDirImportComponent, {
|
|
width: "50vw"
|
|
});
|
|
}
|
|
importGroup() {
|
|
const dialogRef = this.dialog.open(GroupDirImportComponent, {
|
|
width: "50vw"
|
|
});
|
|
}
|
|
|
|
async auth() {
|
|
const isLoggedIn = await this.authService.isAuthenticated();
|
|
if (isLoggedIn)
|
|
this.authService.logout().subscribe();
|
|
else {
|
|
const dialogRef = this.dialog.open(LoginComponent, {
|
|
width: "35vw",
|
|
data: {
|
|
afterLogin: () => {
|
|
dialogRef.close();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
} |