🚧 Update frontend layout
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"lucide-vue-next": "^0.462.0",
|
||||
"vue": "^3.5.13",
|
||||
"vue-router": "^4.5.0"
|
||||
},
|
||||
|
||||
+37
-10
@@ -1,31 +1,58 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { Cpu, KeyRound, LayoutDashboard, MessageSquareText, Moon, Sun } from 'lucide-vue-next'
|
||||
import { applyTheme, initialTheme, type Theme } from './theme'
|
||||
import { submitToken, ui } from './store'
|
||||
|
||||
const token = ref('')
|
||||
const theme = ref<Theme>(initialTheme())
|
||||
|
||||
function onSubmit() {
|
||||
submitToken(token.value)
|
||||
token.value = ''
|
||||
}
|
||||
|
||||
function toggleTheme() {
|
||||
theme.value = theme.value === 'dark' ? 'light' : 'dark'
|
||||
applyTheme(theme.value)
|
||||
}
|
||||
|
||||
// Apply on mount (theme.ts also runs before the app mounts, see main.ts)
|
||||
// so the sidebar ghost button label matches the active theme.
|
||||
onMounted(() => applyTheme(theme.value))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<nav class="nav">
|
||||
<span class="brand">nodeledge</span>
|
||||
<router-link to="/">Dashboard</router-link>
|
||||
<router-link to="/devices">Devices</router-link>
|
||||
<router-link to="/tokens">Tokens</router-link>
|
||||
<router-link to="/messages">Messages</router-link>
|
||||
</nav>
|
||||
<div class="shell">
|
||||
<aside class="sidebar">
|
||||
<div class="brand">.:: vivab ::.</div>
|
||||
<router-link to="/"><LayoutDashboard :size="17" /> <span>Dashboard</span></router-link>
|
||||
<router-link to="/devices"><Cpu :size="17" /> <span>Devices</span></router-link>
|
||||
<router-link to="/tokens"><KeyRound :size="17" /> <span>Tokens</span></router-link>
|
||||
<router-link to="/messages"><MessageSquareText :size="17" /> <span>Messages</span></router-link>
|
||||
<div class="bottom">
|
||||
<button class="ghost" @click="toggleTheme">
|
||||
<Sun v-if="theme === 'dark'" :size="16" />
|
||||
<Moon v-else :size="16" />
|
||||
{{ theme === 'dark' ? 'Light mode' : 'Dark mode' }}
|
||||
</button>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<main>
|
||||
<router-view />
|
||||
</main>
|
||||
|
||||
<div v-if="ui.toasts.length" class="toasts">
|
||||
<div v-for="t in ui.toasts" :key="t.id" class="toast" :class="t.kind">{{ t.text }}</div>
|
||||
<div
|
||||
v-for="t in ui.toasts"
|
||||
:key="t.id"
|
||||
class="toast"
|
||||
:class="t.kind"
|
||||
@click="ui.toasts.splice(ui.toasts.indexOf(t), 1)"
|
||||
>
|
||||
{{ t.text }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="ui.showTokenPrompt" class="modal-backdrop">
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
import { router } from './router'
|
||||
import { applyTheme, initialTheme } from './theme'
|
||||
import './style.css'
|
||||
|
||||
// Apply the saved theme BEFORE mounting so the first paint is already
|
||||
// correct (no white flash for dark-mode users).
|
||||
applyTheme(initialTheme())
|
||||
|
||||
createApp(App).use(router).mount('#app')
|
||||
+344
-52
@@ -1,14 +1,43 @@
|
||||
/* Minimal hand-rolled styling: one shared sheet, no CSS framework. */
|
||||
/* Design system: everything keys off [data-theme] variables (see theme.ts).
|
||||
Class names match the existing views, so the views needed minimal markup
|
||||
changes. */
|
||||
|
||||
:root {
|
||||
--bg: #f4f5f7;
|
||||
--font: 'Inter', 'Segoe UI', system-ui, sans-serif;
|
||||
--mono: ui-monospace, 'JetBrains Mono', Consolas, monospace;
|
||||
|
||||
--bg: #f6f7f9;
|
||||
--card: #ffffff;
|
||||
--border: #d9dce1;
|
||||
--text: #1c2430;
|
||||
--muted: #61707f;
|
||||
--accent: #2563eb;
|
||||
--border: #e4e7ec;
|
||||
--text: #101828;
|
||||
--muted: #667085;
|
||||
--accent: #4f46e5;
|
||||
--accent-soft: #eef2ff;
|
||||
--danger: #dc2626;
|
||||
--danger-soft: #fef2f2;
|
||||
--ok: #16a34a;
|
||||
--ok-soft: #dcfce7;
|
||||
--shadow-sm: 0 1px 2px rgb(16 24 40 / 6%);
|
||||
--shadow-md: 0 4px 12px -2px rgb(16 24 40 / 10%);
|
||||
--radius: 10px;
|
||||
--nav-bg: #101828;
|
||||
}
|
||||
|
||||
[data-theme='dark'] {
|
||||
--bg: #0b1220;
|
||||
--card: #111a2c;
|
||||
--border: #1f2a44;
|
||||
--text: #e6eaf2;
|
||||
--muted: #8b96ab;
|
||||
--accent: #818cf8;
|
||||
--accent-soft: #1e2444;
|
||||
--danger: #f87171;
|
||||
--danger-soft: #2a1618;
|
||||
--ok: #4ade80;
|
||||
--ok-soft: #12281a;
|
||||
--shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
|
||||
--shadow-md: 0 4px 12px -2px rgb(0 0 0 / 50%);
|
||||
--nav-bg: #060b16;
|
||||
}
|
||||
|
||||
* {
|
||||
@@ -17,25 +46,88 @@
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Segoe UI', system-ui, sans-serif;
|
||||
font-family: var(--font);
|
||||
font-size: 14px;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
/* ---- app shell: sidebar + content ---- */
|
||||
.shell {
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: 14rem;
|
||||
flex-shrink: 0;
|
||||
background: var(--nav-bg);
|
||||
padding: 1rem 0.75rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.sidebar .brand {
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
font-size: 1.05rem;
|
||||
padding: 0.5rem 0.75rem 1rem;
|
||||
letter-spacing: 0.01em;
|
||||
}
|
||||
|
||||
.sidebar a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.65rem;
|
||||
color: #9aa5bb;
|
||||
padding: 0.55rem 0.75rem;
|
||||
border-radius: 8px;
|
||||
text-decoration: none;
|
||||
transition:
|
||||
background 0.15s,
|
||||
color 0.15s;
|
||||
}
|
||||
|
||||
.sidebar a:hover {
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 6%);
|
||||
}
|
||||
|
||||
.sidebar a.router-link-active {
|
||||
color: #fff;
|
||||
background: var(--accent);
|
||||
}
|
||||
|
||||
.sidebar .bottom {
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
main {
|
||||
max-width: 64rem;
|
||||
flex: 1;
|
||||
max-width: 70rem;
|
||||
margin: 0 auto;
|
||||
padding: 1.5rem;
|
||||
padding: 1.75rem 2rem 4rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.4rem;
|
||||
margin: 0 0 1rem;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 650;
|
||||
margin: 0 0 1.25rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.05rem;
|
||||
margin: 1.5rem 0 0.75rem;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 600;
|
||||
margin: 1.75rem 0 0.75rem;
|
||||
color: var(--muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
a {
|
||||
@@ -46,21 +138,22 @@ a {
|
||||
.card {
|
||||
background: var(--card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
padding: 1rem;
|
||||
border-radius: var(--radius);
|
||||
box-shadow: var(--shadow-sm);
|
||||
padding: 1rem 1.25rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 0.9rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
text-align: left;
|
||||
padding: 0.4rem 0.6rem;
|
||||
padding: 0.55rem 0.6rem;
|
||||
border-bottom: 1px solid var(--border);
|
||||
vertical-align: top;
|
||||
}
|
||||
@@ -68,17 +161,45 @@ td {
|
||||
th {
|
||||
color: var(--muted);
|
||||
font-weight: 600;
|
||||
font-size: 0.78rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
|
||||
tbody tr {
|
||||
transition: background 0.15s;
|
||||
}
|
||||
|
||||
tbody tr:hover {
|
||||
background: var(--accent-soft);
|
||||
}
|
||||
|
||||
td.mono,
|
||||
.mono {
|
||||
font-family: var(--mono);
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
font: inherit;
|
||||
padding: 0.4rem 0.5rem;
|
||||
padding: 0.5rem 0.65rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
border-radius: 8px;
|
||||
background: var(--card);
|
||||
color: var(--text);
|
||||
transition:
|
||||
border 0.15s,
|
||||
box-shadow 0.15s;
|
||||
}
|
||||
|
||||
input:focus-visible,
|
||||
select:focus-visible,
|
||||
textarea:focus-visible {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 0 3px var(--accent-soft);
|
||||
}
|
||||
|
||||
input[type='text'],
|
||||
@@ -90,13 +211,41 @@ textarea {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
label {
|
||||
font-size: 0.85rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
button {
|
||||
font: inherit;
|
||||
padding: 0.4rem 0.9rem;
|
||||
font-weight: 550;
|
||||
padding: 0.45rem 0.95rem;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
background: var(--card);
|
||||
color: var(--text);
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
transition:
|
||||
box-shadow 0.15s,
|
||||
transform 0.15s,
|
||||
background 0.15s,
|
||||
border 0.15s;
|
||||
}
|
||||
|
||||
button:focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
button:active {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
button.primary {
|
||||
@@ -105,15 +254,36 @@ button.primary {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
button.primary:hover {
|
||||
box-shadow: 0 4px 10px -2px var(--accent);
|
||||
}
|
||||
|
||||
button.danger {
|
||||
color: var(--danger);
|
||||
border-color: var(--danger);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
button.danger:hover {
|
||||
background: var(--danger-soft);
|
||||
}
|
||||
|
||||
button.ghost {
|
||||
border-color: transparent;
|
||||
background: transparent;
|
||||
color: #9aa5bb;
|
||||
}
|
||||
|
||||
button.ghost:hover {
|
||||
color: #fff;
|
||||
box-shadow: none;
|
||||
background: rgb(255 255 255 / 6%);
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
opacity: 0.5;
|
||||
opacity: 0.45;
|
||||
cursor: not-allowed;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.row {
|
||||
@@ -133,29 +303,78 @@ button:disabled {
|
||||
}
|
||||
|
||||
.badge {
|
||||
display: inline-block;
|
||||
padding: 0.05rem 0.5rem;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
padding: 0.1rem 0.55rem;
|
||||
border-radius: 999px;
|
||||
font-size: 0.75rem;
|
||||
background: #e8edf3;
|
||||
color: var(--muted);
|
||||
background: var(--accent-soft);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.badge.ok {
|
||||
background: #dcfce7;
|
||||
background: var(--ok-soft);
|
||||
color: var(--ok);
|
||||
}
|
||||
|
||||
.badge.ok::before {
|
||||
content: '';
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: var(--ok);
|
||||
}
|
||||
|
||||
pre.json {
|
||||
background: #0f172a;
|
||||
color: #e2e8f0;
|
||||
padding: 0.75rem;
|
||||
border-radius: 6px;
|
||||
border-radius: 8px;
|
||||
overflow-x: auto;
|
||||
font-size: 0.8rem;
|
||||
font-size: 0.78rem;
|
||||
font-family: var(--mono);
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
|
||||
[data-theme='dark'] pre.json {
|
||||
background: #060b16;
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
|
||||
/* skeletons */
|
||||
.skeleton {
|
||||
height: 1rem;
|
||||
border-radius: 6px;
|
||||
margin: 0.35rem 0;
|
||||
background: linear-gradient(90deg, var(--border) 25%, var(--accent-soft) 50%, var(--border) 75%);
|
||||
background-size: 200% 100%;
|
||||
animation: shimmer 1.2s infinite;
|
||||
}
|
||||
|
||||
.skeleton.title {
|
||||
height: 1.6rem;
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.skeleton.line {
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
.skeleton.stat {
|
||||
height: 2.4rem;
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
@keyframes shimmer {
|
||||
from {
|
||||
background-position: 200% 0;
|
||||
}
|
||||
to {
|
||||
background-position: -200% 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* toasts */
|
||||
.toasts {
|
||||
position: fixed;
|
||||
@@ -168,11 +387,14 @@ pre.json {
|
||||
}
|
||||
|
||||
.toast {
|
||||
padding: 0.6rem 1rem;
|
||||
border-radius: 6px;
|
||||
padding: 0.65rem 1rem;
|
||||
border-radius: 8px;
|
||||
color: #fff;
|
||||
font-size: 0.9rem;
|
||||
font-size: 0.88rem;
|
||||
max-width: 26rem;
|
||||
box-shadow: var(--shadow-md);
|
||||
animation: slide-in 0.2s ease-out;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.toast.error {
|
||||
@@ -183,11 +405,22 @@ pre.json {
|
||||
background: var(--ok);
|
||||
}
|
||||
|
||||
@keyframes slide-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateX(1rem);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* token prompt modal */
|
||||
.modal-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgb(0 0 0 / 45%);
|
||||
background: rgb(0 0 0 / 50%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -196,33 +429,92 @@ pre.json {
|
||||
|
||||
.modal {
|
||||
background: var(--card);
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 14px;
|
||||
box-shadow: var(--shadow-md);
|
||||
padding: 1.5rem;
|
||||
width: min(90vw, 26rem);
|
||||
}
|
||||
|
||||
/* nav */
|
||||
.nav {
|
||||
background: #0f172a;
|
||||
/* timeline (DeviceDetail) */
|
||||
.timeline {
|
||||
list-style: none;
|
||||
margin: 0.75rem 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.timeline li {
|
||||
position: relative;
|
||||
padding: 0 0 1rem 1.4rem;
|
||||
border-left: 2px solid var(--border);
|
||||
}
|
||||
|
||||
.timeline li:last-child {
|
||||
border-left-color: transparent;
|
||||
}
|
||||
|
||||
.timeline li::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: -5px;
|
||||
top: 0.3rem;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--border);
|
||||
}
|
||||
|
||||
.timeline li.current::before {
|
||||
background: var(--ok);
|
||||
box-shadow: 0 0 0 3px var(--ok-soft);
|
||||
}
|
||||
|
||||
.timeline li .when {
|
||||
color: var(--muted);
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
/* empty states */
|
||||
.empty {
|
||||
text-align: center;
|
||||
padding: 2rem 1rem;
|
||||
color: var(--muted);
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
padding: 0.75rem 1.5rem;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.nav a {
|
||||
color: #cbd5e1;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 6px;
|
||||
}
|
||||
/* responsive: collapse sidebar into an icon bar on narrow screens */
|
||||
@media (max-width: 48rem) {
|
||||
.shell {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.nav a.router-link-active {
|
||||
color: #fff;
|
||||
background: #1e293b;
|
||||
}
|
||||
.sidebar {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
position: static;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
padding: 0.5rem 0.75rem;
|
||||
}
|
||||
|
||||
.nav .brand {
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
margin-right: auto;
|
||||
.sidebar .brand {
|
||||
padding: 0.5rem 0.75rem;
|
||||
}
|
||||
|
||||
.sidebar a span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sidebar .bottom {
|
||||
margin-top: 0;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
main {
|
||||
padding: 1.25rem 1rem 3rem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Theme state: persisted in localStorage, applied as <html data-theme="...">.
|
||||
|
||||
export type Theme = 'light' | 'dark'
|
||||
|
||||
const KEY = 'nodeledge-ui-theme'
|
||||
|
||||
export function initialTheme(): Theme {
|
||||
const saved = localStorage.getItem(KEY)
|
||||
if (saved === 'light' || saved === 'dark') return saved
|
||||
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
||||
}
|
||||
|
||||
export function applyTheme(theme: Theme): void {
|
||||
document.documentElement.dataset.theme = theme
|
||||
localStorage.setItem(KEY, theme)
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { Cpu, Inbox, MessageSquareText } from 'lucide-vue-next'
|
||||
import { api } from '../api'
|
||||
import type { Device, MessagePage } from '../api'
|
||||
import { showError } from '../store'
|
||||
@@ -31,18 +32,30 @@ onMounted(async () => {
|
||||
<h1>Dashboard</h1>
|
||||
<div class="row">
|
||||
<div class="card grow">
|
||||
<div class="muted">Stored messages</div>
|
||||
<div style="font-size: 2rem">{{ messageCount ?? '…' }}</div>
|
||||
<div class="row" style="justify-content: space-between">
|
||||
<span class="muted"><MessageSquareText :size="15" /> Stored messages</span>
|
||||
</div>
|
||||
<div v-if="!loaded" class="skeleton stat" style="margin-top: 0.6rem" />
|
||||
<div v-else style="font-size: 2rem; font-weight: 650">{{ messageCount ?? 0 }}</div>
|
||||
</div>
|
||||
<div class="card grow">
|
||||
<div class="muted">Devices</div>
|
||||
<div style="font-size: 2rem">{{ loaded ? devices.length : '…' }}</div>
|
||||
<div class="row" style="justify-content: space-between">
|
||||
<span class="muted"><Cpu :size="15" /> Devices</span>
|
||||
<router-link v-if="loaded" to="/devices" class="muted">Manage →</router-link>
|
||||
</div>
|
||||
<div v-if="!loaded" class="skeleton stat" style="margin-top: 0.6rem" />
|
||||
<div v-else style="font-size: 2rem; font-weight: 650">{{ devices.length }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>Latest messages</h2>
|
||||
<div class="card">
|
||||
<table v-if="latest.length">
|
||||
<template v-if="!loaded">
|
||||
<div class="skeleton line" />
|
||||
<div class="skeleton line" />
|
||||
<div class="skeleton line" />
|
||||
</template>
|
||||
<table v-else-if="latest.length">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Received</th>
|
||||
@@ -52,7 +65,7 @@ onMounted(async () => {
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="m in latest" :key="m.id">
|
||||
<td>{{ new Date(m.received_at).toLocaleString() }}</td>
|
||||
<td class="mono">{{ new Date(m.received_at).toLocaleString() }}</td>
|
||||
<td>
|
||||
<router-link :to="`/devices/${m.imei}`">{{ m.device }}</router-link>
|
||||
</td>
|
||||
@@ -62,6 +75,9 @@ onMounted(async () => {
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p v-else-if="loaded" class="muted">No messages yet.</p>
|
||||
<div v-else class="empty">
|
||||
<Inbox :size="28" />
|
||||
<span>No messages yet. Publish something or check the listener logs.</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { Plus, Trash2 } from 'lucide-vue-next'
|
||||
import { api } from '../api'
|
||||
import type { AttributeHistory, AttributeVersion, Device, ResolvedAttributes } from '../api'
|
||||
import { formatTime, localInputToUtcIso } from '../format'
|
||||
@@ -170,7 +171,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div class="row" style="margin-bottom: 0.5rem" v-for="(row, i) in rows" :key="i">
|
||||
<label style="width: 8rem"></label>
|
||||
<input v-model="row.key" placeholder="key" style="max-width: 12rem" />
|
||||
<input v-model="row.key" class="mono" placeholder="key" style="max-width: 12rem" />
|
||||
<select v-model="row.type" style="max-width: 7rem">
|
||||
<option value="text">text</option>
|
||||
<option value="number">number</option>
|
||||
@@ -189,7 +190,8 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div class="row">
|
||||
<button type="button" @click="rows.push({ key: '', value: '', type: 'text' })">
|
||||
+ Add setting
|
||||
<Plus :size="15" />
|
||||
Add setting
|
||||
</button>
|
||||
<span class="grow"></span>
|
||||
<button class="primary" type="submit" :disabled="!canSaveSettings">Save settings</button>
|
||||
@@ -204,8 +206,8 @@ onMounted(async () => {
|
||||
<h2>Attribute timeline (time-varying values)</h2>
|
||||
<form class="card" @submit.prevent="appendAttribute">
|
||||
<div class="row" style="margin-bottom: 0.5rem">
|
||||
<input v-model="attrKey" placeholder="key (e.g. temperature_offset)" style="max-width: 16rem" />
|
||||
<input v-model="attrValue" placeholder="value (number, text or JSON)" class="grow" />
|
||||
<input v-model="attrKey" class="mono" placeholder="key (e.g. temperature_offset)" style="max-width: 16rem" />
|
||||
<input v-model="attrValue" class="mono grow" placeholder="value (number, text or JSON)" />
|
||||
</div>
|
||||
<div class="row" style="margin-bottom: 0.5rem">
|
||||
<label>Effective from</label>
|
||||
@@ -225,35 +227,33 @@ onMounted(async () => {
|
||||
|
||||
<div class="card" v-for="[key, versions] in historyEntries" :key="key">
|
||||
<div class="row">
|
||||
<strong>{{ key }}</strong>
|
||||
<span>= {{ JSON.stringify(resolvedNow[key]) }}</span>
|
||||
<strong class="mono">{{ key }}</strong>
|
||||
<span>= <span class="mono">{{ JSON.stringify(resolvedNow[key]) }}</span></span>
|
||||
<span class="badge ok" v-if="key in resolvedNow">in effect now</span>
|
||||
</div>
|
||||
<table style="margin-top: 0.5rem">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Value</th>
|
||||
<th>Effective from</th>
|
||||
<th>Note</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="v in versions" :key="v.effective_from">
|
||||
<td>{{ JSON.stringify(v.value) }}</td>
|
||||
<td>{{ formatTime(v.effective_from) }}</td>
|
||||
<td>{{ v.note ?? '' }}</td>
|
||||
<td style="text-align: right">
|
||||
<button
|
||||
v-if="isLatest(key, v)"
|
||||
class="danger"
|
||||
@click="deleteLatest(key)"
|
||||
>
|
||||
Delete latest
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<ul class="timeline">
|
||||
<li
|
||||
v-for="v in versions"
|
||||
:key="v.effective_from"
|
||||
:class="{ current: isLatest(key, v) }"
|
||||
>
|
||||
<div class="row" style="justify-content: space-between">
|
||||
<span>
|
||||
<strong class="mono">{{ JSON.stringify(v.value) }}</strong>
|
||||
<span class="when" style="margin-left: 0.5rem">{{ formatTime(v.effective_from) }}</span>
|
||||
</span>
|
||||
<button
|
||||
v-if="isLatest(key, v)"
|
||||
class="danger"
|
||||
style="padding: 0.25rem 0.6rem"
|
||||
@click="deleteLatest(key)"
|
||||
>
|
||||
<Trash2 :size="14" />
|
||||
Undo
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="v.note" class="muted" style="margin-top: 0.15rem">{{ v.note }}</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { Cpu, Plus, Trash2 } from 'lucide-vue-next'
|
||||
import { api } from '../api'
|
||||
import type { Device } from '../api'
|
||||
import { showError, toast } from '../store'
|
||||
@@ -56,9 +57,12 @@ async function removeDevice(d: Device) {
|
||||
<h1>Devices</h1>
|
||||
|
||||
<form class="card row" @submit.prevent="addDevice">
|
||||
<input v-model="newImei" class="grow" placeholder="IMEI (15 digits)" style="max-width: 14rem" />
|
||||
<input v-model="newImei" class="grow mono" placeholder="IMEI (15 digits)" style="max-width: 14rem" />
|
||||
<input v-model="newName" class="grow" placeholder="Device name" />
|
||||
<button class="primary" type="submit">Add device</button>
|
||||
<button class="primary" type="submit">
|
||||
<Plus :size="15" />
|
||||
Add device
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="card">
|
||||
@@ -72,16 +76,26 @@ async function removeDevice(d: Device) {
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="d in devices" :key="d.imei">
|
||||
<td>{{ d.imei }}</td>
|
||||
<td class="mono">{{ d.imei }}</td>
|
||||
<td>
|
||||
<router-link :to="`/devices/${d.imei}`">{{ d.device }}</router-link>
|
||||
</td>
|
||||
<td style="text-align: right">
|
||||
<button class="danger" @click="removeDevice(d)">Delete</button>
|
||||
<button class="danger" @click="removeDevice(d)">
|
||||
<Trash2 :size="15" />
|
||||
Delete
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p v-else-if="loaded" class="muted">No devices yet. Add one above.</p>
|
||||
<div v-else-if="loaded" class="empty">
|
||||
<Cpu :size="28" />
|
||||
<span>No devices yet. Add one above to start collecting.</span>
|
||||
</div>
|
||||
<template v-else>
|
||||
<div class="skeleton line" />
|
||||
<div class="skeleton line" />
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { Inbox } from 'lucide-vue-next'
|
||||
import { api } from '../api'
|
||||
import type { MessagePage } from '../api'
|
||||
import { formatTime } from '../format'
|
||||
@@ -70,8 +71,15 @@ onMounted(load)
|
||||
</form>
|
||||
|
||||
<div class="card">
|
||||
<p v-if="loading" class="muted">loading…</p>
|
||||
<p v-else-if="page && !page.items.length" class="muted">No messages match.</p>
|
||||
<template v-if="loading">
|
||||
<div class="skeleton line" />
|
||||
<div class="skeleton line" />
|
||||
<div class="skeleton line" />
|
||||
</template>
|
||||
<div v-else-if="page && !page.items.length" class="empty">
|
||||
<Inbox :size="28" />
|
||||
<span>No messages match.</span>
|
||||
</div>
|
||||
<template v-if="page && page.items.length">
|
||||
<table>
|
||||
<thead>
|
||||
@@ -83,7 +91,7 @@ onMounted(load)
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="m in page.items" :key="m.id">
|
||||
<td>{{ formatTime(m.received_at) }}</td>
|
||||
<td class="mono">{{ formatTime(m.received_at) }}</td>
|
||||
<td>
|
||||
<router-link :to="`/devices/${m.imei}`">{{ m.device }}</router-link>
|
||||
</td>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { KeyRound, Plus, Trash2 } from 'lucide-vue-next'
|
||||
import { api } from '../api'
|
||||
import { showError, toast } from '../store'
|
||||
|
||||
@@ -65,7 +66,10 @@ async function removeToken(name: string) {
|
||||
<form class="card row" @submit.prevent="saveToken">
|
||||
<input v-model="newName" placeholder="app name" style="max-width: 14rem" />
|
||||
<input v-model="newSecret" placeholder="secret" type="password" class="grow" />
|
||||
<button class="primary" type="submit">Add / rotate</button>
|
||||
<button class="primary" type="submit">
|
||||
<Plus :size="15" />
|
||||
Add / rotate
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="card">
|
||||
@@ -78,13 +82,22 @@ async function removeToken(name: string) {
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="n in names" :key="n">
|
||||
<td>{{ n }}</td>
|
||||
<td class="mono">{{ n }}</td>
|
||||
<td style="text-align: right">
|
||||
<button class="danger" @click="removeToken(n)">Delete</button>
|
||||
<button class="danger" @click="removeToken(n)">
|
||||
<Trash2 :size="15" />
|
||||
Delete
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p v-else-if="loaded" class="muted">No tokens yet.</p>
|
||||
<div v-else-if="loaded" class="empty">
|
||||
<KeyRound :size="28" />
|
||||
<span>No tokens yet.</span>
|
||||
</div>
|
||||
<template v-else>
|
||||
<div class="skeleton line" />
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user