diff options
Diffstat (limited to 'Assistant')
-rw-r--r-- | Assistant/DeleteRemote.hs | 9 | ||||
-rw-r--r-- | Assistant/NamedThread.hs | 27 | ||||
-rw-r--r-- | Assistant/Threads/TransferScanner.hs | 2 | ||||
-rw-r--r-- | Assistant/Types/UrlRenderer.hs | 26 |
4 files changed, 45 insertions, 19 deletions
diff --git a/Assistant/DeleteRemote.hs b/Assistant/DeleteRemote.hs index 59aff57fe..a23eeaa8e 100644 --- a/Assistant/DeleteRemote.hs +++ b/Assistant/DeleteRemote.hs @@ -5,13 +5,18 @@ - Licensed under the GNU GPL version 3 or higher. -} +{-# LANGUAGE CPP #-} + module Assistant.DeleteRemote where import Assistant.Common -import Assistant.WebApp +#ifdef WITH_WEBAPP import Assistant.WebApp.Types +import Assistant.WebApp +#endif import Assistant.Alert import Assistant.DaemonStatus +import Assistant.Types.UrlRenderer import qualified Remote import Remote.List import qualified Git.Command @@ -42,6 +47,7 @@ finishRemovingRemote urlrenderer uuid = do void $ removeRemote uuid liftAnnex $ trustSet uuid DeadTrusted +#ifdef WITH_WEBAPP desc <- liftAnnex $ Remote.prettyUUID uuid url <- liftIO $ renderUrl urlrenderer (FinishedDeletingRepositoryContentsR uuid) [] close <- asIO1 removeAlert @@ -50,3 +56,4 @@ finishRemovingRemote urlrenderer uuid = do , buttonUrl = url , buttonAction = Just close } +#endif diff --git a/Assistant/NamedThread.hs b/Assistant/NamedThread.hs index 33af2c304..1d291ba74 100644 --- a/Assistant/NamedThread.hs +++ b/Assistant/NamedThread.hs @@ -13,6 +13,7 @@ import Common.Annex import Assistant.Types.NamedThread import Assistant.Types.ThreadName import Assistant.Types.DaemonStatus +import Assistant.Types.UrlRenderer import Assistant.DaemonStatus import Assistant.Monad @@ -32,13 +33,8 @@ import qualified Data.Text as T - - Named threads are run by a management thread, so if they crash - an alert is displayed, allowing the thread to be restarted. -} -#ifdef WITH_WEBAPP -startNamedThread :: Maybe UrlRenderer -> NamedThread -> Assistant () -startNamedThread urlrenderer namedthread@(NamedThread name a) = do -#else -startNamedThread :: Maybe Bool -> NamedThread -> Assistant () +startNamedThread :: UrlRenderer -> NamedThread -> Assistant () startNamedThread urlrenderer namedthread@(NamedThread name a) = do -#endif m <- startedThreads <$> getDaemonStatus case M.lookup name m of Nothing -> start @@ -69,17 +65,14 @@ startNamedThread urlrenderer namedthread@(NamedThread name a) = do ] hPutStrLn stderr msg #ifdef WITH_WEBAPP - button <- runAssistant d $ - case urlrenderer of - Nothing -> return Nothing - Just renderer -> do - close <- asIO1 removeAlert - url <- liftIO $ renderUrl renderer (RestartThreadR name) [] - return $ Just $ AlertButton - { buttonLabel = T.pack "Restart Thread" - , buttonUrl = url - , buttonAction = Just close - } + button <- runAssistant d $ do + close <- asIO1 removeAlert + url <- liftIO $ renderUrl urlrenderer (RestartThreadR name) [] + return $ Just $ AlertButton + { buttonLabel = T.pack "Restart Thread" + , buttonUrl = url + , buttonAction = Just close + } runAssistant d $ void $ addAlert $ (warningAlert (fromThreadName name) msg) { alertButton = button } diff --git a/Assistant/Threads/TransferScanner.hs b/Assistant/Threads/TransferScanner.hs index e0e42977a..01ea3c22b 100644 --- a/Assistant/Threads/TransferScanner.hs +++ b/Assistant/Threads/TransferScanner.hs @@ -8,7 +8,6 @@ module Assistant.Threads.TransferScanner where import Assistant.Common -import Assistant.WebApp import Assistant.Types.ScanRemotes import Assistant.ScanRemotes import Assistant.TransferQueue @@ -16,6 +15,7 @@ import Assistant.DaemonStatus import Assistant.Drop import Assistant.Sync import Assistant.DeleteRemote +import Assistant.Types.UrlRenderer import Logs.Transfer import Logs.Location import Logs.Group diff --git a/Assistant/Types/UrlRenderer.hs b/Assistant/Types/UrlRenderer.hs new file mode 100644 index 000000000..521905bf3 --- /dev/null +++ b/Assistant/Types/UrlRenderer.hs @@ -0,0 +1,26 @@ +{- webapp url renderer access from the assistant + - + - Copyright 2013 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +{-# LANGUAGE CPP #-} + +module Assistant.Types.UrlRenderer ( + UrlRenderer, + newUrlRenderer +) where + +#ifdef WITH_WEBAPP + +import Assistant.WebApp (UrlRenderer, newUrlRenderer) + +#else + +data UrlRenderer = UrlRenderer -- dummy type + +newUrlRenderer :: IO UrlRenderer +newUrlRenderer = return UrlRenderer + +#endif |