forked from eclipse-edc/DataDashboard
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Asset create dialog edit form (#788)
- Loading branch information
Showing
56 changed files
with
4,062 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...component-library/data-address/data-address-type-select/data-address-type-select-items.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 12 additions & 16 deletions
28
...asset-form-data-address-type-select/edit-asset-form-data-address-type-select.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,26 @@ | ||
import {Component, Input, OnChanges} from '@angular/core'; | ||
import {Component, Input} from '@angular/core'; | ||
import {FormControl} from '@angular/forms'; | ||
import {SimpleChangesTyped} from '../../../core/utils/angular-utils'; | ||
import {DataAddressType} from '../../data-address/data-address-type-select/data-address-type'; | ||
import {dataAddressTypeSelectItems} from '../../data-address/data-address-type-select/data-address-type-select-items'; | ||
import {DataAddressTypeSelectMode} from '../../data-address/data-address-type-select/data-address-type-select-mode'; | ||
|
||
@Component({ | ||
selector: 'edit-asset-form-data-address-type-select', | ||
templateUrl: 'edit-asset-form-data-address-type-select.component.html', | ||
}) | ||
export class EditAssetFormDataAddressTypeSelectComponent implements OnChanges { | ||
export class EditAssetFormDataAddressTypeSelectComponent { | ||
@Input() | ||
label!: string; | ||
|
||
@Input() | ||
control!: FormControl<DataAddressType | null>; | ||
|
||
@Input() | ||
mode: DataAddressTypeSelectMode = 'Datasource-Create'; | ||
|
||
items = dataAddressTypeSelectItems(this.mode); | ||
ngOnChanges( | ||
changes: SimpleChangesTyped<EditAssetFormDataAddressTypeSelectComponent>, | ||
) { | ||
if (changes.mode) { | ||
this.items = dataAddressTypeSelectItems(this.mode); | ||
} | ||
} | ||
items = [ | ||
{ | ||
id: 'Http', | ||
label: 'REST-API Endpoint', | ||
}, | ||
{ | ||
id: 'Custom-Data-Address-Json', | ||
label: `Custom Datasource-Create Config (JSON)`, | ||
}, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
src/app/core/services/asset-data-source-mapper-legacy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import {Injectable} from '@angular/core'; | ||
import {UiDataSource} from '@sovity.de/edc-client'; | ||
import {AssetDatasourceFormValue} from '../../routes/connector-ui/asset-page/asset-edit-dialog/form/model/asset-datasource-form-model'; | ||
import {HttpDatasourceHeaderFormValue} from '../../routes/connector-ui/asset-page/asset-edit-dialog/form/model/http-datasource-header-form-model'; | ||
import {getAuthFields} from '../utils/form-value-utils'; | ||
import {QueryParamsMapper} from './query-params-mapper'; | ||
|
||
@Injectable({providedIn: 'root'}) | ||
export class AssetDataSourceMapperLegacy { | ||
constructor(private queryParamsMapper: QueryParamsMapper) {} | ||
|
||
buildDataSourceOrNullLegacy( | ||
formValue: AssetDatasourceFormValue, | ||
): UiDataSource | null { | ||
if ( | ||
!formValue?.dataAddressType || | ||
formValue.dataAddressType === 'Unchanged' | ||
) { | ||
return null; | ||
} | ||
return this.buildDataSourceLegacy(formValue); | ||
} | ||
|
||
buildDataSourceLegacy(formValue: AssetDatasourceFormValue): UiDataSource { | ||
switch (formValue?.dataAddressType) { | ||
case 'Custom-Data-Address-Json': | ||
return this.buildCustomDataSourceLegacy(formValue); | ||
case 'On-Request': | ||
return this.buildOnRequestDataSourceLegacy(formValue); | ||
case 'Http': | ||
return this.buildHttpDataSourceLegacy(formValue); | ||
default: | ||
throw new Error( | ||
`Invalid Data Address Type ${formValue?.dataAddressType}`, | ||
); | ||
} | ||
} | ||
|
||
private buildCustomDataSourceLegacy( | ||
formValue: AssetDatasourceFormValue, | ||
): UiDataSource { | ||
const json = JSON.parse(formValue.dataDestination?.trim()!!); | ||
return { | ||
type: 'CUSTOM', | ||
customProperties: json, | ||
}; | ||
} | ||
|
||
private buildHttpDataSourceLegacy( | ||
formValue: AssetDatasourceFormValue, | ||
): UiDataSource { | ||
const baseUrl = this.queryParamsMapper.getBaseUrlWithoutQueryParams( | ||
formValue.httpUrl!, | ||
)!; | ||
const queryString = this.queryParamsMapper.getFullQueryString( | ||
formValue.httpUrl!, | ||
formValue.httpQueryParams ?? [], | ||
); | ||
|
||
const authFields = getAuthFields(formValue); | ||
|
||
return { | ||
type: 'HTTP_DATA', | ||
httpData: { | ||
method: formValue.httpMethod, | ||
baseUrl, | ||
queryString: queryString ?? undefined, | ||
authHeaderName: authFields.authHeaderName ?? undefined, | ||
authHeaderValue: { | ||
secretName: authFields.authHeaderSecretName ?? undefined, | ||
rawValue: authFields.authHeaderValue ?? undefined, | ||
}, | ||
headers: this.buildHttpHeaders(formValue.httpHeaders ?? []), | ||
enableMethodParameterization: formValue.httpProxyMethod, | ||
enablePathParameterization: formValue.httpProxyPath, | ||
enableQueryParameterization: formValue.httpProxyQueryParams, | ||
enableBodyParameterization: formValue.httpProxyBody, | ||
}, | ||
}; | ||
} | ||
|
||
private buildOnRequestDataSourceLegacy( | ||
formValue: AssetDatasourceFormValue, | ||
): UiDataSource { | ||
return { | ||
type: 'ON_REQUEST', | ||
onRequest: { | ||
contactEmail: formValue.contactEmail!!, | ||
contactPreferredEmailSubject: formValue.contactPreferredEmailSubject!!, | ||
}, | ||
}; | ||
} | ||
|
||
private buildHttpHeaders( | ||
headers: HttpDatasourceHeaderFormValue[], | ||
): Record<string, string> { | ||
return Object.fromEntries( | ||
headers | ||
.map((header) => [ | ||
header.headerName?.trim() || '', | ||
header.headerValue?.trim() || '', | ||
]) | ||
.filter((a) => a[0] && a[1]), | ||
); | ||
} | ||
} |
Oops, something went wrong.