Skip to content

Commit 4bc2613

Browse files
committed
Merge branch 'feature/422753_adapt_assets' into 'develop'
feature/422753_adapt_assets See merge request upm-inesdata/connector-management-interface!2
2 parents 99ac8c6 + 17bf7f2 commit 4bc2613

File tree

18 files changed

+206
-156
lines changed

18 files changed

+206
-156
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@angular/platform-browser": "^17.1.2",
2626
"@angular/platform-browser-dynamic": "^17.1.2",
2727
"@angular/router": "^17.1.2",
28-
"@think-it-labs/edc-connector-client": "0.2.0",
28+
"@think-it-labs/edc-connector-client": "0.3.0",
2929
"install": "^0.13.0",
3030
"rxjs": "~7.8.1",
3131
"zone.js": "~0.14.2"

src/app/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {MatListModule} from '@angular/material/list';
1414
import {MAT_FORM_FIELD_DEFAULT_OPTIONS} from '@angular/material/form-field';
1515
import {AppConfigService} from "./app-config.service";
1616
import {MatSnackBarModule} from "@angular/material/snack-bar";
17-
import {CONNECTOR_CATALOG_API, CONNECTOR_MANAGEMENT_API} from "./shared/utils/app.constants";
17+
import {CONNECTOR_CATALOG_API, CONNECTOR_MANAGEMENT_API, DATA_ADDRESS_TYPES} from "./shared/utils/app.constants";
1818
import {HTTP_INTERCEPTORS} from "@angular/common/http";
1919
import {EdcApiKeyInterceptor} from "./shared/interceptors/apikey.interceptor";
2020
import {environment} from "../environments/environment";
@@ -67,7 +67,7 @@ import { HttpClientModule } from '@angular/common/http';
6767
},
6868
{
6969
provide: 'STORAGE_TYPES',
70-
useFactory: () => [{id: "AzureStorage", name: "AzureStorage"}, {id: "AmazonS3", name: "AmazonS3"}],
70+
useFactory: () => [{id: DATA_ADDRESS_TYPES.httpData, name: DATA_ADDRESS_TYPES.httpData}, {id: DATA_ADDRESS_TYPES.amazonS3, name: DATA_ADDRESS_TYPES.amazonS3}],
7171
},
7272
{
7373
provide: HTTP_INTERCEPTORS, multi: true, useFactory: () => {

src/app/pages/assets/asset-editor-dialog/asset-editor-dialog.component.html

Lines changed: 92 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div>
33
<mat-form-field class="form-field" color="accent">
44
<mat-label>Id</mat-label>
5-
<input [(ngModel)]="id" matInput>
5+
<input required [(ngModel)]="id" matInput>
66
</mat-form-field>
77
<mat-form-field class="form-field" color="accent">
88
<mat-label>Name</mat-label>
@@ -22,30 +22,110 @@
2222
</div>
2323

2424
<div>
25-
<mat-form-field class="form-field" color="accent" id="form-field-destination">
25+
<mat-form-field class="form-field" color="accent">
2626
<mat-label>Destination</mat-label>
27-
<mat-select [(ngModel)]="storageTypeId" disabled>
27+
<mat-select [(ngModel)]="storageTypeId">
2828
<mat-option *ngFor="let storageType of storageTypes " [value]="storageType.id">
2929
{{storageType.name}}
3030
</mat-option>
3131
</mat-select>
3232
</mat-form-field>
33+
</div>
34+
35+
<div *ngIf="storageTypeId === 'HttpData'">
36+
<mat-form-field class="form-field" color="accent">
37+
<mat-label>Name</mat-label>
38+
<input [(ngModel)]="httpDataAddress.name" matInput>
39+
</mat-form-field>
40+
41+
<mat-form-field class="form-field" color="accent">
42+
<mat-label>Path</mat-label>
43+
<input [(ngModel)]="httpDataAddress.path" matInput>
44+
</mat-form-field>
45+
46+
<mat-form-field class="form-field" color="accent">
47+
<mat-label>Base URL</mat-label>
48+
<input [(ngModel)]="httpDataAddress.baseUrl" matInput>
49+
</mat-form-field>
50+
51+
<mat-form-field class="form-field" color="accent">
52+
<mat-label>Auth Key</mat-label>
53+
<input [(ngModel)]="httpDataAddress.authKey" matInput>
54+
</mat-form-field>
55+
56+
<mat-form-field class="form-field" color="accent">
57+
<mat-label>Auth Code</mat-label>
58+
<input [(ngModel)]="httpDataAddress.authCode" matInput>
59+
</mat-form-field>
60+
61+
<mat-form-field class="form-field" color="accent">
62+
<mat-label>Secret Name</mat-label>
63+
<input [(ngModel)]="httpDataAddress.secretName" matInput>
64+
</mat-form-field>
65+
66+
<mat-form-field class="form-field" color="accent">
67+
<mat-label>Proxy Body</mat-label>
68+
<input [(ngModel)]="httpDataAddress.proxyBody" matInput>
69+
</mat-form-field>
70+
71+
<mat-form-field class="form-field" color="accent">
72+
<mat-label>Proxy Path</mat-label>
73+
<input [(ngModel)]="httpDataAddress.proxyPath" matInput>
74+
</mat-form-field>
3375

34-
<mat-form-field class="form-field" color="accent" id="form-field-account">
35-
<mat-label>Account</mat-label>
36-
<input [(ngModel)]="account" matInput>
76+
<mat-form-field class="form-field" color="accent">
77+
<mat-label>Proxy Query Params</mat-label>
78+
<input [(ngModel)]="httpDataAddress.proxyQueryParams" matInput>
3779
</mat-form-field>
3880

39-
<mat-form-field class="form-field" color="accent" id="form-field-container">
40-
<mat-label>Container</mat-label>
41-
<input disabled [(ngModel)]="container" matInput>
81+
<mat-form-field class="form-field" color="accent">
82+
<mat-label>Proxy Method</mat-label>
83+
<input [(ngModel)]="httpDataAddress.roxyMethod" matInput>
4284
</mat-form-field>
4385

44-
<mat-form-field class="form-field" color="accent" id="form-field-blobname">
45-
<mat-label>Blob Name</mat-label>
46-
<input [(ngModel)]="blobname" matInput>
86+
<mat-form-field class="form-field" color="accent">
87+
<mat-label>Content Type</mat-label>
88+
<input [(ngModel)]="httpDataAddress.contentType" matInput>
4789
</mat-form-field>
4890
</div>
91+
92+
<div *ngIf="storageTypeId === 'AmazonS3'">
93+
<mat-form-field class="form-field" color="accent">
94+
<mat-label>Region</mat-label>
95+
<input required [(ngModel)]="amazonS3DataAddress.region" matInput>
96+
</mat-form-field>
97+
98+
<mat-form-field class="form-field" color="accent">
99+
<mat-label>Bucket Name</mat-label>
100+
<input [(ngModel)]="amazonS3DataAddress.bucketName" matInput>
101+
</mat-form-field>
102+
103+
<mat-form-field class="form-field" color="accent">
104+
<mat-label>Key Prefix</mat-label>
105+
<input [(ngModel)]="amazonS3DataAddress.keyPrefix" matInput>
106+
</mat-form-field>
107+
108+
<mat-form-field class="form-field" color="accent">
109+
<mat-label>Folder Name</mat-label>
110+
<input [(ngModel)]="amazonS3DataAddress.folderName" matInput>
111+
</mat-form-field>
112+
113+
<mat-form-field class="form-field" color="accent">
114+
<mat-label>Access Key Id</mat-label>
115+
<input [(ngModel)]="amazonS3DataAddress.accessKeyId" matInput>
116+
</mat-form-field>
117+
118+
<mat-form-field class="form-field" color="accent">
119+
<mat-label>Secret Access Key</mat-label>
120+
<input [(ngModel)]="amazonS3DataAddress.secretAccessKey" matInput>
121+
</mat-form-field>
122+
123+
<mat-form-field class="form-field" color="accent">
124+
<mat-label>Endpoint Override</mat-label>
125+
<input [(ngModel)]="amazonS3DataAddress.endpointOverride" matInput>
126+
</mat-form-field>
127+
</div>
128+
49129
</mat-dialog-content>
50130

51131

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { Component, Inject } from '@angular/core';
2-
import { AssetInput } from "@think-it-labs/edc-connector-client";
2+
import { AssetInput, HttpDataAddress, DataAddress } from '@think-it-labs/edc-connector-client';
33
import { MatDialogRef } from "@angular/material/dialog";
44
import { StorageType } from "../../../shared/models/storage-type";
5+
import { AmazonS3DataAddress } from "../../../shared/models/amazon-s3-data-address";
6+
import { NotificationService } from 'src/app/shared/services/notification.service';
7+
import { DATA_ADDRESS_TYPES } from 'src/app/shared/utils/app.constants';
58

69

710
@Component({
8-
selector: 'edc-demo-asset-editor-dialog',
11+
selector: 'app-asset-editor-dialog',
912
templateUrl: './asset-editor-dialog.component.html',
1013
styleUrls: ['./asset-editor-dialog.component.scss']
1114
})
@@ -15,33 +18,67 @@ export class AssetEditorDialog {
1518
version: string = '';
1619
name: string = '';
1720
contenttype: string = '';
21+
storageTypeId: string = '';
22+
23+
amazonS3DataAddress: AmazonS3DataAddress = {
24+
type: 'AmazonS3',
25+
region: ''
26+
};
27+
28+
httpDataAddress: HttpDataAddress = {
29+
type: 'HttpData'
30+
};
1831

19-
storageTypeId: string = 'AzureStorage';
20-
account: string = '';
21-
container: string = 'src-container';
22-
blobname: string = '';
2332

2433
constructor(private dialogRef: MatDialogRef<AssetEditorDialog>,
34+
private notificationService: NotificationService,
2535
@Inject('STORAGE_TYPES') public storageTypes: StorageType[]) {
2636
}
2737

2838
onSave() {
39+
if (!this.checkRequiredFields()) {
40+
this.notificationService.showError("Review required fields");
41+
return;
42+
}
43+
44+
let dataAddress: DataAddress;
45+
46+
if (this.storageTypeId === DATA_ADDRESS_TYPES.amazonS3) {
47+
dataAddress = this.amazonS3DataAddress;
48+
} else if (this.storageTypeId === DATA_ADDRESS_TYPES.httpData) {
49+
dataAddress = this.httpDataAddress;
50+
} else {
51+
this.notificationService.showError("Incorrect destination value");
52+
return;
53+
}
54+
2955
const assetInput: AssetInput = {
3056
"@id": this.id,
3157
properties: {
3258
"name": this.name,
3359
"version": this.version,
3460
"contenttype": this.contenttype,
3561
},
36-
dataAddress: {
37-
"type": this.storageTypeId,
38-
"account": this.account,
39-
"container": this.container,
40-
"blobname": this.blobname,
41-
"keyName": `${this.account}-key1`
42-
}
62+
dataAddress: dataAddress
4363
};
4464

4565
this.dialogRef.close({ assetInput });
4666
}
67+
68+
/**
69+
* Checks the required fields
70+
*
71+
* @returns true if required fields have been filled
72+
*/
73+
private checkRequiredFields(): boolean {
74+
if (!this.id || !this.storageTypeId){
75+
return false;
76+
} else {
77+
if (this.storageTypeId === DATA_ADDRESS_TYPES.amazonS3 && !this.amazonS3DataAddress.region) {
78+
return false;
79+
} else {
80+
return true;
81+
}
82+
}
83+
}
4784
}

src/app/pages/assets/asset-viewer/asset-viewer.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {NotificationService} from "../../../shared/services/notification.service
1010

1111

1212
@Component({
13-
selector: 'edc-demo-asset-viewer',
13+
selector: 'app-asset-viewer',
1414
templateUrl: './asset-viewer.component.html',
1515
styleUrls: ['./asset-viewer.component.scss']
1616
})

src/app/pages/catalog/catalog-browser/catalog-browser.component.html

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@
7575

7676
<mat-divider inset></mat-divider>
7777
<mat-card-actions class="card-actions">
78-
<button (click)="onNegotiateClicked(contractOffer)"
79-
[disabled]="isBusy(contractOffer) || isNegotiated(contractOffer)"
80-
color="accent" mat-stroked-button>
81-
<mat-icon>drive_file_rename_outline</mat-icon>
82-
Negotiate
83-
</button>
8478
</mat-card-actions>
8579
<mat-card-footer>
8680
<mat-progress-bar *ngIf="isBusy(contractOffer)" color="accent" mode="indeterminate"></mat-progress-bar>

src/app/pages/catalog/catalog-browser/catalog-browser.component.ts

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface RunningTransferProcess {
1717
}
1818

1919
@Component({
20-
selector: 'edc-demo-catalog-browser',
20+
selector: 'app-catalog-browser',
2121
templateUrl: './catalog-browser.component.html',
2222
styleUrls: ['./catalog-browser.component.scss']
2323
})
@@ -54,62 +54,6 @@ export class CatalogBrowserComponent implements OnInit {
5454
this.fetch$.next(null);
5555
}
5656

57-
onNegotiateClicked(contractOffer: ContractOffer) {
58-
const initiateRequest: ContractNegotiationRequest = {
59-
connectorAddress: contractOffer.originator,
60-
offer: {
61-
offerId: contractOffer.id,
62-
assetId: contractOffer.assetId,
63-
policy: contractOffer.policy,
64-
},
65-
connectorId: 'connector',
66-
providerId: contractOffer.properties.provider
67-
};
68-
69-
const finishedNegotiationStates = [
70-
"VERIFIED",
71-
"TERMINATED",
72-
"ERROR"];
73-
74-
this.apiService.initiateNegotiation(initiateRequest).subscribe(negotiationId => {
75-
this.finishedNegotiations.delete(initiateRequest.offer.offerId);
76-
this.runningNegotiations.set(initiateRequest.offer.offerId, {
77-
id: negotiationId,
78-
offerId: initiateRequest.offer.offerId
79-
});
80-
81-
if (!this.pollingHandleNegotiation) {
82-
// there are no active negotiations
83-
this.pollingHandleNegotiation = setInterval(() => {
84-
// const finishedNegotiations: NegotiationResult[] = [];
85-
86-
for (const negotiation of this.runningNegotiations.values()) {
87-
this.apiService.getNegotiationState(negotiation.id).subscribe(updatedNegotiation => {
88-
if (finishedNegotiationStates.includes(updatedNegotiation.state!)) {
89-
let offerId = negotiation.offerId;
90-
this.runningNegotiations.delete(offerId);
91-
if (updatedNegotiation["edc:state"] === "VERIFIED") {
92-
this.finishedNegotiations.set(offerId, updatedNegotiation);
93-
this.notificationService.showInfo("Contract Negotiation complete!", "Show me!", () => {
94-
this.router.navigate(['/contracts'])
95-
})
96-
}
97-
}
98-
99-
if (this.runningNegotiations.size === 0) {
100-
clearInterval(this.pollingHandleNegotiation);
101-
this.pollingHandleNegotiation = undefined;
102-
}
103-
});
104-
}
105-
}, 1000);
106-
}
107-
}, error => {
108-
console.error(error);
109-
this.notificationService.showError("Error starting negotiation");
110-
});
111-
}
112-
11357
isBusy(contractOffer: ContractOffer) {
11458
return this.runningNegotiations.get(contractOffer.id) !== undefined || !!this.runningTransferProcesses.find(tp => tp.assetId === contractOffer.assetId);
11559
}

src/app/pages/contract-definitions/contract-definition-editor-dialog/contract-definition-editor-dialog.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Asset, ContractDefinitionInput, PolicyDefinition } from "../../../share
66

77

88
@Component({
9-
selector: 'edc-demo-contract-definition-editor-dialog',
9+
selector: 'app-contract-definition-editor-dialog',
1010
templateUrl: './contract-definition-editor-dialog.component.html',
1111
styleUrls: ['./contract-definition-editor-dialog.component.scss']
1212
})

src/app/pages/contract-definitions/contract-definition-viewer/contract-definition-viewer.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { ContractDefinitionInput, ContractDefinition } from "../../../shared/mod
1212

1313

1414
@Component({
15-
selector: 'edc-demo-contract-definition-viewer',
15+
selector: 'app-contract-definition-viewer',
1616
templateUrl: './contract-definition-viewer.component.html',
1717
styleUrls: ['./contract-definition-viewer.component.scss']
1818
})

0 commit comments

Comments
 (0)