From 0f653d5035aebc88f77f8482d953eb8f74d2df14 Mon Sep 17 00:00:00 2001 From: Baptiste Toulemonde <toulemonde@cines.fr> Date: Fri, 16 Jul 2021 09:03:27 +0200 Subject: [PATCH] delete fdp & smartharvester settings: config from environement and get user connected to provide tokens --- src/app/app-routing.module.ts | 4 ++-- src/app/authentication/services/auth.service.ts | 3 ++- src/app/dashboard/dashboard.component.ts | 4 ++-- src/app/datasets/datasets.component.ts | 6 ++++-- src/app/datasets/services/dataset-crud.service.ts | 7 ++++--- src/app/mapping/mapping.component.ts | 6 ++++-- src/app/repository/repository.component.ts | 3 ++- src/app/repository/services/publish-repository.service.ts | 4 ++-- src/app/services/catalog.service.ts | 4 +++- 9 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 292358d56..a78e3ca46 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -30,8 +30,8 @@ const routes: ICustomRoute[] = [ { path: 'repositoryinfo', component: RepositoryinfoComponent }, { path: 'accessapi', component: AccessapiComponent }, { path: 'stats', component: StatsComponent }, - { path: 'settingfdp', component: SettingfdpComponent }, - { path: 'settingsmartharvester', component: SettingsmartapiComponent }, + /* { path: 'settingfdp', component: SettingfdpComponent }, + { path: 'settingsmartharvester', component: SettingsmartapiComponent },*/ { path: 'publishapi', component: PublishApiComponent }, { path: 'advancedsearch', component: SearchComponent }, ] diff --git a/src/app/authentication/services/auth.service.ts b/src/app/authentication/services/auth.service.ts index be1686c49..a4ee7ca60 100644 --- a/src/app/authentication/services/auth.service.ts +++ b/src/app/authentication/services/auth.service.ts @@ -9,6 +9,7 @@ import { environment } from 'src/environments/environment'; const AUTH_API = environment.smartharvesterUrl + '/harvester/auth'; +const FDP_URL = environment.fdpUrl; const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) }; @@ -53,7 +54,7 @@ export class AuthService { getF2DSAuthToken(credentials): Observable<any> { - return this.http.post(this.appConfig.fdpurl + '/tokens', { + return this.http.post(FDP_URL + '/tokens', { email: credentials.email, password: credentials.password }, httpOptions); diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts index 83fdcceab..2dab938b9 100644 --- a/src/app/dashboard/dashboard.component.ts +++ b/src/app/dashboard/dashboard.component.ts @@ -52,7 +52,7 @@ export class DashboardComponent implements OnInit { link: '/dashboard/simplesearch', pathMatch: 'full' }, - { + /*{ title: 'Settings', icon: 'options-2-outline', children: [ @@ -67,7 +67,7 @@ export class DashboardComponent implements OnInit { pathMatch: 'full' } ], - }, + },*/ ]; constructor(private readonly sidebarService: NbSidebarService, diff --git a/src/app/datasets/datasets.component.ts b/src/app/datasets/datasets.component.ts index e823b558e..e57dc1e1b 100644 --- a/src/app/datasets/datasets.component.ts +++ b/src/app/datasets/datasets.component.ts @@ -4,6 +4,7 @@ import { DatasetCrudService } from './services/dataset-crud.service'; import { OpenApi } from '../publishapi/class/openapi'; import { ParameterType } from '../publishapi/class/openapi-enum'; import { OpenApiTag } from '../publishapi/class/openapi-dto'; +import { environment } from 'src/environments/environment.prod'; interface RequestInfo { value?: string; @@ -26,6 +27,7 @@ export class DatasetsComponent implements OnInit { values = new Map<string, Map<string, Map<string, RequestInfo>>>(); previews = new Map<string, any>(); spinners = new Map<string, boolean>(); + FDP_URL = environment.fdpUrl; @@ -300,8 +302,8 @@ export class DatasetsComponent implements OnInit { data = '\@prefix dcat: <http://www.w3.org/ns/dcat#>.\n\ @prefix dct: <http://purl.org/dc/terms/>.\n\ @prefix language: <http://id.loc.gov/vocabulary/iso639-1/>.\n\ - @prefix s: <'+ this.appConfig.fdpurl + '/>.\n\ - @prefix c: <'+ this.appConfig.fdpurl + '/catalog/>.\n\ + @prefix s: <'+ this.FDP_URL + '/>.\n\ + @prefix c: <'+ this.FDP_URL+ '/catalog/>.\n\ s:new\n\ a dcat:Dataset, dcat:Resource;\n\ dct:description ' + description + ';\n\ diff --git a/src/app/datasets/services/dataset-crud.service.ts b/src/app/datasets/services/dataset-crud.service.ts index cafd63ee3..f894912d4 100644 --- a/src/app/datasets/services/dataset-crud.service.ts +++ b/src/app/datasets/services/dataset-crud.service.ts @@ -3,9 +3,10 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { AppConfiguration } from 'src/app/AppConfiguration'; import { TokenStorageService } from 'src/app/authentication/services/token-storage.service'; +import { environment } from 'src/environments/environment.prod'; import { ParseXmlService } from '../../services/parse-xml.service'; - +const FDP_URL = environment.fdpUrl; @Injectable({ providedIn: 'root' }) @@ -26,7 +27,7 @@ export class DatasetCrudService { }) }; - this.http.post(this.appConfig.fdpurl+"/dataset", data, httpOptions ).subscribe( r => { + this.http.post(FDP_URL +"/dataset", data, httpOptions ).subscribe( r => { console.log("resultat: " + JSON.stringify(r)); }, error => console.error("The repository has not been published: " + error) , @@ -50,7 +51,7 @@ export class DatasetCrudService { }) }; - let resultat = this.http.post(this.appConfig.fdpurl+"/distribution", data, httpOptions ).subscribe((r)=>{ + let resultat = this.http.post(FDP_URL +"/distribution", data, httpOptions ).subscribe((r)=>{ console.log('reponse: ', r); return JSON.stringify(resultat); }) ; diff --git a/src/app/mapping/mapping.component.ts b/src/app/mapping/mapping.component.ts index 27239c7d3..511a8a756 100644 --- a/src/app/mapping/mapping.component.ts +++ b/src/app/mapping/mapping.component.ts @@ -2,6 +2,7 @@ import { Component, Input, OnInit, ViewChild } from '@angular/core'; import { Observable, of } from 'rxjs'; import { map } from 'rxjs/operators'; +import { environment } from 'src/environments/environment.prod'; import { AppConfiguration } from '../AppConfiguration'; import { DatasetCrudService } from '../datasets/services/dataset-crud.service'; import { Dataset } from './class/Dataset'; @@ -26,6 +27,7 @@ export class MappingComponent implements OnInit { index: number = 0 first: boolean = true; loading: boolean = false; + FDP_URL = environment.fdpUrl; @ViewChild('autoInput') input; @Input() catalogId: any; @@ -92,8 +94,8 @@ publishDataset() { data = '\@prefix dcat: <http://www.w3.org/ns/dcat#>.\n\ @prefix dct: <http://purl.org/dc/terms/>.\n\ @prefix language: <http://id.loc.gov/vocabulary/iso639-1/>.\n\ - @prefix s: <'+ this.appConfig.fdpurl + '/>.\n\ - @prefix c: <'+ this.appConfig.fdpurl + '/catalog/>.\n\ + @prefix s: <'+ this.FDP_URL + '/>.\n\ + @prefix c: <'+ this.FDP_URL + '/catalog/>.\n\ \n\ s:new\n\ a dcat:Dataset, dcat:Resource;\n\ diff --git a/src/app/repository/repository.component.ts b/src/app/repository/repository.component.ts index 00a7335ae..425df4800 100644 --- a/src/app/repository/repository.component.ts +++ b/src/app/repository/repository.component.ts @@ -22,6 +22,7 @@ export class RepositoryComponent implements OnInit { public importFile: File; public resultat: any; public persistentUrl: string; + FDP_URL = environment.fdpUrl; Form = new FormGroup({ repotype: new FormControl(), @@ -115,7 +116,7 @@ repository:\n\ @prefix dct: <http://purl.org/dc/terms/>.\n\ @prefix foaf: <http://xmlns.com/foaf/0.1/> .\n\ @prefix lang: <http://id.loc.gov/vocabulary/iso639-1/>. \n\ -@prefix fdp: <'+ this.appConfig.fdpurl + '/>.\n\nfdp:new \n\ +@prefix fdp: <'+ this.FDP_URL + '/>.\n\nfdp:new \n\ a dcat:Catalog, dcat:Resource;\n\ dct:description "'+ this.Form.value.repodescription + '";\n\ dct:hasVersion "'+ this.Form.value.repoversion + '";\n\ diff --git a/src/app/repository/services/publish-repository.service.ts b/src/app/repository/services/publish-repository.service.ts index 913909bbc..934455262 100644 --- a/src/app/repository/services/publish-repository.service.ts +++ b/src/app/repository/services/publish-repository.service.ts @@ -10,7 +10,7 @@ interface PersistentUrlResponse { persistentUrl: string; } - +const FDP_URL = environment.fdpUrl; @Injectable({ providedIn: 'root' }) @@ -38,7 +38,7 @@ export class PublishRepositoryService { myHeaders.append('Authorization', 'Bearer ' + this.fds2Token); const myInit = { method: 'POST', body: data, headers: myHeaders }; - const myRequest = new Request(this.appConfig.fdpurl + "/catalog", myInit); + const myRequest = new Request(FDP_URL + "/catalog", myInit); fetch(myRequest, myInit) .then(response => { diff --git a/src/app/services/catalog.service.ts b/src/app/services/catalog.service.ts index e90209f39..f839c4026 100644 --- a/src/app/services/catalog.service.ts +++ b/src/app/services/catalog.service.ts @@ -17,6 +17,8 @@ export interface FdpApiResponseItem { context: string } +const FDP_URL = environment.fdpUrl; + @Injectable({ providedIn: 'root' }) @@ -49,6 +51,6 @@ export class CatalogService { } getCatalogContentById(catId: string) { - return this.http.get<FdpApiResponseItem[]>(this.appConfig.fdpurl + '/catalog/' + catId, this.httpOptionsFDP); + return this.http.get<FdpApiResponseItem[]>(FDP_URL + '/catalog/' + catId, this.httpOptionsFDP); } } -- GitLab