🐛 Fixes the relative paths

This commit is contained in:
Rune Harlyk
2025-08-01 21:36:06 +02:00
parent d899701195
commit 281fa32c89
2 changed files with 76 additions and 70 deletions
+71 -66
View File
@@ -1,9 +1,10 @@
<script lang="ts"> <script lang="ts">
import { page } from '$app/state'; import { page } from '$app/state'
import { useFeatureFlags } from '$lib/stores/featureFlags'; import { base } from '$app/paths'
import GithubButton from '../menu/GithubButton.svelte'; import { useFeatureFlags } from '$lib/stores/featureFlags'
import LogoButton from '../menu/LogoButton.svelte'; import GithubButton from '../menu/GithubButton.svelte'
import MenuList from '../menu/MenuList.svelte'; import LogoButton from '../menu/LogoButton.svelte'
import MenuList from '../menu/MenuList.svelte'
import { import {
Connection, Connection,
Settings, Settings,
@@ -20,42 +21,46 @@
AP, AP,
Copyright, Copyright,
Metrics, Metrics,
DNS, DNS
} from '$lib/components/icons'; } from '$lib/components/icons'
import { PUBLIC_VITE_USE_HOST_NAME } from '$env/static/public'; import { PUBLIC_VITE_USE_HOST_NAME } from '$env/static/public'
const features = useFeatureFlags(); const features = useFeatureFlags()
const appName = page.data.app_name; const appName = page.data.app_name
const copyright = page.data.copyright; const copyright = page.data.copyright
const github = { href: 'https://github.com/' + page.data.github, active: true }; const github = { href: 'https://github.com/' + page.data.github, active: true }
type menuItem = { type menuItem = {
title: string; title: string
icon: ConstructorOfATypedSvelteComponent; icon: ConstructorOfATypedSvelteComponent
href?: string; href?: string
feature: boolean; feature: boolean
active?: boolean; active?: boolean
submenu?: menuItem[]; submenu?: menuItem[]
}; }
let menuItems = $state<menuItem[]>([]); function withBase(path: string) {
return `${base}${path.startsWith('/') ? path : '/' + path}`
}
let menuItems = $state<menuItem[]>([])
$effect(() => { $effect(() => {
menuItems = [ menuItems = [
{ {
title: 'Connection', title: 'Connection',
icon: WiFi, icon: WiFi,
href: '/connection', href: withBase('/connection'),
feature: !PUBLIC_VITE_USE_HOST_NAME, feature: !PUBLIC_VITE_USE_HOST_NAME
}, },
{ {
title: 'Controller', title: 'Controller',
icon: MdiController, icon: MdiController,
href: '/controller', href: withBase('/controller'),
feature: true, feature: true
}, },
{ {
title: 'Peripherals', title: 'Peripherals',
@@ -65,28 +70,28 @@
{ {
title: 'I2C', title: 'I2C',
icon: Connection, icon: Connection,
href: '/peripherals/i2c', href: withBase('/peripherals/i2c'),
feature: true, feature: true
}, },
{ {
title: 'Camera', title: 'Camera',
icon: Camera, icon: Camera,
href: '/peripherals/camera', href: withBase('/peripherals/camera'),
feature: $features.camera, feature: $features.camera
}, },
{ {
title: 'Servo', title: 'Servo',
icon: MotorOutline, icon: MotorOutline,
href: '/peripherals/servo', href: withBase('/peripherals/servo'),
feature: true, feature: true
}, },
{ {
title: 'IMU', title: 'IMU',
icon: Rotate3d, icon: Rotate3d,
href: '/peripherals/imu', href: withBase('/peripherals/imu'),
feature: $features.imu || $features.mag || $features.bmp, feature: $features.imu || $features.mag || $features.bmp
}, }
], ]
}, },
{ {
title: 'WiFi', title: 'WiFi',
@@ -96,22 +101,22 @@
{ {
title: 'WiFi Station', title: 'WiFi Station',
icon: Router, icon: Router,
href: '/wifi/sta', href: withBase('/wifi/sta'),
feature: true, feature: true
}, },
{ {
title: 'Access Point', title: 'Access Point',
icon: AP, icon: AP,
href: '/wifi/ap', href: withBase('/wifi/ap'),
feature: true, feature: true
}, },
{ {
title: 'mDNS', title: 'mDNS',
icon: DNS, icon: DNS,
href: '/wifi/mdns', href: withBase('/wifi/mdns'),
feature: true, feature: true
}, }
], ]
}, },
{ {
title: 'System', title: 'System',
@@ -121,52 +126,52 @@
{ {
title: 'System Status', title: 'System Status',
icon: Health, icon: Health,
href: '/system/status', href: withBase('/system/status'),
feature: true, feature: true
}, },
{ {
title: 'File System', title: 'File System',
icon: Folder, icon: Folder,
href: '/system/filesystem', href: withBase('/system/filesystem'),
feature: true, feature: true
}, },
{ {
title: 'System Metrics', title: 'System Metrics',
icon: Metrics, icon: Metrics,
href: '/system/metrics', href: withBase('/system/metrics'),
feature: true, feature: true
}, },
{ {
title: 'Firmware Update', title: 'Firmware Update',
icon: Update, icon: Update,
href: '/system/update', href: withBase('/system/update'),
feature: $features.ota || $features.upload_firmware || $features.download_firmware, feature: $features.ota || $features.upload_firmware || $features.download_firmware
}, }
], ]
}, }
] as menuItem[]; ] as menuItem[]
}); })
const { menuClicked } = $props(); const { menuClicked } = $props()
function setActiveMenuItem(targetTitle: string) { function setActiveMenuItem(targetTitle: string) {
menuItems.forEach(item => { menuItems.forEach(item => {
item.active = item.title === targetTitle; item.active = item.title === targetTitle
item.submenu?.forEach(subItem => { item.submenu?.forEach(subItem => {
subItem.active = subItem.title === targetTitle; subItem.active = subItem.title === targetTitle
}); })
}); })
menuItems = menuItems; menuItems = menuItems
menuClicked(); menuClicked()
} }
$effect(() => { $effect(() => {
setActiveMenuItem(page.data.title); setActiveMenuItem(page.data.title)
}); })
const updateMenu = (event: any) => { const updateMenu = (event: any) => {
setActiveMenuItem(event.details); setActiveMenuItem(event.details)
}; }
</script> </script>
<div class="flex h-full w-80 flex-col p-4 bg-base-200 text-base-content"> <div class="flex h-full w-80 flex-col p-4 bg-base-200 text-base-content">
+5 -4
View File
@@ -3,6 +3,7 @@ import { notifications } from '$lib/components/toasts/notifications'
import Kinematic from '$lib/kinematic' import Kinematic from '$lib/kinematic'
import { persistentStore } from '$lib/utilities' import { persistentStore } from '$lib/utilities'
import { derived, type Writable } from 'svelte/store' import { derived, type Writable } from 'svelte/store'
import { base } from '$app/paths'
let featureFlagsStore: Writable<Record<string, boolean | string>> let featureFlagsStore: Writable<Record<string, boolean | string>>
@@ -23,8 +24,8 @@ export function useFeatureFlags() {
export const variants = { export const variants = {
SPOTMICRO_ESP32: { SPOTMICRO_ESP32: {
model: '/spot_micro.urdf.xacro', model: `${base}/spot_micro.urdf.xacro`,
stl: '/stl.zip', stl: `${base}/stl.zip`,
kinematics: { kinematics: {
l1: 60.5 / 100, l1: 60.5 / 100,
l2: 10 / 100, l2: 10 / 100,
@@ -35,8 +36,8 @@ export const variants = {
} }
}, },
SPOTMICRO_YERTLE: { SPOTMICRO_YERTLE: {
model: '/yertle.URDF', model: `${base}/yertle.URDF`,
stl: '/URDF.zip', stl: `${base}/URDF.zip`,
kinematics: { kinematics: {
l1: 35 / 100, l1: 35 / 100,
l2: 0 / 100, l2: 0 / 100,