diff options
author | Anton Tananaev <anton@traccar.org> | 2023-07-22 07:49:09 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-07-22 07:49:09 -0700 |
commit | 2a281113650977f6e40f4f7a4daa2a11dea61d8a (patch) | |
tree | 9bb64dd24a46347df5c9ddab2d956051506d155e /modern/src/other | |
parent | 4b50a30e2ff1c64a3e2e4a34651d1695953cae1f (diff) | |
download | trackermap-web-2a281113650977f6e40f4f7a4daa2a11dea61d8a.tar.gz trackermap-web-2a281113650977f6e40f4f7a4daa2a11dea61d8a.tar.bz2 trackermap-web-2a281113650977f6e40f4f7a4daa2a11dea61d8a.zip |
Fix server selection issues
Diffstat (limited to 'modern/src/other')
-rw-r--r-- | modern/src/other/ChangeServerPage.js | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/modern/src/other/ChangeServerPage.js b/modern/src/other/ChangeServerPage.js deleted file mode 100644 index 0343a941..00000000 --- a/modern/src/other/ChangeServerPage.js +++ /dev/null @@ -1,75 +0,0 @@ -import React from 'react'; -import ElectricalServicesIcon from '@mui/icons-material/ElectricalServices'; -import { makeStyles } from '@mui/styles'; -import { - Autocomplete, Container, createFilterOptions, TextField, -} from '@mui/material'; -import { useTranslation } from '../common/components/LocalizationProvider'; - -const currentServer = `${window.location.protocol}//${window.location.host}`; - -const officialServers = [ - currentServer, - 'https://demo.traccar.org', - 'https://demo2.traccar.org', - 'https://demo3.traccar.org', - 'https://demo4.traccar.org', - 'https://server.traccar.org', - 'http://localhost:8082', - 'http://localhost:3000', -]; - -const useStyles = makeStyles((theme) => ({ - icon: { - textAlign: 'center', - fontSize: '128px', - color: theme.palette.colors.neutral, - }, - container: { - textAlign: 'center', - padding: theme.spacing(5, 3), - }, - field: { - margin: theme.spacing(3, 0), - }, -})); - -const ChangeServerPage = () => { - const classes = useStyles(); - const t = useTranslation(); - - const filter = createFilterOptions(); - - const handleSubmit = (url) => { - if (window.webkit && window.webkit.messageHandlers.appInterface) { - window.webkit.messageHandlers.appInterface.postMessage(`server|${url}`); - } else if (window.appInterface) { - window.appInterface.postMessage(`server|${url}`); - } else { - window.location.replace(url); - } - }; - - return ( - <Container maxWidth="xs" className={classes.container}> - <ElectricalServicesIcon className={classes.icon} /> - <Autocomplete - freeSolo - className={classes.field} - options={officialServers} - renderInput={(params) => <TextField {...params} label={t('settingsServer')} />} - value={currentServer} - onChange={(_, value) => handleSubmit(value)} - filterOptions={(options, params) => { - const filtered = filter(options, params); - if (params.inputValue && !filtered.includes(params.inputValue)) { - filtered.push(params.inputValue); - } - return filtered; - }} - /> - </Container> - ); -}; - -export default ChangeServerPage; |