aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-06-30 16:42:04 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-07-09 19:40:12 +0200
commit353d19019153d6e7ee4e98b18d790b2523901c58 (patch)
tree434cfdf6a7ae4cbccd5a5625aea649ca999713a9
parent894db56cb21049ff801b30b3f294854d6da099de (diff)
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.
-rw-r--r--dashboard/app/handler.go2
-rw-r--r--dashboard/app/main.go28
-rw-r--r--dashboard/app/main.html3
-rw-r--r--dashboard/app/static/style.css24
-rw-r--r--dashboard/app/templates.html16
-rw-r--r--pkg/html/generated.go24
6 files changed, 73 insertions, 24 deletions
diff --git a/dashboard/app/handler.go b/dashboard/app/handler.go
index 561547793..ed55831d8 100644
--- a/dashboard/app/handler.go
+++ b/dashboard/app/handler.go
@@ -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 {
diff --git a/dashboard/app/main.go b/dashboard/app/main.go
index 8df3a787e..1039d230b 100644
--- a/dashboard/app/main.go
+++ b/dashboard/app/main.go
@@ -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,
diff --git a/dashboard/app/main.html b/dashboard/app/main.html
index 79c2b663e..89f273fae 100644
--- a/dashboard/app/main.html
+++ b/dashboard/app/main.html
@@ -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}}
diff --git a/dashboard/app/static/style.css b/dashboard/app/static/style.css
index abe632f9c..ae0a2ae6c 100644
--- a/dashboard/app/static/style.css
+++ b/dashboard/app/static/style.css
@@ -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;
}
diff --git a/dashboard/app/templates.html b/dashboard/app/templates.html
index 163df1d2f..15f3f3d53 100644
--- a/dashboard/app/templates.html
+++ b/dashboard/app/templates.html
@@ -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}}
diff --git a/pkg/html/generated.go b/pkg/html/generated.go
index 67259865b..9ded079bb 100644
--- a/pkg/html/generated.go
+++ b/pkg/html/generated.go
@@ -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;
}