diff --git a/src/app/services/api/auscope-api.service.ts b/src/app/services/api/auscope-api.service.ts index 59ab6d9f..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); } @@ -54,12 +53,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 +103,21 @@ 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: { - id: bookmarkId.toString() - } - }; - return this.apiRequest('secure/deleteBookMark.do', options); + return this.apiDelete('bookmarks/'+bookmarkId.toString()); } // Get list of bookmarks for a user public getBookmarks(): Observable { - return this.apiRequest('secure/getBookMarks.do'); + return this.apiRequest('bookmarks'); } /**