Skip to content

Commit 0c9147e

Browse files
committed
Fix log viewer for small devices
1 parent f4dee3e commit 0c9147e

2 files changed

Lines changed: 64 additions & 27 deletions

File tree

dashboard/src/Dashboard/Component/JobDetail.purs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,12 @@ renderLogEntries state
312312
let pageStart = page * logPageSize
313313
let pageLogs = Array.slice pageStart (pageStart + logPageSize) displayLogs
314314
HH.div_
315-
[ HH.table [ HP.class_ (HH.ClassName "log-table") ]
315+
[ renderLogLegend
316+
, HH.table [ HP.class_ (HH.ClassName "log-table") ]
316317
[ HH.thead_
317318
[ HH.tr_
318319
[ HH.th [ HP.class_ (HH.ClassName "log-table__th log-table__th--rownum") ] [ HH.text "#" ]
319320
, HH.th [ HP.class_ (HH.ClassName "log-table__th log-table__th--time") ] [ HH.text "Time" ]
320-
, HH.th [ HP.class_ (HH.ClassName "log-table__th log-table__th--level") ] [ HH.text "Level" ]
321321
, HH.th [ HP.class_ (HH.ClassName "log-table__th") ] [ HH.text "Message" ]
322322
]
323323
]
@@ -337,16 +337,24 @@ renderLogEntry sortOrder totalLogs offset index logLine = do
337337
[ HH.text (show rowNum) ]
338338
, HH.td [ HP.class_ (HH.ClassName "log-entry__time") ]
339339
[ HH.text (Job.formatTimestamp logLine.timestamp) ]
340-
, HH.td [ HP.class_ (HH.ClassName "log-entry__level") ]
341-
[ HH.span [ HP.class_ (HH.ClassName ("log-level log-level--" <> level)) ]
342-
[ HH.text level ]
343-
]
344340
, HH.td [ HP.class_ (HH.ClassName "log-entry__message") ]
345341
[ HH.pre [ HP.class_ (HH.ClassName "log-entry__text") ]
346342
[ HH.text logLine.message ]
347343
]
348344
]
349345

346+
renderLogLegend :: forall m. H.ComponentHTML Action () m
347+
renderLogLegend =
348+
HH.div [ HP.class_ (HH.ClassName "log-legend") ]
349+
(map renderItem [ Debug, Info, Warn, Notice, Error ])
350+
where
351+
renderItem level = do
352+
let name = V1.printLogLevel level
353+
HH.span [ HP.class_ (HH.ClassName "log-legend__item") ]
354+
[ HH.span [ HP.class_ (HH.ClassName ("log-legend__swatch log-legend__swatch--" <> name)) ] []
355+
, HH.text name
356+
]
357+
350358
-- | Render pagination controls for the log table, reusing the jobs-nav CSS.
351359
renderLogPagination :: forall m. Int -> Int -> Int -> H.ComponentHTML Action () m
352360
renderLogPagination page totalPages totalLogs

dashboard/static/style.css

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,6 @@ code, pre {
577577
padding-right: 0.75em;
578578
}
579579
.log-table__th--time { width: 13em; }
580-
.log-table__th--level { width: 5em; }
581580
.log-entry__rownum {
582581
font-family: "Roboto Mono", monospace;
583582
font-size: 75%;
@@ -596,37 +595,65 @@ code, pre {
596595
font-family: "Roboto Mono", monospace;
597596
font-size: 75%;
598597
color: #777;
599-
white-space: nowrap;
598+
white-space: normal;
600599
padding: 0.25em 0.75em 0.25em 0;
601600
vertical-align: baseline;
602601
width: 13em;
603602
}
604603
@media (prefers-color-scheme: dark) {
605604
.log-entry__time { color: #a0a0a0; }
606605
}
607-
.log-entry__level {
608-
font-family: "Roboto Mono", monospace;
609-
font-size: 75%;
610-
font-weight: 700;
611-
white-space: nowrap;
612-
padding: 0.25em 0.75em 0.25em 0;
613-
vertical-align: baseline;
614-
width: 5em;
615-
}
616606
.log-entry__message {
617607
vertical-align: baseline;
618608
}
619-
.log-level--DEBUG { color: #777; }
620-
.log-level--INFO { color: #1565c0; }
621-
.log-level--WARN { color: #e65100; }
622-
.log-level--NOTICE { color: #c4953a; }
623-
.log-level--ERROR { color: #c62828; }
609+
/* Level indicated via left border on the row's first cell */
610+
.log-entry td:first-child { border-left: 5px solid transparent; }
611+
.log-entry--DEBUG td:first-child { border-left-color: #777; }
612+
.log-entry--INFO td:first-child { border-left-color: #1565c0; }
613+
.log-entry--WARN td:first-child { border-left-color: #e65100; }
614+
.log-entry--NOTICE td:first-child { border-left-color: #c4953a; }
615+
.log-entry--ERROR td:first-child { border-left-color: #c62828; }
616+
@media (prefers-color-scheme: dark) {
617+
.log-entry--DEBUG td:first-child { border-left-color: #a0a0a0; }
618+
.log-entry--INFO td:first-child { border-left-color: #64b5f6; }
619+
.log-entry--WARN td:first-child { border-left-color: #ffb74d; }
620+
.log-entry--NOTICE td:first-child { border-left-color: #d8ac55; }
621+
.log-entry--ERROR td:first-child { border-left-color: #ef9a9a; }
622+
}
623+
/* Log level legend */
624+
.log-legend {
625+
display: flex;
626+
flex-wrap: wrap;
627+
gap: 0.5em 1em;
628+
font-size: var(--font-size-sm);
629+
color: #777;
630+
margin-bottom: 0.5em;
631+
}
624632
@media (prefers-color-scheme: dark) {
625-
.log-level--DEBUG { color: #a0a0a0; }
626-
.log-level--INFO { color: #64b5f6; }
627-
.log-level--WARN { color: #ffb74d; }
628-
.log-level--NOTICE { color: #d8ac55; }
629-
.log-level--ERROR { color: #ef9a9a; }
633+
.log-legend { color: #a0a0a0; }
634+
}
635+
.log-legend__item {
636+
display: flex;
637+
align-items: center;
638+
gap: 0.35em;
639+
}
640+
.log-legend__swatch {
641+
display: inline-block;
642+
width: 5px;
643+
height: 1em;
644+
border-radius: 1px;
645+
}
646+
.log-legend__swatch--DEBUG { background: #777; }
647+
.log-legend__swatch--INFO { background: #1565c0; }
648+
.log-legend__swatch--WARN { background: #e65100; }
649+
.log-legend__swatch--NOTICE { background: #c4953a; }
650+
.log-legend__swatch--ERROR { background: #c62828; }
651+
@media (prefers-color-scheme: dark) {
652+
.log-legend__swatch--DEBUG { background: #a0a0a0; }
653+
.log-legend__swatch--INFO { background: #64b5f6; }
654+
.log-legend__swatch--WARN { background: #ffb74d; }
655+
.log-legend__swatch--NOTICE { background: #d8ac55; }
656+
.log-legend__swatch--ERROR { background: #ef9a9a; }
630657
}
631658
.log-entry__text {
632659
font-family: "Roboto Mono", monospace;
@@ -784,4 +811,6 @@ code, pre {
784811
.jobs-table__th:nth-child(6),
785812
.jobs-table__td:nth-child(6) { display: none; }
786813
.job-detail__ts-label { flex: 0 0 5.5em; }
814+
.log-table__th--time { width: 8em; text-align: right; }
815+
.log-entry__time { width: 8em; text-align: right; }
787816
}

0 commit comments

Comments
 (0)