Skip to content

Commit

Permalink
feat: add new mds attributes (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
kulgg authored Jan 26, 2024
1 parent 63f08bc commit 96cbcdb
Show file tree
Hide file tree
Showing 25 changed files with 707 additions and 38 deletions.
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.

#### Minor

- Integrate new MDS fields into asset creation and asset detail dialog

#### Patch

- Fix auth proxy issues by disabling caching for non-static files
Expand Down
43 changes: 29 additions & 14 deletions package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
"@angular/router": "^14.3.0",
"@ng-apimock/core": "^3.11.0",
"@ngxs/store": "^3.8.1",
"@sovity.de/broker-server-client": "0.20240117.145014-main-d0484d54",
"@sovity.de/edc-client": "0.20240117.123601-main-45d15241",
"@sovity.de/broker-server-client": "0.20240123.125521-main-e2b49967",
"@sovity.de/edc-client": "0.20240123.124358-main-e5fee025",
"clean-deep": "^3.4.0",
"date-fns": "^2.30.0",
"date-fns-tz": "^2.0.0",
"dotenv": "^16.3.1",
"isomorphic-dompurify": "^2.0.0",
"json-stable-stringify": "^1.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {PropertyGridGroup} from '../../property-grid/property-grid-group/propert
import {PropertyGridField} from '../../property-grid/property-grid/property-grid-field';
import {PropertyGridFieldService} from '../../property-grid/property-grid/property-grid-field.service';
import {formatDateAgo} from '../../ui-elements/ago/formatDateAgo';
import {UrlListDialogService} from '../../url-list-dialog/url-list-dialog/url-list-dialog.service';
import {
getOnlineStatusColor,
getOnlineStatusIcon,
Expand All @@ -24,6 +25,7 @@ export class AssetPropertyGridGroupBuilder {
private activeFeatureSet: ActiveFeatureSet,
private propertyGridUtils: PropertyGridFieldService,
private jsonDialogService: JsonDialogService,
private urlListDialogService: UrlListDialogService,
private policyPropertyFieldBuilder: PolicyPropertyFieldBuilder,
) {}

Expand Down Expand Up @@ -77,7 +79,7 @@ export class AssetPropertyGridGroupBuilder {
];

if (this.activeFeatureSet.hasMdsFields()) {
fields.push(...this.buildMdsProperties(asset, true));
fields.push(...this.buildMdsProperties(asset));
}

return {
Expand Down Expand Up @@ -126,7 +128,7 @@ export class AssetPropertyGridGroupBuilder {
const fields: PropertyGridField[] = [];

if (!this.activeFeatureSet.hasMdsFields()) {
fields.push(...this.buildMdsProperties(asset, false));
fields.push(...this.buildMdsProperties(asset));
}

fields.push(
Expand All @@ -146,46 +148,100 @@ export class AssetPropertyGridGroupBuilder {
};
}

buildMdsProperties(
asset: UiAssetMapped,
includeEmpty: boolean,
): PropertyGridField[] {
buildMdsProperties(asset: UiAssetMapped): PropertyGridField[] {
const fields: PropertyGridField[] = [];
if (includeEmpty || asset.transportMode) {
if (asset.transportMode) {
fields.push({
icon: 'commute',
label: 'Transport Mode',
...this.propertyGridUtils.guessValue(asset.transportMode?.label),
});
}
if (includeEmpty || asset.dataCategory) {
if (asset.dataCategory) {
fields.push({
icon: 'commute',
label: 'Data Category',
...this.propertyGridUtils.guessValue(asset.dataCategory?.label),
});
}
if (includeEmpty || asset.dataSubcategory) {
if (asset.dataSubcategory) {
fields.push({
icon: 'commute',
label: 'Data Subcategory',
...this.propertyGridUtils.guessValue(asset.dataSubcategory?.label),
});
}
if (includeEmpty || asset.dataModel) {
if (asset.dataModel) {
fields.push({
icon: 'category',
label: 'Data Model',
...this.propertyGridUtils.guessValue(asset.dataModel),
});
}
if (includeEmpty || asset.geoReferenceMethod) {
if (asset.geoReferenceMethod) {
fields.push({
icon: 'commute',
label: 'Geo Reference Method',
...this.propertyGridUtils.guessValue(asset.geoReferenceMethod),
});
}
if (asset.geoLocation) {
fields.push({
icon: 'location_on',
label: 'Geo Location',
...this.propertyGridUtils.guessValue(asset.geoLocation),
});
}
if (asset.nutsLocation?.length) {
fields.push(this.buildNutsLocationsField(asset.nutsLocation));
}
if (asset.sovereignLegalName) {
fields.push({
icon: 'account_balance',
label: 'Sovereign',
...this.propertyGridUtils.guessValue(asset.sovereignLegalName),
});
}
if (asset.dataSampleUrls?.length) {
fields.push(
this.buildDataSampleUrlsField(asset.dataSampleUrls, asset.title),
);
}
if (asset.referenceFileUrls?.length) {
fields.push(
this.buildReferenceFileUrlsField(
asset.referenceFileUrls,
asset.referenceFilesDescription,
asset.title,
),
);
}
if (asset.conditionsForUse) {
fields.push({
icon: 'description',
label: 'Conditions For Use',
...this.propertyGridUtils.guessValue(asset.conditionsForUse),
});
}
if (asset.dataUpdateFrequency) {
fields.push({
icon: 'timelapse',
label: 'Data Update Frequency',
...this.propertyGridUtils.guessValue(asset.dataUpdateFrequency),
});
}
if (asset.temporalCoverageFrom || asset.temporalCoverageToInclusive) {
fields.push({
icon: 'today',
label: 'Temporal Coverage',
...this.propertyGridUtils.guessValue(
this.buildTemporalCoverageString(
asset.temporalCoverageFrom,
asset.temporalCoverageToInclusive,
),
),
});
}
return fields;
}

Expand Down Expand Up @@ -341,4 +397,65 @@ export class AssetPropertyGridGroupBuilder {
...this.propertyGridUtils.guessValue(endpoint),
};
}

buildNutsLocationsField(locations: string[]): PropertyGridField {
return {
icon: 'location_on',
label: 'NUTS Locations',
text: locations.join(', '),
};
}

buildDataSampleUrlsField(
dataSampleUrls: string[],
title: string,
): PropertyGridField {
return {
icon: 'attachment',
label: 'Data Samples',
text: 'Show Data Samples',
onclick: () =>
this.urlListDialogService.showUrlListDialog({
title: `Data Samples`,
subtitle: title,
icon: 'attachment',
urls: dataSampleUrls,
}),
};
}

buildReferenceFileUrlsField(
referenceFileUrls: string[],
description: string | undefined,
title: string,
): PropertyGridField {
return {
icon: 'receipt',
label: 'Reference Files',
text: 'Show Reference Files',
onclick: () =>
this.urlListDialogService.showUrlListDialog({
title: `Reference Files`,
subtitle: title,
icon: 'receipt',
urls: referenceFileUrls,
description: description,
}),
};
}

buildTemporalCoverageString(
start: Date | undefined,
end: Date | undefined,
): string {
if (!end) {
return `Start: ${start!.toLocaleDateString()}`;
}

if (!start) {
return `End: ${end.toLocaleDateString()}`;
}

return `${start.toLocaleDateString()} - ${end.toLocaleDateString()}`;
}
}
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 @@ -12,6 +12,7 @@ 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';
import {UrlListDialogModule} from '../url-list-dialog/url-list-dialog.module';
import {AssetCardTagListComponent} from './asset-card-tag-list/asset-card-tag-list.component';
import {AssetDetailDialogDataService} from './asset-detail-dialog/asset-detail-dialog-data.service';
import {AssetDetailDialogComponent} from './asset-detail-dialog/asset-detail-dialog.component';
Expand Down Expand Up @@ -47,6 +48,7 @@ import {ViewSelectionComponent} from './view-selection/view-selection.component'

// Features
JsonDialogModule,
UrlListDialogModule,
PropertyGridModule,
UiElementsModule,
PipesAndDirectivesModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {MatButtonModule} from '@angular/material/button';
import {MatCardModule} from '@angular/material/card';
import {MatDialogModule} from '@angular/material/dialog';
import {MatIconModule} from '@angular/material/icon';
import {NgxJsonViewerModule} from 'ngx-json-viewer';
import {ConfirmationDialogModule} from '../confirmation-dialog/confirmation-dialog.module';
import {PipesAndDirectivesModule} from '../pipes-and-directives/pipes-and-directives.module';
import {UrlListDialogComponent} from './url-list-dialog/url-list-dialog.component';
import {UrlListDialogService} from './url-list-dialog/url-list-dialog.service';

@NgModule({
imports: [
// Angular
CommonModule,
FormsModule,

// Angular Material
MatButtonModule,
MatCardModule,
MatDialogModule,
MatIconModule,

// Third Party
NgxJsonViewerModule,

// EDC UI Modules
PipesAndDirectivesModule,
ConfirmationDialogModule,
],
declarations: [UrlListDialogComponent],
providers: [UrlListDialogService],
exports: [UrlListDialogComponent],
})
export class UrlListDialogModule {}
Loading

0 comments on commit 96cbcdb

Please sign in to comment.