Skip to content
This repository was archived by the owner on Oct 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions src/components/admin/server/ContentCounts.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useTranslation } from 'react-i18next'
import { formatBytes } from '@/lib/utils/format'
import { Section } from '@/components/account/Section'
import { useLibrariesStats, useServerStats } from '../stats'
import { useServerStats } from '../stats'

interface ContentStat {
labelKey: string
Expand All @@ -12,17 +12,16 @@ interface ContentStat {
export function ContentCounts() {
const { t } = useTranslation('admin-settings')
const server = useServerStats()
const libraries = useLibrariesStats()
const totals = server.data?.totals

const loading = server.isLoading || libraries.isLoading
const stats: ContentStat[] = [
{ labelKey: 'content.libraries', value: server.data?.totals.libraries },
{ labelKey: 'content.series', value: libraries.data?.total.series },
{ labelKey: 'content.books', value: libraries.data?.total.books },
{ labelKey: 'content.collections', value: server.data?.totals.collections },
{ labelKey: 'content.readLists', value: server.data?.totals.readlists },
{ labelKey: 'content.sidecars', value: libraries.data?.total.sidecars },
{ labelKey: 'content.totalSize', value: libraries.data?.total.fileSize, format: formatBytes },
{ labelKey: 'content.libraries', value: totals?.libraries },
{ labelKey: 'content.series', value: totals?.series },
{ labelKey: 'content.books', value: totals?.books },
{ labelKey: 'content.collections', value: totals?.collections },
{ labelKey: 'content.readLists', value: totals?.readlists },
{ labelKey: 'content.sidecars', value: totals?.sidecars },
{ labelKey: 'content.totalSize', value: totals?.fileSize, format: formatBytes },
]

return (
Expand All @@ -31,7 +30,7 @@ export function ContentCounts() {
{stats.map((s) => (
<div key={s.labelKey}>
<p className="text-2xl font-semibold text-ink">
{loading ? '…' : s.value === undefined ? '—' : (s.format?.(s.value) ?? s.value)}
{server.isLoading ? '…' : s.value === undefined ? '—' : (s.format?.(s.value) ?? s.value)}
</p>
<p className="mt-0.5 text-xs text-ink-3">{t(s.labelKey)}</p>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/lib/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,10 @@ export interface ServerStatsDto {
}
totals: {
libraries: number
/** absent on kmrs < 0.18.5 */
series?: number
books?: number
fileSize?: number
collections: number
readlists: number
sidecars: number
Expand Down
Loading