37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import {
|
|
ChangeDetectionStrategy,
|
|
Component,
|
|
effect,
|
|
inject,
|
|
signal,
|
|
} from '@angular/core';
|
|
import { MatButtonModule } from '@angular/material/button';
|
|
import { RouterModule, RouterOutlet } from '@angular/router';
|
|
import { Authentication } from './services/authentication';
|
|
import { keycloakConfig } from './util/keycloak-config';
|
|
|
|
@Component({
|
|
selector: 'app-root',
|
|
imports: [RouterOutlet, MatButtonModule, RouterModule],
|
|
templateUrl: './app.html',
|
|
styleUrl: './app.scss',
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
})
|
|
export class App {
|
|
protected readonly title = signal('frontend');
|
|
protected readonly auth = inject(Authentication);
|
|
|
|
protected gotoProfile() {
|
|
window.location.href = `${keycloakConfig.url}/realms/${keycloakConfig.realm}/account`;
|
|
}
|
|
|
|
constructor() {
|
|
effect(() => {
|
|
const loggedIn = this.auth.loggedIn();
|
|
if (!loggedIn) {
|
|
this.auth.login(window.location.pathname ?? undefined);
|
|
}
|
|
});
|
|
}
|
|
}
|