Description
A simple list of shortcuts displayed as a dashboard widget for easy access to important navigation.
Example
|
explanation
|
Type : string
|
Default value : $localize`:dashboard widget explanation:Shortcuts to quickly navigate to common actions`
|
|
|
|
shortcuts
|
Type : MenuItem[]
|
Default value : []
|
|
|
displayed entries, each representing one line displayed as a shortcut
|
|
subtitle
|
Type : string
|
Default value : $localize`:dashboard widget subtitle:Quick Actions`
|
|
|
Methods
|
Async
copyAbsoluteLink2Clipboard
|
copyAbsoluteLink2Clipboard(link: string)
|
|
|
Parameters :
| Name |
Type |
Optional |
| link |
string
|
No
|
|
|
filteredShortcuts
|
Type : unknown
|
Default value : signal<MenuItem[]>([])
|
|
|
import {
ChangeDetectionStrategy,
Component,
effect,
inject,
input,
signal,
} from "@angular/core";
import { MenuItem } from "../../../../core/ui/navigation/menu-item";
import { MatTableModule } from "@angular/material/table";
import { DynamicComponent } from "../../../../core/config/dynamic-components/dynamic-component.decorator";
import { FaDynamicIconComponent } from "../../../../core/common-components/fa-dynamic-icon/fa-dynamic-icon.component";
import { RouterLink } from "@angular/router";
import { DashboardListWidgetComponent } from "../../../../core/dashboard/dashboard-list-widget/dashboard-list-widget.component";
import { RoutePermissionsService } from "../../../../core/config/dynamic-routing/route-permissions.service";
import { FaIconComponent } from "@fortawesome/angular-fontawesome";
import { MatIconButton } from "@angular/material/button";
import { MatTooltip } from "@angular/material/tooltip";
import { LocationStrategy } from "@angular/common";
import { AlertService } from "../../../../core/alerts/alert.service";
import { Clipboard } from "@angular/cdk/clipboard";
/**
* A simple list of shortcuts displayed as a dashboard widget for easy access to important navigation.
*/
@DynamicComponent("ShortcutDashboard")
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: "app-shortcut-dashboard",
templateUrl: "./shortcut-dashboard.component.html",
styleUrls: ["./shortcut-dashboard.component.scss"],
imports: [
DashboardListWidgetComponent,
MatTableModule,
FaDynamicIconComponent,
RouterLink,
FaIconComponent,
MatIconButton,
MatTooltip,
],
})
export class ShortcutDashboardComponent {
private routePermissionsService = inject(RoutePermissionsService);
private locationStrategy = inject(LocationStrategy);
private clipboard = inject(Clipboard);
private alertService = inject(AlertService);
/** displayed entries, each representing one line displayed as a shortcut */
shortcuts = input<MenuItem[]>([]);
filteredShortcuts = signal<MenuItem[]>([]);
subtitle = input<string>($localize`:dashboard widget subtitle:Quick Actions`);
explanation = input<string>(
$localize`:dashboard widget explanation:Shortcuts to quickly navigate to common actions`,
);
constructor() {
effect((onCleanup) => {
const items = this.shortcuts();
let isCurrent = true;
this.routePermissionsService.filterPermittedRoutes(items).then((res) => {
if (isCurrent) {
this.filteredShortcuts.set(res);
}
});
onCleanup(() => {
isCurrent = false;
});
});
}
async copyAbsoluteLink2Clipboard(link: string) {
const externalLink =
window.location.origin + this.locationStrategy.prepareExternalUrl(link);
const success = this.clipboard.copy(externalLink);
if (success) {
this.alertService.addInfo("Link copied: " + externalLink);
}
}
}
<app-dashboard-list-widget
icon="external-link-alt"
theme="general"
[subtitle]="subtitle()"
[explanation]="explanation()"
[entries]="filteredShortcuts()"
>
<div class="table-container">
<table mat-table i18n-aria-label aria-label="Quick actions">
<!-- Table header only for assistive technologies like screen readers -->
<tr class="visually-hidden">
<th scope="col" i18n="Column header for the icon of a quick action">
Icon
</th>
<th scope="col" i18n="Column header for the label of a quick action">
Label
</th>
<th
scope="col"
i18n="Column header for the copy-link action of a quick action"
>
Copy
</th>
</tr>
<ng-container matColumnDef="icon">
<td *matCellDef="let row" class="pointer" [routerLink]="row.link">
<app-fa-dynamic-icon [icon]="row.icon"></app-fa-dynamic-icon>
</td>
</ng-container>
<ng-container matColumnDef="label">
<td *matCellDef="let row" class="pointer" [routerLink]="row.link">
{{ row.label }}
</td>
</ng-container>
<ng-container matColumnDef="copy">
<td *matCellDef="let row" class="text-align-end">
<button
mat-icon-button
(click)="copyAbsoluteLink2Clipboard(row.link)"
matTooltip="Copy the link to share or paste it somewhere else"
i18n-matTooltip
>
<fa-icon [icon]="['far', 'copy']" size="xs"></fa-icon>
</button>
</td>
</ng-container>
<tr mat-row *matRowDef="let row; columns: ['icon', 'label', 'copy']"></tr>
</table>
</div>
</app-dashboard-list-widget>
@use "../../../../core/dashboard/dashboard-widget-base";
.table-container {
margin-left: 10px;
margin-right: 10px;
}
Legend
Html element with directive