fix label
This commit is contained in:
@@ -245,6 +245,16 @@ function mcpCapability(mcp, configuration, pollRunningSeconds=0) {
|
|||||||
}
|
}
|
||||||
return {state: 'warn', detail: status};
|
return {state: 'warn', detail: status};
|
||||||
}
|
}
|
||||||
|
function llmCapability(llm, configuration) {
|
||||||
|
const enabled = Boolean(llm.enabled || configuration.llm_enabled);
|
||||||
|
if (!enabled) return {state: 'warn', detail: 'disabled'};
|
||||||
|
const status = String(llm.status || 'starting');
|
||||||
|
if (status === 'ok') return {state: 'on', detail: 'ok'};
|
||||||
|
if (status === 'cached') return {state: 'on', detail: 'cached'};
|
||||||
|
if (status === 'error' && String(llm.text || '').trim()) return {state: 'warn', detail: 'cached, assessment error'};
|
||||||
|
if (status === 'error') return {state: 'warn', detail: 'assessment error'};
|
||||||
|
return {state: 'warn', detail: status};
|
||||||
|
}
|
||||||
function actionItem(severity, title, detail, action) {
|
function actionItem(severity, title, detail, action) {
|
||||||
return `<div class="action-item ${esc(severity)}"><strong>${esc(title)}</strong><div>${esc(detail)}</div><div class="muted">Next: ${esc(action)}</div></div>`;
|
return `<div class="action-item ${esc(severity)}"><strong>${esc(title)}</strong><div>${esc(detail)}</div><div class="muted">Next: ${esc(action)}</div></div>`;
|
||||||
}
|
}
|
||||||
@@ -415,9 +425,10 @@ function sharedFieldLabel(item) {
|
|||||||
}
|
}
|
||||||
function profileAdvisorLabel(row, advisor) {
|
function profileAdvisorLabel(row, advisor) {
|
||||||
const rowAdvisor = row.profile_advisor || {};
|
const rowAdvisor = row.profile_advisor || {};
|
||||||
if (rowAdvisor.status === 'heuristic' && rowAdvisor.error) return 'heuristic (advisor error)';
|
if (rowAdvisor.status === 'heuristic' && rowAdvisor.error) return 'heuristic fallback';
|
||||||
if (rowAdvisor.status) return rowAdvisor.status;
|
if (rowAdvisor.status) return rowAdvisor.status;
|
||||||
if (advisor.enabled && advisor.status === 'error') return 'heuristic (advisor error)';
|
if (advisor.enabled && advisor.status === 'heuristic_fallback') return 'heuristic fallback';
|
||||||
|
if (advisor.enabled && advisor.status === 'error') return 'advisor error';
|
||||||
return advisor.enabled ? (advisor.status || 'checking') : 'heuristic';
|
return advisor.enabled ? (advisor.status || 'checking') : 'heuristic';
|
||||||
}
|
}
|
||||||
function drawTrend(history) {
|
function drawTrend(history) {
|
||||||
@@ -590,9 +601,10 @@ async function refresh() {
|
|||||||
const llm = data.llm_assessment || {};
|
const llm = data.llm_assessment || {};
|
||||||
const llmEnabled = Boolean(llm.enabled || configuration.llm_enabled);
|
const llmEnabled = Boolean(llm.enabled || configuration.llm_enabled);
|
||||||
const mcpBadge = mcpCapability(mcp, configuration, pollRunningSeconds);
|
const mcpBadge = mcpCapability(mcp, configuration, pollRunningSeconds);
|
||||||
|
const llmBadge = llmCapability(llm, configuration);
|
||||||
document.getElementById('capabilities').innerHTML = [
|
document.getElementById('capabilities').innerHTML = [
|
||||||
capability('Baseline', baseline.enabled ? 'on' : 'warn', baseline.enabled ? `${baseline.sources_ready || 0} sources ready` : 'disabled'),
|
capability('Baseline', baseline.enabled ? 'on' : 'warn', baseline.enabled ? `${baseline.sources_ready || 0} sources ready` : 'disabled'),
|
||||||
capability('Ollama', llmEnabled && llm.status !== 'error' ? 'on' : 'warn', llmEnabled ? (llm.status || 'starting') : 'disabled'),
|
capability('Ollama', llmBadge.state, llmBadge.detail),
|
||||||
capability('Threat Intel', threat.enabled && threat.configured ? 'on' : 'warn', threat.enabled ? `${threat.provider || 'unknown'}${threat.configured ? '' : ', key missing'}` : 'disabled'),
|
capability('Threat Intel', threat.enabled && threat.configured ? 'on' : 'warn', threat.enabled ? `${threat.provider || 'unknown'}${threat.configured ? '' : ', key missing'}` : 'disabled'),
|
||||||
capability('Graylog MCP', mcpBadge.state, mcpBadge.detail)
|
capability('Graylog MCP', mcpBadge.state, mcpBadge.detail)
|
||||||
].join('');
|
].join('');
|
||||||
@@ -607,6 +619,7 @@ async function refresh() {
|
|||||||
`Baseline DB size: ${esc(bytes((data.baseline || {}).size_bytes || 0))}`,
|
`Baseline DB size: ${esc(bytes((data.baseline || {}).size_bytes || 0))}`,
|
||||||
`Discovery fields recorded: ${esc((data.baseline || {}).discovery_fields_recorded || 0)}`,
|
`Discovery fields recorded: ${esc((data.baseline || {}).discovery_fields_recorded || 0)}`,
|
||||||
`Discovery cache events: ${esc((data.baseline || {}).discovery_cache_events || 0)}`,
|
`Discovery cache events: ${esc((data.baseline || {}).discovery_cache_events || 0)}`,
|
||||||
|
llm.status === 'error' ? `<span class="sev-high">Ollama assessment error: ${esc(llm.error || 'unknown error')}</span>` : '',
|
||||||
`MCP status: ${esc(mcp.status || 'unknown')}`,
|
`MCP status: ${esc(mcp.status || 'unknown')}`,
|
||||||
mcp.status === 'refreshing' && pollStartedAt ? `MCP poll running: ${esc(pollRunningSeconds)}s` : '',
|
mcp.status === 'refreshing' && pollStartedAt ? `MCP poll running: ${esc(pollRunningSeconds)}s` : '',
|
||||||
pollCompletedAt ? `Last completed MCP poll: ${esc(pollCompletedAge)}s ago` : '',
|
pollCompletedAt ? `Last completed MCP poll: ${esc(pollCompletedAge)}s ago` : '',
|
||||||
|
|||||||
@@ -69,6 +69,12 @@ class DashboardTests(unittest.TestCase):
|
|||||||
def test_dashboard_shows_profile_advisor_fallback_as_notice(self):
|
def test_dashboard_shows_profile_advisor_fallback_as_notice(self):
|
||||||
self.assertIn("heuristic_fallback", HTML)
|
self.assertIn("heuristic_fallback", HTML)
|
||||||
self.assertIn("Profile advisor: heuristic fallback", HTML)
|
self.assertIn("Profile advisor: heuristic fallback", HTML)
|
||||||
|
self.assertIn("heuristic fallback", HTML)
|
||||||
|
|
||||||
|
def test_dashboard_labels_ollama_assessment_errors(self):
|
||||||
|
self.assertIn("function llmCapability", HTML)
|
||||||
|
self.assertIn("assessment error", HTML)
|
||||||
|
self.assertIn("Ollama assessment error", HTML)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user