Add branding, license, and firmware table improvements
- Add mchus.pro branding to header and footer - Add author info and git repository link - Add proprietary license (Mike Chus) - Firmware table: replace count column with separate component/model columns - Add branding to TXT export reports Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -353,6 +353,15 @@ func (s *Server) handleGetSerials(w http.ResponseWriter, r *http.Request) {
|
||||
Category: "PSU",
|
||||
})
|
||||
}
|
||||
|
||||
// Firmware (using version as "serial number" for display)
|
||||
for _, fw := range result.Hardware.Firmware {
|
||||
serials = append(serials, SerialEntry{
|
||||
Component: fw.DeviceName,
|
||||
SerialNumber: fw.Version,
|
||||
Category: "Firmware",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jsonResponse(w, serials)
|
||||
@@ -364,7 +373,81 @@ func (s *Server) handleGetFirmware(w http.ResponseWriter, r *http.Request) {
|
||||
jsonResponse(w, []interface{}{})
|
||||
return
|
||||
}
|
||||
jsonResponse(w, result.Hardware.Firmware)
|
||||
|
||||
// Deduplicate firmware by extracting model name and version
|
||||
// E.g., "PSU0 (AP-CR3000F12BY)" and "PSU1 (AP-CR3000F12BY)" with same version -> one entry
|
||||
type FirmwareEntry struct {
|
||||
Component string `json:"component"`
|
||||
Model string `json:"model"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
seen := make(map[string]bool)
|
||||
var deduplicated []FirmwareEntry
|
||||
|
||||
for _, fw := range result.Hardware.Firmware {
|
||||
// Extract component type and model from device name
|
||||
component, model := extractFirmwareComponentAndModel(fw.DeviceName)
|
||||
key := component + "|" + model + "|" + fw.Version
|
||||
|
||||
if !seen[key] {
|
||||
seen[key] = true
|
||||
deduplicated = append(deduplicated, FirmwareEntry{
|
||||
Component: component,
|
||||
Model: model,
|
||||
Version: fw.Version,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jsonResponse(w, deduplicated)
|
||||
}
|
||||
|
||||
// extractFirmwareComponentAndModel extracts the component type and model from firmware device name
|
||||
func extractFirmwareComponentAndModel(deviceName string) (component, model string) {
|
||||
// Parse different firmware name formats and extract component + model
|
||||
|
||||
// For "PSU0 (AP-CR3000F12BY)" -> component: "PSU", model: "AP-CR3000F12BY"
|
||||
if strings.HasPrefix(deviceName, "PSU") {
|
||||
if idx := strings.Index(deviceName, "("); idx != -1 {
|
||||
model = strings.Trim(deviceName[idx:], "()")
|
||||
return "PSU", model
|
||||
}
|
||||
return "PSU", "-"
|
||||
}
|
||||
|
||||
// For "CPU0 Microcode" -> component: "CPU Microcode", model: "-"
|
||||
if strings.HasPrefix(deviceName, "CPU") && strings.Contains(deviceName, "Microcode") {
|
||||
return "CPU Microcode", "-"
|
||||
}
|
||||
|
||||
// For "NIC #CPU1_PCIE9 (MCX512A-ACAT)" -> component: "NIC", model: "MCX512A-ACAT"
|
||||
if strings.HasPrefix(deviceName, "NIC ") {
|
||||
if idx := strings.Index(deviceName, "("); idx != -1 {
|
||||
model = strings.Trim(deviceName[idx:], "()")
|
||||
return "NIC", model
|
||||
}
|
||||
return "NIC", "-"
|
||||
}
|
||||
|
||||
// For "HDD Samsung MZ7L33T8HBNA-00A07" -> component: "HDD", model: "Samsung MZ7L33T8HBNA-00A07"
|
||||
if strings.HasPrefix(deviceName, "HDD ") {
|
||||
return "HDD", strings.TrimPrefix(deviceName, "HDD ")
|
||||
}
|
||||
|
||||
// For "SSD Samsung MZ7..." -> component: "SSD", model: "Samsung MZ7..."
|
||||
if strings.HasPrefix(deviceName, "SSD ") {
|
||||
return "SSD", strings.TrimPrefix(deviceName, "SSD ")
|
||||
}
|
||||
|
||||
// For "NVMe KIOXIA..." -> component: "NVMe", model: "KIOXIA..."
|
||||
if strings.HasPrefix(deviceName, "NVMe ") {
|
||||
return "NVMe", strings.TrimPrefix(deviceName, "NVMe ")
|
||||
}
|
||||
|
||||
// For simple names like "BIOS", "ME", "BKC", "Virtual MicroCo"
|
||||
// component = name, model = "-"
|
||||
return deviceName, "-"
|
||||
}
|
||||
|
||||
func (s *Server) handleGetStatus(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user