From 5a8450ed2a50213c692a319a63fd45f6c91c54d7 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 11 May 2023 08:09:57 -0700 Subject: Add railway map overlay --- modern/src/map/overlay/useMapOverlays.js | 6 ++++++ modern/src/resources/l10n/en.json | 1 + 2 files changed, 7 insertions(+) (limited to 'modern') diff --git a/modern/src/map/overlay/useMapOverlays.js b/modern/src/map/overlay/useMapOverlays.js index 3d539d32..fa5240e8 100644 --- a/modern/src/map/overlay/useMapOverlays.js +++ b/modern/src/map/overlay/useMapOverlays.js @@ -28,6 +28,12 @@ export default () => { source: sourceCustom(['https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png']), available: true, }, + { + id: 'openRaiwayMap', + title: t('mapOpenRaiwayMap'), + source: sourceCustom(['https://tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png']), + available: true, + }, { id: 'openWeatherClouds', title: t('mapOpenWeatherClouds'), diff --git a/modern/src/resources/l10n/en.json b/modern/src/resources/l10n/en.json index 9d76814d..69db954f 100644 --- a/modern/src/resources/l10n/en.json +++ b/modern/src/resources/l10n/en.json @@ -309,6 +309,7 @@ "mapOverlay": "Map Overlay", "mapOverlayCustom": "Custom Overlay", "mapOpenSeaMap": "OpenSeaMap", + "mapOpenRaiwayMap": "OpenRailwayMap", "mapOpenWeatherKey": "OpenWeather API Key", "mapOpenWeatherClouds": "OpenWeather Clouds", "mapOpenWeatherPrecipitation": "OpenWeather Precipitation", -- cgit v1.2.3 From f421878a61ad86c0490bf8e10863d25fbefea93d Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 11 May 2023 18:47:01 -0700 Subject: Fix typo --- modern/src/map/overlay/useMapOverlays.js | 4 ++-- modern/src/resources/l10n/en.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'modern') diff --git a/modern/src/map/overlay/useMapOverlays.js b/modern/src/map/overlay/useMapOverlays.js index fa5240e8..5114424b 100644 --- a/modern/src/map/overlay/useMapOverlays.js +++ b/modern/src/map/overlay/useMapOverlays.js @@ -29,8 +29,8 @@ export default () => { available: true, }, { - id: 'openRaiwayMap', - title: t('mapOpenRaiwayMap'), + id: 'openRailwayMap', + title: t('mapOpenRailwayMap'), source: sourceCustom(['https://tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png']), available: true, }, diff --git a/modern/src/resources/l10n/en.json b/modern/src/resources/l10n/en.json index 69db954f..a6ac151f 100644 --- a/modern/src/resources/l10n/en.json +++ b/modern/src/resources/l10n/en.json @@ -309,7 +309,7 @@ "mapOverlay": "Map Overlay", "mapOverlayCustom": "Custom Overlay", "mapOpenSeaMap": "OpenSeaMap", - "mapOpenRaiwayMap": "OpenRailwayMap", + "mapOpenRailwayMap": "OpenRailwayMap", "mapOpenWeatherKey": "OpenWeather API Key", "mapOpenWeatherClouds": "OpenWeather Clouds", "mapOpenWeatherPrecipitation": "OpenWeather Precipitation", -- cgit v1.2.3 From 60c663cc1df0543d12443ec3aa76b8e65dff6744 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 14 May 2023 07:14:50 -0700 Subject: Standard heart rate attribute --- modern/src/common/attributes/usePositionAttributes.js | 4 ++++ modern/src/resources/l10n/en.json | 1 + 2 files changed, 5 insertions(+) (limited to 'modern') diff --git a/modern/src/common/attributes/usePositionAttributes.js b/modern/src/common/attributes/usePositionAttributes.js index 90905395..cc50911c 100644 --- a/modern/src/common/attributes/usePositionAttributes.js +++ b/modern/src/common/attributes/usePositionAttributes.js @@ -148,6 +148,10 @@ export default (t) => useMemo(() => ({ name: t('positionSteps'), type: 'number', }, + heartRate: { + name: t('positionHeartRate'), + type: 'number', + }, input: { name: t('positionInput'), type: 'number', diff --git a/modern/src/resources/l10n/en.json b/modern/src/resources/l10n/en.json index a6ac151f..4ad897a5 100644 --- a/modern/src/resources/l10n/en.json +++ b/modern/src/resources/l10n/en.json @@ -267,6 +267,7 @@ "positionHours": "Hours", "positionSteps": "Steps", "positionInput": "Input", + "positionHeartRate": "Heart Rate", "positionOutput": "Output", "positionBatteryLevel": "Battery Level", "positionFuelConsumption": "Fuel Consumption", -- cgit v1.2.3 From 474104189d270df752d8a177685c2ab413683b3a Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 15 May 2023 12:06:14 -0700 Subject: Add HTML branding overrides --- modern/public/index.html | 6 +++--- modern/public/manifest.json | 6 +++--- web/debug.html | 2 +- web/release.html | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'modern') diff --git a/modern/public/index.html b/modern/public/index.html index 9d06d07d..f92dae57 100644 --- a/modern/public/index.html +++ b/modern/public/index.html @@ -4,12 +4,12 @@ - - + + - Traccar + ${title} diff --git a/modern/public/manifest.json b/modern/public/manifest.json index fad9bbe5..9142346c 100644 --- a/modern/public/manifest.json +++ b/modern/public/manifest.json @@ -1,6 +1,6 @@ { - "short_name": "Traccar", - "name": "Traccar GPS Tracking System", + "short_name": "${title}", + "name": "${description}", "icons": [ { "src": "favicon.ico", @@ -22,6 +22,6 @@ ], "start_url": ".", "display": "standalone", - "theme_color": "#1a237e", + "theme_color": "${colorPrimary}", "background_color": "#ffffff" } diff --git a/web/debug.html b/web/debug.html index ef2d2a56..08b6e07d 100644 --- a/web/debug.html +++ b/web/debug.html @@ -3,7 +3,7 @@ -Traccar +${title} diff --git a/web/release.html b/web/release.html index 1c22da60..44561ff3 100644 --- a/web/release.html +++ b/web/release.html @@ -3,7 +3,7 @@ -Traccar +${title} -- cgit v1.2.3 From 4aa5da9a669c58dbe43600e576bcfc0346c121a0 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 15 May 2023 13:36:47 -0700 Subject: Make theme dynamic --- modern/src/App.js | 4 +-- modern/src/AppThemeProvider.js | 17 +++++++++++++ modern/src/common/theme/index.js | 9 +++---- modern/src/common/theme/palette.js | 48 +++++++++++++++++++----------------- modern/src/index.js | 19 +++++++------- modern/src/map/core/preloadImages.js | 2 +- 6 files changed, 59 insertions(+), 40 deletions(-) create mode 100644 modern/src/AppThemeProvider.js (limited to 'modern') diff --git a/modern/src/App.js b/modern/src/App.js index baa2c3f2..89785cfa 100644 --- a/modern/src/App.js +++ b/modern/src/App.js @@ -1,9 +1,8 @@ import React from 'react'; import { Outlet, useNavigate } from 'react-router-dom'; import { useDispatch, useSelector } from 'react-redux'; -import { LinearProgress, useMediaQuery } from '@mui/material'; +import { LinearProgress, useMediaQuery, useTheme } from '@mui/material'; import makeStyles from '@mui/styles/makeStyles'; -import theme from './common/theme'; import BottomMenu from './common/components/BottomMenu'; import SocketController from './SocketController'; import CachingController from './CachingController'; @@ -22,6 +21,7 @@ const useStyles = makeStyles(() => ({ const App = () => { const classes = useStyles(); + const theme = useTheme(); const dispatch = useDispatch(); const navigate = useNavigate(); diff --git a/modern/src/AppThemeProvider.js b/modern/src/AppThemeProvider.js new file mode 100644 index 00000000..0f1c5479 --- /dev/null +++ b/modern/src/AppThemeProvider.js @@ -0,0 +1,17 @@ +import React from 'react'; +import { useSelector } from 'react-redux'; +import { ThemeProvider } from '@mui/material'; +import theme from './common/theme'; + +const AppThemeProvider = ({ children }) => { + const server = useSelector((state) => state.session.server); + const themeInstance = theme(server); + + return ( + + {children} + + ); +}; + +export default AppThemeProvider; diff --git a/modern/src/common/theme/index.js b/modern/src/common/theme/index.js index 0cc999ad..0f163e7e 100644 --- a/modern/src/common/theme/index.js +++ b/modern/src/common/theme/index.js @@ -1,12 +1,11 @@ +import { useMemo } from 'react'; import { createTheme } from '@mui/material/styles'; import palette from './palette'; import dimensions from './dimensions'; import components from './components'; -const theme = createTheme({ - palette, +export default (server) => useMemo(() => createTheme({ + palette: palette(server), dimensions, components, -}); - -export default theme; +}), [server]); diff --git a/modern/src/common/theme/palette.js b/modern/src/common/theme/palette.js index c6cb00d9..dfc8b9dd 100644 --- a/modern/src/common/theme/palette.js +++ b/modern/src/common/theme/palette.js @@ -2,28 +2,30 @@ import { amber, grey, green, indigo, red, common, } from '@mui/material/colors'; -const colors = { - white: common.white, - background: grey[50], - primary: indigo[900], - secondary: green[800], - positive: green[500], - medium: amber[700], - negative: red[500], - neutral: grey[500], - geometry: '#3bb2d0', -}; +export default (server) => { + const colors = { + white: common.white, + background: grey[50], + primary: server?.attributes?.colorPrimary || indigo[900], + secondary: server?.attributes?.colorSecondary || green[800], + positive: green[500], + medium: amber[700], + negative: red[500], + neutral: grey[500], + geometry: '#3bb2d0', + }; -export default { - background: { - default: colors.background, - }, - primary: { - main: colors.primary, - }, - secondary: { - main: colors.secondary, - contrastText: colors.white, - }, - colors, + return { + background: { + default: colors.background, + }, + primary: { + main: colors.primary, + }, + secondary: { + main: colors.secondary, + contrastText: colors.white, + }, + colors, + }; }; diff --git a/modern/src/index.js b/modern/src/index.js index e5457789..936fe7c1 100644 --- a/modern/src/index.js +++ b/modern/src/index.js @@ -3,17 +3,17 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; import { BrowserRouter } from 'react-router-dom'; import { Provider } from 'react-redux'; -import { CssBaseline, ThemeProvider, StyledEngineProvider } from '@mui/material'; +import { CssBaseline, StyledEngineProvider } from '@mui/material'; import store from './store'; import { LocalizationProvider } from './common/components/LocalizationProvider'; import ErrorHandler from './common/components/ErrorHandler'; -import theme from './common/theme'; import Navigation from './Navigation'; import preloadImages from './map/core/preloadImages'; import * as serviceWorkerRegistration from './serviceWorkerRegistration'; import NativeInterface from './common/components/NativeInterface'; import ServerProvider from './ServerProvider'; import ErrorBoundary from './ErrorBoundary'; +import AppThemeProvider from './AppThemeProvider'; preloadImages(); @@ -23,16 +23,17 @@ root.render( - - - + + + + - - - - + + + + diff --git a/modern/src/map/core/preloadImages.js b/modern/src/map/core/preloadImages.js index 770c1c57..0634251b 100644 --- a/modern/src/map/core/preloadImages.js +++ b/modern/src/map/core/preloadImages.js @@ -61,7 +61,7 @@ export default async () => { const results = []; ['primary', 'positive', 'negative', 'neutral'].forEach((color) => { results.push(loadImage(mapIcons[category]).then((icon) => { - mapImages[`${category}-${color}`] = prepareIcon(background, icon, palette.colors[color]); + mapImages[`${category}-${color}`] = prepareIcon(background, icon, palette().colors[color]); })); }); await Promise.all(results); -- cgit v1.2.3 From eb364d8726f6e79cede10b168ea2ae31bbbe696e Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 15 May 2023 14:49:09 -0700 Subject: New server attributes --- modern/src/common/attributes/useServerAttributes.js | 18 ++++++++++++++++++ modern/src/resources/l10n/en.json | 4 ++++ 2 files changed, 22 insertions(+) (limited to 'modern') diff --git a/modern/src/common/attributes/useServerAttributes.js b/modern/src/common/attributes/useServerAttributes.js index ba49e44d..76d5a157 100644 --- a/modern/src/common/attributes/useServerAttributes.js +++ b/modern/src/common/attributes/useServerAttributes.js @@ -1,6 +1,24 @@ import { useMemo } from 'react'; export default (t) => useMemo(() => ({ + title: { + name: t('serverName'), + type: 'string', + }, + description: { + name: t('serverDescription'), + type: 'string', + }, + colorPrimary: { + name: t('serverColorPrimary'), + type: 'string', + subtype: 'color', + }, + colorSecondary: { + name: t('serverColorSecondary'), + type: 'string', + subtype: 'color', + }, 'ui.disableLoginLanguage': { name: t('attributeUiDisableLoginLanguage'), type: 'boolean', diff --git a/modern/src/resources/l10n/en.json b/modern/src/resources/l10n/en.json index 4ad897a5..c20023a0 100644 --- a/modern/src/resources/l10n/en.json +++ b/modern/src/resources/l10n/en.json @@ -305,6 +305,10 @@ "serverReadonly": "Readonly", "serverForceSettings": "Force Settings", "serverAnnouncement": "Announcement", + "serverName": "Server Name", + "serverDescription": "Server Description", + "serverColorPrimary": "Color Primary", + "serverColorSecondary": "Color Secondary", "mapTitle": "Map", "mapActive": "Active Maps", "mapOverlay": "Map Overlay", -- cgit v1.2.3