This commit is contained in:
2025-08-17 22:13:40 +02:00
parent 6fa1beac99
commit 66f1603eeb
6 changed files with 41 additions and 42 deletions

View File

@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { formatBytes } from "$lib/utils/conversion"; import { formatBytes } from '$lib/utils/conversion';
import type { Node } from "$lib/interfaces/proxmox"; import type { Node } from '$lib/interfaces/proxmox';
export let nodes: Node[]; export let nodes: Node[];
@@ -19,8 +19,6 @@
.map((n) => n.lxcs.filter((l) => l?.template !== 1 && l.status === 'running')) .map((n) => n.lxcs.filter((l) => l?.template !== 1 && l.status === 'running'))
.flat(2).length .flat(2).length
}; };
</script> </script>
<div class="main-container"> <div class="main-container">

View File

@@ -4,13 +4,13 @@
import { allRoutes } from '$lib/remote/filesystem.remote.ts'; import { allRoutes } from '$lib/remote/filesystem.remote.ts';
let mobileNavOpen = $state(false); let mobileNavOpen = $state(false);
let pages = $state([]) let pages = $state([]);
async function resolvePages() { async function resolvePages() {
pages = await allRoutes() pages = await allRoutes();
} }
resolvePages() resolvePages();
const activePage = derived(page, ($page) => $page.url.pathname); const activePage = derived(page, ($page) => $page.url.pathname);
const toggle = () => { const toggle = () => {

View File

@@ -3,7 +3,6 @@ import { prerender } from '$app/server';
export const allRoutes = prerender(() => { export const allRoutes = prerender(() => {
const modules = import.meta.glob('/src/routes/**/+page.svelte'); const modules = import.meta.glob('/src/routes/**/+page.svelte');
const routes = Object.keys(modules).map((path) => { const routes = Object.keys(modules).map((path) => {
console.log(path);
// Remove '/src/routes' prefix and '+page.svelte' suffix // Remove '/src/routes' prefix and '+page.svelte' suffix
let route = path.replace('/src/routes', '').replace('/+page.svelte', ''); let route = path.replace('/src/routes', '').replace('/+page.svelte', '');
// Handle the root route // Handle the root route
@@ -19,5 +18,5 @@ export const allRoutes = prerender(() => {
}; };
}); });
return [{name: 'Home', path: '/'}, ...allRoute].filter(r => r.name); return [{ name: 'Home', path: '/' }, ...allRoute].filter((r) => r.name);
}); });

View File

@@ -4,7 +4,10 @@ export function hexToRgba(hex: string, alpha = 1) {
// Handle shorthand (#fff → #ffffff) // Handle shorthand (#fff → #ffffff)
if (hex.length === 3) { if (hex.length === 3) {
hex = hex.split('').map(c => c + c).join(''); hex = hex
.split('')
.map((c) => c + c)
.join('');
} }
if (hex.length !== 6) { if (hex.length !== 6) {

View File

@@ -8556,7 +8556,6 @@ const hassData = [
} }
]; ];
function getNeighbors(data) { function getNeighbors(data) {
return ( return (
data.routes data.routes
@@ -8582,10 +8581,10 @@ function getNeighbors(data) {
} }
function getCoordinatorNeighbors(coordinatorId) { function getCoordinatorNeighbors(coordinatorId) {
return hassData.filter(d => { return hassData.filter((d) => {
const exists = d.neighbors.findIndex(n => n.ieee === coordinatorId) const exists = d.neighbors.findIndex((n) => n.ieee === coordinatorId);
return exists; return exists;
}) });
} }
let firstNode = [ let firstNode = [
@@ -8604,7 +8603,7 @@ let firstNode = [
const moreNodes = hassData const moreNodes = hassData
.filter((d) => d?.user_given_name && d.user_given_name !== '') .filter((d) => d?.user_given_name && d.user_given_name !== '')
.map((d) => { .map((d) => {
const group = d.device_type === 'EndDevice' ? 2 : 1 const group = d.device_type === 'EndDevice' ? 2 : 1;
return { return {
name: d.user_given_name, name: d.user_given_name,
@@ -8631,11 +8630,11 @@ const link = firstNode
return ( return (
d?.neighbors?.map((n) => { d?.neighbors?.map((n) => {
const matching = nodes.findIndex((node) => node.ieee === n.ieee); const matching = nodes.findIndex((node) => node.ieee === n.ieee);
if (matching === -1) return if (matching === -1) return;
return { return {
source, source,
target: matching, target: matching
}; };
}) || [] }) || []
); );
@@ -8647,10 +8646,10 @@ const moreLinks = nodes
.map((d, source) => { .map((d, source) => {
return ( return (
d?.neighbors?.map((n) => { d?.neighbors?.map((n) => {
if (n.ieee === '00:21:2e:ff:ff:09:44:73') return if (n.ieee === '00:21:2e:ff:ff:09:44:73') return;
const matching = nodes.findIndex((node) => node.ieee === n.ieee); const matching = nodes.findIndex((node) => node.ieee === n.ieee);
if (matching === -1) return if (matching === -1) return;
return { return {
target: matching, target: matching,
@@ -8662,6 +8661,6 @@ const moreLinks = nodes
.flat() .flat()
.filter((el) => el !== undefined); .filter((el) => el !== undefined);
const links = link.concat(moreLinks) const links = link.concat(moreLinks);
export const data = { nodes, links }; export const data = { nodes, links };

View File

@@ -50,7 +50,7 @@
case 3: case 3:
return '#DB4537'; return '#DB4537';
default: default:
return 'blue' return 'blue';
} }
} }