| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package admin | 5 package admin |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "net/http" | 8 "net/http" |
| 9 | 9 |
| 10 "github.com/julienschmidt/httprouter" | 10 "github.com/julienschmidt/httprouter" |
| 11 "golang.org/x/net/context" | 11 "golang.org/x/net/context" |
| 12 | 12 |
| 13 "github.com/luci/luci-go/server/auth" | 13 "github.com/luci/luci-go/server/auth" |
| 14 "github.com/luci/luci-go/server/auth/xsrf" | 14 "github.com/luci/luci-go/server/auth/xsrf" |
| 15 "github.com/luci/luci-go/server/router" |
| 15 "github.com/luci/luci-go/server/settings" | 16 "github.com/luci/luci-go/server/settings" |
| 16 "github.com/luci/luci-go/server/templates" | 17 "github.com/luci/luci-go/server/templates" |
| 17 ) | 18 ) |
| 18 | 19 |
| 19 type fieldWithValue struct { | 20 type fieldWithValue struct { |
| 20 settings.UIField | 21 settings.UIField |
| 21 Value string | 22 Value string |
| 22 } | 23 } |
| 23 | 24 |
| 24 type validationError struct { | 25 type validationError struct { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 37 templates.MustRender(c, rw, "pages/error.html", templates.Args{ | 38 templates.MustRender(c, rw, "pages/error.html", templates.Args{ |
| 38 "Error": "No such settings", | 39 "Error": "No such settings", |
| 39 }) | 40 }) |
| 40 return | 41 return |
| 41 } | 42 } |
| 42 if err := cb(id, page); err != nil { | 43 if err := cb(id, page); err != nil { |
| 43 replyError(c, rw, err) | 44 replyError(c, rw, err) |
| 44 } | 45 } |
| 45 } | 46 } |
| 46 | 47 |
| 47 func settingsPageGET(c context.Context, rw http.ResponseWriter, r *http.Request,
p httprouter.Params) { | 48 func settingsPageGET(ctx *router.Context) { |
| 49 » c, rw, p := ctx.Context, ctx.Writer, ctx.Params |
| 50 |
| 48 withPage(c, rw, p, func(id string, page settings.UIPage) error { | 51 withPage(c, rw, p, func(id string, page settings.UIPage) error { |
| 49 title, err := page.Title(c) | 52 title, err := page.Title(c) |
| 50 if err != nil { | 53 if err != nil { |
| 51 return err | 54 return err |
| 52 } | 55 } |
| 53 overview, err := page.Overview(c) | 56 overview, err := page.Overview(c) |
| 54 if err != nil { | 57 if err != nil { |
| 55 return err | 58 return err |
| 56 } | 59 } |
| 57 fields, err := page.Fields(c) | 60 fields, err := page.Fields(c) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 75 "ID": id, | 78 "ID": id, |
| 76 "Title": title, | 79 "Title": title, |
| 77 "Overview": overview, | 80 "Overview": overview, |
| 78 "Fields": withValues, | 81 "Fields": withValues, |
| 79 "XsrfTokenField": xsrf.TokenField(c), | 82 "XsrfTokenField": xsrf.TokenField(c), |
| 80 }) | 83 }) |
| 81 return nil | 84 return nil |
| 82 }) | 85 }) |
| 83 } | 86 } |
| 84 | 87 |
| 85 func settingsPagePOST(c context.Context, rw http.ResponseWriter, r *http.Request
, p httprouter.Params) { | 88 func settingsPagePOST(ctx *router.Context) { |
| 89 » c, rw, r, p := ctx.Context, ctx.Writer, ctx.Request, ctx.Params |
| 90 |
| 86 withPage(c, rw, p, func(id string, page settings.UIPage) error { | 91 withPage(c, rw, p, func(id string, page settings.UIPage) error { |
| 87 title, err := page.Title(c) | 92 title, err := page.Title(c) |
| 88 if err != nil { | 93 if err != nil { |
| 89 return err | 94 return err |
| 90 } | 95 } |
| 91 fields, err := page.Fields(c) | 96 fields, err := page.Fields(c) |
| 92 if err != nil { | 97 if err != nil { |
| 93 return err | 98 return err |
| 94 } | 99 } |
| 95 | 100 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 if err != nil { | 132 if err != nil { |
| 128 return err | 133 return err |
| 129 } | 134 } |
| 130 templates.MustRender(c, rw, "pages/done.html", templates.Args{ | 135 templates.MustRender(c, rw, "pages/done.html", templates.Args{ |
| 131 "ID": id, | 136 "ID": id, |
| 132 "Title": title, | 137 "Title": title, |
| 133 }) | 138 }) |
| 134 return nil | 139 return nil |
| 135 }) | 140 }) |
| 136 } | 141 } |
| OLD | NEW |