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

Use new type-safe Asset in UI && Update UiCriterion #487

Merged
35 changes: 22 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@ng-apimock/core": "^3.11.0",
"@ngxs/store": "^3.8.1",
"@sovity.de/broker-server-client": "0.20230712.71619-main-a4860cff",
"@sovity.de/edc-client": "0.20230830.155424-main-b314d7e2",
"@sovity.de/edc-client": "0.20230921.115850-main-5e87f14f",
"clean-deep": "^3.4.0",
"date-fns": "^2.30.0",
"dotenv": "^16.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{{ asset.name }}
</div>
<div class="mat-card-subtitle">
{{ asset.originatorOrganization }}
{{ asset.creatorOrganizationName }}
</div>
</div>
</div>
Expand All @@ -44,7 +44,7 @@
</div>

<!-- Tag List -->
<div *ngIf="asset.keywords.length">
<div *ngIf="asset.keywords?.length">
<mat-chip-list aria-label="Tags">
<mat-chip *ngFor="let keyword of asset.keywords">{{ keyword }}</mat-chip>
</mat-chip-list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import {Observable, Subject, isObservable} from 'rxjs';
import {filter, finalize, takeUntil} from 'rxjs/operators';
import {ContractNegotiationService} from '../../../core/services/api/contract-negotiation.service';
import {EdcApiService} from '../../../core/services/api/edc-api.service';
import {Asset} from '../../../core/services/models/asset';
import {NotificationService} from '../../../core/services/notification.service';
import {ContractAgreementTransferDialogData} from '../../../routes/connector-ui/contract-agreement-page/contract-agreement-transfer-dialog/contract-agreement-transfer-dialog-data';
Expand All @@ -18,7 +19,6 @@ import {
import {PropertyGridGroup} from '../../property-grid/property-grid-group/property-grid-group';
import {AssetDetailDialogData} from './asset-detail-dialog-data';
import {AssetDetailDialogResult} from './asset-detail-dialog-result';
import {EdcApiService} from "../../../core/services/api/edc-api.service";

/**
* Asset Detail Dialog
Expand Down Expand Up @@ -76,10 +76,10 @@ export class AssetDetailDialogComponent implements OnDestroy {
onDeleteClick() {
this.confirmDelete().subscribe(() => {
this.blockingRequest({
successMessage: `Deleted asset ${this.asset.id}.`,
failureMessage: `Failed deleting asset ${this.asset.id}.`,
successMessage: `Deleted asset ${this.asset.assetId}.`,
failureMessage: `Failed deleting asset ${this.asset.assetId}.`,
onsuccess: () => this.close({refreshList: true}),
req: () => this.edcApiService.deleteAsset(this.asset.id),
req: () => this.edcApiService.deleteAsset(this.asset.assetId),
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class AssetPropertyGridGroupBuilder {
icon: 'category',
label: 'ID',
labelTitle: AssetProperties.id,
...this.propertyGridUtils.guessValue(asset.id),
...this.propertyGridUtils.guessValue(asset.assetId),
},
{
icon: 'file_copy',
Expand All @@ -54,32 +54,32 @@ export class AssetPropertyGridGroupBuilder {
icon: 'apartment',
label: 'Publisher',
labelTitle: AssetProperties.publisher,
...this.propertyGridUtils.guessValue(asset.publisher),
...this.propertyGridUtils.guessValue(asset.publisherHomepage),
},
{
icon: 'bookmarks',
label: 'Endpoint Documentation',
labelTitle: AssetProperties.endpointDocumentation,
...this.propertyGridUtils.guessValue(asset.endpointDocumentation),
...this.propertyGridUtils.guessValue(asset.landingPageUrl),
},
{
icon: 'gavel',
label: 'Standard License',
labelTitle: AssetProperties.standardLicense,
...this.propertyGridUtils.guessValue(asset.standardLicense),
...this.propertyGridUtils.guessValue(asset.licenseUrl),
},
this.buildConnectorEndpointField(asset.originator!!),
this.buildConnectorEndpointField(asset.connectorEndpoint),
{
icon: 'account_circle',
label: 'Organization',
labelTitle: AssetProperties.originatorOrganization,
...this.propertyGridUtils.guessValue(asset.originatorOrganization),
...this.propertyGridUtils.guessValue(asset.creatorOrganizationName),
},
{
icon: 'category',
label: 'Content Type',
labelTitle: AssetProperties.contentType,
...this.propertyGridUtils.guessValue(asset.contentType),
...this.propertyGridUtils.guessValue(asset.mediaType),
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{{ asset.name }}
</a>
</mat-card-title>
<mat-card-subtitle>{{ asset.originatorOrganization }}</mat-card-subtitle>
<mat-card-subtitle>{{ asset.creatorOrganizationName }}</mat-card-subtitle>
</mat-card-header>
<mat-card-content class="flex flex-col space-y-[16px]">
<!-- Progress Bar -->
Expand All @@ -29,7 +29,7 @@
</div>

<!-- Tag List -->
<div *ngIf="asset.keywords.length || asset.version">
<div *ngIf="asset.keywords?.length || asset.version">
<mat-chip-list aria-label="Tags">
<mat-chip *ngIf="asset.version" color="primary" selected>{{
asset.version
Expand Down
8 changes: 4 additions & 4 deletions src/app/core/services/api/contract-negotiation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class ContractNegotiationService {
return (
this.runningNegotiations.get(contractOffer.id) !== undefined ||
!!this.runningTransferProcesses.find(
(tp) => tp.assetId === contractOffer.asset.id,
(tp) => tp.assetId === contractOffer.asset.assetId,
)
);
}
Expand All @@ -67,7 +67,7 @@ export class ContractNegotiationService {

getState(contractOffer: ContractOffer): string {
const transferProcess = this.runningTransferProcesses.find(
(tp) => tp.assetId === contractOffer.asset.id,
(tp) => tp.assetId === contractOffer.asset.assetId,
);
if (transferProcess) {
return TransferProcessStates[transferProcess.state];
Expand All @@ -83,11 +83,11 @@ export class ContractNegotiationService {

negotiate(contractOffer: ContractOffer) {
const initiateRequest: NegotiationInitiateRequestDto = {
connectorAddress: contractOffer.asset.originator!,
connectorAddress: contractOffer.asset.connectorEndpoint!,

offer: {
offerId: contractOffer.id,
assetId: contractOffer.asset.id,
assetId: contractOffer.asset.assetId,
policy: contractOffer.policy,
},
connectorId: 'my-connector',
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/services/api/contract-offer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class ContractOfferService {
...contractOfferDto,
asset: this.assetPropertyMapper.buildAsset({
connectorEndpoint,
properties: contractOfferDto.asset.properties,
uiAsset: contractOfferDto.asset,
}),
};
}
Expand Down
10 changes: 10 additions & 0 deletions src/app/core/services/api/criterion-type-ext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {UiCriterionOperatorEnum} from '@sovity.de/edc-client';

export const CRITERION_OPERATOR_SYMBOLS: Record<
UiCriterionOperatorEnum,
string
> = {
EQ: '=',
IN: 'in',
LIKE: 'like',
};
10 changes: 5 additions & 5 deletions src/app/core/services/api/edc-api.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {Inject, Injectable} from '@angular/core';
import {Observable, from} from 'rxjs';
import {
AssetCreateRequest,
AssetDto,
AssetPage,
ConnectorLimits,
ContractAgreementPage,
Expand All @@ -15,6 +13,8 @@ import {
PolicyDefinitionCreateRequest,
PolicyDefinitionPage,
TransferHistoryPage,
UiAsset,
UiAssetCreateRequest,
buildEdcClient,
} from '@sovity.de/edc-client';
import {APP_CONFIG, AppConfig} from '../../config/app-config';
Expand All @@ -35,9 +35,9 @@ export class EdcApiService {
}

createAsset(
assetCreateRequest: AssetCreateRequest,
uiAssetCreateRequest: UiAssetCreateRequest,
): Observable<IdResponseDto> {
return from(this.edcClient.uiApi.createAsset({assetCreateRequest}));
return from(this.edcClient.uiApi.createAsset({uiAssetCreateRequest}));
}

getAssetPage(): Observable<AssetPage> {
Expand Down Expand Up @@ -104,7 +104,7 @@ export class EdcApiService {
return from(this.edcClient.uiApi.transferHistoryPageEndpoint());
}

getTransferProcessAsset(transferProcessId: string): Observable<AssetDto> {
getTransferProcessAsset(transferProcessId: string): Observable<UiAsset> {
return from(
this.edcClient.uiApi.getTransferProcessAsset({transferProcessId}),
);
Expand Down
30 changes: 22 additions & 8 deletions src/app/core/services/api/fake-backend/asset-fake-service.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
import {
AssetCreateRequest,
AssetEntry,
AssetPage,
IdResponseDto,
UiAsset,
UiAssetCreateRequest,
} from '@sovity.de/edc-client';
import {AssetProperties} from '../../asset-properties';
import {TestAssets} from './data/test-assets';

export let assets: AssetEntry[] = [TestAssets.full, TestAssets.boring];
export let assets: UiAsset[] = [TestAssets.full, TestAssets.boring];

export const assetPage = (): AssetPage => {
return {
assets,
};
};

export const createAsset = (asset: AssetCreateRequest): IdResponseDto => {
export const createAsset = (asset: UiAssetCreateRequest): IdResponseDto => {
assets.push({
properties: asset.properties,
assetId: asset.id,
name: asset.name ?? asset.id,
description: asset.description,
creatorOrganizationName: asset.creatorOrganizationName,
publisherHomepage: asset.publisherHomepage,
licenseUrl: asset.licenseUrl,
version: asset.version,
keywords: asset.keywords,
mediaType: asset.mediaType,
landingPageUrl: asset.landingPageUrl,
dataCategory: asset.dataCategory,
dataSubcategory: asset.dataSubcategory,
dataModel: asset.dataModel,
geoReferenceMethod: asset.geoReferenceMethod,
transportMode: asset.transportMode,
additionalProperties: asset.additionalProperties,
privateProperties: asset.privateProperties,
});
return {
id: asset.properties[AssetProperties.id],
id: asset.id,
lastUpdatedDate: new Date(),
};
};

export const deleteAsset = (id: string): IdResponseDto => {
assets = assets.filter((it) => it.properties[AssetProperties.id] !== id);
assets = assets.filter((it) => it.assetId !== id);
return {id, lastUpdatedDate: new Date()};
};
Loading
Loading