diff options
author | Joey Hess <joey@kitenet.net> | 2012-07-30 14:08:22 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-07-30 14:08:22 -0400 |
commit | a9941308434354046fa51d3327c5e05ff080a247 (patch) | |
tree | 025bc566b43d01f6e41908ed635c467d168cb048 /Assistant/Threads/WebApp.hs | |
parent | 1f671ee40c7f26d0adb16408ba1cf7fc9ceb3a7a (diff) |
implement server-side alert closing
Rather than using bootstrap's client-side closing.
Now closed alerts stay closed.
Diffstat (limited to 'Assistant/Threads/WebApp.hs')
-rw-r--r-- | Assistant/Threads/WebApp.hs | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/Assistant/Threads/WebApp.hs b/Assistant/Threads/WebApp.hs index 44fb44f2b..0de4a50a8 100644 --- a/Assistant/Threads/WebApp.hs +++ b/Assistant/Threads/WebApp.hs @@ -93,6 +93,7 @@ mkYesod "WebApp" [parseRoutes| /noscriptauto NoScriptAutoR GET /transfers/#NotificationId TransfersR GET /sidebar/#NotificationId SideBarR GET +/closealert/#AlertId CloseAlert GET /config ConfigR GET /addrepository AddRepositoryR GET /static StaticR Static getStatic @@ -102,6 +103,10 @@ instance PathPiece NotificationId where toPathPiece = pack . show fromPathPiece = readish . unpack +instance PathPiece AlertId where + toPathPiece = pack . show + fromPathPiece = readish . unpack + instance Yesod WebApp where defaultLayout content = do webapp <- getYesod @@ -110,7 +115,6 @@ instance Yesod WebApp where addStylesheet $ StaticR css_bootstrap_responsive_css addScript $ StaticR jquery_full_js addScript $ StaticR js_bootstrap_dropdown_js - addScript $ StaticR js_bootstrap_alert_js $(widgetFile "page") hamletToRepHtml $(hamletFile $ hamletTemplate "bootstrap") @@ -229,7 +233,7 @@ sideBarDisplay noScript = do bootstrapclass Message = "alert-info" renderalert (alertid, alert) = addalert - (show alertid) + alertid (alertClosable alert) (alertBlockDisplay alert) (bootstrapclass $ alertClass alert) @@ -238,11 +242,14 @@ sideBarDisplay noScript = do StringAlert s -> [whamlet|#{s}|] WidgetAlert w -> w alert - rendermessage msg = addalert "yesodmessage" True False + rendermessage msg = addalert firstAlertId True False "alert-info" Nothing [whamlet|#{msg}|] - addalert :: String -> Bool -> Bool -> Text -> Maybe String -> Widget -> Widget - addalert alertid closable block divclass heading widget = $(widgetFile "alert") + addalert :: AlertId -> Bool -> Bool -> Text -> Maybe String -> Widget -> Widget + addalert i closable block divclass heading widget = do + let alertid = show i + let closealert = CloseAlert i + $(widgetFile "alert") {- Called by client to get a sidebar display. - @@ -259,6 +266,12 @@ getSideBarR nid = do page <- widgetToPageContent $ sideBarDisplay True hamletToRepHtml $ [hamlet|^{pageBody page}|] +{- Called by the client to close an alert. -} +getCloseAlert :: AlertId -> Handler () +getCloseAlert i = do + webapp <- getYesod + void $ liftIO $ removeAlert (daemonStatus webapp) i + dashboard :: Bool -> Bool -> Widget dashboard noScript warnNoScript = do sideBarDisplay noScript |