From 353d19019153d6e7ee4e98b18d790b2523901c58 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 30 Jun 2020 16:42:04 +0200 Subject: 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. --- dashboard/app/handler.go | 2 ++ dashboard/app/main.go | 28 +++++++--------------------- dashboard/app/main.html | 3 --- dashboard/app/static/style.css | 24 ++++++++++++++++++++++++ dashboard/app/templates.html | 16 ++++++++++++++++ pkg/html/generated.go | 24 ++++++++++++++++++++++++ 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. {{template "header" .Header}} {{if $.Decommissioned}}

This kernel is DECOMMISSIONED

{{end}} - {{if $.FixedLink}} - fixed bugs ({{$.FixedCount}}) - {{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

syzbot

+ +