| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The LUCI Authors. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 | |
| 15 package frontend | |
| 16 | |
| 17 import ( | |
| 18 "github.com/luci/luci-go/server/router" | |
| 19 "github.com/luci/luci-go/server/templates" | |
| 20 | |
| 21 "github.com/luci/luci-go/common/sync/parallel" | |
| 22 "github.com/luci/luci-go/milo/api/resp" | |
| 23 "github.com/luci/luci-go/milo/buildsource/buildbot" | |
| 24 "github.com/luci/luci-go/milo/buildsource/buildbucket" | |
| 25 "github.com/luci/luci-go/milo/common" | |
| 26 ) | |
| 27 | |
| 28 func frontpageHandler(c *router.Context) { | |
| 29 fp := resp.FrontPage{} | |
| 30 var mBuildbot, mBuildbucket *resp.CIService | |
| 31 | |
| 32 err := parallel.FanOutIn(func(ch chan<- func() error) { | |
| 33 ch <- func() (err error) { | |
| 34 mBuildbot, err = buildbot.GetAllBuilders(c.Context) | |
| 35 return err | |
| 36 } | |
| 37 ch <- func() (err error) { | |
| 38 mBuildbucket, err = buildbucket.GetAllBuilders(c.Context
) | |
| 39 return err | |
| 40 } | |
| 41 }) | |
| 42 | |
| 43 fp.CIServices = append(fp.CIServices, *mBuildbucket) | |
| 44 fp.CIServices = append(fp.CIServices, *mBuildbot) | |
| 45 errMsg := "" | |
| 46 if err != nil { | |
| 47 errMsg = err.Error() | |
| 48 } | |
| 49 templates.MustRender(c.Context, c.Writer, "pages/frontpage.html", templa
tes.Args{ | |
| 50 "frontpage": fp, | |
| 51 "error": errMsg, | |
| 52 }) | |
| 53 } | |
| 54 | |
| 55 func frontpageTestData() []common.TestBundle { | |
| 56 data := &templates.Args{ | |
| 57 "frontpage": resp.FrontPage{ | |
| 58 CIServices: []resp.CIService{ | |
| 59 { | |
| 60 Name: "Module 1", | |
| 61 BuilderGroups: []resp.BuilderGroup{ | |
| 62 { | |
| 63 Name: "Example master A"
, | |
| 64 Builders: []resp.Link{ | |
| 65 *resp.NewLink("E
xample builder", "/master1/buildera"), | |
| 66 *resp.NewLink("E
xample builder 2", "/master1/builderb"), | |
| 67 }, | |
| 68 }, | |
| 69 }, | |
| 70 }, | |
| 71 }, | |
| 72 }, | |
| 73 "error": "couldn't find ice cream", | |
| 74 } | |
| 75 return []common.TestBundle{ | |
| 76 { | |
| 77 Description: "Basic frontpage", | |
| 78 Data: *data, | |
| 79 }, | |
| 80 } | |
| 81 } | |
| OLD | NEW |