Skip to content

Commit edca97c

Browse files
format purescript code
1 parent 150c99f commit edca97c

4 files changed

Lines changed: 57 additions & 26 deletions

File tree

dashboard/src/Dashboard/Component/JobDetail.purs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,10 @@ renderLogEntries state
303303
[ HH.p_ [ HH.text "No logs at this level." ] ]
304304
| otherwise = do
305305
-- Logs are stored in ASC order; reverse at render time for DESC.
306-
let displayLogs = case state.logSortOrder of
307-
ASC -> state.allLogs
308-
DESC -> Array.reverse state.allLogs
306+
let
307+
displayLogs = case state.logSortOrder of
308+
ASC -> state.allLogs
309+
DESC -> Array.reverse state.allLogs
309310
let totalLogs = Array.length displayLogs
310311
let totalPages = logTotalPages totalLogs
311312
let page = min state.logPage (totalPages - 1)
@@ -329,9 +330,10 @@ renderLogEntries state
329330
renderLogEntry :: forall m. SortOrder -> Int -> Int -> Int -> LogLine -> H.ComponentHTML Action () m
330331
renderLogEntry sortOrder totalLogs offset index logLine = do
331332
let level = V1.printLogLevel logLine.level
332-
let rowNum = case sortOrder of
333-
ASC -> offset + index + 1
334-
DESC -> totalLogs - offset - index
333+
let
334+
rowNum = case sortOrder of
335+
ASC -> offset + index + 1
336+
DESC -> totalLogs - offset - index
335337
HH.tr [ HP.class_ (HH.ClassName ("log-entry log-entry--" <> level)) ]
336338
[ HH.td [ HP.class_ (HH.ClassName "log-entry__rownum") ]
337339
[ HH.text (show rowNum) ]
@@ -388,9 +390,10 @@ handleAction = case _ of
388390
H.modify_ _ { currentTime = Just now }
389391
handleAction FetchJob
390392
state <- H.get
391-
let finished = case state.job of
392-
Just job -> isJust (V1.jobInfo job).finishedAt
393-
Nothing -> false
393+
let
394+
finished = case state.job of
395+
Just job -> isJust (V1.jobInfo job).finishedAt
396+
Nothing -> false
394397
unless finished do
395398
subId <- H.subscribe =<< Job.timerEmitter logRefreshInterval LogRefreshTick
396399
H.modify_ _ { logRefreshSubId = Just subId }
@@ -467,9 +470,10 @@ handleAction = case _ of
467470
H.modify_ _ { currentTime = Just now }
468471
state <- H.get
469472
-- No-op if the job is already finished: all logs have been fetched.
470-
let finished = case state.job of
471-
Just job -> isJust (V1.jobInfo job).finishedAt
472-
Nothing -> false
473+
let
474+
finished = case state.job of
475+
Just job -> isJust (V1.jobInfo job).finishedAt
476+
Nothing -> false
473477
unless finished do
474478
result <- H.liftAff $ API.fetchJob state.apiConfig (JobId state.jobId)
475479
{ level: Just state.logLevel, since: state.lastLogTimestamp, until: Nothing, order: Just ASC }

dashboard/src/Dashboard/Component/JobsList.purs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,10 @@ type PageCursor = { timestamp :: DateTime, dir :: PaginationDir }
152152

153153
printCursorParam :: PageCursor -> String
154154
printCursorParam { timestamp, dir } =
155-
(case dir of
156-
Forward -> "f:"
157-
Backward -> "b:")
155+
( case dir of
156+
Forward -> "f:"
157+
Backward -> "b:"
158+
)
158159
<> Job.formatCursorTimestamp timestamp
159160

160161
parseCursorParam :: String -> Maybe PageCursor
@@ -691,9 +692,10 @@ handleAction = case _ of
691692
-- avoids VDOM diffing on every auto-refresh tick when nothing new
692693
-- has arrived.
693694
unless (not state.loading && newFingerprints == oldFingerprints) do
694-
let isBackward = case state.pageCursor of
695-
Just { dir: Backward } -> true
696-
_ -> false
695+
let
696+
isBackward = case state.pageCursor of
697+
Just { dir: Backward } -> true
698+
_ -> false
697699
let hasNext = isBackward || Array.length jobs >= pageSize
698700
H.modify_ _ { loading = false, error = Nothing, jobs = summaries, hasNextPage = hasNext }
699701

dashboard/src/Dashboard/Job.purs

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import Prelude
2626
import Control.Monad.Rec.Class (forever)
2727
import Data.DateTime (DateTime)
2828
import Data.DateTime as DateTime
29+
import Data.Either (hush)
2930
import Data.Formatter.DateTime (FormatterCommand(..))
3031
import Data.Formatter.DateTime as Formatter.DateTime
3132
import Data.Int as Int
3233
import Data.List (List)
3334
import Data.List as List
34-
import Data.Either (hush)
3535
import Data.Maybe (Maybe(..), isJust, isNothing)
3636
import Data.Newtype (unwrap)
3737
import Data.Time.Duration (Seconds)
@@ -142,8 +142,17 @@ formatTimestamp = Formatter.DateTime.format timestampFormat
142142
-- "YYYY-MM-DD HH:MM:SS"
143143
timestampFormat :: List FormatterCommand
144144
timestampFormat = List.fromFoldable
145-
[ YearFull, Placeholder "-", MonthTwoDigits, Placeholder "-", DayOfMonthTwoDigits
146-
, Placeholder " ", Hours24, Placeholder ":", MinutesTwoDigits, Placeholder ":", SecondsTwoDigits
145+
[ YearFull
146+
, Placeholder "-"
147+
, MonthTwoDigits
148+
, Placeholder "-"
149+
, DayOfMonthTwoDigits
150+
, Placeholder " "
151+
, Hours24
152+
, Placeholder ":"
153+
, MinutesTwoDigits
154+
, Placeholder ":"
155+
, SecondsTwoDigits
147156
]
148157

149158
-- | Format a DateTime as an HTML datetime-local input value "YYYY-MM-DDTHH:MM".
@@ -157,8 +166,15 @@ parseDateTimeLocal = hush <<< Formatter.DateTime.unformat dateTimeLocalFormat
157166
-- "YYYY-MM-DDTHH:MM"
158167
dateTimeLocalFormat :: List FormatterCommand
159168
dateTimeLocalFormat = List.fromFoldable
160-
[ YearFull, Placeholder "-", MonthTwoDigits, Placeholder "-", DayOfMonthTwoDigits
161-
, Placeholder "T", Hours24, Placeholder ":", MinutesTwoDigits
169+
[ YearFull
170+
, Placeholder "-"
171+
, MonthTwoDigits
172+
, Placeholder "-"
173+
, DayOfMonthTwoDigits
174+
, Placeholder "T"
175+
, Hours24
176+
, Placeholder ":"
177+
, MinutesTwoDigits
162178
]
163179

164180
-- | Format a DateTime as a URL-safe cursor timestamp "YYYY-MM-DDTHH:MM:SS".
@@ -172,8 +188,17 @@ parseCursorTimestamp = hush <<< Formatter.DateTime.unformat cursorTimestampForma
172188
-- "YYYY-MM-DDTHH:MM:SS"
173189
cursorTimestampFormat :: List FormatterCommand
174190
cursorTimestampFormat = List.fromFoldable
175-
[ YearFull, Placeholder "-", MonthTwoDigits, Placeholder "-", DayOfMonthTwoDigits
176-
, Placeholder "T", Hours24, Placeholder ":", MinutesTwoDigits, Placeholder ":", SecondsTwoDigits
191+
[ YearFull
192+
, Placeholder "-"
193+
, MonthTwoDigits
194+
, Placeholder "-"
195+
, DayOfMonthTwoDigits
196+
, Placeholder "T"
197+
, Hours24
198+
, Placeholder ":"
199+
, MinutesTwoDigits
200+
, Placeholder ":"
201+
, SecondsTwoDigits
177202
]
178203

179204
-- | Format a duration in seconds as a human-readable string.

dashboard/src/Dashboard/Router.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import Dashboard.Component.JobDetail as JobDetail
1010
import Dashboard.Component.JobsList as JobsList
1111
import Dashboard.Route (Route(..))
1212
import Dashboard.Route as Route
13+
import Data.Array as Array
1314
import Data.Const (Const)
1415
import Data.Either (hush)
15-
import Data.Array as Array
1616
import Data.Maybe (Maybe(..), fromMaybe)
1717
import Data.String (Pattern(..))
1818
import Data.String as String

0 commit comments

Comments
 (0)