@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
144 lines (143 loc) • 4.63 kB
TypeScript
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 { TokenEndpointResponse } from 'oauth4webapi';
import SelectionParam from '../../models/selectionparam';
import { GgUserInteractionListener } from './userInteractionManager';
import CustomTheme from '../../models/customtheme';
type GraphicalInterface = {
helpVisible: boolean;
drawingPanelVisible: boolean;
printPanelVisible: boolean;
lidarPanelVisible: boolean;
crossSectionPanelVisible: boolean;
editPanelVisible: boolean;
sharePanelVisible: boolean;
selectionComponentVisible: boolean;
selectionComponent: string;
layoutPanelVisible: boolean;
aboutPanelVisible: boolean;
userPreferencesPanelVisible: boolean;
infoWindowVisible: boolean;
darkMapMode: boolean;
darkFrontendMode: boolean;
};
type Selection = {
selectionParameters: SelectionParam[];
selectedFeatures: Feature[];
focusedFeatures: Feature[] | null;
highlightedFeatures?: Feature[] | null;
gridSelected: boolean;
};
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: Object[];
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;
};
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 {};