diff --git a/keeper.go b/keeper.go index ea58d10..a806acd 100644 --- a/keeper.go +++ b/keeper.go @@ -230,6 +230,16 @@ func (k *Keeper) DelTask(name string) error { return k.save() } +func (k *Keeper) RunTask(name string) error { + fmt.Println("==========runtask==========") + + 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() diff --git a/templates/homepage.html b/templates/homepage.html index 8006c33..c672a0b 100644 --- a/templates/homepage.html +++ b/templates/homepage.html @@ -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; + }; }); @@ -47,6 +59,7 @@