From 1f5f457ba350dfa9d5b03fe4b707967b000e1990 Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Tue, 31 Jan 2012 12:09:56 +1100 Subject: [PATCH] dashboard: better ui layout for subrepo status R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/5595048 --- misc/dashboard/app/build/ui.go | 59 +++++++------- misc/dashboard/app/build/ui.html | 131 +++++++++++++++++++------------ 2 files changed, 113 insertions(+), 77 deletions(-) diff --git a/misc/dashboard/app/build/ui.go b/misc/dashboard/app/build/ui.go index bc5a703455..05bccdc294 100644 --- a/misc/dashboard/app/build/ui.go +++ b/misc/dashboard/app/build/ui.go @@ -53,12 +53,16 @@ func uiHandler(w http.ResponseWriter, r *http.Request) { logErr(w, r, err) return } - builders := commitBuilders(commits) + builders := commitBuilders(commits, "") - tipState, err := TagState(c, "tip") - if err != nil { - logErr(w, r, err) - return + var tipState *TagState + if page == 0 { + // only show sub-repo state on first page + tipState, err = TagStateByName(c, "tip") + if err != nil { + logErr(w, r, err) + return + } } p := &Pagination{} @@ -105,10 +109,10 @@ func goCommits(c appengine.Context, page int) ([]*Commit, os.Error) { // commitBuilders returns the names of the builders that provided // Results for the provided commits. -func commitBuilders(commits []*Commit) []string { +func commitBuilders(commits []*Commit, goHash string) []string { builders := make(map[string]bool) for _, commit := range commits { - for _, r := range commit.Results("") { + for _, r := range commit.Results(goHash) { builders[r.Builder] = true } } @@ -123,16 +127,20 @@ func keys(m map[string]bool) (s []string) { return } -// PackageState represents the state of a Package at a tag. -type PackageState struct { - *Package - *Commit - Results []*Result - OK bool +// TagState represents the state of all Packages at a Tag. +type TagState struct { + Tag *Commit + Packages []*PackageState } -// TagState fetches the results for all Go subrepos at the specified tag. -func TagState(c appengine.Context, name string) ([]*PackageState, os.Error) { +// PackageState represents the state of a Package at a Tag. +type PackageState struct { + Package *Package + Commit *Commit +} + +// TagStateByName fetches the results for all Go subrepos at the specified Tag. +func TagStateByName(c appengine.Context, name string) (*TagState, os.Error) { tag, err := GetTag(c, name) if err != nil { return nil, err @@ -141,29 +149,26 @@ func TagState(c appengine.Context, name string) ([]*PackageState, os.Error) { if err != nil { return nil, err } - var states []*PackageState + var st TagState for _, pkg := range pkgs { - commit, err := pkg.LastCommit(c) + com, err := pkg.LastCommit(c) if err != nil { c.Warningf("%v: no Commit found: %v", pkg, err) continue } - results := commit.Results(tag.Hash) - ok := len(results) > 0 - for _, r := range results { - ok = ok && r.OK - } - states = append(states, &PackageState{ - pkg, commit, results, ok, - }) + st.Packages = append(st.Packages, &PackageState{pkg, com}) } - return states, nil + st.Tag, err = tag.Commit(c) + if err != nil { + return nil, err + } + return &st, nil } type uiTemplateData struct { Commits []*Commit Builders []string - TipState []*PackageState + TipState *TagState Pagination *Pagination } diff --git a/misc/dashboard/app/build/ui.html b/misc/dashboard/app/build/ui.html index 678c95238a..a1ae772f7a 100644 --- a/misc/dashboard/app/build/ui.html +++ b/misc/dashboard/app/build/ui.html @@ -15,7 +15,7 @@ background: #eee; } h2 { - margin-top: 10px; + margin-top: 20px; } .build, .packages { margin: 5px; @@ -103,23 +103,23 @@ {{range $c := $.Commits}} - {{shortHash .Hash}} - {{range $.Builders}} - - {{with $c.Result . ""}} - {{if .OK}} - ok - {{else}} - fail + {{shortHash .Hash}} + {{range $.Builders}} + + {{with $c.Result . ""}} + {{if .OK}} + ok + {{else}} + fail + {{end}} + {{else}} +   + {{end}} + {{end}} - {{else}} -   - {{end}} - - {{end}} - {{shortUser .User}} - {{.Time.Time.Format "Mon 02 Jan 15:04"}} - {{shortDesc .Desc}} + {{shortUser .User}} + {{.Time.Time.Format "Mon 02 Jan 15:04"}} + {{shortDesc .Desc}} {{end}} @@ -136,41 +136,72 @@

No commits to display. Hm.

{{end}} - {{if $.TipState}} -

Other packages

+ {{with $.TipState}} + {{$goHash := .Tag.Hash}} +

+ Sub-repositories at tip + ({{shortHash .Tag.Hash}}) +

- - - - - - - {{range $state := $.TipState}} - -
StatePackage 
- {{if .Results}} - - {{else}} -   + + + + {{range $.Builders | builderSpans}} + + {{end}} + + + + + + + + + + {{range $.Builders | builderSpans}} + + {{end}} + + + + + + + + {{range $.Builders}} + + {{end}} + + + + + {{range $pkg := .Packages}} + + + + {{range $.Builders}} + + {{end}} + {{with $pkg.Commit}} + + + + {{end}} + {{end}} - - - - - {{end}}
{{.OS}}
{{builderArchShort .}}
{{.Package.Name}} + {{$h := $pkg.Commit.Hash}} + {{shortHash $h}} + + {{with $pkg.Commit.Result . $goHash}} + {{if .OK}} + ok + {{else}} + fail + {{end}} + {{else}} +   + {{end}} + {{shortUser .User}}{{.Time.Time.Format "Mon 02 Jan 15:04"}}{{shortDesc .Desc}}
{{.Package.Name}} - {{range .Results}} -
- {{$h := $state.Commit.Hash}} - {{shortHash $h}} - {{if .OK}} - ok - {{else}} - failed - {{end}} - on {{.Builder}}/{{shortHash .GoHash}} -
- {{end}} -
{{end}}