Fix map load.

This commit is contained in:
Paulo Gustavo Veiga 2024-02-09 00:03:34 -08:00
parent e3d6f5dad5
commit e7355bc2fe
6 changed files with 50 additions and 11 deletions

View File

@ -1,3 +1,20 @@
/*
* Copyright [2021] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DesignerKeyboard, EditorRenderMode, PersistenceManager } from '@wisemapping/mindplot'; import { DesignerKeyboard, EditorRenderMode, PersistenceManager } from '@wisemapping/mindplot';
import { useState, useRef, useEffect } from 'react'; import { useState, useRef, useEffect } from 'react';
import Capability from '../../classes/action/capability'; import Capability from '../../classes/action/capability';
@ -65,13 +82,11 @@ export const useEditor = ({
}, [mindplotRef, options]); }, [mindplotRef, options]);
useEffect(() => { useEffect(() => {
if (options) { if (options && options.enableKeyboardEvents) {
if (options.enableKeyboardEvents) {
DesignerKeyboard.resume(); DesignerKeyboard.resume();
} else { } else {
DesignerKeyboard.pause(); DesignerKeyboard.pause();
} }
}
}, [options, options?.enableKeyboardEvents]); }, [options, options?.enableKeyboardEvents]);
return { model, mindplotRef, mapInfo, capability, options }; return { model, mindplotRef, mapInfo, capability, options };

View File

@ -1,3 +1,20 @@
/*
* Copyright [2021] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import DefaultWidgetManager from '../../classes/default-widget-manager'; import DefaultWidgetManager from '../../classes/default-widget-manager';
export const useWidgetManager = (): { export const useWidgetManager = (): {

View File

@ -46,7 +46,7 @@
manifest.json provides metadata used when your web app is installed on a manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
--> -->
<link rel="manifest" href="<%=PUBLIC_URL%>/manifest.json" /> <!-- <link rel="manifest" href="<%=PUBLIC_URL%>/manifest.json" /> -->
<!-- <!--
Notice the use of %PUBLIC_URL% in the tags above. Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build. It will be replaced with the URL of the `public` folder during the build.

View File

@ -64,7 +64,7 @@ export type MapMetadata = {
title: string; title: string;
isLocked: boolean; isLocked: boolean;
isLockedBy?: string; isLockedBy?: string;
zoom: number; jsonProps: string;
}; };
export type ChangeHistory = { export type ChangeHistory = {

View File

@ -134,7 +134,7 @@ class MockClient implements Client {
title: 'my map', title: 'my map',
id: id, id: id,
isLocked: false, isLocked: false,
zoom: 0.8, jsonProps: '{ "zoom": 0.8 }',
}); });
} }

View File

@ -109,6 +109,7 @@ type EditorMetadata = {
mode: EditorRenderMode; mode: EditorRenderMode;
title: string; title: string;
isLocked: boolean; isLocked: boolean;
isLockedBy?: string;
zoom: number; zoom: number;
}; };
@ -138,6 +139,8 @@ const EditorPage = ({ mapId, isTryMode }: EditorPropsType): React.ReactElement =
let mode: EditorRenderMode = null; let mode: EditorRenderMode = null;
let title = ''; let title = '';
let isLocked = false; let isLocked = false;
let zoom = 0.8;
let isLockedBy;
if (isTryMode) { if (isTryMode) {
mode = 'showcase'; mode = 'showcase';
@ -173,11 +176,14 @@ const EditorPage = ({ mapId, isTryMode }: EditorPropsType): React.ReactElement =
} else { } else {
mode = `edition-${fetchMapInfoResult.data.role}`; mode = `edition-${fetchMapInfoResult.data.role}`;
} }
isLocked = fetchMetadataResult.data.isLocked; isLocked = fetchMetadataResult.data.isLocked;
isLockedBy = fetchMetadataResult.data.isLockedBy;
title = fetchMetadataResult.data.title; title = fetchMetadataResult.data.title;
zoom = JSON.parse(fetchMetadataResult.data.jsonProps).zoom;
} }
} }
return mode ? { mode: mode, isLocked: isLocked, title: title, zoom: 0.8 } : undefined; return mode ? { mode, isLocked, isLockedBy, title, zoom } : undefined;
}; };
// What is the role ? // What is the role ?
@ -192,11 +198,12 @@ const EditorPage = ({ mapId, isTryMode }: EditorPropsType): React.ReactElement =
let mapInfo: MapInfo; let mapInfo: MapInfo;
let options: EditorOptions; let options: EditorOptions;
if (loadCompleted) { if (loadCompleted) {
// Configure de // Configure
options = { options = {
enableKeyboardEvents: hotkey, enableKeyboardEvents: hotkey,
locale: userLocale.code, locale: userLocale.code,
mode: mapMetadata.mode, mode: mapMetadata.mode,
enableAppBar: true,
}; };
persistence = buildPersistenceManagerForEditor(mapMetadata.mode); persistence = buildPersistenceManagerForEditor(mapMetadata.mode);