Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
richardtreier committed Jun 30, 2023
1 parent 75a1be8 commit ff5bfa4
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 129 deletions.
8 changes: 0 additions & 8 deletions src/app/core/services/asset-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ export const AssetProperties = {

dataSourceType: 'type',

/**
* Hint if the asset was created by our EDC UI so if set, parameterization is guaranteed to be on or off
*
* Example values: "true", "false"
*/
httpParameterizationEnabled:
'asset:prop:datasource:http:parameterization:enabled',

/**
* Whether this asset supports HTTP Path parameterization
*
Expand Down
31 changes: 11 additions & 20 deletions src/app/core/services/asset-property-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ export class AssetPropertyMapper {
geoReferenceMethod: props[AssetProperties.geoReferenceMethod],
transportMode,
dataSourceType: props[AssetProperties.dataSourceType]!!,
httpParameterizationEnabled: this._parseBoolean(
props[AssetProperties.httpParameterizationEnabled],
),
httpProxyBody: this._parseBoolean(props[AssetProperties.httpProxyBody]),
httpProxyPath: this._parseBoolean(props[AssetProperties.httpProxyPath]),
httpProxyMethod: this._parseBoolean(
Expand Down Expand Up @@ -150,24 +147,18 @@ export class AssetPropertyMapper {
}

if (datasource?.dataAddressType === 'Http') {
props[AssetProperties.httpParameterizationEnabled] = this._encodeBoolean(
datasource?.enableParameterization,
props[AssetProperties.httpProxyBody] = this._encodeBoolean(
datasource?.proxyBody,
);
props[AssetProperties.httpProxyQueryParams] = this._encodeBoolean(
datasource?.proxyQueryParams,
);
props[AssetProperties.httpProxyMethod] = this._encodeBoolean(
datasource?.proxyMethod,
);
props[AssetProperties.httpProxyPath] = this._encodeBoolean(
datasource?.proxyPath,
);

if (datasource?.enableParameterization) {
props[AssetProperties.httpProxyBody] = this._encodeBoolean(
datasource?.proxyBody,
);
props[AssetProperties.httpProxyQueryParams] = this._encodeBoolean(
datasource?.proxyQueryParams,
);
props[AssetProperties.httpProxyMethod] = this._encodeBoolean(
datasource?.proxyMethod,
);
props[AssetProperties.httpProxyPath] = this._encodeBoolean(
datasource?.proxyPath,
);
}
}

return removeNullValues(props);
Expand Down
1 change: 0 additions & 1 deletion src/app/core/services/models/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export interface Asset {

// HTTP Parameterization Metadata
dataSourceType: string;
httpParameterizationEnabled: boolean | null;
httpProxyBody: boolean | null;
httpProxyPath: boolean | null;
httpProxyMethod: boolean | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ export class AssetCreateDialogForm {
return this.all.value;
}

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

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

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

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

constructor(
private formBuilder: FormBuilder,
private activeFeatureSet: ActiveFeatureSet,
Expand Down Expand Up @@ -93,12 +109,6 @@ export class AssetCreateDialogForm {
);
}

onToggleParameterizationClick() {
this.datasource.controls.enableParameterization.setValue(
!this.datasource.controls.enableParameterization.value,
);
}

onHttpHeadersRemoveClick(index: number) {
this.datasource.controls.httpHeaders.removeAt(index);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,95 +163,93 @@ <h1 mat-dialog-title>Create New Asset</h1>
</mat-form-field>

<ng-container *ngIf="form.dataAddressType === 'Http'">
<!-- Parameterization Off, combine Method + URL -->
<ng-container
*ngIf="!form.datasource.controls.enableParameterization.value">
<div class="flex flex-row space-x-[10px]">
<!-- Method (Rest-Api) -->
<mat-form-field
*ngIf="form.datasource.controls.httpMethod; let ctrl"
class="w-1/3">
<mat-label>Method</mat-label>
<mat-select [formControl]="ctrl">
<mat-option
*ngFor="let method of methods"
[value]="method"
>{{ method }}</mat-option
>
</mat-select>
</mat-form-field>

<!-- URL (Rest-Api) -->
<mat-form-field
*ngIf="form.datasource.controls.httpUrl; let ctrl"
class="grow">
<mat-label>URL</mat-label>
<input
matInput
[formControl]="ctrl"
[placeholder]="'https://'" />
<mat-error *ngIf="ctrl.invalid && ctrl.errors?.pattern">
{{ validationMessages.invalidUrlMessage }}
</mat-error>
</mat-form-field>
</div>

<!-- Add Parameterization Button -->
<div class="flex flex-row mb-[10px]">
<button
mat-button
color="primary"
(click)="form.onToggleParameterizationClick()">
Enable API Parameterization
</button>
</div>
</ng-container>
<!-- Toggle Parameterization Button -->
<div class="flex flex-row mb-[10px]">
<button
mat-button
[color]="form.parameterizationEnabled ? 'warn' : 'primary'"
(click)="form.onToggleParameterizationClick()">
{{ form.parameterizationEnabled ? 'Disable' : 'Enable' }} API
Parameterization
</button>
</div>

<div class="form-section-title">Method</div>

<!-- Method (Rest-Api) -->
<mat-form-field
*ngIf="form.datasource.controls.httpMethod; let ctrl">
<mat-label>
{{ form.proxyMethod ? 'Default' : '' }} Method
</mat-label>
<mat-select [formControl]="ctrl">
<mat-option *ngFor="let method of methods" [value]="method">{{
method
}}</mat-option>
</mat-select>
<mat-hint *ngIf="form.proxyMethod">
When no method override is set, this method will be used.
</mat-hint>
</mat-form-field>

<!-- Toggle Proxy Method Button -->
<div
*ngIf="form.datasource.controls.proxyMethod; let ctrl"
class="flex flex-row mb-[10px]">
<button
mat-button
[color]="ctrl.value ? 'warn' : 'primary'"
(click)="ctrl.setValue(!ctrl.value)">
{{ ctrl.value ? 'Remove' : 'Enable' }} Method Parameterization
</button>
</div>

<div class="form-section-title">URL</div>

<!-- Parameterization On: Multiple Sections -->
<ng-container
*ngIf="form.datasource.controls.enableParameterization.value">
<!-- Remove Parameterization Button -->
<div class="flex flex-row mb-[10px]">
<button
mat-button
color="warn"
(click)="form.onToggleParameterizationClick()">
Remove API Parameterization
</button>
</div>

<div class="form-section-title">Method</div>

<!-- Method (Rest-Api) -->
<!-- Base Path (Rest-Api) -->
<mat-form-field
*ngIf="form.datasource.controls.httpUrl; let ctrl"
class="grow">
<mat-label *ngIf="!form.datasource.controls.proxyPath.value">
URL
</mat-label>
<mat-label *ngIf="form.datasource.controls.proxyPath.value">
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>

<!-- Base Path (Rest-Api) -->
<ng-container *ngIf="form.datasource.controls.proxyPath.value">
<mat-form-field
*ngIf="form.datasource.controls.httpMethod; let ctrl">
<mat-label
>{{
form.datasource.controls.proxyMethod.value
? 'Default '
: ''
}}Method</mat-label
>
<mat-select [formControl]="ctrl">
<mat-option *ngFor="let method of methods" [value]="method">{{
method
}}</mat-option>
</mat-select>
*ngIf="form.datasource.controls.defaultPath; let ctrl"
class="grow">
<mat-label>Default Path</mat-label>
<input
matInput
[formControl]="ctrl"
[placeholder]="'sub-path/endpoint'" />
<mat-hint
>When no path override is set, this path will be used.
</mat-hint>
</mat-form-field>

<!-- Toggle Proxy Method Button -->
<div
*ngIf="form.datasource.controls.proxyMethod; let ctrl"
class="flex flex-row mb-[10px]">
<button
mat-button
[color]="ctrl.value ? 'warn' : 'primary'"
(click)="ctrl.setValue(!ctrl.value)">
{{ ctrl.value ? 'Remove' : 'Enable' }} Method Parameterization
</button>
</div>
</ng-container>

<!-- Toggle Proxy Method Button -->
<div
*ngIf="form.datasource.controls.proxyPath; let ctrl"
class="flex flex-row mb-[10px]">
<button
mat-button
[color]="ctrl.value ? 'warn' : 'primary'"
(click)="ctrl.setValue(!ctrl.value)">
{{ ctrl.value ? 'Remove' : 'Enable' }} Path Parameterization
</button>
</div>

<div class="form-section-title">Authentication</div>

<!-- Add Authentication Button -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export class AssetDatasourceFormBuilder {
httpAuthHeaderValue: ['', Validators.required],
httpAuthHeaderSecretName: ['', Validators.required],

enableParameterization: [false],
defaultPath: [''],
proxyMethod: [false],
proxyPath: [false],
Expand All @@ -53,7 +52,6 @@ export class AssetDatasourceFormBuilder {
const httpAuth = value.httpAuthHeaderType !== 'None';
const httpAuthByValue = value.httpAuthHeaderType === 'Value';
const httpAuthByVault = value.httpAuthHeaderType === 'Vault-Secret';
let parametrization = !!value.enableParameterization;
let proxyPath = !!value.proxyPath;

return {
Expand All @@ -74,12 +72,11 @@ export class AssetDatasourceFormBuilder {
httpAuthHeaderValue: http && httpAuthByValue,
httpAuthHeaderSecretName: http && httpAuthByVault,

enableParameterization: http,
defaultPath: http && parametrization && proxyPath,
proxyMethod: http && parametrization,
proxyPath: http && parametrization,
proxyQueryParams: http && parametrization,
proxyBody: http && parametrization,
defaultPath: http && proxyPath,
proxyMethod: http,
proxyPath: http,
proxyQueryParams: http,
proxyBody: http,

httpHeaders: http,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export interface AssetDatasourceFormModel {
httpAuthHeaderValue: FormControl<string>;
httpAuthHeaderSecretName: FormControl<string>;
httpHeaders: FormArray<FormGroup<HttpDatasourceHeaderFormModel>>;

enableParameterization: FormControl<boolean>;
proxyMethod: FormControl<boolean>;
proxyPath: FormControl<boolean>;
proxyQueryParams: FormControl<boolean>;
Expand Down

0 comments on commit ff5bfa4

Please sign in to comment.