From 6af9822118dca6c9416c0d13635b13ee68bd13f6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 11 Oct 2013 02:57:36 -0400 Subject: 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. --- Logs/Schedule.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Logs') 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 -- cgit v1.2.3