restart on upgrade is working, including automatic restart
Made alerts be able to have multiple buttons, so the alerts about upgrading can have a button that enables automatic upgrades. Implemented automatic upgrading when the program file has changed. Note that when an automatic upgrade happens, the webapp displays an alert about it for a few minutes, and then closes. This still needs work.
This commit is contained in:
parent
56e980215f
commit
6abaf19c41
15 changed files with 136 additions and 75 deletions
|
@ -50,6 +50,7 @@ sideBarDisplay = do
|
|||
let message = renderAlertMessage alert
|
||||
let messagelines = T.lines message
|
||||
let multiline = length messagelines > 1
|
||||
let buttons = zip (alertButtons alert) [1..]
|
||||
$(widgetFile "sidebar/alert")
|
||||
|
||||
{- Called by client to get a sidebar display.
|
||||
|
@ -79,16 +80,20 @@ getCloseAlert :: AlertId -> Handler ()
|
|||
getCloseAlert = liftAssistant . removeAlert
|
||||
|
||||
{- When an alert with a button is clicked on, the button takes us here. -}
|
||||
getClickAlert :: AlertId -> Handler ()
|
||||
getClickAlert i = do
|
||||
getClickAlert :: AlertId -> Int -> Handler ()
|
||||
getClickAlert i bnum = do
|
||||
m <- alertMap <$> liftAssistant getDaemonStatus
|
||||
case M.lookup i m of
|
||||
Just (Alert { alertButton = Just b }) -> do
|
||||
{- Spawn a thread to run the action while redirecting. -}
|
||||
case buttonAction b of
|
||||
Nothing -> noop
|
||||
Just a -> liftIO $ void $ forkIO $ a i
|
||||
redirect $ buttonUrl b
|
||||
Just (Alert { alertButtons = bs })
|
||||
| length bs >= bnum -> do
|
||||
let b = bs !! (bnum - 1)
|
||||
{- Spawn a thread to run the action
|
||||
- while redirecting. -}
|
||||
case buttonAction b of
|
||||
Nothing -> noop
|
||||
Just a -> liftIO $ void $ forkIO $ a i
|
||||
redirect $ buttonUrl b
|
||||
| otherwise -> redirectBack
|
||||
_ -> redirectBack
|
||||
|
||||
htmlIcon :: AlertIcon -> Widget
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue