mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-27 12:26:24 +00:00
Add device-dashboard
This commit is contained in:
1 parent
5e01ae0c93
commit
e304a27b0d
23 files changed
+1208
-1
No files matched your search
@@ -0,0 +1,140 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<!-- Mongoose device dashboard -->
|
||||
<script src="https://cdn.jsdelivr.net/gh/cesanta/mongoose@master/resources/dashboard.js"></script>
|
||||
<script>
|
||||
Dashboard.init({
|
||||
debug: true,
|
||||
data: {
|
||||
temperature: 25,
|
||||
humidity: 60,
|
||||
voltage: 12.5,
|
||||
current: 4.2,
|
||||
power: 52.5,
|
||||
speed: 100,
|
||||
},
|
||||
});
|
||||
</script>
|
||||
<script src="main.js" defer></script>
|
||||
<title>My Dashboard Toolbar</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<div class="header-container">
|
||||
<div class="header-left">
|
||||
<nav class="nav-tabs" role="tablist" aria-label="Primary tabs">
|
||||
<img src="logo.svg" alt="Logo" class="logo" />
|
||||
<a href="#overview" id="tab-overview" class="nav-link nav-link-active" role="tab" aria-controls="overview" aria-selected="true">
|
||||
<svg viewBox="0 0 24 24" class="nav-icon" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M3 11.5 12 4l9 7.5" />
|
||||
<path d="M5 10.5V20h14v-9.5" />
|
||||
</svg>
|
||||
Overview
|
||||
</a>
|
||||
<a href="#settings" id="tab-settings" class="nav-link" role="tab" aria-controls="settings" aria-selected="false" tabindex="-1">
|
||||
<svg viewBox="0 0 24 24" class="nav-icon" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
<path d="M19.4 15a1.7 1.7 0 0 0 .34 1.87l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06A1.7 1.7 0 0 0 15 19.4a1.7 1.7 0 0 0-1 .6 1.7 1.7 0 0 0-.4 1.1V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-.4-1.1 1.7 1.7 0 0 0-1-.6 1.7 1.7 0 0 0-1.87.34l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.7 1.7 0 0 0 4.6 15a1.7 1.7 0 0 0-.6-1 1.7 1.7 0 0 0-1.1-.4H2.8a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.1-.4 1.7 1.7 0 0 0 .6-1 1.7 1.7 0 0 0-.34-1.87l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.7 1.7 0 0 0 9 4.6c.38-.16.72-.4 1-.7.26-.3.4-.69.4-1.1V2.8a2 2 0 1 1 4 0v.1c0 .41.14.8.4 1.1.28.3.62.54 1 .7a1.7 1.7 0 0 0 1.87-.34l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.7 1.7 0 0 0 19.4 9c.16.38.4.72.7 1 .3.26.69.4 1.1.4h.1a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.1.4 1.7 1.7 0 0 0-.7 1z" />
|
||||
</svg>
|
||||
Settings
|
||||
</a>
|
||||
<a href="#firmware" id="tab-firmware" class="nav-link" role="tab" aria-controls="firmware" aria-selected="false" tabindex="-1">
|
||||
<svg viewBox="0 0 24 24" class="nav-icon" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M12 3v10" />
|
||||
<path d="m8 9 4 4 4-4" />
|
||||
<rect x="4" y="17" width="16" height="4" rx="2" />
|
||||
</svg>
|
||||
Firmware Update
|
||||
</a>
|
||||
<a href="#events" id="tab-events" class="nav-link" role="tab" aria-controls="events" aria-selected="false" tabindex="-1">
|
||||
<svg viewBox="0 0 24 24" class="nav-icon" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M8 7h8" />
|
||||
<path d="M8 12h8" />
|
||||
<path d="M8 17h5" />
|
||||
<rect x="4" y="4" width="16" height="16" rx="3" />
|
||||
</svg>
|
||||
Events
|
||||
</a>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<div class="connection-badge" aria-label="connection active">
|
||||
<span class="connection-label">live</span>
|
||||
<span class="connection-dot" aria-hidden="true"></span>
|
||||
</div>
|
||||
<nav class="nav-tabs">
|
||||
<div class="nav-link">
|
||||
<svg viewBox="0 0 24 24" class="nav-icon" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" />
|
||||
<circle cx="12" cy="7" r="4" />
|
||||
</svg>
|
||||
<span>admin</span>
|
||||
<svg viewBox="0 0 24 24" class="nav-icon" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
|
||||
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" />
|
||||
<path d="M16 17l5-5-5-5" />
|
||||
<path d="M21 12H9" />
|
||||
</svg>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<main class="tab-stage">
|
||||
<section id="overview" class="tab-panel tab-panel-active" role="tabpanel" aria-labelledby="tab-overview">
|
||||
<div class="overview-grid" aria-label="Electrical overview">
|
||||
<article class="metric-tile">
|
||||
<div class="metric-tile-top">
|
||||
<div class="metric-label">VOLTAGE</div>
|
||||
<span class="metric-chip">
|
||||
<svg viewBox="0 0 24 24" class="metric-icon" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
|
||||
<path d="M13 2 6 14h5l-1 8 7-12h-5z" />
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div class="metric-value">
|
||||
<span class="metric-number">12.5</span>
|
||||
<span class="metric-unit">V</span>
|
||||
</div>
|
||||
</article>
|
||||
<article class="metric-tile">
|
||||
<div class="metric-tile-top">
|
||||
<div class="metric-label">CURRENT</div>
|
||||
<span class="metric-chip">
|
||||
<svg viewBox="0 0 24 24" class="metric-icon" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
|
||||
<path d="M4 12h4l2-6 4 12 2-6h4" />
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div class="metric-value">
|
||||
<span class="metric-number">4.2</span>
|
||||
<span class="metric-unit">A</span>
|
||||
</div>
|
||||
</article>
|
||||
<article class="metric-tile">
|
||||
<div class="metric-tile-top">
|
||||
<div class="metric-label">POWER</div>
|
||||
<span class="metric-chip">
|
||||
<svg viewBox="0 0 24 24" class="metric-icon" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
|
||||
<path d="M12 3v8" />
|
||||
<path d="M7 8h10" />
|
||||
<rect x="5" y="11" width="14" height="8" rx="2" />
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div class="metric-value">
|
||||
<span class="metric-number">52.5</span>
|
||||
<span class="metric-unit">W</span>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
<section id="settings" class="tab-panel" role="tabpanel" aria-labelledby="tab-settings" hidden></section>
|
||||
<section id="firmware" class="tab-panel" role="tabpanel" aria-labelledby="tab-firmware" hidden></section>
|
||||
<section id="events" class="tab-panel" role="tabpanel" aria-labelledby="tab-events" hidden></section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,23 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 600" width="1200" height="600">
|
||||
<defs>
|
||||
<linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0%" stop-color="#2dd4bf"/>
|
||||
<stop offset="100%" stop-color="#0f766e"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
|
||||
<!-- icon: two rounded rectangles -->
|
||||
<g fill="none" stroke="url(#g)" stroke-width="40" stroke-linecap="round" stroke-linejoin="round">
|
||||
<rect x="140" y="160" width="260" height="260" rx="70"/>
|
||||
<rect x="260" y="80" width="260" height="260" rx="70"/>
|
||||
</g>
|
||||
|
||||
<!-- text -->
|
||||
<text x="560" y="330"
|
||||
font-family="system-ui, -apple-system, Segoe UI, Roboto, sans-serif"
|
||||
font-size="160"
|
||||
font-weight="600"
|
||||
fill="#6b7280">
|
||||
my logo
|
||||
</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 773 B |
@@ -0,0 +1,34 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const tabs = Array.from(document.querySelectorAll(".header-left .nav-link[href^='#']"));
|
||||
const panels = Array.from(document.querySelectorAll(".tab-panel"));
|
||||
|
||||
const activateTab = targetId => {
|
||||
const targetPanel = document.getElementById(targetId);
|
||||
if (!targetPanel) return;
|
||||
|
||||
tabs.forEach(tab => {
|
||||
const isActive = tab.getAttribute("href") === `#${targetId}`;
|
||||
tab.classList.toggle("nav-link-active", isActive);
|
||||
tab.setAttribute("aria-selected", String(isActive));
|
||||
tab.setAttribute("tabindex", isActive ? "0" : "-1");
|
||||
});
|
||||
|
||||
panels.forEach(panel => {
|
||||
const isActive = panel.id === targetId;
|
||||
panel.classList.toggle("tab-panel-active", isActive);
|
||||
panel.hidden = !isActive;
|
||||
});
|
||||
};
|
||||
|
||||
tabs.forEach(tab => {
|
||||
tab.addEventListener("click", event => {
|
||||
event.preventDefault();
|
||||
const targetId = tab.getAttribute("href").slice(1);
|
||||
activateTab(targetId);
|
||||
window.history.replaceState(null, "", `#${targetId}`);
|
||||
});
|
||||
});
|
||||
|
||||
const initialId = window.location.hash.slice(1) || "overview";
|
||||
activateTab(initialId);
|
||||
});
|
||||
@@ -0,0 +1,237 @@
|
||||
/* Custom CSS for Dashboard */
|
||||
|
||||
:root {
|
||||
--color-surface-sunken: #e9eff5;
|
||||
--color-border-default: #d8e0ea;
|
||||
--color-text-toolbar: rgb(71, 85, 105);
|
||||
--color-text-strong: #24364d;
|
||||
--color-accent-border: #bae6fd;
|
||||
--color-accent-text: #0369a1;
|
||||
--color-surface-elevated: #ffffff;
|
||||
--font-size-body: 14px;
|
||||
--font-size-toolbar: 1rem;
|
||||
--max-width: 80rem;
|
||||
--spacing-1: 0.25rem;
|
||||
--spacing-2: 0.5rem;
|
||||
--spacing-3: 0.75rem;
|
||||
--spacing-4: 1rem;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
||||
font-size: var(--font-size-body);
|
||||
line-height: 1.5;
|
||||
min-height: 100vh;
|
||||
color: var(--color-text-strong);
|
||||
}
|
||||
|
||||
.header {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 50;
|
||||
}
|
||||
|
||||
.header-container {
|
||||
max-width: var(--max-width);
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--spacing-4);
|
||||
padding: var(--spacing-2) var(--spacing-3);
|
||||
}
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-4);
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: var(--spacing-3);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 2.8rem;
|
||||
margin-right: 1rem;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.connection-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
color: rgb(4, 120, 87);
|
||||
border: 1px solid rgb(167, 243, 208);
|
||||
background: rgb(236, 253, 245);
|
||||
padding: 4px 14px;
|
||||
border-radius: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.connection-dot {
|
||||
width: 11px;
|
||||
height: 11px;
|
||||
border-radius: 50%;
|
||||
background: rgb(16, 185, 129);
|
||||
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.nav-tabs {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-2);
|
||||
background: rgb(248, 250, 252);
|
||||
border: 1px solid rgb(226, 232, 240);
|
||||
padding: calc(var(--spacing-1) + 2px);
|
||||
border-radius: 1rem;
|
||||
box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0.05) 0px 2px 4px 0px inset;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
border-radius: 0.75rem;
|
||||
border: 1px solid transparent;
|
||||
padding: var(--spacing-2) var(--spacing-4);
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.01em;
|
||||
color: var(--color-text-toolbar);
|
||||
background-color: transparent;
|
||||
transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
gap: var(--spacing-2);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.nav-link-active {
|
||||
color: rgb(3, 105, 161);
|
||||
background: #fff;
|
||||
border: 1px solid rgb(186, 230, 253);
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
}
|
||||
|
||||
.nav-icon {
|
||||
height: 1rem;
|
||||
width: 1rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.tab-stage {
|
||||
max-width: var(--max-width);
|
||||
margin: 0 auto;
|
||||
padding: 5.5rem var(--spacing-3) var(--spacing-3);
|
||||
}
|
||||
|
||||
.tab-panel {
|
||||
min-height: calc(100vh - 6rem);
|
||||
/* border-radius: .5rem; */
|
||||
/* background-color: #eee; */
|
||||
/* border: 1px solid rgba(216, 224, 234, 0.78); */
|
||||
/* padding: var(--spacing-4); */
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.72),
|
||||
0 18px 40px rgba(148, 163, 184, 0.1);
|
||||
}
|
||||
|
||||
.overview-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
justify-content: flex-start;
|
||||
gap: 0.45rem;
|
||||
}
|
||||
|
||||
.metric-tile {
|
||||
flex: 0 0 auto;
|
||||
width: 8.75rem;
|
||||
min-height: 0;
|
||||
padding: 0.5rem 0.6rem 0.55rem;
|
||||
border-radius: 0.7rem;
|
||||
background:
|
||||
linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(245, 249, 253, 0.92) 100%);
|
||||
border: 1px solid rgba(203, 213, 225, 0.8);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.9),
|
||||
0 4px 10px rgba(148, 163, 184, 0.08);
|
||||
}
|
||||
|
||||
.metric-tile-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 0.3rem;
|
||||
}
|
||||
|
||||
.metric-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 1.3rem;
|
||||
height: 1.3rem;
|
||||
border-radius: 0.42rem;
|
||||
color: #4f6f93;
|
||||
background: linear-gradient(180deg, rgba(232, 239, 245, 0.98) 0%, rgba(219, 229, 239, 0.92) 100%);
|
||||
border: 1px solid rgba(191, 204, 219, 0.72);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.84),
|
||||
0 2px 6px rgba(148, 163, 184, 0.08);
|
||||
}
|
||||
|
||||
.metric-icon {
|
||||
width: 0.68rem;
|
||||
height: 0.68rem;
|
||||
}
|
||||
|
||||
.metric-label {
|
||||
color: #5d7088;
|
||||
font-size: 0.58rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.metric-value {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 0.16rem;
|
||||
color: #18314f;
|
||||
}
|
||||
|
||||
.metric-number {
|
||||
font-size: 1.18rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.025em;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.metric-unit {
|
||||
color: var(--color-text-muted);
|
||||
font-size: 0.62rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
.tab-panel[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (max-width: 840px) {
|
||||
.overview-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user