UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

143 lines (142 loc) 5.25 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; // SPDX-License-Identifier: Apache-2.0 import MapPosition from './mapposition.js'; import GlobeState from './globe.js'; import { BrainSerialize } from './brain/decorators.js'; import LayersConfig from './layersConfig.js'; import ObjectSelection from './objectselection.js'; import GraphicalInterface from './graphicalInterface.js'; export default class State { /** * 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 themes = { _allThemes: {}, _allFunctionalities: {}, isLoaded: false, lastSelectedTheme: null }; functionalities = {}; // All basemaps from themes.json // Dictionary where the key is the id of the basemap basemaps = {}; // All OCG Servers from themes.json // Dictionary where the key is the name of the server ogcServers = {}; // Current active basemaps activeBasemaps = []; // Current projection projection; // Current mouse coordinates mouseCoordinates = []; // Interface configuration (visible panels, ...) interface = new GraphicalInterface(); userInteractionListeners = []; // Current language language = null; // LIDAR lidar = { line: null, drawActive: false }; news = { urls: null, lastViewDate: 0, lastPublishDate: 0 }; // Is the application currently loading map data? loading = false; // Global variables that represent the state of the application. // They can be used when waiting for big steps in the app. application = { isConfigurationLoaded: false, // This doesn't mean that the user is authenticated, just that the authentication-processed is initialized (including silent login) isAuthInitialized: false, // This doesn't mean that a shared state was loaded, just that the processed is finished isStateInitialized: false, // Cutom serializer are ready. There are important for desirializing the shared state or the current session isCustomSerializerInitialized: false, // When isAuthInitialized and isCustomSerializerInitialized, then we are ready to load themes isReadyToLoadThemes: false, // Everything needed by GeoGirafe to work properly has been loaded isReady: false }; // Current position configuration of the map position = new MapPosition(); // Current layers configuration layers = new LayersConfig(); // Current Treeview state treeview = { renderEnabled: true }; // Current Print state print = { maskVisible: false, pageSize: null, format: null, scale: null, dpi: null }; // Current 3D-Globe state globe = new GlobeState(); // TODO REG : What is this used for? // Is it the default theme configured in the user preferences? // Do we really need this? theme = null; // To manage selected and focused features selection = new ObjectSelection(); infobox = { elements: [] }; infoWindow = { title: null, url: null, width: null, height: null, top: null, left: null }; // Indicates is the application is currently used in offline mode isOffline = false; oauth = { status: 'not-initialized', audience: [], somethingChanged: true }; // 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. extendedState = {}; } __decorate([ BrainSerialize ], State.prototype, "activeBasemaps", void 0); __decorate([ BrainSerialize ], State.prototype, "projection", void 0); __decorate([ BrainSerialize ], State.prototype, "interface", void 0); __decorate([ BrainSerialize ], State.prototype, "position", void 0); __decorate([ BrainSerialize ], State.prototype, "layers", void 0); __decorate([ BrainSerialize ], State.prototype, "globe", void 0); __decorate([ BrainSerialize ], State.prototype, "selection", void 0);