Skip to content

TagSpaces is an offline, open source, document manager with tagging support

Make openstreetmap tile server configurable (#1434)

Stanimir9296db9f6391
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsx
index bbe2c025d..2afbabf41 100644
--- a/app/components/EntryContainer.tsx
+++ b/app/components/EntryContainer.tsx
@@ -58,7 +58,8 @@ import { buffer } from '-/utils/misc';
import {
actions as SettingsActions,
isDesktopMode,
- getKeyBindingObject
+ getKeyBindingObject,
+ getMapTileServer
} from '-/reducers/settings';
import TaggingActions from '-/reducers/tagging-actions';
import {
@@ -209,6 +210,7 @@ interface Props {
setSelectedEntries: (selectedEntries: Array<Object>) => void;
currentDirectoryPath: string | null;
isDesktopMode: boolean;
+ tileServer: TS.MapTileServer;
}
const EntryContainer = (props: Props) => {
@@ -1249,6 +1251,7 @@ const EntryContainer = (props: Props) => {
showNotification={props.showNotification}
isReadOnlyMode={props.isReadOnlyMode}
currentDirectoryPath={props.currentDirectoryPath}
+ tileServer={props.tileServer}
/>
)}
</div>
@@ -1284,7 +1287,8 @@ function mapStateToProps(state) {
settings: state.settings,
isReadOnlyMode: isReadOnlyMode(state),
keyBindings: getKeyBindingObject(state),
- isDesktopMode: isDesktopMode(state)
+ isDesktopMode: isDesktopMode(state),
+ tileServer: getMapTileServer(state)
};
}
diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsx
index be426ef69..813081478 100644
--- a/app/components/EntryProperties.tsx
+++ b/app/components/EntryProperties.tsx
@@ -188,6 +188,7 @@ interface Props {
isReadOnlyMode: boolean;
currentDirectoryPath: string | null;
tagDelimiter: string;
+ tileServer: TS.MapTileServer;
}
const EntryProperties = (props: Props) => {
@@ -197,9 +198,6 @@ const EntryProperties = (props: Props) => {
const objectStorageLinkRef = useRef<HTMLInputElement>(null);
const fileDescriptionRef = useRef<HTMLInputElement>(null);
- const MB_ATTR =
- '<b>Leaflet</b> | Map data &copy; <b>https://openstreetmap.org/copyright</b> contributors, <b>CC-BY-SA</b>, Imagery © <b>Mapbox</b>';
-
const parentDirectoryPath = extractContainingDirectoryPath(
props.openedEntry.path,
PlatformIO.getDirSeparator()
@@ -760,8 +758,8 @@ const EntryProperties = (props: Props) => {
attributionControl={false}
>
<TileLayer
- attribution={MB_ATTR}
- url="https://{s}.tile.osm.org/{z}/{x}/{y}.png"
+ attribution={props.tileServer.serverInfo}
+ url={props.tileServer.serverURL}
/>
<LayerGroup>
<Marker
diff --git a/app/components/Search.tsx b/app/components/Search.tsx
index 948c37788..adbe8c34e 100644
--- a/app/components/Search.tsx
+++ b/app/components/Search.tsx
@@ -448,17 +448,6 @@ const Search = React.memo((props: Props) => {
}
};
- const openPlace = () => {
- if (tagPlaceLat && tagPlaceLong) {
- PlatformIO.openUrl(
- 'https://www.openstreetmap.org/#map=16/' +
- tagPlaceLat +
- '/' +
- tagPlaceLong
- );
- }
- };
-
const startSearch = event => {
if (event.key === 'Enter' || event.keyCode === 13) {
if (props.hideDrawer) {
diff --git a/app/components/dialogs/EditEntryTagDialog.tsx b/app/components/dialogs/EditEntryTagDialog.tsx
index 4c26fcd2f..9b8573b83 100644
--- a/app/components/dialogs/EditEntryTagDialog.tsx
+++ b/app/components/dialogs/EditEntryTagDialog.tsx
@@ -38,6 +38,7 @@ import { isDateTimeTag } from '-/utils/dates';
import { AppConfig } from '-/config';
import { TS } from '-/tagspaces.namespace';
import useValidation from '-/utils/useValidation';
+import { getMapTileServer } from '-/reducers/settings';
const styles = () => ({
root: {
@@ -56,6 +57,7 @@ interface Props {
// currentEntryPath: string;
selectedEntries: Array<TS.FileSystemEntry>;
selectedTag: TS.Tag;
+ tileServer: TS.MapTileServer;
}
const GeoTagEditor = Pro && Pro.UI ? Pro.UI.GeoTagEditor : React.Fragment;
@@ -153,6 +155,7 @@ const EditEntryTagDialog = (props: Props) => {
showAdvancedMode={showAdvancedMode}
haveError={haveError}
setError={setError}
+ tileServer={props.tileServer}
/>
)}
{isShowDatePeriodEditor && (
@@ -229,7 +232,8 @@ function mapStateToProps(state) {
/* currentEntryPath: getSelectedTag(state)
? getSelectedTag(state).path
: undefined, */
- selectedEntries: getSelectedEntries(state)
+ selectedEntries: getSelectedEntries(state),
+ tileServer: getMapTileServer(state)
};
}
diff --git a/app/components/dialogs/settings/MapTileServerDialog.tsx b/app/components/dialogs/settings/MapTileServerDialog.tsx
new file mode 100644
index 000000000..76eec15fc
--- /dev/null
+++ b/app/components/dialogs/settings/MapTileServerDialog.tsx
@@ -0,0 +1,232 @@
+/**
+ * TagSpaces - universal file and folder organizer
+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License (version 3) as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+import React, { useRef } from 'react';
+import Button from '@material-ui/core/Button';
+import Dialog from '@material-ui/core/Dialog';
+import DialogActions from '@material-ui/core/DialogActions';
+import DialogContent from '@material-ui/core/DialogContent';
+import DialogTitle from '@material-ui/core/DialogTitle';
+import IconButton from '@material-ui/core/IconButton';
+import CloseIcon from '@material-ui/icons/Close';
+import TextField from '@material-ui/core/TextField';
+import FormHelperText from '@material-ui/core/FormHelperText';
+import FormControl from '@material-ui/core/FormControl';
+import Switch from '@material-ui/core/Switch';
+import { connect } from 'react-redux';
+import { bindActionCreators } from 'redux';
+import i18n from '-/services/i18n';
+import useValidation from '-/utils/useValidation';
+import { TS } from '-/tagspaces.namespace';
+import { actions as SettingsActions } from '-/reducers/settings';
+
+interface Props {
+ open: boolean;
+ onClose: () => void;
+ tileServer: TS.MapTileServer;
+ isDefault: boolean;
+ editTileServers: (tileServer: TS.MapTileServer, isDefault: boolean) => void;
+ addTileServers: (tileServer: TS.MapTileServer, isDefault: boolean) => void;
+ deleteTileServer: (uuid: string) => void;
+}
+
+const MapTileServerDialog = (props: Props) => {
+ const name = useRef<string>(props.tileServer.name);
+ const serverURL = useRef<string>(props.tileServer.serverURL);
+ const serverInfo = useRef<string>(props.tileServer.serverInfo);
+ const isDefault = useRef<boolean>(props.isDefault);
+
+ const { setError, haveError } = useValidation();
+ const renderTitle = () => (
+ <DialogTitle>
+ {i18n.t(
+ props.tileServer.uuid
+ ? 'core:tileServerDialogEdit'
+ : 'core:tileServerDialogAdd'
+ )}{' '}
+ <IconButton
+ aria-label="close"
+ style={{
+ position: 'absolute',
+ right: 5,
+ top: 5
+ }}
+ onClick={props.onClose}
+ >
+ <CloseIcon />
+ </IconButton>
+ </DialogTitle>
+ );
+
+ const validateForm = () => {
+ if (!name.current) {
+ setError('name');
+ return false;
+ }
+ setError('name', false);
+ return true;
+ };
+
+ const saveTileServer = () => {
+ if (validateForm()) {
+ if (props.tileServer.uuid) {
+ props.editTileServers(
+ {
+ uuid: props.tileServer.uuid,
+ name: name.current,
+ serverInfo: serverInfo.current,
+ serverURL: serverURL.current
+ },
+ isDefault.current
+ );
+ } else {
+ props.addTileServers(
+ {
+ uuid: props.tileServer.uuid,
+ name: name.current,
+ serverInfo: serverInfo.current,
+ serverURL: serverURL.current
+ },
+ isDefault.current
+ );
+ }
+ props.onClose();
+ }
+ };
+
+ const renderContent = () => (
+ <DialogContent>
+ <FormControl fullWidth={true} error={haveError('name')}>
+ <TextField
+ fullWidth
+ error={haveError('name')}
+ margin="dense"
+ autoFocus
+ name="name"
+ label={i18n.t('core:tileServerNameTitle')}
+ onChange={event => {
+ const { target } = event;
+ name.current = target.value;
+ validateForm();
+ }}
+ defaultValue={name.current}
+ data-tid="tileServerNameTID"
+ />
+ </FormControl>
+ <FormControl fullWidth={true}>
+ <TextField
+ fullWidth
+ margin="dense"
+ name="serverURL"
+ label={i18n.t('core:tileServerUrlTitle')}
+ onChange={event => {
+ const { target } = event;
+ serverURL.current = target.value;
+ }}
+ defaultValue={serverURL.current}
+ data-tid="tileServerUrlTID"
+ />
+ <FormHelperText>{i18n.t('core:tileServerUrlHelp')}</FormHelperText>
+ </FormControl>
+ <FormControl fullWidth={true}>
+ <TextField
+ fullWidth
+ margin="dense"
+ name="serverInfo"
+ label={i18n.t('core:tileServerInfoTitle')}
+ onChange={event => {
+ const { target } = event;
+ serverInfo.current = target.value;
+ }}
+ defaultValue={serverInfo.current}
+ data-tid="tileserverInfoTID"
+ />
+ </FormControl>
+ <FormControl fullWidth={true}>
+ <Switch
+ data-tid="serverIsDefaultTID"
+ onClick={() => {
+ isDefault.current = !isDefault.current;
+ }}
+ defaultChecked={isDefault.current}
+ />
+ <FormHelperText>{i18n.t('core:serverIsDefaultHelp')}</FormHelperText>
+ </FormControl>
+ </DialogContent>
+ );
+
+ const renderActions = () => (
+ <DialogActions
+ style={{
+ justifyContent: 'flex-end'
+ }}
+ >
+ {props.tileServer.uuid && (
+ <Button
+ data-tid="deleteTileServerTID"
+ onClick={() => {
+ props.deleteTileServer(props.tileServer.uuid);
+ props.onClose();
+ }}
+ color="secondary"
+ >
+ {i18n.t('core:delete')}
+ </Button>
+ )}
+ <Button
+ data-tid="closeTileServerDialogTID"
+ onClick={props.onClose}
+ color="primary"
+ >
+ {i18n.t('core:closeButton')}
+ </Button>
+ <Button
+ data-tid="saveTileServerDialogTID"
+ onClick={saveTileServer}
+ color="primary"
+ >
+ {i18n.t('core:confirmSaveButton')}
+ </Button>
+ </DialogActions>
+ );
+
+ const { open, onClose } = props;
+ return (
+ <Dialog open={open} keepMounted scroll="paper" onClose={onClose}>
+ {renderTitle()}
+ {renderContent()}
+ {renderActions()}
+ </Dialog>
+ );
+};
+
+function mapActionCreatorsToProps(dispatch) {
+ return bindActionCreators(
+ {
+ editTileServers: SettingsActions.editTileServers,
+ addTileServers: SettingsActions.addTileServers,
+ deleteTileServer: SettingsActions.deleteTileServer
+ },
+ dispatch
+ );
+}
+
+export default connect(
+ undefined,
+ mapActionCreatorsToProps
+)(MapTileServerDialog);
diff --git a/app/components/dialogs/settings/SettingsGeneral.tsx b/app/components/dialogs/settings/SettingsGeneral.tsx
index c38506a68..382432595 100644
--- a/app/components/dialogs/settings/SettingsGeneral.tsx
+++ b/app/components/dialogs/settings/SettingsGeneral.tsx
@@ -34,6 +34,10 @@ import InfoIcon from '@material-ui/icons/InfoOutlined';
import CheckIcon from '@material-ui/icons/Check';
import ToggleButton from '@material-ui/lab/ToggleButton';
import ToggleButtonGroup from '@material-ui/lab/ToggleButtonGroup';
+import EditIcon from '@material-ui/icons/Edit';
+import IconButton from '@material-ui/core/IconButton';
+import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
+import AddIcon from '@material-ui/icons/Add';
import i18n from '-/services/i18n';
import {
actions as SettingsActions,
@@ -43,6 +47,8 @@ import {
import ColorPickerDialog from '../ColorPickerDialog';
import TransparentBackground from '../../TransparentBackground';
import AppConfig from '-/config';
+import { TS } from '-/tagspaces.namespace';
+import MapTileServerDialog from '-/components/dialogs/settings/MapTileServerDialog';
const styles: any = {
root: {
@@ -79,10 +85,12 @@ interface Props {
setMaxSearchResult: (maxResult: string) => void;
setDesktopMode: (desktopMode: boolean) => void;
showResetSettings: (showDialog: boolean) => void;
+ tileServers: Array<TS.MapTileServer>;
}
const SettingsGeneral = (props: Props) => {
const [displayColorPicker, setDisplayColorPicker] = useState<boolean>(false);
+ const [tileServerDialog, setTileServerDialog] = useState<any>(undefined);
const [displayTextColorPicker, setDisplayTextColorPicker] = useState<boolean>(
false
);
@@ -107,225 +115,237 @@ const SettingsGeneral = (props: Props) => {
props.setMaxSearchResult(event.target.value);
};
+ const handleEditTileServerClick = (
+ event: any,
+ tileServer: any,
+ isDefault: boolean
+ ) => {
+ event.preventDefault();
+ event.stopPropagation();
+ setTileServerDialog({ ...tileServer, isDefault });
+ };
+
const { classes, persistTagsInSidecarFile } = props;
return (
- <List className={classes.root}>
- <ListItem className={classes.listItem}>
- <ListItemText primary={i18n.t('core:interfaceLanguage')} />
- <Select
- data-tid="settingsSetLanguage"
- value={props.settings.interfaceLanguage}
- onChange={(event: any) => {
- props.setLanguage(event.target.value);
- const { currentTheme } = props.settings;
- const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
- props.setCurrentTheme(newTheme);
- setTimeout(() => {
- props.setCurrentTheme(currentTheme);
- }, 500);
- }}
- input={<Input id="languageSelector" />}
- >
- {props.settings.supportedLanguages.map(language => (
- <MenuItem key={language.iso} value={language.iso}>
- {language.title}
- </MenuItem>
- ))}
- </Select>
- </ListItem>
- <ListItem className={classes.listItem}>
- <ListItemText primary={i18n.t('core:themeSelector')} />
- <Select
- data-tid="settingsSetCurrentTheme"
- value={props.settings.currentTheme}
- onChange={(event: any) => props.setCurrentTheme(event.target.value)}
- input={<Input id="themeSelector" />}
- >
- {props.settings.supportedThemes.map(theme => (
- <MenuItem key={theme} value={theme}>
- {theme}
- </MenuItem>
- ))}
- </Select>
- </ListItem>
- <ListItem
- className={classes.listItem}
- title={
- AppConfig.useSidecarsForFileTaggingDisableSetting
- ? 'This setting is managed with an external configuration'
- : ''
- }
- >
- <ListItemText primary="File tagging method" />
- {AppConfig.useSidecarsForFileTaggingDisableSetting ? (
- <Button size="small" variant="outlined" disabled>
- {persistTagsInSidecarFile ? 'Use Sidecar Files' : 'Rename Files'}
- </Button>
- ) : (
- <ToggleButtonGroup
- value={persistTagsInSidecarFile}
- size="small"
- exclusive
+ <>
+ <List className={classes.root}>
+ <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('core:interfaceLanguage')} />
+ <Select
+ data-tid="settingsSetLanguage"
+ value={props.settings.interfaceLanguage}
+ onChange={(event: any) => {
+ props.setLanguage(event.target.value);
+ const { currentTheme } = props.settings;
+ const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
+ props.setCurrentTheme(newTheme);
+ setTimeout(() => {
+ props.setCurrentTheme(currentTheme);
+ }, 500);
+ }}
+ input={<Input id="languageSelector" />}
+ >
+ {props.settings.supportedLanguages.map(language => (
+ <MenuItem key={language.iso} value={language.iso}>
+ {language.title}
+ </MenuItem>
+ ))}
+ </Select>
+ </ListItem>
+ <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('core:themeSelector')} />
+ <Select
+ data-tid="settingsSetCurrentTheme"
+ value={props.settings.currentTheme}
+ onChange={(event: any) => props.setCurrentTheme(event.target.value)}
+ input={<Input id="themeSelector" />}
>
- <ToggleButton
- value={false}
- data-tid="settingsSetPersistTagsInFileName"
- onClick={() => props.setPersistTagsInSidecarFile(false)}
+ {props.settings.supportedThemes.map(theme => (
+ <MenuItem key={theme} value={theme}>
+ {theme}
+ </MenuItem>
+ ))}
+ </Select>
+ </ListItem>
+ <ListItem
+ className={classes.listItem}
+ title={
+ AppConfig.useSidecarsForFileTaggingDisableSetting
+ ? 'This setting is managed with an external configuration'
+ : ''
+ }
+ >
+ <ListItemText primary="File tagging method" />
+ {AppConfig.useSidecarsForFileTaggingDisableSetting ? (
+ <Button size="small" variant="outlined" disabled>
+ {persistTagsInSidecarFile ? 'Use Sidecar Files' : 'Rename Files'}
+ </Button>
+ ) : (
+ <ToggleButtonGroup
+ value={persistTagsInSidecarFile}
+ size="small"
+ exclusive
>
- <Tooltip
- arrow
- title={
- <Typography color="inherit">
- Use the name of file for saving the tags - Tagging the file{' '}
- <b>image.jpg</b> with a tag <b>sunset</b> will rename it to{' '}
- <b>image[sunset].jpg</b>
- </Typography>
- }
+ <ToggleButton
+ value={false}
+ data-tid="settingsSetPersistTagsInFileName"
+ onClick={() => props.setPersistTagsInSidecarFile(false)}
>
- <div style={{ display: 'flex' }}>
- {!persistTagsInSidecarFile && <CheckIcon />}
- &nbsp;Rename Files&nbsp;&nbsp;
- <InfoIcon />
- </div>
- </Tooltip>
- </ToggleButton>
- <ToggleButton
- value={true}
- data-tid="settingsSetPersistTagsInSidecarFile"
- onClick={() => props.setPersistTagsInSidecarFile(true)}
- >
- <Tooltip
- arrow
- title={
- <Typography color="inherit">
- Use sidecar file for saving the tags - Tagging the file{' '}
- <b>image.jpg</b> with a tag <b>sunset</b> will save this tag{' '}
- in an additional sidecar file called <b>image.jpg.json</b>{' '}
- located in a sub folder with the name <b>.ts</b>
- </Typography>
- }
+ <Tooltip
+ arrow
+ title={
+ <Typography color="inherit">
+ Use the name of file for saving the tags - Tagging the
+ file <b>image.jpg</b> with a tag <b>sunset</b> will rename
+ it to <b>image[sunset].jpg</b>
+ </Typography>
+ }
+ >
+ <div style={{ display: 'flex' }}>
+ {!persistTagsInSidecarFile && <CheckIcon />}
+ &nbsp;Rename Files&nbsp;&nbsp;
+ <InfoIcon />
+ </div>
+ </Tooltip>
+ </ToggleButton>
+ <ToggleButton
+ value={true}
+ data-tid="settingsSetPersistTagsInSidecarFile"
+ onClick={() => props.setPersistTagsInSidecarFile(true)}
>
- <div style={{ display: 'flex' }}>
- {persistTagsInSidecarFile && <CheckIcon />}
- &nbsp;Use Sidecar Files&nbsp;&nbsp;
- <InfoIcon />
- </div>
- </Tooltip>
- </ToggleButton>
- </ToggleButtonGroup>
- )}
- </ListItem>
- <ListItem className={classes.listItem}>
- <ListItemText primary={i18n.t('core:checkForNewVersionOnStartup')} />
- <Switch
- data-tid="settingsSetCheckForUpdates"
- onClick={() =>
- props.setCheckForUpdates(!props.settings.checkForUpdates)
- }
- checked={props.settings.checkForUpdates}
- />
- </ListItem>
- <ListItem className={classes.listItem}>
- <ListItemText primary={i18n.t('core:addTagsToLibrary')} />
- <Switch
- data-tid="settingsSetAddTagsToLibrary"
- onClick={() =>
- props.setAddTagsToLibrary(!props.settings.addTagsToLibrary)
- }
- checked={props.settings.addTagsToLibrary}
- />
- </ListItem>
- <ListItem className={classes.listItem}>
- <ListItemText primary={i18n.t('core:useGenerateThumbnails')} />
- <Switch
- data-tid="settingsUseGenerateThumbnails"
- onClick={() =>
- props.setUseGenerateThumbnails(
- !props.settings.useGenerateThumbnails
- )
- }
- checked={props.settings.useGenerateThumbnails}
- />
- </ListItem>
- <ListItem className={classes.listItem}>
- <ListItemText primary={i18n.t('core:tagBackgroundColor')} />
- <TransparentBackground>
- <Button
- data-tid="settingsToggleDefaultTagBackgroundColor"
- className={classes.colorChooserButton}
- size="small"
- style={{
- backgroundColor: props.settings.tagBackgroundColor
- }}
- onClick={toggleDefaultTagBackgroundColorPicker}
- >
- &nbsp;
- </Button>
- </TransparentBackground>
- {displayColorPicker && (
- <ColorPickerDialog
- open={displayColorPicker}
- setColor={color => {
- props.setTagColor(color);
- }}
- onClose={toggleDefaultTagBackgroundColorPicker}
- color={props.settings.tagBackgroundColor}
+ <Tooltip
+ arrow
+ title={
+ <Typography color="inherit">
+ Use sidecar file for saving the tags - Tagging the file{' '}
+ <b>image.jpg</b> with a tag <b>sunset</b> will save this
+ tag in an additional sidecar file called{' '}
+ <b>image.jpg.json</b> located in a sub folder with the
+ name <b>.ts</b>
+ </Typography>
+ }
+ >
+ <div style={{ display: 'flex' }}>
+ {persistTagsInSidecarFile && <CheckIcon />}
+ &nbsp;Use Sidecar Files&nbsp;&nbsp;
+ <InfoIcon />
+ </div>
+ </Tooltip>
+ </ToggleButton>
+ </ToggleButtonGroup>
+ )}
+ </ListItem>
+ <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('core:checkForNewVersionOnStartup')} />
+ <Switch
+ data-tid="settingsSetCheckForUpdates"
+ onClick={() =>
+ props.setCheckForUpdates(!props.settings.checkForUpdates)
+ }
+ checked={props.settings.checkForUpdates}
/>
- )}
- </ListItem>
- <ListItem className={classes.listItem}>
- <ListItemText primary={i18n.t('core:tagForegroundColor')} />
- <TransparentBackground>
- <Button
- data-tid="settingsToggleDefaultTagForegroundColor"
- className={classes.colorChooserButton}
- size="small"
- style={{ backgroundColor: props.settings.tagTextColor }}
- onClick={toggleDefaultTagTextColorPicker}
- >
- &nbsp;
- </Button>
- </TransparentBackground>
- {displayTextColorPicker && (
- <ColorPickerDialog
- open={displayTextColorPicker}
- setColor={color => {
- props.setTagTextColor(color);
- }}
- onClose={toggleDefaultTagTextColorPicker}
- color={props.settings.tagTextColor}
+ </ListItem>
+ <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('core:addTagsToLibrary')} />
+ <Switch
+ data-tid="settingsSetAddTagsToLibrary"
+ onClick={() =>
+ props.setAddTagsToLibrary(!props.settings.addTagsToLibrary)
+ }
+ checked={props.settings.addTagsToLibrary}
+ />
+ </ListItem>
+ <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('core:useGenerateThumbnails')} />
+ <Switch
+ data-tid="settingsUseGenerateThumbnails"
+ onClick={() =>
+ props.setUseGenerateThumbnails(
+ !props.settings.useGenerateThumbnails
+ )
+ }
+ checked={props.settings.useGenerateThumbnails}
/>
+ </ListItem>
+ <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('core:tagBackgroundColor')} />
+ <TransparentBackground>
+ <Button
+ data-tid="settingsToggleDefaultTagBackgroundColor"
+ className={classes.colorChooserButton}
+ size="small"
+ style={{
+ backgroundColor: props.settings.tagBackgroundColor
+ }}
+ onClick={toggleDefaultTagBackgroundColorPicker}
+ >
+ &nbsp;
+ </Button>
+ </TransparentBackground>
+ {displayColorPicker && (
+ <ColorPickerDialog
+ open={displayColorPicker}
+ setColor={color => {
+ props.setTagColor(color);
+ }}
+ onClose={toggleDefaultTagBackgroundColorPicker}
+ color={props.settings.tagBackgroundColor}
+ />
+ )}
+ </ListItem>
+ <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('core:tagForegroundColor')} />
+ <TransparentBackground>
+ <Button
+ data-tid="settingsToggleDefaultTagForegroundColor"
+ className={classes.colorChooserButton}
+ size="small"
+ style={{ backgroundColor: props.settings.tagTextColor }}
+ onClick={toggleDefaultTagTextColorPicker}
+ >
+ &nbsp;
+ </Button>
+ </TransparentBackground>
+ {displayTextColorPicker && (
+ <ColorPickerDialog
+ open={displayTextColorPicker}
+ setColor={color => {
+ props.setTagTextColor(color);
+ }}
+ onClose={toggleDefaultTagTextColorPicker}
+ color={props.settings.tagTextColor}
+ />
+ )}
+ </ListItem>
+ {AppConfig.isElectron && (
+ <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('core:useTrashCan')} />
+ <Switch
+ data-tid="settingsSetUseTrashCan"
+ onClick={() => props.setUseTrashCan(!props.settings.useTrashCan)}
+ checked={props.settings.useTrashCan}
+ />
+ </ListItem>
)}
- </ListItem>
- {AppConfig.isElectron && (
<ListItem className={classes.listItem}>
- <ListItemText primary={i18n.t('core:useTrashCan')} />
+ <ListItemText primary={i18n.t('core:showUnixHiddenFiles')} />
<Switch
- data-tid="settingsSetUseTrashCan"
- onClick={() => props.setUseTrashCan(!props.settings.useTrashCan)}
- checked={props.settings.useTrashCan}
+ data-tid="settingsSetShowUnixHiddenEntries"
+ onClick={props.toggleShowUnixHiddenEntries}
+ checked={props.settings.showUnixHiddenEntries}
/>
</ListItem>
- )}
- <ListItem className={classes.listItem}>
- <ListItemText primary={i18n.t('core:showUnixHiddenFiles')} />
- <Switch
- data-tid="settingsSetShowUnixHiddenEntries"
- onClick={props.toggleShowUnixHiddenEntries}
- checked={props.settings.showUnixHiddenEntries}
- />
- </ListItem>
- <ListItem className={classes.listItem}>
- <ListItemText primary="Enable mobile (small screen) mode" />
- <Switch
- data-tid="settingsSetDesktopMode"
- disabled={!(typeof window.ExtDisplayMode === 'undefined')}
- onClick={() => props.setDesktopMode(!props.settings.desktopMode)}
- checked={!props.settings.desktopMode}
- />
- </ListItem>
- {/* <ListItem className={classes.listItem}>
+ <ListItem className={classes.listItem}>
+ <ListItemText primary="Enable mobile (small screen) mode" />
+ <Switch
+ data-tid="settingsSetDesktopMode"
+ disabled={!(typeof window.ExtDisplayMode === 'undefined')}
+ onClick={() => props.setDesktopMode(!props.settings.desktopMode)}
+ checked={!props.settings.desktopMode}
+ />
+ </ListItem>
+ {/* <ListItem className={classes.listItem}>
<ListItemText style={{ maxWidth: '300px' }} primary={i18n.t('core:tagDelimiterChoose')} />
<Select
style={{ minWidth: '170px' }}
@@ -342,17 +362,60 @@ const SettingsGeneral = (props: Props) => {
<MenuItem value=",">{i18n.t('core:tagDelimiterComma')}</MenuItem>
</Select>
</ListItem> */}
- <ListItem className={classes.listItem}>
- <ListItemText primary={i18n.t('core:maxSearchResultChoose')} />
- <Input
- style={{ maxWidth: '100px' }}
- type="number"
- data-tid="settingsMaxSearchResult"
- value={props.settings.maxSearchResult}
- onChange={handleMaxSearchResult}
- />
- </ListItem>
- {/* <ListItem className={classes.listItem}>
+ <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('core:maxSearchResultChoose')} />
+ <Input
+ style={{ maxWidth: '100px' }}
+ type="number"
+ data-tid="settingsMaxSearchResult"
+ value={props.settings.maxSearchResult}
+ onChange={handleMaxSearchResult}
+ />
+ </ListItem>
+ <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('core:tileServerTitle')} />
+ <ListItemSecondaryAction>
+ <IconButton
+ aria-label={i18n.t('core:add')}
+ aria-haspopup="true"
+ edge="end"
+ data-tid="addTileServerTID"
+ onClick={event => handleEditTileServerClick(event, {}, true)}
+ >
+ <AddIcon />
+ </IconButton>
+ </ListItemSecondaryAction>
+ </ListItem>
+ {props.tileServers.map((tileServer, index) => (
+ <ListItem key={tileServer.uuid} className={classes.listItem}>
+ <ListItemText
+ primary={tileServer.name}
+ secondary={tileServer.serverURL}
+ />
+ <ListItemSecondaryAction>
+ {index === 0 && (
+ <Tooltip title={i18n.t('core:serverIsDefaultHelp')}>
+ <CheckIcon
+ data-tid="startupIndication"
+ style={{ marginLeft: 10 }}
+ />
+ </Tooltip>
+ )}
+ <IconButton
+ aria-label={i18n.t('core:options')}
+ aria-haspopup="true"
+ edge="end"
+ data-tid={'locationMoreButton_' + tileServer.name}
+ onClick={event =>
+ handleEditTileServerClick(event, tileServer, index === 0)
+ }
+ >
+ <EditIcon />
+ </IconButton>
+ </ListItemSecondaryAction>
+ </ListItem>
+ ))}
+ {/* <ListItem className={classes.listItem}>
<ListItemText primary={i18n.t('core:coloredFileExtensionsEnabled')} />
<Switch
data-tid="settingsSetColoredFileExtension"
@@ -364,7 +427,7 @@ const SettingsGeneral = (props: Props) => {
checked={this.props.settings.coloredFileExtension}
/>
</ListItem> */}
- {/* <ListItem className={classes.listItem}>
+ {/* <ListItem className={classes.listItem}>
<ListItemText primary={i18n.t('core:loadLocationMetaData')} />
<Switch
data-tid="settingsSetLoadsLocationMetaData"
@@ -376,54 +439,43 @@ const SettingsGeneral = (props: Props) => {
checked={this.props.settings.loadsLocationMetaData}
/>
</ListItem> */}
- <ListItem className={classes.listItem}>
- <Button
- data-tid="resetSettingsTID"
- onClick={() => props.showResetSettings(true)}
- color="secondary"
- style={{ marginLeft: -7 }}
- >
- {i18n.t('core:resetSettings')}
- </Button>
- <Button
- data-tid="reloadAppTID"
- onClick={() => {
- window.location.reload();
- }}
- color="secondary"
- >
- {i18n.t('core:reloadApplication')}
- </Button>
- </ListItem>
- </List>
- );
-};
-
-/*
<ListItem className={classes.listItem}>
- <span className={this.props.classes.pro}>pro</span>
- <ListItemText primary={i18n.t('core:calculateTag')} />
- <Switch
- data-tid="settingsSetCalculateTags"
- onClick={() =>
- this.props.setCalculateTags(!this.props.settings.calculateTags)
- }
- checked={this.props.settings.calculateTags}
- />
- </ListItem>
- <ListItem>
- <ListItemText primary={i18n.t('core:useTextExtraction')} />
- <Switch
- onClick={() => this.props.setUseTextExtraction(!this.props.settings.useTextExtraction)}
- checked={this.props.settings.useTextExtraction}
- />
+ <Button
+ data-tid="resetSettingsTID"
+ onClick={() => props.showResetSettings(true)}
+ color="secondary"
+ style={{ marginLeft: -7 }}
+ >
+ {i18n.t('core:resetSettings')}
+ </Button>
+ <Button
+ data-tid="reloadAppTID"
+ onClick={() => {
+ window.location.reload();
+ }}
+ color="secondary"
+ >
+ {i18n.t('core:reloadApplication')}
+ </Button>
</ListItem>
-*/
+ </List>
+ {tileServerDialog && (
+ <MapTileServerDialog
+ open={tileServerDialog !== undefined}
+ onClose={() => setTileServerDialog(undefined)}
+ tileServer={tileServerDialog}
+ isDefault={tileServerDialog.isDefault}
+ />
+ )}
+ </>
+ );
+};
function mapStateToProps(state) {
return {
settings: getSettings(state),
- persistTagsInSidecarFile: getPersistTagsInSidecarFile(state)
+ persistTagsInSidecarFile: getPersistTagsInSidecarFile(state),
+ tileServers: state.settings.tileServers
};
}
diff --git a/app/locales/en/core.json b/app/locales/en/core.json
index b2c30d945..34c8dd787 100644
--- a/app/locales/en/core.json
+++ b/app/locales/en/core.json
@@ -556,6 +556,14 @@
"exportCsv": "Export current files and folders as CSV file",
"lat": "Latitude",
"lng": "Longitude",
- "coordinatesTitleHelper": "Invalid coordinate (please use 40.123, -74.123 or 40° 7.38’, -74° 7.38’)",
+ "coordinatesTitleHelper": "Invalid coordinate (supported 40.123 or 40° 7.38’)",
+ "tileServerTitle": "Map Tile Servers",
+ "tileServerDialogEdit": "Edit Map Tile Server",
+ "tileServerDialogAdd": "Add Map Tile Server",
+ "tileServerNameTitle": "Server Name",
+ "tileServerUrlTitle": "Server URL",
+ "tileServerUrlHelp": "Example: https://{s}.tile.osm.org/{z}/{x}/{y}.png",
+ "tileServerInfoTitle": "Copyright Information",
+ "serverIsDefaultHelp": "Default Map Tile Server",
"-": "-"
}
diff --git a/app/reducers/settings-default.ts b/app/reducers/settings-default.ts
index bc7e8df9c..0f7332115 100644
--- a/app/reducers/settings-default.ts
+++ b/app/reducers/settings-default.ts
@@ -25,6 +25,28 @@ if (window.ExtDisplayMode && window.ExtDisplayMode === 'mobile') {
desktopMode = true;
}
+let tileServers;
+if (window.ExtTileServers) {
+ tileServers = window.ExtTileServers;
+} else {
+ tileServers = [
+ {
+ uuid: '1',
+ name: 'Standard',
+ serverURL: 'https://{s}.tile.osm.org/{z}/{x}/{y}.png',
+ serverInfo:
+ '<b>Leaflet</b> | Map data &copy; <b>https://openstreetmap.org/copyright</b> contributors, <b>CC-BY-SA</b>, Imagery © <b>Mapbox</b>'
+ },
+ {
+ uuid: '2',
+ name: 'Topographic',
+ serverURL: 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
+ serverInfo:
+ '<b>Leaflet</b> | Map data: &copy; <b>https://openstreetmap.org/copyright</b> contributors, <b>http://viewfinderpanoramas.org</b> - SRTM | Map style: &copy; <b>https://opentopomap.org</b> - OpenTopoMap (<b>https://creativecommons.org/licenses/by-sa/3.0/</b> - CC-BY-SA'
+ }
+ ];
+}
+
export function findAvailableExtensions() {
// TODO Search in users tagspaces folder
// Search in the installation folder
@@ -115,6 +137,7 @@ export function findAvailableExtensions() {
}
export default {
+ tileServers,
settingsVersion: 3,
isLoading: false,
error: null,
diff --git a/app/reducers/settings.ts b/app/reducers/settings.ts
index 965a074f8..7d3806b22 100644
--- a/app/reducers/settings.ts
+++ b/app/reducers/settings.ts
@@ -17,6 +17,7 @@
*/
import semver from 'semver';
+import uuidv1 from 'uuid';
import i18n from '../services/i18n';
// import AppConfig from '../config';
import defaultSettings from './settings-default';
@@ -24,6 +25,7 @@ import PlatformIO from '../services/platform-io';
import AppConfig from '../config';
import versionMeta from '../version.json';
import { actions as AppActions } from './app';
+import { TS } from '-/tagspaces.namespace';
export const types = {
UPGRADE_SETTINGS: 'SETTINGS/UPGRADE_SETTINGS',
@@ -66,7 +68,10 @@ export const types = {
SET_MAIN_VSPLIT_SIZE: 'SETTINGS/SET_MAIN_VSPLIT_SIZE',
SET_LEFT_VSPLIT_SIZE: 'SETTINGS/SET_LEFT_VSPLIT_SIZE',
SET_FIRST_RUN: 'SETTINGS/SET_FIRST_RUN',
- TOGGLE_TAGGROUP: 'TOGGLE_TAGGROUP'
+ TOGGLE_TAGGROUP: 'TOGGLE_TAGGROUP',
+ ADD_MAPTILE_SERVER: 'SET_MAPTILE_SERVER',
+ EDIT_MAPTILE_SERVER: 'EDIT_MAPTILE_SERVER',
+ DELETE_MAPTILE_SERVER: 'DELETE_MAPTILE_SERVER'
};
export default (state: any = defaultSettings, action: any) => {
@@ -304,6 +309,56 @@ export default (state: any = defaultSettings, action: any) => {
tagGroupCollapsed
};
}
+ case types.ADD_MAPTILE_SERVER: {
+ let tileServers;
+ if (action.isDefault) {
+ tileServers = [
+ { ...action.tileServer, uuid: uuidv1() },
+ ...state.tileServers
+ ];
+ } else {
+ tileServers = [
+ ...state.tileServers,
+ { ...action.tileServer, uuid: uuidv1() }
+ ];
+ }
+ return {
+ ...state,
+ tileServers
+ };
+ }
+ case types.EDIT_MAPTILE_SERVER: {
+ let tileServers;
+ if (action.isDefault) {
+ tileServers = [
+ action.tileServer,
+ ...state.tileServers.filter(
+ tileServer => tileServer.uuid !== action.tileServer.uuid
+ )
+ ];
+ } else {
+ tileServers = [
+ ...state.tileServers.filter(
+ tileServer => tileServer.uuid !== action.tileServer.uuid
+ ),
+ action.tileServer
+ ];
+ }
+
+ return {
+ ...state,
+ tileServers
+ };
+ }
+ case types.DELETE_MAPTILE_SERVER: {
+ const tileServers = state.tileServers.filter(
+ tileServer => tileServer.uuid !== action.uuid
+ );
+ return {
+ ...state,
+ tileServers
+ };
+ }
default: {
return state;
}
@@ -311,6 +366,26 @@ export default (state: any = defaultSettings, action: any) => {
};
export const actions = {
+ addTileServers: (
+ tileServer: TS.MapTileServer,
+ isDefault: boolean = false
+ ) => ({
+ type: types.ADD_MAPTILE_SERVER,
+ tileServer,
+ isDefault
+ }),
+ editTileServers: (
+ tileServer: TS.MapTileServer,
+ isDefault: boolean = false
+ ) => ({
+ type: types.EDIT_MAPTILE_SERVER,
+ tileServer,
+ isDefault
+ }),
+ deleteTileServer: (uuid: string) => ({
+ type: types.DELETE_MAPTILE_SERVER,
+ uuid
+ }),
toggleTagGroup: (tagGroupUUID: string) => ({
type: types.TOGGLE_TAGGROUP,
uuid: tagGroupUUID
@@ -493,6 +568,8 @@ export function getLastVersionPromise(): Promise<string> {
}
// Selectors
+export const getMapTileServer = (state: any): TS.MapTileServer =>
+ state.settings.tileServers[0];
export const getSettings = (state: any) => state.settings;
export const getDesktopMode = (state: any) => {
if (typeof window.ExtDisplayMode === 'undefined') {
diff --git a/app/tagspaces.d.ts b/app/tagspaces.d.ts
index d428b4d84..145c4b1b5 100644
--- a/app/tagspaces.d.ts
+++ b/app/tagspaces.d.ts
@@ -27,6 +27,7 @@ declare module '*.xml';
declare interface Window {
// interface TSCustomWindow extends Window {
+ ExtTileServers?: Array<TS.MapTileServer>;
walkCanceled?: boolean;
ExtLogoURL?: string;
ExtDefaultVerticalPanel?: string;
diff --git a/app/tagspaces.namespace.d.ts b/app/tagspaces.namespace.d.ts
index 59ac1abfc..77cb71fea 100644
--- a/app/tagspaces.namespace.d.ts
+++ b/app/tagspaces.namespace.d.ts
@@ -126,4 +126,11 @@ export namespace TS {
files?: Array<FileSystemEntry>;
dirs?: Array<FileSystemEntry>;
}
+
+ interface MapTileServer {
+ uuid: string;
+ name: string;
+ serverURL: string;
+ serverInfo: string;
+ }
}