Skip to content

Commit

Permalink
chore: updated the test data and renamed transfer history page object…
Browse files Browse the repository at this point in the history
…s in the transfer-history-page.component
  • Loading branch information
AnurosePrakash committed Aug 8, 2023
1 parent ec28f36 commit f796b4c
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 161 deletions.
68 changes: 68 additions & 0 deletions fake-backend/json/transferHistoryPage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"transferEntries": [
{
"transferProcessId": "339b2a27-3b66-49f5-8b43-6a400d5914b5",
"createdDate": "2022-01-20T11:18:59.659Z",
"lastUpdatedDate": "2022-06-25T11:18:59.659Z",
"state": {
"code": 800,
"name": "COMPLETED",
"simplifiedState": "OK"
},
"contractAgreementId": "test-asset-1-cd:f52a5d30-6356-4a55-a75a-3c45d7a88c3e",
"direction": "CONSUMING",
"counterPartyConnectorEndpoint": "https://sovity-demo4-mds/api/v1/ids/data",
"assetName": "Test Asset 1",
"assetId": "urn:artifact:test-asset-1",
"errorMessage": null
},
{
"transferProcessId": "1317d0da-cdc6-42ab-b54b-1f90bcfed508",
"createdDate": "2022-03-20T11:18:59.659Z",
"lastUpdatedDate": "2022-03-25T11:18:59.659Z",
"state": {
"code": -1,
"name": "ERROR",
"simplifiedState": "ERROR"
},
"contractAgreementId": "test-asset-2-cd:5816a60b-86c1-489a-b26a-ed129947f973",
"direction": "CONSUMING",
"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"
},
{
"transferProcessId": "81cdf4cf-8427-480f-9662-8a29d66ddd3b",
"createdDate": "2022-03-25T11:18:59.659Z",
"lastUpdatedDate": "2022-11-20T11:18:59.659Z",
"state": {
"code": 800,
"name": "COMPLETED",
"simplifiedState": "OK"
},
"contractAgreementId": "test-asset-3-cd:6ebbc301-9b1e-4cd7-9f17-97b5b7867531",
"direction": "CONSUMING",
"counterPartyConnectorEndpoint": "https://sovity-demo2-edc/api/v1/ids/data",
"assetName": "Test Asset 3",
"assetId": "urn:artifact:test-asset-3",
"errorMessage": null
},
{
"transferProcessId": "47240a35-d8fc-41d9-b020-07b87f3cc7b6",
"createdDate": "2023-01-29T11:18:59.659Z",
"lastUpdatedDate": "2023-02-29T11:18:59.659Z",
"state": {
"code": 600,
"name": "IN_PROGRESS",
"simplifiedState": "RUNNING"
},
"contractAgreementId": "test-asset-4-cd:f52a5d30-6356-4a55-a75a-3c45d7a88c3e",
"direction": "PROVIDING",
"counterPartyConnectorEndpoint": "https://sovity-demo2-edc/api/v1/ids/data",
"assetName": "Test Asset 4",
"assetId": "urn:artifact:test-asset-4",
"errorMessage": null
}
]
}
50 changes: 0 additions & 50 deletions fake-backend/json/transferProcess.json

This file was deleted.

30 changes: 15 additions & 15 deletions fake-backend/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ app.get('/api/v1/data/contractdefinitions', (req, res) => {
res.json(contractDefinitions);
});

const transferProcess = json('json/transferProcess.json');
app.get('/api/v1/data/transferprocess', (req, res) => {
res.json(transferProcess);
});

const contractAgreements = json('json/contractAgreements.json');
app.get('/api/v1/data/contractagreements', (req, res) => {
res.json(contractAgreements);
Expand All @@ -73,16 +68,6 @@ 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 Expand Up @@ -116,6 +101,21 @@ app.get('/api/v1/data/wrapper/ui/pages/contract-agreement-page', (_, res) => {
res.json(contractAgreementPage);
});

const transferProcess = json('json/transferHistoryPage.json');
app.get('/api/v1/data/wrapper/ui/pages/transfer-history-page', (req, res) => {
res.json(transferProcess);
});

const transferHistoryAssetDetails = json(
'json/transferHistoryAssetDetails.json',
);
app.get(
'/api/v1/data/wrapper/ui/pages/transfer-history-page/transfer-processes/47240a35-d8fc-41d9-b020-07b87f3cc7b6/asset',
(req, res) => {
res.json(transferHistoryAssetDetails);
},
);

// Connector Limits
const connectorLimits = json('json/connectorLimits.json');
app.get('/api/v1/data/wrapper/ee/connector-limits', (_, res) => {
Expand Down
12 changes: 0 additions & 12 deletions src/app/core/services/models/transfer-history-entry.ts

This file was deleted.

22 changes: 0 additions & 22 deletions src/app/core/services/transfer-process-asset-details.service.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class ContractAgreementTransferDialogComponent implements OnDestroy {
type: 'PARAMS_ONLY',
params: {
contractAgreementId: this.data.contractId,
properties: transferRequestProperties,
privateProperties: transferRequestProperties,
dataSinkProperties,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ import {
ContractAgreementService,
ContractDefinitionService,
PolicyService,
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 {DonutChartData} from '../dashboard-donut-chart/donut-chart-data';
import {DashboardPageData, defaultDashboardData} from './dashboard-page-data';
import {EdcApiService} from "../../../../core/services/api/edc-api.service";
import {TransferHistoryEntry} from "@sovity.de/edc-client";

@Injectable({providedIn: 'root'})
export class DashboardPageDataService {
constructor(
private edcApiService: EdcApiService,
private catalogBrowserService: ContractOfferService,
private contractDefinitionService: ContractDefinitionService,
private contractAgreementService: ContractAgreementService,
private policyService: PolicyService,
private catalogApiUrlService: CatalogApiUrlService,
private transferProcessService: TransferProcessService,
private assetService: AssetService,
private lastCommitInfoService: LastCommitInfoService,
private connectorInfoPropertyGridGroupBuilder: ConnectorInfoPropertyGridGroupBuilder,
Expand Down Expand Up @@ -116,35 +116,34 @@ export class DashboardPageDataService {
}

private transferProcessKpis(): Observable<Partial<DashboardPageData>> {
return this.transferProcessService
.getAllTransferProcesses(0, 10_000_000)
return this.edcApiService.getTransferHistoryPage()
.pipe(
Fetched.wrap({
failureMessage: 'Failed fetching transfer processes.',
}),
map((transferData) => ({
incomingTransfersChart: transferData.map((it) =>
this.buildTransferChart(it, 'incoming'),
this.buildTransferChart(it.transferEntries, 'CONSUMING'),
),
outgoingTransfersChart: transferData.map((it) =>
this.buildTransferChart(it, 'outgoing'),
this.buildTransferChart(it.transferEntries, 'PROVIDING'),
),
})),
);
}

private buildTransferChart(
transfers: TransferProcessDto[],
direction: 'incoming' | 'outgoing',
transfers: TransferHistoryEntry[],
direction: 'CONSUMING' | 'PROVIDING',
): DonutChartData {
const filteredTransfers =
direction === 'incoming'
? transfers.filter((it) => it.direction === 'incoming')
: transfers.filter((it) => it.direction === 'outgoing');
direction === 'CONSUMING'
? transfers.filter((it) => it.direction === 'CONSUMING')
: transfers.filter((it) => it.direction === 'PROVIDING');

// Use the keys of the TransferProcessesStates Enum as order
const order = Object.keys(TransferProcessStates);
const states = [...new Set(filteredTransfers.map((it) => it.state))].sort(
const states = [...new Set(filteredTransfers.map((it) => it.state.name))].sort(
(a, b) => order.indexOf(a) - order.indexOf(b),
);

Expand All @@ -155,15 +154,14 @@ export class DashboardPageDataService {
const defaultColor = '#bd7ebe';

const amountsByState = states.map(
(state) => filteredTransfers.filter((it) => it.state === state).length,
(state) => filteredTransfers.filter((it) => it.state.name === state).length,
);

return {
totalLabel: 'Total',
totalValue: filteredTransfers.length,
isEmpty: !filteredTransfers.length,
emptyMessage: `No ${direction} transfer processes.`,

labels: states,
datasets: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,29 @@
<th *matHeaderCellDef mat-header-cell scope="col">Direction</th>
<td *matCellDef="let item" mat-cell>
<mat-icon mat-table-avatar>
{{ item.direction === 'outgoing' ? 'upload' : 'download' }}
{{ item.direction === 'PROVIDING' ? 'upload' : 'download' }}
</mat-icon>
</td>
</ng-container>
<ng-container matColumnDef="assetId">
<th *matHeaderCellDef mat-header-cell scope="col">Asset</th>
<td *matCellDef="let item" mat-cell>
<div *ngIf="item.direction === 'outgoing'">
<div *ngIf="item.direction === 'PROVIDING'">
<a
class="link"
href="javascript:void(0)"
(click)="onAssetDetailsClick(item.transferProcessId)">
{{ item.assetName ?? item.assetId }}
</a>
</div>
<div *ngIf="item.direction === 'incoming'">
<div *ngIf="item.direction === 'CONSUMING'">
{{ item.assetName ?? item.assetId }}
</div>
</td>
</ng-container>
<ng-container matColumnDef="state">
<th *matHeaderCellDef mat-header-cell scope="col">State</th>
<td *matCellDef="let item" mat-cell>{{ item.state }}</td>
<td *matCellDef="let item" mat-cell>{{ item.state.name }}</td>
</ng-container>
<ng-container matColumnDef="lastUpdated">
<th *matHeaderCellDef mat-header-cell scope="col">Last updated</th>
Expand Down
Loading

0 comments on commit f796b4c

Please sign in to comment.