`
font-weight: 500;
letter-spacing: 1px;
cursor: pointer;
- background-color: ${(props) => (props.variant === 'primary' ? '#003366' : props.variant === 'secondary' ? '#FF0000' : '#000000')};
+ background-color: ${(props) => (props.variant === 'primary' ? '#003366' : props.variant === 'secondary' ? '#DC3545' : '#000000')};
color: #FFFFFF;
&:hover {
transform: scale(0.98);
From fe6adfe18e87d136035ebb0760cd3eb65f7812da Mon Sep 17 00:00:00 2001
From: TylerMaloney <123214152+TylerMaloney@users.noreply.github.com>
Date: Thu, 27 Jul 2023 20:33:03 -0700
Subject: [PATCH 15/19] Update
src/frontend-pwa/src/components/utility/Mapping/Mapping.tsx
Co-authored-by: Matthew Logan <62873746+LocalNewsTV@users.noreply.github.com>
---
src/frontend-pwa/src/components/utility/Mapping/Mapping.tsx | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/frontend-pwa/src/components/utility/Mapping/Mapping.tsx b/src/frontend-pwa/src/components/utility/Mapping/Mapping.tsx
index 8a28fc5..0c2048b 100644
--- a/src/frontend-pwa/src/components/utility/Mapping/Mapping.tsx
+++ b/src/frontend-pwa/src/components/utility/Mapping/Mapping.tsx
@@ -86,10 +86,6 @@ export default function Mapping({ locations, currentLocation }: MappingProps) {
? 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
: '/mapTiles/{z}/{x}/{y}.png';
- // eslint-disable-next-line no-console
- console.log('Are map tiles cached?: ', state.mapsCached);
- // TODO: Add conditional rendering to map in offline mode if maps are cached
-
if (!onlineMode && !state.mapsCached) {
return (
From a7f3f194584569eff192063466abb55f22b240da Mon Sep 17 00:00:00 2001
From: TylerMaloney
Date: Thu, 27 Jul 2023 21:19:44 -0700
Subject: [PATCH 16/19] resolving suggestions
---
.../components/common/Button/button.styles.ts | 2 +-
.../components/utility/Mapping/Mapping.tsx | 14 ++++++-------
.../utility/Mapping/mapping.styles.ts | 7 +++++++
src/frontend-pwa/src/content/content.ts | 12 +++++++++++
.../src/views/Settings/Settings.tsx | 20 ++++++++++++-------
.../src/views/Settings/settings.styles.ts | 11 ++++++++++
6 files changed, 50 insertions(+), 16 deletions(-)
diff --git a/src/frontend-pwa/src/components/common/Button/button.styles.ts b/src/frontend-pwa/src/components/common/Button/button.styles.ts
index 8d894ae..322ac20 100644
--- a/src/frontend-pwa/src/components/common/Button/button.styles.ts
+++ b/src/frontend-pwa/src/components/common/Button/button.styles.ts
@@ -25,7 +25,7 @@ const StyledButton = styled.button`
font-weight: 500;
letter-spacing: 1px;
cursor: pointer;
- background-color: ${(props) => (props.variant === 'primary' ? '#003366' : props.variant === 'secondary' ? '#FF0000' : '#000000')};
+ background-color: ${(props) => (props.variant === 'primary' ? '#003366' : props.variant === 'secondary' ? '#DC3545' : '#000000')};
color: #FFFFFF;
&:hover {
transform: scale(0.98);
diff --git a/src/frontend-pwa/src/components/utility/Mapping/Mapping.tsx b/src/frontend-pwa/src/components/utility/Mapping/Mapping.tsx
index 8a28fc5..d11c6d6 100644
--- a/src/frontend-pwa/src/components/utility/Mapping/Mapping.tsx
+++ b/src/frontend-pwa/src/components/utility/Mapping/Mapping.tsx
@@ -34,6 +34,7 @@ import {
StyledPopup,
StyledMapContainer,
PopupInfo,
+ MapTilesNotFoundDiv,
} from './mapping.styles';
import SingleLocation from '../../../Type/SingleLocation';
import LocationsArray from '../../../Type/LocationsArray';
@@ -86,16 +87,13 @@ export default function Mapping({ locations, currentLocation }: MappingProps) {
? 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
: '/mapTiles/{z}/{x}/{y}.png';
- // eslint-disable-next-line no-console
- console.log('Are map tiles cached?: ', state.mapsCached);
- // TODO: Add conditional rendering to map in offline mode if maps are cached
-
if (!onlineMode && !state.mapsCached) {
return (
-
- The map data was not found and the device appears to be offline.
- The offline map is unable to be rendered.
-
+
+
+ {mappingContent.offlineMapTilesNotFoundMessage[lang]}
+
+
);
}
diff --git a/src/frontend-pwa/src/components/utility/Mapping/mapping.styles.ts b/src/frontend-pwa/src/components/utility/Mapping/mapping.styles.ts
index d3cc6db..333cf08 100644
--- a/src/frontend-pwa/src/components/utility/Mapping/mapping.styles.ts
+++ b/src/frontend-pwa/src/components/utility/Mapping/mapping.styles.ts
@@ -44,3 +44,10 @@ export const StyledPopupDiv = styled.div`
max-height: 10em;
overflow-y: auto;
`;
+
+export const MapTilesNotFoundDiv = styled.div`
+ color: darkred;
+ align-items: center;
+ justify-content: center;
+ padding: 3em;
+`;
diff --git a/src/frontend-pwa/src/content/content.ts b/src/frontend-pwa/src/content/content.ts
index 4be7750..107e84d 100644
--- a/src/frontend-pwa/src/content/content.ts
+++ b/src/frontend-pwa/src/content/content.ts
@@ -84,6 +84,14 @@ export const SettingsContent: ContentMap = {
eng: 'To decrease app size, you can delete the saved tiles. This will prevent offline map functionality.',
fr: 'Pour réduire la taille de l\'application, vous pouvez supprimer les vignettes enregistrées. Cela empêchera la fonctionnalité de carte hors ligne.',
},
+ installMapTilesButtonTextOffline: {
+ eng: 'Offline',
+ fr: 'Hors ligne',
+ },
+ installMapTilesButtonTextOnline: {
+ eng: 'Download',
+ fr: 'Télécharger',
+ },
clearCache: {
eng: 'Delete Data',
fr: 'Suprimmer les données',
@@ -548,6 +556,10 @@ export const mappingContent: ContentMap = {
eng: 'Phone Number: ',
fr: 'Numéro de téléphone: ',
},
+ offlineMapTilesNotFoundMessage: {
+ eng: 'The map data was not found and the device appears to be offline. The offline map is unable to be rendered.',
+ fr: 'Les données cartographiques sont introuvables et l\'appareil semble être hors ligne. La carte hors ligne ne peut pas être rendue.',
+ },
};
export const reportHistoryContent: ContentMap = {
diff --git a/src/frontend-pwa/src/views/Settings/Settings.tsx b/src/frontend-pwa/src/views/Settings/Settings.tsx
index bae99d6..5b80677 100644
--- a/src/frontend-pwa/src/views/Settings/Settings.tsx
+++ b/src/frontend-pwa/src/views/Settings/Settings.tsx
@@ -23,6 +23,8 @@ import {
SettingsContainer,
ContentContainer,
ModalWrapper,
+ ModalPopup,
+ AccordionButtonDiv,
} from './settings.styles';
import useAppService from '../../services/app/useAppService';
import MoreInfoButton from '../../components/common/MoreInfoButton/MoreInfoButton';
@@ -227,15 +229,19 @@ export default function Settings() {
* @summary Clears all mapTile data from browser cache,
* sets the mapsCached state to false,
* and closes the confirmation modal.
+ *
* @author Tyler Maloney, Dallas Richmond
*/
const handleCacheModalConfirm = () => {
if ('serviceWorker' in navigator) {
+ // get all cache keys
caches.keys()
.then((cacheNames) => {
+ // find cache matching workbox precache
const precacheName = cacheNames.filter((cacheName) => cacheName.startsWith('workbox-precache-v2'));
caches.open(precacheName[0])
.then((cache) => {
+ // get the keys for all assets in cache, check assets, if asset includes /mapTiles it is deleted
cache.keys()
.then((keys) => {
keys.forEach((key) => {
@@ -317,7 +323,7 @@ export default function Settings() {
-
+
)}
text={SettingsContent.refreshData[lang]}
@@ -334,7 +340,7 @@ export default function Settings() {
-
+
{state.mapsCached ? (
)}
{isClearCacheModalOpen && (
{SettingsContent.clearCacheConfirmText[lang]}
-
+
-
+
)}
-
+
)}
text={SettingsContent.offlineMapTilesTitle[lang]}
diff --git a/src/frontend-pwa/src/views/Settings/settings.styles.ts b/src/frontend-pwa/src/views/Settings/settings.styles.ts
index fc03771..4141677 100644
--- a/src/frontend-pwa/src/views/Settings/settings.styles.ts
+++ b/src/frontend-pwa/src/views/Settings/settings.styles.ts
@@ -95,3 +95,14 @@ export const ModalWrapper = styled.div`
box-shadow: 0 0.125em 0.25em rgba(0, 0, 0, 0.2);
border: 0.125em solid #003366;
`;
+
+export const ModalPopup = styled.div`
+ display: flex;
+ gap: 10px;
+ margin-top: 20px;
+`;
+
+export const AccordionButtonDiv = styled.div`
+ display: flex;
+ gap: 10px;
+`;
From d744b4211d0e9eaafe79e71145283c62b8cc35d6 Mon Sep 17 00:00:00 2001
From: TylerMaloney
Date: Fri, 28 Jul 2023 09:30:47 -0700
Subject: [PATCH 17/19] vers. no. 1.0.0, confirmation modals
---
src/frontend-pwa/package.json | 2 +-
.../src/components/common/Button/Button.tsx | 2 +-
.../components/common/Button/button.styles.ts | 1 +
.../src/content/changelogContent.ts | 10 ++++
src/frontend-pwa/src/content/content.ts | 4 ++
.../src/services/app/useAppService.ts | 6 +++
.../src/views/Settings/Settings.tsx | 47 +++++++++++++++++--
7 files changed, 66 insertions(+), 6 deletions(-)
diff --git a/src/frontend-pwa/package.json b/src/frontend-pwa/package.json
index dd8a4c8..adaec78 100644
--- a/src/frontend-pwa/package.json
+++ b/src/frontend-pwa/package.json
@@ -1,7 +1,7 @@
{
"name": "testing-vite",
"private": true,
- "version": "0.9.0",
+ "version": "1.0.0",
"type": "module",
"scripts": {
"dev": "vite",
diff --git a/src/frontend-pwa/src/components/common/Button/Button.tsx b/src/frontend-pwa/src/components/common/Button/Button.tsx
index 25bd4f5..c3f419f 100644
--- a/src/frontend-pwa/src/components/common/Button/Button.tsx
+++ b/src/frontend-pwa/src/components/common/Button/Button.tsx
@@ -12,7 +12,7 @@
import StyledButton from './button.styles';
-export type ButtonVariants = 'default' | 'primary' | 'secondary';
+export type ButtonVariants = 'default' | 'primary' | 'secondary' | 'tertiary';
export type ButtonSizes = 'sm' | 'md' | 'lg';
export type ButtonProps = {
diff --git a/src/frontend-pwa/src/components/common/Button/button.styles.ts b/src/frontend-pwa/src/components/common/Button/button.styles.ts
index 322ac20..1e5b27e 100644
--- a/src/frontend-pwa/src/components/common/Button/button.styles.ts
+++ b/src/frontend-pwa/src/components/common/Button/button.styles.ts
@@ -26,6 +26,7 @@ const StyledButton = styled.button`
letter-spacing: 1px;
cursor: pointer;
background-color: ${(props) => (props.variant === 'primary' ? '#003366' : props.variant === 'secondary' ? '#DC3545' : '#000000')};
+ background-color: ${(props) => (props.variant === 'primary' ? '#003366' : props.variant === 'secondary' ? '#DC3545' : props.variant === 'tertiary' ? '#198754' : '#000000')};
color: #FFFFFF;
&:hover {
transform: scale(0.98);
diff --git a/src/frontend-pwa/src/content/changelogContent.ts b/src/frontend-pwa/src/content/changelogContent.ts
index 3c18531..b7fd65b 100644
--- a/src/frontend-pwa/src/content/changelogContent.ts
+++ b/src/frontend-pwa/src/content/changelogContent.ts
@@ -7,6 +7,16 @@ export interface ContentMap {
}
const ChangeLog: ContentMap = {
+ '1.0.0': {
+ eng: [
+ 'Added ability to delete and recache map tiles at will',
+ 'Changed the secondary button color to a softer shade of red',
+ ],
+ fr: [
+ 'Ajout de la possibilité de supprimer et de remettre en cache des tuiles de carte à volonté',
+ 'Modification de la couleur du bouton secondaire en une nuance de rouge plus douce',
+ ],
+ },
'0.9.0': {
eng: [
'Settings view revamped to new modern design',
diff --git a/src/frontend-pwa/src/content/content.ts b/src/frontend-pwa/src/content/content.ts
index 107e84d..a4e0d10 100644
--- a/src/frontend-pwa/src/content/content.ts
+++ b/src/frontend-pwa/src/content/content.ts
@@ -92,6 +92,10 @@ export const SettingsContent: ContentMap = {
eng: 'Download',
fr: 'Télécharger',
},
+ installMapTilesModalWarning: {
+ eng: 'The size of the mapTile package is ~35MB. do you wish to proceed with the download?',
+ fr: 'La taille du package mapTile est d\'environ 35 Mo. Souhaitez-vous poursuivre le téléchargement ?',
+ },
clearCache: {
eng: 'Delete Data',
fr: 'Suprimmer les données',
diff --git a/src/frontend-pwa/src/services/app/useAppService.ts b/src/frontend-pwa/src/services/app/useAppService.ts
index 7f9f61e..2250bc3 100644
--- a/src/frontend-pwa/src/services/app/useAppService.ts
+++ b/src/frontend-pwa/src/services/app/useAppService.ts
@@ -289,6 +289,12 @@ const useAppService = () => {
});
};
+ /**
+ * @summary Sets the state for determining whether the map tiles are present or not
+ * @param cached is a boolean that indicates whether the app has cached map tiles or not
+ * @type {( cached: boolean )}
+ * @author Dallas Richmond
+ */
const setMapsCache = (cached: boolean) => {
saveDataToLocalStorage(constants.MAPS_CACHED_KEY, cached);
dispatch({ type: SET_MAP_CACHED, payload: cached });
diff --git a/src/frontend-pwa/src/views/Settings/Settings.tsx b/src/frontend-pwa/src/views/Settings/Settings.tsx
index 5b80677..715a7d6 100644
--- a/src/frontend-pwa/src/views/Settings/Settings.tsx
+++ b/src/frontend-pwa/src/views/Settings/Settings.tsx
@@ -48,6 +48,7 @@ export default function Settings() {
const [analyticsToggleValue, setAnalyticsToggleValue] = useState(state.settings.analytics_opt_in);
const [lang, setLang] = useState(state.settings.lang || 'eng');
const [isClearCacheModalOpen, setIsClearCacheModalOpen] = useState(false);
+ const [isInstallMapTilesModalOpen, setIsInstallMapTilesModalOpen] = useState(false);
const onlineCheck = state.isOnline && !state.settings.offline_mode;
const geolocationKnown = localStorageKeyExists(constants.CURRENT_LOCATION_KEY);
const latitude = state.currentLocation ? state.currentLocation.lat : 49.2827;
@@ -190,6 +191,14 @@ export default function Settings() {
}
};
+ /**
+ * @summary Opens the map tile confirmation modal.
+ * @author Tyler Maloney
+ */
+ const handleInstallMapTilesConfirm = () => {
+ setIsInstallMapTilesModalOpen(true);
+ };
+
/**
* @summary Pulls in new map tile data if user hits the refresh button.
* Forces the page to unregister the service-worker and reload
@@ -199,7 +208,7 @@ export default function Settings() {
*
* @author Dallas Richmond, Tyler Maloney
*/
- const handleMapTiles = () => {
+ const handleInstallMapTilesModalConfirm = () => {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.getRegistrations().then((registrations) => {
registrations.forEach((registration) => {
@@ -215,6 +224,15 @@ export default function Settings() {
console.error('Error registering service worker:', error);
});
}
+ setIsInstallMapTilesModalOpen(false);
+ };
+
+ /**
+ * @summary Closes the map tile confirmation modal.
+ * @author Tyler Maloney
+ */
+ const handleInstallMapTilesModalCancel = () => {
+ setIsInstallMapTilesModalOpen(false);
};
/**
@@ -261,7 +279,7 @@ export default function Settings() {
* @summary Closes the map tile confirmation modal.
* @author Tyler Maloney
*/
- const handleModalCancel = () => {
+ const handleCacheModalCancel = () => {
setIsClearCacheModalOpen(false);
};
@@ -351,7 +369,7 @@ export default function Settings() {
/>
) : (
+
+