mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Remove Util.Time module, useing Message.DateFormat
This commit is contained in:
@ -11,6 +11,7 @@ module Messages.DateFormat exposing
|
|||||||
, formatDateShort
|
, formatDateShort
|
||||||
, formatDateTimeLong
|
, formatDateTimeLong
|
||||||
, formatDateTimeShort
|
, formatDateTimeShort
|
||||||
|
, formatIsoDateTimeUtc
|
||||||
)
|
)
|
||||||
|
|
||||||
import DateFormat exposing (Token)
|
import DateFormat exposing (Token)
|
||||||
@ -20,6 +21,7 @@ import Time
|
|||||||
exposing
|
exposing
|
||||||
( Month(..)
|
( Month(..)
|
||||||
, Weekday(..)
|
, Weekday(..)
|
||||||
|
, Zone
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -74,6 +76,29 @@ formatDateTimeShort lang millis =
|
|||||||
format lang .dateTimeShort millis
|
format lang .dateTimeShort millis
|
||||||
|
|
||||||
|
|
||||||
|
isoDateTimeFormatter : List Token
|
||||||
|
isoDateTimeFormatter =
|
||||||
|
[ DateFormat.yearNumber
|
||||||
|
, DateFormat.text "-"
|
||||||
|
, DateFormat.monthFixed
|
||||||
|
, DateFormat.text "-"
|
||||||
|
, DateFormat.dayOfMonthFixed
|
||||||
|
, DateFormat.text "T"
|
||||||
|
, DateFormat.hourMilitaryNumber
|
||||||
|
, DateFormat.text ":"
|
||||||
|
, DateFormat.minuteFixed
|
||||||
|
, DateFormat.text ":"
|
||||||
|
, DateFormat.secondFixed
|
||||||
|
, DateFormat.text "Z"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
formatIsoDateTimeUtc : Int -> String
|
||||||
|
formatIsoDateTimeUtc millis =
|
||||||
|
Time.millisToPosix millis
|
||||||
|
|> DateFormat.format isoDateTimeFormatter Time.utc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Language Definitions
|
--- Language Definitions
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import Html.Events exposing (onClick)
|
|||||||
import Messages.Page.Queue exposing (Texts)
|
import Messages.Page.Queue exposing (Texts)
|
||||||
import Page.Queue.Data exposing (..)
|
import Page.Queue.Data exposing (..)
|
||||||
import Styles as S
|
import Styles as S
|
||||||
import Util.Time exposing (formatIsoDateTime)
|
|
||||||
|
|
||||||
|
|
||||||
viewSidebar : Texts -> Bool -> Flags -> UiSettings -> Model -> Html Msg
|
viewSidebar : Texts -> Bool -> Flags -> UiSettings -> Model -> Html Msg
|
||||||
@ -91,7 +90,7 @@ viewSidebar texts visible _ _ model =
|
|||||||
|
|
||||||
|
|
||||||
viewContent : Texts -> Flags -> UiSettings -> Model -> Html Msg
|
viewContent : Texts -> Flags -> UiSettings -> Model -> Html Msg
|
||||||
viewContent texts _ _ model =
|
viewContent texts _ settings model =
|
||||||
let
|
let
|
||||||
gridStyle =
|
gridStyle =
|
||||||
"grid gap-4 grid-cols-1 md:grid-cols-2"
|
"grid gap-4 grid-cols-1 md:grid-cols-2"
|
||||||
@ -109,7 +108,7 @@ viewContent texts _ _ model =
|
|||||||
]
|
]
|
||||||
[ case model.showLog of
|
[ case model.showLog of
|
||||||
Just job ->
|
Just job ->
|
||||||
renderJobLog job
|
renderJobLog texts settings job
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
span [ class "hidden" ] []
|
span [ class "hidden" ] []
|
||||||
@ -120,7 +119,7 @@ viewContent texts _ _ model =
|
|||||||
|
|
||||||
else
|
else
|
||||||
div [ class "flex flex-col space-y-2" ]
|
div [ class "flex flex-col space-y-2" ]
|
||||||
(List.map (renderProgressCard texts model) model.state.progress)
|
(List.map (renderProgressCard texts settings model) model.state.progress)
|
||||||
|
|
||||||
QueueAll ->
|
QueueAll ->
|
||||||
if List.isEmpty model.state.completed && List.isEmpty model.state.completed then
|
if List.isEmpty model.state.completed && List.isEmpty model.state.completed then
|
||||||
@ -187,8 +186,8 @@ filterJobDetails list state =
|
|||||||
List.filter isState list
|
List.filter isState list
|
||||||
|
|
||||||
|
|
||||||
renderJobLog : JobDetail -> Html Msg
|
renderJobLog : Texts -> UiSettings -> JobDetail -> Html Msg
|
||||||
renderJobLog job =
|
renderJobLog texts settings job =
|
||||||
div
|
div
|
||||||
[ class " absolute top-12 left-0 w-full h-full-12 z-40 flex flex-col items-center px-4 py-2 "
|
[ class " absolute top-12 left-0 w-full h-full-12 z-40 flex flex-col items-center px-4 py-2 "
|
||||||
, class "bg-white bg-opacity-80 dark:bg-black dark:bg-slate-900 dark:bg-opacity-90"
|
, class "bg-white bg-opacity-80 dark:bg-black dark:bg-slate-900 dark:bg-opacity-90"
|
||||||
@ -209,13 +208,13 @@ renderJobLog job =
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
, div [ class styleJobLog ]
|
, div [ class styleJobLog ]
|
||||||
(List.map renderLogLine job.logs)
|
(List.map (renderLogLine texts settings) job.logs)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
renderProgressCard : Texts -> Model -> JobDetail -> Html Msg
|
renderProgressCard : Texts -> UiSettings -> Model -> JobDetail -> Html Msg
|
||||||
renderProgressCard texts model job =
|
renderProgressCard texts settings model job =
|
||||||
div [ class (S.box ++ "px-2 flex flex-col") ]
|
div [ class (S.box ++ "px-2 flex flex-col") ]
|
||||||
[ Comp.Progress.topAttachedIndicating job.progress
|
[ Comp.Progress.topAttachedIndicating job.progress
|
||||||
, Html.map (DimmerMsg job)
|
, Html.map (DimmerMsg job)
|
||||||
@ -248,7 +247,7 @@ renderProgressCard texts model job =
|
|||||||
]
|
]
|
||||||
, div [ class "py-2", id "joblog" ]
|
, div [ class "py-2", id "joblog" ]
|
||||||
[ div [ class styleJobLog ]
|
[ div [ class styleJobLog ]
|
||||||
(List.map renderLogLine job.logs)
|
(List.map (renderLogLine texts settings) job.logs)
|
||||||
]
|
]
|
||||||
, div [ class "py-2 flex flex-row justify-end" ]
|
, div [ class "py-2 flex flex-row justify-end" ]
|
||||||
[ button [ class S.secondaryButton, onClick (RequestCancelJob job) ]
|
[ button [ class S.secondaryButton, onClick (RequestCancelJob job) ]
|
||||||
@ -263,8 +262,8 @@ styleJobLog =
|
|||||||
"bg-gray-900 text-xs leading-5 px-2 py-1 font-mono text-gray-100 overflow-auto max-h-96 rounded"
|
"bg-gray-900 text-xs leading-5 px-2 py-1 font-mono text-gray-100 overflow-auto max-h-96 rounded"
|
||||||
|
|
||||||
|
|
||||||
renderLogLine : JobLogEvent -> Html Msg
|
renderLogLine : Texts -> UiSettings -> JobLogEvent -> Html Msg
|
||||||
renderLogLine log =
|
renderLogLine texts settings log =
|
||||||
let
|
let
|
||||||
lineStyle =
|
lineStyle =
|
||||||
case String.toLower log.level of
|
case String.toLower log.level of
|
||||||
@ -284,7 +283,7 @@ renderLogLine log =
|
|||||||
""
|
""
|
||||||
in
|
in
|
||||||
span [ class lineStyle ]
|
span [ class lineStyle ]
|
||||||
[ formatIsoDateTime log.time |> text
|
[ texts.formatDateTime log.time |> text
|
||||||
, text ": "
|
, text ": "
|
||||||
, text log.message
|
, text log.message
|
||||||
, br [] []
|
, br [] []
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
{-
|
|
||||||
Copyright 2020 Eike K. & Contributors
|
|
||||||
|
|
||||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
|
||||||
-}
|
|
||||||
|
|
||||||
|
|
||||||
module Util.Time exposing (formatIsoDateTime)
|
|
||||||
|
|
||||||
import DateFormat
|
|
||||||
import Time exposing (Posix, Zone, utc)
|
|
||||||
|
|
||||||
|
|
||||||
isoDateTimeFormatter : Zone -> Posix -> String
|
|
||||||
isoDateTimeFormatter =
|
|
||||||
DateFormat.format
|
|
||||||
[ DateFormat.yearNumber
|
|
||||||
, DateFormat.text "-"
|
|
||||||
, DateFormat.monthFixed
|
|
||||||
, DateFormat.text "-"
|
|
||||||
, DateFormat.dayOfMonthFixed
|
|
||||||
, DateFormat.text "T"
|
|
||||||
, DateFormat.hourMilitaryNumber
|
|
||||||
, DateFormat.text ":"
|
|
||||||
, DateFormat.minuteFixed
|
|
||||||
, DateFormat.text ":"
|
|
||||||
, DateFormat.secondFixed
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
timeZone : Zone
|
|
||||||
timeZone =
|
|
||||||
utc
|
|
||||||
|
|
||||||
|
|
||||||
formatIsoDateTime : Int -> String
|
|
||||||
formatIsoDateTime millis =
|
|
||||||
Time.millisToPosix millis
|
|
||||||
|> isoDateTimeFormatter timeZone
|
|
Reference in New Issue
Block a user