aboutsummaryrefslogtreecommitdiffstats
path: root/dashboard/app/handler.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-11-22 14:27:37 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-11-22 14:36:32 +0100
commit13ab4beeefd2c49666ce771753fbb3a28c9d2f2c (patch)
tree95591888c2e60e548c30e111bdce6e0d2e6a3963 /dashboard/app/handler.go
parent582e1f0d1d51b9237d2dedfcb4c1540b849da8c2 (diff)
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
Diffstat (limited to 'dashboard/app/handler.go')
-rw-r--r--dashboard/app/handler.go87
1 files changed, 2 insertions, 85 deletions
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")