Skip to content

Commit

Permalink
feat: broker ui migration to Eclipse EDC 0
Browse files Browse the repository at this point in the history
  • Loading branch information
richardtreier committed Nov 17, 2023
1 parent 061b123 commit b3d5bcb
Show file tree
Hide file tree
Showing 63 changed files with 862 additions and 547 deletions.
5 changes: 3 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ e2e
node_modules
.angular
.github
dist

package-lock.json

openapi
src/modules/edc-dmgmt-client
src/assets/config/app-config.json
470 changes: 149 additions & 321 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Injectable} from '@angular/core';
import {Asset} from '../../../core/services/models/asset';
import {DataOffer} from '../../../core/services/models/data-offer';
import {BrokerDataOffer} from '../../../routes/broker-ui/catalog-page/catalog-page/mapping/broker-data-offer';
import {UiAssetMapped} from '../../../core/services/models/ui-asset-mapped';
import {CatalogDataOfferMapped} from '../../../routes/broker-ui/catalog-page/catalog-page/mapping/catalog-page-result-mapped';
import {ContractAgreementCardMapped} from '../../../routes/connector-ui/contract-agreement-page/contract-agreement-cards/contract-agreement-card-mapped';
import {AssetDetailDialogData} from './asset-detail-dialog-data';
import {AssetPropertyGridGroupBuilder} from './asset-property-grid-group-builder';
Expand All @@ -12,7 +12,10 @@ export class AssetDetailDialogDataService {
private assetPropertyGridGroupBuilder: AssetPropertyGridGroupBuilder,
) {}

assetDetails(asset: Asset, allowDelete: boolean): AssetDetailDialogData {
assetDetails(
asset: UiAssetMapped,
allowDelete: boolean,
): AssetDetailDialogData {
const propertyGridGroups = [
this.assetPropertyGridGroupBuilder.buildAssetPropertiesGroup(asset, null),
this.assetPropertyGridGroupBuilder.buildAdditionalPropertiesGroup(asset),
Expand Down Expand Up @@ -69,7 +72,9 @@ export class AssetDetailDialogDataService {
};
}

brokerDataOfferDetails(dataOffer: BrokerDataOffer): AssetDetailDialogData {
brokerDataOfferDetails(
dataOffer: CatalogDataOfferMapped,
): AssetDetailDialogData {
const asset = dataOffer.asset;

const propertyGridGroups = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Asset} from 'src/app/core/services/models/asset';
import {UiAssetMapped} from 'src/app/core/services/models/ui-asset-mapped';
import {DataOffer} from '../../../core/services/models/data-offer';
import {BrokerDataOffer} from '../../../routes/broker-ui/catalog-page/catalog-page/mapping/broker-data-offer';
import {CatalogDataOfferMapped} from '../../../routes/broker-ui/catalog-page/catalog-page/mapping/catalog-page-result-mapped';
import {ContractAgreementCardMapped} from '../../../routes/connector-ui/contract-agreement-page/contract-agreement-cards/contract-agreement-card-mapped';
import {PropertyGridGroup} from '../../property-grid/property-grid-group/property-grid-group';

Expand All @@ -11,9 +11,9 @@ export interface AssetDetailDialogData {
| 'contract-agreement'
| 'broker-data-offer';
propertyGridGroups: PropertyGridGroup[];
asset: Asset;
asset: UiAssetMapped;
dataOffer?: DataOffer;
contractAgreement?: ContractAgreementCardMapped;
brokerDataOffer?: BrokerDataOffer;
brokerDataOffer?: CatalogDataOfferMapped;
showDeleteButton?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {filter, finalize, takeUntil} from 'rxjs/operators';
import {UiContractOffer} from '@sovity.de/edc-client';
import {EdcApiService} from '../../../core/services/api/edc-api.service';
import {ContractNegotiationService} from '../../../core/services/contract-negotiation.service';
import {Asset} from '../../../core/services/models/asset';
import {UiAssetMapped} from '../../../core/services/models/ui-asset-mapped';
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';
import {ContractAgreementTransferDialogComponent} from '../../../routes/connector-ui/contract-agreement-page/contract-agreement-transfer-dialog/contract-agreement-transfer-dialog.component';
Expand All @@ -35,7 +35,7 @@ import {AssetDetailDialogResult} from './asset-detail-dialog-result';
})
export class AssetDetailDialogComponent implements OnDestroy {
data!: AssetDetailDialogData;
asset!: Asset;
asset!: UiAssetMapped;
propGroups!: PropertyGridGroup[];

loading = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {Injectable} from '@angular/core';
import {CatalogContractOffer} from '@sovity.de/broker-server-client';
import {UiPolicy} from '@sovity.de/edc-client';
import {ActiveFeatureSet} from '../../../core/config/active-feature-set';
import {Asset} from '../../../core/services/models/asset';
import {BrokerDataOffer} from '../../../routes/broker-ui/catalog-page/catalog-page/mapping/broker-data-offer';
import {UiAssetMapped} from '../../../core/services/models/ui-asset-mapped';
import {CatalogDataOfferMapped} from '../../../routes/broker-ui/catalog-page/catalog-page/mapping/catalog-page-result-mapped';
import {ContractAgreementCardMapped} from '../../../routes/connector-ui/contract-agreement-page/contract-agreement-cards/contract-agreement-card-mapped';
import {JsonDialogService} from '../../json-dialog/json-dialog/json-dialog.service';
import {PropertyGridGroup} from '../../property-grid/property-grid-group/property-grid-group';
Expand All @@ -26,7 +26,7 @@ export class AssetPropertyGridGroupBuilder {
) {}

buildAssetPropertiesGroup(
asset: Asset,
asset: UiAssetMapped,
groupLabel: string | null,
): PropertyGridGroup {
const fields: PropertyGridField[] = [
Expand Down Expand Up @@ -84,7 +84,7 @@ export class AssetPropertyGridGroupBuilder {
};
}

private buildHttpDatasourceFields(asset: Asset): PropertyGridField[] {
private buildHttpDatasourceFields(asset: UiAssetMapped): PropertyGridField[] {
const fields: PropertyGridField[] = [];

const hints: {label: string; value: boolean | undefined}[] = [
Expand Down Expand Up @@ -120,7 +120,7 @@ export class AssetPropertyGridGroupBuilder {
return fields;
}

buildAdditionalPropertiesGroup(asset: Asset): PropertyGridGroup {
buildAdditionalPropertiesGroup(asset: UiAssetMapped): PropertyGridGroup {
const fields: PropertyGridField[] = [];

if (!this.activeFeatureSet.hasMdsFields()) {
Expand All @@ -144,7 +144,10 @@ export class AssetPropertyGridGroupBuilder {
};
}

buildMdsProperties(asset: Asset, includeEmpty: boolean): PropertyGridField[] {
buildMdsProperties(
asset: UiAssetMapped,
includeEmpty: boolean,
): PropertyGridField[] {
const fields: PropertyGridField[] = [];
if (includeEmpty || asset.transportMode) {
fields.push({
Expand Down Expand Up @@ -185,7 +188,7 @@ export class AssetPropertyGridGroupBuilder {
}

buildBrokerContractOfferGroup(
asset: Asset,
asset: UiAssetMapped,
contractOffer: CatalogContractOffer,
i: number,
total: number,
Expand All @@ -202,7 +205,7 @@ export class AssetPropertyGridGroupBuilder {
subtitle: asset.title,
icon: 'policy',
objectForJson: JSON.parse(
contractOffer.contractPolicy.legacyPolicy ?? 'null',
contractOffer.contractPolicy.policyJsonLd,
),
}),
},
Expand Down Expand Up @@ -290,7 +293,9 @@ export class AssetPropertyGridGroupBuilder {
};
}

buildBrokerDataOfferGroup(dataOffer: BrokerDataOffer): PropertyGridGroup {
buildBrokerDataOfferGroup(
dataOffer: CatalogDataOfferMapped,
): PropertyGridGroup {
const lastUpdate = formatDateAgo(
dataOffer.connectorOfflineSinceOrLastUpdatedAt,
);
Expand Down
2 changes: 2 additions & 0 deletions src/app/component-library/catalog/catalog.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {MatIconModule} from '@angular/material/icon';
import {MatProgressBarModule} from '@angular/material/progress-bar';
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
import {MatTooltipModule} from '@angular/material/tooltip';
import {JsonDialogModule} from '../json-dialog/json-dialog.module';
import {PipesAndDirectivesModule} from '../pipes-and-directives/pipes-and-directives.module';
import {PropertyGridModule} from '../property-grid/property-grid.module';
import {UiElementsModule} from '../ui-elements/ui-elements.module';
Expand Down Expand Up @@ -38,6 +39,7 @@ import {TransferHistoryMiniListComponent} from './transfer-history-mini-list/tra
MatTooltipModule,

// Features
JsonDialogModule,
PropertyGridModule,
UiElementsModule,
PipesAndDirectivesModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {NgForOf} from '@angular/common';
import {Attribute, Directive, TrackByFunction, inject} from '@angular/core';
import {Attribute, Directive, Host, TrackByFunction} from '@angular/core';

export const newTrackByFn =
<T>(key: keyof T): TrackByFunction<T> =>
Expand All @@ -10,13 +10,15 @@ export const newTrackByFn =
* Creates Track By Function for ngFor loops
*/
@Directive({
selector: '[ngFor][ngForOf][trackByField]',
selector: '[trackByField]',
})
export class TrackByFieldDirective {
constructor(
@Host() ngForOf: NgForOf<unknown>,
@Attribute('trackByField') private readonly trackByField: string,
) {
const ngForOf = inject(NgForOf<unknown>, {self: true});
ngForOf.ngForTrackBy = newTrackByFn(this.trackByField);
if (!ngForOf.ngForTrackBy) {
ngForOf.ngForTrackBy = newTrackByFn(this.trackByField);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import {
CatalogContractOffer,
CatalogDataOffer,
CatalogPageQuery,
CatalogPageResult,
DataOfferDetailContractOffer,
DataOfferDetailPageQuery,
DataOfferDetailPageResult,
UiAsset,
} from '@sovity.de/broker-server-client';
import {subDays, subMinutes} from 'date-fns';
import {TestAssets} from '../connector-fake-impl/data/test-assets';
import {TestPolicies} from '../connector-fake-impl/data/test-policies';

const DATA_OFFERS: DataOfferDetailPageResult[] = [
{
assetId: TestAssets.full.assetId,
asset: TestAssets.full as UiAsset,
connectorEndpoint: 'https://example-connector/api/dsp',
viewCount: 103,
connectorOfflineSinceOrLastUpdatedAt: subMinutes(new Date(), 5),
updatedAt: subMinutes(new Date(), 5),
createdAt: subDays(new Date(), 7),
connectorOnlineStatus: 'ONLINE',
contractOffers: [
{
contractOfferId: 'contract-offer-1',
updatedAt: subMinutes(new Date(), 5),
createdAt: subDays(new Date(), 7),
contractPolicy: TestPolicies.warnings,
},
],
},
{
assetId: TestAssets.withSuffix(TestAssets.boring, '2').assetId,
asset: TestAssets.withSuffix(TestAssets.boring, '2') as UiAsset,
connectorEndpoint: 'https://example-connector/api/dsp',
viewCount: 103,
connectorOfflineSinceOrLastUpdatedAt: subMinutes(new Date(), 5),
updatedAt: subMinutes(new Date(), 5),
createdAt: subDays(new Date(), 7),
connectorOnlineStatus: 'OFFLINE',
contractOffers: [
{
contractOfferId: 'contract-offer-1',
updatedAt: subMinutes(new Date(), 5),
createdAt: subDays(new Date(), 7),
contractPolicy: TestPolicies.warnings,
},
],
},
{
assetId: TestAssets.boring.assetId,
asset: TestAssets.boring as UiAsset,
connectorEndpoint: 'https://example-connector/api/dsp',
viewCount: 103,
connectorOfflineSinceOrLastUpdatedAt: subDays(new Date(), 3),
updatedAt: subMinutes(new Date(), 5),
createdAt: subDays(new Date(), 7),
connectorOnlineStatus: 'DEAD',
contractOffers: [
{
contractOfferId: 'contract-offer-1',
updatedAt: subMinutes(new Date(), 5),
createdAt: subDays(new Date(), 7),
contractPolicy: TestPolicies.warnings,
},
],
},
];

export const getCatalogPage = (query: CatalogPageQuery): CatalogPageResult => {
const dataOffers: CatalogDataOffer[] = DATA_OFFERS.map(buildCatalogDataOffer);

return {
dataOffers,
availableFilters: {
fields: [
{
id: 'example-filter',
title: 'Example Filter',
values: [
{id: 'example-value', title: 'Example Value'},
{id: 'other-value', title: 'Other Value'},
{id: '', title: ''},
],
},
{
id: 'other-filter',
title: 'Other Filter',
values: [
{id: 'example-value', title: 'Example Value'},
{id: 'other-value', title: 'Other Value'},
{id: '', title: ''},
],
},
],
},
paginationMetadata: {
pageSize: 20,
numVisible: dataOffers.length,
pageOneBased: 0,
numTotal: dataOffers.length,
},
availableSortings: [
{sorting: 'TITLE', title: 'Test Sorting'},
{sorting: 'MOST_RECENT', title: 'Other Sorting'},
],
};
};

export const getDataOfferDetailPage = (
query: DataOfferDetailPageQuery,
): DataOfferDetailPageResult => {
return DATA_OFFERS.find(
(it) =>
it.connectorEndpoint === query.connectorEndpoint &&
it.assetId === query.assetId,
)!;
};

const buildCatalogDataOffer = (
it: DataOfferDetailPageResult,
): CatalogDataOffer => ({
assetId: it.assetId,
connectorEndpoint: it.connectorEndpoint,
asset: it.asset,
contractOffers: it.contractOffers.map(buildCatalogContractOffer),
updatedAt: it.updatedAt,
createdAt: it.createdAt,
connectorOfflineSinceOrLastUpdatedAt: it.connectorOfflineSinceOrLastUpdatedAt,
connectorOnlineStatus: it.connectorOnlineStatus,
});

const buildCatalogContractOffer = (
co: DataOfferDetailContractOffer,
): CatalogContractOffer => ({
contractOfferId: co.contractOfferId,
contractPolicy: co.contractPolicy,
createdAt: co.createdAt,
updatedAt: co.updatedAt,
});
Loading

0 comments on commit b3d5bcb

Please sign in to comment.