Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace manager frontend PWA with mapper frontend PWA #2247

Merged
merged 5 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"tailwindcss": "^3.4.3",
"typescript": "^5.4.5",
"vite": "^5.2.12",
"vite-plugin-pwa": "^0.20.0",
"vitest": "^1.6.0",
"workbox-window": "^7.1.0"
},
Expand Down
2,733 changes: 180 additions & 2,553 deletions src/frontend/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions src/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import '@hotosm/ui/dist/components';
import environment from '@/environment';
import AppRoutes from '@/routes';
import { store, persistor } from '@/store/Store';
import OfflineReadyPrompt from '@/components/OfflineReadyPrompt';

const RefreshUserCookies = () => {
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -54,7 +53,6 @@ const App = () => {
<PersistGate loading={null} persistor={persistor}>
<RouterProvider router={AppRoutes} />
<RefreshUserCookies />
<OfflineReadyPrompt />
<hot-tracking site-id={environment.matomoTrackingId} domain={'fmtm.hotosm.org'}></hot-tracking>
</PersistGate>
</Provider>
Expand Down
52 changes: 0 additions & 52 deletions src/frontend/src/components/OfflineReadyPrompt.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions src/frontend/src/components/createnewproject/SelectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ const SelectForm = ({ flag, _geojsonFile, xlsFormFile, setXlsFormFile }) => {
const { files } = event.target;
// Set the selected file as the xlsFormFile state
setXlsFormFile(files[0]);
console.log(files[0]);
console.log(xlsFormFile);
handleCustomChange('xlsFormFileUpload', files[0]);
};
const resetFile = (): void => {
Expand Down
32 changes: 0 additions & 32 deletions src/frontend/src/styles/OfflineReadyPrompt.css

This file was deleted.

3 changes: 1 addition & 2 deletions src/frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
"noImplicitReturns": true,
"strictPropertyInitialization": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"types": ["vite-plugin-pwa/react"]
"noUnusedParameters": true
},
"include": ["src", "src/**/*.ts", "tests"],
"exclude": ["node_modules", "dist"]
Expand Down
41 changes: 1 addition & 40 deletions src/frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,11 @@ import path from 'path';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { configDefaults } from 'vitest/config';
import { VitePWA } from 'vite-plugin-pwa';
import type { VitePWAOptions } from 'vite-plugin-pwa';

const pwaOptions: Partial<VitePWAOptions> = {
// this is temporary to remove the existing service worker
// prior to complete PWA removal
selfDestroying: true,
manifest: {
name: 'Field Mapping Tasking Manager',
short_name: 'FMTM',
description: 'Coordinated field mapping for Open Mapping campaigns.',
display: 'standalone',
theme_color: '#d63f3f',
background_color: '#d63f3f',
icons: [
{
src: 'pwa-64x64.png',
sizes: '64x64',
type: 'image/png',
},
{
src: 'pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: 'pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
},
{
src: 'maskable-icon-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable',
},
],
},
};

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
return {
plugins: [react(), VitePWA(pwaOptions)],
plugins: [react()],
server: {
port: 7051,
host: '0.0.0.0',
Expand Down
2 changes: 1 addition & 1 deletion src/mapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@typescript-eslint/eslint-plugin": "^8.16.0",
"@typescript-eslint/parser": "^8.16.0",
"@unocss/extractor-svelte": "^0.65.0-beta.2",
"@vite-pwa/sveltekit": "^0.6.7",
"eslint": "^9.16.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.46.1",
Expand All @@ -40,7 +41,6 @@
"typescript": "^5.7.2",
"unocss": "^0.65.0-beta.2",
"vite": "^6.0.1",
"vite-plugin-pwa": "^0.21.1",
"vitest": "^2.1.6"
},
"dependencies": {
Expand Down
24 changes: 21 additions & 3 deletions src/mapper/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/mapper/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<script lang="ts">
import '@hotosm/ui/dist/style.css';
import '@hotosm/ui/dist/hotosm-ui';
import { pwaInfo } from 'virtual:pwa-info';
import Toast from '$lib/components/toast.svelte';
import Header from '$lib/components/header.svelte';

let { data, children } = $props();
const webManifestLink = $derived(pwaInfo ? pwaInfo.webManifest.linkTag : '');
</script>

<svelte:head>
{@html webManifestLink}
</svelte:head>
<main class="flex flex-col h-screen overflow-hidden">
<Header />
<Toast />
Expand Down
7 changes: 5 additions & 2 deletions src/mapper/src/routes/[projectId]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ export const load: PageLoad = async ({ parent, params, fetch }) => {
if (projectResponse.status === 401) {
// TODO redirect to different error page to handle login
throw error(401, { message: `You must log in first` });
}
if (projectResponse.status === 404) {
} else if (projectResponse.status === 404) {
throw error(404, { message: `Project with ID (${projectId}) not found` });
} else if (projectResponse.status === 400) {
throw error(400, { message: `Invalid project ID (${projectId}). It must be numeric` });
} else if (projectResponse.status >= 300) {
throw error(400, { message: `Unknown error for project (${projectId})` });
}

return {
Expand Down
2 changes: 1 addition & 1 deletion src/mapper/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler",
"types": ["vite-plugin-pwa/client"],
"types": ["vite-plugin-pwa/client", "vite-plugin-pwa/info"],
"paths": {
"$lib/*": ["./src/lib/*"],
"$components/*": ["./src/components/*"],
Expand Down
48 changes: 41 additions & 7 deletions src/mapper/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,61 @@
import path from 'path';
import { defineConfig } from 'vitest/config';
import { VitePWA } from 'vite-plugin-pwa';
import type { VitePWAOptions } from 'vite-plugin-pwa';
import { SvelteKitPWA } from '@vite-pwa/sveltekit';
import { sveltekit } from '@sveltejs/kit/vite';
import { paraglide } from '@inlang/paraglide-vite';
import UnoCSS from 'unocss/vite';
import extractorSvelte from '@unocss/extractor-svelte';

const pwaOptions: Partial<VitePWAOptions> = {
registerType: 'autoUpdate',
devOptions: {
enabled: true,
},
manifest: {
name: 'FieldTM',
short_name: 'FieldTM',
description: 'Coordinated field mapping for Open Mapping campaigns.',
display: 'standalone',
theme_color: '#d63f3f',
background_color: '#d63f3f',
icons: [
{
src: 'pwa-64x64.png',
sizes: '64x64',
type: 'image/png',
},
{
src: 'pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: 'pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
},
{
src: 'maskable-icon-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable',
},
],
},
};

export default defineConfig({
plugins: [
sveltekit(),
SvelteKitPWA(pwaOptions),
paraglide({
project: './project.inlang',
outdir: './src/translations',
}),
UnoCSS({
extractors: [extractorSvelte()],
}),
VitePWA({
registerType: 'autoUpdate',
devOptions: {
enabled: true,
},
}),
],
server: {
host: true,
Expand Down