webapp: Repository list is now included in the dashboard, and other UI tweaks.

This commit is contained in:
Joey Hess 2013-03-15 00:34:42 -04:00
parent 6c7ce8f193
commit 810a06b771
18 changed files with 77 additions and 108 deletions

View file

@ -29,31 +29,11 @@ getConfigurationR = ifM (inFirstRun)
$(widgetFile "configurators/main")
)
{- An intro message, list of repositories, and nudge to make more. -}
introDisplay :: Text -> Widget
introDisplay ident = do
webapp <- lift getYesod
repolist <- lift $ repoList $ RepoSelector
{ onlyCloud = False
, onlyConfigured = True
, includeHere = False
}
let n = length repolist
let numrepos = show n
$(widgetFile "configurators/intro")
lift $ modifyWebAppState $ \s -> s { showIntro = False }
{- Lists known repositories, followed by options to add more. -}
getRepositoriesR :: Handler RepHtml
getRepositoriesR = page "Repositories" (Just Repositories) $ do
let repolist = repoListDisplay $ RepoSelector
{ onlyCloud = False
, onlyConfigured = False
, includeHere = True
}
getAddRepositoryR :: Handler RepHtml
getAddRepositoryR = page "Add Repository" (Just Configuration) $ do
let repolist = repoListDisplay mainRepoSelector
$(widgetFile "configurators/repositories")
makeMiscRepositories :: Widget
makeMiscRepositories = $(widgetFile "configurators/repositories/misc")

View file

@ -128,7 +128,7 @@ editForm new uuid = page "Configure repository" (Just Configuration) $ do
FormSuccess input -> lift $ do
checkarchivedirectory input
setRepoConfig uuid mremote curr input
redirect RepositoriesR
redirect DashboardR
_ -> showform form enctype curr
where
showform form enctype curr = do

View file

@ -156,6 +156,7 @@ xmppPairEnd inprogress theirjid = pairPage $ do
{ onlyCloud = True
, onlyConfigured = False
, includeHere = False
, nudgeAddMore = False
}
$(widgetFile "configurators/pairing/xmpp/end")
#endif

View file

@ -11,8 +11,8 @@ module Assistant.WebApp.DashBoard where
import Assistant.WebApp.Common
import Assistant.WebApp.Utility
import Assistant.WebApp.RepoList
import Assistant.WebApp.Notifications
import Assistant.WebApp.Configurators
import Assistant.TransferQueue
import Utility.NotificationBroadcaster
import Logs.Transfer
@ -36,12 +36,7 @@ transfersDisplay warnNoScript = do
queued <- lift $ take 10 <$> liftAssistant getTransferQueue
autoUpdate ident NotifierTransfersR (10 :: Int) (10 :: Int)
let transfers = simplifyTransfers $ current ++ queued
if null transfers
then ifM (lift $ showIntro <$> getWebAppState)
( introDisplay ident
, $(widgetFile "dashboard/transfers")
)
else $(widgetFile "dashboard/transfers")
$(widgetFile "dashboard/transfers")
where
ident = "transfers"
isrunning info = not $
@ -74,7 +69,9 @@ getTransfersR nid = do
{- The main dashboard. -}
dashboard :: Bool -> Widget
dashboard warnNoScript = do
let content = transfersDisplay warnNoScript
let repolist = repoListDisplay $
mainRepoSelector { nudgeAddMore = True }
let transferlist = transfersDisplay warnNoScript
$(widgetFile "dashboard/main")
getDashboardR :: Handler RepHtml

View file

@ -19,18 +19,16 @@ import Yesod
import Text.Hamlet
import Data.Text (Text)
data NavBarItem = DashBoard | Repositories | Configuration | About
data NavBarItem = DashBoard | Configuration | About
deriving (Eq, Ord, Enum, Bounded)
navBarName :: NavBarItem -> Text
navBarName DashBoard = "Dashboard"
navBarName Repositories = "Repositories"
navBarName Configuration = "Configuration"
navBarName About = "About"
navBarRoute :: NavBarItem -> Route WebApp
navBarRoute DashBoard = DashboardR
navBarRoute Repositories = RepositoriesR
navBarRoute Configuration = ConfigurationR
navBarRoute About = AboutR

View file

@ -63,7 +63,7 @@ notSyncing (SyncingRepoActions _ _) = False
notSyncing _ = True
{- Called by client to get a list of repos, that refreshes
- when new repos as added.
- when new repos are added.
-
- Returns a div, which will be inserted into the calling page.
-}
@ -73,6 +73,14 @@ getRepoListR (RepoListNotificationId nid reposelector) = do
p <- widgetToPageContent $ repoListDisplay reposelector
hamletToRepHtml $ [hamlet|^{pageBody p}|]
mainRepoSelector :: RepoSelector
mainRepoSelector = RepoSelector
{ onlyCloud = False
, onlyConfigured = False
, includeHere = True
, nudgeAddMore = False
}
repoListDisplay :: RepoSelector -> Widget
repoListDisplay reposelector = do
autoUpdate ident (NotifierRepoListR reposelector) (10 :: Int) (10 :: Int)
@ -82,17 +90,16 @@ repoListDisplay reposelector = do
addScript $ StaticR jquery_ui_sortable_js
repolist <- lift $ repoList reposelector
let addmore = nudgeAddMore reposelector
let nootherrepos = length repolist < 2
$(widgetFile "repolist")
where
ident = "repolist"
-- (num, name, uuid, actions)
type RepoList = [(String, String, UUID, Actions)]
type RepoList = [(String, UUID, Actions)]
{- A numbered list of known repositories,
- with actions that can be taken on them. -}
{- A list of known repositories, with actions that can be taken on them. -}
repoList :: RepoSelector -> Handler RepoList
repoList reposelector
| onlyConfigured reposelector = list =<< configured
@ -149,12 +156,10 @@ repoList reposelector
val iscloud r = Just (iscloud, (u, DisabledRepoActions $ r u))
list l = liftAnnex $ do
let l' = nubBy (\x y -> fst x == fst y) l
l'' <- zip3
<$> pure counter
<*> Remote.prettyListUUIDs (map fst l')
l'' <- zip
<$> Remote.prettyListUUIDs (map fst l')
<*> pure l'
return $ map (\(num, name, (uuid, actions)) -> (num, name, uuid, actions)) l''
counter = map show ([1..] :: [Int])
return $ map (\(name, (uuid, actions)) -> (name, uuid, actions)) l''
getEnableSyncR :: UUID -> Handler ()
getEnableSyncR = flipSync True
@ -166,7 +171,7 @@ flipSync :: Bool -> UUID -> Handler ()
flipSync enable uuid = do
mremote <- liftAnnex $ Remote.remoteFromUUID uuid
changeSyncable mremote enable
redirect RepositoriesR
redirectBack
getRepositoriesReorderR :: Handler ()
getRepositoriesReorderR = do

View file

@ -83,6 +83,7 @@ data RepoSelector = RepoSelector
{ onlyCloud :: Bool
, onlyConfigured :: Bool
, includeHere :: Bool
, nudgeAddMore :: Bool
}
deriving (Read, Show, Eq)

View file

@ -1,8 +1,5 @@
/ DashboardR GET HEAD
/repositories RepositoriesR GET
/repositories/reorder RepositoriesReorderR GET
/noscript NoScriptR GET
/noscript/auto NoScriptAutoR GET
@ -20,6 +17,7 @@
/config/preferences PreferencesR GET
/config/xmpp XMPPR GET
/config/addrepository AddRepositoryR GET
/config/repository/new/first FirstRepositoryR GET
/config/repository/new NewRepositoryR GET
/config/repository/switcher RepositorySwitcherR GET
@ -55,6 +53,8 @@
/config/repository/enable/glacier/#UUID EnableGlacierR GET
/config/repository/enable/webdav/#UUID EnableWebDAVR GET
/config/repository/reorder RepositoriesReorderR GET
/transfers/#NotificationId TransfersR GET
/notifier/transfers NotifierTransfersR GET

7
debian/changelog vendored
View file

@ -1,3 +1,10 @@
git-annex (4.20130315) UNRELEASED; urgency=low
* webapp: Repository list is now included in the dashboard, and other
UI tweaks.
-- Joey Hess <joeyh@debian.org> Fri, 15 Mar 2013 00:10:07 -0400
git-annex (4.20130314) unstable; urgency=low
* Bugfix: git annex add, when ran without any file or directory specified,

View file

@ -1,16 +1,5 @@
The webapp is a web server that displays a shiny interface.
## interface
* Combine the replist with the dashboard. Put the list of repos or nudge
to make repos on top, and the transfers below. Make a "+ Add repo" button
on the list of repos that expands a hidden div, showing the repo creation
choices. Only one problem: If I have 20 repositories, all
I can see on the dashboard w/o scrolling is my repos..
* drag and drop to reorder
* keep it accessible to blind, etc
## other features
* there could be a UI to export a file, which would make it be served up

View file

@ -20,7 +20,7 @@
<div .form-actions>
<button .btn .btn-primary type=submit>
Save Changes
<a .btn href="@{RepositoriesR}">
<a .btn href="@{DashboardR}">
Cancel
$if new
<p>

View file

@ -6,5 +6,5 @@
<p>
<a .btn href="@{AddDriveR}">
On a removable drive
<a .btn href="@{RepositoriesR}">
<a .btn href="@{DashboardR}">
Cancel

View file

@ -1,24 +0,0 @@
<div .span9 ##{ident} .hero-unit>
$maybe reldir <- relDir webapp
<h2>
git-annex is watching over your files in <small><tt>#{reldir}</tt></small>
<p>
It will automatically notice changes, and keep files in sync #
$if (null repolist)
with repositories elsewhere ...
<h2>
But no other repositories are set up yet.
<a .btn .btn-primary .btn-large href="@{RepositoriesR}">Add another repository</a>
$else
\ with these repositories:
<table .table .table-striped .table-condensed>
<tbody>
$forall (num, name, _, _) <- repolist
<tr>
<td>
#{num}
<td>
#{name}
<a .btn .btn-primary .btn-large href="@{RepositoriesR}">Add another repository</a>
<p>
Or just sit back, watch the magic, and get on with using your files.

View file

@ -1,5 +1,11 @@
<div .span9>
<div .row-fluid>
<div .span4>
<h3>
<a href="@{AddRepositoryR}">
Repositories
<p>
Configure the repositories that git-annex syncs with.
<div .span4>
<h3>
<a href="@{PreferencesR}">

View file

@ -1,10 +1,12 @@
^{content}
$if warnNoScript
<noscript>
<div .navbar .navbar-fixed-bottom>
<div .navbar-inner>
<div .container>
Javascript is disabled; cannot update in real-time.
<div .btn-group>
<a .btn .btn-primary href="@{NoScriptAutoR}">Auto-refresh every 3 seconds #
<a .btn .btn-primary href="@{NoScriptR}">Manually refresh
<div .span9>
^{repolist}
^{transferlist}
$if warnNoScript
<noscript>
<div .navbar .navbar-fixed-bottom>
<div .navbar-inner>
<div .container>
Javascript is disabled; cannot update in real-time.
<div .btn-group>
<a .btn .btn-primary href="@{NoScriptAutoR}">Auto-refresh every 3 seconds #
<a .btn .btn-primary href="@{NoScriptR}">Manually refresh

View file

@ -1,15 +1,9 @@
<div .span9 ##{ident}>
$maybe reldir <- relDir webapp
<div .alert .alert-info>
<p>
git-annex is watching over your files in #
<small><tt>#{reldir}</tt></small>, #
and keeping them in sync with #
<a href="@{RepositoriesR}">
other repositories.
<div ##{ident}>
<h2>Transfers
$if null transfers
<i>
(no file transfers running)
$else
<h2>Transfers
$forall (transfer, info) <- transfers
$with percent <- maybe "unknown" (showPercentage 0) $ percentComplete transfer info
<div .row-fluid>

View file

@ -11,7 +11,7 @@
Repositories
<table .table .table-condensed>
<tbody #costsortable>
$forall (_num, name, uuid, actions) <- repolist
$forall (name, uuid, actions) <- repolist
<tr .repoline ##{fromUUID uuid}>
<td .handle>
<i .icon-resize-vertical></i>
@ -33,3 +33,15 @@
$else
<a href="@{setupRepoLink actions}">
configure
$if addmore
<tr>
<td colspan="3">
$if nootherrepos
<a .btn .btn-primary .btn-large href="@{AddRepositoryR}">
<i .icon-plus-sign></i> Add another repository
$else
<a .btn .btn-small href="@{AddRepositoryR}">
<i .icon-plus-sign></i> Add another repository
<span>
&nbsp; Sync your files with another drive, device, or #
share with a friend.

View file

@ -1,6 +1,7 @@
$(function() {
var setup = function() {
$("#costsortable").sortable({
items: ".repoline",
handle: ".handle",
cursor: "move",
forceHelperSize: true,