2021-12-24 18:40:08 +01:00
|
|
|
/* eslint-disable vars-on-top */
|
2021-12-23 19:51:26 +01:00
|
|
|
import { $notify } from '@wisemapping/core-js';
|
2021-12-24 01:35:46 +01:00
|
|
|
import { buildDesigner, buildOptions } 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
|
|
|
|
|
|
|
// Configure designer options ...
|
2021-12-24 20:04:50 +01:00
|
|
|
let persistence;
|
2021-12-23 19:51:26 +01:00
|
|
|
if (!global.memoryPersistence && !global.readOnlyMode) {
|
2021-12-24 20:04:50 +01:00
|
|
|
persistence = new RESTPersistenceManager(
|
2021-12-23 19:51:26 +01:00
|
|
|
{
|
2021-12-24 18:40:08 +01:00
|
|
|
documentUrl: '/c/restful/maps/{id}/document',
|
|
|
|
revertUrl: '/c/restful/maps/{id}/history/latest',
|
|
|
|
lockUrl: '/c/restful/maps/{id}/lock',
|
2021-12-23 19:51:26 +01:00
|
|
|
timestamp: global.lockTimestamp,
|
|
|
|
session: global.lockSession,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
} else {
|
2021-12-23 20:55:07 +01:00
|
|
|
// @todo: review ...
|
2021-12-24 01:35:46 +01:00
|
|
|
// persistenceManager = new LocalStorageManager('c/restful/maps/{id}${hid != null ? '/' : ''}${hid != null ? hid : ''}/document/xml${principal != null ? '' : '-pub'}", true);
|
2021-12-24 20:04:50 +01:00
|
|
|
persistence = new LocalStorageManager('/c/restful/maps/{id}', true);
|
2021-12-23 19:51:26 +01:00
|
|
|
}
|
2021-12-24 01:35:46 +01:00
|
|
|
|
2021-12-24 20:04:50 +01:00
|
|
|
const options = buildOptions({
|
|
|
|
persistenceManager: persistence,
|
|
|
|
isReadOnly: global.readOnlyMode || false,
|
|
|
|
mapId: global.mapId,
|
|
|
|
zoom: global.userOptions.zoom,
|
|
|
|
});
|
2021-12-23 19:51:26 +01:00
|
|
|
|
|
|
|
// Build designer ...
|
|
|
|
const designer = buildDesigner(options);
|
|
|
|
|
|
|
|
// Load map from XML file persisted on disk...
|
2021-12-24 20:04:50 +01:00
|
|
|
const instance = PersistenceManager.getInstance();
|
|
|
|
const mindmap = instance.load(global.mapId);
|
2021-12-23 19:51:26 +01:00
|
|
|
designer.loadMap(mindmap);
|
|
|
|
|
|
|
|
if (global.mindmapLocked) {
|
2021-12-24 01:35:46 +01:00
|
|
|
$notify(global.mindmapLockedMsg, false);
|
2021-12-23 19:51:26 +01:00
|
|
|
}
|