наблюдаемость: завершить базовый контур Community
Добавить структурированные журналы, метрики, трассировку и безопасный канал критических ошибок. Усилить границы рантайма, тесты, проверку зависимостей и сценарии развёртывания.
This commit is contained in:
+40
-4
@@ -8,6 +8,8 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
openId: null,
|
||||
liveMode: true,
|
||||
timer: null,
|
||||
searchTimer: null,
|
||||
refreshPromise: null,
|
||||
workspaceId: null,
|
||||
loading: false,
|
||||
loadError: '',
|
||||
@@ -457,7 +459,13 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
}
|
||||
|
||||
async function refreshOperationalData() {
|
||||
await Promise.all([loadLogs(), loadApprovals()]);
|
||||
if (state.refreshPromise) {
|
||||
return state.refreshPromise;
|
||||
}
|
||||
state.refreshPromise = Promise.all([loadLogs(), loadApprovals()]).finally(function () {
|
||||
state.refreshPromise = null;
|
||||
});
|
||||
return state.refreshPromise;
|
||||
}
|
||||
|
||||
async function loadLogDetail(logId) {
|
||||
@@ -494,10 +502,14 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
function startPolling() {
|
||||
stopPolling();
|
||||
if (!state.liveMode) {
|
||||
if (!state.liveMode || document.hidden) {
|
||||
return;
|
||||
}
|
||||
state.timer = setInterval(refreshOperationalData, 4000);
|
||||
state.timer = setTimeout(async function poll() {
|
||||
state.timer = null;
|
||||
await refreshOperationalData();
|
||||
startPolling();
|
||||
}, 4000);
|
||||
}
|
||||
|
||||
function toggleLive() {
|
||||
@@ -526,7 +538,13 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
if (logSearch) {
|
||||
logSearch.addEventListener('input', function () {
|
||||
state.search = this.value.trim();
|
||||
loadLogs();
|
||||
if (state.searchTimer) {
|
||||
clearTimeout(state.searchTimer);
|
||||
}
|
||||
state.searchTimer = setTimeout(function () {
|
||||
state.searchTimer = null;
|
||||
loadLogs();
|
||||
}, 250);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -572,6 +590,24 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
refreshOperationalData();
|
||||
});
|
||||
|
||||
document.addEventListener('visibilitychange', function () {
|
||||
if (document.hidden) {
|
||||
stopPolling();
|
||||
return;
|
||||
}
|
||||
if (state.liveMode) {
|
||||
refreshOperationalData().finally(startPolling);
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('pagehide', function () {
|
||||
stopPolling();
|
||||
if (state.searchTimer) {
|
||||
clearTimeout(state.searchTimer);
|
||||
state.searchTimer = null;
|
||||
}
|
||||
});
|
||||
|
||||
setLiveState();
|
||||
startPolling();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user