Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrating transfer history page to api wrapper #351

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bc44910
feat: migrating transfer history page to api wrapper
AnurosePrakash Jul 12, 2023
4a11203
chore: run format and cleaned test data
AnurosePrakash Jul 12, 2023
585aa20
Merge branch 'main' into feat/transfer_history_page_migrations_to_api…
AnurosePrakash Jul 19, 2023
b254b76
chore: minor type additions and removing blank lines
AnurosePrakash Jul 19, 2023
4dfa4c5
feat: migrating transfer history page to api wrapper
AnurosePrakash Jul 12, 2023
5e7b91a
chore: run format and cleaned test data
AnurosePrakash Jul 12, 2023
50cff68
chore: minor type additions and removing blank lines
AnurosePrakash Jul 19, 2023
344a48a
chore: update in the edc-api.service.ts to consume new wrapper endpoints
AnurosePrakash Aug 8, 2023
ec28f36
Merge remote-tracking branch 'origin/feat/transfer_history_page_migra…
AnurosePrakash Aug 8, 2023
f796b4c
chore: updated the test data and renamed transfer history page object…
AnurosePrakash Aug 8, 2023
a1a0702
chore: minor refactorings - renaming variables and removing unwanted …
AnurosePrakash Aug 10, 2023
2bd44f3
Merge branch 'main' into feat/transfer_history_page_migrations_to_api…
AnurosePrakash Aug 11, 2023
aa248a3
chore: adding icons as per transfer process states and minor refactor…
AnurosePrakash Aug 14, 2023
6728faa
Merge branch 'main' into feat/transfer_history_page_migrations_to_api…
AnurosePrakash Aug 14, 2023
4d691c6
Merge branch 'main' of https://github.com/sovity/edc-ui into feat/tra…
AnurosePrakash Aug 14, 2023
975d288
Merge remote-tracking branch 'origin/feat/transfer_history_page_migra…
AnurosePrakash Aug 14, 2023
52dd8f9
fix: invalid date in test data
richardtreier Aug 14, 2023
24f5007
fix: dialog headers not working in transfer history page
richardtreier Aug 14, 2023
a70cfc3
Merge remote-tracking branch 'origin/feat/transfer_history_page_migra…
AnurosePrakash Aug 14, 2023
a9a8b4b
chore: adding polling to the transfer history page
AnurosePrakash Aug 14, 2023
0b092b7
chore: updating the dashboard page component to get data from transfe…
AnurosePrakash Aug 14, 2023
dbbb1f2
chore: updating icons on transfer-history-page.component.html
AnurosePrakash Aug 14, 2023
acadb0f
fix: issues with contract agreement page's asset detail dialog
richardtreier Aug 14, 2023
132b00d
chore: fix formatDateAgo nullability
richardtreier Aug 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ the detailed section referring to by linking pull requests or issues.

#### Changed

- Migrated transfer history page to api wrapper

#### Removed

#### Fixed
Expand Down
21 changes: 21 additions & 0 deletions fake-backend/json/transferHistoryAssetDetails.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"properties": {
"asset:prop:id": "urn:artifact:test-asset-1",
"asset:prop:name": "Test Asset 1",
"asset:prop:version": "1.1",
"asset:prop:originator": "https://example-connector.de/api/v1/ids/data",
"asset:prop:originatorOrganization": "Organization",
"asset:prop:keywords": "test, example",
"asset:prop:contenttype": "application/json",
"asset:prop:description": "Test asset for checking asset fetch in transfer history page",
"asset:prop:language": "https://w3id.org/idsa/code/EN",
"asset:prop:publisher": "https://my.cool-api.gg/about",
"asset:prop:standardLicense": "https://my.cool-api.gg/license",
"asset:prop:endpointDocumentation": "https://my.cool-api.gg/docs",
"http://w3id.org/mds#dataCategory": "Example",
"http://w3id.org/mds#dataSubcategory": "example-data",
"http://w3id.org/mds#dataModel": "data-model-001",
"http://w3id.org/mds#geoReferenceMethod": "example-reference-method",
"http://w3id.org/mds#transportMode": "Mode"
}
}
154 changes: 38 additions & 116 deletions fake-backend/json/transferProcess.json
Original file line number Diff line number Diff line change
@@ -1,128 +1,50 @@
[
{
"createdAt": 1675344948954,
"updatedAt": 1675344960579,
"id": "be0cac12-bb43-420e-aa29-d66bb3d0e0ac",
"type": "CONSUMER",
"state": "ERROR",
"stateTimestamp": 1675344960579,
"errorDetail": "TransferProcessManager: attempt #8 failed to send transfer. Retry limit exceeded, TransferProcess 1317d0da-cdc6-42ab-b54b-1f90bcfed508 moves to ERROR state. Cause: java.net.SocketException: Connection reset",
"dataRequest": {
"id": "c9fec9a2-1243-4738-9576-d70bf4558687",
"assetId": "urn:artifact:example-asset",
"contractId": "my-data-offer:5816a60b-86c1-489a-b26a-ed129947f973",
"connectorId": "consumer"
},
"dataDestination": {
"properties": {
"baseUrl": "https://webhook.site/ab9ba683-77d3-4d66-9c79-03b9724927eb",
"type": "HttpData"
}
}
},
{
"createdAt": 1675346050941,
"updatedAt": 1675346062120,
"id": "81cdf4cf-8427-480f-9662-8a29d66ddd3b",
"type": "CONSUMER",
"state": "COMPLETED",
"stateTimestamp": 1675346062120,
"errorDetail": null,
"dataRequest": {
"id": "92658c7a-9485-421f-a4be-ab186e7b190e",
"assetId": "urn:artifact:example-asset",
"contractId": "my-data-offer:5816a60b-86c1-489a-b26a-ed129947f973",
"connectorId": "consumer"
},
"dataDestination": {
"properties": {
"baseUrl": "asd",
"type": "HttpData"
}
}
},
{
"createdAt": 1675346295640,
"updatedAt": 1675346304201,
"id": "339b2a27-3b66-49f5-8b43-6a400d5914b5",
"type": "CONSUMER",
"transferProcessId": "339b2a27-3b66-49f5-8b43-6a400d5914b5",
"createdDate": "2022-01-20T11:18:59.659Z",
"lastUpdatedDate": "2022-06-25T11:18:59.659Z",
"state": "COMPLETED",
"stateTimestamp": 1675346304201,
"errorDetail": null,
"dataRequest": {
"id": "101eb0ff-8a1c-4879-a9d3-02a378a4f7c7",
"assetId": "urn:artifact:example-asset",
"contractId": "my-data-offer:5816a60b-86c1-489a-b26a-ed129947f973",
"connectorId": "consumer"
},
"dataDestination": {
"properties": {
"baseUrl": "https://webhook.site/ab9ba683-77d3-4d66-9c79-03b9724927eb",
"type": "HttpData"
}
}
"contractAgreementId": "test-asset-1-cd:f52a5d30-6356-4a55-a75a-3c45d7a88c3e",
"direction": "outgoing",
"counterPartyConnectorEndpoint": "https://sovity-demo4-mds/api/v1/ids/data",
"assetName": "Test Asset 1",
"assetId": "urn:artifact:test-asset-1",
"errorMessage": null
},
{
"createdAt": 1675346968148,
"updatedAt": 1675346969520,
"id": "47240a35-d8fc-41d9-b020-07b87f3cc7b6",
"type": "PROVIDER",
"state": "IN_PROGRESS",
"stateTimestamp": 1675346969520,
"errorDetail": null,
"dataRequest": {
"id": "de881e9a-3ea8-4f05-9318-1aef45601581",
"assetId": "urn:artifact:pallene-asset",
"contractId": "pallene-asset-def:80de309c-0f0a-4eaf-a169-727c0ca6575b",
"connectorId": "urn:connector:edc"
},
"dataDestination": {
"properties": {
"baseUrl": "https://webhook.site/ab9ba683-77d3-4d66-9c79-03b9724927eb",
"type": "HttpData"
}
}
"transferProcessId": "1317d0da-cdc6-42ab-b54b-1f90bcfed508",
"createdDate": "2022-03-20T11:18:59.659Z",
"lastUpdatedDate": "2022-03-25T11:18:59.659Z",
"state": "ERROR",
"contractAgreementId": "test-asset-2-cd:5816a60b-86c1-489a-b26a-ed129947f973",
"direction": "outgoing",
"counterPartyConnectorEndpoint": "http://edc2:11003/api/v1/ids/data",
"assetName": "Test Asset 2",
"assetId": "urn:artifact:test-asset-2",
"errorMessage": "TransferProcessManager: attempt #8 failed to send transfer. Retry limit exceeded, TransferProcess 1317d0da-cdc6-42ab-b54b-1f90bcfed508 moves to ERROR state. Cause: java.net.SocketException: Connection reset"
},
{
"createdAt": 1675346958929,
"updatedAt": 1675347017414,
"id": "8a31794f-d6be-449a-a037-eed8c63424df",
"type": "CONSUMER",
"state": "ERROR",
"stateTimestamp": 1675347017414,
"errorDetail": "TransferProcessManager: attempt #8 failed to send transfer. Retry limit exceeded, TransferProcess 8a31794f-d6be-449a-a037-eed8c63424df moves to ERROR state. Cause: org.eclipse.edc.spi.EdcException: Received class de.fraunhofer.iais.eis.RejectionMessageImpl but expected [class de.fraunhofer.iais.eis.RequestInProcessMessageImpl].",
"dataRequest": {
"id": "ba2dca23-ed46-496e-b121-1556958a7ec6",
"assetId": "urn:artifact:pallene-asset",
"contractId": "pallene-asset-def:80de309c-0f0a-4eaf-a169-727c0ca6575b",
"connectorId": "consumer"
},
"dataDestination": {
"properties": {
"baseUrl": "https://webhook.site/ab9ba683-77d3-4d66-9c79-03b9724927eb",
"type": "HttpData"
}
}
"transferProcessId": "81cdf4cf-8427-480f-9662-8a29d66ddd3b",
"createdDate": "2022-03-25T11:18:59.659Z",
"lastUpdatedDate": "2022-11-20T11:18:59.659Z",
"state": "COMPLETED",
"contractAgreementId": "test-asset-3-cd:6ebbc301-9b1e-4cd7-9f17-97b5b7867531",
"direction": "incoming",
"counterPartyConnectorEndpoint": "https://sovity-demo2-edc/api/v1/ids/data",
"assetName": "Test Asset 3",
"assetId": "urn:artifact:test-asset-3",
"errorMessage": null
},
{
"createdAt": 1675347001981,
"updatedAt": 1675347005464,
"id": "d25328ce-bbf4-4623-991b-63b2b529f259",
"type": "PROVIDER",
"transferProcessId": "47240a35-d8fc-41d9-b020-07b87f3cc7b6",
"createdDate": "2023-01-29T11:18:59.659Z",
"lastUpdatedDate": "2023-02-29T11:18:59.659Z",
"state": "IN_PROGRESS",
"stateTimestamp": 1675347005464,
"errorDetail": null,
"dataRequest": {
"id": "7cf62113-67e8-4e17-935c-14ba0e2592d6",
"assetId": "urn:artifact:pallene-asset",
"contractId": "pallene-asset-def:80de309c-0f0a-4eaf-a169-727c0ca6575b",
"connectorId": "urn:connector:edc"
},
"dataDestination": {
"properties": {
"baseUrl": "https://webhook.site/ab9ba683-77d3-4d66-9c79-03b9724927eb",
"type": "HttpData"
}
}
"contractAgreementId": "test-asset-4-cd:f52a5d30-6356-4a55-a75a-3c45d7a88c3e",
"direction": "outgoing",
"counterPartyConnectorEndpoint": "https://sovity-demo2-edc/api/v1/ids/data",
"assetName": "Test Asset 4",
"assetId": "urn:artifact:test-asset-4",
"errorMessage": null
}
]
10 changes: 10 additions & 0 deletions fake-backend/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ app.get('/api/v1/data/last-commit-info', (req, res) => {
res.json(lastCommitInfo);
});

const transferHistoryAssetDetails = json(
'json/transferHistoryAssetDetails.json',
);
app.get(
'/api/v1/data/transfer-history-page/transfer-processes/339b2a27-3b66-49f5-8b43-6a400d5914b5/asset',
(req, res) => {
res.json(transferHistoryAssetDetails);
},
);

const catalog1 = json('json/catalog1.json');
const catalog2 = json('json/catalog2.json');
app.get('/api/v1/data/catalog', (req, res) => {
Expand Down
2 changes: 2 additions & 0 deletions src/app/component-library/ui-elements/ago/date-input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type DateInput = Date | string | null
AnurosePrakash marked this conversation as resolved.
Show resolved Hide resolved

7 changes: 5 additions & 2 deletions src/app/component-library/ui-elements/ago/formatDateAgo.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import {formatDistanceToNow} from 'date-fns';
import {DateInput} from "./date-input";

/**
* Formats date as "{n} {timeUnit} ago" or "in {n} {timeUnit}s".
* @param date date
*/
export function formatDateAgo(date?: Date | null): string {
export function formatDateAgo(date?: DateInput): string {
if (!date) {
return '';
}

if (typeof date === 'string') {
date = new Date(date);
}
return formatDistanceToNow(date, {addSuffix: true});
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import {
} from '@angular/common/http';
import {Inject, Injectable, Optional} from '@angular/core';
import {Observable} from 'rxjs';
// @ts-ignore
import {TransferProcessDto} from '../../../../core/services/models/transfer-history-entry';
import {Configuration} from '../configuration';
import {CustomHttpParameterCodec} from '../encoder';
// @ts-ignore
import {TransferId} from '../model/transferId';
// @ts-ignore
import {TransferProcessDto} from '../model/transferProcessDto';
// @ts-ignore
import {TransferRequestDto} from '../model/transferRequestDto';
// @ts-ignore
import {TransferState} from '../model/transferState';
Expand Down
12 changes: 12 additions & 0 deletions src/app/core/services/models/transfer-history-entry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export interface TransferProcessDto {
id: string;
createdDate: Date;
lastUpdatedDate: Date;
state: string;
contractAgreementId: string;
direction: string;
counterPartyConnectorEndpoint: string;
assetName: string;
assetId: string;
errorMessage?: string;
}
22 changes: 22 additions & 0 deletions src/app/core/services/transfer-process-asset-details.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {HttpClient} from '@angular/common/http';
import {Inject, Injectable} from '@angular/core';
import {Observable} from 'rxjs';
import {APP_CONFIG, AppConfig} from '../config/app-config';
import {AssetDto} from './models/asset-dto';

@Injectable({
providedIn: 'root',
})
export class TransferProcessAssetDetailsService {
constructor(
private http: HttpClient,
@Inject(APP_CONFIG) public config: AppConfig,
) {}

getTransferProcessAssetDetails(
transferProcessId: string,
): Observable<AssetDto> {
const url = `${this.config.managementApiUrl}/transfer-history-page/transfer-processes/${transferProcessId}/asset`;
return this.http.get<AssetDto>(url);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {ContractAgreementCardMapped} from '../contract-agreement-cards/contract-
import {ContractAgreementCardMappedService} from '../contract-agreement-cards/contract-agreement-card-mapped.service';
import {ContractAgreementPageData} from './contract-agreement-page.data';


@Injectable({providedIn: 'root'})
export class ContractAgreementPageService {
constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import {
ContractAgreementService,
ContractDefinitionService,
PolicyService,
TransferProcessDto,
TransferProcessService,
} from '../../../../core/services/api/legacy-managent-api-client';
import {ConnectorInfoPropertyGridGroupBuilder} from '../../../../core/services/connector-info-property-grid-group-builder';
import {LastCommitInfoService} from '../../../../core/services/last-commit-info.service';
import {Fetched} from '../../../../core/services/models/fetched';
import {TransferProcessDto} from '../../../../core/services/models/transfer-history-entry';
import {TransferProcessStates} from '../../../../core/services/models/transfer-process-states';
import {TransferProcessUtils} from '../../../../core/services/transfer-process-utils';
import {DonutChartData} from '../dashboard-donut-chart/donut-chart-data';
import {DashboardPageData, defaultDashboardData} from './dashboard-page-data';

Expand All @@ -29,7 +28,6 @@ export class DashboardPageDataService {
private catalogApiUrlService: CatalogApiUrlService,
private transferProcessService: TransferProcessService,
private assetService: AssetService,
private transferProcessUtils: TransferProcessUtils,
private lastCommitInfoService: LastCommitInfoService,
private connectorInfoPropertyGridGroupBuilder: ConnectorInfoPropertyGridGroupBuilder,
) {}
Expand Down Expand Up @@ -141,8 +139,8 @@ export class DashboardPageDataService {
): DonutChartData {
const filteredTransfers =
direction === 'incoming'
? transfers.filter((it) => this.transferProcessUtils.isIncoming(it))
: transfers.filter((it) => this.transferProcessUtils.isOutgoing(it));
? transfers.filter((it) => it.direction === 'incoming')
: transfers.filter((it) => it.direction === 'outgoing');
AnurosePrakash marked this conversation as resolved.
Show resolved Hide resolved

// Use the keys of the TransferProcessesStates Enum as order
const order = Object.keys(TransferProcessStates);
AnurosePrakash marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {MatIconModule} from '@angular/material/icon';
import {MatPaginatorModule} from '@angular/material/paginator';
import {MatTableModule} from '@angular/material/table';
import {RouterModule} from '@angular/router';
import {CatalogModule} from '../../../component-library/catalog/catalog.module';
import {PipesAndDirectivesModule} from '../../../component-library/pipes-and-directives/pipes-and-directives.module';
import {UiElementsModule} from '../../../component-library/ui-elements/ui-elements.module';
import {TransferHistoryPageComponent} from './transfer-history-page/transfer-history-page.component';
Expand All @@ -25,6 +26,7 @@ import {TransferHistoryPageComponent} from './transfer-history-page/transfer-his
MatIconModule,

// EDC UI Modules
CatalogModule,
PipesAndDirectivesModule,
UiElementsModule,
],
Expand Down
Loading