108 lines
2.8 KiB
TypeScript
108 lines
2.8 KiB
TypeScript
import { Component, computed, inject, input, output } from '@angular/core';
|
|
import { CommonModule } from '@angular/common';
|
|
import { Router, RouterLink, RouterLinkActive } from '@angular/router';
|
|
import { MatIconModule } from '@angular/material/icon';
|
|
import { MatListModule } from '@angular/material/list';
|
|
import { MatButtonModule } from '@angular/material/button';
|
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
import { CredentialService } from '../../services/credential.service';
|
|
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
|
import { MatDialog } from '@angular/material/dialog';
|
|
import { ConfirmationDialogComponent } from '../confirmation-dialog/confirmation-dialog.component';
|
|
|
|
@Component({
|
|
selector: 'app-menu',
|
|
imports: [
|
|
CommonModule,
|
|
RouterLink,
|
|
MatIconModule,
|
|
MatListModule,
|
|
RouterLinkActive,
|
|
MatProgressBarModule,
|
|
MatButtonModule,
|
|
MatTooltipModule,
|
|
],
|
|
templateUrl: './app-menu.component.html',
|
|
styleUrl: './app-menu.component.scss',
|
|
standalone: true,
|
|
})
|
|
export class AppMenuComponent {
|
|
collapsed = input(false);
|
|
canCollapse = input(false);
|
|
toggleCollapsed = output<void>();
|
|
navItems = [
|
|
{
|
|
label: 'Dashboard',
|
|
icon: 'dashboard',
|
|
route: '/dashboard',
|
|
disabled: false,
|
|
},
|
|
{
|
|
label: 'Personen',
|
|
icon: 'groups',
|
|
route: '/persons',
|
|
queryParams: {
|
|
institutionName: this.credentialService.organizationName.value,
|
|
},
|
|
disabled: false,
|
|
},
|
|
{
|
|
label: 'News',
|
|
icon: 'newspaper',
|
|
route: '/news',
|
|
disabled: false,
|
|
},
|
|
{
|
|
label: 'Institutionen',
|
|
icon: 'apartment',
|
|
route: '/institutions',
|
|
disabled: false,
|
|
queryParams: {
|
|
search: '',
|
|
page: 0,
|
|
size: 10,
|
|
sort_by: 'works_count',
|
|
sorting_order: 'desc',
|
|
},
|
|
},
|
|
{
|
|
label: 'Projekte',
|
|
icon: 'work',
|
|
route: '/projects',
|
|
disabled: false,
|
|
queryParams: {
|
|
search: '',
|
|
page: 0,
|
|
size: 10,
|
|
selected_project_types: 'eu,bund,dfg',
|
|
sort_by: 'title',
|
|
sorting_order: 'asc',
|
|
},
|
|
},
|
|
];
|
|
|
|
constructor(
|
|
public credentialService: CredentialService,
|
|
private readonly router: Router,
|
|
) {}
|
|
|
|
isNavigating = computed(() => !!this.router.currentNavigation());
|
|
private readonly dialog = inject(MatDialog);
|
|
|
|
onLogout() {
|
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
|
data: {
|
|
title: 'Abmelden',
|
|
message: 'Möchtest Du Dich wirklich abmelden?',
|
|
confirmText: 'Abmelden',
|
|
cancelText: 'Abbrechen',
|
|
},
|
|
});
|
|
|
|
dialogRef.componentInstance.confirmDelete.subscribe(() => {
|
|
this.credentialService.logoutAcount();
|
|
this.router.navigate(['/login']);
|
|
});
|
|
}
|
|
}
|