From fd4b407e755ed8800c0af8c68d47d46737b61b7a Mon Sep 17 00:00:00 2001 From: chrisvpeters Date: Tue, 29 Oct 2024 16:21:07 +1100 Subject: [PATCH 1/2] AUS-4265 --- src/app/services/api/auscope-api.service.ts | 28 ++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/app/services/api/auscope-api.service.ts b/src/app/services/api/auscope-api.service.ts index 59ab6d9f..9c93cebb 100644 --- a/src/app/services/api/auscope-api.service.ts +++ b/src/app/services/api/auscope-api.service.ts @@ -54,12 +54,26 @@ export class AuscopeApiService { return this.http.post>(url, body, opts).pipe(switchMap(apiData)); } + private apiPostJson(endpoint: string, params = {}, options = {}): Observable { + const url = environment.portalProxyUrl + endpoint; + const body = params; + const opts: { observe: 'body' } = { ...options, observe: 'body' }; + + return this.http.post>(url, body, opts).pipe(switchMap(apiData)); + } + private apiGet(endpoint: string, params = {}, options?): Observable { const url = environment.portalProxyUrl + endpoint; const opts: { observe: 'body' } = { ...options, observe: 'body', params: params }; return this.http.get>(url, opts).pipe(switchMap(apiData)); } + private apiDelete(endpoint: string, params = {}, options?): Observable { + const url = environment.portalProxyUrl + endpoint; + const opts: { observe: 'body' } = { ...options, observe: 'body', params: params }; + return this.http.delete>(url, opts).pipe(switchMap(apiData)); + } + public getWmsCapabilities(serviceUrl: string, version: string): Observable { if (serviceUrl.indexOf('?') !== -1) { serviceUrl = serviceUrl.substring(0, serviceUrl.indexOf('?')); @@ -90,28 +104,24 @@ export class AuscopeApiService { // Add bookmark to database public addBookmark(layerId: string): Observable { - const options = { - params: { + const params = { fileIdentifier: layerId, serviceId: '' } - }; - return this.apiRequest('secure/addBookMark.do', options); + return this.apiPostJson('bookmarks', params); } // Remove bookmark information from database public removeBookmark(bookmarkId: number) { - const options = { - params: { + const params = { id: bookmarkId.toString() } - }; - return this.apiRequest('secure/deleteBookMark.do', options); + return this.apiDelete('bookmarks', params); } // Get list of bookmarks for a user public getBookmarks(): Observable { - return this.apiRequest('secure/getBookMarks.do'); + return this.apiRequest('bookmarks'); } /** From 8f5544ab2414f2fdeaed4b987699d43ae6cc9fe3 Mon Sep 17 00:00:00 2001 From: chrisvpeters Date: Tue, 19 Nov 2024 15:53:04 +1100 Subject: [PATCH 2/2] AUS-4265 - fix DELETE api call for bookmarks --- src/app/services/api/auscope-api.service.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/app/services/api/auscope-api.service.ts b/src/app/services/api/auscope-api.service.ts index 9c93cebb..337b18d6 100644 --- a/src/app/services/api/auscope-api.service.ts +++ b/src/app/services/api/auscope-api.service.ts @@ -17,7 +17,6 @@ interface ApiResponse { function apiData(response: ApiResponse): Observable { // Convert a VGL error into an Observable error if (!response.success) { - console.log('API response error: ' + JSON.stringify(response)); return throwError(response.msg); } @@ -113,10 +112,7 @@ export class AuscopeApiService { // Remove bookmark information from database public removeBookmark(bookmarkId: number) { - const params = { - id: bookmarkId.toString() - } - return this.apiDelete('bookmarks', params); + return this.apiDelete('bookmarks/'+bookmarkId.toString()); } // Get list of bookmarks for a user