Files
core/internal/api/ui_index.tmpl

85 lines
2.8 KiB
Cheetah

{{define "index"}}
<!DOCTYPE html>
<html lang="en">
{{template "head" .}}
<body>
{{template "topbar" .}}
<main class="container">
<section class="card">
<h2>Registry Snapshot</h2>
<div class="stats">
<div class="stat"><span>Projects</span><strong>{{.ProjectCount}}</strong></div>
<div class="stat"><span>Assets</span><strong>{{.AssetCount}}</strong></div>
<div class="stat"><span>Components</span><strong>{{.ComponentCount}}</strong></div>
</div>
</section>
<section class="card">
<h2>Latest Assets</h2>
{{if .Assets}}
<table class="table">
<thead>
<tr>
<th>Status</th>
<th>Name</th>
<th>Vendor Serial</th>
<th>Project</th>
<th>Created</th>
</tr>
</thead>
<tbody>
{{range $i, $item := .Assets}}
{{if lt $i 5}}
<tr class="clickable" onclick="navigateToRow('/ui/assets/{{$item.ID}}')">
<td><span class="badge {{assetStatusClass (index $.AssetStatusByID $item.ID)}}">{{assetStatusText (index $.AssetStatusByID $item.ID)}}</span></td>
<td>{{$item.Name}}</td>
<td>{{$item.VendorSerial}}</td>
<td>{{projectName $item.ProjectID $.ProjectByID}}</td>
<td title="{{formatTimeFull $item.CreatedAt}}">{{formatTime $item.CreatedAt}}</td>
</tr>
{{end}}
{{end}}
</tbody>
</table>
{{else}}
<div class="meta">No assets yet.</div>
{{end}}
<div class="meta"><a href="/ui/assets">View all assets</a></div>
</section>
<section class="card">
<h2>Latest Components</h2>
{{if .Components}}
<table class="table">
<thead>
<tr>
<th>Status</th>
<th>Vendor Serial</th>
<th>First Seen</th>
<th>Created</th>
</tr>
</thead>
<tbody>
{{range $i, $item := .Components}}
{{if lt $i 5}}
<tr class="clickable" onclick="navigateToRow('/ui/components/{{$item.ID}}')">
<td><span class="badge {{componentStatusClass (index $.ComponentStatusByID $item.ID)}}">{{componentStatusText (index $.ComponentStatusByID $item.ID)}}</span></td>
<td>{{componentLabelByID $item.ID $.ComponentLabelByID}}</td>
<td title="{{formatTimePtrFull $item.FirstSeenAt}}">{{formatTimePtr $item.FirstSeenAt}}</td>
<td title="{{formatTimeFull $item.CreatedAt}}">{{formatTime $item.CreatedAt}}</td>
</tr>
{{end}}
{{end}}
</tbody>
</table>
{{else}}
<div class="meta">No components yet.</div>
{{end}}
<div class="meta"><a href="/ui/components">View all components</a></div>
</section>
</main>
</body>
</html>
{{end}}