refactor: extract models/routes and env-based server config
- Move API request/response structs into new lib/models package - Centralize Gin route registration in lib/routing to simplify wiring - Add lib/server config helper to allow WARPBOX_BOX_POLL_INTERVAL_MS override - Improves modularity and makes polling behavior configurable per environmentrefactor: extract models/routes and env-based server config - Move API request/response structs into new lib/models package - Centralize Gin route registration in lib/routing to simplify wiring - Add lib/server config helper to allow WARPBOX_BOX_POLL_INTERVAL_MS override - Improves modularity and makes polling behavior configurable per environment
This commit is contained in:
@@ -119,7 +119,7 @@
|
||||
min-height: 0;
|
||||
margin-top: 8px;
|
||||
overflow-y: auto;
|
||||
background: #ffffff;
|
||||
color: #fff;
|
||||
border-top: 2px solid #808080;
|
||||
border-left: 2px solid #808080;
|
||||
border-right: 2px solid #ffffff;
|
||||
@@ -371,10 +371,6 @@
|
||||
min-height: 126px;
|
||||
}
|
||||
|
||||
.upload-file-list {
|
||||
min-height: 160px;
|
||||
}
|
||||
|
||||
.upload-result {
|
||||
grid-template-columns: 64px minmax(0, 1fr) 68px;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ async function refreshBoxStatus() {
|
||||
const boxID = boxPanel.dataset.boxId;
|
||||
const response = await fetch(`/box/${boxID}/status`);
|
||||
if (!response.ok) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
@@ -63,10 +63,16 @@ async function refreshBoxStatus() {
|
||||
}
|
||||
|
||||
if (boxPanel) {
|
||||
const pollMS = Number.parseInt(boxPanel.dataset.pollMs, 10) || 5000;
|
||||
const timer = setInterval(async () => {
|
||||
const hasLoadingFiles = await refreshBoxStatus();
|
||||
if (!hasLoadingFiles) {
|
||||
clearInterval(timer);
|
||||
try {
|
||||
const hasLoadingFiles = await refreshBoxStatus();
|
||||
if (!hasLoadingFiles) {
|
||||
clearInterval(timer);
|
||||
}
|
||||
} catch (error) {
|
||||
// Keep polling through temporary network/server hiccups; otherwise
|
||||
// an in-progress file can appear stuck forever after one bad poll.
|
||||
}
|
||||
}, 1500);
|
||||
}, pollMS);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user