@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
68 lines (67 loc) • 2.25 kB
JavaScript
import ApiSessionManager from './apisessionmanager.js';
import { updateConfigPaths } from './apiutils.js';
import ContextInitializationHelper from '../tools/context/contexthelper.js';
export default class GirafeApiContext {
userDataManager;
configManager;
stateManager;
componentManager;
userInteractionManager;
i18nManager;
pluginManager;
themesManager;
themesHelper;
permalinkManager;
dragManager;
urlManager;
layerManager;
sessionManager;
stateSerializer;
shareManager;
customThemesManager;
errorManager;
wfsManager;
authManager;
snapManager;
mapManager;
logManager;
offlineManager;
applicationLifeCycleManager;
orderingManager;
userLayerManager;
wmsManager;
wmtsManager;
selectionManager;
ogcApiFeaturesManager;
localFileManager;
onBoardingManager;
themeFavoritesManager;
searchManager;
feedbackManager;
contextHelper = new ContextInitializationHelper();
constructor() {
this.contextHelper.constructContext(this, ['sessionManager']);
this.sessionManager = new ApiSessionManager(this);
}
async initialize() {
await this.contextHelper.initializeContext(this);
}
/** The context can contains hook methods that will be called after each manager initialization.
* The hook method must be named with the property name + the "Hook" suffix.
* The hook method must be async and will be awaited
* For example, the methods themesManagerHook() will be called immediately after
* the call of themesManager.initializeSingleton().
* This allows specific initialization methods when defining custom contexts
* (for example for the apiContext, the mockContext, or any customContext)
*/
async configManagerHook() {
await this.configManager.initializeSingleton();
// For the API context, some configuraton options in the config file can be relative.
// We have to convert them to absolute paths.
updateConfigPaths(this.configManager.Config);
}
async stateManagerHook() {
await this.stateManager.initializeSingleton();
this.stateManager.state.interface.isApi = true;
}
}