Skip to content

Commit

Permalink
fix: http parameterization fields inaccessible due to asset property bug
Browse files Browse the repository at this point in the history
  • Loading branch information
richardtreier committed Jul 7, 2023
1 parent a592ff4 commit 884da2e
Show file tree
Hide file tree
Showing 11 changed files with 232 additions and 38 deletions.
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Release
about: Create an issue to track a release process.
title: "Release v0.0.1-milestone-8-sovity{{version}}"
labels: ["task/release", "scope/ce"]
assignees: ""
---

# Release

## Work Breakdown

Feel free to edit this release checklist in-progress depending on what tasks need to be done:
- [ ] Decide a release version depending on the previous release.
- [ ] Update this issue's title to the new version
- [ ] `release-prep` PR:
- [ ] Update the CHANGELOG.md.
- [ ] Add a clean `Unreleased` version.
- [ ] Add the version to the old section.
- [ ] Add the current date to the old version.
- [ ] Write or review a `Deployment Migration Notes` section.
- [ ] Write or review a release summary.
- [ ] Remove empty sections from the patch notes.
- [ ] Merge the `release-prep` PR.
- [ ] Wait for the main branch to be green.
- [ ] Create a release and re-use the changelog section as release description, and the version as title.
- [ ] Check if the pipeline built the release versions in the Actions-Section (or you won't see it).
- [ ] Revisit the changed list of tasks and compare it with [.github/ISSUE_TEMPLATE/release.md](https://github.com/sovity/edc-ui/blob/main/.github/ISSUE_TEMPLATE/release.md). Propose changes where it
makes sense.
- [ ] Close this issue.
4 changes: 2 additions & 2 deletions fake-backend/json/connectorLimits.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"numActiveConsumingContractAgreements": 2,
"maxActiveConsumingContractAgreements": 1
"numActiveConsumingContractAgreements": 3,
"maxActiveConsumingContractAgreements": 2
}
92 changes: 90 additions & 2 deletions fake-backend/json/contractAgreementPage.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"assetId": "urn:artifact:my-test-asset",
"createdAt": "2023-04-24T12:32:28.492Z",
"properties": {
"asset:prop:id": "urn:artifact:my-test-asset"
"asset:prop:id": "urn:artifact:consumed-asset"
}
},
"contractPolicy": {
Expand All @@ -128,7 +128,7 @@
{
"edctype": "dataspaceconnector:permission",
"uid": null,
"target": "urn:artifact:my-test-asset",
"target": "urn:artifact:consumed-asset",
"action": {
"type": "USE",
"includedIn": null,
Expand Down Expand Up @@ -191,6 +191,23 @@
"createdAt": "2023-04-24T12:32:28.492Z",
"properties": {
"asset:prop:id": "urn:artifact:my-test-asset-2",
"asset:prop:name": "Consuming Contract Offer If Asset Propreties Weren't Buggy",
"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",
"asset:prop:datasource:http:hints:proxyMethod": "true",
"asset:prop:datasource:http:hints:proxyPath": "true",
"asset:prop:datasource:http:hints:proxyQueryParams": "true",
Expand Down Expand Up @@ -243,6 +260,77 @@
}
},
"transferProcesses": []
},
{
"contractAgreementId": "my-test-asset-cd:6ebbc301-9b1e-4cd7-9f17-97b5b786752",
"direction": "CONSUMING",
"counterPartyAddress": "http://edc2:11003/api/v1/ids/data",
"counterPartyId": "my-connector",
"contractSigningDate": "2022-03-25T11:18:59.659Z",
"contractStartDate": "2022-03-25T11:18:59.659Z",
"contractEndDate": "2022-05-01T20:04:35.658Z",
"asset": {
"assetId": "urn:artifact:my-test-asset",
"createdAt": "2023-04-24T12:32:28.492Z",
"properties": {
"asset:prop:id": "urn:artifact:consumed-asset-2"
}
},
"contractPolicy": {
"legacyPolicy": {
"permissions": [
{
"edctype": "dataspaceconnector:permission",
"uid": null,
"target": "urn:artifact:consumed-asset",
"action": {
"type": "USE",
"includedIn": null,
"constraint": null
},
"assignee": null,
"assigner": null,
"constraints": [
{
"edctype": "AtomicConstraint",
"leftExpression": {
"edctype": "dataspaceconnector:literalexpression",
"value": "ALWAYS_TRUE"
},
"rightExpression": {
"edctype": "dataspaceconnector:literalexpression",
"value": "true"
},
"operator": "EQ"
}
],
"duties": []
}
],
"prohibitions": [],
"obligations": [],
"extensibleProperties": {},
"inheritsFrom": null,
"assigner": null,
"assignee": null,
"target": "urn:artifact:my-test-asset",
"@type": {
"@policytype": "set"
}
}
},
"transferProcesses": [
{
"transferProcessId": "522138de-349d-4b68-9356-7e5929f053e0",
"lastUpdatedDate": "2023-04-24T12:32:43.027Z",
"state": {
"code": 800,
"name": "COMPLETED",
"simplifiedState": "OK"
},
"errorMessage": null
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export class AssetPropertyGridGroupBuilder {
tooltip: contractAgreement.statusTooltipText,
textIconAfter: contractAgreement.statusTooltipText ? 'help' : null,
text: contractAgreement.statusText,
additionalClasses: 'text-warn',
additionalClasses: contractAgreement.canTransfer ? '' : 'text-warn',
});
}

Expand Down
19 changes: 14 additions & 5 deletions src/app/core/services/http-params-mapper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,21 @@ export class HttpRequestParamsMapper {
const body = value.httpProxiedBody?.trim() ?? '';
const contentType = value.httpProxiedBodyContentType?.trim() ?? '';

let proxyMethod =
value.showAllHttpParameterizationFields || asset.httpProxyMethod;
let proxyPath =
value.showAllHttpParameterizationFields || asset.httpProxyPath;
let proxyQueryParams =
value.showAllHttpParameterizationFields || asset.httpProxyQueryParams;
let proxyBody =
value.showAllHttpParameterizationFields || asset.httpProxyBody;

return removeNullValues({
method: asset.httpProxyMethod ? method : null,
pathSegments: asset.httpProxyPath ? pathSegments : null,
queryParams: asset.httpProxyQueryParams ? queryParams : null,
body: asset.httpProxyBody ? body : null,
mediaType: asset.httpProxyBody ? contentType : null,
method: proxyMethod ? method : null,
pathSegments: proxyPath ? pathSegments : null,
queryParams: proxyQueryParams ? queryParams : null,
body: proxyBody ? body : null,
mediaType: proxyBody ? contentType : null,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ export class AssetCreateDialogForm {
return this.datasource.controls.httpProxyQueryParams.value;
}

get proxyBody(): boolean {
return this.datasource.controls.httpProxyBody.value;
}

constructor(
private formBuilder: FormBuilder,
private activeFeatureSet: ActiveFeatureSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,20 +236,16 @@ <h1 mat-dialog-title>Create New Asset</h1>
<mat-form-field
*ngIf="form.datasource.controls.httpUrl; let ctrl"
class="grow">
<mat-label *ngIf="!form.datasource.controls.httpProxyPath.value">
URL
</mat-label>
<mat-label *ngIf="form.datasource.controls.httpProxyPath.value">
Base URL
</mat-label>
<mat-label *ngIf="!form.proxyPath"> URL </mat-label>
<mat-label *ngIf="form.proxyPath"> Base URL </mat-label>
<input matInput [formControl]="ctrl" [placeholder]="'https://'" />
<mat-error *ngIf="ctrl.invalid && ctrl.errors?.pattern">
{{ validationMessages.invalidUrlMessage }}
</mat-error>
</mat-form-field>

<!-- Default Path (Rest-Api) -->
<ng-container *ngIf="form.datasource.controls.httpProxyPath.value">
<ng-container *ngIf="form.proxyPath">
<mat-form-field
*ngIf="form.datasource.controls.httpDefaultPath; let ctrl"
class="grow">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export interface ContractAgreementTransferDialogFormModel {
httpUrl: FormControl<string>;
httpMethod: FormControl<string>;

showAllHttpParameterizationFields: FormControl<boolean>;

httpAuthHeaderType: FormControl<HttpDatasinkAuthHeaderType>;
httpAuthHeaderName: FormControl<string>;
httpAuthHeaderValue: FormControl<string>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export class ContractAgreementTransferDialogForm {
new Array<FormGroup<HttpDatasinkHeaderFormModel>>(),
),

showAllHttpParameterizationFields: [false],

httpProxiedPath: [''],
httpProxiedMethod: ['GET'],
httpProxiedQueryParams: this.formBuilder.array(
Expand Down Expand Up @@ -96,6 +98,8 @@ export class ContractAgreementTransferDialogForm {

httpHeaders: http,

showAllHttpParameterizationFields: !customTransferProcessRequest,

httpProxiedPath: !customTransferProcessRequest,
httpProxiedMethod: !customTransferProcessRequest,
httpProxiedQueryParams: !customTransferProcessRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,27 @@ <h1 mat-dialog-title>Initiate Transfer</h1>
</ng-container>

<ng-container
*ngIf="
form.dataAddressType !== 'Custom-Transfer-Process-Request' &&
(proxyMethod || proxyPath || proxyQueryParams || proxyBody)
">
<div class="form-section-title">Datasource Parameterization</div>
*ngIf="form.dataAddressType !== 'Custom-Transfer-Process-Request'">
<div class="form-section-title">HTTP Datasource Parameterization</div>

<div class="text-sm mb-[10px] px-[3px]">
When the data offer on the provider side is of the type
<b>HttpData</b> and certain data source fields are set, certain parts
of the request to the data source can be customized from the consumer
side and will be passed to the other connector when initiating the
transfer. This allows an asset to contain more than just one kind of
data, allowing additional filtering or even sharing of entire APIs
with multiple data sets via a single asset and a single contract.
</div>

<div
*ngIf="proxyPath || proxyMethod"
class="text-sm mb-[10px] px-[3px]">
The resulting URL will look like
<i>{{
'{baseUrl}{customSubPath}?{baseQueryParams}&{customQueryParams}'
}}</i>
</div>

<div
*ngIf="proxyMethod || proxyPath"
Expand All @@ -217,7 +233,7 @@ <h1 mat-dialog-title>Initiate Transfer</h1>
<mat-form-field
*ngIf="form.all.controls.httpProxiedMethod; let ctrl"
[ngClass]="{'w-1/3': proxyPath}">
<mat-label>Method</mat-label>
<mat-label>Custom Method</mat-label>
<mat-select [formControl]="ctrl">
<mat-option
*ngFor="let method of dataSourceMethods"
Expand All @@ -236,13 +252,13 @@ <h1 mat-dialog-title>Initiate Transfer</h1>
<mat-form-field
*ngIf="form.all.controls.httpProxiedPath; let ctrl"
class="grow">
<mat-label>Custom Path Segment</mat-label>
<mat-label>Custom Subpath</mat-label>
<input
matInput
[formControl]="ctrl"
[placeholder]="'sub-path/endpoint'" />
<mat-hint>
Will be added to Base URL. Default:
Default:
{{ data.asset.httpDefaultPath ?? 'Unknown' }}
</mat-hint>
</mat-form-field>
Expand All @@ -258,7 +274,7 @@ <h1 mat-dialog-title>Initiate Transfer</h1>
class="flex flex-row space-x-[10px]">
<!-- Query Param Name -->
<mat-form-field class="w-1/3">
<mat-label>Query Param Name</mat-label>
<mat-label>Custom Query Param Name</mat-label>
<input
matInput
placeholder="key"
Expand Down Expand Up @@ -293,15 +309,15 @@ <h1 mat-dialog-title>Initiate Transfer</h1>
mat-button
color="primary"
(click)="form.onHttpQueryParamsAddClick()">
Add Query Param
Add Custom Query Param
</button>
</div>
</ng-container>

<ng-container *ngIf="proxyBody">
<!-- Request Body Content Type -->
<mat-form-field class="grow">
<mat-label>Content Type</mat-label>
<mat-label>Custom Request Body Content Type</mat-label>
<input
matInput
autocomplete="new-content-type"
Expand All @@ -311,14 +327,31 @@ <h1 mat-dialog-title>Initiate Transfer</h1>

<!-- Request Body -->
<mat-form-field *ngIf="form.all.controls.httpProxiedBody; let ctrl">
<mat-label>Body</mat-label>
<mat-label>Custom Request Body</mat-label>
<textarea
matInput
placeholder='{"some": "request-body"}'
autocomplete="new-request-body"
[formControl]="ctrl"></textarea>
</mat-form-field>
</ng-container>

<!-- Toggle Parameterization Fields Button -->
<div
*ngIf="
showHttpParameterizationToggleButton &&
form.all.controls.showAllHttpParameterizationFields;
let ctrl
"
class="flex flex-row mb-[10px]">
<button
mat-button
[color]="ctrl.value ? 'warn' : 'primary'"
(click)="ctrl.setValue(!ctrl.value)">
{{ ctrl.value ? 'Hide' : 'Show' }} Http Datasource Parameterization
Fields
</button>
</div>
</ng-container>
</div>
</form>
Expand Down
Loading

0 comments on commit 884da2e

Please sign in to comment.