move display of transfer scan in progress to transfers section of dashboard

This way it's only visible when transfers are not running, which is about
what a user would expect.
This commit is contained in:
Joey Hess 2013-03-19 12:51:22 -04:00
parent a30768cf7f
commit bb284cd980
5 changed files with 30 additions and 21 deletions

View file

@ -240,13 +240,6 @@ commitAlert = activityAlert Nothing
showRemotes :: [Remote] -> TenseChunk showRemotes :: [Remote] -> TenseChunk
showRemotes = UnTensed . T.intercalate ", " . map (T.pack . Remote.name) showRemotes = UnTensed . T.intercalate ", " . map (T.pack . Remote.name)
scanAlert :: Alert
scanAlert = baseActivityAlert
{ alertHeader = Just $
tenseWords [Tensed "Scanning" "Scanned", "for file transfers"]
, alertPriority = Low
}
syncAlert :: [Remote] -> Alert syncAlert :: [Remote] -> Alert
syncAlert rs = baseActivityAlert syncAlert rs = baseActivityAlert
{ alertName = Just SyncAlert { alertName = Just SyncAlert

View file

@ -14,13 +14,13 @@ import Assistant.TransferQueue
import Assistant.DaemonStatus import Assistant.DaemonStatus
import Assistant.Drop import Assistant.Drop
import Assistant.Sync import Assistant.Sync
import Assistant.Alert
import Logs.Transfer import Logs.Transfer
import Logs.Location import Logs.Location
import Logs.Web (webUUID) import Logs.Web (webUUID)
import qualified Remote import qualified Remote
import qualified Types.Remote as Remote import qualified Types.Remote as Remote
import Utility.ThreadScheduler import Utility.ThreadScheduler
import Utility.NotificationBroadcaster
import qualified Git.LsFiles as LsFiles import qualified Git.LsFiles as LsFiles
import qualified Backend import qualified Backend
import Annex.Content import Annex.Content
@ -37,17 +37,22 @@ transferScannerThread = namedThread "TransferScanner" $ do
go S.empty go S.empty
where where
go scanned = do go scanned = do
scanrunning False
liftIO $ threadDelaySeconds (Seconds 2) liftIO $ threadDelaySeconds (Seconds 2)
(rs, infos) <- unzip <$> getScanRemote (rs, infos) <- unzip <$> getScanRemote
void $ alertWhile scanAlert $ do scanrunning True
if any fullScan infos || any (`S.notMember` scanned) rs if any fullScan infos || any (`S.notMember` scanned) rs
then do then do
expensiveScan rs expensiveScan rs
go $ scanned `S.union` S.fromList rs go $ scanned `S.union` S.fromList rs
else do else do
mapM_ failedTransferScan rs mapM_ failedTransferScan rs
go scanned go scanned
return True scanrunning b = do
ds <- modifyDaemonStatus $ \s ->
(s { transferScanRunning = b }, s)
liftIO $ sendNotification $ transferNotifier ds
{- All git remotes are synced, and all available remotes {- All git remotes are synced, and all available remotes
- are scanned in full on startup, for multiple reasons, including: - are scanned in full on startup, for multiple reasons, including:
- -

View file

@ -35,6 +35,8 @@ data DaemonStatus = DaemonStatus
, sanityCheckRunning :: Bool , sanityCheckRunning :: Bool
-- Last time the sanity checker ran -- Last time the sanity checker ran
, lastSanityCheck :: Maybe POSIXTime , lastSanityCheck :: Maybe POSIXTime
-- True when a scan for file transfers is running
, transferScanRunning :: Bool
-- Currently running file content transfers -- Currently running file content transfers
, currentTransfers :: TransferMap , currentTransfers :: TransferMap
-- Messages to display to the user. -- Messages to display to the user.
@ -77,6 +79,7 @@ newDaemonStatus = DaemonStatus
<*> pure Nothing <*> pure Nothing
<*> pure False <*> pure False
<*> pure Nothing <*> pure Nothing
<*> pure False
<*> pure M.empty <*> pure M.empty
<*> pure M.empty <*> pure M.empty
<*> pure firstAlertId <*> pure firstAlertId

View file

@ -14,6 +14,7 @@ import Assistant.WebApp.Utility
import Assistant.WebApp.RepoList import Assistant.WebApp.RepoList
import Assistant.WebApp.Notifications import Assistant.WebApp.Notifications
import Assistant.TransferQueue import Assistant.TransferQueue
import Assistant.DaemonStatus
import Utility.NotificationBroadcaster import Utility.NotificationBroadcaster
import Logs.Transfer import Logs.Transfer
import Utility.Percentage import Utility.Percentage
@ -37,6 +38,10 @@ transfersDisplay warnNoScript = do
queued <- take 10 <$> liftAssistant getTransferQueue queued <- take 10 <$> liftAssistant getTransferQueue
autoUpdate ident NotifierTransfersR (10 :: Int) (10 :: Int) autoUpdate ident NotifierTransfersR (10 :: Int) (10 :: Int)
let transfers = simplifyTransfers $ current ++ queued let transfers = simplifyTransfers $ current ++ queued
let transfersrunning = not $ null transfers
scanrunning <- if transfersrunning
then return False
else liftAssistant $ transferScanRunning <$> getDaemonStatus
$(widgetFile "dashboard/transfers") $(widgetFile "dashboard/transfers")
where where
ident = "transfers" ident = "transfers"

View file

@ -1,9 +1,6 @@
<div ##{ident}> <div ##{ident}>
<h2>Transfers <h2>Transfers
$if null transfers $if transfersrunning
<i>
(no file transfers running)
$else
$forall (transfer, info) <- transfers $forall (transfer, info) <- transfers
$with percent <- maybe "unknown" (showPercentage 0) $ percentComplete transfer info $with percent <- maybe "unknown" (showPercentage 0) $ percentComplete transfer info
<div .row-fluid> <div .row-fluid>
@ -39,3 +36,9 @@
$else $else
^{actionButton (StartTransferR transfer) Nothing (Just "continue") "btn" "icon-play"} ^{actionButton (StartTransferR transfer) Nothing (Just "continue") "btn" "icon-play"}
^{actionButton (CancelTransferR transfer) Nothing (Just "cancel") "btn" "icon-remove"} ^{actionButton (CancelTransferR transfer) Nothing (Just "cancel") "btn" "icon-remove"}
$else
$if scanrunning
<i .icon-refresh></i> Scanning for files to transfer
$else
<i>
(No file transfers running)