webapp: Repository list is now included in the dashboard, and other UI tweaks.
This commit is contained in:
		
					parent
					
						
							
								6c7ce8f193
							
						
					
				
			
			
				commit
				
					
						810a06b771
					
				
			
		
					 18 changed files with 77 additions and 108 deletions
				
			
		|  | @ -29,31 +29,11 @@ getConfigurationR = ifM (inFirstRun) | ||||||
| 		$(widgetFile "configurators/main") | 		$(widgetFile "configurators/main") | ||||||
| 	) | 	) | ||||||
| 
 | 
 | ||||||
| {- An intro message, list of repositories, and nudge to make more. -} | getAddRepositoryR :: Handler RepHtml | ||||||
| introDisplay :: Text -> Widget | getAddRepositoryR = page "Add Repository" (Just Configuration) $ do | ||||||
| introDisplay ident = do | 	let repolist = repoListDisplay mainRepoSelector | ||||||
| 	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 |  | ||||||
| 		} |  | ||||||
| 	$(widgetFile "configurators/repositories") | 	$(widgetFile "configurators/repositories") | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| makeMiscRepositories :: Widget | makeMiscRepositories :: Widget | ||||||
| makeMiscRepositories = $(widgetFile "configurators/repositories/misc") | makeMiscRepositories = $(widgetFile "configurators/repositories/misc") | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -128,7 +128,7 @@ editForm new uuid = page "Configure repository" (Just Configuration) $ do | ||||||
| 		FormSuccess input -> lift $ do | 		FormSuccess input -> lift $ do | ||||||
| 			checkarchivedirectory input | 			checkarchivedirectory input | ||||||
| 			setRepoConfig uuid mremote curr input | 			setRepoConfig uuid mremote curr input | ||||||
| 			redirect RepositoriesR | 			redirect DashboardR | ||||||
| 		_ -> showform form enctype curr | 		_ -> showform form enctype curr | ||||||
|   where |   where | ||||||
| 	showform form enctype curr = do | 	showform form enctype curr = do | ||||||
|  |  | ||||||
|  | @ -156,6 +156,7 @@ xmppPairEnd inprogress theirjid = pairPage $ do | ||||||
| 		{ onlyCloud = True | 		{ onlyCloud = True | ||||||
| 		, onlyConfigured = False | 		, onlyConfigured = False | ||||||
| 		, includeHere = False | 		, includeHere = False | ||||||
|  | 		, nudgeAddMore = False | ||||||
| 		} | 		} | ||||||
| 	$(widgetFile "configurators/pairing/xmpp/end") | 	$(widgetFile "configurators/pairing/xmpp/end") | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | @ -11,8 +11,8 @@ module Assistant.WebApp.DashBoard where | ||||||
| 
 | 
 | ||||||
| import Assistant.WebApp.Common | import Assistant.WebApp.Common | ||||||
| import Assistant.WebApp.Utility | import Assistant.WebApp.Utility | ||||||
|  | import Assistant.WebApp.RepoList | ||||||
| import Assistant.WebApp.Notifications | import Assistant.WebApp.Notifications | ||||||
| import Assistant.WebApp.Configurators |  | ||||||
| import Assistant.TransferQueue | import Assistant.TransferQueue | ||||||
| import Utility.NotificationBroadcaster | import Utility.NotificationBroadcaster | ||||||
| import Logs.Transfer | import Logs.Transfer | ||||||
|  | @ -36,12 +36,7 @@ transfersDisplay warnNoScript = do | ||||||
| 	queued <- lift $ take 10 <$> liftAssistant getTransferQueue | 	queued <- lift $ 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 | ||||||
| 	if null transfers | 	$(widgetFile "dashboard/transfers") | ||||||
| 		then ifM (lift $ showIntro <$> getWebAppState) |  | ||||||
| 			( introDisplay ident |  | ||||||
| 			, $(widgetFile "dashboard/transfers") |  | ||||||
| 			) |  | ||||||
| 		else $(widgetFile "dashboard/transfers") |  | ||||||
|   where |   where | ||||||
| 	ident = "transfers" | 	ident = "transfers" | ||||||
| 	isrunning info = not $ | 	isrunning info = not $ | ||||||
|  | @ -74,7 +69,9 @@ getTransfersR nid = do | ||||||
| {- The main dashboard. -} | {- The main dashboard. -} | ||||||
| dashboard :: Bool -> Widget | dashboard :: Bool -> Widget | ||||||
| dashboard warnNoScript = do | dashboard warnNoScript = do | ||||||
| 	let content = transfersDisplay warnNoScript | 	let repolist = repoListDisplay $ | ||||||
|  | 		mainRepoSelector { nudgeAddMore = True } | ||||||
|  | 	let transferlist = transfersDisplay warnNoScript | ||||||
| 	$(widgetFile "dashboard/main") | 	$(widgetFile "dashboard/main") | ||||||
| 
 | 
 | ||||||
| getDashboardR :: Handler RepHtml | getDashboardR :: Handler RepHtml | ||||||
|  |  | ||||||
|  | @ -19,18 +19,16 @@ import Yesod | ||||||
| import Text.Hamlet | import Text.Hamlet | ||||||
| import Data.Text (Text) | import Data.Text (Text) | ||||||
| 
 | 
 | ||||||
| data NavBarItem = DashBoard | Repositories | Configuration | About | data NavBarItem = DashBoard | Configuration | About | ||||||
| 	deriving (Eq, Ord, Enum, Bounded) | 	deriving (Eq, Ord, Enum, Bounded) | ||||||
| 
 | 
 | ||||||
| navBarName :: NavBarItem -> Text | navBarName :: NavBarItem -> Text | ||||||
| navBarName DashBoard = "Dashboard" | navBarName DashBoard = "Dashboard" | ||||||
| navBarName Repositories = "Repositories" |  | ||||||
| navBarName Configuration = "Configuration" | navBarName Configuration = "Configuration" | ||||||
| navBarName About = "About" | navBarName About = "About" | ||||||
| 
 | 
 | ||||||
| navBarRoute :: NavBarItem -> Route WebApp | navBarRoute :: NavBarItem -> Route WebApp | ||||||
| navBarRoute DashBoard = DashboardR | navBarRoute DashBoard = DashboardR | ||||||
| navBarRoute Repositories = RepositoriesR |  | ||||||
| navBarRoute Configuration = ConfigurationR | navBarRoute Configuration = ConfigurationR | ||||||
| navBarRoute About = AboutR | navBarRoute About = AboutR | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -63,7 +63,7 @@ notSyncing (SyncingRepoActions _ _) = False | ||||||
| notSyncing _ = True | notSyncing _ = True | ||||||
| 
 | 
 | ||||||
| {- Called by client to get a list of repos, that refreshes | {- 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. |  - Returns a div, which will be inserted into the calling page. | ||||||
|  -} |  -} | ||||||
|  | @ -73,6 +73,14 @@ getRepoListR (RepoListNotificationId nid reposelector) = do | ||||||
| 	p <- widgetToPageContent $ repoListDisplay reposelector | 	p <- widgetToPageContent $ repoListDisplay reposelector | ||||||
| 	hamletToRepHtml $ [hamlet|^{pageBody p}|] | 	hamletToRepHtml $ [hamlet|^{pageBody p}|] | ||||||
| 
 | 
 | ||||||
|  | mainRepoSelector :: RepoSelector | ||||||
|  | mainRepoSelector = RepoSelector | ||||||
|  | 	{ onlyCloud = False | ||||||
|  | 	, onlyConfigured = False | ||||||
|  | 	, includeHere = True | ||||||
|  | 	, nudgeAddMore = False | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| repoListDisplay :: RepoSelector -> Widget | repoListDisplay :: RepoSelector -> Widget | ||||||
| repoListDisplay reposelector = do | repoListDisplay reposelector = do | ||||||
| 	autoUpdate ident (NotifierRepoListR reposelector) (10 :: Int) (10 :: Int) | 	autoUpdate ident (NotifierRepoListR reposelector) (10 :: Int) (10 :: Int) | ||||||
|  | @ -82,17 +90,16 @@ repoListDisplay reposelector = do | ||||||
| 	addScript $ StaticR jquery_ui_sortable_js | 	addScript $ StaticR jquery_ui_sortable_js | ||||||
| 
 | 
 | ||||||
| 	repolist <- lift $ repoList reposelector | 	repolist <- lift $ repoList reposelector | ||||||
|  | 	let addmore = nudgeAddMore reposelector | ||||||
|  | 	let nootherrepos = length repolist < 2 | ||||||
| 
 | 
 | ||||||
| 	$(widgetFile "repolist") | 	$(widgetFile "repolist") | ||||||
| 
 |  | ||||||
|   where |   where | ||||||
| 	ident = "repolist" | 	ident = "repolist" | ||||||
| 
 | 
 | ||||||
| -- (num, name, uuid, actions) | type RepoList = [(String, UUID, Actions)] | ||||||
| type RepoList = [(String, String, UUID, Actions)] |  | ||||||
| 
 | 
 | ||||||
| {- A numbered list of known repositories, | {- A list of known repositories, with actions that can be taken on them. -} | ||||||
|  - with actions that can be taken on them. -} |  | ||||||
| repoList :: RepoSelector -> Handler RepoList | repoList :: RepoSelector -> Handler RepoList | ||||||
| repoList reposelector | repoList reposelector | ||||||
| 	| onlyConfigured reposelector = list =<< configured | 	| onlyConfigured reposelector = list =<< configured | ||||||
|  | @ -149,12 +156,10 @@ repoList reposelector | ||||||
| 		val iscloud r = Just (iscloud, (u, DisabledRepoActions $ r u)) | 		val iscloud r = Just (iscloud, (u, DisabledRepoActions $ r u)) | ||||||
| 	list l = liftAnnex $ do | 	list l = liftAnnex $ do | ||||||
| 		let l' = nubBy (\x y -> fst x == fst y) l | 		let l' = nubBy (\x y -> fst x == fst y) l | ||||||
| 		l'' <- zip3 | 		l'' <- zip | ||||||
| 			<$> pure counter | 			<$> Remote.prettyListUUIDs (map fst l') | ||||||
| 			<*> Remote.prettyListUUIDs (map fst l') |  | ||||||
| 			<*> pure l' | 			<*> pure l' | ||||||
| 		return $ map (\(num, name, (uuid, actions)) -> (num, name, uuid, actions)) l'' | 		return $ map (\(name, (uuid, actions)) -> (name, uuid, actions)) l'' | ||||||
| 	counter = map show ([1..] :: [Int]) |  | ||||||
| 
 | 
 | ||||||
| getEnableSyncR :: UUID -> Handler () | getEnableSyncR :: UUID -> Handler () | ||||||
| getEnableSyncR = flipSync True | getEnableSyncR = flipSync True | ||||||
|  | @ -166,7 +171,7 @@ flipSync :: Bool -> UUID -> Handler () | ||||||
| flipSync enable uuid = do | flipSync enable uuid = do | ||||||
| 	mremote <- liftAnnex $ Remote.remoteFromUUID uuid | 	mremote <- liftAnnex $ Remote.remoteFromUUID uuid | ||||||
| 	changeSyncable mremote enable | 	changeSyncable mremote enable | ||||||
| 	redirect RepositoriesR | 	redirectBack | ||||||
| 
 | 
 | ||||||
| getRepositoriesReorderR :: Handler () | getRepositoriesReorderR :: Handler () | ||||||
| getRepositoriesReorderR = do | getRepositoriesReorderR = do | ||||||
|  |  | ||||||
|  | @ -83,6 +83,7 @@ data RepoSelector = RepoSelector | ||||||
| 	{ onlyCloud :: Bool | 	{ onlyCloud :: Bool | ||||||
| 	, onlyConfigured :: Bool | 	, onlyConfigured :: Bool | ||||||
| 	, includeHere :: Bool | 	, includeHere :: Bool | ||||||
|  | 	, nudgeAddMore :: Bool | ||||||
| 	} | 	} | ||||||
| 	deriving (Read, Show, Eq) | 	deriving (Read, Show, Eq) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,8 +1,5 @@ | ||||||
| / DashboardR GET HEAD | / DashboardR GET HEAD | ||||||
| 
 | 
 | ||||||
| /repositories RepositoriesR GET |  | ||||||
| /repositories/reorder RepositoriesReorderR GET |  | ||||||
| 
 |  | ||||||
| /noscript NoScriptR GET | /noscript NoScriptR GET | ||||||
| /noscript/auto NoScriptAutoR GET | /noscript/auto NoScriptAutoR GET | ||||||
| 
 | 
 | ||||||
|  | @ -20,6 +17,7 @@ | ||||||
| /config/preferences PreferencesR GET | /config/preferences PreferencesR GET | ||||||
| /config/xmpp XMPPR GET | /config/xmpp XMPPR GET | ||||||
| 
 | 
 | ||||||
|  | /config/addrepository AddRepositoryR GET | ||||||
| /config/repository/new/first FirstRepositoryR GET | /config/repository/new/first FirstRepositoryR GET | ||||||
| /config/repository/new NewRepositoryR GET | /config/repository/new NewRepositoryR GET | ||||||
| /config/repository/switcher RepositorySwitcherR GET | /config/repository/switcher RepositorySwitcherR GET | ||||||
|  | @ -55,6 +53,8 @@ | ||||||
| /config/repository/enable/glacier/#UUID EnableGlacierR GET | /config/repository/enable/glacier/#UUID EnableGlacierR GET | ||||||
| /config/repository/enable/webdav/#UUID EnableWebDAVR GET | /config/repository/enable/webdav/#UUID EnableWebDAVR GET | ||||||
| 
 | 
 | ||||||
|  | /config/repository/reorder RepositoriesReorderR GET | ||||||
|  | 
 | ||||||
| /transfers/#NotificationId TransfersR GET | /transfers/#NotificationId TransfersR GET | ||||||
| /notifier/transfers NotifierTransfersR GET | /notifier/transfers NotifierTransfersR GET | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										7
									
								
								debian/changelog
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								debian/changelog
									
										
									
									
										vendored
									
									
								
							|  | @ -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 | git-annex (4.20130314) unstable; urgency=low | ||||||
| 
 | 
 | ||||||
|   * Bugfix: git annex add, when ran without any file or directory specified, |   * Bugfix: git annex add, when ran without any file or directory specified, | ||||||
|  |  | ||||||
|  | @ -1,16 +1,5 @@ | ||||||
| The webapp is a web server that displays a shiny interface. | 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 | ## other features | ||||||
| 
 | 
 | ||||||
| * there could be a UI to export a file, which would make it be served up | * there could be a UI to export a file, which would make it be served up | ||||||
|  |  | ||||||
|  | @ -20,7 +20,7 @@ | ||||||
|         <div .form-actions> |         <div .form-actions> | ||||||
|           <button .btn .btn-primary type=submit> |           <button .btn .btn-primary type=submit> | ||||||
|             Save Changes |             Save Changes | ||||||
|           <a .btn href="@{RepositoriesR}"> |           <a .btn href="@{DashboardR}"> | ||||||
|             Cancel |             Cancel | ||||||
|   $if new |   $if new | ||||||
|     <p> |     <p> | ||||||
|  |  | ||||||
|  | @ -6,5 +6,5 @@ | ||||||
|   <p> |   <p> | ||||||
|     <a .btn href="@{AddDriveR}"> |     <a .btn href="@{AddDriveR}"> | ||||||
|       On a removable drive |       On a removable drive | ||||||
|     <a .btn href="@{RepositoriesR}"> |     <a .btn href="@{DashboardR}"> | ||||||
|       Cancel |       Cancel | ||||||
|  |  | ||||||
|  | @ -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. |  | ||||||
|  | @ -1,5 +1,11 @@ | ||||||
| <div .span9> | <div .span9> | ||||||
|   <div .row-fluid> |   <div .row-fluid> | ||||||
|  |     <div .span4> | ||||||
|  |       <h3> | ||||||
|  |         <a href="@{AddRepositoryR}"> | ||||||
|  |           Repositories | ||||||
|  |       <p> | ||||||
|  |         Configure the repositories that git-annex syncs with. | ||||||
|     <div .span4> |     <div .span4> | ||||||
|       <h3> |       <h3> | ||||||
|         <a href="@{PreferencesR}"> |         <a href="@{PreferencesR}"> | ||||||
|  |  | ||||||
|  | @ -1,5 +1,7 @@ | ||||||
| ^{content} | <div .span9> | ||||||
|   $if warnNoScript |   ^{repolist} | ||||||
|  |   ^{transferlist} | ||||||
|  | $if warnNoScript | ||||||
|   <noscript> |   <noscript> | ||||||
|     <div .navbar .navbar-fixed-bottom> |     <div .navbar .navbar-fixed-bottom> | ||||||
|       <div .navbar-inner> |       <div .navbar-inner> | ||||||
|  |  | ||||||
|  | @ -1,15 +1,9 @@ | ||||||
| <div .span9 ##{ident}> | <div ##{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. |  | ||||||
|   $if null transfers |  | ||||||
|   $else |  | ||||||
|   <h2>Transfers |   <h2>Transfers | ||||||
|  |   $if null transfers | ||||||
|  |     <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> | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ | ||||||
|         Repositories |         Repositories | ||||||
|   <table .table .table-condensed> |   <table .table .table-condensed> | ||||||
|     <tbody #costsortable> |     <tbody #costsortable> | ||||||
|       $forall (_num, name, uuid, actions) <- repolist |       $forall (name, uuid, actions) <- repolist | ||||||
|         <tr .repoline ##{fromUUID uuid}> |         <tr .repoline ##{fromUUID uuid}> | ||||||
|           <td .handle> |           <td .handle> | ||||||
|             <i .icon-resize-vertical></i> |             <i .icon-resize-vertical></i> | ||||||
|  | @ -33,3 +33,15 @@ | ||||||
|             $else |             $else | ||||||
|               <a href="@{setupRepoLink actions}"> |               <a href="@{setupRepoLink actions}"> | ||||||
|                 configure |                 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> | ||||||
|  |                 Sync your files with another drive, device, or # | ||||||
|  |               share with a friend. | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| $(function() { | $(function() { | ||||||
| 	var setup = function() { | 	var setup = function() { | ||||||
| 		$("#costsortable").sortable({ | 		$("#costsortable").sortable({ | ||||||
|  | 			items: ".repoline", | ||||||
| 			handle: ".handle", | 			handle: ".handle", | ||||||
| 			cursor: "move", | 			cursor: "move", | ||||||
| 			forceHelperSize: true, | 			forceHelperSize: true, | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Joey Hess
				Joey Hess