Chromium Code Reviews| Index: appengine/cmd/milo/console/html.go |
| diff --git a/appengine/cmd/milo/console/html.go b/appengine/cmd/milo/console/html.go |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8a1f07d612986c1b747bc2539aaca4b3068f1279 |
| --- /dev/null |
| +++ b/appengine/cmd/milo/console/html.go |
| @@ -0,0 +1,88 @@ |
| +// Copyright 2016 The LUCI Authors. All rights reserved. |
| +// Use of this source code is governed under the Apache License, Version 2.0 |
| +// that can be found in the LICENSE file. |
| + |
| +package console |
| + |
| +import ( |
| + "net/http" |
| + |
| + "github.com/julienschmidt/httprouter" |
| + "golang.org/x/net/context" |
| + |
| + "github.com/luci/luci-go/appengine/cmd/milo/miloerror" |
| + "github.com/luci/luci-go/appengine/cmd/milo/resp" |
| + "github.com/luci/luci-go/appengine/cmd/milo/settings" |
| + "github.com/luci/luci-go/common/clock" |
| + log "github.com/luci/luci-go/common/logging" |
| + "github.com/luci/luci-go/server/templates" |
| +) |
| + |
| +type Console struct{} |
| + |
| +// GetTemplateName returns the template name for console pages. |
| +func (x Console) GetTemplateName(t settings.Theme) string { |
| + return "console.html" |
| +} |
| + |
| +type ConsoleDef struct { |
| + Name string |
| + Repository string |
| + Branch string |
| + Builders []resp.BuilderRef |
| +} |
| + |
| +// TODO(hinoka): Move all this into some sorta luci-config thing |
| +var def = ConsoleDef{ |
| + Name: "Chromium Main Waterfall", |
| + Repository: "chromium.googlesource.com/chromium/src", |
|
nodir
2016/08/03 20:26:17
please make it a valid URL, prepend https://
hinoka
2016/08/03 21:55:40
Done.
|
| + Branch: "master", |
| + Builders: []resp.BuilderRef{ |
| + {"buildbot", "chromium/Android", "clobber", "an"}, |
| + {"buildbot", "chromium/Linux x64", "clobber", "lx"}, |
| + {"buildbot", "chromium/Mac", "clobber", "mc"}, |
| + {"buildbot", "chromium/Win", "clobber|win", "32"}, |
| + {"buildbot", "chromium/Win x64", "clobber|win", "64"}, |
| + {"buildbot", "chromium.linux/Android Arm64 Builder (dbg)", "linux|android|arm", "db"}, |
| + {"buildbot", "chromium.linux/Android Builder", "linux|android|x86", "rl"}, |
| + {"buildbot", "chromium.linux/Android Builder (dbg)", "linux|android|x86", "db"}, |
| + {"buildbot", "chromium.linux/Android Clang Builder (dbg)", "linux|android|clang", "db"}, |
| + {"buildbot", "chromium.linux/Android Tests", "linux|android|tests", "db"}, |
| + {"buildbot", "chromium.linux/Android Tests (dbg)", "linux|android|tests", "db"}, |
| + {"buildbot", "chromium.linux/Blimp Linux (dbg)", "linux", "bl"}, |
| + {"buildbot", "chromium.linux/Cast Android (dbg)", "linux|cast", "an"}, |
| + {"buildbot", "chromium.linux/Cast Linux", "linux|cast", "lx"}, |
| + {"buildbot", "chromium.linux/Linux Builder", "linux|build", "rl"}, |
| + {"buildbot", "chromium.linux/Linux Builder (dbg)", "linux|build", "d6"}, |
| + {"buildbot", "chromium.linux/Linux Builder (dbg)(32)", "linux|build", "d3"}, |
| + {"buildbot", "chromium.linux/Linux Tests", "linux|test", "rl"}, |
| + {"buildbot", "chromium.linux/Linux Tests (dbg)(1)", "linux|test", "d1"}, |
| + {"buildbot", "chromium.linux/Linux Tests (dbg)(1)(32)", "linux|test", "d2"}, |
| + }, |
| +} |
| + |
| +// Render Renders the console page. |
|
nodir
2016/08/03 20:26:17
s/Renders/renders/
hinoka
2016/08/03 21:55:40
Done.
|
| +func (x Console) Render(c context.Context, r *http.Request, p httprouter.Params) (*templates.Args, error) { |
| + // Ignore, hardcoded for demo |
| + name := p.ByName("name") |
| + if name == "" { |
| + return nil, &miloerror.Error{ |
| + Message: "No name", |
| + Code: http.StatusBadRequest, |
| + } |
| + } |
| + |
| + t3 := clock.Now(c) |
|
nodir
2016/08/03 20:26:17
rename to start
hinoka
2016/08/03 21:55:40
Removing this, the impl has timing logs
|
| + result, err := console(c, &def) |
| + if err != nil { |
| + return nil, err |
| + } |
| + t4 := clock.Now(c) |
| + log.Debugf(c, "Console took %f seconds.", t4.Sub(t3).Seconds()) |
|
nodir
2016/08/03 20:26:17
use native representation of durations
nodir
2016/08/03 20:26:17
use clock.Since(c, start)
hinoka
2016/08/03 21:55:40
Removed
|
| + |
| + // Render into the template |
| + args := &templates.Args{ |
| + "Console": result, |
| + } |
| + return args, nil |
| +} |