feat: 保存集成服务后提示重新下发,设备列表显示需重新下发角标

This commit is contained in:
tian 2026-07-24 19:28:18 +08:00
parent c6591d1eae
commit 8a59f66572
4 changed files with 34 additions and 4 deletions

View File

@ -80,6 +80,7 @@ type ConfigIntegrationServiceAsset struct {
Enabled bool `json:"enabled"`
AddressSummary string `json:"address_summary"`
RefCount int `json:"ref_count"`
UpdatedAt string `json:"updated_at"`
ObjectStorage *ObjectStorageConfig `json:"object_storage,omitempty"`
TokenService *TokenServiceConfig `json:"token_service,omitempty"`
AlarmService *AlarmServiceConfig `json:"alarm_service,omitempty"`
@ -1642,6 +1643,7 @@ func integrationServiceAssetFromRecord(record storage.IntegrationServiceRecord)
Type: firstString(record.ServiceType, stringValue(raw["type"])),
Description: firstString(raw["description"], record.Description),
Enabled: boolValue(raw["enabled"], record.Enabled),
UpdatedAt: record.UpdatedAt,
Raw: raw,
}
item.TypeLabel = integrationTypeLabel(item.Type)

View File

@ -187,9 +187,10 @@ type PageData struct {
}
type DeviceOverviewRow struct {
Device *models.Device
ConfigStatus *ConfigStatusView
ConfigStatusErr string
Device *models.Device
ConfigStatus *ConfigStatusView
ConfigStatusErr string
IntegrationStale bool
}
type TaskDeviceRow struct {
@ -3869,7 +3870,7 @@ func (u *UI) actionAssetIntegrationSave(w http.ResponseWriter, r *http.Request)
http.Redirect(w, r, "/assets/integrations?error="+urlQueryEscape(err.Error())+"&name="+url.PathEscape(asset.Name), http.StatusFound)
return
}
http.Redirect(w, r, "/assets/integrations?msg="+urlQueryEscape("第三方服务已保存")+"&name="+url.PathEscape(asset.Name), http.StatusFound)
http.Redirect(w, r, "/assets/integrations?msg="+urlQueryEscape("第三方服务已保存,请通过部署向导重新下发生效")+"&name="+url.PathEscape(asset.Name), http.StatusFound)
}
func (u *UI) actionAssetIntegrationDelete(w http.ResponseWriter, r *http.Request) {
@ -5112,6 +5113,32 @@ func (u *UI) deviceOverviewPageData(r *http.Request, selectedIDs []string, errMs
selectedIDs = selectedIDsFromQuery(r.URL.Query()["selected"])
}
selectedIDs = filterSelectedDeviceIDs(devices, selectedIDs)
// Check if integrations were updated after device's last deployment
if u.preview != nil {
if svcs, _ := u.preview.ListIntegrationServices(); len(svcs) > 0 {
maxUpdated := ""
for _, s := range svcs {
if s.UpdatedAt > maxUpdated {
maxUpdated = s.UpdatedAt
}
}
if maxUpdated != "" {
for i := range rows {
dev := rows[i].Device
if dev == nil || !dev.Online {
continue
}
status, _, _ := u.loadConfigStatus(dev)
if status == nil || status.Metadata.RenderedAt == "" {
continue
}
rows[i].IntegrationStale = maxUpdated > status.Metadata.RenderedAt
}
}
}
}
data := PageData{
Title: "设备管理",
Devices: devices,

View File

@ -94,6 +94,7 @@
{{else}}
<span class="pill bad">未知</span>
{{end}}
{{if .IntegrationStale}}<span class="pill warn">需重新下发</span>{{end}}
</div>
</div>
</td>

Binary file not shown.