128 lines
11 KiB
Go
128 lines
11 KiB
Go
// Code generated by templ - DO NOT EDIT.
|
|
|
|
// templ: version: v0.3.1001
|
|
package views
|
|
|
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
|
|
|
import "github.com/a-h/templ"
|
|
import templruntime "github.com/a-h/templ/runtime"
|
|
|
|
import (
|
|
"strings"
|
|
"vctp/components/core"
|
|
)
|
|
|
|
type BuildInfo struct {
|
|
BuildTime string
|
|
SHA1Ver string
|
|
GoVersion string
|
|
}
|
|
|
|
func truncateSHA(sha string) string {
|
|
trimmed := strings.TrimSpace(sha)
|
|
if len(trimmed) <= 14 {
|
|
return trimmed
|
|
}
|
|
return trimmed[:14] + "..."
|
|
}
|
|
|
|
func Index(info BuildInfo) templ.Component {
|
|
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
return templ_7745c5c3_CtxErr
|
|
}
|
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
if !templ_7745c5c3_IsBuffer {
|
|
defer func() {
|
|
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err == nil {
|
|
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
}
|
|
}()
|
|
}
|
|
ctx = templ.InitializeContext(ctx)
|
|
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
|
if templ_7745c5c3_Var1 == nil {
|
|
templ_7745c5c3_Var1 = templ.NopComponent
|
|
}
|
|
ctx = templ.ClearChildren(ctx)
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<!doctype html><html lang=\"en\">")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = core.Header().Render(ctx, templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<body class=\"flex flex-col min-h-screen web2-bg\"><main class=\"flex-grow web2-shell web2-card-grid\"><section class=\"web2-header web2-page-head\"><div class=\"web2-page-head-row\"><div class=\"web2-head-copy\"><div class=\"web2-pill\">vCTP Console</div><h1 class=\"web2-page-title\">Chargeback Intelligence Dashboard</h1><p class=\"web2-page-subtitle\">Point-in-time snapshots of vSphere consumption with LDAP and JWT-protected API access.</p></div><div class=\"web2-actions\"><a class=\"web2-button\" href=\"/snapshots/hourly\">Hourly Snapshots</a> <a class=\"web2-button\" href=\"/snapshots/daily\">Daily Snapshots</a> <a class=\"web2-button\" href=\"/snapshots/monthly\">Monthly Snapshots</a> <a class=\"web2-button\" href=\"/vm/trace\">VM Trace</a> <a class=\"web2-button secondary\" href=\"/vcenters\">vCenters</a> <a class=\"web2-button secondary\" href=\"/swagger/\">Swagger UI</a></div></div><div class=\"web2-note\">When authentication is enabled, obtain a token from <code class=\"web2-code\">POST /api/auth/login</code> and send it as <code class=\"web2-code\">Authorization: Bearer <token></code>. Role policy: <code class=\"web2-code\">viewer</code> covers read/report APIs, <code class=\"web2-code\">admin</code> covers mutating/admin APIs (and includes viewer). UI pages and <code class=\"web2-code\">/metrics</code> remain public.</div></section><section class=\"web2-kpi-grid\"><div class=\"web2-card\"><p class=\"web2-kpi-label\">Build Time</p><p class=\"web2-kpi-value\">")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
var templ_7745c5c3_Var2 string
|
|
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(info.BuildTime)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/index.templ`, Line: 51, Col: 48}
|
|
}
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</p></div><div class=\"web2-card\"><p class=\"web2-kpi-label\">SHA1 Version</p><p class=\"web2-kpi-value web2-kpi-value-mono web2-kpi-truncate\" title=\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
var templ_7745c5c3_Var3 string
|
|
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(info.SHA1Ver)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/index.templ`, Line: 55, Col: 90}
|
|
}
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "\">")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
var templ_7745c5c3_Var4 string
|
|
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(truncateSHA(info.SHA1Ver))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/index.templ`, Line: 55, Col: 120}
|
|
}
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</p></div><div class=\"web2-card\"><p class=\"web2-kpi-label\">Go Runtime</p><p class=\"web2-kpi-value\">")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
var templ_7745c5c3_Var5 string
|
|
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(info.GoVersion)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/index.templ`, Line: 59, Col: 48}
|
|
}
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "</p></div></section><section class=\"web2-index-sections\"><div class=\"web2-card web2-card-overview web2-index-overview\"><h2 class=\"mb-2\">Overview</h2><p class=\"web2-page-subtitle\">vCTP is a vSphere Chargeback Tracking Platform.</p><p class=\"web2-page-subtitle\">Use fast vCenter totals views (Daily Aggregated and Hourly Detail 45d) and VM Trace views (Hourly Detail and Daily Aggregated) to move between long-range trends and granular timelines.</p><p class=\"web2-page-subtitle\">Use <code class=\"web2-code\">/api/auth/me</code> to inspect active claims and roles during integration and diagnostics.</p></div><div class=\"web2-card web2-card-featured web2-index-featured\"><h2 class=\"mb-2\">Snapshots and Reports</h2><div class=\"web2-paragraphs web2-page-subtitle\"><p>Hourly snapshots capture inventory per vCenter (concurrency via <code class=\"web2-code\">hourly_snapshot_concurrency</code>), then daily and monthly summaries are derived from those snapshots.</p><p><strong>Hourly tracks:</strong> VM identity (<code class=\"web2-code\">InventoryId</code>, <code class=\"web2-code\">Name</code>, <code class=\"web2-code\">VmId</code>, <code class=\"web2-code\">VmUuid</code>, <code class=\"web2-code\">Vcenter</code>, <code class=\"web2-code\">EventKey</code>, <code class=\"web2-code\">CloudId</code>), lifecycle (<code class=\"web2-code\">CreationTime</code>, <code class=\"web2-code\">DeletionTime</code>, <code class=\"web2-code\">SnapshotTime</code>), placement (<code class=\"web2-code\">Datacenter</code>, <code class=\"web2-code\">Cluster</code>, <code class=\"web2-code\">Folder</code>, <code class=\"web2-code\">ResourcePool</code>), and sizing/state (<code class=\"web2-code\">VcpuCount</code>, <code class=\"web2-code\">RamGB</code>, <code class=\"web2-code\">ProvisionedDisk</code>, <code class=\"web2-code\">PoweredOn</code>, <code class=\"web2-code\">IsTemplate</code>, <code class=\"web2-code\">SrmPlaceholder</code>).</p><p><strong>Daily tracks:</strong> <code class=\"web2-code\">SamplesPresent</code>, <code class=\"web2-code\">TotalSamples</code>, <code class=\"web2-code\">AvgIsPresent</code>, <code class=\"web2-code\">AvgVcpuCount</code>, <code class=\"web2-code\">AvgRamGB</code>, <code class=\"web2-code\">AvgProvisionedDisk</code>, <code class=\"web2-code\">PoolTinPct</code>, <code class=\"web2-code\">PoolBronzePct</code>, <code class=\"web2-code\">PoolSilverPct</code>, <code class=\"web2-code\">PoolGoldPct</code>, plus chargeback totals columns <code class=\"web2-code\">Tin</code>, <code class=\"web2-code\">Bronze</code>, <code class=\"web2-code\">Silver</code>, <code class=\"web2-code\">Gold</code>.</p><p><strong>Monthly tracks:</strong> the same daily aggregate fields, with monthly values weighted by per-day sample volume so partial-day VMs and config changes stay proportional.</p><p>Snapshots are registered in <code class=\"web2-code\">snapshot_registry</code> so regeneration via <code class=\"web2-code\">/api/snapshots/aggregate</code> can locate the correct tables (fallback scanning is also supported).</p><p>vCenter totals pages are accelerated by compact cache tables: <code class=\"web2-code\">vcenter_latest_totals</code> and <code class=\"web2-code\">vcenter_aggregate_totals</code>.</p><p>VM Trace daily mode uses the <code class=\"web2-code\">vm_daily_rollup</code> cache when available, and falls back to daily summary tables if needed.</p><p>Reports (XLSX with totals/charts) are generated automatically after hourly, daily, and monthly jobs and written to a reports directory.</p><p>Hourly totals are interval-based: each row represents <code class=\"web2-code\">[HH:00, HH+1:00)</code> and uses the first snapshot at or after the hour end (including cross-day snapshots) to prorate VM presence.</p><p>Monthly aggregation reports include a Daily Totals sheet with full-day interval labels (YYYY-MM-DD to YYYY-MM-DD) and prorated totals.</p></div></div><div class=\"web2-card web2-index-wide\"><h2 class=\"mb-2\">Prorating and Aggregation</h2><div class=\"web2-paragraphs web2-page-subtitle\"><p><code class=\"web2-code\">SamplesPresent</code> is the count of snapshots in which the VM appears; <code class=\"web2-code\">TotalSamples</code> is the count of unique snapshot times for that vCenter/day.</p><p><code class=\"web2-code\">AvgIsPresent = SamplesPresent / TotalSamples</code> (0 when <code class=\"web2-code\">TotalSamples</code> is 0).</p><p>Daily <code class=\"web2-code\">AvgVcpuCount</code>, <code class=\"web2-code\">AvgRamGB</code>, and <code class=\"web2-code\">AvgProvisionedDisk</code> are per-sample sums divided by <code class=\"web2-code\">TotalSamples</code> (time-weighted).</p><p>Daily pool percentages (<code class=\"web2-code\">PoolTinPct</code>/<code class=\"web2-code\">PoolBronzePct</code>/<code class=\"web2-code\">PoolSilverPct</code>/<code class=\"web2-code\">PoolGoldPct</code>) use pool-hit counts divided by <code class=\"web2-code\">SamplesPresent</code>.</p><p>Monthly aggregation converts each day into weighted sums using sample volume, then recomputes monthly averages and pool percentages from those weighted totals.</p><p>CreationTime is only set when vCenter provides it; otherwise it remains 0.</p></div></div></section></main></body>")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = core.Footer().Render(ctx, templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "</html>")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
var _ = templruntime.GeneratedTemplate
|