makeReport generates a report for the specified command. If configEditor is not null, it is used to edit the config used for the report.
(w http.ResponseWriter, req *http.Request, cmd []string, configEditor func(*config))
| 259 | // makeReport generates a report for the specified command. |
| 260 | // If configEditor is not null, it is used to edit the config used for the report. |
| 261 | func (ui *webInterface) makeReport(w http.ResponseWriter, req *http.Request, |
| 262 | cmd []string, configEditor func(*config)) (*report.Report, []string) { |
| 263 | cfg := currentConfig() |
| 264 | if err := cfg.applyURL(req.URL.Query()); err != nil { |
| 265 | http.Error(w, err.Error(), http.StatusBadRequest) |
| 266 | ui.options.UI.PrintErr(err) |
| 267 | return nil, nil |
| 268 | } |
| 269 | if configEditor != nil { |
| 270 | configEditor(&cfg) |
| 271 | } |
| 272 | catcher := &errorCatcher{UI: ui.options.UI} |
| 273 | options := *ui.options |
| 274 | options.UI = catcher |
| 275 | _, rpt, err := generateRawReport(ui.copier.newCopy(), cmd, cfg, &options) |
| 276 | if err != nil { |
| 277 | http.Error(w, err.Error(), http.StatusBadRequest) |
| 278 | ui.options.UI.PrintErr(err) |
| 279 | return nil, nil |
| 280 | } |
| 281 | return rpt, catcher.errors |
| 282 | } |
| 283 | |
| 284 | // renderHTML generates html using the named template based on the contents of data. |
| 285 | func renderHTML(dst io.Writer, tmpl string, rpt *report.Report, errList, legend []string, data webArgs) error { |