Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ func (k *Keeper) DelTask(name string) error {
return k.save()
}

func (k *Keeper) RunTask(name string) error {
fmt.Println("==========runtask==========")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to remove all log output in go and js


if tk, ok := k.tasks[name]; ok {
tk.Run(TRIGGER_MANUAL)
return nil
}
return errors.New("Can't run tasks")
}

func (k *Keeper) PutTask(name string, t Task) error {
k.tkmu.Lock()
defer k.tkmu.Unlock()
Expand Down
13 changes: 13 additions & 0 deletions templates/homepage.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
}
var top = 400;
var duration = 2000;
$scope.runTask = function(taskName){
console.log(taskName);
$http.post("/run/",{'name':taskName})
.success(function(res){
console.log("return");
})
.error(function(res){
console.log("err");
});
window.location="/"+taskName
return false;
};


});
Expand Down Expand Up @@ -47,6 +59,7 @@ <h3><span class="glyphicon" ng-class="t.exit_code ? 'glyphicon-remove' : 'glyphi
{{t.name}}</h3>
</a>
<span class="pull-right">
<a class="quick-link" href="javascript:;" ng-click=runTask(t.name) ><span class="glyphicon glyphicon-play"></span></a>
<a class="quick-link" ng-hide="t.status == 'pending'" href="/{{t.name}}/builds/{{t.index}}">
#{{t.index}}
</a>
Expand Down
19 changes: 19 additions & 0 deletions web.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,25 @@ func initRoutes() {
ctx.HTML(200, "settings")
})

m.Post("/run/", func(ctx *macaron.Context) {
type T struct {
Name string
}
var t T
dec := json.NewDecoder(ctx.Req.Body().ReadCloser())
if err := dec.Decode(&t); err != nil {
ctx.Error(500, err.Error())
return
}
log.Println(t.Name)
if err := keeper.RunTask(t.Name); err != nil {
ctx.Error(500, err.Error())
return
}

ctx.JSON(200, "success")
})

m.Get("/api/records/:name/index/:index", func(ctx *macaron.Context) {
name := ctx.Params(":name")
index := ctx.ParamsInt(":index")
Expand Down