summaryrefslogtreecommitdiff
path: root/Logs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-10-11 02:57:36 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-10-11 03:04:11 -0400
commit6af9822118dca6c9416c0d13635b13ee68bd13f6 (patch)
treeb130674e0586605006b0ff9a141bce7b5c7d8df9 /Logs
parent477f118bfd8b959fd8b36a1b39bb0e5f58c129ed (diff)
add/remove/edit schedule UI working
Once I built the basic widget, it turned out to be rather easy to replicate it once per scheduled activity and wire it all up to a fully working UI. This does abuse yesod's form handling a bit, but I think it's ok. And it would be nice to have it all ajax-y, so that saving one modified form won't lose any modifications to other forms. But for now, a nice simple 115 line of code implementation is a win. This late night hack session commit was sponsored by Andrea Rota.
Diffstat (limited to 'Logs')
-rw-r--r--Logs/Schedule.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/Logs/Schedule.hs b/Logs/Schedule.hs
index 7fc210c14..35745b9f3 100644
--- a/Logs/Schedule.hs
+++ b/Logs/Schedule.hs
@@ -8,6 +8,9 @@
module Logs.Schedule (
scheduleLog,
scheduleSet,
+ scheduleAdd,
+ scheduleRemove,
+ scheduleChange,
scheduleGet,
scheduleMap,
getLastRunTimes,
@@ -46,6 +49,15 @@ scheduleGet u = do
m <- scheduleMap
return $ maybe S.empty S.fromList (M.lookup u m)
+scheduleRemove :: UUID -> ScheduledActivity -> Annex ()
+scheduleRemove u activity = scheduleChange u $ S.delete activity
+
+scheduleAdd :: UUID -> ScheduledActivity -> Annex ()
+scheduleAdd u activity = scheduleChange u $ S.insert activity
+
+scheduleChange :: UUID -> (S.Set ScheduledActivity -> S.Set ScheduledActivity) -> Annex ()
+scheduleChange u a = scheduleSet u . S.toList . a =<< scheduleGet u
+
getLastRunTimes :: Annex (M.Map ScheduledActivity LocalTime)
getLastRunTimes = do
f <- fromRepo gitAnnexScheduleState