Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions internal/admin/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"strings"

"gomodel/config"
"gomodel/internal/version"

"github.com/labstack/echo/v5"
)
Expand Down Expand Up @@ -66,12 +67,13 @@ func NewWithBasePath(basePath string) (*Handler, error) {

type templateData struct {
BasePath string
Version string
}

// Index serves GET /admin/dashboard — the main dashboard page.
func (h *Handler) Index(c *echo.Context) error {
var buf bytes.Buffer
if err := h.indexTmpl.ExecuteTemplate(&buf, "layout", templateData{BasePath: h.basePath}); err != nil {
if err := h.indexTmpl.ExecuteTemplate(&buf, "layout", templateData{BasePath: h.basePath, Version: version.Info()}); err != nil {
slog.Error("failed to render admin dashboard", "path", c.Request().URL.Path, "error", err)
return err
}
Expand Down Expand Up @@ -113,8 +115,8 @@ func assetURL(basePath, assetPath string, versions map[string]string) string {
return config.JoinBasePath(basePath, "/admin/static/")
}
urlPath := config.JoinBasePath(basePath, "/admin/static/"+normalizedPath)
if version := versions[normalizedPath]; version != "" {
return urlPath + "?v=" + version
if v := versions[normalizedPath]; v != "" {
return urlPath + "?v=" + v
}
return urlPath
}
6 changes: 6 additions & 0 deletions internal/admin/dashboard/dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ func TestIndex_ReturnsHTML(t *testing.T) {
if !regexp.MustCompile(`/admin/static/css/dashboard\.css\?v=[0-9a-f]+`).MatchString(rec.Body.String()) {
t.Errorf("expected versioned dashboard CSS link in page HTML")
}
if !strings.Contains(body, "settings-version-footer") {
t.Errorf("expected settings-version-footer element in page HTML")
}
if !strings.Contains(body, "gomodel ") {
t.Errorf("expected gomodel version string in page HTML")
}
}

func TestIndex_UsesBasePathForGeneratedURLs(t *testing.T) {
Expand Down
7 changes: 7 additions & 0 deletions internal/admin/dashboard/static/css/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -3414,6 +3414,13 @@ body.conversation-drawer-open {
border-top: 1px solid var(--border);
}

.settings-version-footer {
margin-top: 24px;
color: var(--text-muted);
font-size: 12px;
text-align: right;
}

.settings-refresh-section h3 {
font-size: 18px;
}
Expand Down
2 changes: 2 additions & 0 deletions internal/admin/dashboard/templates/page-settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ <h3>Runtime Refresh</h3>
</ul>
</div>
</div>

<p class="settings-version-footer mono">{{.Version}}</p>
</div>
</template>
{{end}}
Loading