restart UI

Browser behavior is not ideal; a new tab is opened on restart.
Browsers won't let me redirect to a file:// so I cannot use the old tab.
This commit is contained in:
Joey Hess 2013-01-03 18:50:30 -04:00
parent e09b7198d4
commit bad9b6761d
9 changed files with 56 additions and 34 deletions

View file

@ -10,6 +10,7 @@
module Assistant.WebApp.Control where
import Assistant.WebApp.Common
import Locations.UserConfig
import Control.Concurrent
import System.Posix (getProcessID, signalProcess, sigTERM)
@ -26,3 +27,16 @@ getShutdownConfirmedR = page "Shutdown" Nothing $ do
threadDelay 2000000
signalProcess sigTERM =<< getProcessID
$(widgetFile "control/shutdownconfirmed")
{- Quite a hack, and doesn't redirect the browser window. -}
getRestartR :: Handler RepHtml
getRestartR = page "Restarting" Nothing $ do
void $ liftIO $ forkIO $ do
threadDelay 2000000
program <- readProgramFile
unlessM (boolSystem "sh" [Param "-c", Param $ restartcommand program]) $
error "restart failed"
$(widgetFile "control/restarting")
where
restartcommand program = program ++ " assistant --stop; " ++
program ++ " webapp"

View file

@ -125,9 +125,7 @@ openFileBrowser = do
boolSystem cmd [Param path]
return True
, do
clearUltDest
setUltDest $ "file://" ++ path
void $ redirectUltDest HomeR
void $ redirect $ "file://" ++ path
return False
)
where

View file

@ -7,6 +7,7 @@
/shutdown ShutdownR GET
/shutdown/confirm ShutdownConfirmedR GET
/restart RestartR GET
/config ConfigurationR GET
/config/repository RepositoriesR GET