add CONTAINER_DETAILS env var (#1305)

This commit is contained in:
henrygd
2025-10-25 15:33:01 -04:00
parent 1dee63a0eb
commit a9657f9c00
2 changed files with 9 additions and 6 deletions

View File

@@ -252,12 +252,15 @@ func (h *Hub) registerApiRoutes(se *core.ServeEvent) error {
// update / delete user alerts // update / delete user alerts
apiAuth.POST("/user-alerts", alerts.UpsertUserAlerts) apiAuth.POST("/user-alerts", alerts.UpsertUserAlerts)
apiAuth.DELETE("/user-alerts", alerts.DeleteUserAlerts) apiAuth.DELETE("/user-alerts", alerts.DeleteUserAlerts)
// get container logs
apiAuth.GET("/containers/logs", h.getContainerLogs)
// get container info
apiAuth.GET("/containers/info", h.getContainerInfo)
// get SMART data // get SMART data
apiAuth.GET("/smart", h.getSmartData) apiAuth.GET("/smart", h.getSmartData)
// /containers routes
if enabled, _ := GetEnv("CONTAINER_DETAILS"); enabled != "false" {
// get container logs
apiAuth.GET("/containers/logs", h.getContainerLogs)
// get container info
apiAuth.GET("/containers/info", h.getContainerInfo)
}
return nil return nil
} }

View File

@@ -234,7 +234,7 @@ async function getLogsHtml(container: ContainerRecord): Promise<string> {
system: container.system, system: container.system,
container: container.id, container: container.id,
})]) })])
return highlighter.codeToHtml(logsHtml.logs, { lang: "log", theme: syntaxTheme }) return logsHtml.logs ? highlighter.codeToHtml(logsHtml.logs, { lang: "log", theme: syntaxTheme }) : t`No results.`
} catch (error) { } catch (error) {
console.error(error) console.error(error)
return "" return ""
@@ -250,7 +250,7 @@ async function getInfoHtml(container: ContainerRecord): Promise<string> {
try { try {
info = JSON.stringify(JSON.parse(info), null, 2) info = JSON.stringify(JSON.parse(info), null, 2)
} catch (_) { } } catch (_) { }
return highlighter.codeToHtml(info, { lang: "json", theme: syntaxTheme }) return info ? highlighter.codeToHtml(info, { lang: "json", theme: syntaxTheme }) : t`No results.`
} catch (error) { } catch (error) {
console.error(error) console.error(error)
return "" return ""