UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

244 lines (243 loc) 8.25 kB
import MapPosition from './mapposition'; import { systemIsInDarkMode } from '../utils/utils'; export default class State { constructor() { /** * This class is a used as the state of the application, which will be accessed behind a javascript proxy. * This means that each modification made to its properties must come from outside, * because they have to be made through the proxy, so that the modification can be listen. * Therefore, this class must not contain any method which is updating a value directly * For example, any method doing <this.xxx = value> is forbidden here, because the modification be known from the proxy */ // All themes from themes.json // Dictionary where the key is the id of the theme Object.defineProperty(this, "themes", { enumerable: true, configurable: true, writable: true, value: { _allThemes: {}, isLoaded: false, lastSelectedTheme: null } }); // All basemaps from themes.json // Dictionary where the key is the id of the basemap Object.defineProperty(this, "basemaps", { enumerable: true, configurable: true, writable: true, value: {} }); // All OCG Servers from themes.json // Dictionary where the key is the name of the server Object.defineProperty(this, "ogcServers", { enumerable: true, configurable: true, writable: true, value: {} }); // Current active basemap Object.defineProperty(this, "activeBasemap", { enumerable: true, configurable: true, writable: true, value: null }); // Current projection Object.defineProperty(this, "projection", { enumerable: true, configurable: true, writable: true, value: void 0 }); // Current mouse coordinates Object.defineProperty(this, "mouseCoordinates", { enumerable: true, configurable: true, writable: true, value: [] }); // Interface configuration (visible panels, ...) Object.defineProperty(this, "interface", { enumerable: true, configurable: true, writable: true, value: { isMobile: false, helpVisible: false, drawingPanelVisible: false, printPanelVisible: false, lidarPanelVisible: false, crossSectionPanelVisible: false, editPanelVisible: false, sharePanelVisible: false, selectionComponentVisible: false, selectionComponent: '', layoutPanelVisible: false, aboutPanelVisible: false, userPreferencesPanelVisible: false, infoWindowVisible: false, darkMapMode: false, // TODO: remove of adjust this when the component UserDataManager is monted on mobile UI darkFrontendMode: systemIsInDarkMode() ?? false, swipeupPanelMode: 'closed', contactPanelVisible: false, swipeupPanelContent: 'selector' } }); Object.defineProperty(this, "userInteractionListeners", { enumerable: true, configurable: true, writable: true, value: [] }); // Current language Object.defineProperty(this, "language", { enumerable: true, configurable: true, writable: true, value: null }); // LIDAR Object.defineProperty(this, "lidar", { enumerable: true, configurable: true, writable: true, value: { line: null, drawActive: false } }); // Is the application currently loading data ? Object.defineProperty(this, "loading", { enumerable: true, configurable: true, writable: true, value: false }); // Does a shared state exist and is it loaded? null = no shared state in URL Object.defineProperty(this, "sharedStateIsLoaded", { enumerable: true, configurable: true, writable: true, value: false }); // Current position configuration of the map Object.defineProperty(this, "position", { enumerable: true, configurable: true, writable: true, value: new MapPosition() }); // Current layers configuration Object.defineProperty(this, "layers", { enumerable: true, configurable: true, writable: true, value: { layersList: [] } }); // Current Treeview state Object.defineProperty(this, "treeview", { enumerable: true, configurable: true, writable: true, value: { advanced: false, renderEnabled: true } }); // Current Print state Object.defineProperty(this, "print", { enumerable: true, configurable: true, writable: true, value: { maskVisible: false, pageSize: null, format: null, scale: null, dpi: null } }); // Current 3D-Globe state Object.defineProperty(this, "globe", { enumerable: true, configurable: true, writable: true, value: { // Possible values : ['3D, '2D/3D', '2D'] display: '2D', loaded: false, shadows: false, shadowsTimestamp: new Date().valueOf() } }); // To manage selected and focused features Object.defineProperty(this, "selection", { enumerable: true, configurable: true, writable: true, value: { selectionParameters: [], selectedFeatures: [], focusedFeatures: null, gridSelected: false } }); Object.defineProperty(this, "theme", { enumerable: true, configurable: true, writable: true, value: null }); Object.defineProperty(this, "infobox", { enumerable: true, configurable: true, writable: true, value: { elements: [] } }); Object.defineProperty(this, "infoWindow", { enumerable: true, configurable: true, writable: true, value: { title: null, url: null, width: null, height: null, top: null, left: null } }); // Indicates is the application is currently used in offline mode Object.defineProperty(this, "isOffline", { enumerable: true, configurable: true, writable: true, value: false }); Object.defineProperty(this, "oauth", { enumerable: true, configurable: true, writable: true, value: { status: 'loggedOut', audience: [] } }); // The State object is defined as <not extensible> by the StateManager. // This property can be used by third-parts components or extensions // to add custom attributes to the state. Object.defineProperty(this, "extendedState", { enumerable: true, configurable: true, writable: true, value: {} }); } }