Skip to content

Commit 0e7163f

Browse files
committed
feat(logs): improve log count visibility
- Add total logs count to sticky display options bar - Show exact remaining count in load more button ("load 32 more" vs "load up to 100 more")
1 parent d7d1c6c commit 0e7163f

File tree

2 files changed

+42
-18
lines changed

2 files changed

+42
-18
lines changed

products/logs/frontend/LogsScene.tsx

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { Sparkline } from 'lib/components/Sparkline'
2828
import { TZLabel, TZLabelProps } from 'lib/components/TZLabel'
2929
import { ListHog } from 'lib/components/hedgehogs'
3030
import { LemonField } from 'lib/lemon-ui/LemonField'
31+
import { humanFriendlyNumber } from 'lib/utils'
3132
import { cn } from 'lib/utils/css-classes'
3233
import { Scene, SceneExport } from 'scenes/sceneTypes'
3334
import { sceneConfigurations } from 'scenes/scenes'
@@ -67,6 +68,8 @@ export function LogsScene(): JSX.Element {
6768
isPinned,
6869
hasMoreLogsToLoad,
6970
logsPageSize,
71+
totalLogsMatchingFilters,
72+
logsRemainingToLoad,
7073
} = useValues(logsLogic)
7174
const { runQuery, setDateRangeFromSparkline, loadMoreLogs } = useActions(logsLogic)
7275

@@ -172,10 +175,10 @@ export function LogsScene(): JSX.Element {
172175
disabled={!hasMoreLogsToLoad || logsLoading}
173176
>
174177
{logsLoading
175-
? `Loading up to ${logsPageSize} more logs...`
178+
? 'Loading more logs...'
176179
: hasMoreLogsToLoad
177-
? `Showing first ${parsedLogs.length} ${parsedLogs.length === 1 ? 'entry' : 'entries'} – load up to ${logsPageSize} more`
178-
: `Showing all ${parsedLogs.length} ${parsedLogs.length === 1 ? 'entry' : 'entries'}`}
180+
? `Showing ${humanFriendlyNumber(parsedLogs.length)} of ${humanFriendlyNumber(totalLogsMatchingFilters)} logs – load ${humanFriendlyNumber(Math.min(logsPageSize, logsRemainingToLoad))} more`
181+
: `Showing all ${humanFriendlyNumber(parsedLogs.length)} logs`}
179182
</LemonButton>
180183
</div>
181184
)}
@@ -451,7 +454,15 @@ const Filters = (): JSX.Element => {
451454
}
452455

453456
const DisplayOptions = (): JSX.Element => {
454-
const { orderBy, wrapBody, prettifyJson, timestampFormat, logsPageSize } = useValues(logsLogic)
457+
const {
458+
orderBy,
459+
wrapBody,
460+
prettifyJson,
461+
timestampFormat,
462+
logsPageSize,
463+
totalLogsMatchingFilters,
464+
sparklineLoading,
465+
} = useValues(logsLogic)
455466
const { setOrderBy, setWrapBody, setPrettifyJson, setTimestampFormat, setLogsPageSize } = useActions(logsLogic)
456467

457468
return (
@@ -492,20 +503,25 @@ const DisplayOptions = (): JSX.Element => {
492503
]}
493504
/>
494505
</div>
495-
<LemonField.Pure label="Page Size" inline className="items-center gap-2">
496-
<LemonSelect
497-
value={logsPageSize}
498-
onChange={(value: number) => setLogsPageSize(value)}
499-
size="small"
500-
type="secondary"
501-
options={[
502-
{ value: 100, label: '100' },
503-
{ value: 200, label: '200' },
504-
{ value: 500, label: '500' },
505-
{ value: 1000, label: '1000' },
506-
]}
507-
/>
508-
</LemonField.Pure>
506+
<div className="flex items-center gap-4">
507+
{!sparklineLoading && totalLogsMatchingFilters > 0 && (
508+
<span className="text-muted text-xs">{humanFriendlyNumber(totalLogsMatchingFilters)} logs</span>
509+
)}
510+
<LemonField.Pure label="Page size" inline className="items-center gap-2">
511+
<LemonSelect
512+
value={logsPageSize}
513+
onChange={(value: number) => setLogsPageSize(value)}
514+
size="small"
515+
type="secondary"
516+
options={[
517+
{ value: 100, label: '100' },
518+
{ value: 200, label: '200' },
519+
{ value: 500, label: '500' },
520+
{ value: 1000, label: '1000' },
521+
]}
522+
/>
523+
</LemonField.Pure>
524+
</div>
509525
</div>
510526
)
511527
}

products/logs/frontend/logsLogic.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,14 @@ export const logsLogic = kea<logsLogicType>([
595595
return newest
596596
},
597597
],
598+
totalLogsMatchingFilters: [
599+
(s) => [s.sparkline],
600+
(sparkline): number => sparkline.reduce((sum, item) => sum + item.count, 0),
601+
],
602+
logsRemainingToLoad: [
603+
(s) => [s.totalLogsMatchingFilters, s.logs],
604+
(totalLogsMatchingFilters, logs): number => totalLogsMatchingFilters - logs.length,
605+
],
598606
}),
599607

600608
listeners(({ values, actions }) => ({

0 commit comments

Comments
 (0)