Skip to content
Snippets Groups Projects
Commit ed6d4ee9 authored by jrabbit's avatar jrabbit
Browse files

delete timers

parent a9881930
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@ import (
func Version() string {
return "0.0.1a4"
}
var CurrentTimers []Timer
var CurrentAlarms map[string]Alarm
......@@ -18,6 +19,7 @@ func Init() {
CurrentAlarms = make(map[string]Alarm)
CurrentTimers = make([]Timer, 0)
}
type Alarm struct {
Name string
Early bool
......@@ -27,9 +29,11 @@ type Alarm struct {
Uuid uuid.UUID
Creator string
}
func (a *Alarm) String() string {
return fmt.Sprintf("%v by %v", a.Name, a.Creator)
}
type Timer struct {
Name string
Start time.Time
......@@ -63,7 +67,6 @@ func DemoTimer() {
t.Countdown()
}
func debug(ty interface{}) {
fooType := reflect.TypeOf(ty)
fmt.Println(fooType)
......@@ -72,4 +75,3 @@ func debug(ty interface{}) {
fmt.Println(method.Name)
}
}
......@@ -2,10 +2,12 @@ package cmd
import (
"0xacab.org/jrabbit/adormit/adormit"
"github.com/satori/go.uuid"
"github.com/spf13/cobra"
"gopkg.in/macaron.v1"
"log"
"net/http"
"slices"
"strconv"
"time"
)
......@@ -47,6 +49,16 @@ func newTimer(req *http.Request) string {
}
func delTimer(req *http.Request) string {
i := req.FormValue("uuid")
myuuid, _ := uuid.FromString(i)
idxChecker := func(e adormit.Timer) bool {
if e.Uuid == myuuid {
return true
} else {
return false
}
}
slices.DeleteFunc(adormit.CurrentTimers, idxChecker)
return "OK"
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment