From d38a327863629bc34065254d40f3c3e995f7c73d Mon Sep 17 00:00:00 2001 From: kaw67872 <kawtar.laariche@iais.fraunhofer.de> Date: Tue, 30 Jul 2024 13:34:32 +0200 Subject: [PATCH] #25: add create, update, delete catalog function --- src/app/core/config/api-config.ts | 2 + .../core/services/private-catalogs.service.ts | 57 +++++++++++++++++++ src/environments/environment.ts | 2 +- 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/app/core/config/api-config.ts b/src/app/core/config/api-config.ts index 025faa8..dab1cb1 100644 --- a/src/app/core/config/api-config.ts +++ b/src/app/core/config/api-config.ts @@ -68,4 +68,6 @@ export const apiConfig = { urlPublishSolution: '/api/publish', urlSearchPublishRequest: '/api/publish/request/search/revision', withdrawPublishRequestUrl: '/api/publish/request/withdraw/', + urlCatalogPath: '/api/catalog', + urlSiteConfig: '/api/admin/config', }; diff --git a/src/app/core/services/private-catalogs.service.ts b/src/app/core/services/private-catalogs.service.ts index c9266ce..ef5b8f7 100644 --- a/src/app/core/services/private-catalogs.service.ts +++ b/src/app/core/services/private-catalogs.service.ts @@ -935,4 +935,61 @@ export class PrivateCatalogsService { }), ); } + + createCatalog(catalog: Catalog) { + const requestObj = { + request_body: { + ...catalog, + url: 'http://localhost', + }, + }; + const url = apiConfig.apiBackendURL + apiConfig.urlCatalogPath; + + return this._httpSharedService.post(url, undefined, requestObj).pipe( + catchError((error) => { + throw error; + }), + ); + } + + updateCatalog(catalog: Catalog) { + const requestObj = { + request_body: { + ...catalog, + url: 'http://localhost', + }, + }; + const url = apiConfig.apiBackendURL + apiConfig.urlCatalogPath; + + return this._httpSharedService.put(url, undefined, requestObj).pipe( + catchError((error) => { + throw error; + }), + ); + } + + deleteCatalog(catalog: Catalog) { + const url = + apiConfig.apiBackendURL + + apiConfig.urlCatalogPath + + '/' + + catalog.catalogId; + + return this._httpSharedService.delete(url).pipe( + catchError((error) => { + throw error; + }), + ); + } + + getSiteConfig() { + const url = + apiConfig.apiBackendURL + apiConfig.urlSiteConfig + '/site_config'; + + return this._httpSharedService.get(url, undefined).pipe( + catchError((error) => { + throw error; + }), + ); + } } diff --git a/src/environments/environment.ts b/src/environments/environment.ts index e0a56ed..87f4dc1 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -2,7 +2,7 @@ export const environment = { // local with session production: false, skipAuth: false, - apiBackendURL: 'https://aiexp-dev.ai4europe.eu', + apiBackendURL: 'https://dev02.ki-lab.nrw', isDebugMode: true, logging: { level: { -- GitLab