UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

157 lines (156 loc) 5.25 kB
import MapPosition from './mapposition'; import type Feature from 'ol/Feature'; import type Basemap from '../../models/basemap'; import type Theme from '../../models/theme'; import type BaseLayer from '../../models/layers/baselayer'; import type ThemeLayer from '../../models/layers/themelayer'; import type OlGeomLineString from 'ol/geom/LineString'; import type ServerOgc from '../../models/serverogc'; import type { TokenEndpointResponse } from 'oauth4webapi'; import type SelectionParam from '../../models/selectionparam'; import type { GgUserInteractionListener } from './userInteractionManager'; import type CustomTheme from '../../models/customtheme'; type GraphicalInterface = { isMobile: boolean; helpVisible: boolean; drawingPanelVisible: boolean; printPanelVisible: boolean; lidarPanelVisible: boolean; crossSectionPanelVisible: boolean; editPanelVisible: boolean; sharePanelVisible: boolean; selectionComponentVisible: boolean; selectionComponent: string; layoutPanelVisible: boolean; aboutPanelVisible: boolean; userPreferencesPanelVisible: boolean; contactPanelVisible: boolean; infoWindowVisible: boolean; darkMapMode: boolean; darkFrontendMode: boolean; swipeupPanelMode: SwipeupPanelMode; swipeupPanelContent: 'selector' | null; }; type Selection = { selectionParameters: SelectionParam[]; selectedFeatures: Feature[]; focusedFeatures: Feature[] | null; highlightedFeatures?: Feature[] | null; gridSelected: boolean; }; export type ThemesConfig = { _allThemes: Record<number, ThemeLayer>; isLoaded: boolean; lastSelectedTheme: ThemeLayer | CustomTheme | null; }; type LayersConfig = { layersList: BaseLayer[]; }; type TreeviewConfig = { advanced: boolean; renderEnabled: boolean; }; type PrintConfig = { maskVisible: boolean; pageSize: [number, number] | null; format: string | null; scale: number | null; dpi: number | null; }; type GlobeConfig = { display: '2D' | '3D' | '2D/3D'; loaded: boolean; shadows: boolean; shadowsTimestamp: number; }; export type InfoBoxContent = { id: string; text: string; type: 'info' | 'warning' | 'error'; }; export type Lidar = { line: OlGeomLineString | null; drawActive: boolean; }; type Functionalities = { authorized_plugins?: string[]; }; type UserInfo = { username: string; display_name: string; email: string; family_name: string; given_name: string; is_intranet: boolean; two_factor_enable: boolean; roles: unknown[]; functionalities?: Functionalities; }; /** * Login states : * 1. issuer.loggedIn : Logged in to identity provider * 2. loggedIn : Fully logged in (to both identity provider and backend) * 3. loginFailed : Login failed * 4. backend.loggedOut : Logout from backend * 5. loggedOut : Fully Logged out (from both identity provider and backend) * 5. logoutFailed : Logout failed */ type LoginState = { status: 'issuer.loggedIn' | 'loggedIn' | 'loginFailed' | 'backend.loggedOut' | 'loggedOut' | 'logoutFailed' | 'loggedOutForcedFromBackend'; tokens?: TokenEndpointResponse; userInfo?: UserInfo; audience: string[]; }; export type InfoWindow = { title: string | null; url: string | null; width: string | number | null; height: string | number | null; top: string | number | null; left: string | number | null; }; /** * The pannel can be: * - "closed": it is invisible, below screen * - "reduced": only a small tray is visible at the bottom of the screen * - "half": about half of the screen * - "full": the pannel is fully open, covering up to almost the top of the screen * - "manual": a state reserved for when the panel handle was used to manually adjust the panel height */ export type SwipeupPanelMode = 'closed' | 'reduced' | 'half' | 'full' | 'manual'; 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 */ themes: ThemesConfig; basemaps: Record<number, Basemap>; ogcServers: Record<string, ServerOgc>; activeBasemap: Basemap | null; projection: string; mouseCoordinates: number[]; interface: GraphicalInterface; userInteractionListeners: GgUserInteractionListener[]; language: string | null; lidar: Lidar; loading: boolean; sharedStateIsLoaded: boolean; position: MapPosition; layers: LayersConfig; treeview: TreeviewConfig; print: PrintConfig; globe: GlobeConfig; selection: Selection; theme: Theme | null; infobox: { elements: InfoBoxContent[]; }; infoWindow: InfoWindow; isOffline: boolean; oauth: LoginState; extendedState: Record<string, object>; } export {};