add %full field to table
This commit is contained in:
parent
68a99a8f48
commit
d4b2f8201d
1 changed files with 21 additions and 6 deletions
|
@ -16,6 +16,7 @@ import Types.RepoSize
|
||||||
import Logs.MaxSize
|
import Logs.MaxSize
|
||||||
import Logs.Trust
|
import Logs.Trust
|
||||||
import Utility.DataUnits
|
import Utility.DataUnits
|
||||||
|
import Utility.Percentage
|
||||||
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
|
@ -80,7 +81,7 @@ sizeOverview o = do
|
||||||
M.mapWithKey (gather maxsizes) reposizes
|
M.mapWithKey (gather maxsizes) reposizes
|
||||||
v <- Remote.prettyPrintUUIDsWith' False (Just "size")
|
v <- Remote.prettyPrintUUIDsWith' False (Just "size")
|
||||||
"repositories" descmap showsizes l
|
"repositories" descmap showsizes l
|
||||||
showRaw $ encodeBS $ tableheader
|
showRaw $ encodeBS $ tablerow (zip widths headers)
|
||||||
showRaw $ encodeBS $ dropWhileEnd (== '\n') v
|
showRaw $ encodeBS $ dropWhileEnd (== '\n') v
|
||||||
return True
|
return True
|
||||||
stop
|
stop
|
||||||
|
@ -94,20 +95,34 @@ sizeOverview o = do
|
||||||
, (maxsizefield, fromMaxSize <$> M.lookup u maxsizes)
|
, (maxsizefield, fromMaxSize <$> M.lookup u maxsizes)
|
||||||
]
|
]
|
||||||
|
|
||||||
tableheader = tablerow ["size", "maxsize", "repository"]
|
(widths, headers) = unzip
|
||||||
|
[ (7, "size")
|
||||||
|
, (7, "maxsize")
|
||||||
|
, (4, "%full")
|
||||||
|
, (0, "repository")
|
||||||
|
]
|
||||||
|
|
||||||
showsizes m = do
|
showsizes m = do
|
||||||
size <- M.lookup sizefield m
|
size <- M.lookup sizefield m
|
||||||
maxsize <- M.lookup maxsizefield m
|
maxsize <- M.lookup maxsizefield m
|
||||||
return $ tablerow [formatsize size, formatsize maxsize, ""]
|
return $ tablerow $ zip widths
|
||||||
|
[ formatsize size
|
||||||
|
, formatsize maxsize
|
||||||
|
, case (size, maxsize) of
|
||||||
|
(Just size', Just maxsize') ->
|
||||||
|
showPercentage 0 $
|
||||||
|
percentage maxsize' size'
|
||||||
|
_ -> ""
|
||||||
|
, ""
|
||||||
|
]
|
||||||
|
|
||||||
formatsize = maybe "" (formatSize o (roughSize' storageUnits True 0))
|
formatsize = maybe "" (formatSize o (roughSize' storageUnits True 0))
|
||||||
|
|
||||||
padcolumn s = replicate (7 - length s) ' ' ++ s
|
padcolumn width s = replicate (width - length s) ' ' ++ s
|
||||||
|
|
||||||
tablerow [] = ""
|
tablerow [] = ""
|
||||||
tablerow (s:[]) = " " ++ s
|
tablerow ((_, s):[]) = " " ++ s
|
||||||
tablerow (s:l) = padcolumn s ++ " " ++ tablerow l
|
tablerow ((width, s):l) = padcolumn width s ++ " " ++ tablerow l
|
||||||
|
|
||||||
formatSize :: MaxSizeOptions -> (ByteSize -> String) -> ByteSize -> String
|
formatSize :: MaxSizeOptions -> (ByteSize -> String) -> ByteSize -> String
|
||||||
formatSize o f n
|
formatSize o f n
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue