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

Merge branch 'fix/repository-description' into 'master'

bug fix

See merge request !31
parents ff9bffc7 57107b4d
No related branches found
No related tags found
1 merge request!31bug fix
......@@ -52,8 +52,8 @@
<div class="field">
<label for="x-result">x-result</label>
<div>
<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/>
<input *ngIf="openApi.info['x-format'] !== 'ISO 19115' " name="x-result" [(ngModel)]="openApi.info['x-result']" value="json" fullWidth nbInput />
<input *ngIf="openApi.info['x-format'] === 'ISO 19115' " name="x-result" [(ngModel)]="openApi.info['x-result']" value="xml" fullWidth nbInput />
</div>
</div>
......
......@@ -34,7 +34,7 @@ export class PublishApiComponent implements OnInit {
parametersTypes: string[];
shemaTypes: string[];
httpStatusCodes: string[];
catalogList: { title: string, catId: string, server: string, type: string }[] = [];
catalogList: { title: string, catId: string, server: string, type: string, version?: string, description?: string, result?: string}[] = [];
canNext = false;
type: string;
initLabelThree = false;
......@@ -59,13 +59,16 @@ export class PublishApiComponent implements OnInit {
const titlePromises: Promise<any>[] = [];
response.forEach((catalog) => {
titlePromises.push(
this.catalogService.getCatalogContentById(catalog.catId).toPromise().then(
(response2) => {
this.catalogList.push({
catId: catalog.catId,
title: this.getTitleFromFdpApi(response2),
server: this.getServerFromFdpApi(response2),
type: this.getTypeFromFdpApi(response2)
type: this.getTypeFromFdpApi(response2),
description: this.getDescriptionFromFdpApi(response2),
version: this.getVersionFromFdpApi(response2),
});
}).catch(
(error) => {
......@@ -103,6 +106,11 @@ export class PublishApiComponent implements OnInit {
},
error: () => {
this.openApi = new OpenApi(catId, this.getServer(catId));
this.openApi.info['x-format'] = this.getType(catId);
this.openApi.info['title'] = this.getTitle(catId);
this.openApi.info['version'] = this.getVersion(catId);
this.openApi.info['description'] = this.getDescription(catId);
this.openApi.info['x-result'] = this.getResult(catId);
this.openApi.paths.push(this.openApiDTOMappingService.getEmptyPath(OpenApiTag.search));
this.openApi.paths.push(this.openApiDTOMappingService.getEmptyPath(OpenApiTag.dataset));
this.canNext = true;
......@@ -144,6 +152,24 @@ export class PublishApiComponent implements OnInit {
return '';
}
getDescriptionFromFdpApi(fdpApiResponse: FdpApiResponseItem[]): string {
for (const item of fdpApiResponse) {
if (item.predicate.localName === 'description') {
return item.object.label;
}
}
return '';
}
getVersionFromFdpApi(fdpApiResponse: FdpApiResponseItem[]): string {
for (const item of fdpApiResponse) {
if (item.predicate.localName === 'hasVersion') {
return item.object.label;
}
}
return '';
}
getServer(catId: string): string {
for (const catalog of this.catalogList) {
if (catalog.catId === catId) {
......@@ -162,6 +188,42 @@ export class PublishApiComponent implements OnInit {
return null;
}
getTitle(catId: string): string {
for (const catalog of this.catalogList) {
if(catalog.catId === catId) {
return catalog.title;
}
}
return null;
}
getVersion(catId: string): string {
for (const catalog of this.catalogList) {
if(catalog.catId === catId) {
return catalog.version;
}
}
return null;
}
getDescription(catId: string): string {
for (const catalog of this.catalogList) {
if(catalog.catId === catId) {
return catalog.description;
}
}
return null;
}
getResult(catId: string): string {
for (const catalog of this.catalogList) {
if(catalog.catId === catId) {
return (catalog.type === "ISO 19115") ? 'xml' : 'json';
}
}
return null;
}
savePublication() {
this.openApiService.publishOpenApi(this.openApi).subscribe();
}
......
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