Skip to content

Commit

Permalink
Remove unused portal state calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwoodman committed Sep 5, 2024
1 parent b8e1877 commit b62ba54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 96 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<string> = new BehaviorSubject<string>(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?
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<any> {
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<any>) => {
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<any> {
// 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<any>) => {
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);
}

}
6 changes: 2 additions & 4 deletions projects/portal-core-ui/src/lib/service/wms/legend.service.ts
Original file line number Diff line number Diff line change
@@ -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';


Expand All @@ -16,7 +15,6 @@ export class LegendService {
* @param styleUrl URL string to get legend from local server
*/
public getLegendStyle(styleUrl: string): Observable<any> {
const me = this;
return this.http.get(this.env.portalBaseUrl + styleUrl, {responseType: 'text'}).pipe(
tap(result => result));
}
Expand Down

0 comments on commit b62ba54

Please sign in to comment.