55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
import { Component, inject, signal } from '@angular/core';
|
|
import { Router, RouterOutlet } from '@angular/router';
|
|
import { AuthService } from './auth/auth.service';
|
|
import { AdminLayoutRs1 } from '../../projects/rschneider/ng-daisyui/src/lib/layout';
|
|
import { Menu, MenuItem } from './components/menu/menu';
|
|
@Component({
|
|
selector: 'app-root',
|
|
|
|
imports: [RouterOutlet, AdminLayoutRs1, Menu],
|
|
templateUrl: './app.html',
|
|
styleUrl: './app.css',
|
|
})
|
|
export class App {
|
|
protected readonly title = signal('admin');
|
|
protected menuConfig: MenuItem[] = [
|
|
|
|
];
|
|
protected currentUserRoles: string[] = ['admin'];
|
|
protected menuTitle: string | undefined = 'Menü';
|
|
|
|
|
|
constructor(private authService: AuthService, private router: Router) {
|
|
this.menuConfig = [
|
|
{
|
|
menuText: 'Esemény típusok',
|
|
targetUrl: '/event-type/table',
|
|
svgIcon: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M6.429 9.75 2.25 12l4.179 2.25m0-4.5 5.571 3 5.571-3m-11.142 0L2.25 7.5 12 2.25l9.75 5.25-4.179 2.25m0 0L21.75 12l-4.179 2.25m0 0 4.179 2.25L12 21.75 2.25 16.5l4.179-2.25m11.142 0-5.571 3-5.571-3" />
|
|
</svg>
|
|
`
|
|
}
|
|
]
|
|
}
|
|
|
|
logout(): void {
|
|
// With the interceptor fixed, this is now the correct and robust way.
|
|
// The error from a failed server logout will propagate here.
|
|
this.authService.serverSideLogout().subscribe({
|
|
next: () => {
|
|
console.log('Server-side logout successful.');
|
|
this.authService.clientSideLogout();
|
|
},
|
|
error: (err) => {
|
|
console.error('Server-side logout failed, logging out client-side anyway.', err);
|
|
this.authService.clientSideLogout();
|
|
},
|
|
});
|
|
}
|
|
|
|
loggedIn(){
|
|
return this.authService.isLoggedIn()
|
|
}
|
|
|
|
}
|