添加对指定数据源统计带宽
This commit is contained in:
@@ -98,6 +98,7 @@
|
||||
oldPasswordInput: document.getElementById('oldPassword'),
|
||||
newPasswordInput: document.getElementById('newPassword'),
|
||||
confirmNewPasswordInput: document.getElementById('confirmNewPassword'),
|
||||
networkSourceSelector: document.getElementById('network-source-selector'),
|
||||
btnChangePassword: document.getElementById('btnChangePassword'),
|
||||
changePasswordMessage: document.getElementById('changePasswordMessage'),
|
||||
globeContainer: document.getElementById('globeContainer'),
|
||||
@@ -1907,6 +1908,21 @@
|
||||
if (dom.faviconUrlInput) dom.faviconUrlInput.value = settings.favicon_url || '';
|
||||
if (dom.showPageNameInput) dom.showPageNameInput.value = settings.show_page_name !== undefined ? settings.show_page_name.toString() : "1";
|
||||
if (dom.requireLoginForServerDetailsInput) dom.requireLoginForServerDetailsInput.value = settings.require_login_for_server_details ? "1" : "0";
|
||||
|
||||
// Handle network data sources checkboxes
|
||||
if (settings.network_data_sources) {
|
||||
const selected = settings.network_data_sources.split(',').map(s => s.trim());
|
||||
const checkboxes = dom.networkSourceSelector.querySelectorAll('input[type="checkbox"]');
|
||||
checkboxes.forEach(cb => {
|
||||
cb.checked = selected.includes(cb.value);
|
||||
});
|
||||
// We'll also store this in a temporary place because loadSources might run later
|
||||
dom.networkSourceSelector.dataset.pendingSelected = settings.network_data_sources;
|
||||
} else {
|
||||
const checkboxes = dom.networkSourceSelector.querySelectorAll('input[type="checkbox"]');
|
||||
checkboxes.forEach(cb => cb.checked = false);
|
||||
dom.networkSourceSelector.dataset.pendingSelected = "";
|
||||
}
|
||||
|
||||
// Handle Theme Priority: localStorage > Site Default
|
||||
const savedTheme = localStorage.getItem('theme');
|
||||
@@ -2033,7 +2049,8 @@
|
||||
show_95_bandwidth: dom.show95BandwidthInput ? (dom.show95BandwidthInput.value === "1") : false,
|
||||
p95_type: dom.p95TypeSelect ? dom.p95TypeSelect.value : 'tx',
|
||||
ps_filing: dom.psFilingInput ? dom.psFilingInput.value.trim() : '',
|
||||
icp_filing: dom.icpFilingInput ? dom.icpFilingInput.value.trim() : ''
|
||||
icp_filing: dom.icpFilingInput ? dom.icpFilingInput.value.trim() : '',
|
||||
network_data_sources: Array.from(dom.networkSourceSelector.querySelectorAll('input[type="checkbox"]:checked')).map(cb => cb.value).join(',')
|
||||
};
|
||||
|
||||
dom.btnSaveSiteSettings.disabled = true;
|
||||
@@ -2317,6 +2334,7 @@
|
||||
if (dom.totalServersLabel) dom.totalServersLabel.textContent = `服务器总数 (${promSources.length} 数据源)`;
|
||||
updateSourceFilterOptions(sourcesArray);
|
||||
renderSources(sourcesArray);
|
||||
renderNetworkSourceSelector(sourcesArray);
|
||||
} catch (err) {
|
||||
console.error('Error loading sources:', err);
|
||||
}
|
||||
@@ -2351,6 +2369,27 @@
|
||||
`).join('');
|
||||
}
|
||||
|
||||
function renderNetworkSourceSelector(sources) {
|
||||
if (!dom.networkSourceSelector) return;
|
||||
|
||||
// Only show Prometheus sources for filtering
|
||||
const promSources = sources.filter(s => s.type !== 'blackbox');
|
||||
|
||||
if (promSources.length === 0) {
|
||||
dom.networkSourceSelector.innerHTML = '<div style="color: var(--text-muted); font-size: 0.9rem;">暂无可用数据源</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
const pendingSelected = dom.networkSourceSelector.dataset.pendingSelected ? dom.networkSourceSelector.dataset.pendingSelected.split(',').map(s => s.trim()) : [];
|
||||
|
||||
dom.networkSourceSelector.innerHTML = promSources.map(source => `
|
||||
<label style="display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 4px 8px; border-radius: 4px; background: rgba(255,255,255,0.05); font-size: 0.9rem;">
|
||||
<input type="checkbox" value="${escapeHtml(source.name)}" ${pendingSelected.includes(source.name) ? 'checked' : ''} style="cursor: pointer;">
|
||||
<span>${escapeHtml(source.name)}</span>
|
||||
</label>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
// ---- Test Connection ----
|
||||
async function testConnection() {
|
||||
const url = dom.sourceUrl.value.trim();
|
||||
|
||||
Reference in New Issue
Block a user