Skip to content

Commit

Permalink
Merge branch 'main' into feat/disabling_polling_in_brokerui
Browse files Browse the repository at this point in the history
  • Loading branch information
richardtreier authored Aug 14, 2023
2 parents d81dd74 + 2d8d88e commit 765bf68
Show file tree
Hide file tree
Showing 22 changed files with 171 additions and 112 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ the detailed section referring to by linking pull requests or issues.

#### Added

- Added custom 404 pages to connector and broker ui

#### Changed

- Disabled login polling in broker UI
Expand Down
72 changes: 38 additions & 34 deletions fake-backend/json/assets.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
[
{
"properties": {
"asset:prop:id": "urn:artifact:db-rail-network-2023-jan",
"asset:prop:name": "Rail Network DB 2023 January",
"asset:prop:version": "1.1",
"asset:prop:originator": "https://example-connector.rail-mgmt.bahn.de/api/v1/ids/data",
"asset:prop:originatorOrganization": "Deutsche Bahn AG",
"asset:prop:keywords": "db, bahn, rail, Rail-Designer",
"asset:prop:contenttype": "application/json",
"asset:prop:description": "Train Network Map released on 10.01.2023, valid until 31.02.2023. \nFile format is xyz as exported by Rail-Designer.",
"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": "Infrastructure and Logistics",
"http://w3id.org/mds#dataSubcategory": "General Information About Planning Of Routes",
"http://w3id.org/mds#dataModel": "my-data-model-001",
"http://w3id.org/mds#geoReferenceMethod": "my-geo-reference-method",
"http://w3id.org/mds#transportMode": "Rail",
"asset:prop:some-unsupported-property": "F10E2821BBBEA527EA02200352313BC059445190"
{
"assets": [
{
"properties": {
"asset:prop:id": "urn:artifact:db-rail-network-2023-jan",
"asset:prop:name": "Rail Network DB 2023 January",
"asset:prop:version": "1.1",
"asset:prop:originator": "https://example-connector.rail-mgmt.bahn.de/api/v1/ids/data",
"asset:prop:originatorOrganization": "Deutsche Bahn AG",
"asset:prop:keywords": "db, bahn, rail, Rail-Designer",
"asset:prop:contenttype": "application/json",
"asset:prop:description": "Train Network Map released on 10.01.2023, valid until 31.02.2023. \nFile format is xyz as exported by Rail-Designer.",
"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": "Infrastructure and Logistics",
"http://w3id.org/mds#dataSubcategory": "General Information About Planning Of Routes",
"http://w3id.org/mds#dataModel": "my-data-model-001",
"http://w3id.org/mds#geoReferenceMethod": "my-geo-reference-method",
"http://w3id.org/mds#transportMode": "Rail",
"asset:prop:some-unsupported-property": "test"
},
"privateProperties": {}
},
{
"properties": {
"asset:prop:id": "urn:artifact:bitcoin-data",
"asset:prop:name": "Bitcoin Data",
"asset:prop:contenttype": "application/json",
"asset:prop:description": "description",
"asset:prop:version": "1.0",
"asset:prop:type": "HttpData",
"asset:prop:originator": "https://sovity-001.stage-sovity.azure.sovity.io/control/api/v1/ids/data"
},
"privateProperties": {}
}
},
{
"properties": {
"asset:prop:id": "urn:artifact:bitcoin-data",
"asset:prop:name": "Bitcoin Data",
"asset:prop:contenttype": "application/json",
"asset:prop:description": "description",
"asset:prop:version": "1.0",
"asset:prop:type": "HttpData",
"asset:prop:originator": "https://sovity-001.stage-sovity.azure.sovity.io/control/api/v1/ids/data"
}
}
]
]
}
10 changes: 5 additions & 5 deletions fake-backend/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ app.use((req, res, next) => setTimeout(next, 1000));

// Management API

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

const policyDefinitions = json('json/policyDefinitions.json');
app.get('/api/v1/data/policydefinitions', (req, res) => {
res.json(policyDefinitions);
Expand Down Expand Up @@ -101,6 +96,11 @@ app.post(
);

// UI API Wrapper
const assetPage = json('json/assets.json');
app.get('/api/v1/data/wrapper/ui/pages/asset-page', (req, res) => {
res.json(assetPage);
});

const contractAgreementPage = json('json/contractAgreementPage.json');
app.get('/api/v1/data/wrapper/ui/pages/contract-agreement-page', (_, res) => {
res.json(contractAgreementPage);
Expand Down
8 changes: 4 additions & 4 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.20230711.54203-main-f9c4b8f7",
"@sovity.de/edc-client": "0.20230810.82616-main-89593380",
"clean-deep": "^3.4.0",
"date-fns": "^2.30.0",
"dotenv": "^16.3.1",
Expand Down
35 changes: 20 additions & 15 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {NgModule} from '@angular/core';
import {
LoadChildrenCallback,
ROUTES,
RouterModule,
Routes,
} from '@angular/router';
import {APP_CONFIG, AppConfig} from './core/config/app-config';
import {PageNotFoundComponent} from "./component-library/error-404-component/page-not-found.component";


@NgModule({
imports: [RouterModule.forRoot([], {paramsInheritanceStrategy: 'always'})],
Expand All @@ -15,27 +16,31 @@ import {APP_CONFIG, AppConfig} from './core/config/app-config';
provide: ROUTES,
deps: [APP_CONFIG],
multi: true,
useFactory: (config: AppConfig): Routes => {
const loadChildRoutes = (
loadChildren: LoadChildrenCallback,
): Routes => [{path: '', loadChildren}];

useFactory: (config: AppConfig): Routes => {
const routes: Routes = [];
switch (config.routes) {
case 'broker-ui':
return loadChildRoutes(() =>
import('./routes/broker-ui/broker-ui.module').then(
(m) => m.BrokerUiModule,
),
);
routes.push({
path: '', loadChildren: () =>
import('./routes/broker-ui/broker-ui.module').then(
(m) => m.BrokerUiModule,
)
});
break;
case 'connector-ui':
return loadChildRoutes(() =>
import('./routes/connector-ui/connector-ui.module').then(
(m) => m.ConnectorUiModule,
),
);
routes.push({
path: '', loadChildren: () =>
import('./routes/connector-ui/connector-ui.module').then(
(m) => m.ConnectorUiModule,
)
});
break;
default:
throw new Error(`Unhandled PageSet: ${config.routes}`);
}
routes.push({path: '**', component: PageNotFoundComponent})
return routes;
},
},
],
Expand Down
3 changes: 2 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {NgxsModule} from '@ngxs/store';
import {NgChartsModule} from 'ng2-charts';
import {AppRoutingModule} from './app-routing.module';
import {AppComponent} from './app.component';
import {PageNotFoundComponent} from './component-library/error-404-component/page-not-found.component';
import {provideAppConfig} from './core/config/app-config-initializer';
import {provideAppConfigProperty} from './core/config/app-config-injection-utils';
import {ApiKeyInterceptor} from './core/services/api/api-key.interceptor';
Expand Down Expand Up @@ -54,7 +55,7 @@ import {
// Routing
AppRoutingModule,
],
declarations: [AppComponent],
declarations: [AppComponent, PageNotFoundComponent],
providers: [
provideAppConfig(),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
import {Observable, Subject, isObservable} from 'rxjs';
import {filter, finalize, takeUntil} from 'rxjs/operators';
import {ContractNegotiationService} from '../../../core/services/api/contract-negotiation.service';
import {AssetService} from '../../../core/services/api/legacy-managent-api-client';
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 @@ -19,6 +18,7 @@ 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 @@ -50,8 +50,8 @@ export class AssetDetailDialogComponent implements OnDestroy {
}

constructor(
private edcApiService: EdcApiService,
private notificationService: NotificationService,
private assetService: AssetService,
private matDialog: MatDialog,
private matDialogRef: MatDialogRef<AssetDetailDialogComponent>,
@Inject(MAT_DIALOG_DATA)
Expand Down Expand Up @@ -79,7 +79,7 @@ export class AssetDetailDialogComponent implements OnDestroy {
successMessage: `Deleted asset ${this.asset.id}.`,
failureMessage: `Failed deleting asset ${this.asset.id}.`,
onsuccess: () => this.close({refreshList: true}),
req: () => this.assetService.removeAsset(this.asset.id),
req: () => this.edcApiService.deleteAsset(this.asset.id),
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export class AssetPropertyGridGroupBuilder {
labelTitle: AssetProperties.language,
...this.propertyGridUtils.guessValue(asset.language?.label),
},

{
icon: 'apartment',
label: 'Publisher',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="flex flex-col items-center max-w-sm mx-auto text-center">
<h1 class="mt-3 text-2xl font-semibold text-gray-800 md:text-3xl">
Page not found
</h1>
<p class="mt-4 text-gray-500">The page you are looking for doesn't exist.</p>
<div class="flex items-center w-full mt-6 gap-x-3 shrink-0 sm:w-auto">
<a routerLink="/" mat-raised-button color="primary"> Go Back </a>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {Component, HostBinding} from '@angular/core';

@Component({
selector: 'app-page-not-found',
templateUrl: './page-not-found.component.html',
})
export class PageNotFoundComponent {
@HostBinding('class.container')
@HostBinding('class.flex')
@HostBinding('class.items-center')
@HostBinding('class.min-h-screen')
@HostBinding('class.px-6')
@HostBinding('class.py-12')
@HostBinding('class.box-border')
cls = true;
}
21 changes: 20 additions & 1 deletion src/app/core/services/api/edc-api.service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import {Inject, Injectable} from '@angular/core';
import {Observable, from} from 'rxjs';
import {
AssetPage,
ConnectorLimits,
ContractAgreementPage,
ContractAgreementTransferRequest,
EdcClient,
IdResponse,
IdResponseDto,
buildEdcClient,
} from '@sovity.de/edc-client';
import {AssetCreateRequest} from '@sovity.de/edc-client/dist/generated/models/AssetCreateRequest';
import {APP_CONFIG, AppConfig} from '../../config/app-config';

@Injectable({providedIn: 'root'})
Expand All @@ -21,13 +24,29 @@ export class EdcApiService {
});
}

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

getAssetPage(): Observable<AssetPage> {
return from(this.edcClient.uiApi.assetPage());
}

deleteAsset(
assetId: string,
): Observable<IdResponseDto> {
return from(this.edcClient.uiApi.deleteAsset({assetId}));
}

getContractAgreementPage(): Observable<ContractAgreementPage> {
return from(this.edcClient.uiApi.contractAgreementEndpoint());
}

initiateTranfer(
contractAgreementTransferRequest: ContractAgreementTransferRequest,
): Observable<IdResponseDto> {
): Observable<IdResponse> {
return from(
this.edcClient.uiApi.initiateTransfer({contractAgreementTransferRequest}),
);
Expand Down
18 changes: 11 additions & 7 deletions src/app/core/services/asset-entry-builder.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
import {Injectable} from '@angular/core';
import {AssetEditorDialogFormValue} from '../../routes/connector-ui/asset-page/asset-create-dialog/asset-editor-dialog-form-model';
import {AssetEntryDto} from './api/legacy-managent-api-client';
import {AssetCreateRequest} from '@sovity.de/edc-client/dist/generated/models/AssetCreateRequest';
import {
AssetEditorDialogFormValue
} from '../../routes/connector-ui/asset-page/asset-create-dialog/asset-editor-dialog-form-model';
import {AssetPropertyMapper} from './asset-property-mapper';
import {DataAddressMapper} from './data-address-mapper';


@Injectable()
export class AssetEntryBuilder {
constructor(
private assetPropertyMapper: AssetPropertyMapper,
private dataAddressMapper: DataAddressMapper,
) {}
) {
}

/**
* Build {@link AssetEntryDto} from {@link AssetEditorDialogFormValue}
* Build {@link AssetCreateRequest} from {@link AssetEditorDialogFormValue}
*
* @param formValue form value
* @return asset create dto
*/
buildAssetEntry(formValue: AssetEditorDialogFormValue): AssetEntryDto {
buildAssetCreateRequest(formValue: AssetEditorDialogFormValue): AssetCreateRequest {
let properties = this.assetPropertyMapper.buildProperties(formValue);
const dataAddress = this.dataAddressMapper.buildDataAddressProperties(
const dataAddressProperties = this.dataAddressMapper.buildDataAddressProperties(
formValue.datasource,
);
return {asset: {properties}, dataAddress};
return {properties, dataAddressProperties, privateProperties: {}};
}
}
Loading

0 comments on commit 765bf68

Please sign in to comment.