mirror of
https://github.com/KevinMidboe/infra-map.git
synced 2025-10-29 17:40:28 +00:00
linting
This commit is contained in:
@@ -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">
|
||||||
|
|||||||
@@ -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 = () => {
|
||||||
|
|||||||
@@ -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);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,19 +1,22 @@
|
|||||||
export function hexToRgba(hex: string, alpha = 1) {
|
export function hexToRgba(hex: string, alpha = 1) {
|
||||||
// Remove leading # if present
|
// Remove leading # if present
|
||||||
hex = hex.replace(/^#/, '');
|
hex = hex.replace(/^#/, '');
|
||||||
|
|
||||||
// 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) {
|
||||||
throw new Error('Invalid HEX color.');
|
throw new Error('Invalid HEX color.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const r = parseInt(hex.substring(0, 2), 16);
|
const r = parseInt(hex.substring(0, 2), 16);
|
||||||
const g = parseInt(hex.substring(2, 4), 16);
|
const g = parseInt(hex.substring(2, 4), 16);
|
||||||
const b = parseInt(hex.substring(4, 6), 16);
|
const b = parseInt(hex.substring(4, 6), 16);
|
||||||
|
|
||||||
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8556,7 +8556,6 @@ const hassData = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
function getNeighbors(data) {
|
function getNeighbors(data) {
|
||||||
return (
|
return (
|
||||||
data.routes
|
data.routes
|
||||||
@@ -8582,21 +8581,21 @@ 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 = [
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
name: 'HUB',
|
name: 'HUB',
|
||||||
ieee: hassData[0].ieee,
|
ieee: hassData[0].ieee,
|
||||||
device: hassData[0].name,
|
device: hassData[0].name,
|
||||||
area: hassData[0].area_id,
|
area: hassData[0].area_id,
|
||||||
type: hassData[0].device_type,
|
type: hassData[0].device_type,
|
||||||
neighbors: getCoordinatorNeighbors('00:21:2e:ff:ff:09:44:73'),
|
neighbors: getCoordinatorNeighbors('00:21:2e:ff:ff:09:44:73'),
|
||||||
group: 0
|
group: 0
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@@ -8604,14 +8603,14 @@ 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,
|
||||||
ieee: d.ieee,
|
ieee: d.ieee,
|
||||||
device: d.name,
|
device: d.name,
|
||||||
area: d.area_id,
|
area: d.area_id,
|
||||||
type: d.device_type,
|
type: d.device_type,
|
||||||
neighbors: getNeighbors(d),
|
neighbors: getNeighbors(d),
|
||||||
group
|
group
|
||||||
};
|
};
|
||||||
@@ -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 };
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
case 3:
|
case 3:
|
||||||
return '#DB4537';
|
return '#DB4537';
|
||||||
default:
|
default:
|
||||||
return 'blue'
|
return 'blue';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user