wisemapping-frontend/packages/mindplot/src/indexLoader.js

50 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-12-23 19:51:26 +01:00
import { $notify } from '@wisemapping/core-js';
2021-12-23 20:41:39 +01:00
import { buildDesigner, buildDefaultOptions } from './components/DesignerBuilder';
2021-12-23 19:51:26 +01:00
import RESTPersistenceManager from './components/RestPersistenceManager';
import PersistenceManager from './components/PersistenceManager';
2021-12-23 20:55:07 +01:00
import LocalStorageManager from './components/LocalStorageManager';
2021-12-23 19:51:26 +01:00
global.memoryPersistence = false;
global.readOnlyMode = false;
global.userOptions = {};
global.locale = 'us';
global.mindmapLocked = false;
global.mapLockedMessage = 'map locked';
global.lockSession = 111111;
global.lockTimestamp = 11111;
// Configure designer options ...
2021-12-23 20:55:07 +01:00
let persistenceManager;
2021-12-23 19:51:26 +01:00
if (!global.memoryPersistence && !global.readOnlyMode) {
2021-12-23 20:55:07 +01:00
persistenceManager = new RESTPersistenceManager(
2021-12-23 19:51:26 +01:00
{
documentUrl: 'c/restful/maps/{id}/document',
revertUrl: 'c/restful/maps/{id}/history/latest',
lockUrl: 'c/restful/maps/{id}/lock',
timestamp: global.lockTimestamp,
session: global.lockSession,
},
);
} else {
2021-12-23 20:55:07 +01:00
// persistenceManager = new LocalStorageManager('c/restful/maps/{id}${hid != null ? '/' : ''}${hid != null ? hid : ''}/document/xml${principal != null ? '' : '-pub'}", true);
// @todo: review ...
persistenceManager = new LocalStorageManager('c/restful/maps/{id}', true);
2021-12-23 19:51:26 +01:00
}
2021-12-23 20:55:07 +01:00
const options = buildDefaultOptions(persistenceManager, false);
2021-12-23 19:51:26 +01:00
options.zoom = global.userOptions.zoom;
// Set map id ...
options.mapId = global.mapId;
// Build designer ...
const designer = buildDesigner(options);
// Load map from XML file persisted on disk...
const persistence = PersistenceManager.getInstance();
const mindmap = persistence.load(global.mapId);
designer.loadMap(mindmap);
if (global.mindmapLocked) {
$notify(global.mappL, false);
}