diff --git a/projects/portal-core-ui/src/lib/service/permanentlink/manage-state.service.ts b/projects/portal-core-ui/src/lib/service/permanentlink/manage-state.service.ts index 93e6416..7db9c36 100644 --- a/projects/portal-core-ui/src/lib/service/permanentlink/manage-state.service.ts +++ b/projects/portal-core-ui/src/lib/service/permanentlink/manage-state.service.ts @@ -1,9 +1,5 @@ -import { Injectable, Inject} from '@angular/core'; -import { v4 as uuidv4 } from 'uuid'; -import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http'; -import { throwError as observableThrowError, of, BehaviorSubject } from 'rxjs'; -import { map, catchError } from 'rxjs/operators'; -import { Observable } from 'rxjs'; +import { Injectable } from '@angular/core'; +import { BehaviorSubject } from 'rxjs'; import { CsMapObject } from '../cesium-map/cs-map-object'; import { MapState } from '../../model/data/mapstate.model'; @@ -19,14 +15,13 @@ import { MapState } from '../../model/data/mapstate.model'; export class ManageStateService { private state: any = {}; - private prevState: any = {}; private permLinkMode: boolean = false; // Is true if a permanent link has been employed // Layer requires expanding private layerToExpandBS: BehaviorSubject = new BehaviorSubject(null); public readonly layerToExpand = this.layerToExpandBS.asObservable(); - constructor(private csMapObject: CsMapObject, private http: HttpClient, @Inject('env') private env) {} + constructor(private csMapObject: CsMapObject) {} /** * Is the map currently displaying a permanent link? @@ -68,22 +63,6 @@ export class ManageStateService { this.permLinkMode = false; } - /** - * Generate a one off state. This is used in NVCL borehole analytic where we want to generate a perm link to a artifically generated layer and filter - * @param layerid the layer that have been added - * @param filterCollection the associated filtercollection of the layer - * @param optionalFilters any optional filters that have been selected - */ - public generateOneOffState(layerid: string, filterCollection: any, optionalFilters: any) { - filterCollection['optionalFilters'] = []; - const state = {}; - state[layerid] = { - filterCollection: filterCollection, - optionalFilters: optionalFilters - }; - return state; - } - /** * When a layer is removed, update the state * @param layerid the id of the layer that have been removed @@ -126,72 +105,4 @@ export class ManageStateService { } } - /** - * Saves current UI state via back end API call - * - * @param state UI state, a JSON string - * @returns Observable of response - */ - public saveStateToDB(state: string): Observable { - const id = uuidv4(); - let httpParams = new HttpParams(); - httpParams = httpParams.append('id', id); - httpParams = httpParams.append('state', state); - return this.http.get(this.env.portalBaseUrl + 'saveUIState.do', { - params: httpParams - }).pipe(map(response => { - if (response['success']) { - response['id'] = id; - } - return response; - }), catchError( - (error: HttpResponse) => { - return observableThrowError(error); - } - ), ); - } - - /** - * Retrieves current UI state via back end API call - * - * @param id identity string of UI state - * @returns JSON response or empty object - */ - public fetchStateFromDB(id: string): Observable { - // If no state then return empty object - if (id === undefined) { - return of({}); - } - // If we have already stored this state locally then return it - if (id in this.prevState) { - return of(this.prevState[id]); - } - // Call the backend API to get state - let httpParams = new HttpParams(); - httpParams = httpParams.append('id', id); - return this.http.get(this.env.portalBaseUrl + 'fetchUIState.do', { - params: httpParams - }).pipe(map(response => { - if (response['success'] === true) { - this.prevState[id] = JSON.parse(response['data']); - return this.prevState[id]; - } - // If not successful, return empty object - return {}; - }), catchError( - (error: HttpResponse) => { - return observableThrowError(error); - } - ), ); - } - - /** - * Notify listeners (LayerPanel) that a layer is to be expanded - * - * @param layerId ID of layer - */ - setLayerToExpand(layerId: string) { - this.layerToExpandBS.next(layerId); - } - } diff --git a/projects/portal-core-ui/src/lib/service/wms/legend.service.ts b/projects/portal-core-ui/src/lib/service/wms/legend.service.ts index 6643853..97139f2 100644 --- a/projects/portal-core-ui/src/lib/service/wms/legend.service.ts +++ b/projects/portal-core-ui/src/lib/service/wms/legend.service.ts @@ -1,7 +1,6 @@ - -import {tap} from 'rxjs/operators'; +import { tap } from 'rxjs/operators'; import { Injectable, Inject } from '@angular/core'; -import {HttpClient} from '@angular/common/http'; +import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; @@ -16,7 +15,6 @@ export class LegendService { * @param styleUrl URL string to get legend from local server */ public getLegendStyle(styleUrl: string): Observable { - const me = this; return this.http.get(this.env.portalBaseUrl + styleUrl, {responseType: 'text'}).pipe( tap(result => result)); }