dvbooking/admin/src/app/app.ts
2025-11-20 15:08:32 +01:00

65 lines
2.3 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>
`
},
{
menuText: 'Események',
targetUrl: '/events/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.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 7.5v11.25m-18 0A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75m-18 0v-7.5A2.25 2.25 0 0 1 5.25 9h13.5A2.25 2.25 0 0 1 21 11.25v7.5" />
</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()
}
}