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

refactor: cleanup Asset model #114

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,18 @@ Substitute the values as necessary:

As some extra safety consider running `git udpate-index --assume-unchanged src/assets/config/app.config.json` before changing this file.

## Running a frondend and a connector locally (for demo purpose)
## Running a frondend and two connectors locally (for demo purpose)
To test the correct functionality locally you can spin up a local docker compose
that will load the `data-dashboard` service and the `connector` one.
First you need to change the `app.config.json` this way:
```json
{
...
"managementApiUrl": "http://consumer-connector/management",
"catalogUrl": "http://consumer-connector/management",
...
}
```
that will load two `data-dashboard`s service and two `connector`s, one for consumer
and one for provider.

Then you can start the docker compose:
Just start the docker compose.
```shell
docker compose up
```

The DataDashboard will be available at `http://localhost:8080`
Consumer data-dashboard will be available at `http://localhost:18080`
Provider data-dashboard will be available at `http://localhost:28080`

### Running DataDashboard from the host machine (for debugging purpose)
To have a quicker development cycle, you can also run the DataDashboard from the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ edc.transfer.send.retry.limit=1
edc.transfer.send.retry.base-delay.ms=10
edc.transfer.state-machine.iteration-wait-millis=10

edc.federated.node.url=http://provider-connector:9194/protocol

edc.web.rest.cors.enabled=true
8 changes: 8 additions & 0 deletions deployment/conf/consumer.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"apiKey": "ApiKeyDefaultValue",
"managementApiUrl": "http://localhost:18080/management",
"catalogUrl": "http://localhost:18080/management",
"storageAccount": "company2assets",
"storageExplorerLinkTemplate": "storageexplorer://v=1",
"theme": "theme-2"
}
19 changes: 19 additions & 0 deletions deployment/conf/consumer.nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
events {}
http {
include /etc/nginx/mime.types;
server {
listen 80;
server_name localhost;

root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri $uri/ /index.html;
}

location /management {
proxy_pass http://consumer-connector:9193/management;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ edc.negotiation.state-machine.iteration-wait-millis=100
edc.transfer.send.retry.limit=1
edc.transfer.send.retry.base-delay.ms=10
edc.transfer.state-machine.iteration-wait-millis=10

edc.federated.node.url=http://consumer-connector:9194/protocol
8 changes: 8 additions & 0 deletions deployment/conf/provider.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"apiKey": "ApiKeyDefaultValue",
"managementApiUrl": "http://localhost:28080/management",
"catalogUrl": "http://localhost:28080/management",
"storageAccount": "company2assets",
"storageExplorerLinkTemplate": "storageexplorer://v=1",
"theme": "theme-2"
}
19 changes: 19 additions & 0 deletions deployment/conf/provider.nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
events {}
http {
include /etc/nginx/mime.types;
server {
listen 80;
server_name localhost;

root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri $uri/ /index.html;
}

location /management {
proxy_pass http://provider-connector:9193/management;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
*
*/

package org.eclipse.edc.datadashboard;

import org.eclipse.edc.catalog.spi.FederatedCacheNode;
import org.eclipse.edc.catalog.spi.FederatedCacheNodeDirectory;
import org.eclipse.edc.connector.dataplane.selector.spi.instance.DataPlaneInstance;
import org.eclipse.edc.connector.dataplane.selector.spi.store.DataPlaneInstanceStore;
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;

import java.util.List;
import java.util.UUID;

@Extension(value = DataDashboardLocalExtension.NAME)
public class DataDashboardLocalExtension implements ServiceExtension {

public static final String NAME = "DataDashboard Local - please do not use in production";

@Inject
private FederatedCacheNodeDirectory federatedCacheNodeDirectory;

@Inject
private DataPlaneInstanceStore dataPlaneInstanceStore;

@Override
public String name() {
return NAME;
}

@Override
public void initialize(ServiceExtensionContext context) {
var nodeUrl = context.getSetting("edc.federated.node.url", null);
if (nodeUrl != null) {
context.getMonitor().info("Register federated node: %s".formatted(nodeUrl));
federatedCacheNodeDirectory.insert(new FederatedCacheNode(UUID.randomUUID().toString(), nodeUrl, List.of("dataspace-protocol-http")));
}
}

@Override
public void start() {
var dataPlaneInstance = DataPlaneInstance.Builder.newInstance()
.url("http://localhost:9192/control/transfer")
.allowedSourceType("HttpData")
.allowedDestType("HttpData")
.build();
dataPlaneInstanceStore.create(dataPlaneInstance);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.eclipse.edc.datadashboard.DataDashboardLocalExtension
33 changes: 30 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
version: "3.9"

services:
data-dashboard:
consumer-data-dashboard:
build: .
platform: ${DOCKER_PLATFORM:-linux/amd64}
ports:
- "8080:80"
- "18080:80"
volumes:
- ./deployment/nginx.compose.conf:/etc/nginx/nginx.conf
- ./deployment/conf/consumer.nginx.conf:/etc/nginx/nginx.conf
- ./deployment/conf/consumer.config.json:/usr/share/nginx/html/assets/config/app.config.json

provider-data-dashboard:
build: .
platform: ${DOCKER_PLATFORM:-linux/amd64}
ports:
- "28080:80"
volumes:
- ./deployment/conf/provider.nginx.conf:/etc/nginx/nginx.conf
- ./deployment/conf/provider.config.json:/usr/share/nginx/html/assets/config/app.config.json

consumer-connector:
build: deployment/connector
Expand All @@ -25,3 +35,20 @@ services:
EDC_FS_CONFIG: /config/configuration.properties
volumes:
- ./deployment/conf/consumer-connector.config:/config

provider-connector:
build: deployment/connector
platform: ${DOCKER_PLATFORM:-linux/amd64}
ports:
- "29191:9191" # connector default
- "29192:9192" # connector control
- "29193:9193" # connector management
- "29194:9194" # connector protocol
- "29291:9291" # data-plane public
environment:
EDC_VAULT: /config/vault.properties
EDC_KEYSTORE: /config/vault-keys.p12
EDC_KEYSTORE_PASSWORD: 123456
EDC_FS_CONFIG: /config/configuration.properties
volumes:
- ./deployment/conf/provider-connector.config:/config
2 changes: 1 addition & 1 deletion proxy.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"/management":
{
"target": "http://localhost:8080",
"target": "http://localhost:18080",
"secure": false
}
}
4 changes: 2 additions & 2 deletions src/assets/config/app.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"apiKey": "ApiKeyDefaultValue",
"managementApiUrl": "http://localhost:9192/api/v1/data",
"catalogUrl": "http://localhost:9191/api/v1/data/",
"managementApiUrl": "http://localhost:4200/management",
"catalogUrl": "http://localhost:4200/management",
"storageAccount": "company2assets",
"storageExplorerLinkTemplate": "storageexplorer://v=1",
"theme": "theme-2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,29 @@
<mat-card *ngFor="let contractOffer of filteredContractOffers" class="asset-card">
<mat-card-header>
<mat-icon mat-card-avatar>sim_card</mat-icon>
<mat-card-title>{{contractOffer.asset.name}}</mat-card-title>
<mat-card-title>{{contractOffer.properties.name}}</mat-card-title>
</mat-card-header>
<mat-card-content>
<mat-list dense>
<!-- <mat-list-item>
<mat-icon mat-list-icon>policy</mat-icon>
<div mat-line class="asset-property-name">Policy</div>
<div mat-line>{{contractOffer.asset.policyId}}</div>
<div mat-line>{{contractOffer.properties.policyId}}</div>
</mat-list-item> -->
<mat-list-item>
<mat-icon mat-list-icon>category</mat-icon>
<div class="asset-property-name" mat-line>Type</div>
<div mat-line>{{contractOffer.asset.type}}</div>
<div mat-line>{{contractOffer.properties.type}}</div>
</mat-list-item>
<mat-list-item>
<mat-icon mat-list-icon>key</mat-icon>
<div class="asset-property-name" mat-line>Id</div>
<div mat-line>{{contractOffer.assetId}}</div>
</mat-list-item>
<mat-list-item *ngIf="contractOffer.originator">
<mat-icon mat-list-icon>link</mat-icon>
<div class="asset-property-name" mat-line>Originator</div>
<div mat-line>{{contractOffer.originator}}</div>
</mat-list-item>
</mat-list>

Expand All @@ -44,35 +54,25 @@
</mat-panel-title>
</mat-expansion-panel-header>
<mat-list dense>
<mat-list-item>
<mat-icon mat-list-icon>key</mat-icon>
<div class="asset-property-name" mat-line>Id</div>
<div mat-line>{{contractOffer.asset.id}}</div>
</mat-list-item>
<mat-list-item>
<mat-icon mat-list-icon>numbers</mat-icon>
<div class="asset-property-name" mat-line>Version</div>
<div mat-line>{{contractOffer.asset.version}}</div>
<div mat-line>{{contractOffer.properties.version}}</div>
</mat-list-item>
<mat-list-item *ngIf="contractOffer.asset.contentType">
<mat-list-item *ngIf="contractOffer.properties.contentType">
<mat-icon mat-list-icon>content_paste</mat-icon>
<div class="asset-property-name" mat-line>Content-Type</div>
<div mat-line>{{contractOffer.asset.contentType}}</div>
</mat-list-item>
<mat-list-item *ngIf="contractOffer.asset.originator">
<mat-icon mat-list-icon>link</mat-icon>
<div class="asset-property-name" mat-line>Originator</div>
<div mat-line>{{contractOffer.asset.originator}}</div>
<div mat-line>{{contractOffer.properties.contentType}}</div>
</mat-list-item>
<mat-list-item *ngFor="let additionalPropertyKey of contractOffer.asset.additionalPropertyKeys">
<mat-list-item *ngFor="let additionalPropertyKey of contractOffer.properties.additionalPropertyKeys">
<mat-icon mat-list-icon>list</mat-icon>
<div *ngIf="additionalPropertyKey.replace('asset:prop:', '') as name"
class="asset-property-name"
mat-line>
{{name.charAt(0).toUpperCase() + name.slice(1)}}
</div>
<div mat-line title="{{contractOffer.asset.properties[additionalPropertyKey]}}">
{{contractOffer.asset.properties[additionalPropertyKey]}}</div>
<div mat-line title="{{contractOffer.properties.properties[additionalPropertyKey]}}">
{{contractOffer.properties.properties[additionalPropertyKey]}}</div>
</mat-list-item>
</mat-list>
</mat-expansion-panel>
Expand All @@ -82,7 +82,7 @@
<mat-divider inset></mat-divider>
<mat-card-actions class="card-actions">
<button (click)="onNegotiateClicked(contractOffer)"
[disabled]="!contractOffer.asset.isAsync || isBusy(contractOffer) || isNegotiated(contractOffer)"
[disabled]="isBusy(contractOffer) || isNegotiated(contractOffer)"
color="accent" mat-stroked-button>
<mat-icon>drive_file_rename_outline</mat-icon>
Negotiate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ export class CatalogBrowserComponent implements OnInit {

onNegotiateClicked(contractOffer: ContractOffer) {
const initiateRequest: NegotiationInitiateRequestDto = {
connectorAddress: contractOffer["edc:originator"],
connectorAddress: contractOffer.originator,
"@context": {
"edc": "https://w3id.org/edc/v0.0.1/ns/",
"odrl": "http://www.w3.org/ns/odrl/2/"
},
offer: {
offerId: contractOffer.id,
assetId: contractOffer.asset.id,
assetId: contractOffer.assetId,
policy: contractOffer.policy,
},
connectorId: 'connector',
Expand Down Expand Up @@ -115,11 +115,11 @@ export class CatalogBrowserComponent implements OnInit {
}

isBusy(contractOffer: ContractOffer) {
return this.runningNegotiations.get(contractOffer.id) !== undefined || !!this.runningTransferProcesses.find(tp => tp.assetId === contractOffer.asset.id);
return this.runningNegotiations.get(contractOffer.id) !== undefined || !!this.runningTransferProcesses.find(tp => tp.assetId === contractOffer.assetId);
}

getState(contractOffer: ContractOffer): string {
const transferProcess = this.runningTransferProcesses.find(tp => tp.assetId === contractOffer.asset.id);
const transferProcess = this.runningTransferProcesses.find(tp => tp.assetId === contractOffer.assetId);
if (transferProcess) {
return TransferProcessStates[transferProcess.state];
}
Expand Down
Loading