Elffuss BraidHub

kikocis/dataspace-portal public

feat: shareable data offer links (#243)

Co-authored-by: illfixit <66363651+illfixit@users.noreply.github.com>
Changeseted9211a4e64d11972aacce13d25d7f20f937cae3d67ae37c2b4bfc5d82cbaaf1
AuthorKamil Czaja <46053356+kamilczaja@users.noreply.github.com> · 2024-07-22 16:29 +02:00
CommitterGitHub <noreply@github.com> · 2024-07-22 16:29 +02:00
Parents3e1282cf21a3

Browse the files at this changeset

9 files changed

modified CHANGELOG.md +3 −0
@@ -13,6 +13,9 @@
1313
1414 #### Minor
1515
16+- Added unique URLs to data offers that enable direct navigation
17+- Added a button in the data offer detail view to copy the data offer URL
18+
1619 #### Patch
1720 - Fix Catalog UI after Broker intergration [#238](https://github.com/sovity/authority-portal/issues/238)
1821 - Fix deployment environment not syncing in URLs for the catalog
modified authority-portal-frontend/src/app/app-routing.module.ts +20 −0
@@ -149,6 +149,16 @@
149149 requiresRole: ['USER'] satisfies UserRoleDto[],
150150 },
151151 canActivate: [requiresRole],
152+ children: [
153+ {
154+ path: ':connectorId/:assetId',
155+ component: CatalogPageComponent,
156+ data: {
157+ requiresRole: ['USER'] satisfies UserRoleDto[],
158+ },
159+ canActivate: [requiresRole],
160+ },
161+ ],
152162 },
153163 {
154164 path: 'my-organization/data-offers',
@@ -158,6 +168,16 @@
158168 catalogType: 'my-data-offers',
159169 },
160170 canActivate: [requiresRole],
171+ children: [
172+ {
173+ path: ':connectorId/:assetId',
174+ component: CatalogPageComponent,
175+ data: {
176+ requiresRole: ['USER'] satisfies UserRoleDto[],
177+ },
178+ canActivate: [requiresRole],
179+ },
180+ ],
161181 },
162182 {
163183 path: 'control-center',
modified authority-portal-frontend/src/app/pages/catalog-page/asset-detail-dialog/asset-detail-dialog.component.html +20 −17
@@ -1,24 +1,27 @@
11 <div class="p-2">
2- <!-- close button -->
3- <div class="flex w-full justify-end">
4- <button class="!fixed" mat-icon-button mat-dialog-close aria-label="close">
5- <mat-icon>close</mat-icon>
6- </button>
7- </div>
8- <!-- close button -->
9-
102 <!-- Title Section -->
11- <div class="flex flex-col justify-start mt-4 mx-4 lg:mx-8 lg:mt-[3rem]">
12- <h3 class="form-dialog-title">
13- {{ dataOffer.assetTitle }}
3+ <div class="flex flex-row justify-between">
4+ <div class="flex flex-col justify-start mt-4 mx-4 lg:mx-8 lg:mt-[3rem]">
5+ <h3 class="form-dialog-title">
6+ {{ dataOffer.assetTitle }}
147
15- <app-connector-status-led
16- class="inline-flex"
17- [status]="dataOffer.connectorOnlineStatus">
18- </app-connector-status-led>
19- </h3>
20- <p class="form-dialog-prose">{{ dataOffer.organizationName }}</p>
8+ <app-connector-status-led
9+ class="inline-flex"
10+ [status]="dataOffer.connectorOnlineStatus">
11+ </app-connector-status-led>
12+ </h3>
13+ <p class="form-dialog-prose">{{ dataOffer.organizationName }}</p>
14+ </div>
15+ <div class="flex flex-row justify-start mt-4 mx-4 lg:mx-8 lg:mt-[2.5rem]">
16+ <button mat-icon-button (click)="copyUrl()">
17+ <mat-icon>share</mat-icon>
18+ </button>
19+ <button mat-icon-button mat-dialog-close aria-label="close">
20+ <mat-icon>close</mat-icon>
21+ </button>
22+ </div>
2123 </div>
24+
2225 <!-- Title Section -->
2326
2427 <!-- Content Section -->
modified authority-portal-frontend/src/app/pages/catalog-page/asset-detail-dialog/asset-detail-dialog.component.ts +15 −0
@@ -18,6 +18,7 @@
1818 DataOfferDetailPageResult,
1919 UiAsset,
2020 } from '@sovity.de/authority-portal-client';
21+import {ToastService} from '../../../shared/common/toast-notifications/toast.service';
2122 import {PropertyGridGroup} from '../property-grid-group/property-grid-group';
2223 import {AssetDetailDialogData} from './asset-detail-dialog-data';
2324
@@ -44,6 +45,7 @@
4445 constructor(
4546 @Inject(MAT_DIALOG_DATA)
4647 private _data: AssetDetailDialogData | Observable<AssetDetailDialogData>,
48+ private toastService: ToastService,
4749 ) {
4850 if (isObservable(this._data)) {
4951 this._data
@@ -61,6 +63,19 @@
6163 this.propGroups = this.data.propertyGridGroups;
6264 }
6365
66+ copyUrl() {
67+ navigator.clipboard
68+ .writeText(window.location.href)
69+ .then(() => {
70+ this.toastService.showSuccess('Data Offer URL copied to clipboard');
71+ })
72+ .catch(() => {
73+ this.toastService.showSuccess(
74+ 'Failed to copy Data Offer URL to clipboard. Check if your browser permissions allow this action.',
75+ );
76+ });
77+ }
78+
6479 ngOnDestroy$ = new Subject();
6580
6681 ngOnDestroy(): void {
modified authority-portal-frontend/src/app/pages/catalog-page/asset-detail-dialog/asset-detail-dialog.service.ts +16 −2
@@ -13,7 +13,7 @@
1313 import {Injectable} from '@angular/core';
1414 import {MatDialog} from '@angular/material/dialog';
1515 import {NEVER, Observable, takeUntil} from 'rxjs';
16-import {map, switchMap} from 'rxjs/operators';
16+import {catchError, map, switchMap} from 'rxjs/operators';
1717 import {DataOfferDetailPageQuery} from '@sovity.de/authority-portal-client';
1818 import {CatalogApiService} from 'src/app/core/api/catalog-api.service';
1919 import {GlobalStateUtils} from 'src/app/core/global-state/global-state-utils';
@@ -22,6 +22,7 @@
2222 import {AssetDetailDialogData} from './asset-detail-dialog-data';
2323 import {AssetDetailDialogDataService} from './asset-detail-dialog-data.service';
2424 import {AssetDetailDialogComponent} from './asset-detail-dialog.component';
25+import {AssetNotAvailableDialogComponent} from './asset-not-available-dialog/asset-not-available-dialog.component';
2526
2627 @Injectable()
2728 export class AssetDetailDialogService {
@@ -53,8 +54,10 @@
5354 map((result) =>
5455 this.assetDetailDialogDataService.dataOfferDetailPage(result),
5556 ),
56- this.errorService.toastFailureRxjs('Failed to load Data Offer Details'),
5757 switchMap((data) => this.openDialogWithData(data, until$)),
58+ catchError(() => {
59+ return this.openErrorDialog(until$);
60+ }),
5861 );
5962 }
6063
@@ -79,4 +82,15 @@
7982 until$,
8083 );
8184 }
85+
86+ private openErrorDialog(
87+ until$: Observable<any> = NEVER,
88+ ): Observable<undefined> {
89+ return showDialogUntil(
90+ this.dialog,
91+ AssetNotAvailableDialogComponent,
92+ {maxWidth: '600px'},
93+ until$,
94+ );
95+ }
8296 }
added authority-portal-frontend/src/app/pages/catalog-page/asset-detail-dialog/asset-not-available-dialog/asset-not-available-dialog.component.html +16 −0
@@ -0,0 +1,16 @@
1+<div class="flex flex-row">
2+ <div class="flex flex-col justify-start items-start p-6">
3+ <h3 class="text-xl font-bold mb-6 mt-3">Data Offer not found</h3>
4+ <p>
5+ We could not find the data offer you are looking for. The URL you provided
6+ is incorrect or the data offer is no longer available.
7+ </p>
8+ <button
9+ class="btn-accent-outline mt-6 ml-auto"
10+ type="button"
11+ mat-dialog-close
12+ (click)="closeDialog()">
13+ Close
14+ </button>
15+ </div>
16+</div>
added authority-portal-frontend/src/app/pages/catalog-page/asset-detail-dialog/asset-not-available-dialog/asset-not-available-dialog.component.ts +24 −0
@@ -0,0 +1,24 @@
1+import {Component, OnDestroy} from '@angular/core';
2+import {MatDialogRef} from '@angular/material/dialog';
3+import {Subject} from 'rxjs';
4+
5+@Component({
6+ selector: 'app-asset-not-available-dialog',
7+ templateUrl: './asset-not-available-dialog.component.html',
8+})
9+export class AssetNotAvailableDialogComponent implements OnDestroy {
10+ constructor(
11+ private dialogRef: MatDialogRef<AssetNotAvailableDialogComponent>,
12+ ) {}
13+
14+ closeDialog(): void {
15+ this.dialogRef.close();
16+ }
17+
18+ ngOnDestroy$ = new Subject();
19+
20+ ngOnDestroy(): void {
21+ this.ngOnDestroy$.next(null);
22+ this.ngOnDestroy$.complete();
23+ }
24+}
modified authority-portal-frontend/src/app/pages/catalog-page/catalog-page/catalog-page.component.ts +43 −3
@@ -19,9 +19,9 @@
1919 } from '@angular/core';
2020 import {FormControl} from '@angular/forms';
2121 import {PageEvent} from '@angular/material/paginator';
22-import {ActivatedRoute, Params} from '@angular/router';
22+import {ActivatedRoute, Router} from '@angular/router';
2323 import {Subject, distinctUntilChanged, of, switchMap, tap} from 'rxjs';
24-import {map, take, takeUntil} from 'rxjs/operators';
24+import {finalize, map, take, takeUntil} from 'rxjs/operators';
2525 import {Store} from '@ngxs/store';
2626 import {
2727 CatalogDataOffer,
@@ -69,6 +69,7 @@
6969 private assetDetailDialogService: AssetDetailDialogService,
7070 private store: Store,
7171 private route: ActivatedRoute,
72+ private router: Router,
7273 private globalStateUtils: GlobalStateUtils,
7374 private deploymentEnvironmentUrlSyncService: DeploymentEnvironmentUrlSyncService,
7475 ) {}
@@ -87,6 +88,7 @@
8788 this.startListeningToEnvironmentChanges();
8889 this.startEmittingSearchText();
8990 this.startEmittingSortBy();
91+ this.openDataOfferDetailDialogOnceFromUrl();
9092 }
9193
9294 private initializePage() {
@@ -115,6 +117,14 @@
115117 });
116118 }
117119
120+ private openDataOfferDetailDialogOnceFromUrl() {
121+ const params = this.route.firstChild?.snapshot.params;
122+ if (params) {
123+ console.log('PARAMS ' + params['connectorId'] + ' ' + params['assetId']);
124+ this.openDataOfferDialog(params['assetId'], params['connectorId']);
125+ }
126+ }
127+
118128 private startListeningToStore() {
119129 this.store
120130 .select<CatalogPageStateModel>(CatalogPageState)
@@ -155,9 +165,39 @@
155165 }
156166
157167 onDataOfferClick(dataOffer: CatalogDataOffer) {
168+ this.openDataOfferDialog(dataOffer.assetId, dataOffer.connectorId);
169+ }
170+
171+ private openDataOfferDialog(assetId: string, connectorId: string) {
158172 this.assetDetailDialogService
159- .open(dataOffer.assetId, dataOffer.connectorId, this.ngOnDestroy$)
173+ .open(assetId, connectorId, this.ngOnDestroy$)
174+ .pipe(
175+ finalize(() => {
176+ this.changeUrlToCatalogRoot();
177+ }),
178+ )
160179 .subscribe();
180+
181+ this.router.navigate([connectorId, assetId], {
182+ relativeTo: this.route,
183+ queryParams: {
184+ environmentId: this.route.snapshot.queryParams.environmentId,
185+ },
186+ });
187+ // BreadcrumbService builds the name from the URL which is nonsensical in casse of asset IDs
188+ document.title = 'MDS Catalog - Data Offer';
189+ }
190+
191+ private changeUrlToCatalogRoot() {
192+ const currentRoute = this.route.snapshot;
193+ this.router.navigate(
194+ [currentRoute.url.map((segment) => segment.path).join('/')],
195+ {
196+ queryParams: {
197+ environmentId: currentRoute.queryParams.environmentId,
198+ },
199+ },
200+ );
161201 }
162202
163203 ngOnDestroy$ = new Subject();
modified authority-portal-frontend/src/app/shared/common/toast-notifications/toast-notifications.component.html +1 −1
@@ -1,4 +1,4 @@
1-<div class="flex flex-col fixed items-end right-3 top-3 space-y-2 z-50">
1+<div class="flex flex-col fixed items-end right-3 top-3 space-y-2 z-[9999]">
22 <div
33 *ngFor="let toast of toasts; trackBy: trackByFn"
44 class="flex flex-row items-center bg-white rounded-lg shadow-lg overflow-hidden p-2 max-h-12 border w-fit animate-showNotification"