refactor: 🎨 remove caching #48

Merged
jamie merged 15 commits from v2.0.0 into main 2026-05-23 21:04:45 +01:00
3 changed files with 18 additions and 18 deletions
Showing only changes of commit 9e47cbee4e - Show all commits
+2 -2
View File
@@ -77,7 +77,7 @@ function formatHour(h: number) {
<div> <div>
<div class="text-xs font-medium uppercase tracking-wide text-slate-500">Total IPv4 addresses</div> <div class="text-xs font-medium uppercase tracking-wide text-slate-500">Total IPv4 addresses</div>
<div class="mt-1 text-2xl font-bold text-accent">{{ stats.total_ips.toLocaleString() }}</div> <div class="mt-1 text-2xl font-bold text-accent">{{ stats.total_ips.toLocaleString() }}</div>
<div class="text-sm text-slate-500">{{ stats.utilization_percent }}% utilized</div> <div class="text-sm text-slate-500">{{ stats.utilization_percent }}% utilised</div>
</div> </div>
</div> </div>
<div class="card flex items-start gap-4"> <div class="card flex items-start gap-4">
@@ -163,7 +163,7 @@ function formatHour(h: number) {
<tr class="border-b border-slate-200 text-xs font-medium uppercase tracking-wide text-slate-500 dark:border-slate-700"> <tr class="border-b border-slate-200 text-xs font-medium uppercase tracking-wide text-slate-500 dark:border-slate-700">
<th class="p-2">Subnet</th> <th class="p-2">Subnet</th>
<th class="p-2">Name</th> <th class="p-2">Name</th>
<th class="p-2">Utilized</th> <th class="p-2">Utilised</th>
<th class="p-2">Available</th> <th class="p-2">Available</th>
<th class="p-2">Site</th> <th class="p-2">Site</th>
<th class="p-2">Status</th> <th class="p-2">Status</th>
+7 -7
View File
@@ -7,7 +7,6 @@ import { useAuthStore } from "@/stores/auth";
const route = useRoute(); const route = useRoute();
const auth = useAuthStore(); const auth = useAuthStore();
const rack = ref<Rack | null>(null); const rack = ref<Rack | null>(null);
const side = ref("front");
const showAddDevice = ref(false); const showAddDevice = ref(false);
const showAddNonnet = ref(false); const showAddNonnet = ref(false);
const addForm = ref({ device_id: 0, position_u: 1, side: "front" }); const addForm = ref({ device_id: 0, position_u: 1, side: "front" });
@@ -24,11 +23,11 @@ onMounted(load);
const siteDevices = () => rack.value?.site_devices || []; const siteDevices = () => rack.value?.site_devices || [];
const slots = (r: Rack) => { const slotsForSide = (r: Rack, rackSide: string) => {
const h = r.height_u; const h = r.height_u;
const map: Record<number, typeof r.devices> = {}; const map: Record<number, typeof r.devices> = {};
for (const d of r.devices || []) { for (const d of r.devices || []) {
if (d.side === side.value) (map[d.position_u] ??= []).push(d); if (d.side === rackSide) (map[d.position_u] ??= []).push(d);
} }
return Array.from({ length: h }, (_, i) => ({ u: h - i, devices: map[h - i] || [] })); return Array.from({ length: h }, (_, i) => ({ u: h - i, devices: map[h - i] || [] }));
}; };
@@ -81,14 +80,14 @@ async function removeDevice(rackDeviceId: number) {
<a v-if="auth.can('export_rack_csv')" :href="`/api/v2/racks/${rack.id}/export`" class="btn-secondary text-sm">Export CSV</a> <a v-if="auth.can('export_rack_csv')" :href="`/api/v2/racks/${rack.id}/export`" class="btn-secondary text-sm">Export CSV</a>
</div> </div>
<div class="mt-4 flex flex-wrap gap-2"> <div class="mt-4 flex flex-wrap gap-2">
<button class="rounded-lg px-3 py-1 text-sm" :class="side === 'front' ? 'bg-accent text-slate-950' : 'bg-surface-overlay'" @click="side = 'front'">Front</button>
<button class="rounded-lg px-3 py-1 text-sm" :class="side === 'back' ? 'bg-accent text-slate-950' : 'bg-surface-overlay'" @click="side = 'back'">Back</button>
<button v-if="auth.can('add_device_to_rack')" class="btn-secondary text-sm" @click="showAddDevice = true; err = ''">Add device</button> <button v-if="auth.can('add_device_to_rack')" class="btn-secondary text-sm" @click="showAddDevice = true; err = ''">Add device</button>
<button v-if="auth.can('add_nonnet_device_to_rack')" class="btn-secondary text-sm" @click="showAddNonnet = true; err = ''">Add non-networked</button> <button v-if="auth.can('add_nonnet_device_to_rack')" class="btn-secondary text-sm" @click="showAddNonnet = true; err = ''">Add non-networked</button>
</div> </div>
<div class="card mt-6 max-w-md font-mono text-sm"> <div class="mt-6 grid gap-6 lg:grid-cols-2">
<div v-for="row in slots(rack)" :key="row.u" class="flex border-b border-slate-200 py-2 dark:border-slate-700"> <div v-for="rackSide in ['front', 'back'] as const" :key="rackSide" class="card font-mono text-sm">
<h2 class="mb-3 border-b border-slate-200 pb-2 text-base font-semibold capitalize dark:border-slate-700">{{ rackSide }}</h2>
<div v-for="row in slotsForSide(rack, rackSide)" :key="row.u" class="flex border-b border-slate-200 py-2 dark:border-slate-700">
<span class="w-10 shrink-0 text-slate-500">U{{ row.u }}</span> <span class="w-10 shrink-0 text-slate-500">U{{ row.u }}</span>
<span class="flex flex-1 flex-col gap-1"> <span class="flex flex-1 flex-col gap-1">
<span v-for="d in row.devices" :key="d.id" class="flex items-center gap-2"> <span v-for="d in row.devices" :key="d.id" class="flex items-center gap-2">
@@ -100,6 +99,7 @@ async function removeDevice(rackDeviceId: number) {
</span> </span>
</div> </div>
</div> </div>
</div>
<div v-if="showAddDevice" class="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4" @click.self="showAddDevice = false"> <div v-if="showAddDevice" class="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4" @click.self="showAddDevice = false">
<form class="card w-full max-w-md space-y-3" @submit.prevent="addDevice"> <form class="card w-full max-w-md space-y-3" @submit.prevent="addDevice">
+1 -1
View File
@@ -50,7 +50,7 @@ function isDhcpRow(hostname?: string) {
</script> </script>
<template> <template>
<div> <div>
<RouterLink to="/" class="text-sm text-accent hover:underline"> Home</RouterLink> <RouterLink to="/subnets" class="text-sm text-accent hover:underline"> Subnets</RouterLink>
<p v-if="loading" class="mt-8 text-slate-500">Loading</p> <p v-if="loading" class="mt-8 text-slate-500">Loading</p>
<p v-else-if="error" class="mt-8 text-red-500">{{ error }}</p> <p v-else-if="error" class="mt-8 text-red-500">{{ error }}</p>
<template v-else-if="subnet"> <template v-else-if="subnet">