From 4a8ecce1b9f4e4d43465404c33b017a2d8f935dd Mon Sep 17 00:00:00 2001 From: Charly <maeder@cines.fr> Date: Thu, 22 Jul 2021 17:25:54 +0200 Subject: [PATCH 1/3] Add process when showing catalog list to clean not found catalog in fdp-api --- src/app/publishapi/publishapi.component.ts | 11 +++++++++-- src/app/services/catalog.service.ts | 23 ++++++++++++---------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/app/publishapi/publishapi.component.ts b/src/app/publishapi/publishapi.component.ts index 32d3a2b00..19c5c2714 100644 --- a/src/app/publishapi/publishapi.component.ts +++ b/src/app/publishapi/publishapi.component.ts @@ -36,7 +36,7 @@ export class PublishApiComponent implements OnInit { httpStatusCodes: string[]; catalogList: { title: string, catId: string, server: string }[] = []; canNext = false; - initLabelThree: boolean = false; + initLabelThree = false; ngOnInit(): void { this.openApi = new OpenApi(null, null); @@ -66,7 +66,14 @@ export class PublishApiComponent implements OnInit { server: this.getServerFromFdpApi(response2) }); }).catch( - () => this.catalogList.push({ catId: catalog.catId, title: catalog.catId, server: null })) + (error) => { + if (error.status === 404) { + this.catalogService.deleteCatalog(catalog.catId); + } else { + this.catalogList.push({ catId: catalog.catId, title: catalog.catId, server: null }); + } + } + ) ); }); Promise.all(titlePromises).finally(() => { diff --git a/src/app/services/catalog.service.ts b/src/app/services/catalog.service.ts index f839c4026..729d79ef2 100644 --- a/src/app/services/catalog.service.ts +++ b/src/app/services/catalog.service.ts @@ -1,6 +1,5 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { AppConfiguration } from '../AppConfiguration'; import { environment } from 'src/environments/environment'; import { TokenStorageService } from '../authentication/services/token-storage.service'; @@ -8,13 +7,13 @@ export interface FdpApiResponseItem { subject: { namespace: string, localName: string - }, + }; predicate: { namespace: string, localName: string - }, - object: any, - context: string + }; + object: any; + context: string; } const FDP_URL = environment.fdpUrl; @@ -26,31 +25,35 @@ export class CatalogService { httpOptionsSmartHarvester = { headers: new HttpHeaders({ - 'Authorization': 'Bearer '+ this.tokenService.getToken() + Authorization: 'Bearer ' + this.tokenService.getToken() }) }; httpOptionsFDP = { headers: new HttpHeaders({ - 'Authorization': 'Bearer '+ this.tokenService.getFDPToken() + Authorization: 'Bearer ' + this.tokenService.getFDPToken() }) }; constructor( - private appConfig: AppConfiguration, private tokenService: TokenStorageService, private http: HttpClient ) { } get smartApiUrl(): string { - return environment.smartharvesterUrl + '/harvester/api' + return environment.smartharvesterUrl + '/harvester/api'; } getAllCatalogId() { const user = this.tokenService.getUser(); - return this.http.get<{ catId: string, uuid: string }[]>(this.smartApiUrl + '/user/' + user.email + '/catalogs', this.httpOptionsSmartHarvester); + return this.http.get<{ catId: string, uuid: string }[]>(this.smartApiUrl + '/user/' + user.email + '/catalogs', + this.httpOptionsSmartHarvester); } getCatalogContentById(catId: string) { return this.http.get<FdpApiResponseItem[]>(FDP_URL + '/catalog/' + catId, this.httpOptionsFDP); } + + deleteCatalog(catId: string) { + return this.http.delete(this.smartApiUrl + '/catalog/' + catId, this.httpOptionsSmartHarvester); + } } -- GitLab From f14d9de525fb4480db9643b6e3136b3e39bc2dbf Mon Sep 17 00:00:00 2001 From: Charly <maeder@cines.fr> Date: Fri, 23 Jul 2021 13:08:06 +0200 Subject: [PATCH 2/3] Fix catalog deletion , bug in copy required param and set primary required param --- src/app/publishapi/publishapi.component.html | 21 +++++++++++++++----- src/app/publishapi/publishapi.component.ts | 6 ++++-- src/app/services/catalog.service.ts | 2 +- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/app/publishapi/publishapi.component.html b/src/app/publishapi/publishapi.component.html index 1dbd5fd3c..f667a8174 100644 --- a/src/app/publishapi/publishapi.component.html +++ b/src/app/publishapi/publishapi.component.html @@ -161,25 +161,36 @@ <tbody> <tr *ngFor="let parameter of request.parameters"> <td> - <input [(ngModel)]="parameter.name" nbInput /> + <nb-form-field> + <nb-icon *ngIf="parameter.required" nbSuffix + icon="question-mark-circle-outline" pack="eva" + nbTooltip="Dataset id (Required parameter)" + nbTooltipPlacement="right"></nb-icon> + <input [(ngModel)]="parameter.name" + [status]="parameter.required ? 'primary' : 'basic'" nbInput /> + </nb-form-field> </td> <td> - <nb-select [(ngModel)]="parameter.in"> + <nb-select [(ngModel)]="parameter.in" + [status]="parameter.required ? 'primary' : 'basic'"> <nb-option *ngFor="let type of parametersTypes" value="{{type}}"> {{type}}</nb-option> </nb-select> </td> <td> - <nb-select [(ngModel)]="parameter.schema.type"> + <nb-select [(ngModel)]="parameter.schema.type" + [status]="parameter.required ? 'primary' : 'basic'"> <nb-option *ngFor="let type of shemaTypes" value="{{type}}">{{type}} </nb-option> </nb-select> </td> <td> - <input name="default" [(ngModel)]="parameter.schema.default" nbInput /> + <input name="default" [(ngModel)]="parameter.schema.default" + [status]="parameter.required ? 'primary' : 'basic'"nbInput /> </td> <td> - <input name="default" [(ngModel)]="parameter.description" nbInput /> + <input name="default" [(ngModel)]="parameter.description" + [status]="parameter.required ? 'primary' : 'basic'" nbInput /> </td> <td> <nb-icon icon="copy-outline" nbTooltip="Duplicate parameter" diff --git a/src/app/publishapi/publishapi.component.ts b/src/app/publishapi/publishapi.component.ts index 19c5c2714..2079ab1d9 100644 --- a/src/app/publishapi/publishapi.component.ts +++ b/src/app/publishapi/publishapi.component.ts @@ -68,7 +68,7 @@ export class PublishApiComponent implements OnInit { }).catch( (error) => { if (error.status === 404) { - this.catalogService.deleteCatalog(catalog.catId); + this.catalogService.deleteCatalog(catalog.catId).subscribe(); } else { this.catalogList.push({ catId: catalog.catId, title: catalog.catId, server: null }); } @@ -205,7 +205,9 @@ export class PublishApiComponent implements OnInit { } duplicateParameter(request: Request, parameter: Parameter): void { - request.parameters.unshift(cloneDeep(parameter)); + const newParam = cloneDeep(parameter); + newParam.required = false; + request.parameters.unshift(newParam); } deleteParameter(request: Request, parameter: Parameter): void { diff --git a/src/app/services/catalog.service.ts b/src/app/services/catalog.service.ts index 729d79ef2..6c90a711a 100644 --- a/src/app/services/catalog.service.ts +++ b/src/app/services/catalog.service.ts @@ -54,6 +54,6 @@ export class CatalogService { } deleteCatalog(catId: string) { - return this.http.delete(this.smartApiUrl + '/catalog/' + catId, this.httpOptionsSmartHarvester); + return this.http.delete(this.smartApiUrl + '/catalogs/' + catId, this.httpOptionsSmartHarvester); } } -- GitLab From e61ca96af578cfbe2ee6a6472ed04847f5b51827 Mon Sep 17 00:00:00 2001 From: Charly <maeder@cines.fr> Date: Fri, 23 Jul 2021 16:59:26 +0200 Subject: [PATCH 3/3] Set nebular theme for catalog creation page and add required star in label --- src/app/repository/repository.component.html | 57 ++++++++++---------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/src/app/repository/repository.component.html b/src/app/repository/repository.component.html index baabf0007..3a97da5f7 100644 --- a/src/app/repository/repository.component.html +++ b/src/app/repository/repository.component.html @@ -1,48 +1,49 @@ +<form [formGroup]="Form"> -<form [formGroup]="Form" > - - <label>Upload and fill form width repository description file: </label><br> - <input type="file" id="repofile" name="repofile " class="btn btn-primary" (change)="yamlToRepository()" ><br> - <label>Or describe your repository and save a new file for publishing in the FDP database:</label><br> + <label>Upload and fill form width repository description file: </label><br> + <input type="file" id="repofile" name="repofile " class="btn btn-primary" (change)="yamlToRepository()"><br> + <label>Or describe your repository and save a new file for publishing in the FDP database:</label><br> <div> - <label>Repository Type</label> - <select class="form-control" formControlName="repotype" required> - <option value="Dataverse">Dataverse</option>> - <option value="Custom">Custom</option>> - </select> + <label>Repository Type*</label> + <nb-select class="form-control" formControlName="repotype" required> + <nb-option value="Dataverse">Dataverse</nb-option> + <nb-option value="Custom">Custom</nb-option> + </nb-select> </div> <div class="form-group"> - <label>Repository Name</label> - <input type="text" class="form-control" formControlName="reponame" required> + <label>Repository Name*</label> + <input nbInput type="text" class="form-control" formControlName="reponame" required> </div> - <div class="form-group"> + <div class="form-group"> <label>Description</label> - <textarea class="form-control" formControlName="repodescription"></textarea> + <textarea nbInput class="form-control" formControlName="repodescription"></textarea> </div> <div class="form-group"> - <label>url</label> - <input type="text" class="form-control" formControlName="repourl" required> + <label>url*</label> + <input nbInput type="text" class="form-control" formControlName="repourl" required> </div> <div class="form-group"> <label>Version</label> - <input type="text" class="form-control" formControlName="repoversion"> - </div> <div class="form-group"> - <label>License</label> - <input type="text" class="form-control" formControlName="repolicence"> -</div> <div class="form-group"> - <label>Language</label> - <input type="text" class="form-control" formControlName="repolanguage"> -</div> + <input nbInput type="text" class="form-control" formControlName="repoversion"> + </div> + <div class="form-group"> + <label>License</label> + <input nbInput type="text" class="form-control" formControlName="repolicence"> + </div> + <div class="form-group"> + <label>Language</label> + <input nbInput type="text" class="form-control" formControlName="repolanguage"> + </div> <div> <br> - <button type="submit" (click)="repositorytoyaml()" class="btn btn-primary">Save repository description file</button> + <button nbButton type="submit" (click)="repositorytoyaml()" class="btn btn-primary">Save repository description file</button> </div> <div> <br> - <button type="submit" (click)="publishCatalog()" class="btn btn-success" [disabled]="!Form.valid">Publish catalog description in FDP</button> + <button nbButton type="submit" (click)="publishCatalog()" class="btn btn-success" [disabled]="!Form.valid">Publish catalog + description in FDP</button> </div> -</form> - +</form> \ No newline at end of file -- GitLab