From 3f3a5136eb5f766fc3e7cfd4e06d5753fd317ce0 Mon Sep 17 00:00:00 2001 From: William Bruno Date: Sat, 21 Mar 2026 07:33:12 -0400 Subject: [PATCH] rework Menu Bar / Rework socketioStore --- package-lock.json | 44 ++++ package.json | 2 + quasar.config.ts | 22 +- src/] | 194 ---------------- src/boot/socket.ts | 58 ----- src/boot/socketio.ts | 16 ++ src/components/ExampleComponent.vue | 37 ---- src/components/LRoutingMachine.vue | 84 +++++++ src/components/LeafletTest.vue | 109 +++++---- src/components/MenuBar.vue | 296 +++++++++++++++---------- src/components/SetLocationDialog.vue | 6 + src/components/SimulationCommands.ts | 1 + src/components/SocketTest.vue | 81 +++++-- src/components/StatusBar.vue | 43 +++- src/components/models.ts | 199 ++++++++++++++++- src/constants/controls.ts | 62 ++++++ src/constants/favorites.ts | 79 +++++++ src/functions/routingControl.ts | 89 ++++++++ src/layouts/MainLayout.vue | 31 ++- src/pages/DeviceInfo.vue | 59 +++++ src/router/routes.ts | 5 + src/stores/socketio.ts | 233 +++++++++++++++++++ src/stores/status.ts | 39 ---- src/types/leaflet-routing-machine.d.ts | 15 ++ 24 files changed, 1278 insertions(+), 526 deletions(-) delete mode 100644 src/] delete mode 100644 src/boot/socket.ts create mode 100644 src/boot/socketio.ts delete mode 100644 src/components/ExampleComponent.vue create mode 100644 src/components/LRoutingMachine.vue create mode 100644 src/components/SimulationCommands.ts create mode 100644 src/constants/controls.ts create mode 100644 src/constants/favorites.ts create mode 100644 src/functions/routingControl.ts create mode 100644 src/pages/DeviceInfo.vue create mode 100644 src/stores/socketio.ts delete mode 100644 src/stores/status.ts create mode 100644 src/types/leaflet-routing-machine.d.ts diff --git a/package-lock.json b/package-lock.json index c57cd12..a0078a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,9 @@ "@vue-leaflet/vue-leaflet": "^0.10.1", "axios": "^1.2.1", "leaflet": "^1.9.4", + "leaflet-extra-markers": "^2.0.1", "leaflet-geosearch": "^4.2.2", + "leaflet-routing-machine": "^3.2.12", "pinia": "^3.0.4", "quasar": "^2.16.0", "socket.io-client": "^4.8.3", @@ -1043,6 +1045,23 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@mapbox/corslite": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/@mapbox/corslite/-/corslite-0.0.7.tgz", + "integrity": "sha512-w/uS474VFjmqQ7fFWIMZINQM1BAQxDLuoJaZZIPES1BmeYpCtlh9MtbFxKGGDAsfvut8/HircIsVvEYRjQ+iMg==", + "license": "BSD" + }, + "node_modules/@mapbox/polyline": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@mapbox/polyline/-/polyline-0.2.0.tgz", + "integrity": "sha512-GCddO0iw6AzOQqZgBmjEQI9Pgo40/yRgkTkikGctE01kNBN0ThWYuAnTD+hRWrAWMV6QJ0rNm4m8DAsaAXE7Pg==", + "bin": { + "polyline": "bin/polyline.bin.js" + }, + "engines": { + "node": "*" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -5729,6 +5748,14 @@ "integrity": "sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==", "license": "BSD-2-Clause" }, + "node_modules/leaflet-extra-markers": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/leaflet-extra-markers/-/leaflet-extra-markers-2.0.1.tgz", + "integrity": "sha512-cbCo+YSgnN+tomDJRxv/vf+ZXfLymSKjDDuv7omYaOO+8oj9q9uvwytL+eViyClPuscAT3lNh339R+gr8w20qg==", + "peerDependencies": { + "leaflet": "^1.9.4" + } + }, "node_modules/leaflet-geosearch": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/leaflet-geosearch/-/leaflet-geosearch-4.2.2.tgz", @@ -5739,6 +5766,17 @@ "leaflet": "^1.6.0" } }, + "node_modules/leaflet-routing-machine": { + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/leaflet-routing-machine/-/leaflet-routing-machine-3.2.12.tgz", + "integrity": "sha512-HLde58G1YtD9xSIzZavJ6BPABZaV1hHeGst8ouhzuxmSC3s32NVtADT+njbIUMW1maHRCrsgTk/E4hz5QH7FrA==", + "license": "ISC", + "dependencies": { + "@mapbox/corslite": "0.0.7", + "@mapbox/polyline": "^0.2.0", + "osrm-text-instructions": "^0.13.2" + } + }, "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -6305,6 +6343,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/osrm-text-instructions": { + "version": "0.13.4", + "resolved": "https://registry.npmjs.org/osrm-text-instructions/-/osrm-text-instructions-0.13.4.tgz", + "integrity": "sha512-ge4ZTIetMQKAHKq2MwWf83ntzdJN20ndRKRaVNoZ3SkDkBNO99Qddz7r6+hrVx38I+ih6Rk5T1yslczAB6Q9Pg==", + "license": "BSD-2-Clause" + }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", diff --git a/package.json b/package.json index 3ff2172..814627e 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,9 @@ "@vue-leaflet/vue-leaflet": "^0.10.1", "axios": "^1.2.1", "leaflet": "^1.9.4", + "leaflet-extra-markers": "^2.0.1", "leaflet-geosearch": "^4.2.2", + "leaflet-routing-machine": "^3.2.12", "pinia": "^3.0.4", "quasar": "^2.16.0", "socket.io-client": "^4.8.3", diff --git a/quasar.config.ts b/quasar.config.ts index 0da3e7a..20a0172 100644 --- a/quasar.config.ts +++ b/quasar.config.ts @@ -2,6 +2,7 @@ // https://v2.quasar.dev/quasar-cli-vite/quasar-config-file import { defineConfig } from '#q-app/wrappers'; +import { fileURLToPath } from 'node:url'; export default defineConfig((/* ctx */) => { return { @@ -11,7 +12,7 @@ export default defineConfig((/* ctx */) => { // app boot file (/src/boot) // --> boot files are part of "main.js" // https://v2.quasar.dev/quasar-cli-vite/boot-files - boot: ['axios', 'socket'], + boot: ['axios', 'socketio'], // https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#css css: ['app.scss'], @@ -32,6 +33,11 @@ export default defineConfig((/* ctx */) => { // Full list of options: https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#build build: { + alias: { + constants: fileURLToPath(new URL('./src/constants', import.meta.url)), + functions: fileURLToPath(new URL('./src/functions', import.meta.url)), + types: fileURLToPath(new URL('./src/types', import.meta.url)), + }, target: { browser: ['es2022', 'firefox115', 'chrome115', 'safari14'], node: 'node20', @@ -43,7 +49,7 @@ export default defineConfig((/* ctx */) => { // extendTsConfig (tsConfig) {} }, - vueRouterMode: 'hash', // available values: 'hash', 'history' + vueRouterMode: 'history', // available values: 'hash', 'history' // vueRouterBase, // vueDevtools, // vueOptionsAPI: false, @@ -65,7 +71,13 @@ export default defineConfig((/* ctx */) => { extendViteConf() { return { server: { - allowedHosts: ['localhost'], + hmr: { +// overlay: false, + }, + allowedHosts: [ + 'localhost', + 'strixx.famor.org' + ], }, }; }, @@ -79,6 +91,7 @@ export default defineConfig((/* ctx */) => { lintCommand: 'eslint -c ./eslint.config.js "./src*/**/*.{ts,js,mjs,cjs,vue}"', useFlatConfig: true, }, + overlay: false, }, { server: false }, ], @@ -95,6 +108,7 @@ export default defineConfig((/* ctx */) => { '/api': { target: 'http://localhost:8000', changeOrigin: true, + rewrite: (path) => path.replace(/^\/api/, ''), }, '/socket.io': { target: 'http://localhost:8000', // Your backend WebSocket server @@ -112,7 +126,7 @@ export default defineConfig((/* ctx */) => { config: { dark: true, }, - iconSet: 'material-icons', // Quasar icon set + iconSet: 'material-icons', // Quasar icon set // lang: 'en-US', // Quasar language pack // For special cases outside of where the auto-import strategy can have an impact diff --git a/src/] b/src/] deleted file mode 100644 index 5cd3fee..0000000 --- a/src/] +++ /dev/null @@ -1,194 +0,0 @@ - - - - - diff --git a/src/boot/socket.ts b/src/boot/socket.ts deleted file mode 100644 index b848e8d..0000000 --- a/src/boot/socket.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { defineBoot } from '#q-app/wrappers'; -import type { Socket } from 'socket.io-client'; -import { io } from 'socket.io-client'; -import type { StatusUpdate } from 'src/types'; - -interface SimulationStatus { - status: boolean; - data: { - latitude: number; - longitude: number; - start: string; - end?: string; - next_move?: number; - }; -} - -interface SimulationRequest { - latitude: number; - longitude: number; - delay?: number; - start?: string; - end?: string; -} - -interface ServerToClientEvents { - noArg: () => void; - withAck: (d: string, callback: (e: number) => void) => void; - status_update: (d: StatusUpdate) => void; - simulation: (d: SimulationStatus) => void; -} - -interface ClientToServerEvents { - message: (data: string) => void; - connect: () => void; - disconnect: () => void; - set_location: (data: SimulationRequest, callback: (response: SimulationStatus) => void) => void; - request_update: (callback: (response: { statusUpdate: StatusUpdate }) => void) => void; - command: ( - command: string, - callback: (response: { status: boolean; message?: string }) => void, - ) => void; - shutdown: ( - delay: number, - callback: (response: { success: boolean; message?: string }) => void, - ) => void; - // ... other events -} - -const socket: Socket = io('/', { - autoConnect: true, - transports: ['websocket'], -}); - -export default defineBoot(({ app }) => { - app.config.globalProperties.$socket = socket; -}); - -export { socket }; diff --git a/src/boot/socketio.ts b/src/boot/socketio.ts new file mode 100644 index 0000000..2aa8ab7 --- /dev/null +++ b/src/boot/socketio.ts @@ -0,0 +1,16 @@ +import { defineBoot } from '#q-app/wrappers'; +import type { Socket } from 'socket.io-client'; +import { io } from 'socket.io-client'; +import type { ServerToClientEvents, ClientToServerEvents } from 'components/models'; + + +const socket: Socket = io('/', { + autoConnect: true, + transports: ['websocket', 'webtransport', 'polling'], +}); + +export default defineBoot(({ app }) => { + app.config.globalProperties.$socket = socket; +}); + +export { socket }; diff --git a/src/components/ExampleComponent.vue b/src/components/ExampleComponent.vue deleted file mode 100644 index 46646b5..0000000 --- a/src/components/ExampleComponent.vue +++ /dev/null @@ -1,37 +0,0 @@ - - - diff --git a/src/components/LRoutingMachine.vue b/src/components/LRoutingMachine.vue new file mode 100644 index 0000000..2d97fe9 --- /dev/null +++ b/src/components/LRoutingMachine.vue @@ -0,0 +1,84 @@ + diff --git a/src/components/LeafletTest.vue b/src/components/LeafletTest.vue index 7801c5c..6db9ed0 100644 --- a/src/components/LeafletTest.vue +++ b/src/components/LeafletTest.vue @@ -1,6 +1,6 @@ @@ -119,49 +94,148 @@ function handleControlClick(ctrl: Control) {