global webapp redirects, to finish upgrades
When an automatic upgrade completes, or when the user clicks on the upgrade button in one webapp, but also has it open in another browser window/tab, we have a problem: The current web server is going to stop running in minutes, but there is no way to send a redirect to the web browser to the new url. To solve this, used long polling, so the webapp is always listening for urls it should redirect to. This allows globally redirecting every open webapp. Works great! Tested with 2 web browsers with 2 tabs each. May be useful for other purposes later too, dunno. The overhead is 2 http requests per page load in the webapp. Due to yesod's speed, this does not seem to noticibly delay it. Only 1 of the requests could possibly block the page load, the other is async.
This commit is contained in:
parent
d24f7f94fe
commit
183f7355cd
11 changed files with 148 additions and 82 deletions
|
@ -217,12 +217,12 @@ notFsckedAlert mr button = Alert
|
|||
, alertData = []
|
||||
}
|
||||
|
||||
baseUpgradeAlert :: AlertButton -> TenseText -> Alert
|
||||
baseUpgradeAlert button message = Alert
|
||||
baseUpgradeAlert :: [AlertButton] -> TenseText -> Alert
|
||||
baseUpgradeAlert buttons message = Alert
|
||||
{ alertHeader = Just message
|
||||
, alertIcon = Just UpgradeIcon
|
||||
, alertPriority = High
|
||||
, alertButtons = [button]
|
||||
, alertButtons = buttons
|
||||
, alertClosable = True
|
||||
, alertClass = Message
|
||||
, alertMessageRender = renderData
|
||||
|
@ -235,7 +235,7 @@ baseUpgradeAlert button message = Alert
|
|||
|
||||
canUpgradeAlert :: AlertPriority -> AlertButton -> Alert
|
||||
canUpgradeAlert priority button =
|
||||
(baseUpgradeAlert button $ fromString msg)
|
||||
(baseUpgradeAlert [button] $ fromString msg)
|
||||
{ alertPriority = priority }
|
||||
where
|
||||
msg = if priority >= High
|
||||
|
@ -243,15 +243,15 @@ canUpgradeAlert priority button =
|
|||
else "An upgrade of git-annex is available."
|
||||
|
||||
upgradeReadyAlert :: AlertButton -> Alert
|
||||
upgradeReadyAlert button = baseUpgradeAlert button $
|
||||
upgradeReadyAlert button = baseUpgradeAlert [button] $
|
||||
fromString "A new version of git-annex has been installed."
|
||||
|
||||
upgradingAlert :: Alert
|
||||
upgradingAlert = activityAlert Nothing [ fromString "Upgrading git-annex" ]
|
||||
|
||||
upgradeFinishedAlert :: AlertButton -> GitAnnexVersion -> Alert
|
||||
upgradeFinishedAlert :: Maybe AlertButton -> GitAnnexVersion -> Alert
|
||||
upgradeFinishedAlert button version =
|
||||
baseUpgradeAlert button $ fromString $
|
||||
baseUpgradeAlert (maybe [] (:[]) button) $ fromString $
|
||||
"Finished upgrading git-annex to version " ++ version
|
||||
|
||||
brokenRepositoryAlert :: AlertButton -> Alert
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue