From d74470311a658de9dd035b01e1be408affda532e Mon Sep 17 00:00:00 2001 From: Christophe Loiseau Date: Wed, 7 Aug 2024 09:30:58 +0200 Subject: [PATCH] feat: fetch a single contract agreement (#782) --- CHANGELOG.md | 1 + package-lock.json | 14 +++++++------- package.json | 2 +- src/app/core/services/api/edc-api.service.ts | 16 +++------------- .../api/fake-backend/edc-fake-backend.ts | 8 ++++++++ 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08e734ca7..70a385b87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ the detailed section referring to by linking pull requests or issues. - Copyable contact email and subject fields on asset and data offer detail dialogs - Assets Page search input field is now case insensitive +- Performance improvement when fetching a single contract agreement - Temporary reimplement the Edit Asset as a Dialog ## [v4.1.0] - 2024-07-24 diff --git a/package-lock.json b/package-lock.json index 05e1ccd51..055d5becb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "@angular/router": "^14.3.0", "@ng-apimock/core": "^3.11.0", "@ngxs/store": "^3.8.1", - "@sovity.de/edc-client": "0.20240719.91939-main-f62d9761", + "@sovity.de/edc-client": "0.20240805.72446-main-4f0ae71b", "clean-deep": "^3.4.0", "date-fns": "^2.30.0", "date-fns-tz": "^2.0.1", @@ -3574,9 +3574,9 @@ "dev": true }, "node_modules/@sovity.de/edc-client": { - "version": "0.20240719.91939-main-f62d9761", - "resolved": "https://registry.npmjs.org/@sovity.de/edc-client/-/edc-client-0.20240719.91939-main-f62d9761.tgz", - "integrity": "sha512-ZKPZh8QoXZV82EYn9IqQNZ7rNmIChCsI9HPze2H9xWTfv3v1NJ9OuItciBg61BGzbhKozxp84oWDRcjWFaNzqw==", + "version": "0.20240805.72446-main-4f0ae71b", + "resolved": "https://registry.npmjs.org/@sovity.de/edc-client/-/edc-client-0.20240805.72446-main-4f0ae71b.tgz", + "integrity": "sha512-TLwikNivrsUmiVNFDqHvjVsojuNXVWxMogtFfaujLURflAL9+s/XGJ1eBZPaAMhmeRFfeqEGhrtI8RD4xtc1jg==", "dependencies": { "zod": "^3.22.4" } @@ -16640,9 +16640,9 @@ "dev": true }, "@sovity.de/edc-client": { - "version": "0.20240719.91939-main-f62d9761", - "resolved": "https://registry.npmjs.org/@sovity.de/edc-client/-/edc-client-0.20240719.91939-main-f62d9761.tgz", - "integrity": "sha512-ZKPZh8QoXZV82EYn9IqQNZ7rNmIChCsI9HPze2H9xWTfv3v1NJ9OuItciBg61BGzbhKozxp84oWDRcjWFaNzqw==", + "version": "0.20240805.72446-main-4f0ae71b", + "resolved": "https://registry.npmjs.org/@sovity.de/edc-client/-/edc-client-0.20240805.72446-main-4f0ae71b.tgz", + "integrity": "sha512-TLwikNivrsUmiVNFDqHvjVsojuNXVWxMogtFfaujLURflAL9+s/XGJ1eBZPaAMhmeRFfeqEGhrtI8RD4xtc1jg==", "requires": { "zod": "^3.22.4" } diff --git a/package.json b/package.json index 677dc2a24..bd158ae1e 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "@angular/router": "^14.3.0", "@ng-apimock/core": "^3.11.0", "@ngxs/store": "^3.8.1", - "@sovity.de/edc-client": "0.20240719.91939-main-f62d9761", + "@sovity.de/edc-client": "0.20240805.72446-main-4f0ae71b", "clean-deep": "^3.4.0", "date-fns": "^2.30.0", "date-fns-tz": "^2.0.1", diff --git a/src/app/core/services/api/edc-api.service.ts b/src/app/core/services/api/edc-api.service.ts index fcd3be5cb..122f9ff88 100644 --- a/src/app/core/services/api/edc-api.service.ts +++ b/src/app/core/services/api/edc-api.service.ts @@ -1,6 +1,5 @@ import {Inject, Injectable} from '@angular/core'; import {Observable} from 'rxjs'; -import {map} from 'rxjs/operators'; import { AssetPage, ConnectorLimits, @@ -29,7 +28,7 @@ import { buildEdcClient, } from '@sovity.de/edc-client'; import {APP_CONFIG, AppConfig} from '../../config/app-config'; -import {throwIfNull, toObservable} from '../../utils/rxjs-utils'; +import {toObservable} from '../../utils/rxjs-utils'; import {EDC_FAKE_BACKEND} from './fake-backend/edc-fake-backend'; @Injectable({providedIn: 'root'}) @@ -179,17 +178,8 @@ export class EdcApiService { getContractAgreementById( contractAgreementId: string, ): Observable { - return this.getContractAgreementPage({ - contractAgreementPageQuery: {terminationStatus: undefined}, - }).pipe( - map((page) => - page.contractAgreements.find( - (it) => it.contractAgreementId === contractAgreementId, - ), - ), - throwIfNull( - `Contract Agreement with ID ${contractAgreementId} not found`, - ), + return toObservable(() => + this.edcClient.uiApi.getContractAgreementCard({contractAgreementId}), ); } diff --git a/src/app/core/services/api/fake-backend/edc-fake-backend.ts b/src/app/core/services/api/fake-backend/edc-fake-backend.ts index c58c18218..305ab99fe 100644 --- a/src/app/core/services/api/fake-backend/edc-fake-backend.ts +++ b/src/app/core/services/api/fake-backend/edc-fake-backend.ts @@ -191,6 +191,14 @@ export const EDC_FAKE_BACKEND: FetchAPI = async ( return ok(ContractAgreementPageToJSON(page)); }) + .url('ui/pages/contract-agreement-page/*') + .on('GET', (contractAgreementId: String) => { + return ok( + contractAgreementPage().contractAgreements + .find( (contractAgreement) => contractAgreement.contractAgreementId === contractAgreementId) + ); + }) + .url('ui/pages/content-agreement-page/*/terminate') .on('POST', (contractAgreementId) => { const request = ContractTerminationRequestFromJSON(body);