From 13ab4beeefd2c49666ce771753fbb3a28c9d2f2c Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 22 Nov 2018 14:27:37 +0100 Subject: syz-manager: modernize web UI 1. Use dashboard style. 2. Allow sorting of tables. 3. Show old crashes in grey. 4. Use tables instead of text output for more pages. 5. Show corpus inputs on a separate page to allow copy-pasting. 6. Use standard JS sorting instead of custom bubble sort (much faster). 7. Fix off-by one in table sorting. Fixes #694 --- dashboard/app/handler.go | 87 ++---------------------------------------------- 1 file changed, 2 insertions(+), 85 deletions(-) (limited to 'dashboard/app/handler.go') diff --git a/dashboard/app/handler.go b/dashboard/app/handler.go index 3bde1cab5..167ca5857 100644 --- a/dashboard/app/handler.go +++ b/dashboard/app/handler.go @@ -5,12 +5,9 @@ package dash import ( "bytes" - "fmt" - "html/template" "net/http" - "time" - "github.com/google/syzkaller/dashboard/dashapi" + "github.com/google/syzkaller/pkg/html" "golang.org/x/net/context" "google.golang.org/appengine" "google.golang.org/appengine/log" @@ -90,84 +87,4 @@ func commonHeader(c context.Context, r *http.Request) *uiHeader { return h } -func formatTime(t time.Time) string { - if t.IsZero() { - return "" - } - return t.Format("2006/01/02 15:04") -} - -func formatClock(t time.Time) string { - if t.IsZero() { - return "" - } - return t.Format("15:04") -} - -func formatDuration(d time.Duration) string { - if d == 0 { - return "" - } - days := int(d / (24 * time.Hour)) - hours := int(d / time.Hour % 24) - mins := int(d / time.Minute % 60) - if days >= 10 { - return fmt.Sprintf("%vd", days) - } else if days != 0 { - return fmt.Sprintf("%vd%02vh", days, hours) - } else if hours != 0 { - return fmt.Sprintf("%vh%02vm", hours, mins) - } - return fmt.Sprintf("%vm", mins) -} - -func formatLateness(now, t time.Time) string { - if t.IsZero() { - return "never" - } - d := now.Sub(t) - if d < 5*time.Minute { - return "now" - } - return formatDuration(d) -} - -func formatReproLevel(l dashapi.ReproLevel) string { - switch l { - case ReproLevelSyz: - return "syz" - case ReproLevelC: - return "C" - default: - return "" - } -} - -func formatStat(v int64) string { - if v == 0 { - return "" - } - return fmt.Sprint(v) -} - -func formatShortHash(v string) string { - const hashLen = 8 - if len(v) <= hashLen { - return v - } - return v[:hashLen] -} - -var ( - templates = template.Must(template.New("").Funcs(templateFuncs).ParseGlob("*.html")) - - templateFuncs = template.FuncMap{ - "formatTime": formatTime, - "formatClock": formatClock, - "formatDuration": formatDuration, - "formatLateness": formatLateness, - "formatReproLevel": formatReproLevel, - "formatStat": formatStat, - "formatShortHash": formatShortHash, - } -) +var templates = html.CreateGlob("*.html") -- cgit mrf-deployment