chore: 同步之前未提交的改动 (auto_config, ui, console)

This commit is contained in:
tian 2026-07-22 11:16:25 +08:00
parent c440186ce3
commit 3d109b4b11
3 changed files with 21 additions and 1 deletions

View File

@ -714,6 +714,15 @@ func injectIntegrationsIntoConfig(config map[string]any, preview *ConfigPreviewS
setDefault(extAPI, "token_json_path", "responseBody.token")
setDefault(extAPI, "token_cache_sec", float64(1200))
}
// Always add agent alarm reporting (http action to local agent)
if _, ok := actions["http"]; !ok {
actions["http"] = map[string]any{
"enable": true,
"url": "http://127.0.0.1:9100/v1/alarms/report",
"method": "POST",
"timeout_ms": 3000,
}
}
}
}
}

View File

@ -1265,11 +1265,22 @@ func (u *UI) actionConsoleSave(w http.ResponseWriter, r *http.Request) {
devices := u.registry.GetDevices()
// Step 1: collect form features per device.
// Only process devices listed in dirty_device_ids (client-side change detection).
dirtyIDs := strings.Split(strings.TrimSpace(r.FormValue("dirty_device_ids")), ",")
dirtySet := map[string]bool{}
for _, id := range dirtyIDs {
if id != "" {
dirtySet[id] = true
}
}
formFeatures := map[string][]string{}
for _, dev := range devices {
if dev == nil || dev.DeviceID == "" {
continue
}
if len(dirtySet) > 0 && !dirtySet[dev.DeviceID] {
continue
}
features := cleanFormList(r.Form["device_"+dev.DeviceID+"_feature"])
if len(features) > 0 {
formFeatures[dev.DeviceID] = features

View File

@ -24,7 +24,7 @@
<form id="console-form" method="post" action="/console" style="display:contents">
{{range $i, $cd := .ConsoleDevices}}
<div class="console-device-row">
<div class="console-device-row" data-device-id="{{$cd.Device.DeviceID}}">
<div class="console-header">
<span class="status-dot {{if $cd.Device.Online}}ok{{else}}bad{{end}}"></span>
<span class="console-device-name">{{$cd.Device.DisplayName}}</span>