package webcmd import ( "fmt" "net/http" "sort" "time" ) type TaskListItem struct { ref string start int64 } type TaskList []TaskListItem func (tl TaskList) Len() int { return len(tl) } func (tl TaskList) Swap(i, j int) { tl[i], tl[j] = tl[j], tl[i] } func (tl TaskList) Less(i, j int) bool { return tl[i].start < tl[j].start } func (this *App) Serve_Tasks(w http.ResponseWriter) { w.Header().Set("Content-Type", "text/html;charset=UTF-8") w.WriteHeader(200) this.ServePartial_Header(w, "/tasks") fmt.Fprint(w, `
Task | Started | State |
---|---|---|
%s | %s | `, hesc(ref), hesc(ref), hesc(startTime.Format(time.RFC3339)), hesc(startTime.Format(time.RFC822)), ) if t.Finished() { fmt.Fprint(w, `Finished`) } else { fmt.Fprint(w, `Running`) } fmt.Fprint(w, ` |