58 lines
2.1 KiB
TypeScript
58 lines
2.1 KiB
TypeScript
import { Component, inject } from '@angular/core';
|
|
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
|
import { Roles } from '@users/roles';
|
|
import { getCurrentUser, IqserPermissionsService, List, TenantsService } from '@iqser/common-ui';
|
|
import { User } from '@red/domain';
|
|
import { UserService } from '@users/user.service';
|
|
|
|
interface MenuItem {
|
|
readonly id: string;
|
|
readonly name: string;
|
|
readonly routerLink?: string;
|
|
readonly show: boolean;
|
|
readonly action?: () => void;
|
|
readonly showDot?: () => boolean;
|
|
}
|
|
|
|
@Component({
|
|
selector: 'app-user-menu',
|
|
templateUrl: './user-menu.component.html',
|
|
styleUrls: ['./user-menu.component.scss'],
|
|
})
|
|
export class UserMenuComponent {
|
|
readonly currentUser = getCurrentUser<User>();
|
|
readonly tenantsService = inject(TenantsService);
|
|
readonly userService = inject(UserService);
|
|
readonly #permissionsService = inject(IqserPermissionsService);
|
|
readonly userMenuItems: List<MenuItem> = [
|
|
{
|
|
id: 'account',
|
|
name: _('top-bar.navigation-items.my-account.children.account'),
|
|
routerLink: '/main/account',
|
|
show: true,
|
|
},
|
|
{
|
|
id: 'admin',
|
|
name: _('top-bar.navigation-items.my-account.children.admin'),
|
|
routerLink: '/main/admin',
|
|
show: (this.currentUser.isManager || this.currentUser.isUserAdmin) && this.#permissionsService.has([Roles.templates.read]),
|
|
},
|
|
{
|
|
id: 'downloads',
|
|
name: _('top-bar.navigation-items.my-account.children.downloads'),
|
|
routerLink: '/main/downloads',
|
|
show: this.currentUser.isUser && this.#permissionsService.has(Roles.readDownloadStatus),
|
|
},
|
|
{
|
|
id: 'trash',
|
|
name: _('top-bar.navigation-items.my-account.children.trash'),
|
|
routerLink: '/main/trash',
|
|
show: this.currentUser.isUser && this.#permissionsService.has([Roles.dossiers.read, Roles.files.readStatus]),
|
|
},
|
|
];
|
|
|
|
trackBy(_index: number, item: MenuItem) {
|
|
return item.id;
|
|
}
|
|
}
|