chore: prep 0.1.2 release, tidy repo

This commit is contained in:
Aaron
2025-12-13 17:04:32 -05:00
parent 0c69e9bf90
commit b70f4c5f3f
43 changed files with 4259 additions and 4167 deletions

View File

@@ -0,0 +1,140 @@
@font-face {
font-family: "Red Hat Text";
src: url("../fonts/RedHatText-Regular.woff2") format("woff2");
font-weight: 400;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Red Hat Text";
src: url("../fonts/RedHatText-Medium.woff2") format("woff2");
font-weight: 500;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Red Hat Display";
src: url("../fonts/RedHatDisplay-SemiBold.woff2") format("woff2");
font-weight: 600;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Red Hat Display";
src: url("../fonts/RedHatDisplay-Bold.woff2") format("woff2");
font-weight: 700;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Space Grotesk";
src: url("../fonts/SpaceGrotesk-Regular.woff2") format("woff2");
font-weight: 400;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Space Grotesk";
src: url("../fonts/SpaceGrotesk-Medium.woff2") format("woff2");
font-weight: 500;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Space Grotesk";
src: url("../fonts/SpaceGrotesk-SemiBold.woff2") format("woff2");
font-weight: 600;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Manrope";
src: url("../fonts/Manrope-Regular.woff2") format("woff2");
font-weight: 400;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Manrope";
src: url("../fonts/Manrope-SemiBold.woff2") format("woff2");
font-weight: 600;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "DM Sans";
src: url("../fonts/DMSans-Regular.woff2") format("woff2");
font-weight: 400;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "DM Sans";
src: url("../fonts/DMSans-Medium.woff2") format("woff2");
font-weight: 500;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "DM Sans";
src: url("../fonts/DMSans-Bold.woff2") format("woff2");
font-weight: 700;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Sora";
src: url("../fonts/Sora-Regular.woff2") format("woff2");
font-weight: 400;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Sora";
src: url("../fonts/Sora-SemiBold.woff2") format("woff2");
font-weight: 600;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Chivo";
src: url("../fonts/Chivo-Regular.woff2") format("woff2");
font-weight: 400;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Chivo";
src: url("../fonts/Chivo-Bold.woff2") format("woff2");
font-weight: 700;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Atkinson Hyperlegible";
src: url("../fonts/Atkinson-Regular.woff2") format("woff2");
font-weight: 400;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Atkinson Hyperlegible";
src: url("../fonts/Atkinson-Bold.woff2") format("woff2");
font-weight: 700;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "IBM Plex Sans";
src: url("../fonts/PlexSans-Regular.woff2") format("woff2");
font-weight: 400;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "IBM Plex Sans";
src: url("../fonts/PlexSans-SemiBold.woff2") format("woff2");
font-weight: 600;
font-style: normal;
font-display: swap;
}

View File

@@ -0,0 +1,335 @@
button {
background: linear-gradient(135deg, #22c55e, #7dd3fc);
color: #041012;
border: none;
padding: 10px 16px;
border-radius: 10px;
cursor: pointer;
font-weight: 600;
box-shadow: var(--shadow);
}
button.ghost {
background: transparent;
color: var(--text);
border: 1px solid var(--border);
box-shadow: none;
}
button.icon-btn {
width: 40px;
height: 40px;
padding: 0;
display: grid;
place-items: center;
font-size: 1.1rem;
box-shadow: none;
}
:root[data-theme="light"] button.icon-btn {
box-shadow: inset 0 0 0 1px var(--border);
border-radius: 10px;
}
button:active {
transform: translateY(1px);
}
button.danger-btn {
background: linear-gradient(135deg, #f87171, #ef4444);
color: #0f1117;
}
.menu-btn {
font-size: 1rem;
width: 32px;
height: 32px;
padding: 0;
display: grid;
place-items: center;
border-radius: 8px;
}
.service-menu {
position: absolute;
top: 8px;
right: 8px;
display: flex;
flex-direction: column-reverse;
align-items: flex-end;
gap: 6px;
}
.service-menu .ghost {
border: 1px solid color-mix(in srgb, var(--border) 60%, var(--text) 20%);
width: 32px;
height: 32px;
padding: 0;
display: grid;
place-items: center;
border-radius: 8px;
}
label.toggle {
position: relative;
display: inline-block;
width: 46px;
height: 24px;
}
label.toggle input {
display: none;
}
label.toggle .slider {
position: absolute;
cursor: pointer;
inset: 0;
background: var(--toggle-track);
border-radius: 24px;
transition: 0.2s;
}
label.toggle .slider:before {
position: absolute;
content: "";
height: 18px;
width: 18px;
left: 3px;
bottom: 3px;
background: white;
border-radius: 50%;
transition: 0.2s;
}
label.toggle input:checked + .slider {
background: linear-gradient(135deg, #22c55e, #7dd3fc);
}
label.toggle input:checked + .slider:before {
transform: translateX(22px);
}
.controls {
display: flex;
flex-direction: column;
gap: 10px;
}
.accordion {
border: 1px solid var(--border);
border-radius: 12px;
overflow: hidden;
background: var(--panel-overlay);
}
.accordion + .accordion {
margin-top: 8px;
}
.accordion-toggle {
width: 100%;
text-align: left;
background: transparent;
color: var(--text);
border: none;
padding: 12px 14px;
font-weight: 700;
cursor: pointer;
}
.accordion-toggle.danger-btn {
color: #0f1117;
}
.accordion-body {
padding: 0 14px 0;
max-height: 0;
overflow: hidden;
opacity: 0;
transition:
max-height 0.24s ease,
opacity 0.18s ease,
padding-bottom 0.18s ease,
padding-top 0.18s ease;
}
.accordion.open .accordion-body {
max-height: 1200px;
opacity: 1;
padding: 8px 12px 6px;
}
.accordion-body p {
margin: 0 0 6px;
}
.control-card {
border: 1px solid var(--border);
border-radius: 12px;
padding: 12px;
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}
.control-actions {
display: flex;
gap: 10px;
align-items: center;
flex-wrap: wrap;
}
.control-actions.split-row {
justify-content: flex-start;
gap: 10px;
align-items: center;
margin-top: 4px;
flex-wrap: wrap;
}
.control-actions.column.tight {
gap: 6px;
align-items: flex-start;
}
.control-actions.column {
flex-direction: column;
align-items: stretch;
}
.control-actions.column > .checkbox-row.inline {
margin-top: 6px;
}
select,
input {
background: var(--input-bg);
color: var(--text);
border: 1px solid var(--input-border);
padding: 8px 10px;
border-radius: 10px;
}
.checkbox-row {
display: flex;
align-items: center;
gap: 8px;
color: var(--muted);
font-size: 0.95rem;
}
.checkbox-row.inline {
display: inline-flex;
gap: 10px;
align-items: center;
}
.checkbox-row.inline.tight {
margin-top: 6px;
}
.checkbox-row.inline.nowrap span {
white-space: nowrap;
}
.control-row.split {
display: flex;
gap: 12px;
align-items: center;
flex-wrap: wrap;
}
.control-row.split > * {
margin: 0;
}
.dual-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
align-items: center;
}
.dual-row .dual-col:last-child {
text-align: right;
}
.dual-row .checkbox-row.inline {
justify-content: flex-start;
width: fit-content;
}
.form-grid {
display: grid;
gap: 6px;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.field {
display: flex;
flex-direction: column;
gap: 4px;
color: var(--muted);
font-size: 0.95rem;
}
.field input,
.field select {
width: 100%;
}
.checkbox-field .checkbox-row {
color: var(--text);
}
.status-msg {
margin-top: 4px;
}
.status-msg.error {
color: #f87171;
}
.note-warn {
color: #f87171;
font-weight: 600;
}
.is-disabled {
opacity: 0.45;
}
.is-disabled input,
.is-disabled select,
.is-disabled textarea {
filter: grayscale(0.5);
background: var(--input-disabled-bg);
color: var(--input-disabled-text);
border-color: var(--input-disabled-border);
box-shadow: none;
}
.is-disabled label {
color: var(--disabled-text);
}
.is-disabled .slider {
filter: grayscale(0.7);
}
.hidden {
display: none !important;
}
button:disabled {
opacity: 0.55;
cursor: not-allowed;
box-shadow: none;
background: #2f3844;
border: 1px solid #3b4756;
color: #c9d2dc;
pointer-events: none;
}

View File

@@ -0,0 +1,379 @@
.host-chip {
border-radius: 10px;
background: rgba(255, 255, 255, 0.04);
color: var(--text);
}
.layout {
max-width: 1200px;
margin: 0 auto;
padding: 32px 18px 80px;
}
.hero {
display: grid;
grid-template-columns: 1.1fr 0.9fr;
gap: 20px;
align-items: center;
margin-bottom: 24px;
}
.eyebrow {
text-transform: uppercase;
font-size: 0.75rem;
letter-spacing: 0.12rem;
color: var(--muted);
margin: 0 0 6px;
font-family: var(--font-heading);
}
.eyebrow.warning {
color: var(--warning);
}
h1 {
margin: 0 0 10px;
line-height: 1.2;
font-family: var(--font-heading);
font-weight: 700;
}
h2 {
margin: 0 0 6px;
line-height: 1.2;
font-family: var(--font-heading);
font-weight: 600;
}
.lede {
color: var(--muted);
margin: 0 0 14px;
}
.hint {
color: var(--muted);
margin: 0;
font-size: 0.95rem;
}
.hint.quiet {
opacity: 0.8;
font-size: 0.85rem;
}
.actions {
display: flex;
gap: 10px;
flex-wrap: wrap;
}
.hero-stats {
background: var(--panel);
border: 1px solid var(--border);
border-radius: 14px;
padding: 14px;
box-shadow: var(--shadow);
display: grid;
grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
gap: 12px;
}
.stat {
background: var(--card-overlay);
border: 1px solid var(--border);
border-radius: 12px;
padding: 9px;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.stat .label {
color: var(--muted);
font-size: 0.85rem;
}
.stat .value {
font-size: 1.15rem;
font-weight: 700;
line-height: 1.25;
white-space: nowrap;
font-variant-numeric: tabular-nums;
}
.panel {
background: var(--panel);
border: 1px solid var(--border);
border-radius: 16px;
padding: 18px;
margin-bottom: 18px;
box-shadow: var(--shadow);
}
.panel-header {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
flex-wrap: wrap;
margin-bottom: 12px;
font-family: var(--font-heading);
}
.panel-actions {
display: flex;
gap: 8px;
align-items: center;
margin-left: auto;
}
.panel-actions .icon-btn {
font-size: 1.15rem;
width: 38px;
height: 38px;
padding: 0;
}
.panel-header.small-gap {
margin-top: 12px;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 12px;
}
.grid.empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 220px;
width: 100%;
}
.empty-state {
text-align: center;
color: var(--muted);
padding: 16px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 10px;
width: 100%;
height: 100%;
}
.empty-state button {
margin-top: 6px;
box-shadow: none;
}
.card {
border: 1px solid var(--border);
background: var(--card-overlay);
padding: 12px;
padding-right: 48px; /* reserve room for stacked action buttons */
padding-bottom: 34px; /* reserve room for bottom badges */
border-radius: 12px;
display: flex;
flex-direction: column;
gap: 6px;
position: relative;
}
.card.clickable {
cursor: pointer;
}
.card.offline {
border-color: rgba(225, 29, 72, 0.45);
}
.card a {
color: var(--accent);
text-decoration: none;
word-break: break-all;
}
.service-url {
color: var(--text);
font-weight: 600;
word-break: break-all;
}
.pill {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 4px 8px;
border-radius: 999px;
background: color-mix(in srgb, var(--accent) 18%, var(--panel) 82%);
border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border) 65%);
color: var(--text);
font-size: 0.85rem;
max-width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.pill-small {
font-size: 0.8rem;
}
.notice-pill {
display: inline-flex;
align-items: center;
padding: 2px 8px;
border-radius: 999px;
border: 1px dashed #6b7280;
color: #6b7280;
font-size: 0.78rem;
margin-left: 6px;
}
.self-signed-pill {
position: absolute;
right: 10px;
bottom: 10px;
margin-left: 0;
}
.notice-link {
display: inline-block;
margin-top: 8px;
color: var(--accent);
text-decoration: underline;
}
.info-btn {
width: 30px;
height: 30px;
padding: 0;
border: 1px solid color-mix(in srgb, var(--border) 60%, var(--text) 20%);
border-radius: 10px;
font-size: 1rem;
color: var(--text);
background: var(--card-overlay);
line-height: 1;
}
.status-dot {
width: 10px;
height: 10px;
border-radius: 50%;
background: #e11d48;
box-shadow: 0 0 8px rgba(225, 29, 72, 0.5);
}
.status-dot.on {
background: #22c55e;
box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}
html[data-anim="on"] .status-dot.on {
animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
0% {
box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.35);
}
70% {
box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
}
}
.status-dot.off {
background: #f87171;
box-shadow: 0 0 8px rgba(248, 113, 113, 0.5);
}
.service-header {
display: grid;
grid-template-columns: auto minmax(0, 1fr) auto auto;
align-items: center;
gap: 8px;
width: 100%;
}
.service-header .pill {
min-width: 0;
max-width: 100%;
}
.service-header .status-dot,
.service-header .menu-btn,
.service-header .notice-pill {
justify-self: start;
}
.service-header .menu-btn {
justify-self: end;
}
#servicesGrid {
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.log-card {
background: var(--panel);
border: 1px solid var(--border);
border-radius: 10px;
padding: 10px;
margin-top: 12px;
}
.log-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 6px;
}
.log-actions {
display: flex;
align-items: center;
gap: 8px;
}
.log-actions .icon-btn {
width: 32px;
height: 32px;
padding: 0;
font-size: 0.9rem;
background: var(--card-overlay);
border: 1px solid var(--border);
}
.log-box {
max-height: 140px;
overflow-y: auto;
background: rgba(0, 0, 0, 0.08);
border-radius: 6px;
padding: 10px;
font-family: "DM Sans", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 0.9rem;
border: 1px dashed var(--border);
color: var(--muted);
white-space: pre-wrap;
}
:root[data-theme="light"] .log-box {
background: rgba(12, 18, 32, 0.04);
}
.codeblock {
background: var(--input-bg);
padding: 10px;
border-radius: 10px;
max-width: 440px;
min-width: 260px;
border: 1px solid var(--border);
white-space: pre-wrap;
word-break: break-all;
}

View File

@@ -0,0 +1,272 @@
.modal {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.55);
display: grid;
place-items: center;
opacity: 0;
pointer-events: none;
transition: opacity 0.18s ease;
z-index: 20;
}
.modal#changelogModal {
z-index: 40;
}
.modal.hidden {
display: none;
}
.modal:not(.hidden) {
opacity: 1;
pointer-events: auto;
}
.modal-card {
background: var(--panel);
border: 1px solid var(--border);
padding: 18px;
border-radius: 14px;
min-width: 300px;
max-width: 420px;
transform: translateY(6px) scale(0.99);
transition:
transform 0.18s ease,
box-shadow 0.18s ease;
}
.modal-card.wide {
max-width: 820px;
width: 90vw;
max-height: 90vh;
overflow-y: auto;
position: relative;
padding: 12px;
}
.modal-card.wide .panel-header {
position: sticky;
top: 0;
z-index: 3;
margin: 0 0 12px;
padding: 18px 18px 12px;
background: var(--panel);
border-bottom: 1px solid var(--border);
}
.modal-card.wide .help-body,
.modal-card.wide .controls {
padding: 0 12px 12px;
}
.modal-card.wide .control-card {
padding: 12px 14px;
}
/* Extra breathing room for custom add-service modal */
#addServiceModal .modal-card {
padding: 18px 18px 16px;
}
#addServiceModal .controls {
padding: 0 2px 4px;
}
/* Busy overlay already defined; ensure modal width for release modal */
#releaseModal .modal-card.wide {
max-width: 760px;
}
.release-versions {
display: flex;
gap: 16px;
align-items: flex-start;
justify-content: space-between;
}
.release-versions > div {
flex: 1;
min-width: 0;
}
.release-versions .align-right {
text-align: right;
}
.modal-card .status-msg {
overflow-wrap: anywhere;
margin-top: 6px;
}
.modal:not(.hidden) .modal-card {
transform: translateY(0) scale(1);
}
.modal-card .close-btn {
min-width: 0;
width: 36px;
height: 36px;
font-size: 1rem;
line-height: 1;
padding: 0;
}
.config-list {
display: flex;
flex-direction: column;
gap: 12px;
}
.config-row {
border: 1px solid var(--border);
border-radius: 12px;
padding: 12px;
display: flex;
justify-content: space-between;
gap: 12px;
flex-wrap: wrap;
align-items: center;
}
.config-row.danger {
border-color: #ef4444;
}
.modal-actions {
margin-top: 14px;
display: flex;
align-items: center;
justify-content: flex-end;
gap: 10px;
}
.modal-actions .push {
flex: 1;
}
.modal-actions .primary {
background: linear-gradient(135deg, #16d0d8, #59e693);
color: #0c0f17;
border: none;
padding: 10px 14px;
border-radius: 10px;
font-weight: 600;
}
.config-label h4 {
margin: 0 0 4px;
}
.config-controls {
display: flex;
gap: 10px;
align-items: center;
flex-wrap: wrap;
}
.config-controls textarea {
width: 100%;
resize: vertical;
min-height: 96px;
}
.config-controls input[type="text"],
.config-controls input[type="number"],
.config-controls select {
width: 100%;
max-width: 100%;
}
.overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.6);
display: grid;
place-items: center;
z-index: 50;
}
.overlay.hidden {
display: none;
}
.overlay-box {
background: var(--panel);
border: 1px solid var(--border);
padding: 20px;
border-radius: 14px;
max-width: 420px;
text-align: center;
box-shadow: var(--shadow);
}
.spinner {
margin: 12px auto 4px;
width: 32px;
height: 32px;
border: 4px solid rgba(255, 255, 255, 0.2);
border-top-color: var(--accent);
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
.modal-actions button {
min-width: 100px;
}
.help-body h4 {
margin: 10px 0 6px;
}
.help-body ul {
margin: 0 0 12px 18px;
padding: 0;
color: var(--text);
}
.help-body ul a {
color: var(--accent);
text-decoration: underline;
}
.help-body li {
margin: 4px 0;
}
.danger {
border-color: #ef4444;
}
.modal-card label {
display: block;
margin-top: 10px;
color: var(--muted);
font-size: 0.95rem;
}
.modal-card input {
width: 100%;
margin-top: 4px;
}
.modal-card.wide pre.log-box {
max-height: 60vh;
}
#releaseModal pre.log-box {
max-height: 220px !important;
min-height: 220px;
overflow-y: auto;
}
#diagModal pre.log-box {
max-height: 60vh;
min-height: 300px;
}

View File

@@ -0,0 +1,57 @@
/* Motion (opt-out via data-anim="off") */
html[data-anim="on"] .card,
html[data-anim="on"] .stat,
html[data-anim="on"] button,
html[data-anim="on"] .accordion,
html[data-anim="on"] .modal-card {
transition:
transform 0.18s ease,
box-shadow 0.18s ease,
border-color 0.18s ease,
background-color 0.18s ease;
}
html[data-anim="on"] .card:hover {
transform: translateY(-2px);
box-shadow: 0 14px 26px rgba(0, 0, 0, 0.12);
}
html[data-anim="on"][data-theme="light"] .card:hover {
box-shadow: 0 14px 26px rgba(12, 18, 32, 0.12);
}
html[data-anim="on"] button:hover {
transform: translateY(-1px);
box-shadow: var(--shadow);
}
html[data-anim="on"] button:active {
transform: translateY(1px);
}
html[data-anim="off"] .card,
html[data-anim="off"] .stat,
html[data-anim="off"] button,
html[data-anim="off"] .accordion,
html[data-anim="off"] .modal-card {
transition: none;
}
/* Hard-stop any remaining motion (spinners, keyframes, incidental transitions) */
html[data-anim="off"] *,
html[data-anim="off"] *::before,
html[data-anim="off"] *::after {
animation: none !important;
transition: none !important;
}
/* Focus states */
button:focus-visible,
input:focus-visible,
select:focus-visible,
.card:focus-visible,
.status-chip:focus-visible,
.accordion-toggle:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}

View File

@@ -0,0 +1,88 @@
@media (min-width: 1180px) {
#servicesGrid {
grid-template-columns: repeat(3, 1fr);
}
}
@media (max-width: 560px) {
#servicesGrid {
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
}
@media (max-width: 960px) {
.hero {
grid-template-columns: 1fr;
}
.layout {
padding: 24px 14px 60px;
}
.panel {
padding: 16px;
}
.grid {
gap: 10px;
}
.card {
padding: 12px;
}
.hero-stats {
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
}
@media (max-width: 640px) {
.release-versions {
flex-direction: column;
gap: 8px;
}
.release-versions .align-right {
text-align: left;
}
}
@media (max-width: 760px) {
.topbar {
flex-direction: column;
align-items: stretch;
gap: 10px;
padding: 12px 16px;
}
.brand {
justify-content: flex-start;
}
.top-actions {
width: 100%;
justify-content: flex-start;
gap: 8px;
}
.top-actions .ghost {
padding: 8px 10px;
}
.top-indicators {
width: 100%;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
gap: 8px;
align-items: center;
}
.top-indicators .chip-label {
grid-column: 1 / -1;
margin-right: 0;
font-size: 0.8rem;
}
.top-indicators .status-chip,
.top-indicators .hint {
width: auto;
justify-self: flex-start;
}
}
@media (max-width: 820px) {
.hero {
grid-template-columns: 1fr;
}
.hero-stats {
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
}

View File

@@ -0,0 +1,117 @@
:root {
--bg: #0f1117;
--panel: #161a23;
--panel-overlay: rgba(255, 255, 255, 0.02);
--card-overlay: rgba(255, 255, 255, 0.03);
--muted: #9ca3af;
--text: #e5e7eb;
--accent: #7dd3fc;
--accent-2: #22c55e;
--warning: #f59e0b;
--border: #1f2430;
--shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
--topbar-bg: rgba(15, 17, 23, 0.8);
--toggle-track: #374151;
--input-bg: #0c0e14;
--input-border: var(--border);
--disabled-bg: #141a22;
--disabled-border: #2a313c;
--disabled-text: #7c8696;
--disabled-strong: #0b0f18;
--input-disabled-bg: #141a22;
--input-disabled-text: #7c8696;
--input-disabled-border: #2a313c;
--font-body: "Red Hat Text", "Inter", "Segoe UI", system-ui, -apple-system,
sans-serif;
--font-heading: "Red Hat Display", "Red Hat Text", system-ui, -apple-system,
sans-serif;
font-family: var(--font-body);
}
:root[data-font="space"] {
--font-body: "Space Grotesk", "Inter", "Segoe UI", system-ui, -apple-system,
sans-serif;
--font-heading: "Space Grotesk", "Red Hat Text", system-ui, -apple-system,
sans-serif;
}
:root[data-font="manrope"] {
--font-body: "Manrope", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
--font-heading: "Manrope", "Manrope", system-ui, -apple-system, sans-serif;
}
:root[data-font="dmsans"] {
--font-body: "DM Sans", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
--font-heading: "DM Sans", "Red Hat Display", system-ui, -apple-system, sans-serif;
}
:root[data-font="sora"] {
--font-body: "Sora", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
--font-heading: "Sora", "Sora", system-ui, -apple-system, sans-serif;
}
:root[data-font="chivo"] {
--font-body: "Chivo", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
--font-heading: "Chivo", "Chivo", system-ui, -apple-system, sans-serif;
}
:root[data-font="atkinson"] {
--font-body: "Atkinson Hyperlegible", "Inter", "Segoe UI", system-ui, -apple-system,
sans-serif;
--font-heading: "Atkinson Hyperlegible", "Atkinson Hyperlegible", system-ui,
-apple-system, sans-serif;
}
:root[data-font="plex"] {
--font-body: "IBM Plex Sans", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
--font-heading: "IBM Plex Sans", "IBM Plex Sans", system-ui, -apple-system, sans-serif;
}
:root[data-theme="light"] {
--bg: #dfe4ee;
--panel: #f6f8fd;
--panel-overlay: rgba(10, 12, 18, 0.06);
--card-overlay: rgba(10, 12, 18, 0.11);
--muted: #4b5563;
--text: #0b1224;
--accent: #0077c2;
--accent-2: #15803d;
--warning: #b45309;
--border: #bcc5d6;
--shadow: 0 12px 30px rgba(12, 18, 32, 0.12);
--topbar-bg: rgba(249, 251, 255, 0.92);
--toggle-track: #d1d5db;
--input-bg: #f0f2f7;
--input-border: #c5ccd9;
--disabled-bg: #f4f6fb;
--disabled-border: #c8d0df;
--disabled-text: #7a8292;
--disabled-strong: #eef1f7;
--input-disabled-bg: #f8fafc;
--input-disabled-text: #6a6f7b;
--input-disabled-border: #c9d1df;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
background:
radial-gradient(
circle at 20% 20%,
rgba(125, 211, 252, 0.08),
transparent 32%
),
radial-gradient(circle at 80% 0%, rgba(34, 197, 94, 0.06), transparent 28%),
linear-gradient(180deg, #0f1117 0%, #0e1119 55%, #0b0f15 100%);
background-attachment: fixed;
background-repeat: no-repeat;
color: var(--text);
line-height: 1.5;
transition: background 240ms ease, color 240ms ease;
}
:root[data-theme="light"] body {
background:
radial-gradient(
circle at 25% 18%,
rgba(0, 119, 194, 0.14),
transparent 34%
),
radial-gradient(circle at 78% 8%, rgba(21, 128, 61, 0.12), transparent 30%),
linear-gradient(180deg, #f6f8fd 0%, #e8edf7 52%, #d6dde9 100%);
background-attachment: fixed;
background-repeat: no-repeat;
}

View File

@@ -0,0 +1,204 @@
.toast-container {
position: fixed;
bottom: 16px;
left: 50%;
transform: translateX(-50%);
z-index: 40;
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: center;
gap: 10px;
pointer-events: none;
}
.toast {
min-width: 200px;
max-width: 320px;
max-height: 240px;
overflow: hidden;
padding: 10px 12px;
border-radius: 10px;
border: 1px solid var(--border);
background: var(--panel);
color: var(--text);
box-shadow: var(--shadow);
font-weight: 600;
pointer-events: auto;
opacity: 0;
transform: translateY(var(--toast-slide-offset, 14px));
transition:
opacity var(--toast-speed, 0.28s) ease,
transform var(--toast-speed, 0.28s) ease,
max-height var(--toast-speed, 0.28s) ease,
padding var(--toast-speed, 0.28s) ease,
margin var(--toast-speed, 0.28s) ease;
}
.toast.show {
opacity: 1;
transform: translateY(0);
}
.toast.success {
border-color: rgba(34, 197, 94, 0.5);
}
.toast.warn {
border-color: rgba(217, 119, 6, 0.5);
}
.toast.error {
border-color: rgba(225, 29, 72, 0.6);
}
.toast.info {
border-color: rgba(125, 211, 252, 0.4);
}
html[data-anim="off"] .toast {
transition: none !important;
}
.toast.anim-slide-in {
transform: translate(var(--toast-slide-x, 0px), var(--toast-slide-y, 24px));
opacity: 0;
}
.toast.anim-slide-in.show {
transform: translate(0, 0);
opacity: 1;
}
.toast.anim-fade {
transform: none;
opacity: 0;
}
.toast.anim-fade.show {
opacity: 1;
}
.toast.anim-pop {
transform: scale(0.9);
opacity: 0;
}
.toast.anim-pop.show {
transform: scale(1);
opacity: 1;
}
.toast.anim-bounce {
opacity: 0;
transform: translateY(calc(var(--toast-dir, 1) * 20px));
}
.toast.anim-bounce.show {
opacity: 1;
animation: toast-bounce var(--toast-speed, 0.46s) cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.toast.anim-drop {
opacity: 0;
transform: translateY(calc(var(--toast-dir, 1) * -24px)) scale(0.98);
}
.toast.anim-drop.show {
transform: translateY(0) scale(1);
opacity: 1;
}
.toast.anim-grow {
transform: scale(0.85);
opacity: 0;
}
.toast.anim-grow.show {
transform: scale(1);
opacity: 1;
}
.toast.leaving {
opacity: 0 !important;
transform: translateY(12px) !important;
max-height: 0 !important;
margin: 0 !important;
padding-top: 0 !important;
padding-bottom: 0 !important;
}
@keyframes toast-bounce {
0% {
opacity: 0;
transform: translateY(calc(var(--toast-dir, 1) * 20px)) scale(0.96);
}
55% {
opacity: 1;
transform: translateY(calc(var(--toast-dir, 1) * -8px)) scale(1.03);
}
100% {
opacity: 1;
transform: translateY(0) scale(1);
}
}
.toast-container.pos-bottom-center {
bottom: 16px;
left: 50%;
right: auto;
top: auto;
transform: translateX(-50%);
flex-direction: column-reverse;
align-items: center;
}
.toast-container.pos-bottom-right {
bottom: 16px;
right: 16px;
left: auto;
top: auto;
transform: none;
flex-direction: column-reverse;
align-items: flex-end;
}
.toast-container.pos-bottom-left {
bottom: 16px;
left: 16px;
right: auto;
top: auto;
transform: none;
flex-direction: column-reverse;
align-items: flex-start;
}
.toast-container.pos-top-right {
top: 16px;
right: 16px;
bottom: auto;
left: auto;
transform: none;
flex-direction: column;
align-items: flex-end;
}
.toast-container.pos-top-left {
top: 16px;
left: 16px;
bottom: auto;
right: auto;
transform: none;
flex-direction: column;
align-items: flex-start;
}
.toast-container.pos-top-center {
top: 16px;
left: 50%;
right: auto;
bottom: auto;
transform: translateX(-50%);
flex-direction: column;
align-items: center;
}

View File

@@ -0,0 +1,126 @@
.topbar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 14px 22px;
border-bottom: 1px solid var(--border);
backdrop-filter: blur(10px);
position: sticky;
top: 0;
z-index: 10;
background: var(--topbar-bg);
}
.brand {
display: flex;
align-items: center;
gap: 10px;
font-weight: 700;
letter-spacing: 0.3px;
font-family: var(--font-heading);
}
.brand .dot {
width: 12px;
height: 12px;
border-radius: 50%;
background: linear-gradient(135deg, #22c55e, #7dd3fc);
box-shadow: 0 0 10px rgba(125, 211, 252, 0.6);
cursor: help;
}
.top-actions {
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
justify-content: flex-end;
}
.top-indicators {
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
}
.chip-label {
font-size: 0.85rem;
color: var(--muted);
margin-right: 4px;
}
.status-chip {
padding: 6px 12px;
border-radius: 999px;
border: 1px solid var(--border);
color: var(--muted);
font-size: 0.9rem;
background: rgba(0, 0, 0, 0.06);
}
.status-chip.quiet {
opacity: 0.75;
font-size: 0.85rem;
background: rgba(0, 0, 0, 0.04);
}
.status-chip.chip-on {
color: var(--accent-2);
border-color: rgba(22, 163, 74, 0.4);
background: rgba(22, 163, 74, 0.08);
}
.status-chip.chip-off {
color: #e11d48;
border-color: rgba(225, 29, 72, 0.4);
background: rgba(225, 29, 72, 0.08);
}
.status-chip.chip-system {
color: #3b82f6;
border-color: rgba(59, 130, 246, 0.45);
background: rgba(59, 130, 246, 0.12);
}
.status-chip.chip-warm {
color: #d97706;
border-color: rgba(217, 119, 6, 0.35);
background: rgba(217, 119, 6, 0.12);
}
:root[data-theme="light"] .status-chip {
background: rgba(12, 18, 32, 0.06);
border-color: rgba(12, 18, 32, 0.14);
color: #1f2a3d;
}
:root[data-theme="light"] .status-chip.quiet {
background: rgba(12, 18, 32, 0.05);
color: #243247;
opacity: 0.92;
}
:root[data-theme="light"] .status-chip.chip-on {
background: rgba(34, 197, 94, 0.16);
border-color: rgba(34, 197, 94, 0.5);
color: #0f5132;
}
:root[data-theme="light"] .status-chip.chip-system {
background: rgba(59, 130, 246, 0.16);
border-color: rgba(59, 130, 246, 0.55);
color: #153e9f;
}
:root[data-theme="light"] .status-chip.chip-warm {
background: rgba(217, 119, 6, 0.16);
border-color: rgba(217, 119, 6, 0.5);
color: #8a4b08;
}
:root[data-theme="light"] .status-chip.chip-off {
background: rgba(225, 29, 72, 0.18);
border-color: rgba(225, 29, 72, 0.55);
color: #7a1028;
}

View File

@@ -0,0 +1,152 @@
#releaseProgress {
display: none;
}
.updates-status {
display: none;
}
.updates-status.error {
display: block;
}
#acc-updates .accordion-body {
display: flex;
flex-direction: column;
gap: 6px;
padding: 8px 12px 2px !important;
}
#updatesSection {
width: 100%;
gap: 4px;
margin-bottom: 0;
}
#updatesControls {
display: flex;
flex-direction: column;
gap: 6px;
margin: 0;
padding: 0;
width: 100%;
}
#updatesControls.is-disabled {
opacity: 0.6;
background: var(--disabled-bg);
border: 1px dashed var(--disabled-border);
border-radius: 8px;
padding: 6px;
}
#updatesControls.is-disabled * {
pointer-events: none;
}
#updatesControls input:disabled,
#updatesControls select:disabled,
#updatesControls textarea:disabled {
background: var(--input-disabled-bg);
color: var(--input-disabled-text);
border-color: var(--input-disabled-border);
}
#updatesControls .checkbox-row input:disabled + span,
#updatesControls label,
#updatesControls .field > span,
#updatesControls .hint {
color: var(--disabled-text);
}
#updatesControls .control-actions,
#updatesControls .field {
opacity: 0.9;
}
#updatesControls .toggle .slider {
filter: grayscale(0.9);
}
/* Disabled styling scoped to updates section */
#updatesControls.is-disabled input,
#updatesControls.is-disabled select,
#updatesControls.is-disabled textarea {
background: var(--input-disabled-bg);
color: var(--input-disabled-text);
border-color: var(--input-disabled-border);
box-shadow: none;
}
#updatesControls.is-disabled .checkbox-row span,
#updatesControls.is-disabled label,
#updatesControls.is-disabled .field > span,
#updatesControls.is-disabled .hint {
color: var(--disabled-text);
}
#updatesControls.is-disabled .control-actions,
#updatesControls.is-disabled .field {
opacity: 0.9;
}
#updatesControls.is-disabled .toggle .slider {
filter: grayscale(0.8);
}
/* Light theme contrast for disabled controls */
:root[data-theme="light"] #updatesSection {
background: #f7f9fd;
border: 1px solid #d9dfeb;
border-radius: 10px;
padding: 8px 10px;
}
:root[data-theme="light"] #updatesControls {
gap: 8px;
}
:root[data-theme="light"] #updatesControls.is-disabled {
opacity: 1;
background: var(--disabled-bg);
border: 1px dashed var(--disabled-border);
border-radius: 8px;
padding: 6px;
}
:root[data-theme="light"] #updatesControls.is-disabled * {
pointer-events: none;
}
:root[data-theme="light"] #updatesControls.is-disabled input,
:root[data-theme="light"] #updatesControls.is-disabled select,
:root[data-theme="light"] #updatesControls.is-disabled textarea {
background: var(--input-disabled-bg) !important;
color: var(--input-disabled-text) !important;
border: 1px dashed var(--disabled-border) !important;
box-shadow: none !important;
}
:root[data-theme="light"] #updatesControls.is-disabled .checkbox-row input:disabled + span,
:root[data-theme="light"] #updatesControls.is-disabled label,
:root[data-theme="light"] #updatesControls.is-disabled .field > span,
:root[data-theme="light"] #updatesControls.is-disabled .hint {
color: var(--disabled-text) !important;
}
:root[data-theme="light"] #updatesControls.is-disabled .control-actions,
:root[data-theme="light"] #updatesControls.is-disabled .field {
opacity: 1;
}
:root[data-theme="light"] #updatesControls.is-disabled .toggle .slider {
filter: grayscale(0.2);
}
#updatesControls .form-grid {
margin: 0;
}
#updatesControls .control-actions.split-row {
margin: 0;
}

View File

@@ -93,22 +93,22 @@ export async function initDiagUI({ elements, toast }) {
if (statusEl) statusEl.textContent = `${merged.length} entries`;
}
async function refresh() {
async function refresh({ silent = false } = {}) {
if (loading) return;
setBusy(true);
try {
const entries = await syncState();
render(entries);
toast?.("Diagnostics refreshed", "success");
if (!silent) toast?.("Diagnostics refreshed", "success");
} catch (e) {
toast?.(e.error || "Failed to load diagnostics", "error");
if (!silent) toast?.(e.error || "Failed to load diagnostics", "error");
// retry once if failed
try {
const entries = await syncState();
render(entries);
toast?.("Diagnostics refreshed (after retry)", "success");
if (!silent) toast?.("Diagnostics refreshed (after retry)", "success");
} catch (err2) {
toast?.(err2.error || "Diagnostics still failing", "error");
if (!silent) toast?.(err2.error || "Diagnostics still failing", "error");
}
} finally {
setBusy(false);
@@ -207,7 +207,7 @@ export async function initDiagUI({ elements, toast }) {
// initial load
attachClickTracker();
await refresh();
await refresh({ silent: true });
logButton?.addEventListener("click", () => {
if (!uiEnabled) return;

View File

@@ -1,12 +1,21 @@
// Entry point for the dashboard: wires UI events, pulls status, and initializes
// feature modules (services, settings, stats).
import { getStatus, triggerReset } from "./api.js";
import { initServiceControls } from "./services.js";
import { placeholderStatus, renderStats } from "./status.js";
import { initServiceControls, renderServices } from "./services.js";
import { initSettings } from "./settings.js";
import { initUpdateSettings, isUpdatesDirty } from "./update-settings.js";
import { initReleaseUI } from "./releases.js?v=20251213h";
import { initDiagUI, logUi } from "./diaglog.js?v=20251213j";
import { createToastManager } from "./toast.js?v=20251213a";
import {
applyTooltips,
wireModalPairs,
wireAccordions,
createBusyOverlay,
createConfirmModal,
} from "./ui.js";
import { createStatusController } from "./status-controller.js";
const servicesGrid = document.getElementById("servicesGrid");
const heroStats = document.getElementById("heroStats");
@@ -32,6 +41,7 @@ const toastPosSelect = document.getElementById("toastPosSelect");
const toastAnimSelect = document.getElementById("toastAnimSelect");
const toastSpeedInput = document.getElementById("toastSpeedInput");
const toastDurationInput = document.getElementById("toastDurationInput");
const toastTestBtn = document.getElementById("toastTestBtn");
const fontSelect = document.getElementById("fontSelect");
const updatesScope = document.getElementById("updatesScope");
const updateTimeInput = document.getElementById("updateTimeInput");
@@ -111,194 +121,141 @@ const diagModal = document.getElementById("diagModal");
const diagClose = document.getElementById("diagClose");
const diagStatusModal = document.getElementById("diagStatusModal");
const TOAST_POS_KEY = "pikit-toast-pos";
const TOAST_ANIM_KEY = "pikit-toast-anim";
const TOAST_SPEED_KEY = "pikit-toast-speed";
const TOAST_DURATION_KEY = "pikit-toast-duration";
const FONT_KEY = "pikit-font";
const ALLOWED_TOAST_POS = [
"bottom-center",
"bottom-right",
"bottom-left",
"top-right",
"top-left",
"top-center",
];
const ALLOWED_TOAST_ANIM = ["slide-in", "fade", "pop", "bounce", "drop", "grow"];
const ALLOWED_FONTS = ["redhat", "space", "manrope", "dmsans", "sora", "chivo", "atkinson", "plex"];
let toastPosition = "bottom-center";
let toastAnimation = "slide-in";
let toastDurationMs = 5000;
let toastSpeedMs = 300;
let fontChoice = "redhat";
const toastController = createToastManager({
container: toastContainer,
posSelect: toastPosSelect,
animSelect: toastAnimSelect,
speedInput: toastSpeedInput,
durationInput: toastDurationInput,
fontSelect,
testBtn: toastTestBtn,
});
const showToast = toastController.showToast;
let releaseUI = null;
let lastStatusData = null;
const { showBusy, hideBusy } = createBusyOverlay({
overlay: busyOverlay,
titleEl: busyTitle,
textEl: busyText,
});
const confirmAction = createConfirmModal({
modal: confirmModal,
titleEl: confirmTitle,
bodyEl: confirmBody,
okBtn: confirmOk,
cancelBtn: confirmCancel,
});
const collapseAccordions = () => document.querySelectorAll(".accordion").forEach((a) => a.classList.remove("open"));
function applyToastSettings() {
if (!toastContainer) return;
toastContainer.className = `toast-container pos-${toastPosition}`;
document.documentElement.style.setProperty("--toast-speed", `${toastSpeedMs}ms`);
const dir = toastPosition.startsWith("top") ? -1 : 1;
const isLeft = toastPosition.includes("left");
const isRight = toastPosition.includes("right");
const slideX = isLeft ? -26 : isRight ? 26 : 0;
const slideY = isLeft || isRight ? 0 : dir * 24;
document.documentElement.style.setProperty("--toast-slide-offset", `${dir * 24}px`);
document.documentElement.style.setProperty("--toast-dir", `${dir}`);
document.documentElement.style.setProperty("--toast-slide-x", `${slideX}px`);
document.documentElement.style.setProperty("--toast-slide-y", `${slideY}px`);
if (toastDurationInput) toastDurationInput.value = toastDurationMs;
}
const statusController = createStatusController({
heroStats,
servicesGrid,
updatesFlagTop,
updatesNoteTop,
tempFlagTop,
readyOverlay,
logUi,
getStatus,
isUpdatesDirty,
setUpdatesUI,
updatesFlagEl: setUpdatesFlag,
releaseUIGetter: () => releaseUI,
onReadyWait: () => setTimeout(() => statusController.loadStatus(), 3000),
});
const { loadStatus } = statusController;
function applyFontSetting() {
document.documentElement.setAttribute("data-font", fontChoice);
if (fontSelect) fontSelect.value = fontChoice;
}
function loadToastSettings() {
try {
const posSaved = localStorage.getItem(TOAST_POS_KEY);
if (ALLOWED_TOAST_POS.includes(posSaved)) toastPosition = posSaved;
const animSaved = localStorage.getItem(TOAST_ANIM_KEY);
const migrated =
animSaved === "slide-up" || animSaved === "slide-left" || animSaved === "slide-right"
? "slide-in"
: animSaved;
if (migrated && ALLOWED_TOAST_ANIM.includes(migrated)) toastAnimation = migrated;
const savedSpeed = Number(localStorage.getItem(TOAST_SPEED_KEY));
if (!Number.isNaN(savedSpeed) && savedSpeed >= 100 && savedSpeed <= 3000) {
toastSpeedMs = savedSpeed;
function wireDialogs() {
wireModalPairs([
{ openBtn: aboutBtn, modal: aboutModal, closeBtn: aboutClose },
{ openBtn: helpBtn, modal: helpModal, closeBtn: helpClose },
]);
// Settings modal keeps custom accordion collapse on close
advBtn?.addEventListener("click", () => {
if (window.__pikitTest?.forceServiceFormVisible) {
// For tests: avoid opening any modal; just ensure form controls are visible
addServiceModal?.classList.add("hidden");
addServiceModal?.setAttribute("style", "display:none;");
window.__pikitTest.forceServiceFormVisible();
return;
}
const savedDur = Number(localStorage.getItem(TOAST_DURATION_KEY));
if (!Number.isNaN(savedDur) && savedDur >= 1000 && savedDur <= 15000) {
toastDurationMs = savedDur;
}
const savedFont = localStorage.getItem(FONT_KEY);
if (ALLOWED_FONTS.includes(savedFont)) fontChoice = savedFont;
} catch (e) {
console.warn("Toast settings load failed", e);
}
if (toastPosSelect) toastPosSelect.value = toastPosition;
if (toastAnimSelect) toastAnimSelect.value = toastAnimation;
if (toastSpeedInput) toastSpeedInput.value = toastSpeedMs;
if (toastDurationInput) toastDurationInput.value = toastDurationMs;
if (fontSelect) fontSelect.value = fontChoice;
applyToastSettings();
applyFontSetting();
}
function persistToastSettings() {
try {
localStorage.setItem(TOAST_POS_KEY, toastPosition);
localStorage.setItem(TOAST_ANIM_KEY, toastAnimation);
localStorage.setItem(TOAST_SPEED_KEY, String(toastSpeedMs));
localStorage.setItem(TOAST_DURATION_KEY, String(toastDurationMs));
localStorage.setItem(FONT_KEY, fontChoice);
} catch (e) {
console.warn("Toast settings save failed", e);
}
}
function showToast(message, type = "info") {
if (!toastContainer || !message) return;
const t = document.createElement("div");
t.className = `toast ${type} anim-${toastAnimation}`;
t.textContent = message;
toastContainer.appendChild(t);
const animOn = document.documentElement.getAttribute("data-anim") !== "off";
if (!animOn) {
t.classList.add("show");
} else {
requestAnimationFrame(() => t.classList.add("show"));
}
const duration = toastDurationMs;
setTimeout(() => {
const all = Array.from(toastContainer.querySelectorAll(".toast"));
const others = all.filter((el) => el !== t && !el.classList.contains("leaving"));
const first = new Map(
others.map((el) => [el, el.getBoundingClientRect()]),
);
t.classList.add("leaving");
// force layout
void t.offsetHeight;
requestAnimationFrame(() => {
const second = new Map(
others.map((el) => [el, el.getBoundingClientRect()]),
);
others.forEach((el) => {
const dy = first.get(el).top - second.get(el).top;
if (Math.abs(dy) > 0.5) {
el.style.transition = "transform var(--toast-speed, 0.28s) ease";
el.style.transform = `translateY(${dy}px)`;
requestAnimationFrame(() => {
el.style.transform = "";
});
}
});
});
const removeDelay = animOn ? toastSpeedMs : 0;
setTimeout(() => {
t.classList.remove("show");
t.remove();
// clear transition styling
others.forEach((el) => (el.style.transition = ""));
}, removeDelay);
}, duration);
}
function applyTooltips() {
const tips = {
updatesFlagTop: "Auto updates status; configure in Settings → Automatic updates.",
refreshFlagTop: "Auto-refresh interval; change in Settings → Refresh interval.",
tempFlagTop: "CPU temperature status; see details in the hero stats below.",
releaseFlagTop: "Pi-Kit release status; open Settings → Updates to install.",
themeToggle: "Toggle light or dark theme",
helpBtn: "Open quick help",
advBtn: "Open settings",
animToggle: "Enable or disable dashboard animations",
refreshIntervalInput: "Seconds between automatic refreshes (5-120)",
refreshIntervalSave: "Save refresh interval",
svcName: "Display name for the service card",
svcPort: "Port number the service listens on",
svcPath: "Optional path like /admin",
svcScheme: "Choose HTTP or HTTPS link",
svcSelfSigned: "Mark service as using a self-signed certificate",
svcNotice: "Optional note shown on the service card",
svcNoticeLink: "Optional link for more info about the service",
svcAddBtn: "Add the service to the dashboard",
updatesToggle: "Turn unattended upgrades on or off",
updatesScope: "Select security-only or all updates",
updateTimeInput: "Time to download updates (24h)",
upgradeTimeInput: "Time to install updates (24h)",
updatesCleanup: "Remove unused dependencies after upgrades",
updatesBandwidth: "Limit download bandwidth in KB/s (0 = unlimited)",
updatesRebootToggle: "Auto-reboot if required by updates",
updatesRebootTime: "Scheduled reboot time when auto-reboot is on",
updatesRebootUsers: "Allow reboot even if users are logged in",
updatesSaveBtn: "Save unattended-upgrades settings",
resetConfirm: "Type YES to enable factory reset",
resetBtn: "Factory reset this Pi-Kit",
menuRename: "Change the service display name",
menuPort: "Change the service port",
menuPath: "Optional service path",
menuScheme: "Switch between HTTP and HTTPS",
menuSelfSigned: "Mark the service as self-signed",
menuNotice: "Edit the notice text shown on the card",
menuNoticeLink: "Optional link for the notice",
menuSaveBtn: "Save service changes",
menuCancelBtn: "Cancel changes",
menuRemoveBtn: "Remove this service",
};
Object.entries(tips).forEach(([id, text]) => {
const el = document.getElementById(id);
if (el) el.title = text;
advModal.classList.remove("hidden");
});
advClose?.addEventListener("click", () => {
advModal.classList.add("hidden");
collapseAccordions();
});
menuClose.onclick = () => menuModal.classList.add("hidden");
addServiceOpen?.addEventListener("click", openAddService);
addSvcClose?.addEventListener("click", () => addServiceModal?.classList.add("hidden"));
addServiceModal?.addEventListener("click", (e) => {
if (e.target === addServiceModal) addServiceModal.classList.add("hidden");
});
}
// Testing hook
if (typeof window !== "undefined") {
window.__pikitTest = window.__pikitTest || {};
window.__pikitTest.showBusy = showBusy;
window.__pikitTest.hideBusy = hideBusy;
window.__pikitTest.exposeServiceForm = () => {
if (!addServiceModal) return;
const card = addServiceModal.querySelector(".modal-card");
if (!card) return;
addServiceModal.classList.add("hidden"); // keep overlay out of the way
card.style.position = "static";
card.style.background = "transparent";
card.style.boxShadow = "none";
card.style.border = "none";
card.style.padding = "0";
card.style.margin = "12px auto";
card.style.maxWidth = "720px";
// Move the form inline so Playwright can see it without the overlay
document.body.appendChild(card);
};
}
const TOOLTIP_MAP = {
updatesFlagTop: "Auto updates status; configure in Settings → Automatic updates.",
refreshFlagTop: "Auto-refresh interval; change in Settings → Refresh interval.",
tempFlagTop: "CPU temperature status; see details in the hero stats below.",
releaseFlagTop: "Pi-Kit release status; open Settings → Updates to install.",
themeToggle: "Toggle light or dark theme",
helpBtn: "Open quick help",
advBtn: "Open settings",
animToggle: "Enable or disable dashboard animations",
refreshIntervalInput: "Seconds between automatic refreshes (5-120)",
refreshIntervalSave: "Save refresh interval",
svcName: "Display name for the service card",
svcPort: "Port number the service listens on",
svcPath: "Optional path like /admin",
svcScheme: "Choose HTTP or HTTPS link",
svcSelfSigned: "Mark service as using a self-signed certificate",
svcNotice: "Optional note shown on the service card",
svcNoticeLink: "Optional link for more info about the service",
svcAddBtn: "Add the service to the dashboard",
updatesToggle: "Turn unattended upgrades on or off",
updatesScope: "Select security-only or all updates",
updateTimeInput: "Time to download updates (24h)",
upgradeTimeInput: "Time to install updates (24h)",
updatesCleanup: "Remove unused dependencies after upgrades",
updatesBandwidth: "Limit download bandwidth in KB/s (0 = unlimited)",
updatesRebootToggle: "Auto-reboot if required by updates",
updatesRebootTime: "Scheduled reboot time when auto-reboot is on",
updatesRebootUsers: "Allow reboot even if users are logged in",
updatesSaveBtn: "Save unattended-upgrades settings",
resetConfirm: "Type YES to enable factory reset",
resetBtn: "Factory reset this Pi-Kit",
menuRename: "Change the service display name",
menuPort: "Change the service port",
menuPath: "Optional service path",
menuScheme: "Switch between HTTP and HTTPS",
menuSelfSigned: "Mark the service as self-signed",
menuNotice: "Edit the notice text shown on the card",
menuNoticeLink: "Optional link for the notice",
menuSaveBtn: "Save service changes",
menuCancelBtn: "Cancel changes",
menuRemoveBtn: "Remove this service",
};
// Clamp name inputs to 30 chars
[svcName, menuRename].forEach((el) => {
if (!el) return;
@@ -316,79 +273,7 @@ function setUpdatesUI(enabled) {
updatesStatus.classList.toggle("chip-off", !on);
}
async function loadStatus() {
try {
const data = await getStatus();
lastStatusData = data;
renderStats(heroStats, data);
renderServices(servicesGrid, data.services, { openAddService });
const updatesEnabled =
data?.auto_updates?.enabled ?? data.auto_updates_enabled;
if (updatesEnabled !== undefined && !isUpdatesDirty()) {
setUpdatesUI(updatesEnabled);
}
// Updates chip + reboot note
updatesFlagEl(
updatesEnabled === undefined ? null : updatesEnabled === true,
);
const cfg = data.updates_config || {};
const rebootReq = data.reboot_required;
setTempFlag(data.cpu_temp_c);
if (updatesNoteTop) {
updatesNoteTop.textContent = "";
updatesNoteTop.classList.remove("note-warn");
if (rebootReq) {
if (cfg.auto_reboot) {
updatesNoteTop.textContent = `Reboot scheduled at ${cfg.reboot_time || "02:00"}.`;
} else {
updatesNoteTop.textContent = "Reboot required. Please reboot when you can.";
updatesNoteTop.classList.add("note-warn");
}
}
}
if (readyOverlay) {
if (data.ready) {
readyOverlay.classList.add("hidden");
} else {
readyOverlay.classList.remove("hidden");
// When not ready, retry periodically until API reports ready
setTimeout(loadStatus, 3000);
}
}
// Pull Pi-Kit release status after core status
releaseUI?.refreshStatus();
} catch (e) {
console.error(e);
logUi(`Status refresh failed: ${e?.message || e}`, "error");
if (!lastStatusData) {
renderStats(heroStats, placeholderStatus);
}
setTimeout(loadStatus, 2000);
}
}
function setTempFlag(tempC) {
if (!tempFlagTop) return;
const t = typeof tempC === "number" ? tempC : null;
let label = "Temp: n/a";
tempFlagTop.classList.remove("chip-on", "chip-warm", "chip-off");
if (t !== null) {
if (t < 55) {
label = "Temp: OK";
tempFlagTop.classList.add("chip-on");
} else if (t < 70) {
label = "Temp: Warm";
tempFlagTop.classList.add("chip-warm");
} else {
label = "Temp: Hot";
tempFlagTop.classList.add("chip-off");
}
}
tempFlagTop.textContent = label;
}
function updatesFlagEl(enabled) {
function setUpdatesFlag(enabled) {
if (!updatesFlagTop) return;
const labelOn = "System updates: On";
const labelOff = "System updates: Off";
@@ -398,61 +283,6 @@ function updatesFlagEl(enabled) {
if (enabled === false) updatesFlagTop.classList.add("chip-off");
}
function wireModals() {
advBtn.onclick = () => advModal.classList.remove("hidden");
advClose.onclick = () => advModal.classList.add("hidden");
helpBtn.onclick = () => helpModal.classList.remove("hidden");
helpClose.onclick = () => helpModal.classList.add("hidden");
aboutBtn.onclick = () => aboutModal.classList.remove("hidden");
aboutClose.onclick = () => aboutModal.classList.add("hidden");
menuClose.onclick = () => menuModal.classList.add("hidden");
addServiceOpen?.addEventListener("click", openAddService);
addSvcClose?.addEventListener("click", () => addServiceModal?.classList.add("hidden"));
addServiceModal?.addEventListener("click", (e) => {
if (e.target === addServiceModal) addServiceModal.classList.add("hidden");
});
}
function showBusy(title = "Working…", text = "This may take a few seconds.") {
if (!busyOverlay) return;
busyTitle.textContent = title;
busyText.textContent = text || "";
busyText.classList.toggle("hidden", !text);
busyOverlay.classList.remove("hidden");
}
function hideBusy() {
busyOverlay?.classList.add("hidden");
}
function confirmAction(title, body) {
return new Promise((resolve) => {
if (!confirmModal) {
const ok = window.confirm(body || title || "Are you sure?");
resolve(ok);
return;
}
confirmTitle.textContent = title || "Are you sure?";
confirmBody.textContent = body || "";
confirmModal.classList.remove("hidden");
const done = (val) => {
confirmModal.classList.add("hidden");
resolve(val);
};
const okHandler = () => done(true);
const cancelHandler = () => done(false);
confirmOk.onclick = okHandler;
confirmCancel.onclick = cancelHandler;
});
}
// Testing hook
if (typeof window !== "undefined") {
window.__pikitTest = window.__pikitTest || {};
window.__pikitTest.showBusy = showBusy;
window.__pikitTest.hideBusy = hideBusy;
}
function wireResetAndUpdates() {
resetBtn.onclick = async () => {
resetBtn.disabled = true;
@@ -471,31 +301,6 @@ function wireResetAndUpdates() {
});
}
function wireAccordions() {
const forceOpen = typeof window !== "undefined" && window.__pikitTest?.forceAccordionsOpen;
const accordions = document.querySelectorAll(".accordion");
if (forceOpen) {
accordions.forEach((a) => a.classList.add("open"));
return;
}
document.querySelectorAll(".accordion-toggle").forEach((btn) => {
btn.addEventListener("click", () => {
const acc = btn.closest(".accordion");
if (acc.classList.contains("open")) {
acc.classList.remove("open");
} else {
// Keep a single accordion expanded at a time for readability
accordions.forEach((a) => a.classList.remove("open"));
acc.classList.add("open");
}
});
});
}
function collapseAccordions() {
document.querySelectorAll(".accordion").forEach((a) => a.classList.remove("open"));
}
function openAddService() {
if (addServiceModal) addServiceModal.classList.remove("hidden");
document.getElementById("svcName")?.focus();
@@ -505,10 +310,17 @@ if (typeof window !== "undefined") {
}
function main() {
applyTooltips();
wireModals();
applyTooltips(TOOLTIP_MAP);
// Test convenience: ensure service form elements are visible when hook is set
if (window.__pikitTest?.forceServiceFormVisible) {
window.__pikitTest.forceServiceFormVisible();
window.__pikitTest.exposeServiceForm?.();
}
wireDialogs();
wireResetAndUpdates();
wireAccordions();
wireAccordions({
forceOpen: typeof window !== "undefined" && window.__pikitTest?.forceAccordionsOpen,
});
releaseUI = initReleaseUI({
showToast,
showBusy,
@@ -516,14 +328,6 @@ function main() {
confirmAction,
logUi,
});
loadToastSettings();
if (advClose) {
advClose.onclick = () => {
advModal.classList.add("hidden");
collapseAccordions();
};
}
initServiceControls({
gridEl: servicesGrid,
@@ -598,98 +402,6 @@ function main() {
console.error("Diag init failed", e);
});
// Toast controls
toastPosSelect?.addEventListener("change", () => {
const val = toastPosSelect.value;
if (ALLOWED_TOAST_POS.includes(val)) {
toastPosition = val;
applyToastSettings();
persistToastSettings();
} else {
toastPosSelect.value = toastPosition;
showToast("Invalid toast position", "error");
}
});
toastAnimSelect?.addEventListener("change", () => {
let val = toastAnimSelect.value;
if (val === "slide-up" || val === "slide-left" || val === "slide-right") val = "slide-in"; // migrate old label if cached
if (ALLOWED_TOAST_ANIM.includes(val)) {
toastAnimation = val;
persistToastSettings();
} else {
toastAnimSelect.value = toastAnimation;
showToast("Invalid toast animation", "error");
}
});
const clampSpeed = (val) => Math.min(3000, Math.max(100, val));
const clampDuration = (val) => Math.min(15000, Math.max(1000, val));
toastSpeedInput?.addEventListener("input", () => {
const raw = toastSpeedInput.value;
if (raw === "") return; // allow typing
const val = Number(raw);
if (Number.isNaN(val) || val < 100 || val > 3000) return; // wait until valid
toastSpeedMs = val;
applyToastSettings();
persistToastSettings();
});
toastSpeedInput?.addEventListener("blur", () => {
const raw = toastSpeedInput.value;
if (raw === "") {
toastSpeedInput.value = toastSpeedMs;
return;
}
const val = Number(raw);
if (Number.isNaN(val) || val < 100 || val > 3000) {
toastSpeedMs = clampSpeed(toastSpeedMs);
toastSpeedInput.value = toastSpeedMs;
showToast("Toast speed must be 100-3000 ms", "error");
return;
}
toastSpeedMs = val;
toastSpeedInput.value = toastSpeedMs;
applyToastSettings();
persistToastSettings();
});
toastDurationInput?.addEventListener("input", () => {
const raw = toastDurationInput.value;
if (raw === "") return; // allow typing
const val = Number(raw);
if (Number.isNaN(val) || val < 1000 || val > 15000) return; // wait until valid
toastDurationMs = val;
persistToastSettings();
});
toastDurationInput?.addEventListener("blur", () => {
const raw = toastDurationInput.value;
if (raw === "") {
toastDurationInput.value = toastDurationMs;
return;
}
const val = Number(raw);
if (Number.isNaN(val) || val < 1000 || val > 15000) {
toastDurationMs = clampDuration(toastDurationMs);
toastDurationInput.value = toastDurationMs;
showToast("Toast duration must be 1000-15000 ms", "error");
return;
}
toastDurationMs = val;
toastDurationInput.value = toastDurationMs;
persistToastSettings();
});
fontSelect?.addEventListener("change", () => {
const val = fontSelect.value;
if (!ALLOWED_FONTS.includes(val)) {
fontSelect.value = fontChoice;
showToast("Invalid font choice", "error");
return;
}
fontChoice = val;
applyFontSetting();
persistToastSettings();
});
toastTestBtn?.addEventListener("click", () => showToast("This is a test toast", "info"));
initUpdateSettings({
elements: {
updatesStatus,

View File

@@ -0,0 +1,38 @@
export function shorten(text, max = 90) {
if (!text || typeof text !== "string") return text;
return text.length > max ? `${text.slice(0, max - 3)}...` : text;
}
export function createReleaseLogger(logUi = () => {}) {
let lines = [];
let lastMessage = null;
const state = { el: null };
function render() {
if (state.el) {
state.el.textContent = lines.join("\n");
state.el.scrollTop = 0;
}
}
function log(msg) {
if (!msg) return;
const plain = msg.trim();
if (plain === lastMessage) return;
lastMessage = plain;
const ts = new Date().toLocaleTimeString();
const line = `${ts} ${msg}`;
lines.unshift(line);
lines = lines.slice(0, 120);
render();
const lvl = msg.toLowerCase().startsWith("error") ? "error" : "info";
logUi(`Update: ${msg}`, lvl);
}
function attach(el) {
state.el = el;
render();
}
return { log, attach, getLines: () => lines.slice() };
}

View File

@@ -9,11 +9,7 @@ import {
setReleaseAutoCheck,
setReleaseChannel,
} from "./api.js";
function shorten(text, max = 90) {
if (!text || typeof text !== "string") return text;
return text.length > max ? `${text.slice(0, max - 3)}...` : text;
}
import { shorten, createReleaseLogger } from "./releases-utils.js";
export function initReleaseUI({ showToast, showBusy, hideBusy, confirmAction, logUi = () => {} }) {
const releaseFlagTop = document.getElementById("releaseFlagTop");
@@ -42,32 +38,14 @@ export function initReleaseUI({ showToast, showBusy, hideBusy, confirmAction, lo
const changelogClose = document.getElementById("changelogClose");
let releaseBusyActive = false;
let releaseLogLines = [];
let releaseLastFetched = 0;
let lastReleaseLogKey = "";
let lastReleaseToastKey = null;
let lastLogMessage = null;
let changelogCache = { version: null, text: "" };
let lastChangelogUrl = null;
let releaseChannel = "dev";
function logRelease(msg) {
if (!msg) return;
const plain = msg.trim();
if (plain === lastLogMessage) return;
lastLogMessage = plain;
const ts = new Date().toLocaleTimeString();
const line = `${ts} ${msg}`;
releaseLogLines.unshift(line);
releaseLogLines = releaseLogLines.slice(0, 120);
if (releaseLog) {
releaseLog.textContent = releaseLogLines.join("\n");
releaseLog.scrollTop = 0; // keep most recent in view
}
// Mirror into global diagnostics log (frontend side)
const lvl = msg.toLowerCase().startsWith("error") ? "error" : "info";
logUi(`Update: ${msg}`, lvl);
}
const logger = createReleaseLogger(logUi);
logger.attach(releaseLog);
function setReleaseChip(state) {
if (!releaseFlagTop) return;
@@ -136,6 +114,8 @@ export function initReleaseUI({ showToast, showBusy, hideBusy, confirmAction, lo
}
}
const logRelease = logger.log;
async function loadReleaseStatus(force = false) {
if (!releaseFlagTop) return;
const now = Date.now();

View File

@@ -0,0 +1,37 @@
export const DEFAULT_SELF_SIGNED_MSG =
"This service uses a self-signed certificate. Expect a browser warning; proceed only if you trust this device.";
export function isValidLink(str) {
if (!str) return true; // empty is allowed
try {
const u = new URL(str);
return u.protocol === "http:" || u.protocol === "https:";
} catch (e) {
return false;
}
}
export function normalizePath(path) {
if (!path) return "";
const trimmed = path.trim();
if (!trimmed) return "";
if (/\s/.test(trimmed)) return null; // no spaces or tabs in paths
if (trimmed.startsWith("http://") || trimmed.startsWith("https://")) return null;
return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
}
export function validateServiceFields({ name, port, path, notice, notice_link }, fail) {
const err = (m) => {
fail?.(m);
return false;
};
if (!name || name.trim().length < 2) return err("Name must be at least 2 characters.");
if (name.length > 48) return err("Name is too long (max 48 chars).");
if (!Number.isInteger(port) || port < 1 || port > 65535) return err("Port must be 1-65535.");
if (path === null) return err("Path must be relative (e.g. /admin) or blank.");
if (path.length > 200) return err("Path is too long (max 200 chars).");
if (notice && notice.length > 180) return err("Notice text too long (max 180 chars).");
if (notice_link && notice_link.length > 200) return err("Notice link too long (max 200 chars).");
if (!isValidLink(notice_link)) return err("Enter a valid URL (http/https) or leave blank.");
return true;
}

View File

@@ -1,48 +1,16 @@
import { addService, updateService, removeService } from "./api.js";
import { logUi } from "./diaglog.js";
import {
DEFAULT_SELF_SIGNED_MSG,
isValidLink,
normalizePath,
validateServiceFields,
} from "./services-helpers.js";
// Renders service cards and wires UI controls for add/edit/remove operations.
// All mutations round-trip through the API then invoke onChange to refresh data.
let noticeModalRefs = null;
const DEFAULT_SELF_SIGNED_MSG =
"This service uses a self-signed certificate. Expect a browser warning; proceed only if you trust this device.";
function isValidLink(str) {
if (!str) return true; // empty is allowed
try {
const u = new URL(str);
return u.protocol === "http:" || u.protocol === "https:";
} catch (e) {
return false;
}
}
function normalizePath(path) {
if (!path) return "";
const trimmed = path.trim();
if (!trimmed) return "";
if (/\s/.test(trimmed)) return null; // no spaces or tabs in paths
if (trimmed.startsWith("http://") || trimmed.startsWith("https://")) return null;
return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
}
function validateServiceFields({ name, port, path, notice, notice_link }, setMsg, toast) {
const fail = (m) => {
setMsg("");
toast?.(m, "error");
return false;
};
if (!name || name.trim().length < 2) return fail("Name must be at least 2 characters.");
if (name.length > 48) return fail("Name is too long (max 48 chars).");
if (!Number.isInteger(port) || port < 1 || port > 65535) return fail("Port must be 1-65535.");
if (path === null) return fail("Path must be relative (e.g. /admin) or blank.");
if (path.length > 200) return fail("Path is too long (max 200 chars).");
if (notice && notice.length > 180) return fail("Notice text too long (max 180 chars).");
if (notice_link && notice_link.length > 200) return fail("Notice link too long (max 200 chars).");
if (!isValidLink(notice_link)) return fail("Enter a valid URL (http/https) or leave blank.");
return true;
}
function ensureNoticeModal() {
if (noticeModalRefs) return noticeModalRefs;
const modal = document.createElement("div");
@@ -264,6 +232,7 @@ export function initServiceControls({ gridEl, menu, addForm, onChange, overlay,
async function menuAction(action, body = {}) {
if (!menuContext) return;
msg.textContent = "";
const original = { ...menuContext };
try {
const isRemove = action === "remove";
const isSave = action === "save";
@@ -285,6 +254,17 @@ export function initServiceControls({ gridEl, menu, addForm, onChange, overlay,
}
msg.textContent = "";
toast?.(isRemove ? "Service removed" : "Service saved", "success");
logUi(isRemove ? "Service removed" : "Service updated", "info", {
name: body.name || original.name,
port_from: original.port,
port_to: body.new_port || original.port,
scheme_from: original.scheme,
scheme_to: body.scheme || original.scheme,
path_from: original.path,
path_to: body.path ?? original.path,
notice_changed: body.notice !== undefined,
self_signed: body.self_signed,
});
modal?.classList.add("hidden");
menuContext = null;
await onChange?.();
@@ -292,6 +272,12 @@ export function initServiceControls({ gridEl, menu, addForm, onChange, overlay,
const err = e.error || "Action failed.";
msg.textContent = "";
toast?.(err, "error");
logUi("Service update failed", "error", {
action,
name: body.name || original.name,
port: original.port,
reason: err,
});
} finally {
hideBusy();
}
@@ -310,8 +296,7 @@ export function initServiceControls({ gridEl, menu, addForm, onChange, overlay,
if (
!validateServiceFields(
{ name, port: new_port, path, notice, notice_link },
() => {},
toast,
(m) => toast?.(m, "error"),
)
)
return;
@@ -335,11 +320,7 @@ export function initServiceControls({ gridEl, menu, addForm, onChange, overlay,
const notice_link = (addNoticeLinkInput?.value || "").trim();
const self_signed = !!addSelfSignedInput?.checked;
if (
!validateServiceFields(
{ name, port, path, notice, notice_link },
() => {},
toast,
)
!validateServiceFields({ name, port, path, notice, notice_link }, (m) => toast?.(m, "error"))
)
return;
addBtn.disabled = true;
@@ -348,11 +329,21 @@ export function initServiceControls({ gridEl, menu, addForm, onChange, overlay,
await addService({ name, port, scheme, path, notice, notice_link, self_signed });
addMsg.textContent = "";
toast?.("Service added", "success");
logUi("Service added", "info", {
name,
port,
scheme,
path,
notice: !!notice,
notice_link: !!notice_link,
self_signed,
});
await onChange?.();
} catch (e) {
const err = e.error || "Failed to add.";
addMsg.textContent = "";
toast?.(err, "error");
logUi("Service add failed", "error", { name, port, scheme, reason: err });
} finally {
addBtn.disabled = false;
hideBusy();

View File

@@ -0,0 +1,100 @@
// Status polling and UI flag helpers
import { placeholderStatus, renderStats } from "./status.js";
import { renderServices } from "./services.js";
export function createStatusController({
heroStats,
servicesGrid,
updatesFlagTop,
updatesNoteTop,
tempFlagTop,
readyOverlay,
logUi,
showToast = () => {},
onReadyWait = null,
getStatus,
isUpdatesDirty,
releaseUIGetter = () => null,
setUpdatesUI = null,
updatesFlagEl = null,
}) {
let lastStatusData = null;
function setTempFlag(tempC) {
if (!tempFlagTop) return;
const t = typeof tempC === "number" ? tempC : null;
let label = "Temp: n/a";
tempFlagTop.classList.remove("chip-on", "chip-warm", "chip-off");
if (t !== null) {
if (t < 55) {
label = "Temp: OK";
tempFlagTop.classList.add("chip-on");
} else if (t < 70) {
label = "Temp: Warm";
tempFlagTop.classList.add("chip-warm");
} else {
label = "Temp: Hot";
tempFlagTop.classList.add("chip-off");
}
}
tempFlagTop.textContent = label;
}
function updatesFlagEl(enabled) {
if (!updatesFlagTop) return;
const labelOn = "System updates: On";
const labelOff = "System updates: Off";
updatesFlagTop.textContent =
enabled === true ? labelOn : enabled === false ? labelOff : "System updates";
updatesFlagTop.className = "status-chip quiet chip-system";
if (enabled === false) updatesFlagTop.classList.add("chip-off");
}
async function loadStatus() {
try {
const data = await getStatus();
lastStatusData = data;
renderStats(heroStats, data);
renderServices(servicesGrid, data.services, { openAddService: window.__pikitOpenAddService });
const updatesEnabled = data?.auto_updates?.enabled ?? data.auto_updates_enabled;
if (updatesEnabled !== undefined && !isUpdatesDirty()) {
setUpdatesUI?.(updatesEnabled);
}
updatesFlagEl?.(updatesEnabled === undefined ? null : updatesEnabled === true);
const cfg = data.updates_config || {};
const rebootReq = data.reboot_required;
setTempFlag(data.cpu_temp_c);
if (updatesNoteTop) {
updatesNoteTop.textContent = "";
updatesNoteTop.classList.remove("note-warn");
if (rebootReq) {
if (cfg.auto_reboot) {
updatesNoteTop.textContent = `Reboot scheduled at ${cfg.reboot_time || "02:00"}.`;
} else {
updatesNoteTop.textContent = "Reboot required. Please reboot when you can.";
updatesNoteTop.classList.add("note-warn");
}
}
}
if (readyOverlay) {
if (data.ready) {
readyOverlay.classList.add("hidden");
} else {
readyOverlay.classList.remove("hidden");
onReadyWait?.();
}
}
releaseUIGetter()?.refreshStatus();
} catch (e) {
console.error(e);
logUi?.(`Status refresh failed: ${e?.message || e}`, "error");
if (!lastStatusData) {
renderStats(heroStats, placeholderStatus);
}
setTimeout(loadStatus, 2000);
}
}
return { loadStatus, setTempFlag, updatesFlagEl };
}

File diff suppressed because it is too large Load Diff

258
pikit-web/assets/toast.js Normal file
View File

@@ -0,0 +1,258 @@
const TOAST_POS_KEY = "pikit-toast-pos";
const TOAST_ANIM_KEY = "pikit-toast-anim";
const TOAST_SPEED_KEY = "pikit-toast-speed";
const TOAST_DURATION_KEY = "pikit-toast-duration";
const FONT_KEY = "pikit-font";
export const ALLOWED_TOAST_POS = [
"bottom-center",
"bottom-right",
"bottom-left",
"top-right",
"top-left",
"top-center",
];
export const ALLOWED_TOAST_ANIM = ["slide-in", "fade", "pop", "bounce", "drop", "grow"];
export const ALLOWED_FONTS = ["redhat", "space", "manrope", "dmsans", "sora", "chivo", "atkinson", "plex"];
const clamp = (val, min, max) => Math.min(max, Math.max(min, val));
export function createToastManager({
container,
posSelect,
animSelect,
speedInput,
durationInput,
fontSelect,
testBtn,
} = {}) {
const state = {
position: "bottom-center",
animation: "slide-in",
durationMs: 5000,
speedMs: 300,
font: "redhat",
};
function applyToastSettings() {
if (!container) return;
container.className = `toast-container pos-${state.position}`;
document.documentElement.style.setProperty("--toast-speed", `${state.speedMs}ms`);
const dir = state.position.startsWith("top") ? -1 : 1;
const isLeft = state.position.includes("left");
const isRight = state.position.includes("right");
const slideX = isLeft ? -26 : isRight ? 26 : 0;
const slideY = isLeft || isRight ? 0 : dir * 24;
document.documentElement.style.setProperty("--toast-slide-offset", `${dir * 24}px`);
document.documentElement.style.setProperty("--toast-dir", `${dir}`);
document.documentElement.style.setProperty("--toast-slide-x", `${slideX}px`);
document.documentElement.style.setProperty("--toast-slide-y", `${slideY}px`);
if (durationInput) durationInput.value = state.durationMs;
}
function applyFontSetting() {
document.documentElement.setAttribute("data-font", state.font);
if (fontSelect) fontSelect.value = state.font;
}
function persistSettings() {
try {
localStorage.setItem(TOAST_POS_KEY, state.position);
localStorage.setItem(TOAST_ANIM_KEY, state.animation);
localStorage.setItem(TOAST_SPEED_KEY, String(state.speedMs));
localStorage.setItem(TOAST_DURATION_KEY, String(state.durationMs));
localStorage.setItem(FONT_KEY, state.font);
} catch (e) {
console.warn("Toast settings save failed", e);
}
}
function loadFromStorage() {
try {
const posSaved = localStorage.getItem(TOAST_POS_KEY);
if (ALLOWED_TOAST_POS.includes(posSaved)) state.position = posSaved;
const animSaved = localStorage.getItem(TOAST_ANIM_KEY);
const migrated =
animSaved === "slide-up" || animSaved === "slide-left" || animSaved === "slide-right"
? "slide-in"
: animSaved;
if (migrated && ALLOWED_TOAST_ANIM.includes(migrated)) state.animation = migrated;
const savedSpeed = Number(localStorage.getItem(TOAST_SPEED_KEY));
if (!Number.isNaN(savedSpeed) && savedSpeed >= 100 && savedSpeed <= 3000) {
state.speedMs = savedSpeed;
}
const savedDur = Number(localStorage.getItem(TOAST_DURATION_KEY));
if (!Number.isNaN(savedDur) && savedDur >= 1000 && savedDur <= 15000) {
state.durationMs = savedDur;
}
const savedFont = localStorage.getItem(FONT_KEY);
if (ALLOWED_FONTS.includes(savedFont)) state.font = savedFont;
} catch (e) {
console.warn("Toast settings load failed", e);
}
if (posSelect) posSelect.value = state.position;
if (animSelect) animSelect.value = state.animation;
if (speedInput) speedInput.value = state.speedMs;
if (durationInput) durationInput.value = state.durationMs;
if (fontSelect) fontSelect.value = state.font;
applyToastSettings();
applyFontSetting();
}
function showToast(message, type = "info") {
if (!container || !message) return;
const t = document.createElement("div");
t.className = `toast ${type} anim-${state.animation}`;
t.textContent = message;
container.appendChild(t);
const animOn = document.documentElement.getAttribute("data-anim") !== "off";
if (!animOn) {
t.classList.add("show");
} else {
requestAnimationFrame(() => t.classList.add("show"));
}
const duration = state.durationMs;
setTimeout(() => {
const all = Array.from(container.querySelectorAll(".toast"));
const others = all.filter((el) => el !== t && !el.classList.contains("leaving"));
const first = new Map(
others.map((el) => [el, el.getBoundingClientRect()]),
);
t.classList.add("leaving");
void t.offsetHeight;
requestAnimationFrame(() => {
const second = new Map(
others.map((el) => [el, el.getBoundingClientRect()]),
);
others.forEach((el) => {
const dy = first.get(el).top - second.get(el).top;
if (Math.abs(dy) > 0.5) {
el.style.transition = "transform var(--toast-speed, 0.28s) ease";
el.style.transform = `translateY(${dy}px)`;
requestAnimationFrame(() => {
el.style.transform = "";
});
}
});
});
const removeDelay = animOn ? state.speedMs : 0;
setTimeout(() => {
t.classList.remove("show");
t.remove();
others.forEach((el) => (el.style.transition = ""));
}, removeDelay);
}, duration);
}
function wireControls() {
posSelect?.addEventListener("change", () => {
const val = posSelect.value;
if (ALLOWED_TOAST_POS.includes(val)) {
state.position = val;
applyToastSettings();
persistSettings();
} else {
posSelect.value = state.position;
showToast("Invalid toast position", "error");
}
});
animSelect?.addEventListener("change", () => {
let val = animSelect.value;
if (val === "slide-up" || val === "slide-left" || val === "slide-right") val = "slide-in";
if (ALLOWED_TOAST_ANIM.includes(val)) {
state.animation = val;
persistSettings();
} else {
animSelect.value = state.animation;
showToast("Invalid toast animation", "error");
}
});
const clampSpeed = (val) => clamp(val, 100, 3000);
const clampDuration = (val) => clamp(val, 1000, 15000);
speedInput?.addEventListener("input", () => {
const raw = speedInput.value;
if (raw === "") return;
const val = Number(raw);
if (Number.isNaN(val) || val < 100 || val > 3000) return;
state.speedMs = val;
applyToastSettings();
persistSettings();
});
speedInput?.addEventListener("blur", () => {
const raw = speedInput.value;
if (raw === "") {
speedInput.value = state.speedMs;
return;
}
const val = Number(raw);
if (Number.isNaN(val) || val < 100 || val > 3000) {
state.speedMs = clampSpeed(state.speedMs);
speedInput.value = state.speedMs;
showToast("Toast speed must be 100-3000 ms", "error");
return;
}
state.speedMs = val;
speedInput.value = state.speedMs;
applyToastSettings();
persistSettings();
});
durationInput?.addEventListener("input", () => {
const raw = durationInput.value;
if (raw === "") return;
const val = Number(raw);
if (Number.isNaN(val) || val < 1000 || val > 15000) return;
state.durationMs = val;
persistSettings();
});
durationInput?.addEventListener("blur", () => {
const raw = durationInput.value;
if (raw === "") {
durationInput.value = state.durationMs;
return;
}
const val = Number(raw);
if (Number.isNaN(val) || val < 1000 || val > 15000) {
state.durationMs = clampDuration(state.durationMs);
durationInput.value = state.durationMs;
showToast("Toast duration must be 1000-15000 ms", "error");
return;
}
state.durationMs = val;
durationInput.value = state.durationMs;
persistSettings();
});
fontSelect?.addEventListener("change", () => {
const val = fontSelect.value;
if (!ALLOWED_FONTS.includes(val)) {
fontSelect.value = state.font;
showToast("Invalid font choice", "error");
return;
}
state.font = val;
applyFontSetting();
persistSettings();
});
testBtn?.addEventListener("click", () => showToast("This is a test toast", "info"));
}
loadFromStorage();
wireControls();
return {
state,
showToast,
applyToastSettings,
applyFontSetting,
persistSettings,
loadFromStorage,
};
}

80
pikit-web/assets/ui.js Normal file
View File

@@ -0,0 +1,80 @@
// Small UI helpers to keep main.js lean and declarative.
export function applyTooltips(map = {}) {
Object.entries(map).forEach(([id, text]) => {
const el = document.getElementById(id);
if (el && text) el.title = text;
});
}
export function wireModalPairs(pairs = []) {
pairs.forEach(({ openBtn, modal, closeBtn }) => {
if (!modal) return;
openBtn?.addEventListener("click", () => modal.classList.remove("hidden"));
closeBtn?.addEventListener("click", () => modal.classList.add("hidden"));
modal.addEventListener("click", (e) => {
if (e.target === modal) modal.classList.add("hidden");
});
});
}
export function wireAccordions({
toggleSelector = ".accordion-toggle",
accordionSelector = ".accordion",
forceOpen = false,
} = {}) {
const accordions = Array.from(document.querySelectorAll(accordionSelector));
const toggles = Array.from(document.querySelectorAll(toggleSelector));
if (forceOpen) {
accordions.forEach((a) => a.classList.add("open"));
return;
}
toggles.forEach((btn) => {
btn.addEventListener("click", () => {
const acc = btn.closest(accordionSelector);
if (!acc) return;
if (acc.classList.contains("open")) {
acc.classList.remove("open");
} else {
accordions.forEach((a) => a.classList.remove("open"));
acc.classList.add("open");
}
});
});
}
export function createBusyOverlay({ overlay, titleEl, textEl }) {
const showBusy = (title = "Working…", text = "This may take a few seconds.") => {
if (!overlay) return;
if (titleEl) titleEl.textContent = title;
if (textEl) {
textEl.textContent = text || "";
textEl.classList.toggle("hidden", !text);
}
overlay.classList.remove("hidden");
};
const hideBusy = () => overlay?.classList.add("hidden");
return { showBusy, hideBusy };
}
export function createConfirmModal({ modal, titleEl, bodyEl, okBtn, cancelBtn }) {
const confirmAction = (title, body) =>
new Promise((resolve) => {
if (!modal) {
resolve(window.confirm(body || title || "Are you sure?"));
return;
}
if (titleEl) titleEl.textContent = title || "Are you sure?";
if (bodyEl) bodyEl.textContent = body || "";
modal.classList.remove("hidden");
const done = (val) => {
modal.classList.add("hidden");
resolve(val);
};
const okHandler = () => done(true);
const cancelHandler = () => done(false);
okBtn?.addEventListener("click", okHandler, { once: true });
cancelBtn?.addEventListener("click", cancelHandler, { once: true });
});
return confirmAction;
}

View File

@@ -1,6 +1,7 @@
// UI controller for unattended-upgrades settings.
// Fetches current config, mirrors it into the form, and saves changes.
import { getUpdateConfig, saveUpdateConfig } from "./api.js";
import { logUi } from "./diaglog.js";
const TIME_RE = /^(\d{1,2}):(\d{2})$/;
const MAX_BANDWIDTH_KBPS = 1_000_000; // 1 GB/s cap to prevent typos
@@ -115,15 +116,14 @@ export function initUpdateSettings({
function showMessage(text, isError = false) {
if (!msgEl) return;
// Only surface inline text for errors; successes go to toast only.
if (isError) {
msgEl.textContent = text || "Something went wrong";
msgEl.classList.add("error");
toast?.(text || "Error", "error");
} else {
msgEl.textContent = "";
msgEl.textContent = text || "";
msgEl.classList.remove("error");
}
if (toast) toast(text || (isError ? "Error" : ""), isError ? "error" : "success");
}
function currentConfigFromForm() {
@@ -246,6 +246,7 @@ export function initUpdateSettings({
showMessage("");
try {
const prev = lastConfig ? { ...lastConfig } : null;
const payload = buildPayload();
if (overrideEnable !== null) payload.enable = !!overrideEnable;
@@ -257,6 +258,7 @@ export function initUpdateSettings({
showMessage("Update settings saved.");
toast?.("Updates saved", "success");
logUi("Update settings saved", "info", { from: prev, to: payload });
onAfterSave?.();
@@ -273,6 +275,16 @@ export function initUpdateSettings({
}
showMessage(e?.error || e?.message || "Save failed", true);
logUi("Update settings save failed", "error", {
payload: (() => {
try {
return buildPayload();
} catch {
return null;
}
})(),
reason: e?.error || e?.message,
});
} finally {
saving = false;

View File

@@ -1,3 +1,3 @@
{
"version": "0.1.0-dev"
"version": "0.1.2"
}

View File

@@ -4,6 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Pi-Kit Dashboard</title>
<link rel="icon" href="/favicon.ico" />
<link rel="stylesheet" href="assets/style.css" />
</head>
<body>

View File