From 374bb3c90cc75ea05d3f52eb0a06641e357f945b Mon Sep 17 00:00:00 2001 From: Sebastian Leidig Date: Fri, 28 Jun 2024 16:05:51 +0200 Subject: [PATCH] fix: revert problematic copiable links and add copy button to shortcut widget see #1217 --- .../shortcut-dashboard.component.html | 26 +++++++++++++------ .../shortcut-dashboard.component.ts | 25 +++++++++++++++++- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/app/features/dashboard-widgets/shortcut-dashboard-widget/shortcut-dashboard/shortcut-dashboard.component.html b/src/app/features/dashboard-widgets/shortcut-dashboard-widget/shortcut-dashboard/shortcut-dashboard.component.html index e0e0e6c99f..d98bf1f2fe 100644 --- a/src/app/features/dashboard-widgets/shortcut-dashboard-widget/shortcut-dashboard/shortcut-dashboard.component.html +++ b/src/app/features/dashboard-widgets/shortcut-dashboard-widget/shortcut-dashboard/shortcut-dashboard.component.html @@ -16,21 +16,31 @@ Label - + - {{ row.label }} + + {{ row.label }} + + + + + + + - + diff --git a/src/app/features/dashboard-widgets/shortcut-dashboard-widget/shortcut-dashboard/shortcut-dashboard.component.ts b/src/app/features/dashboard-widgets/shortcut-dashboard-widget/shortcut-dashboard/shortcut-dashboard.component.ts index 8cc85cd487..738c19e6ea 100644 --- a/src/app/features/dashboard-widgets/shortcut-dashboard-widget/shortcut-dashboard/shortcut-dashboard.component.ts +++ b/src/app/features/dashboard-widgets/shortcut-dashboard-widget/shortcut-dashboard/shortcut-dashboard.component.ts @@ -6,6 +6,12 @@ import { FaDynamicIconComponent } from "../../../../core/common-components/fa-dy 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. @@ -20,6 +26,9 @@ import { RoutePermissionsService } from "../../../../core/config/dynamic-routing MatTableModule, FaDynamicIconComponent, RouterLink, + FaIconComponent, + MatIconButton, + MatTooltip, ], standalone: true, }) @@ -35,5 +44,19 @@ export class ShortcutDashboardComponent { } _shortcuts: MenuItem[] = []; - constructor(private routePermissionsService: RoutePermissionsService) {} + constructor( + private routePermissionsService: RoutePermissionsService, + private locationStrategy: LocationStrategy, + private clipboard: Clipboard, + private alertService: AlertService, + ) {} + + 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); + } + } }