Skip to content

Commit 58a2fd7

Browse files
Copilotdorkmo
andcommitted
Grey out refresh buttons during refresh and fix Last Dashboard Refresh timestamp
Co-authored-by: dorkmo <[email protected]>
1 parent 97b8cb8 commit 58a2fd7

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

TankAlarm-112025-Server-BluesOpta/TankAlarm-112025-Server-BluesOpta.ino

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,9 @@ static const char DASHBOARD_HTML[] PROGMEM = R"HTML(
12531253
function refreshButton(row) {
12541254
if (!row.client || row.client === '--') return '--';
12551255
const escapedClient = escapeHtml(row.client);
1256-
return `<button class="icon-button" onclick="refreshTank('${escapedClient}')" title="Refresh Tank" style="width:32px;height:32px;font-size:1rem;">🔄</button>`;
1256+
const disabled = state.refreshing ? 'disabled' : '';
1257+
const opacity = state.refreshing ? 'opacity:0.4;' : '';
1258+
return `<button class="icon-button refresh-btn" onclick="refreshTank('${escapedClient}')" title="Refresh Tank" style="width:32px;height:32px;font-size:1rem;${opacity}" ${disabled}>🔄</button>`;
12571259
}
12581260
12591261
function escapeHtml(unsafe) {
@@ -1269,6 +1271,7 @@ static const char DASHBOARD_HTML[] PROGMEM = R"HTML(
12691271
async function refreshTank(clientUid) {
12701272
if (state.refreshing) return;
12711273
state.refreshing = true;
1274+
renderTankRows();
12721275
try {
12731276
const res = await fetch('/api/refresh', {
12741277
method: 'POST',
@@ -1286,6 +1289,7 @@ static const char DASHBOARD_HTML[] PROGMEM = R"HTML(
12861289
showToast(err.message || 'Refresh failed', true);
12871290
} finally {
12881291
state.refreshing = false;
1292+
renderTankRows();
12891293
}
12901294
}
12911295
window.refreshTank = refreshTank;
@@ -1323,7 +1327,14 @@ static const char DASHBOARD_HTML[] PROGMEM = R"HTML(
13231327
els.fleetName.textContent = serverInfo.clientFleet || 'tankalarm-clients';
13241328
els.nextEmail.textContent = formatEpoch(data.nextDailyEmailEpoch);
13251329
els.lastSync.textContent = formatEpoch(data.lastSyncEpoch);
1326-
els.lastRefresh.textContent = new Date().toLocaleString();
1330+
els.lastRefresh.textContent = new Date().toLocaleString(undefined, {
1331+
year: 'numeric',
1332+
month: 'numeric',
1333+
day: 'numeric',
1334+
hour: 'numeric',
1335+
minute: '2-digit',
1336+
hour12: true
1337+
});
13271338
state.uiRefreshSeconds = DEFAULT_REFRESH_SECONDS;
13281339
renderTankRows();
13291340
updateStats();

0 commit comments

Comments
 (0)