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">
|
||||
import { formatBytes } from "$lib/utils/conversion";
|
||||
import type { Node } from "$lib/interfaces/proxmox";
|
||||
import { formatBytes } from '$lib/utils/conversion';
|
||||
import type { Node } from '$lib/interfaces/proxmox';
|
||||
|
||||
export let nodes: Node[];
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
.map((n) => n.lxcs.filter((l) => l?.template !== 1 && l.status === 'running'))
|
||||
.flat(2).length
|
||||
};
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<div class="main-container">
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
import { allRoutes } from '$lib/remote/filesystem.remote.ts';
|
||||
|
||||
let mobileNavOpen = $state(false);
|
||||
let pages = $state([])
|
||||
let pages = $state([]);
|
||||
|
||||
async function resolvePages() {
|
||||
pages = await allRoutes()
|
||||
pages = await allRoutes();
|
||||
}
|
||||
|
||||
resolvePages()
|
||||
resolvePages();
|
||||
|
||||
const activePage = derived(page, ($page) => $page.url.pathname);
|
||||
const toggle = () => {
|
||||
|
||||
@@ -3,7 +3,6 @@ import { prerender } from '$app/server';
|
||||
export const allRoutes = prerender(() => {
|
||||
const modules = import.meta.glob('/src/routes/**/+page.svelte');
|
||||
const routes = Object.keys(modules).map((path) => {
|
||||
console.log(path);
|
||||
// Remove '/src/routes' prefix and '+page.svelte' suffix
|
||||
let route = path.replace('/src/routes', '').replace('/+page.svelte', '');
|
||||
// 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) {
|
||||
// Remove leading # if present
|
||||
hex = hex.replace(/^#/, '');
|
||||
// Remove leading # if present
|
||||
hex = hex.replace(/^#/, '');
|
||||
|
||||
// Handle shorthand (#fff → #ffffff)
|
||||
if (hex.length === 3) {
|
||||
hex = hex.split('').map(c => c + c).join('');
|
||||
}
|
||||
// Handle shorthand (#fff → #ffffff)
|
||||
if (hex.length === 3) {
|
||||
hex = hex
|
||||
.split('')
|
||||
.map((c) => c + c)
|
||||
.join('');
|
||||
}
|
||||
|
||||
if (hex.length !== 6) {
|
||||
throw new Error('Invalid HEX color.');
|
||||
}
|
||||
if (hex.length !== 6) {
|
||||
throw new Error('Invalid HEX color.');
|
||||
}
|
||||
|
||||
const r = parseInt(hex.substring(0, 2), 16);
|
||||
const g = parseInt(hex.substring(2, 4), 16);
|
||||
const b = parseInt(hex.substring(4, 6), 16);
|
||||
const r = parseInt(hex.substring(0, 2), 16);
|
||||
const g = parseInt(hex.substring(2, 4), 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) {
|
||||
return (
|
||||
data.routes
|
||||
@@ -8582,21 +8581,21 @@ function getNeighbors(data) {
|
||||
}
|
||||
|
||||
function getCoordinatorNeighbors(coordinatorId) {
|
||||
return hassData.filter(d => {
|
||||
const exists = d.neighbors.findIndex(n => n.ieee === coordinatorId)
|
||||
return exists;
|
||||
})
|
||||
return hassData.filter((d) => {
|
||||
const exists = d.neighbors.findIndex((n) => n.ieee === coordinatorId);
|
||||
return exists;
|
||||
});
|
||||
}
|
||||
|
||||
let firstNode = [
|
||||
{
|
||||
id: 0,
|
||||
name: 'HUB',
|
||||
ieee: hassData[0].ieee,
|
||||
device: hassData[0].name,
|
||||
area: hassData[0].area_id,
|
||||
type: hassData[0].device_type,
|
||||
neighbors: getCoordinatorNeighbors('00:21:2e:ff:ff:09:44:73'),
|
||||
ieee: hassData[0].ieee,
|
||||
device: hassData[0].name,
|
||||
area: hassData[0].area_id,
|
||||
type: hassData[0].device_type,
|
||||
neighbors: getCoordinatorNeighbors('00:21:2e:ff:ff:09:44:73'),
|
||||
group: 0
|
||||
}
|
||||
];
|
||||
@@ -8604,14 +8603,14 @@ let firstNode = [
|
||||
const moreNodes = hassData
|
||||
.filter((d) => d?.user_given_name && d.user_given_name !== '')
|
||||
.map((d) => {
|
||||
const group = d.device_type === 'EndDevice' ? 2 : 1
|
||||
const group = d.device_type === 'EndDevice' ? 2 : 1;
|
||||
|
||||
return {
|
||||
name: d.user_given_name,
|
||||
ieee: d.ieee,
|
||||
device: d.name,
|
||||
area: d.area_id,
|
||||
type: d.device_type,
|
||||
device: d.name,
|
||||
area: d.area_id,
|
||||
type: d.device_type,
|
||||
neighbors: getNeighbors(d),
|
||||
group
|
||||
};
|
||||
@@ -8631,11 +8630,11 @@ const link = firstNode
|
||||
return (
|
||||
d?.neighbors?.map((n) => {
|
||||
const matching = nodes.findIndex((node) => node.ieee === n.ieee);
|
||||
if (matching === -1) return
|
||||
if (matching === -1) return;
|
||||
|
||||
return {
|
||||
source,
|
||||
target: matching,
|
||||
target: matching
|
||||
};
|
||||
}) || []
|
||||
);
|
||||
@@ -8647,10 +8646,10 @@ const moreLinks = nodes
|
||||
.map((d, source) => {
|
||||
return (
|
||||
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);
|
||||
if (matching === -1) return
|
||||
if (matching === -1) return;
|
||||
|
||||
return {
|
||||
target: matching,
|
||||
@@ -8662,6 +8661,6 @@ const moreLinks = nodes
|
||||
.flat()
|
||||
.filter((el) => el !== undefined);
|
||||
|
||||
const links = link.concat(moreLinks)
|
||||
const links = link.concat(moreLinks);
|
||||
|
||||
export const data = { nodes, links };
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
case 3:
|
||||
return '#DB4537';
|
||||
default:
|
||||
return 'blue'
|
||||
return 'blue';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user