mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 10:58:26 +00:00
Initial version.
Features: - Upload PDF files let them analyze - Manage meta data and items - See processing in webapp
This commit is contained in:
24
modules/webapp/src/main/elm/Util/Size.elm
Normal file
24
modules/webapp/src/main/elm/Util/Size.elm
Normal file
@ -0,0 +1,24 @@
|
||||
module Util.Size exposing (..)
|
||||
|
||||
type SizeUnit = G|M|K|B
|
||||
|
||||
prettyNumber: Float -> String
|
||||
prettyNumber n =
|
||||
let
|
||||
parts = String.split "." (String.fromFloat n)
|
||||
in
|
||||
case parts of
|
||||
n0 :: d :: [] -> n0 ++ "." ++ (String.left 2 d)
|
||||
_ -> String.join "." parts
|
||||
|
||||
bytesReadable: SizeUnit -> Float -> String
|
||||
bytesReadable unit n =
|
||||
let
|
||||
k = n / 1024
|
||||
num = prettyNumber n
|
||||
in
|
||||
case unit of
|
||||
G -> num ++ "G"
|
||||
M -> if k > 1 then (bytesReadable G k) else num ++ "M"
|
||||
K -> if k > 1 then (bytesReadable M k) else num ++ "K"
|
||||
B -> if k > 1 then (bytesReadable K k) else num ++ "B"
|
Reference in New Issue
Block a user