fix list fields array
This commit is contained in:
@@ -197,7 +197,7 @@ document.getElementById('loadFields').addEventListener('click', async () => {
|
||||
const selected = document.querySelector('.graylog-stream:checked');
|
||||
if (!selected) { document.getElementById('fieldPicker').textContent = 'Load streams, tick one stream, then load its fields.'; return; }
|
||||
const payload = await (await fetch(`/api/graylog/fields?stream_id=${encodeURIComponent(selected.dataset.id)}`)).json();
|
||||
document.getElementById('fieldPicker').innerHTML = (payload.fields || []).map(field => `<div><code>${esc(field.name || field.field)}</code> ${esc(field.type || '')} ${esc((field.capabilities || []).join(', '))}</div>`).join('') || esc(payload.error || 'No fields found.');
|
||||
document.getElementById('fieldPicker').innerHTML = (payload.fields || []).map(field => `<div><code>${esc(field.name || field.field)}</code> ${esc((field.type || {}).type || field.type || '')} ${esc(((field.type || {}).properties || field.capabilities || []).join(', '))}</div>`).join('') || esc(payload.error || 'No fields found.');
|
||||
});
|
||||
document.getElementById('settingsForm').addEventListener('submit', async event => {
|
||||
event.preventDefault();
|
||||
@@ -259,7 +259,9 @@ def serve_dashboard(host: str, port: int, status_file: str, *, image_dir: str |
|
||||
result = client.call_tool("list_fields", {"streams": [stream_id]})
|
||||
content = result.get("result", {}).get("content", [])
|
||||
text = next((item.get("text", "") for item in content if isinstance(item, dict)), "")
|
||||
self._send(200, "application/json", json.dumps({"fields": json.loads(text)}).encode("utf-8"))
|
||||
payload = json.loads(text)
|
||||
fields = payload.get("fields", payload) if isinstance(payload, dict) else payload
|
||||
self._send(200, "application/json", json.dumps({"fields": fields}).encode("utf-8"))
|
||||
except Exception as exc:
|
||||
self._send(400, "application/json", json.dumps({"error": str(exc)}).encode("utf-8"))
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user