ci / smoke (push) Waiting to run
Brand strings only: - UI page titles (base/monitoring/history/analytics), header logo, footer - predict.py argparse description, systemd unit Description fields - README + AGENTS headings, CHANGELOG entry - header CSS shrinks below 640px so the longer name fits phone screens Operational names intentionally unchanged (data/history continuity): OBJECT_LABEL, DB paths, service unit filenames, repo/remote, Indonesian UI/log strings (karung/truk).
569 lines
19 KiB
HTML
569 lines
19 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en" data-theme="light">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>{% block title %}Feedmill Counting Platform{% endblock %}</title>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
<style>
|
|
:root {
|
|
/* Apple Minimalist Light Palette */
|
|
--bg-base: #F5F5F7;
|
|
--bg-card: #FFFFFF;
|
|
--border-color: #E5E7EB;
|
|
--text-primary: #1D1D1F;
|
|
--text-secondary: #86868B;
|
|
--accent-blue: #0071E3;
|
|
--accent-green: #34C759;
|
|
--accent-red: #FF3B30;
|
|
--accent-orange: #FF9500;
|
|
--nav-bg: rgba(255, 255, 255, 0.8);
|
|
--nav-border: rgba(0, 0, 0, 0.05);
|
|
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
|
|
--radius-md: 12px;
|
|
--radius-lg: 16px;
|
|
--transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
}
|
|
|
|
[data-theme="dark"] {
|
|
/* Apple Dark Mode Palette */
|
|
--bg-base: #000000;
|
|
--bg-card: #1C1C1E;
|
|
--border-color: #2C2C2E;
|
|
--text-primary: #F5F5F7;
|
|
--text-secondary: #8E8E93;
|
|
--accent-blue: #0A84FF;
|
|
--accent-green: #30D158;
|
|
--accent-red: #FF453A;
|
|
--accent-orange: #FF9F0A;
|
|
--nav-bg: rgba(28, 28, 30, 0.8);
|
|
--nav-border: rgba(255, 255, 255, 0.05);
|
|
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
|
|
--shadow-md: 0 4px 10px rgba(0, 0, 0, 0.4);
|
|
}
|
|
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
background-color: var(--bg-base);
|
|
color: var(--text-primary);
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
line-height: 1.5;
|
|
-webkit-font-smoothing: antialiased;
|
|
transition: background-color 0.3s var(--transition);
|
|
}
|
|
|
|
/* Grouped Header/Navbar */
|
|
header {
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 100;
|
|
background-color: var(--nav-bg);
|
|
backdrop-filter: blur(20px);
|
|
-webkit-backdrop-filter: blur(20px);
|
|
border-bottom: 1px solid var(--nav-border);
|
|
padding: 0 24px;
|
|
height: 64px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.header-left {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 32px;
|
|
}
|
|
|
|
.logo-container {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
|
|
.logo-container i {
|
|
font-size: 20px;
|
|
color: var(--accent-blue);
|
|
}
|
|
|
|
.logo-text {
|
|
font-size: 18px;
|
|
font-weight: 600;
|
|
letter-spacing: -0.5px;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
/* narrow phones: long brand name must not blow up the 64px header */
|
|
@media (max-width: 640px) {
|
|
header { padding: 0 12px; gap: 12px; overflow-x: auto; }
|
|
.header-left { gap: 16px; }
|
|
.logo-text { font-size: 14px; }
|
|
.nav-groups { gap: 12px; }
|
|
}
|
|
|
|
.nav-groups {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 24px;
|
|
}
|
|
|
|
.nav-group {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
padding: 0 12px;
|
|
border-left: 1px solid var(--border-color);
|
|
}
|
|
|
|
.nav-group:first-child {
|
|
border-left: none;
|
|
padding-left: 0;
|
|
}
|
|
|
|
.nav-group-label {
|
|
font-size: 11px;
|
|
font-weight: 700;
|
|
color: var(--text-secondary);
|
|
text-transform: uppercase;
|
|
letter-spacing: 1px;
|
|
margin-right: 4px;
|
|
}
|
|
|
|
.nav-link {
|
|
text-decoration: none;
|
|
color: var(--text-secondary);
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
padding: 6px 12px;
|
|
border-radius: var(--radius-md);
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
transition: var(--transition);
|
|
}
|
|
|
|
.nav-link:hover {
|
|
color: var(--text-primary);
|
|
background-color: rgba(0, 0, 0, 0.03);
|
|
}
|
|
|
|
[data-theme="dark"] .nav-link:hover {
|
|
background-color: rgba(255, 255, 255, 0.03);
|
|
}
|
|
|
|
.nav-link.active {
|
|
color: var(--accent-blue);
|
|
background-color: rgba(0, 113, 227, 0.08);
|
|
font-weight: 600;
|
|
}
|
|
|
|
.header-right {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 16px;
|
|
}
|
|
|
|
.live-badge {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
letter-spacing: 0.5px;
|
|
background-color: rgba(52, 199, 89, 0.12);
|
|
color: var(--accent-green);
|
|
padding: 4px 10px;
|
|
border-radius: 999px;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.live-badge span.dot {
|
|
width: 6px;
|
|
height: 6px;
|
|
background-color: var(--accent-green);
|
|
border-radius: 50%;
|
|
display: inline-block;
|
|
box-shadow: 0 0 6px var(--accent-green);
|
|
animation: pulse-dot 1.5s infinite;
|
|
}
|
|
|
|
@keyframes pulse-dot {
|
|
0%, 100% { opacity: 1; transform: scale(1); }
|
|
50% { opacity: 0.4; transform: scale(1.1); }
|
|
}
|
|
|
|
.theme-btn {
|
|
background: none;
|
|
border: 1px solid var(--border-color);
|
|
color: var(--text-primary);
|
|
width: 36px;
|
|
height: 36px;
|
|
border-radius: 50%;
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 16px;
|
|
transition: var(--transition);
|
|
}
|
|
|
|
.theme-btn:hover {
|
|
background-color: rgba(0, 0, 0, 0.03);
|
|
border-color: var(--text-primary);
|
|
}
|
|
|
|
[data-theme="dark"] .theme-btn:hover {
|
|
background-color: rgba(255, 255, 255, 0.03);
|
|
}
|
|
|
|
/* Container & Layout */
|
|
main.container {
|
|
flex: 1;
|
|
width: 100%;
|
|
max-width: 1440px;
|
|
margin: 0 auto;
|
|
padding: 32px 24px;
|
|
position: relative;
|
|
}
|
|
|
|
footer {
|
|
text-align: center;
|
|
padding: 24px;
|
|
font-size: 13px;
|
|
color: var(--text-secondary);
|
|
border-top: 1px solid var(--border-color);
|
|
background-color: var(--bg-card);
|
|
}
|
|
|
|
/* Reusable UI Components */
|
|
.card {
|
|
background-color: var(--bg-card);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: var(--radius-lg);
|
|
padding: 24px;
|
|
box-shadow: var(--shadow-sm);
|
|
transition: var(--transition);
|
|
}
|
|
|
|
.card:hover {
|
|
box-shadow: var(--shadow-md);
|
|
}
|
|
|
|
.btn {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 8px;
|
|
font-family: inherit;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
padding: 10px 16px;
|
|
border-radius: var(--radius-md);
|
|
cursor: pointer;
|
|
transition: var(--transition);
|
|
text-decoration: none;
|
|
border: 1px solid transparent;
|
|
}
|
|
|
|
.btn-primary {
|
|
background-color: var(--accent-blue);
|
|
color: #FFFFFF;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background-color: #005bb5;
|
|
}
|
|
|
|
.btn-secondary {
|
|
background-color: var(--bg-base);
|
|
border-color: var(--border-color);
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
background-color: rgba(0, 0, 0, 0.03);
|
|
}
|
|
|
|
[data-theme="dark"] .btn-secondary:hover {
|
|
background-color: rgba(255, 255, 255, 0.03);
|
|
}
|
|
|
|
/* Custom scrollbar */
|
|
::-webkit-scrollbar {
|
|
width: 8px;
|
|
height: 8px;
|
|
}
|
|
::-webkit-scrollbar-track {
|
|
background: transparent;
|
|
}
|
|
::-webkit-scrollbar-thumb {
|
|
background: rgba(0,0,0,0.1);
|
|
border-radius: 99px;
|
|
}
|
|
[data-theme="dark"] ::-webkit-scrollbar-thumb {
|
|
background: rgba(255,255,255,0.1);
|
|
}
|
|
|
|
/* Shared "clip ready" toast (office pages) */
|
|
#clipToastWrap {
|
|
position: fixed;
|
|
right: 20px;
|
|
bottom: 20px;
|
|
z-index: 1000;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
max-width: 340px;
|
|
pointer-events: none;
|
|
}
|
|
|
|
.clip-toast {
|
|
position: relative;
|
|
pointer-events: auto;
|
|
background-color: var(--bg-card);
|
|
border: 1px solid var(--border-color);
|
|
border-left: 3px solid var(--accent-green);
|
|
border-radius: var(--radius-md);
|
|
padding: 12px 32px 12px 14px;
|
|
box-shadow: var(--shadow-md);
|
|
cursor: pointer;
|
|
transition: var(--transition);
|
|
}
|
|
|
|
.clip-toast.clip-toast-error {
|
|
border-left-color: var(--accent-orange);
|
|
}
|
|
|
|
.clip-toast-title {
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.clip-toast-sub {
|
|
font-size: 12px;
|
|
color: var(--text-secondary);
|
|
margin-top: 2px;
|
|
}
|
|
|
|
.clip-toast-err {
|
|
font-size: 12px;
|
|
color: var(--accent-orange);
|
|
margin-top: 2px;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 2;
|
|
-webkit-box-orient: vertical;
|
|
overflow: hidden;
|
|
word-break: break-word;
|
|
}
|
|
|
|
.clip-toast-close {
|
|
position: absolute;
|
|
top: 6px;
|
|
right: 8px;
|
|
background: none;
|
|
border: none;
|
|
color: var(--text-secondary);
|
|
font-size: 16px;
|
|
line-height: 1;
|
|
cursor: pointer;
|
|
padding: 2px;
|
|
}
|
|
|
|
.clip-toast-close:hover {
|
|
color: var(--text-primary);
|
|
}
|
|
</style>
|
|
{% block extra_head %}{% endblock %}
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<div class="header-left">
|
|
<div class="logo-container">
|
|
<i class="fa-solid fa-cube"></i>
|
|
<div class="logo-text">Feedmill Counting Platform</div>
|
|
</div>
|
|
{% if show_nav is not defined or show_nav %}
|
|
<div class="nav-groups">
|
|
<!-- Group 1: Monitoring -->
|
|
<div class="nav-group">
|
|
<span class="nav-group-label">Monitor</span>
|
|
<a href="/" class="nav-link {% if request.path == '/' or request.path == '/monitoring' %}active{% endif %}">
|
|
<i class="fa-solid fa-desktop"></i> Live CCTV
|
|
</a>
|
|
</div>
|
|
<!-- Group 2: Data & Reports -->
|
|
<div class="nav-group">
|
|
<span class="nav-group-label">Data</span>
|
|
<a href="/history" class="nav-link {% if request.path == '/history' %}active{% endif %}">
|
|
<i class="fa-solid fa-history"></i> History
|
|
</a>
|
|
<a href="/analytics" class="nav-link {% if request.path == '/analytics' %}active{% endif %}">
|
|
<i class="fa-solid fa-chart-line"></i> Analytics
|
|
</a>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
<div class="header-right">
|
|
<div class="live-badge">
|
|
<span class="dot"></span> {{ site_name }}
|
|
</div>
|
|
<button class="theme-btn" id="themeToggleBtn" onclick="toggleTheme()" title="Toggle Light/Dark Mode">
|
|
<i class="fa-solid fa-moon"></i>
|
|
</button>
|
|
</div>
|
|
</header>
|
|
|
|
<main class="container">
|
|
{% block content %}{% endblock %}
|
|
</main>
|
|
|
|
<footer>
|
|
<p>© 2026 Feedmill Counting Platform. All rights reserved.</p>
|
|
</footer>
|
|
|
|
<script>
|
|
// Init theme from localStorage or system preference
|
|
function initTheme() {
|
|
const savedTheme = localStorage.getItem('theme');
|
|
const themeBtn = document.getElementById('themeToggleBtn');
|
|
const icon = themeBtn.querySelector('i');
|
|
|
|
if (savedTheme) {
|
|
document.documentElement.setAttribute('data-theme', savedTheme);
|
|
if (savedTheme === 'dark') {
|
|
icon.className = 'fa-solid fa-sun';
|
|
} else {
|
|
icon.className = 'fa-solid fa-moon';
|
|
}
|
|
} else {
|
|
const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
const activeTheme = systemPrefersDark ? 'dark' : 'light';
|
|
document.documentElement.setAttribute('data-theme', activeTheme);
|
|
icon.className = systemPrefersDark ? 'fa-solid fa-sun' : 'fa-solid fa-moon';
|
|
}
|
|
}
|
|
|
|
function toggleTheme() {
|
|
const currentTheme = document.documentElement.getAttribute('data-theme');
|
|
const nextTheme = currentTheme === 'dark' ? 'light' : 'dark';
|
|
const themeBtn = document.getElementById('themeToggleBtn');
|
|
const icon = themeBtn.querySelector('i');
|
|
|
|
document.documentElement.setAttribute('data-theme', nextTheme);
|
|
localStorage.setItem('theme', nextTheme);
|
|
|
|
if (nextTheme === 'dark') {
|
|
icon.className = 'fa-solid fa-sun';
|
|
} else {
|
|
icon.className = 'fa-solid fa-moon';
|
|
}
|
|
|
|
// Dispatch event for components that need to redrawn (like Chart.js)
|
|
window.dispatchEvent(new Event('themeChanged'));
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', initTheme);
|
|
</script>
|
|
<script>
|
|
// Shared non-blocking "clip ready" toast: polls office-only
|
|
// GET /api/batch-clip/pending. Bootstrap once; 403 (operator port)
|
|
// → never poll. Otherwise poll every 3 s. sessionStorage dedupe.
|
|
(function () {
|
|
const STORE_KEY = 'clipNotified';
|
|
const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
let active = true;
|
|
let polling = false;
|
|
let notified = [];
|
|
try { notified = JSON.parse(sessionStorage.getItem(STORE_KEY) || '[]'); } catch (e) { notified = []; }
|
|
|
|
function persistNotified() {
|
|
notified = notified.slice(-50);
|
|
try { sessionStorage.setItem(STORE_KEY, JSON.stringify(notified)); } catch (e) {}
|
|
}
|
|
|
|
function escapeHtmlToast(s) {
|
|
return String(s).replace(/[&<>"']/g, c => ({
|
|
'&': '&', '<': '<', '>': '>', '"': '"', "'": '''
|
|
})[c]);
|
|
}
|
|
|
|
function fmtWhen(start) {
|
|
const d = new Date(start);
|
|
if (isNaN(d.getTime())) return '';
|
|
const p = n => String(n).padStart(2, '0');
|
|
return `${p(d.getDate())} ${MONTHS[d.getMonth()]} ${p(d.getHours())}:${p(d.getMinutes())}`;
|
|
}
|
|
|
|
function showToast(job, isError) {
|
|
let wrap = document.getElementById('clipToastWrap');
|
|
if (!wrap) {
|
|
wrap = document.createElement('div');
|
|
wrap.id = 'clipToastWrap';
|
|
document.body.appendChild(wrap);
|
|
}
|
|
const el = document.createElement('div');
|
|
el.className = 'clip-toast' + (isError ? ' clip-toast-error' : '');
|
|
el.innerHTML =
|
|
'<button class="clip-toast-close" type="button" aria-label="Tutup">×</button>' +
|
|
`<div class="clip-toast-title">${isError ? 'Klip gagal' : 'Klip siap'}</div>` +
|
|
`<div class="clip-toast-sub">batch ${escapeHtmlToast(job.batch_number)} — ${fmtWhen(job.start_time)}</div>` +
|
|
(isError && job.error ? '<div class="clip-toast-err"></div>' : '');
|
|
const errEl = el.querySelector('.clip-toast-err');
|
|
if (errEl) errEl.textContent = String(job.error).slice(0, 120);
|
|
el.addEventListener('click', ev => {
|
|
if (ev.target.closest('.clip-toast-close')) { el.remove(); return; }
|
|
location.href = '/history';
|
|
});
|
|
wrap.appendChild(el);
|
|
setTimeout(() => { if (el.parentNode) el.remove(); }, 8000);
|
|
}
|
|
|
|
function retryBootstrapping() {
|
|
if (!polling) setTimeout(pollPending, 3000);
|
|
}
|
|
|
|
async function pollPending() {
|
|
if (!active) return;
|
|
let data;
|
|
try {
|
|
const res = await fetch('/api/batch-clip/pending');
|
|
if (res.status === 403) { active = false; return; } // operator page → stop for good
|
|
if (!res.ok) { retryBootstrapping(); return; }
|
|
data = await res.json();
|
|
} catch (e) {
|
|
retryBootstrapping();
|
|
return;
|
|
}
|
|
if (!polling) {
|
|
polling = true;
|
|
setInterval(pollPending, 3000);
|
|
}
|
|
if (!data || !data.success) return;
|
|
(data.jobs || []).forEach(job => {
|
|
if (!job || (job.status !== 'ready' && job.status !== 'error')) return;
|
|
const key = `${job.date}/${job.batch_number}`;
|
|
if (notified.indexOf(key) !== -1) return;
|
|
notified.push(key);
|
|
persistNotified();
|
|
showToast(job, job.status === 'error');
|
|
});
|
|
}
|
|
|
|
pollPending();
|
|
})();
|
|
</script>
|
|
{% block extra_js %}{% endblock %}
|
|
</body>
|
|
</html>
|