Skip to content
Snippets Groups Projects
Commit 543e2e6e authored by Baptiste Toulemonde's avatar Baptiste Toulemonde
Browse files

featuring xml parsing to dcat

parent 59faa3fd
No related branches found
No related tags found
1 merge request!26Feature/mapping from iso19115
......@@ -40,7 +40,8 @@
<ng-container *ngIf="spinners.get(path.pathName); else preview"></ng-container>
<ng-template #preview>
<ng-container *ngIf="request.tags != null && request.tags.length > 0">
<pre *ngIf="request.tags[0] === tagEnum.dataset">{{ previews.get(path.pathName)|json}}</pre>
<pre *ngIf="request.tags[0] === tagEnum.dataset && openApi.info['x-result'] === 'xml' ">{{ previews.get(path.pathName) }}</pre>
<pre *ngIf="request.tags[0] === tagEnum.dataset && openApi.info['x-result'] === 'json' ">{{ previews.get(path.pathName) | json }}</pre>
<ul *ngIf="request.tags[0] === tagEnum.search">
<li *ngFor="let datasetId of previews.get(path.pathName)">{{datasetId}}</li>
</ul>
......
......@@ -179,12 +179,13 @@ export class DatasetsComponent implements OnInit, AfterViewChecked, AfterContent
}
}
}
console.log(myHeaders)
const requestHref = url.href;
let result: any = null;
try {
const response = await this.getRequestPromiseByHttpMethod(httpMethod as HttpMethod, requestHref, myHeaders);
const response = await this.getRequestPromiseByHttpMethod(httpMethod as HttpMethod, requestHref, myHeaders, pathName);
switch (this.getTagByPathName(pathName, httpMethod)) {
case OpenApiTag.search:
......@@ -202,12 +203,19 @@ export class DatasetsComponent implements OnInit, AfterViewChecked, AfterContent
return result;
}
getRequestPromiseByHttpMethod(httpMethod: HttpMethod, requestUrl: string, headers: any): Promise<any> {
getRequestPromiseByHttpMethod(httpMethod: HttpMethod, requestUrl: string, headers: any, pathName: string): Promise<any> {
let requestObs: Observable<any>;
switch (httpMethod.toLowerCase()) {
case HttpMethod.GET:
requestObs = this.httpClient.get(requestUrl, { headers });
if (this.openApi.info['x-result'] === "xml" && this.getTagByPathName(pathName, httpMethod) == OpenApiTag.dataset) {
requestObs = this.httpClient.get(requestUrl, { headers, responseType: 'text' });
} else {
requestObs = this.httpClient.get(requestUrl, { headers });
}
}
return requestObs.toPromise();
......@@ -342,7 +350,7 @@ export class DatasetsComponent implements OnInit, AfterViewChecked, AfterContent
}
private getListFromDialog(searchRequestPathName: string, searchRequestHttpMethod: string,
datasetRequestPathName: string, datasetRequestHttpMethod: string) {
datasetRequestPathName: string, datasetRequestHttpMethod: string) {
this.launchRequest(searchRequestPathName, searchRequestHttpMethod, false).then((response) => {
this.dialog.open(DatasetsDialogComponent, {
width: '100vw',
......
<ng-container *ngIf="type !== 'ISO 19115'; else xml">
<form #form="ngForm">
<div class="card-row">
<div class="card-col">
......@@ -169,4 +170,7 @@
</nb-card-footer>
</nb-card>
</div>
</div>
\ No newline at end of file
</div>
</ng-container>
<ng-template #xml></ng-template>
\ No newline at end of file
......@@ -52,7 +52,9 @@
<div class="field">
<label for="x-result">x-result</label>
<div>
<input name="x-result" [(ngModel)]="openApi.info['x-result']" fullWidth nbInput />
<input *ngIf="openApi.info['x-format'] !== 'ISO 19115' " name="x-result" [(ngModel)]="openApi.info['x-result']" value="json" fullWidth nbInput disabled/>
<input *ngIf="openApi.info['x-format'] === 'ISO 19115' " name="x-result" [(ngModel)]="openApi.info['x-result']" value="xml" fullWidth nbInput disabled/>
</div>
</div>
<div class="field">
......@@ -240,7 +242,7 @@
<td>
<div *ngFor="let content of response.contents">
<input name="default" [(ngModel)]="content.contentType" nbInput
disabled />
/>
</div>
</td>
<td>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment