@samitouri / QOSami-HFS / commits / 830348e0

admin/monitoring: live-log will reflect the show-downloads

Massimo Melina committed Nov 21, 2024 at 22:20 UTC 830348e0c10f327130a21d1bed1c4c415146360a
2 files changed +10 -4
admin/src/LogsPage.ts
+8 -3
@@ -99,7 +99,8 @@ export default function LogsPage() {
99
100 const LOGS_ON_FILE: string[] = [CFG.log, CFG.error_log]
101
102 -export function LogFile({ file, footerSide, hidden, limit, ...rest }: { limit?: number, hidden?: boolean, file: string, footerSide?: ReactNode } & Partial<DataTableProps>) {
102 +type LogFileProps = { filter?: (row:any) => boolean, limit?: number, hidden?: boolean, file: string, footerSide?: ReactNode } & Partial<DataTableProps>
103 +export function LogFile({ file, footerSide, hidden, limit, filter, ...rest }: LogFileProps) {
104 const [showCountry, setShowCountry] = useState(false)
105 const [showAgent, setShowAgent] = useState(false)
106 const { pause, pauseButton } = usePauseButton()
@@ -147,7 +148,11 @@ export function LogFile({ file, footerSide, hidden, limit, ...rest }: { limit?:
148 valueGetter: ({ value }) => new Date(value as string),
149 renderCell: ({ value }) => h(Fragment, {}, value.toLocaleDateString(), h('br'), value.toLocaleTimeString())
150 }
150 - const rows = useMemo(() => showApi || list?.[0]?.uri === undefined ? list : list.filter(x => !x.uri.startsWith(API_URL)), [list, showApi]) //TODO TypeError: l.uri is undefined
151 + const rows = useMemo(() =>
152 + filter ? list.filter(filter)
153 + : showApi || list?.[0]?.uri === undefined ? list
154 + : list.filter(x => !x.uri.startsWith(API_URL)),
155 + [list, showApi, filter])
156 const blockIp = useBlockIp()
157 const isConsole = file === 'console'
158 const isIps = file === 'ips'
@@ -315,7 +320,7 @@ export function LogFile({ file, footerSide, hidden, limit, ...rest }: { limit?:
320 setShowAgent(true)
321 if (row.uri) {
322 const partial = stringAfter('?', row.uri).includes('partial=')
318 - row.notes = extra?.dl ? "fully downloaded"
323 + row.notes = extra?.dl ? "fully downloaded" // 'dl' here is not the '?dl' of the url, and has a different meaning
324 : (row.method === 'PUT' || extra?.ul) ? "uploaded " + (partial ? "up to " : "") + formatBytes(extra?.size, { sep: NBSP })
325 : row.status === HTTP_UNAUTHORIZED && row.uri?.startsWith(API_URL + 'loginSrp') ? "login failed" + prefix(':\n', extra?.u)
326 : _.map(extra?.params, (v, k) => `${k}: ${v}\n`).join('') + (row.notes || '')
admin/src/MonitorPage.ts
+2 -1
@@ -8,7 +8,7 @@ import { Alert, Box, Chip, ChipProps, Grid } from '@mui/material'
8 import { DataTable } from './DataTable'
9 import {
10 formatBytes, ipForUrl, CFG, formatSpeed, with_, createDurationFormatter, formatTimestamp, formatPerc, md, Callback,
11 - reactJoin,
11 + reactJoin, SPECIAL_URI,
12 } from "./misc"
13 import {
14 IconBtn, IconProgress, iconTooltip, usePauseButton, useBreakpoint, Country, hTooltip, useToggleButton, Flex, Btn
@@ -270,6 +270,7 @@ function Connections() {
270 logAble && wantLog && h(Grid, { item: true, xs: logSize, display: 'flex', flexDirection: 'column' },
271 h(LogFile, {
272 file: `${CFG.log}|${CFG.error_log}`,
273 + filter: monitorOnlyFiles ? (row => !row.uri.startsWith(SPECIAL_URI)) : undefined,
274 fillFlex: true,
275 compact: false,
276 limit: 1000,