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

delete timers

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