dashboard/app: add navigation buttons

Currently we have only "fixed" link at the top of the page.
"invalid" is missing and this is not scalable.
Add natigation buttons (tabs) for main pages.
This commit is contained in:
Dmitry Vyukov 2020-06-30 16:42:04 +02:00
parent 894db56cb2
commit 353d190191
6 changed files with 73 additions and 24 deletions

View File

@ -92,6 +92,7 @@ func serveTemplate(w http.ResponseWriter, name string, data interface{}) error {
type uiHeader struct {
Admin bool
URLPath string
LoginLink string
AnalyticsTrackingID string
Subpage string
@ -111,6 +112,7 @@ type cookieData struct {
func commonHeaderRaw(c context.Context, r *http.Request) *uiHeader {
h := &uiHeader{
Admin: accessLevel(c, r) == AccessAdmin,
URLPath: r.URL.Path,
AnalyticsTrackingID: config.AnalyticsTrackingID,
}
if user.Current(c) == nil {

View File

@ -47,8 +47,6 @@ type uiMainPage struct {
Header *uiHeader
Now time.Time
Decommissioned bool
FixedLink string
FixedCount int
Managers []*uiManager
Groups []*uiBugGroup
}
@ -222,20 +220,14 @@ func handleMain(c context.Context, w http.ResponseWriter, r *http.Request) error
return err
}
manager := r.FormValue("manager")
groups, fixedCount, err := fetchNamespaceBugs(c, accessLevel, hdr.Namespace, manager)
groups, err := fetchNamespaceBugs(c, accessLevel, hdr.Namespace, manager)
if err != nil {
return err
}
fixedLink := fmt.Sprintf("/%v/fixed", hdr.Namespace)
if manager != "" {
fixedLink = fmt.Sprintf("%v?manager=%v", fixedLink, manager)
}
data := &uiMainPage{
Header: hdr,
Decommissioned: config.Namespaces[hdr.Namespace].Decommissioned,
Now: timeNow(c),
FixedCount: fixedCount,
FixedLink: fixedLink,
Groups: groups,
Managers: managers,
}
@ -547,8 +539,7 @@ func textFilename(tag string) string {
}
}
func fetchNamespaceBugs(c context.Context, accessLevel AccessLevel,
ns, manager string) ([]*uiBugGroup, int, error) {
func fetchNamespaceBugs(c context.Context, accessLevel AccessLevel, ns, manager string) ([]*uiBugGroup, error) {
filter := func(query *db.Query) *db.Query {
query = query.Filter("Namespace=", ns)
if manager != "" {
@ -558,26 +549,21 @@ func fetchNamespaceBugs(c context.Context, accessLevel AccessLevel,
}
bugs, _, err := loadAllBugs(c, filter)
if err != nil {
return nil, 0, err
return nil, err
}
state, err := loadReportingState(c)
if err != nil {
return nil, 0, err
return nil, err
}
managers, err := managerList(c, ns)
if err != nil {
return nil, 0, err
return nil, err
}
fixedCount := 0
groups := make(map[int][]*uiBug)
bugMap := make(map[string]*uiBug)
var dups []*Bug
for _, bug := range bugs {
if bug.Status == BugStatusFixed {
fixedCount++
continue
}
if bug.Status == BugStatusInvalid {
if bug.Status == BugStatusFixed || bug.Status == BugStatusInvalid {
continue
}
if accessLevel < bug.sanitizeAccess(accessLevel) {
@ -640,7 +626,7 @@ func fetchNamespaceBugs(c context.Context, accessLevel AccessLevel,
sort.Slice(uiGroups, func(i, j int) bool {
return uiGroups[i].ShowIndex > uiGroups[j].ShowIndex
})
return uiGroups, fixedCount, nil
return uiGroups, nil
}
func fetchTerminalBugs(c context.Context, accessLevel AccessLevel,

View File

@ -14,9 +14,6 @@ Main page.
<body>
{{template "header" .Header}}
{{if $.Decommissioned}}<h1>This kernel is DECOMMISSIONED</h1>{{end}}
{{if $.FixedLink}}
<a href="{{$.FixedLink}}">fixed bugs ({{$.FixedCount}})</a>
{{end}}
{{template "manager_list" $.Managers}}
{{range $group := $.Groups}}
{{template "bug_list" $group}}

View File

@ -15,6 +15,24 @@ h1, h2, h3, h4 {
font-weight: bold;
}
.navigation_tab {
border: 1px solid black;
padding: 4px;
margin: 4px;
}
.navigation_tab_selected {
font-weight: bold;
border: 2px solid black;
padding: 4px;
margin: 4px;
}
.position_table .navigation {
padding-top: 15px;
padding-bottom: 6px;
}
table {
border: 1px solid #ccc;
margin: 20px 5px;
@ -53,6 +71,12 @@ table td, table th {
padding: 0px;
}
.position_table .namespace_td {
width: 100%;
padding-top: 10px;
padding-left: 20px;
}
.position_table .search {
text-align: right;
}

View File

@ -30,6 +30,8 @@ Use of this source code is governed by Apache 2 LICENSE that can be found in the
<tr>
<td>
<h1><a href="/{{$.Namespace}}">syzbot</a></h1>
</td>
<td class="namespace_td">
<select class="namespace" onchange="window.location.href = '/' + this.value + '{{.Subpage}}';">
{{- range $ns := .Namespaces}}
<option value="{{$ns.Name}}" {{if eq $.Namespace $ns.Name}}selected="1"{{end}}>
@ -51,6 +53,20 @@ Use of this source code is governed by Apache 2 LICENSE that can be found in the
</td>
</tr>
</table>
{{if not (eq .URLPath "/admin")}}
<table class="position_table">
<tr>
<td class="navigation">
<a class="navigation_tab{{if eq .URLPath (printf "/%v" $.Namespace)}}_selected{{end}}" href='/{{$.Namespace}}'>
<span style="color:DeepPink;">🐞</span> Open</a>
<a class="navigation_tab{{if eq .URLPath (printf "/%v/fixed" $.Namespace)}}_selected{{end}}" href='/{{$.Namespace}}/fixed'>
<span style="color:ForestGreen;">🐞</span> Fixed</a>
<a class="navigation_tab{{if eq .URLPath (printf "/%v/invalid" $.Namespace)}}_selected{{end}}" href='/{{$.Namespace}}/invalid'>
<span style="color:RoyalBlue;">🐞</span> Invalid</a>
</td>
</tr>
</table>
{{end}}
</header>
<br>
{{end}}

View File

@ -18,6 +18,24 @@ h1, h2, h3, h4 {
font-weight: bold;
}
.navigation_tab {
border: 1px solid black;
padding: 4px;
margin: 4px;
}
.navigation_tab_selected {
font-weight: bold;
border: 2px solid black;
padding: 4px;
margin: 4px;
}
.position_table .navigation {
padding-top: 15px;
padding-bottom: 6px;
}
table {
border: 1px solid #ccc;
margin: 20px 5px;
@ -56,6 +74,12 @@ table td, table th {
padding: 0px;
}
.position_table .namespace_td {
width: 100%;
padding-top: 10px;
padding-left: 20px;
}
.position_table .search {
text-align: right;
}