mirror of
https://github.com/golang/go
synced 2024-11-24 21:10:04 -07:00
dashboard: better ui layout for subrepo status
R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/5595048
This commit is contained in:
parent
33b6d46afd
commit
1f5f457ba3
@ -53,12 +53,16 @@ func uiHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
logErr(w, r, err)
|
logErr(w, r, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
builders := commitBuilders(commits)
|
builders := commitBuilders(commits, "")
|
||||||
|
|
||||||
tipState, err := TagState(c, "tip")
|
var tipState *TagState
|
||||||
if err != nil {
|
if page == 0 {
|
||||||
logErr(w, r, err)
|
// only show sub-repo state on first page
|
||||||
return
|
tipState, err = TagStateByName(c, "tip")
|
||||||
|
if err != nil {
|
||||||
|
logErr(w, r, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p := &Pagination{}
|
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
|
// commitBuilders returns the names of the builders that provided
|
||||||
// Results for the provided commits.
|
// Results for the provided commits.
|
||||||
func commitBuilders(commits []*Commit) []string {
|
func commitBuilders(commits []*Commit, goHash string) []string {
|
||||||
builders := make(map[string]bool)
|
builders := make(map[string]bool)
|
||||||
for _, commit := range commits {
|
for _, commit := range commits {
|
||||||
for _, r := range commit.Results("") {
|
for _, r := range commit.Results(goHash) {
|
||||||
builders[r.Builder] = true
|
builders[r.Builder] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,16 +127,20 @@ func keys(m map[string]bool) (s []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackageState represents the state of a Package at a tag.
|
// TagState represents the state of all Packages at a Tag.
|
||||||
type PackageState struct {
|
type TagState struct {
|
||||||
*Package
|
Tag *Commit
|
||||||
*Commit
|
Packages []*PackageState
|
||||||
Results []*Result
|
|
||||||
OK bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TagState fetches the results for all Go subrepos at the specified tag.
|
// PackageState represents the state of a Package at a Tag.
|
||||||
func TagState(c appengine.Context, name string) ([]*PackageState, os.Error) {
|
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)
|
tag, err := GetTag(c, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -141,29 +149,26 @@ func TagState(c appengine.Context, name string) ([]*PackageState, os.Error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var states []*PackageState
|
var st TagState
|
||||||
for _, pkg := range pkgs {
|
for _, pkg := range pkgs {
|
||||||
commit, err := pkg.LastCommit(c)
|
com, err := pkg.LastCommit(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Warningf("%v: no Commit found: %v", pkg, err)
|
c.Warningf("%v: no Commit found: %v", pkg, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
results := commit.Results(tag.Hash)
|
st.Packages = append(st.Packages, &PackageState{pkg, com})
|
||||||
ok := len(results) > 0
|
|
||||||
for _, r := range results {
|
|
||||||
ok = ok && r.OK
|
|
||||||
}
|
|
||||||
states = append(states, &PackageState{
|
|
||||||
pkg, commit, results, ok,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return states, nil
|
st.Tag, err = tag.Commit(c)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &st, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type uiTemplateData struct {
|
type uiTemplateData struct {
|
||||||
Commits []*Commit
|
Commits []*Commit
|
||||||
Builders []string
|
Builders []string
|
||||||
TipState []*PackageState
|
TipState *TagState
|
||||||
Pagination *Pagination
|
Pagination *Pagination
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
background: #eee;
|
background: #eee;
|
||||||
}
|
}
|
||||||
h2 {
|
h2 {
|
||||||
margin-top: 10px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
.build, .packages {
|
.build, .packages {
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
@ -103,23 +103,23 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{{range $c := $.Commits}}
|
{{range $c := $.Commits}}
|
||||||
<tr class="commit">
|
<tr class="commit">
|
||||||
<td class="hash"><a href="{{repoURL .Hash ""}}">{{shortHash .Hash}}</a></td>
|
<td class="hash"><a href="{{repoURL .Hash ""}}">{{shortHash .Hash}}</a></td>
|
||||||
{{range $.Builders}}
|
{{range $.Builders}}
|
||||||
<td class="result">
|
<td class="result">
|
||||||
{{with $c.Result . ""}}
|
{{with $c.Result . ""}}
|
||||||
{{if .OK}}
|
{{if .OK}}
|
||||||
<span class="ok">ok</span>
|
<span class="ok">ok</span>
|
||||||
{{else}}
|
{{else}}
|
||||||
<a href="/log/{{.LogHash}}" class="fail">fail</a>
|
<a href="/log/{{.LogHash}}" class="fail">fail</a>
|
||||||
|
{{end}}
|
||||||
|
{{else}}
|
||||||
|
|
||||||
|
{{end}}
|
||||||
|
</td>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{else}}
|
<td class="user" title="{{.User}}">{{shortUser .User}}</td>
|
||||||
|
<td class="time">{{.Time.Time.Format "Mon 02 Jan 15:04"}}</td>
|
||||||
{{end}}
|
<td class="desc" title="{{.Desc}}">{{shortDesc .Desc}}</td>
|
||||||
</td>
|
|
||||||
{{end}}
|
|
||||||
<td class="user" title="{{.User}}">{{shortUser .User}}</td>
|
|
||||||
<td class="time">{{.Time.Time.Format "Mon 02 Jan 15:04"}}</td>
|
|
||||||
<td class="desc" title="{{.Desc}}">{{shortDesc .Desc}}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
</table>
|
</table>
|
||||||
@ -136,41 +136,72 @@
|
|||||||
<p>No commits to display. Hm.</p>
|
<p>No commits to display. Hm.</p>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if $.TipState}}
|
{{with $.TipState}}
|
||||||
<h2>Other packages</h2>
|
{{$goHash := .Tag.Hash}}
|
||||||
|
<h2>
|
||||||
|
Sub-repositories at tip
|
||||||
|
<small>(<a href="{{repoURL .Tag.Hash ""}}">{{shortHash .Tag.Hash}}</a>)</small>
|
||||||
|
</h2>
|
||||||
|
|
||||||
<table class="packages">
|
<table class="build">
|
||||||
<tr>
|
<colgroup class="col-package"></colgroup>
|
||||||
<th>State</th>
|
<colgroup class="col-hash"></colgroup>
|
||||||
<th>Package</th>
|
{{range $.Builders | builderSpans}}
|
||||||
<th> </th>
|
<colgroup class="col-result" span="{{.N}}"></colgroup>
|
||||||
</tr>
|
{{end}}
|
||||||
{{range $state := $.TipState}}
|
<colgroup class="col-user"></colgroup>
|
||||||
<tr>
|
<colgroup class="col-time"></colgroup>
|
||||||
<td>
|
<colgroup class="col-desc"></colgroup>
|
||||||
{{if .Results}}
|
<tr>
|
||||||
<img src="/static/status_{{if .OK}}good{{else}}alert{{end}}.gif" />
|
<!-- extra row to make alternating colors use dark for first result -->
|
||||||
{{else}}
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
{{range $.Builders | builderSpans}}
|
||||||
|
<th colspan="{{.N}}">{{.OS}}</th>
|
||||||
|
{{end}}
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
{{range $.Builders}}
|
||||||
|
<th class="result arch" title="{{.}}">{{builderArchShort .}}</th>
|
||||||
|
{{end}}
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
{{range $pkg := .Packages}}
|
||||||
|
<tr class="commit">
|
||||||
|
<td><a title="{{.Package.Path}}">{{.Package.Name}}</a></td>
|
||||||
|
<td class="hash">
|
||||||
|
{{$h := $pkg.Commit.Hash}}
|
||||||
|
<a href="{{repoURL $h $pkg.Commit.PackagePath}}">{{shortHash $h}}</a>
|
||||||
|
</td>
|
||||||
|
{{range $.Builders}}
|
||||||
|
<td class="result">
|
||||||
|
{{with $pkg.Commit.Result . $goHash}}
|
||||||
|
{{if .OK}}
|
||||||
|
<span class="ok">ok</span>
|
||||||
|
{{else}}
|
||||||
|
<a href="/log/{{.LogHash}}" class="fail">fail</a>
|
||||||
|
{{end}}
|
||||||
|
{{else}}
|
||||||
|
|
||||||
|
{{end}}
|
||||||
|
</td>
|
||||||
|
{{end}}
|
||||||
|
{{with $pkg.Commit}}
|
||||||
|
<td class="user" title="{{.User}}">{{shortUser .User}}</td>
|
||||||
|
<td class="time">{{.Time.Time.Format "Mon 02 Jan 15:04"}}</td>
|
||||||
|
<td class="desc" title="{{.Desc}}">{{shortDesc .Desc}}</td>
|
||||||
|
{{end}}
|
||||||
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
</td>
|
|
||||||
<td><a title="{{.Package.Path}}">{{.Package.Name}}</a></td>
|
|
||||||
<td>
|
|
||||||
{{range .Results}}
|
|
||||||
<div>
|
|
||||||
{{$h := $state.Commit.Hash}}
|
|
||||||
<a href="{{repoURL $h $state.Commit.PackagePath}}">{{shortHash $h}}</a>
|
|
||||||
{{if .OK}}
|
|
||||||
ok
|
|
||||||
{{else}}
|
|
||||||
<a href="/log/{{.LogHash}}" class="fail">failed</a>
|
|
||||||
{{end}}
|
|
||||||
on {{.Builder}}/<a href="{{repoURL .GoHash ""}}">{{shortHash .GoHash}}</a>
|
|
||||||
</a></div>
|
|
||||||
{{end}}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{end}}
|
|
||||||
</table>
|
</table>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user