2017-09-26 12:50:09 +00:00
|
|
|
package controller
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/cuigh/auxo/net/web"
|
|
|
|
"github.com/cuigh/swirl/biz/docker"
|
2017-10-10 07:26:07 +00:00
|
|
|
"github.com/cuigh/swirl/misc"
|
2017-09-26 12:50:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type TaskController struct {
|
|
|
|
Detail web.HandlerFunc `path:"/:id/detail" name:"task.detail" authorize:"!" desc:"task detail page"`
|
|
|
|
Raw web.HandlerFunc `path:"/:id/raw" name:"task.raw" authorize:"!" desc:"task raw page"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func Task() (c *TaskController) {
|
|
|
|
c = &TaskController{}
|
|
|
|
|
|
|
|
c.Detail = func(ctx web.Context) error {
|
|
|
|
id := ctx.P("id")
|
|
|
|
task, _, err := docker.TaskInspect(id)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
m := newModel(ctx).Add("Task", task)
|
|
|
|
return ctx.Render("task/detail", m)
|
|
|
|
}
|
|
|
|
|
|
|
|
c.Raw = func(ctx web.Context) error {
|
|
|
|
id := ctx.P("id")
|
|
|
|
task, raw, err := docker.TaskInspect(id)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-10-10 07:26:07 +00:00
|
|
|
j, err := misc.JSONIndent(raw)
|
2017-09-26 12:50:09 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-10-10 07:26:07 +00:00
|
|
|
m := newModel(ctx).Add("Task", task).Add("Raw", j)
|
2017-09-26 12:50:09 +00:00
|
|
|
return ctx.Render("task/raw", m)
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|