Add base configuration support for publish dialog

This commit is contained in:
Paulo Gustavo Veiga 2022-04-13 19:17:37 -03:00
parent 4c71ccd25a
commit 5e68914686
3 changed files with 13 additions and 7 deletions

View File

@ -83,7 +83,7 @@ const FR = {
CTRL: 'Ctrl',
SPACE_BAR: 'Space Bar',
K_INSERT: 'Insert',
MOUSE_CLICK: 'Mouse Click',
MOUSE_CLICK: 'Clic de Souris',
K_DELETE: 'Delete',
BACKSPACE: 'Backspace',
};

View File

@ -15,7 +15,7 @@ interface Config {
class _AppConfig {
private defaultInstance: Config = {
apiBaseUrl: '/',
apiBaseUrl: `${window.location.protocol}//${window.location.hostname}:${window.location.port}`,
clientType: 'mock',
recaptcha2Enabled: true,
recaptcha2SiteKey: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'
@ -57,7 +57,7 @@ class _AppConfig {
const config = this.getInstance();
let result: Client;
if (config.clientType == 'rest') {
result = new RestClient(config.apiBaseUrl);
result = new RestClient(this.getBaseUrl());
console.log('Service using rest client. ' + JSON.stringify(config));
} else {
console.log('Warning:Service using mockservice client');
@ -67,6 +67,11 @@ class _AppConfig {
// Wrap with a cache decorator ...
return new CacheDecoratorClient(result);
}
getBaseUrl(): string {
const config = this.getInstance();
return config.apiBaseUrl;
}
}
const AppConfig = new _AppConfig();

View File

@ -18,6 +18,7 @@ import TabPanel from '@mui/lab/TabPanel';
import Typography from '@mui/material/Typography';
import TextareaAutosize from '@mui/material/TextareaAutosize';
import Box from '@mui/system/Box';
import AppConfig from '../../../../classes/app-config';
const PublishDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElement => {
const { map } = fetchMapById(mapId);
@ -28,7 +29,6 @@ const PublishDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElemen
const [activeTab, setActiveTab] = React.useState('1');
const queryClient = useQueryClient();
const intl = useIntl();
const classes = useStyles();
const mutation = useMutation<void, ErrorInfo, boolean>(
(model: boolean) => {
@ -60,10 +60,11 @@ const PublishDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElemen
setModel(checked);
};
const handleTabChange = (event, newValue) => {
const handleTabChange = (event: React.ChangeEvent<HTMLInputElement>, newValue: string) => {
setActiveTab(newValue);
};
const baseUrl = AppConfig.getBaseUrl();
return (
<div>
<BaseDialog
@ -130,7 +131,7 @@ const PublishDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElemen
readOnly={true}
spellCheck={false}
maxRows={6}
defaultValue={`<iframe style="width:600px;height:400px;border:1px solid black" src="https://app.wisemapping.com/c/maps/${mapId}/embed?zoom=1.0"></iframe>`}
defaultValue={`<iframe style="width:600px;height:400px;border:1px solid black" src="${baseUrl}/c/maps/${mapId}/embed?zoom=1.0"></iframe>`}
/>
</TabPanel>
<TabPanel value="1">
@ -145,7 +146,7 @@ const PublishDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElemen
readOnly={true}
spellCheck={false}
maxRows={1}
defaultValue={`https://app.wisemapping.com/c/maps/${mapId}/public`}
defaultValue={`${baseUrl}/c/maps/${mapId}/public`}
/>
</TabPanel>
</TabContext>