Display live batch mode (AUTO MODE / MANUAL TRIGGER) in dashboard UI

This commit is contained in:
andrew committed 2026-11-30 08:10:20 +07:00
1 parent a168322194
commit 6af5968823
3 files changed
+30 -3

No files matched your search

+1
View File
@@ -169,6 +169,7 @@ def index():
stream_fps=STREAM_FPS_DISPLAY,
stream_resolution=STREAM_RESOLUTION_DISPLAY,
stream_accuracy=STREAM_ACCURACY_PCT,
batch_mode=BATCH_MODE,
)
+14 -3
View File
@@ -902,11 +902,11 @@
<span class="bc-dot"></span>
<span id="bcStatusText">STOPPED / IDLE</span>
</span>
<span class="bc-mode-tag"><i class="fas fa-hand-pointer"></i> MANUAL TRIGGER</span>
<span class="bc-mode-tag" id="bcModeTag">{% if batch_mode == 'auto' %}<i class="fas fa-robot"></i> AUTO MODE{% else %}<i class="fas fa-hand-pointer"></i> MANUAL TRIGGER{% endif %}</span>
</div>
<div class="bc-info-row">
<div class="bc-main-info" id="bcMainInfo">Sistem Siap Menghitung</div>
<div class="bc-sub-info" id="bcSubInfo">Sistem idle. Klik "Start Batch" untuk menghitung karung dan box sekaligus.</div>
<div class="bc-sub-info" id="bcSubInfo">{% if batch_mode == 'auto' %}Mode otomatis aktif. Batch dimulai otomatis saat karung/box melintas.{% else %}Sistem idle. Klik "Start Batch" untuk menghitung karung dan box sekaligus.{% endif %}</div>
</div>
</div>
<div class="bc-right">
@@ -1394,8 +1394,11 @@ async function loadCurrentBatch() {
const svcCamDot = document.getElementById('svc-cam-dot');
// Control bar elements
const batchMode = (data.batch_mode || '{{ batch_mode|default("manual") }}').toLowerCase();
const isAuto = batchMode === 'auto';
const bcStatusBadge = document.getElementById('bcStatusBadge');
const bcStatusText = document.getElementById('bcStatusText');
const bcModeTag = document.getElementById('bcModeTag');
const bcMainInfo = document.getElementById('bcMainInfo');
const bcSubInfo = document.getElementById('bcSubInfo');
const btnStart = document.getElementById('btnBatchStart');
@@ -1403,6 +1406,12 @@ async function loadCurrentBatch() {
const lblNextBatch = document.getElementById('lblNextBatch');
const lblCurrBatch = document.getElementById('lblCurrBatch');
if (bcModeTag) {
bcModeTag.innerHTML = isAuto
? '<i class="fas fa-robot"></i> AUTO MODE'
: '<i class="fas fa-hand-pointer"></i> MANUAL TRIGGER';
}
if (svcCamEl) svcCamEl.textContent = videoActive ? 'Streaming' : 'Standby';
if (svcCamDot) svcCamDot.style.background = videoActive ? 'var(--green)' : 'var(--yellow-line)';
@@ -1476,7 +1485,9 @@ async function loadCurrentBatch() {
bcMainInfo.textContent = `Siap Menghitung (Batch #${currentBatchState.next_batch_number})`;
}
if (bcSubInfo) {
bcSubInfo.textContent = 'Sistem idle. Klik "Start Batch" untuk menghitung karung dan box sekaligus.';
bcSubInfo.textContent = isAuto
? 'Mode otomatis aktif. Batch dimulai otomatis saat karung/box melintas.'
: 'Sistem idle. Klik "Start Batch" untuk menghitung karung dan box sekaligus.';
}
if (btnStart) {
btnStart.style.display = 'inline-flex';
+15
View File
@@ -81,6 +81,21 @@ class DashboardUnifiedBatchTests(unittest.TestCase):
self.assertIn('id="modalStopBatchBoxCount"', html)
self.assertIn('id="modalStopBatchPlate"', html)
def test_dashboard_renders_mode_badge_for_auto_and_manual(self):
with patch.object(counter_dashboard, "BATCH_MODE", "auto"):
auto_html = self.client.get("/").get_data(as_text=True)
self.assertIn(
'id="bcModeTag"><i class="fas fa-robot"></i> AUTO MODE</span>',
auto_html,
)
with patch.object(counter_dashboard, "BATCH_MODE", "manual"):
manual_html = self.client.get("/").get_data(as_text=True)
self.assertIn(
'id="bcModeTag"><i class="fas fa-hand-pointer"></i> MANUAL TRIGGER</span>',
manual_html,
)
def test_daily_export_has_sack_and_box_columns(self):
counting_date = counter_dashboard.get_counting_date()
self.seed_batch(counting_date)