| Index: milo/frontend/view_console.go
|
| diff --git a/milo/frontend/console/console.go b/milo/frontend/view_console.go
|
| similarity index 80%
|
| rename from milo/frontend/console/console.go
|
| rename to milo/frontend/view_console.go
|
| index 74c1b6826a697a2834c9d58aafa1addc77425337..9294005a6db896ddd1605585ee0f466e297e3eb5 100644
|
| --- a/milo/frontend/console/console.go
|
| +++ b/milo/frontend/view_console.go
|
| @@ -1,4 +1,4 @@
|
| -// Copyright 2016 The LUCI Authors.
|
| +// Copyright 2017 The LUCI Authors.
|
| //
|
| // Licensed under the Apache License, Version 2.0 (the "License");
|
| // you may not use this file except in compliance with the License.
|
| @@ -12,7 +12,7 @@
|
| // See the License for the specific language governing permissions and
|
| // limitations under the License.
|
|
|
| -package console
|
| +package frontend
|
|
|
| import (
|
| "fmt"
|
| @@ -22,17 +22,20 @@ import (
|
| "golang.org/x/net/context"
|
|
|
| "github.com/luci/luci-go/common/clock"
|
| + "github.com/luci/luci-go/common/errors"
|
| "github.com/luci/luci-go/common/logging"
|
| + "github.com/luci/luci-go/server/router"
|
| + "github.com/luci/luci-go/server/templates"
|
| +
|
| "github.com/luci/luci-go/milo/api/config"
|
| "github.com/luci/luci-go/milo/api/resp"
|
| "github.com/luci/luci-go/milo/common"
|
| "github.com/luci/luci-go/milo/common/gitiles"
|
| "github.com/luci/luci-go/milo/common/model"
|
| - "github.com/luci/luci-go/server/router"
|
| )
|
|
|
| // Returns results of build[commit_index][builder_index]
|
| -func GetConsoleBuilds(
|
| +func getConsoleBuilds(
|
| c context.Context, builders []resp.BuilderRef, commits []string) (
|
| [][]*model.BuildSummary, error) {
|
|
|
| @@ -52,15 +55,6 @@ func getConsoleDef(c context.Context, project, name string) (*config.Console, er
|
| return cs, nil
|
| }
|
|
|
| -// Main is a redirect handler that redirects the user to the main console for a
|
| -// particular project.
|
| -func Main(ctx *router.Context) {
|
| - w, r, p := ctx.Writer, ctx.Request, ctx.Params
|
| - proj := p.ByName("project")
|
| - http.Redirect(w, r, fmt.Sprintf("/console/%s/main", proj), http.StatusMovedPermanently)
|
| - return
|
| -}
|
| -
|
| func summaryToConsole(bs []*model.BuildSummary) []*resp.ConsoleBuild {
|
| cb := make([]*resp.ConsoleBuild, 0, len(bs))
|
| for _, b := range bs {
|
| @@ -99,7 +93,7 @@ func console(c context.Context, project, name string) (*resp.Console, error) {
|
| b.Name, strings.Split(b.Category, "|"), b.ShortName,
|
| }
|
| }
|
| - cb, err := GetConsoleBuilds(c, builders, commitNames)
|
| + cb, err := getConsoleBuilds(c, builders, commitNames)
|
| tConsole := clock.Now(c)
|
| logging.Debugf(c, "Loading the console took a total of %s.", tConsole.Sub(tGitiles))
|
| if err != nil {
|
| @@ -120,3 +114,32 @@ func console(c context.Context, project, name string) (*resp.Console, error) {
|
|
|
| return cs, nil
|
| }
|
| +
|
| +// ConsoleHandler renders the console page.
|
| +func ConsoleHandler(c *router.Context) {
|
| + project := c.Params.ByName("project")
|
| + if project == "" {
|
| + ErrorHandler(c, errors.New("Missing Project", common.CodeParameterError))
|
| + return
|
| + }
|
| + name := c.Params.ByName("name")
|
| +
|
| + result, err := console(c.Context, project, name)
|
| + if err != nil {
|
| + ErrorHandler(c, err)
|
| + return
|
| + }
|
| +
|
| + templates.MustRender(c.Context, c.Writer, "pages/console.html", templates.Args{
|
| + "Console": result,
|
| + })
|
| +}
|
| +
|
| +// ConsoleMainHandler is a redirect handler that redirects the user to the main
|
| +// console for a particular project.
|
| +func ConsoleMainHandler(ctx *router.Context) {
|
| + w, r, p := ctx.Writer, ctx.Request, ctx.Params
|
| + proj := p.ByName("project")
|
| + http.Redirect(w, r, fmt.Sprintf("/console/%s/main", proj), http.StatusMovedPermanently)
|
| + return
|
| +}
|
|
|