Merge remote-tracking branch 'origin/dev' into topic-colored-chips

This commit is contained in:
2026-07-03 12:31:34 +02:00
158 changed files with 8743 additions and 3054 deletions
@@ -0,0 +1,20 @@
<div class="content">
<div class="account-profile-information">
<div class="personal-information">
<span class="name">{{ accountProfile().name }}</span>
<span class="mail">{{ accountProfile().email }}</span>
</div>
<span class="organization">{{ accountProfile().organization_name }}</span>
<mat-chip-set>
@for (role of roles; track $index) {
<mat-chip class="role-chip">{{ role | role }}</mat-chip>
}
</mat-chip-set>
</div>
</div>
<mat-divider />
<mat-tab-group>
<mat-tab label="Einstellungen"></mat-tab>
</mat-tab-group>
@@ -0,0 +1,44 @@
.content {
max-width: 100%;
}
.account-profile-information {
display: flex;
flex-direction: column;
gap: 0.5rem;
justify-content: center;
align-items: center;
padding: 1rem;
}
.personal-information {
display: flex;
flex-direction: column;
align-items: center;
}
.role-chip {
font-size: 10px;
font-weight: 600;
color: var(--sg-text-muted);
background: var(--sg-surface-muted);
border-radius: var(--sg-radius-sm);
}
.name {
font-size: 16px;
font-weight: 600;
color: var(--sg-text-primary);
}
.mail {
font-size: 12px;
font-weight: 600;
color: var(--sg-text-muted);
}
.organization {
font-size: 12px;
font-weight: 600;
color: var(--sg-text-muted);
}
@@ -0,0 +1,24 @@
import { Component, effect, input } from '@angular/core';
import { AccountProfile, UserRole } from '../../api';
import { RolePipe } from '../../shared/pipes/role.pipe';
import { MatChipsModule } from '@angular/material/chips';
import { MatTabsModule } from '@angular/material/tabs';
import { MatDividerModule } from '@angular/material/divider';
@Component({
selector: 'app-account',
imports: [RolePipe, MatChipsModule, MatTabsModule, MatDividerModule],
templateUrl: './account.component.html',
styleUrl: './account.component.scss',
})
export class AccountComponent {
readonly accountProfile = input.required<AccountProfile>();
roles: UserRole[] = [];
constructor() {
effect(() => {
this.roles = [this.accountProfile().role];
});
}
}
@@ -0,0 +1,67 @@
<h2 mat-dialog-title>
{{ data.mode === 'create' ? 'Account erstellen' : 'Account bearbeiten' }}
</h2>
<mat-dialog-content>
<form class="account-form" [formGroup]="form" (ngSubmit)="submit()">
<mat-form-field appearance="outline">
<mat-label>E-Mail</mat-label>
<input matInput type="email" formControlName="email" />
@if (form.controls.email.hasError('required')) {
<mat-error>E-Mail ist erforderlich.</mat-error>
} @else if (form.controls.email.hasError('email')) {
<mat-error>Bitte gültige E-Mail eingeben.</mat-error>
}
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Name</mat-label>
<input matInput formControlName="name" />
@if (form.controls.name.hasError('required')) {
<mat-error>Name ist erforderlich.</mat-error>
}
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Rolle</mat-label>
<mat-select formControlName="role">
@for (role of data.roles; track role) {
<mat-option [value]="role">{{ role }}</mat-option>
}
</mat-select>
</mat-form-field>
@if (data.canSelectOrganization) {
<mat-form-field appearance="outline">
<mat-label>Organisation</mat-label>
<mat-select formControlName="organizationId">
@for (organization of data.organizations; track organization.id) {
<mat-option [value]="organization.id">
{{ organization.name }}
</mat-option>
}
</mat-select>
</mat-form-field>
}
<mat-form-field appearance="outline">
<mat-label>
{{ data.mode === 'create' ? 'Initiales Passwort' : 'Neues Passwort' }}
</mat-label>
<input matInput type="password" formControlName="password" />
@if (form.controls.password.hasError('required')) {
<mat-error>Passwort ist erforderlich.</mat-error>
} @else if (form.controls.password.hasError('minlength')) {
<mat-error>Mindestens 8 Zeichen.</mat-error>
}
</mat-form-field>
</form>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button mat-button type="button" (click)="close()">Abbrechen</button>
<button mat-flat-button color="primary" type="button" (click)="submit()">
<mat-icon>save</mat-icon>
Speichern
</button>
</mat-dialog-actions>
@@ -0,0 +1,22 @@
.account-form {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px 14px;
min-width: min(680px, calc(100vw - 64px));
padding-top: 4px;
}
.account-form mat-form-field {
width: 100%;
}
mat-dialog-actions {
padding: 12px 24px 20px;
}
@media (max-width: 720px) {
.account-form {
grid-template-columns: 1fr;
min-width: 0;
}
}
@@ -0,0 +1,153 @@
import { CommonModule } from '@angular/common';
import { Component, inject } from '@angular/core';
import {
FormControl,
FormGroup,
ReactiveFormsModule,
Validators,
} from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import {
MAT_DIALOG_DATA,
MatDialogModule,
MatDialogRef,
} from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatSelectModule } from '@angular/material/select';
import type {
AccountPayload,
AccountProfile,
AccountRole,
CreateAccountPayload,
OrganizationProfile,
} from '../../shared/services/account-management.service';
export type AccountDialogMode = 'create' | 'edit';
export interface AccountDialogData {
mode: AccountDialogMode;
account?: AccountProfile;
organizations: OrganizationProfile[];
canSelectOrganization: boolean;
roles: AccountRole[];
}
export type AccountDialogResult =
| { mode: 'create'; payload: CreateAccountPayload }
| { mode: 'edit'; accountId: string; payload: AccountPayload };
@Component({
selector: 'app-account-dialog',
imports: [
CommonModule,
ReactiveFormsModule,
MatButtonModule,
MatDialogModule,
MatFormFieldModule,
MatIconModule,
MatInputModule,
MatSelectModule,
],
templateUrl: './account-dialog.component.html',
styleUrl: './account-dialog.component.scss',
standalone: true,
})
export class AccountDialogComponent {
private readonly dialogRef =
inject<
MatDialogRef<AccountDialogComponent, AccountDialogResult | undefined>
>(MatDialogRef);
protected readonly data = inject<AccountDialogData>(MAT_DIALOG_DATA);
protected readonly form = new FormGroup({
email: new FormControl<string>(this.data.account?.email ?? '', [
Validators.required,
Validators.email,
]),
name: new FormControl<string>(this.data.account?.name ?? '', [
Validators.required,
]),
role: new FormControl<AccountRole>(this.data.account?.role ?? 'USER', [
Validators.required,
]),
organizationId: new FormControl<string>(
this.data.account?.organization_id ??
(this.data.organizations.length === 1
? this.data.organizations[0].id
: ''),
[Validators.required],
),
password: new FormControl<string>('', [
...(this.data.mode === 'create' ? [Validators.required] : []),
Validators.minLength(8),
]),
});
protected submit(): void {
if (this.form.invalid) {
this.form.markAllAsTouched();
return;
}
const value = this.form.getRawValue();
if (this.data.mode === 'create') {
this.dialogRef.close({
mode: 'create',
payload: {
email: value.email ?? '',
name: value.name ?? '',
role: value.role ?? 'USER',
organization_id: value.organizationId ?? '',
password: value.password ?? '',
},
});
return;
}
const account = this.data.account!;
const payload: AccountPayload = {};
const email = (value.email ?? '').trim();
const name = (value.name ?? '').trim();
const role = value.role ?? account.role;
const organizationId = value.organizationId ?? account.organization_id;
const password = value.password?.trim() ?? '';
if (email !== account.email) {
payload.email = email;
}
if (name !== account.name) {
payload.name = name;
}
if (role !== account.role) {
payload.role = role;
}
if (password) {
payload.password = password;
}
if (
this.data.canSelectOrganization &&
organizationId &&
organizationId !== account.organization_id
) {
payload.organization_id = organizationId;
}
this.dialogRef.close({
mode: 'edit',
accountId: account.id,
payload,
});
}
protected close(): void {
this.dialogRef.close(undefined);
}
}
@@ -0,0 +1,146 @@
<section class="accounts-page">
<header class="page-header">
<div>
<h1>Accounts</h1>
<p>Account-Zugänge verwalten, Rollen setzen und Impersonation starten.</p>
</div>
<button
mat-flat-button
color="primary"
type="button"
(click)="startCreate()">
<mat-icon>person_add</mat-icon>
Neuer Account
</button>
</header>
<form class="filters" [formGroup]="filterForm" (ngSubmit)="applyFilters()">
<mat-form-field appearance="outline">
<mat-label>Name oder E-Mail</mat-label>
<input matInput formControlName="search" />
</mat-form-field>
@if (credentialService.isEffectiveSuperAdmin()) {
<mat-form-field appearance="outline">
<mat-label>Organisation</mat-label>
<mat-select formControlName="organizationId">
<mat-option value="">Alle Organisationen</mat-option>
@for (organization of organizations; track organization.id) {
<mat-option [value]="organization.id">
{{ organization.name }}
</mat-option>
}
</mat-select>
</mat-form-field>
}
<div class="filter-actions">
<button mat-flat-button color="primary" type="submit">
<mat-icon>search</mat-icon>
Suchen
</button>
<button mat-button type="button" (click)="resetFilters()">
Zurücksetzen
</button>
</div>
</form>
<section class="table-panel">
<div class="table-header">
<strong>{{ total }} Accounts</strong>
@if (isLoading) {
<span>Wird geladen...</span>
}
</div>
<div class="table-wrap">
<table>
<thead>
<tr>
<th>Name</th>
<th>E-Mail</th>
<th>Organisation</th>
<th>Rolle</th>
<th>Status</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
@for (account of accounts; track account.id) {
<tr [class.deleted]="account.deleted">
<td>
<button
class="link-button"
type="button"
(click)="startEdit(account)">
{{ account.name }}
</button>
</td>
<td>{{ account.email }}</td>
<td>{{ account.organization_name }}</td>
<td>
<span class="role">{{ account.role | role }}</span>
</td>
<td>
<span class="status" [class.status--deleted]="account.deleted">
{{ account.deleted ? 'deleted' : 'active' }}
</span>
</td>
<td>
<div class="row-actions">
<button
mat-icon-button
type="button"
aria-label="Bearbeiten"
(click)="startEdit(account)">
<mat-icon>edit</mat-icon>
</button>
<button
mat-icon-button
type="button"
aria-label="Impersonate"
[disabled]="!canImpersonate(account)"
(click)="impersonate(account)">
<mat-icon>switch_account</mat-icon>
</button>
<button
mat-icon-button
type="button"
aria-label="Deaktivieren"
[disabled]="account.is_current || account.deleted"
(click)="deleteAccount(account)">
<mat-icon>delete</mat-icon>
</button>
</div>
</td>
</tr>
} @empty {
<tr>
<td colspan="6" class="empty">Keine Accounts gefunden.</td>
</tr>
}
</tbody>
</table>
</div>
<div class="pagination">
<button
mat-button
type="button"
[disabled]="!canPageBack"
(click)="loadAccounts(page - 1)">
<mat-icon>chevron_left</mat-icon>
Zurück
</button>
<span>Seite {{ page + 1 }}</span>
<button
mat-button
type="button"
[disabled]="!canPageForward"
(click)="loadAccounts(page + 1)">
Weiter
<mat-icon>chevron_right</mat-icon>
</button>
</div>
</section>
</section>
@@ -0,0 +1,147 @@
.accounts-page {
display: flex;
flex-direction: column;
gap: 20px;
padding: 24px;
}
.page-header,
.filters,
.table-header,
.pagination,
.row-actions {
display: flex;
align-items: center;
}
.page-header {
justify-content: space-between;
gap: 16px;
}
h1,
h2,
p {
margin: 0;
}
.page-header p {
color: #64748b;
margin-top: 6px;
}
.filters {
gap: 12px;
flex-wrap: wrap;
}
.filters mat-form-field {
width: min(320px, 100%);
}
.filter-actions {
display: flex;
gap: 8px;
margin-bottom: 22px;
}
.table-panel {
border: 1px solid #d7dde6;
border-radius: 8px;
background: #fff;
}
.table-header {
justify-content: space-between;
padding: 16px;
border-bottom: 1px solid #e5e7eb;
}
.table-header span {
color: #64748b;
}
.table-wrap {
overflow-x: auto;
}
table {
width: 100%;
border-collapse: collapse;
}
th,
td {
padding: 12px 16px;
text-align: left;
border-bottom: 1px solid #edf1f7;
white-space: nowrap;
}
th {
color: #475569;
font-weight: 700;
background: #f8fafc;
}
tr.deleted {
color: #94a3b8;
}
.link-button {
border: 0;
background: transparent;
color: #1d4ed8;
padding: 0;
font: inherit;
cursor: pointer;
}
.role,
.status {
display: inline-flex;
align-items: center;
min-height: 24px;
border-radius: 999px;
padding: 2px 10px;
background: #eef2ff;
color: #3730a3;
font-size: 12px;
font-weight: 700;
}
.status {
background: #dcfce7;
color: #166534;
}
.status--deleted {
background: #fee2e2;
color: #991b1b;
}
.row-actions {
gap: 4px;
}
.empty {
color: #64748b;
text-align: center;
}
.pagination {
justify-content: flex-end;
gap: 8px;
padding: 12px 16px;
}
@media (max-width: 640px) {
.accounts-page {
padding: 16px;
}
.page-header {
align-items: flex-start;
flex-direction: column;
}
}
@@ -0,0 +1,248 @@
import { CommonModule } from '@angular/common';
import { Component, OnInit, inject } from '@angular/core';
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatSelectModule } from '@angular/material/select';
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { Router } from '@angular/router';
import { finalize } from 'rxjs';
import { AccountManagementService } from '../../shared/services/account-management.service';
import type {
AccountProfile,
AccountRole,
OrganizationProfile,
} from '../../shared/services/account-management.service';
import { CredentialService } from '../../shared/services/credential.service';
import type {
AccountDialogComponent,
AccountDialogResult,
} from './account-dialog.component';
import { RolePipe } from '../../shared/pipes/role.pipe';
@Component({
selector: 'app-accounts',
imports: [
CommonModule,
ReactiveFormsModule,
MatButtonModule,
MatIconModule,
MatFormFieldModule,
MatInputModule,
MatSelectModule,
MatSnackBarModule,
MatDialogModule,
RolePipe,
],
templateUrl: './accounts.component.html',
styleUrl: './accounts.component.scss',
standalone: true,
})
export class AccountsComponent implements OnInit {
private readonly accountService = inject(AccountManagementService);
protected readonly credentialService = inject(CredentialService);
private readonly snackBar = inject(MatSnackBar);
private readonly router = inject(Router);
private readonly dialog = inject(MatDialog);
protected get availableRoles(): AccountRole[] {
if (this.credentialService.isEffectiveSuperAdmin()) {
return ['SUPER_ADMIN', 'ADMIN', 'MANAGER', 'USER'];
}
return ['MANAGER', 'USER'];
}
protected accounts: AccountProfile[] = [];
protected organizations: OrganizationProfile[] = [];
protected total = 0;
protected page = 0;
protected readonly pageSize = 10;
protected isLoading = false;
protected filterForm = new FormGroup({
search: new FormControl<string>(''),
organizationId: new FormControl<string>(''),
});
ngOnInit(): void {
this.loadOrganizations();
this.loadAccounts();
}
protected loadAccounts(page = this.page): void {
this.page = page;
this.isLoading = true;
this.accountService
.listAccounts({
page: this.page,
pageSize: this.pageSize,
search: this.filterForm.controls.search.value?.trim() || undefined,
organizationId:
this.filterForm.controls.organizationId.value || undefined,
})
.pipe(finalize(() => (this.isLoading = false)))
.subscribe({
next: (result) => {
this.accounts = result.items;
this.total = result.total;
},
error: () => {
this.snackBar.open('Accounts konnten nicht geladen werden.', 'OK', {
duration: 5000,
});
},
});
}
protected loadOrganizations(): void {
this.accountService.listOrganizations().subscribe({
next: (organizations) => {
this.organizations = organizations;
},
});
}
protected applyFilters(): void {
this.loadAccounts(0);
}
protected resetFilters(): void {
this.filterForm.reset({ search: '', organizationId: '' });
this.loadAccounts(0);
}
protected startCreate(): void {
this.openAccountDialog({ mode: 'create' });
}
protected startEdit(account: AccountProfile): void {
this.openAccountDialog({ mode: 'edit', account });
}
private saveDialogResult(result: AccountDialogResult): void {
const request =
result.mode === 'create'
? this.accountService.createAccount(result.payload)
: this.accountService.updateAccount(result.accountId, result.payload);
request.subscribe({
next: () => {
this.snackBar.open('Account wurde gespeichert.', 'OK', {
duration: 3000,
});
this.loadAccounts(0);
},
error: (error) => {
const message =
error.status === 409
? 'Diese E-Mail-Adresse wird bereits verwendet.'
: 'Account konnte nicht gespeichert werden.';
this.snackBar.open(message, 'OK', { duration: 5000 });
},
});
}
private openAccountDialog(data: {
mode: 'create' | 'edit';
account?: AccountProfile;
}): void {
import('./account-dialog.component').then(({ AccountDialogComponent }) => {
const dialogRef = this.dialog.open<
AccountDialogComponent,
{
mode: 'create' | 'edit';
account?: AccountProfile;
organizations: OrganizationProfile[];
canSelectOrganization: boolean;
roles: AccountRole[];
},
AccountDialogResult | undefined
>(AccountDialogComponent, {
width: '760px',
maxWidth: 'calc(100vw - 32px)',
data: {
...data,
organizations: this.organizations,
canSelectOrganization: this.credentialService.isEffectiveSuperAdmin(),
roles: this.availableRoles,
},
});
dialogRef.afterClosed().subscribe((result) => {
if (result) {
this.saveDialogResult(result);
}
});
});
}
protected deleteAccount(account: AccountProfile): void {
if (account.is_current) {
return;
}
this.accountService.deleteAccount(account.id).subscribe({
next: () => {
this.snackBar.open('Account wurde deaktiviert.', 'OK', {
duration: 3000,
});
this.loadAccounts();
},
error: () => {
this.snackBar.open('Account konnte nicht deaktiviert werden.', 'OK', {
duration: 5000,
});
},
});
}
protected impersonate(account: AccountProfile): void {
if (!this.canImpersonate(account)) {
return;
}
this.credentialService.impersonateAccount(account.id).subscribe({
next: () => {
this.snackBar.open(`Impersonation aktiv: ${account.name}`, 'OK', {
duration: 4000,
});
this.router.navigate(['/dashboard']);
},
error: () => {
this.snackBar.open(
'Impersonation konnte nicht gestartet werden.',
'OK',
{
duration: 5000,
},
);
},
});
}
protected get canPageBack(): boolean {
return this.page > 0;
}
protected get canPageForward(): boolean {
return (this.page + 1) * this.pageSize < this.total;
}
protected canImpersonate(account: AccountProfile): boolean {
if (account.is_current || account.deleted) {
return false;
}
if (this.credentialService.isEffectiveSuperAdmin()) {
return true;
}
return (
this.credentialService.isEffectiveAdmin() &&
(account.role === 'MANAGER' || account.role === 'USER')
);
}
}
@@ -1,68 +1,160 @@
<div class="container">
<form class="form" [formGroup]="loginForm">
<h3>Anmeldung</h3>
<p class="field">
Um auf den Dienst zuzugreifen, musst Du Deine Anmeldedaten eingeben.
</p>
<mat-form-field class="field">
<mat-label>Login</mat-label>
<input id="dp-login" matInput formControlName="login" />
@if (loginForm.controls.login.hasError('required')) {
<mat-error>Fehler: <b>Login</b> erforderlich.</mat-error>
} @else if (loginForm.controls.login.hasError('minlength')) {
<mat-error>Fehler: <b>Login</b> ist unvollständig.</mat-error>
}
</mat-form-field>
<mat-form-field class="field">
<mat-label>Passwort</mat-label>
<input
id="dp-password"
matInput
[type]="showPassword ? 'text' : 'password'"
formControlName="password" />
@if (showPassword) {
<mat-icon matSuffix (click)="showPassword = false">visibility</mat-icon>
} @else {
<mat-icon matSuffix (click)="showPassword = true"
>visibility_off</mat-icon
>
}
@if (loginForm.controls.password.hasError('required')) {
<mat-error>Fehler: <b>Passwort</b> erforderlich.</mat-error>
} @else if (loginForm.controls.password.hasError('minlength')) {
<mat-error>Fehler: <b>Passwort</b> ist unvollständig.</mat-error>
}
</mat-form-field>
<button
mat-raised-button
class="button"
(click)="login()"
[disabled]="!loginForm.valid || (credentialService.validating | async)">
Anmelden
</button>
<div class="field" style="text-align: center; margin-top: -10px">
<button mat-button type="button" routerLink="/register">
Noch kein Konto? <b>Registrieren</b>
</button>
<section class="login-page">
<div class="login-panel">
<div class="brand-block">
<span class="eyebrow">SmartGuide Account Portal</span>
<h1>Login</h1>
<p>
Melde Dich mit Deiner Organisation an. Nach den Zugangsdaten erhältst Du
einen einmaligen Code per E-Mail.
</p>
</div>
</form>
<p class="progress">
@if (credentialService.validating | async) {
<span><i>Anmeldung läuft,</i> bitte warte einen Moment.</span>
<div class="stepper" aria-label="Login-Fortschritt">
<div class="step" [class.step--active]="currentStep === 'credentials'">
<span>1</span>
<strong>Zugangsdaten</strong>
</div>
<div class="step-line"></div>
<div class="step" [class.step--active]="currentStep === 'otk'">
<span>2</span>
<strong>OTK-Code</strong>
</div>
</div>
@if (currentStep === 'credentials') {
<form
class="login-form"
[formGroup]="credentialsForm"
(ngSubmit)="requestOtk()">
<mat-form-field class="field" appearance="outline">
<mat-label>E-Mail-Adresse</mat-label>
<input
id="login-email"
matInput
type="email"
autocomplete="email"
formControlName="email" />
@if (credentialsForm.controls.email.hasError('required')) {
<mat-error>E-Mail-Adresse ist erforderlich.</mat-error>
} @else if (credentialsForm.controls.email.hasError('email')) {
<mat-error>Bitte gib eine gültige E-Mail-Adresse ein.</mat-error>
}
</mat-form-field>
<mat-form-field class="field" appearance="outline">
<mat-label>Passwort</mat-label>
<input
id="login-password"
matInput
[type]="showPassword ? 'text' : 'password'"
autocomplete="current-password"
formControlName="password" />
<button
mat-icon-button
matSuffix
type="button"
[attr.aria-label]="
showPassword ? 'Passwort verbergen' : 'Passwort anzeigen'
"
(click)="showPassword = !showPassword">
<mat-icon>{{
showPassword ? 'visibility' : 'visibility_off'
}}</mat-icon>
</button>
@if (credentialsForm.controls.password.hasError('required')) {
<mat-error>Passwort ist erforderlich.</mat-error>
} @else if (credentialsForm.controls.password.hasError('minlength')) {
<mat-error>Passwort muss mindestens 8 Zeichen haben.</mat-error>
}
</mat-form-field>
<button
mat-flat-button
color="primary"
class="submit-button"
type="submit"
[disabled]="credentialsForm.invalid || isSubmitting">
@if (isSubmitting) {
Code wird gesendet...
} @else {
Code per E-Mail senden
}
</button>
<div class="form-actions">
<a routerLink="/login">Passwort vergessen?</a>
<a routerLink="/register">Konto erstellen</a>
</div>
</form>
} @else {
@if (
(credentialService.authenticated | async) &&
!(credentialService.superadmin | async) &&
!(credentialService.universityadmin | async)
) {
<span class="error"
>Fehler: <b>{{ credentialService.login.value }}</b> ist nicht
berechtigt.</span
>
}
<form class="login-form" [formGroup]="otkForm" (ngSubmit)="login()">
<div class="code-intro">
<mat-icon>mark_email_unread</mat-icon>
<div>
<strong>Code eingeben</strong>
<span>
Wir haben den Code an
{{
credentialsForm.controls.email.value || 'Deine E-Mail-Adresse'
}}
gesendet.
</span>
</div>
</div>
<mat-form-field class="field" appearance="outline">
<mat-label>OTK-Code</mat-label>
<input
id="login-otk"
matInput
inputmode="text"
autocomplete="one-time-code"
formControlName="code" />
@if (otkForm.controls.code.hasError('required')) {
<mat-error>OTK-Code ist erforderlich.</mat-error>
} @else if (otkForm.controls.code.hasError('pattern')) {
<mat-error>Bitte gib den Code aus der E-Mail ein.</mat-error>
}
</mat-form-field>
<div
class="expiry"
[class.expiry--expired]="codeExpiresIn === 0"
aria-live="polite">
<mat-icon>timer</mat-icon>
@if (codeExpiresIn > 0) {
<span>Code läuft in {{ formatCountdown() }} ab.</span>
} @else {
<span>Code ist abgelaufen. Bitte neuen Code anfordern.</span>
}
</div>
<button
mat-flat-button
color="primary"
class="submit-button"
type="submit"
[disabled]="otkForm.invalid || isSubmitting || codeExpiresIn === 0">
@if (isSubmitting) {
Anmeldung wird geprüft...
} @else {
Anmelden
}
</button>
<div class="form-actions">
<button
mat-button
type="button"
(click)="resendCode()"
[disabled]="isSubmitting">
Code erneut senden
</button>
<button mat-button type="button" (click)="editCredentials()">
E-Mail ändern
</button>
</div>
</form>
}
</p>
</div>
</div>
</section>
@@ -1,54 +1,191 @@
.container {
display: flex;
flex-direction: column;
.login-page {
display: grid;
min-height: calc(100svh - 41px);
place-items: center;
padding: 48px 20px;
background:
radial-gradient(
circle at top left,
rgba(61, 124, 255, 0.12),
transparent 34%
),
linear-gradient(160deg, #f7f9ff 0%, #ffffff 64%);
}
.login-panel {
width: min(100%, 480px);
padding: 34px;
background: var(--sg-surface);
border: 1px solid var(--sg-border);
border-radius: var(--sg-radius-sm);
box-shadow: var(--sg-shadow-md);
}
.brand-block {
display: grid;
gap: 10px;
margin-bottom: 28px;
}
.eyebrow {
color: var(--sg-blue-highlight);
font-size: 12px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: 32px;
line-height: 1.15;
}
p {
margin: 0;
color: var(--sg-text-muted);
}
.stepper {
display: grid;
grid-template-columns: auto 1fr auto;
align-items: center;
justify-content: center;
gap: 12px;
margin-bottom: 28px;
}
.step {
display: inline-flex;
align-items: center;
gap: 8px;
color: var(--sg-text-muted);
font-size: 13px;
}
.step span {
display: grid;
width: 28px;
height: 28px;
place-items: center;
border: 1px solid var(--sg-border-strong);
border-radius: 50%;
background: var(--sg-surface);
font-weight: 700;
}
.step--active {
color: var(--sg-text);
}
.step--active span {
background: var(--sg-primary);
border-color: var(--sg-primary);
color: #ffffff;
}
.step-line {
height: 1px;
background: var(--sg-border);
}
.login-form {
display: grid;
gap: 18px;
}
.field,
.submit-button {
width: 100%;
height: 100%;
background: linear-gradient(160deg, #f4f6fb 0%, #e8ecf7 100%);
}
.form {
display: flex;
flex-direction: column;
align-items: center;
background: white;
border: none;
border-radius: 12px;
box-shadow:
0 2px 12px rgba(26, 58, 110, 0.1),
0 1px 4px rgba(0, 0, 0, 0.06);
gap: 20px;
padding: 36px 32px 28px;
}
.form h3 {
margin: 0 0 4px;
font-weight: 600;
color: #1a3a6e;
}
.button {
.submit-button {
min-height: 48px;
min-width: 140px;
border-radius: 8px;
font-weight: 500;
letter-spacing: 0.02em;
border-radius: var(--sg-radius-sm);
font-weight: 700;
}
.field {
width: 400px;
.form-actions {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
min-height: 40px;
}
.progress {
padding-top: 5px;
width: 300px;
height: 2em;
text-align: center;
font-size: small;
color: #585f71;
.form-actions a,
.form-actions button {
color: var(--sg-text-muted);
font-size: 13px;
}
.error {
.code-intro {
display: grid;
grid-template-columns: auto 1fr;
gap: 14px;
padding: 14px;
background: var(--sg-surface-soft);
border: 1px solid var(--sg-border);
border-radius: var(--sg-radius-sm);
}
.code-intro mat-icon {
color: var(--sg-blue-highlight);
}
.code-intro div {
display: grid;
gap: 3px;
}
.code-intro span {
color: var(--sg-text-muted);
font-size: 13px;
overflow-wrap: anywhere;
}
.expiry {
display: inline-flex;
align-items: center;
gap: 8px;
color: var(--sg-success);
font-size: 13px;
}
.expiry mat-icon {
width: 18px;
height: 18px;
font-size: 18px;
}
.expiry--expired {
color: #ba1a1a;
}
@media (max-width: 560px) {
.login-page {
padding: 28px 14px;
place-items: start center;
}
.login-panel {
padding: 24px 18px;
}
h1 {
font-size: 28px;
}
.stepper {
grid-template-columns: 1fr;
align-items: start;
}
.step-line {
display: none;
}
.form-actions {
align-items: stretch;
flex-direction: column;
}
}
@@ -11,9 +11,12 @@ import { MatInputModule } from '@angular/material/input';
import { CredentialService } from '../../shared/services/credential.service';
import { MatIconModule } from '@angular/material/icon';
import { CommonModule } from '@angular/common';
import { Subscription } from 'rxjs';
import { finalize, Subscription } from 'rxjs';
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
import { Router, RouterLink } from '@angular/router';
import { HttpErrorResponse } from '@angular/common/http';
type LoginStep = 'credentials' | 'otk';
@Component({
selector: 'app-app-login',
@@ -32,20 +35,30 @@ import { Router, RouterLink } from '@angular/router';
standalone: true,
})
export class AppLoginComponent implements OnInit, OnDestroy {
loginForm = new FormGroup({
login: new FormControl<string>('', [
Validators.required,
Validators.minLength(4),
]),
credentialsForm = new FormGroup({
email: new FormControl<string>('', [Validators.required, Validators.email]),
password: new FormControl<string>('', [
Validators.required,
Validators.minLength(4),
Validators.minLength(8),
]),
});
otkForm = new FormGroup({
code: new FormControl<string>('', [
Validators.required,
Validators.pattern(/^[0-9A-Za-z]{6,10}$/),
]),
});
currentStep: LoginStep = 'credentials';
showPassword = false;
isSubmitting = false;
codeExpiresIn = 0;
readonly codeLifetimeSeconds = 300;
subscription?: Subscription;
private countdownInterval?: ReturnType<typeof setInterval>;
private accountId?: string;
constructor(
protected credentialService: CredentialService,
@@ -57,20 +70,22 @@ export class AppLoginComponent implements OnInit, OnDestroy {
this.subscription = this.credentialService.validating.subscribe(
(validating) => {
if (validating) {
this.loginForm.disable();
this.credentialsForm.disable();
this.otkForm.disable();
} else {
this.loginForm.enable();
this.credentialsForm.enable();
this.otkForm.enable();
this.checkEnter();
}
},
);
if (!this.credentialService.validating) {
if (!this.credentialService.validating.value) {
this.checkEnter();
}
}
checkEnter(): void {
if (this.credentialService.authenticated.value) {
if (this.credentialService.isAuthenticated.value) {
this.router.navigate(['/dashboard']);
}
}
@@ -80,13 +95,159 @@ export class AppLoginComponent implements OnInit, OnDestroy {
this.subscription.unsubscribe();
this.subscription = undefined;
}
this.stopCountdown();
}
requestOtk() {
if (this.credentialsForm.invalid || this.isSubmitting) {
this.credentialsForm.markAllAsTouched();
return;
}
this.isSubmitting = true;
this.credentialsForm.disable();
const email = this.credentialsForm.controls.email.value ?? '';
const password = this.credentialsForm.controls.password.value ?? '';
this.credentialService
.requestOtk(email, password)
.pipe(
finalize(() => {
this.isSubmitting = false;
this.credentialsForm.enable();
}),
)
.subscribe({
next: (accountId) => {
if (!accountId) {
return;
}
this.accountId = accountId;
this.currentStep = 'otk';
this.otkForm.reset();
this.startCountdown();
this.snackBar.open(
'OTK-Code wurde an die E-Mail-Adresse gesendet.',
'OK',
{
duration: 4000,
},
);
},
error: (error: HttpErrorResponse) => {
this.credentialService.clearLocalAuthState();
this.snackBar.open(this.getLoginErrorMessage(error), 'OK', {
duration: 5000,
});
},
});
}
resendCode() {
if (this.isSubmitting) {
return;
}
this.requestOtk();
}
login() {
let user = this.loginForm.controls.login.value;
let pass = this.loginForm.controls.password.value;
if (user && pass) {
this.credentialService.loginAccount(user, pass);
if (this.otkForm.invalid || this.isSubmitting) {
this.otkForm.markAllAsTouched();
return;
}
if (this.codeExpiresIn <= 0) {
this.snackBar.open(
'Der Code ist abgelaufen. Bitte fordere einen neuen Code an.',
'OK',
{ duration: 5000 },
);
return;
}
if (!this.accountId) {
this.snackBar.open('Bitte fordere zuerst einen neuen Code an.', 'OK', {
duration: 5000,
});
return;
}
this.isSubmitting = true;
this.otkForm.disable();
const email = this.credentialsForm.controls.email.value ?? '';
const code = this.otkForm.controls.code.value ?? '';
this.credentialService
.loginWithOtk(this.accountId, email, code)
.pipe(
finalize(() => {
this.isSubmitting = false;
this.otkForm.enable();
}),
)
.subscribe({
next: () => {
this.stopCountdown();
this.router.navigate(['/dashboard']);
},
error: (error: HttpErrorResponse) => {
this.credentialService.clearLocalAuthState();
this.snackBar.open(this.getLoginErrorMessage(error), 'OK', {
duration: 5000,
});
},
});
}
editCredentials() {
this.currentStep = 'credentials';
this.accountId = undefined;
this.stopCountdown();
this.otkForm.reset();
}
formatCountdown(): string {
const minutes = Math.floor(this.codeExpiresIn / 60);
const seconds = this.codeExpiresIn % 60;
return `${minutes}:${seconds.toString().padStart(2, '0')}`;
}
private startCountdown(): void {
this.stopCountdown();
this.codeExpiresIn = this.codeLifetimeSeconds;
this.countdownInterval = setInterval(() => {
this.codeExpiresIn = Math.max(this.codeExpiresIn - 1, 0);
if (this.codeExpiresIn === 0) {
this.stopCountdown(false);
}
}, 1000);
}
private stopCountdown(reset = true): void {
if (this.countdownInterval) {
clearInterval(this.countdownInterval);
this.countdownInterval = undefined;
}
if (reset) {
this.codeExpiresIn = 0;
}
}
private getLoginErrorMessage(error: HttpErrorResponse): string {
if (error.status === 401) {
return 'E-Mail, Passwort oder OTK-Code ist ungültig.';
}
if (error.status === 403) {
return 'Dieses Konto ist nicht für die Anmeldung freigeschaltet.';
}
return 'Die Anmeldung konnte nicht abgeschlossen werden. Bitte versuche es erneut.';
}
}
@@ -95,7 +95,7 @@ export class AppRegisterComponent implements OnDestroy, OnInit {
}
checkEnter(): void {
if (this.credentialService.authenticated.value) {
if (this.credentialService.isAuthenticated.value) {
this.router.navigate(['/dashboard']);
}
}
@@ -1,4 +1,3 @@
import { Location } from '@angular/common';
import { Component, input, OnInit, signal, inject } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
@@ -28,7 +27,6 @@ export class ErrorPageComponent implements OnInit {
isDetailsOpen = signal<boolean>(false);
private readonly location = inject(Location);
private readonly errorService = inject(ErrorService);
ngOnInit() {
@@ -53,6 +51,6 @@ export class ErrorPageComponent implements OnInit {
}
goBack() {
this.location.back();
window.history.back();
}
}
@@ -0,0 +1,38 @@
<h2 mat-dialog-title>
{{
data.mode === 'create'
? 'Organisation erstellen'
: 'Organisation bearbeiten'
}}
</h2>
<mat-dialog-content>
<form class="organization-form" [formGroup]="form" (ngSubmit)="submit()">
<mat-form-field appearance="outline">
<mat-label>Name</mat-label>
<input matInput formControlName="name" />
@if (form.controls.name.hasError('required')) {
<mat-error>Name ist erforderlich.</mat-error>
}
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Externe Institutions-ID</mat-label>
<input matInput formControlName="otherInstId" />
</mat-form-field>
@if (data.mode === 'edit') {
<mat-checkbox formControlName="deleted">
Organisation als gelöscht markieren
</mat-checkbox>
}
</form>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button mat-button type="button" (click)="close()">Abbrechen</button>
<button mat-flat-button color="primary" type="button" (click)="submit()">
<mat-icon>save</mat-icon>
Speichern
</button>
</mat-dialog-actions>
@@ -0,0 +1,20 @@
.organization-form {
display: grid;
gap: 12px;
min-width: min(540px, calc(100vw - 64px));
padding-top: 4px;
}
.organization-form mat-form-field {
width: 100%;
}
mat-dialog-actions {
padding: 12px 24px 20px;
}
@media (max-width: 600px) {
.organization-form {
min-width: 0;
}
}
@@ -0,0 +1,104 @@
import { CommonModule } from '@angular/common';
import { Component, inject } from '@angular/core';
import {
FormControl,
FormGroup,
ReactiveFormsModule,
Validators,
} from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatCheckboxModule } from '@angular/material/checkbox';
import {
MAT_DIALOG_DATA,
MatDialogModule,
MatDialogRef,
} from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import type {
CreateOrganizationPayload,
OrganizationProfile,
UpdateOrganizationPayload,
} from '../../../shared/services/organization-management.service';
export interface OrganizationDialogData {
mode: 'create' | 'edit';
organization?: OrganizationProfile;
}
export type OrganizationDialogResult =
| { mode: 'create'; payload: CreateOrganizationPayload }
| {
mode: 'edit';
organizationId: string;
payload: UpdateOrganizationPayload;
};
@Component({
selector: 'app-organization-dialog',
imports: [
CommonModule,
ReactiveFormsModule,
MatButtonModule,
MatCheckboxModule,
MatDialogModule,
MatFormFieldModule,
MatIconModule,
MatInputModule,
],
templateUrl: './organization-dialog.component.html',
styleUrl: './organization-dialog.component.scss',
standalone: true,
})
export class OrganizationDialogComponent {
private readonly dialogRef =
inject<
MatDialogRef<
OrganizationDialogComponent,
OrganizationDialogResult | undefined
>
>(MatDialogRef);
protected readonly data = inject<OrganizationDialogData>(MAT_DIALOG_DATA);
protected readonly form = new FormGroup({
name: new FormControl(this.data.organization?.name ?? '', {
nonNullable: true,
validators: [Validators.required],
}),
otherInstId: new FormControl(this.data.organization?.other_inst_id ?? '', {
nonNullable: true,
}),
deleted: new FormControl(this.data.organization?.deleted ?? false, {
nonNullable: true,
}),
});
protected submit(): void {
if (this.form.invalid) {
this.form.markAllAsTouched();
return;
}
const value = this.form.getRawValue();
const payload = {
name: value.name.trim(),
other_inst_id: value.otherInstId.trim(),
};
if (this.data.mode === 'create') {
this.dialogRef.close({ mode: 'create', payload });
return;
}
this.dialogRef.close({
mode: 'edit',
organizationId: this.data.organization!.id,
payload: { ...payload, deleted: value.deleted },
});
}
protected close(): void {
this.dialogRef.close(undefined);
}
}
@@ -0,0 +1,105 @@
<section class="organizations-page">
<header class="page-header">
<div>
<h1>Organisationen</h1>
<p>Mandanten, externe Institutions-IDs und Status verwalten.</p>
</div>
<button
mat-flat-button
color="primary"
type="button"
(click)="startCreate()">
<mat-icon>add_business</mat-icon>
Neue Organisation
</button>
</header>
<section class="table-panel">
<div class="table-header">
<strong>{{ total }} Organisationen</strong>
@if (isLoading) {
<span>Wird geladen...</span>
}
</div>
<div class="table-wrap">
<table>
<thead>
<tr>
<th>Name</th>
<th>Externe Institutions-ID</th>
<th>Mitglieder</th>
<th>Status</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
@for (organization of organizations; track organization.id) {
<tr [class.deleted]="organization.deleted">
<td>
<button
class="link-button"
type="button"
(click)="startEdit(organization)">
{{ organization.name }}
</button>
</td>
<td>{{ organization.other_inst_id || '–' }}</td>
<td>{{ organization.member_count }}</td>
<td>
<span
class="status"
[class.status--deleted]="organization.deleted">
{{ organization.deleted ? 'deleted' : 'active' }}
</span>
</td>
<td>
<div class="row-actions">
<button
mat-icon-button
type="button"
aria-label="Bearbeiten"
(click)="startEdit(organization)">
<mat-icon>edit</mat-icon>
</button>
<button
mat-icon-button
type="button"
aria-label="Deaktivieren"
[disabled]="organization.deleted"
(click)="deleteOrganization(organization)">
<mat-icon>delete</mat-icon>
</button>
</div>
</td>
</tr>
} @empty {
<tr>
<td colspan="6" class="empty">Keine Organisationen gefunden.</td>
</tr>
}
</tbody>
</table>
</div>
<div class="pagination">
<button
mat-button
type="button"
[disabled]="!canPageBack"
(click)="loadOrganizations(page - 1)">
<mat-icon>chevron_left</mat-icon>
Zurück
</button>
<span>Seite {{ page + 1 }}</span>
<button
mat-button
type="button"
[disabled]="!canPageForward"
(click)="loadOrganizations(page + 1)">
Weiter
<mat-icon>chevron_right</mat-icon>
</button>
</div>
</section>
</section>
@@ -0,0 +1,130 @@
.organizations-page {
display: flex;
flex-direction: column;
gap: 20px;
padding: 24px;
}
.page-header,
.table-header,
.pagination,
.row-actions {
display: flex;
align-items: center;
}
.page-header {
justify-content: space-between;
gap: 16px;
}
h1,
p {
margin: 0;
}
.page-header p,
.table-header span {
color: #64748b;
}
.page-header p {
margin-top: 6px;
}
.table-panel {
overflow: hidden;
border: 1px solid #d7dde6;
border-radius: 8px;
background: #fff;
}
.table-header {
justify-content: space-between;
padding: 16px;
border-bottom: 1px solid #e5e7eb;
}
.table-wrap {
overflow-x: auto;
}
table {
width: 100%;
border-collapse: collapse;
}
th,
td {
padding: 12px 16px;
text-align: left;
border-bottom: 1px solid #edf1f7;
white-space: nowrap;
}
th {
color: #475569;
font-weight: 700;
background: #f8fafc;
}
tr.deleted {
color: #94a3b8;
}
.identifier {
font-family: monospace;
font-size: 12px;
}
.link-button {
border: 0;
background: transparent;
color: #1d4ed8;
padding: 0;
font: inherit;
cursor: pointer;
}
.status {
display: inline-flex;
align-items: center;
min-height: 24px;
border-radius: 999px;
padding: 2px 10px;
background: #dcfce7;
color: #166534;
font-size: 12px;
font-weight: 700;
}
.status--deleted {
background: #fee2e2;
color: #991b1b;
}
.row-actions {
gap: 4px;
}
.empty {
color: #64748b;
text-align: center;
}
.pagination {
justify-content: flex-end;
gap: 8px;
padding: 12px 16px;
}
@media (max-width: 640px) {
.organizations-page {
padding: 16px;
}
.page-header {
align-items: flex-start;
flex-direction: column;
}
}
@@ -0,0 +1,160 @@
import { CommonModule } from '@angular/common';
import { Component, OnInit, inject } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
import { finalize } from 'rxjs';
import {
OrganizationManagementService,
OrganizationProfile,
} from '../../shared/services/organization-management.service';
import type {
OrganizationDialogComponent,
OrganizationDialogData,
OrganizationDialogResult,
} from './organization-dialog/organization-dialog.component';
@Component({
selector: 'app-organizations',
imports: [
CommonModule,
MatButtonModule,
MatDialogModule,
MatIconModule,
MatSnackBarModule,
],
templateUrl: './organizations.component.html',
styleUrl: './organizations.component.scss',
standalone: true,
})
export class OrganizationsComponent implements OnInit {
private readonly organizationService = inject(OrganizationManagementService);
private readonly dialog = inject(MatDialog);
private readonly snackBar = inject(MatSnackBar);
protected organizations: OrganizationProfile[] = [];
protected total = 0;
protected page = 0;
protected readonly pageSize = 10;
protected isLoading = false;
ngOnInit(): void {
this.loadOrganizations();
}
protected loadOrganizations(page = this.page): void {
this.page = page;
this.isLoading = true;
this.organizationService
.getOrganizations(page, this.pageSize)
.pipe(finalize(() => (this.isLoading = false)))
.subscribe({
next: (result) => {
this.organizations = result.items;
this.total = result.total;
},
error: () =>
this.showError('Organisationen konnten nicht geladen werden.'),
});
}
protected startCreate(): void {
this.openDialog({ mode: 'create' });
}
protected startEdit(organization: OrganizationProfile): void {
this.openDialog({ mode: 'edit', organization });
}
protected deleteOrganization(organization: OrganizationProfile): void {
if (organization.deleted) return;
import('../../shared/ui/confirmation-dialog/confirmation-dialog.component').then(
({ ConfirmationDialogComponent }) => {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: {
title: 'Organisation deaktivieren',
message: `Möchtest Du die Organisation „${organization.name}“ wirklich deaktivieren?`,
confirmText: 'Deaktivieren',
cancelText: 'Abbrechen',
},
});
dialogRef.componentInstance.confirmDelete.subscribe(() => {
this.softDeleteOrganization(organization);
});
},
);
}
private softDeleteOrganization(organization: OrganizationProfile): void {
this.organizationService.deleteOrganization(organization.id).subscribe({
next: () => {
this.snackBar.open('Organisation wurde deaktiviert.', 'OK', {
duration: 3000,
});
this.loadOrganizations();
},
error: () =>
this.showError('Organisation konnte nicht deaktiviert werden.'),
});
}
protected get canPageBack(): boolean {
return this.page > 0;
}
protected get canPageForward(): boolean {
return (this.page + 1) * this.pageSize < this.total;
}
private openDialog(data: OrganizationDialogData): void {
import('./organization-dialog/organization-dialog.component').then(
({ OrganizationDialogComponent }) => {
const dialogRef = this.dialog.open<
OrganizationDialogComponent,
OrganizationDialogData,
OrganizationDialogResult | undefined
>(OrganizationDialogComponent, {
width: '620px',
maxWidth: 'calc(100vw - 32px)',
data,
});
dialogRef.afterClosed().subscribe((result) => {
if (result) this.save(result);
});
},
);
}
private save(result: OrganizationDialogResult): void {
const request =
result.mode === 'create'
? this.organizationService.createOrganization(result.payload)
: this.organizationService.updateOrganization(
result.organizationId,
result.payload,
);
request.subscribe({
next: () => {
this.snackBar.open('Organisation wurde gespeichert.', 'OK', {
duration: 3000,
});
this.loadOrganizations(0);
},
error: (error) =>
this.showError(
error.status === 409
? 'Eine Organisation mit diesem Namen existiert bereits.'
: 'Organisation konnte nicht gespeichert werden.',
),
});
}
private showError(message: string): void {
this.snackBar.open(message, 'OK', { duration: 5000 });
}
}
@@ -90,7 +90,7 @@
</ul>
</div>
@if (selectedPatent.assignees.length > 0) {
@if ((selectedPatent.assignees?.length ?? 0) > 0) {
<div class="detail-section">
<h4>Anmelder</h4>
<ul class="tag-list">
@@ -101,7 +101,7 @@
</div>
}
@if (selectedPatent.ipc_descriptions.length > 0) {
@if ((selectedPatent.ipc_descriptions?.length ?? 0) > 0) {
<div
class="detail-section classification-section classification-section--ipc">
<h4>Klassifikation (IPC)</h4>
@@ -166,7 +166,7 @@
}
</div>
</div>
} @else if (selectedPatent.ipc.length > 0) {
} @else if ((selectedPatent.ipc?.length ?? 0) > 0) {
<div class="detail-section">
<h4>Klassifikation (IPC)</h4>
<ul class="tag-list tag-list--compact">
@@ -177,7 +177,7 @@
</div>
}
@if (selectedPatent.cpc_descriptions.length > 0) {
@if ((selectedPatent.cpc_descriptions?.length ?? 0) > 0) {
<div
class="detail-section classification-section classification-section--cpc">
<h4>Klassifikation (CPC)</h4>
@@ -242,7 +242,7 @@
}
</div>
</div>
} @else if (selectedPatent.cpc.length > 0) {
} @else if ((selectedPatent.cpc?.length ?? 0) > 0) {
<div class="detail-section">
<h4>Klassifikation (CPC)</h4>
<ul class="tag-list tag-list--compact">
@@ -284,7 +284,7 @@
<mat-divider />
<div class="card-metadata">
<span>{{ patent.patent_id }}</span>
<span>{{ formatDate(patent.publication_date) }}</span>
<span>{{ formatDate(patent.publication_date ?? '') }}</span>
</div>
<mat-divider />
</mat-card-content>
@@ -13,7 +13,8 @@ import { MatDividerModule } from '@angular/material/divider';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { debounceTime, distinctUntilChanged, Subject } from 'rxjs';
import { PatentsService } from '../../api/api/patents.service';
import { PatentEntry, IpcClassification } from '../../api/model/patentEntry';
import { PatentEntry } from '../../api/model/patentEntry';
import { IpcClassification } from '../../api';
type SourceFilter = 'all' | 'EPO' | 'USPTO';
type ClassificationSystem = 'IPC' | 'CPC';
@@ -332,9 +333,9 @@ export class PatentsComponent implements OnInit {
seen.add(norm);
rows.push({ label, value });
};
addRow('Sektion', entry.section);
addRow('Klasse', entry.class);
addRow('Unterklasse', entry.subclass);
addRow('Sektion', entry.section ?? null);
addRow('Klasse', entry.class ?? null);
addRow('Unterklasse', entry.subclass ?? null);
return rows;
}
@@ -6,7 +6,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
import { CustomAuthor, DehydratedInstitution, WorkTopic } from '../../api';
import { SkTextDirective } from '../../custom-directives/sk-text.directive';
import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component';
import { topicHierarchyColor } from '../../shared/utils/topic-colors';
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
@Component({
selector: 'app-person-card',
@@ -16,7 +16,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import { TopicCount } from '../../api';
import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component';
import { TopicLegendComponent } from '../../shared/ui/topic-legend/topic-legend.component';
import { topicHierarchyColor } from '../../shared/utils/topic-colors';
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
import {
buildTopicLegendGroups,
getTopicLegendFieldId,
@@ -25,7 +25,7 @@ import {
TopicLegendSubfieldSelection,
toggleTopicLegendFieldSelection,
toggleTopicLegendSubfieldSelection,
} from '../../shared/utils/topic-legend';
} from '../../resolvers/utils/topic-legend';
interface InterestTag {
id: string;
@@ -23,7 +23,7 @@ import { TopicsService } from '../../api/api/topics.service';
import { TopicHierarchyComponent } from '../topic-hierarchy/topic-hierarchy.component';
import { PersonCardComponent } from '../person-card/person-card.component';
import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component';
import { topicHierarchyColor } from '../../shared/utils/topic-colors';
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
import { SharedStateService } from '../../shared/services/shared-state.service';
import { PaginationService } from '../../shared/services/pagination.service';
import {
@@ -14,7 +14,7 @@ import {
} from '@angular/core';
import { TopicChipComponent } from '../../../../shared/ui/topic-chip/topic-chip.component';
import { TopicLegendComponent } from '../../../../shared/ui/topic-legend/topic-legend.component';
import { topicHierarchyColor } from '../../../../shared/utils/topic-colors';
import { topicHierarchyColor } from '../../../../resolvers/utils/topic-colors';
import {
buildTopicLegendGroups,
getTopicLegendFieldId,
@@ -24,8 +24,8 @@ import {
TopicLegendTopic,
toggleTopicLegendFieldSelection,
toggleTopicLegendSubfieldSelection,
} from '../../../../shared/utils/topic-legend';
import { buildTopicHierarchyTooltip } from '../../../../shared/utils/topic-tooltip';
} from '../../../../resolvers/utils/topic-legend';
import { buildTopicHierarchyTooltip } from '../../../../resolvers/utils/topic-tooltip';
export interface TopicTimelineTopic {
id?: string;
@@ -103,7 +103,7 @@ interface TimelineScrollAnchor {
})
export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
@ViewChild('timelineWrapper')
private timelineWrapper?: ElementRef<HTMLDivElement>;
private readonly timelineWrapper?: ElementRef<HTMLDivElement>;
@Input() elements: TopicTimelineElement[] = [];
@Input() loading = false;
@Input() loadFailed = false;
@@ -6,9 +6,6 @@ import { MatTooltipModule } from '@angular/material/tooltip';
import { combineLatest, distinctUntilChanged, map } from 'rxjs';
import { TopicCount, TopicsByYear, WorksService } from '../../api';
import { topicHierarchyColor } from '../../shared/utils/topic-colors';
import { TopicLegendTopic } from '../../shared/utils/topic-legend';
import { buildTopicHierarchyTooltip } from '../../shared/utils/topic-tooltip';
import {
ResearchTimelineComponent,
TimelineViewMode,
@@ -17,6 +14,9 @@ import {
TopicTimelineElement,
TopicTimelineTopic,
} from './components/research-timeline/research-timeline.component';
import { TopicLegendTopic } from '../../resolvers/utils/topic-legend';
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
import { buildTopicHierarchyTooltip } from '../../resolvers/utils/topic-tooltip';
export interface WordCloudWord {
name: string;
@@ -2,7 +2,8 @@ import { Component, OnInit, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
import { PatentsService } from '../../api/api/patents.service';
import { PatentEntry, IpcClassification } from '../../api/model/patentEntry';
import { PatentEntry } from '../../api/model/patentEntry';
import { IpcClassification } from '../../api';
type SortMode = 'date' | 'title';
type SourceFilter = 'all' | 'EPO' | 'USPTO';
@@ -40,10 +40,10 @@ import {
import { Work, WorksService, WorkTopic } from '../../api';
import { PaginationService } from '../../shared/services/pagination.service';
import { createLoadError } from '../../shared/utils/errorHandler';
import { createLoadError } from '../../resolvers/utils/errorHandler';
import { ChipComponent } from '../../shared/ui/chip/chip.component';
import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component';
import { topicHierarchyColor } from '../../shared/utils/topic-colors';
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
interface InstitutionAutocompleteOption {
id?: string | null;
@@ -53,14 +53,18 @@
<div class="metric-item">
<mat-icon>calendar_today</mat-icon>
<div class="metric-content">
<strong>{{ getStartDate() || 'N/A' }}</strong>
<strong>{{
bundProject.funding_start_date | date: 'dd.MM.yyyy'
}}</strong>
<span>Förderbeginn</span>
</div>
</div>
<div class="metric-item">
<mat-icon>event_busy</mat-icon>
<div class="metric-content">
<strong>{{ getFundingStatus(getEndDate()) }}</strong>
<strong>{{
getFundingStatus(bundProject.funding_end_date)
}}</strong>
<span>Förderende</span>
</div>
</div>
@@ -77,7 +81,10 @@
<div class="metric-item">
<mat-icon>paid</mat-icon>
<div class="metric-content">
<strong>{{ getFundingAmountDisplay() }}</strong>
<strong>{{
bundProject.funding_amount
| currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
}}</strong>
<span>Fördersumme</span>
</div>
</div>
@@ -351,7 +358,12 @@
@if (bundProject.funding_amount) {
<div class="detail-row">
<dt>Fördersumme</dt>
<dd>{{ getFundingAmountDisplay() }}</dd>
<dd>
{{
bundProject.funding_amount
| currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
}}
</dd>
</div>
}
@if (bundProject.funding_amount) {
@@ -374,12 +386,16 @@
<dt>Förderende</dt>
<dd>{{ getFundingStatus(getEndDate()) }}</dd>
</div> -->
@if (getDuration()) {
<div class="detail-row">
<dt>Laufzeit</dt>
<dd>{{ getDuration() }}</dd>
</div>
}
<div class="detail-row">
<dt>Laufzeit</dt>
<dd>
von
{{ bundProject.funding_start_date | date: 'dd.MM.yyyy' }} bis
{{ bundProject.funding_end_date | date: 'dd.MM.yyyy' }}
</dd>
</div>
@if (bundProject.joint_project) {
<div class="detail-row">
<dt>Gemeinschaftsprojekt</dt>
@@ -1,11 +1,10 @@
import { Component, OnInit, inject } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { CommonModule } from '@angular/common';
import { MatCardModule } from '@angular/material/card';
import { MatIconModule } from '@angular/material/icon';
import { BundProjectDetails } from '../../../api/model/bundProjectDetails';
import { Router } from '@angular/router';
import { formatGermanDate } from '../../../shared/utils/formatters';
@Component({
selector: 'app-bund-details',
standalone: true,
@@ -14,10 +13,10 @@ import { formatGermanDate } from '../../../shared/utils/formatters';
styleUrl: './bund-details.component.scss',
})
export class BundDetailsComponent implements OnInit {
private route = inject(ActivatedRoute);
private readonly route = inject(ActivatedRoute);
bundProject: BundProjectDetails | undefined;
constructor(private router: Router) {}
constructor(private readonly router: Router) {}
ngOnInit(): void {
this.route.data.subscribe(({ bundSingleProject }) => {
@@ -38,25 +37,13 @@ export class BundDetailsComponent implements OnInit {
getFundingStatus(fundingEndDate: string | null | undefined): string {
if (!fundingEndDate) return 'N/A';
if (fundingEndDate === '2999') return 'laufend';
const year = parseInt(fundingEndDate, 10);
if (isNaN(year)) return fundingEndDate;
const year = Number.parseInt(fundingEndDate, 10);
if (Number.isNaN(year)) return fundingEndDate;
return year >= new Date().getFullYear()
? `${fundingEndDate}`
: `${fundingEndDate}`;
}
formatCurrency(amount: number | null | undefined): string {
if (amount === null || amount === undefined) return 'N/A';
// Format as Euro with thousands separators
return new Intl.NumberFormat('de-DE', {
style: 'currency',
currency: 'EUR',
minimumFractionDigits: 0,
maximumFractionDigits: 0,
}).format(amount);
}
searchForPersonName(personName: string): void {
this.router.navigate(['/persons'], {
queryParams: {
@@ -110,22 +97,7 @@ export class BundDetailsComponent implements OnInit {
getAssociatedPersons(): string[] {
return this.bundProject?.associated_persons || [];
}
getStartDate(): string {
return formatGermanDate(this.bundProject?.funding_start_date ?? '');
}
getEndDate(): string {
return formatGermanDate(this.bundProject?.funding_end_date ?? '');
}
getDuration(): string {
const start = this.bundProject?.funding_start_date;
const end = this.bundProject?.funding_end_date;
if (!start || !end) return '';
return `von ${formatGermanDate(start)} bis ${formatGermanDate(end)}`;
}
/**
* All institutions as a simple list.
*/
@@ -140,17 +112,10 @@ export class BundDetailsComponent implements OnInit {
return this.bundProject?.is_new === true;
}
/**
* Get display name for funding amount
*/
getFundingAmountDisplay(): string {
if (!this.bundProject?.funding_amount) return 'N/A';
return this.formatCurrency(this.bundProject.funding_amount);
}
getStatusDisplay(fundingEndDate: string | null | undefined): string {
if (!fundingEndDate) return 'N/A';
if (fundingEndDate === '2999') return 'Laufend';
const year = parseInt(fundingEndDate, 10);
const year = Number.parseInt(fundingEndDate, 10);
return year >= new Date().getFullYear() ? `Laufend` : `Abgeschlossen`;
}
getStatusColor(status: string | null | undefined): string {
@@ -72,14 +72,14 @@
<div class="metric-item">
<mat-icon>calendar_today</mat-icon>
<div class="metric-content">
<strong>{{ formatDate(euProject.startDate) || 'N/A' }}</strong>
<strong>{{ euProject.startDate | date: 'dd.MM.yyyy' }}</strong>
<span>Förderbeginn</span>
</div>
</div>
<div class="metric-item">
<mat-icon>event_busy</mat-icon>
<div class="metric-content">
<strong>{{ formatDate(euProject.endDate) || 'N/A' }}</strong>
<strong>{{ euProject.endDate | date: 'dd.MM.yyyy' }}</strong>
<span>Förderende</span>
</div>
</div>
@@ -94,7 +94,10 @@
<div class="metric-item">
<mat-icon>euro_symbol</mat-icon>
<div class="metric-content">
<strong>{{ formatCurr(euProject.ecMaxContribution) }}</strong>
<strong>{{
euProject.ecMaxContribution
| currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
}}</strong>
<span>EU-Beitrag</span>
</div>
</div>
@@ -103,7 +106,10 @@
<div class="metric-item">
<mat-icon>attach_money</mat-icon>
<div class="metric-content">
<strong>{{ formatCurr(euProject.totalCost) }}</strong>
<strong>{{
euProject.totalCost
| currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
}}</strong>
<span>Gesamtkosten</span>
</div>
</div>
@@ -368,19 +374,31 @@
@if (euProject.ecMaxContribution) {
<div class="detail-row">
<dt>Max. EU-Beitrag</dt>
<dd>{{ formatCurr(euProject.ecMaxContribution) }}</dd>
<dd>
{{
euProject.ecMaxContribution
| currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
}}
</dd>
</div>
}
@if (euProject.totalCost) {
<div class="detail-row">
<dt>Gesamtkosten</dt>
<dd>{{ formatCurr(euProject.totalCost) }}</dd>
<dd>
{{
euProject.totalCost
| currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
}}
</dd>
</div>
}
@if (euProject.ecSignatureDate) {
<div class="detail-row">
<dt>EU-Unterzeichnung</dt>
<dd>{{ formatDate(euProject.ecSignatureDate) }}</dd>
<dd>
{{ euProject.ecSignatureDate | date: 'dd.MM.yyyy' }}
</dd>
</div>
}
@if (euProject.nature) {
@@ -402,22 +420,25 @@
<div class="detail-row">
<dt>Laufzeit</dt>
<dd>
{{
getDuration(euProject.startDate, euProject.endDate) ||
'N/A'
}}
von
{{ euProject.startDate | date: 'dd.MM.yyyy' }}
bis {{ euProject.endDate | date: 'dd.MM.yyyy' }}
</dd>
</div>
@if (euProject.ecSignatureDate) {
<div class="detail-row">
<dt>EU-Unterzeichnung</dt>
<dd>{{ formatDate(euProject.ecSignatureDate) }}</dd>
<dd>
{{ euProject.ecSignatureDate | date: 'dd.MM.yyyy' }}
</dd>
</div>
}
@if (euProject.contentUpdateDate) {
<div class="detail-row">
<dt>Letzte Aktualisierung</dt>
<dd>{{ formatDate(euProject.contentUpdateDate) }}</dd>
<dd>
{{ euProject.contentUpdateDate | date: 'dd.MM.yyyy' }}
</dd>
</div>
}
@if (euProject.grantDoi) {
@@ -1,7 +1,7 @@
// eu-details.component.ts (refactored)
import { Component, OnInit, inject, OnDestroy } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { CommonModule } from '@angular/common';
import { CommonModule, CurrencyPipe } from '@angular/common';
import { MatCardModule } from '@angular/material/card';
import { MatIconModule } from '@angular/material/icon';
import { MatChipsModule } from '@angular/material/chips';
@@ -9,16 +9,13 @@ import { MatButtonModule } from '@angular/material/button';
import { MatDividerModule } from '@angular/material/divider';
import { MatTooltipModule } from '@angular/material/tooltip';
import { Subscription } from 'rxjs';
import {
formatGermanDate,
formatCurrency,
} from '../../../shared/utils/formatters';
import { EuProjectData } from '../../../api/model/euProjectData';
import { TopicChipComponent } from '../../../shared/ui/topic-chip/topic-chip.component';
import { OrganizationsTableComponent } from './organizations-table/organizations-table/organizations-table.component';
import { PublicationsTableComponent } from './publications-table/publications-table.component';
import { PatentsCardsComponent } from './patents-cards/patents-cards.component';
import { DeliverablesCardsComponent } from './deliverables-cards/deliverables-cards.component';
export type TabType =
| 'overview'
| 'organizations'
@@ -42,13 +39,14 @@ export type TabType =
PublicationsTableComponent,
PatentsCardsComponent,
DeliverablesCardsComponent,
CurrencyPipe,
],
templateUrl: './eu-details.component.html',
styleUrl: './eu-details.component.scss',
})
export class EuDetailsComponent implements OnInit, OnDestroy {
private route = inject(ActivatedRoute);
private router = inject(Router);
private readonly route = inject(ActivatedRoute);
private readonly router = inject(Router);
// Data
euProject: EuProjectData | undefined;
@@ -320,30 +318,11 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
const end = new Date(endDate);
const now = new Date();
if (isNaN(end.getTime())) return endDate;
if (Number.isNaN(end.getTime())) return endDate;
return end >= now ? 'Laufend' : 'Abgeschlossen';
}
getDuration(start: string | undefined, end: string | undefined): string {
if (!start || !end) return '';
return `von ${formatGermanDate(start)} bis ${formatGermanDate(end)}`;
}
formatDate(date: string | undefined): string | undefined {
if (date) {
return formatGermanDate(date);
}
return date;
}
formatCurr(value: number | undefined | null): string | null | undefined {
if (value) {
return formatCurrency(value);
}
return String(value);
}
getStatusColor(status: string | null | undefined): string {
if (!status) return '#95a5a6';
@@ -58,7 +58,7 @@
<td mat-cell *matCellDef="let org">
@if (org.ecContribution) {
<span class="currency-value">{{
formatCurr(org.ecContribution)
org.ecContribution | currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
}}</span>
} @else {
<span class="empty-value">—</span>
@@ -1,18 +1,18 @@
import { Component, inject, Input } from '@angular/core';
import { MatTableModule } from '@angular/material/table';
import { Router } from '@angular/router';
import { formatCurrency } from '../../../../../shared/utils/formatters';
import { MatIcon } from '@angular/material/icon';
import { MatCard } from '@angular/material/card';
import { HEUOrganization } from '../../../../../api';
import { CurrencyPipe } from '@angular/common';
@Component({
selector: 'app-organizations-table',
imports: [MatTableModule, MatIcon, MatCard],
imports: [MatTableModule, MatIcon, MatCard, CurrencyPipe],
templateUrl: './organizations-table.component.html',
styleUrl: './organizations-table.component.scss',
})
export class OrganizationsTableComponent {
private router = inject(Router);
private readonly router = inject(Router);
@Input() orgs!: HEUOrganization[];
@Input() showHeader: boolean = true;
@@ -46,10 +46,4 @@ export class OrganizationsTableComponent {
getOrgsCount(): number {
return this.orgs?.length || 0;
}
formatCurr(value: number | undefined | null) {
if (value) {
return formatCurrency(value);
}
return value;
}
}
@@ -62,8 +62,8 @@
<mat-divider />
<div class="card-metadata">
<span
>Von {{ fundingProject.start_date | date }} bis
{{ fundingProject.end_date | date }}</span
>Von {{ fundingProject.start_date | date: 'dd.MM.yyyy' }} bis
{{ fundingProject.end_date | date: 'dd.MM.yyyy' }}</span
>
</div>
<mat-divider />
@@ -16,7 +16,7 @@ import {
WorkTopic,
} from '../../api';
import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component';
import { topicHierarchyColor } from '../../shared/utils/topic-colors';
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
interface DetailLink {
label: string;
@@ -6,7 +6,7 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatRadioModule } from '@angular/material/radio';
import { MatTooltipModule } from '@angular/material/tooltip';
import { TopicsService } from '../../api/api/topics.service';
import { topicHierarchyColor } from '../../shared/utils/topic-colors';
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
import { combineLatest, of } from 'rxjs';
import { toObservable } from '@angular/core/rxjs-interop';
import {