A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.
fix: resolve logs not appearing when log viewer is opened.
towfiqi75984f77dbbf
diff --git a/frontend/src/components/common/LogViewer/LogViewer.module.scss b/frontend/src/components/common/LogViewer/LogViewer.module.scssindex 85b46c9..4652569 100644--- a/frontend/src/components/common/LogViewer/LogViewer.module.scss+++ b/frontend/src/components/common/LogViewer/LogViewer.module.scss@@ -68,7 +68,7 @@}}.logs {- height: calc(100vh - 290px);+ height: calc(100vh - 300px);overflow: auto;.log {diff --git a/frontend/src/components/common/LogViewer/LogViewer.tsx b/frontend/src/components/common/LogViewer/LogViewer.tsxindex c10678e..bb53004 100644--- a/frontend/src/components/common/LogViewer/LogViewer.tsx+++ b/frontend/src/components/common/LogViewer/LogViewer.tsx@@ -1,4 +1,4 @@-import { useState } from 'react';+import { useState, useEffect } from 'react';import Icon from '../Icon/Icon';import classes from './LogViewer.module.scss';import { useGetDownloadLogs } from '../../../services/plans';@@ -25,19 +25,27 @@ const LogViewer = ({ type = '', planMethod = 'backup', logs = [], planId, settinconst allTaskTypes = [...new Set(logs.map((log) => log.module))];const [search, setSearch] = useState('');const [filters, setFilters] = useState<string[]>(['info', 'error', 'warn']);- const [taskTypes, setTaskTypes] = useState<string[]>(allTaskTypes);+ const [taskTypes, setTaskTypes] = useState<string[]>([]);const [currentPage, setCurrentPage] = useState(1);const downloadPlanLogsMutation = useGetDownloadLogs();const downloadAppLogsMutation = useGetDownloadAppLogs();- const theLogs = logs.filter((log) => {- const matchesSearch = log.msg?.toLowerCase().includes(search.toLowerCase());- const matchesBackupId = log.backupId?.toLowerCase().includes(search.toLowerCase());- const logType = getLogLevelName(log.level);- const matchesFilter = filters.includes(logType);- const matchesTaskType = taskTypes.includes(log.module);- return (matchesSearch || matchesBackupId) && matchesFilter && matchesTaskType;- });+ useEffect(() => {+ if (allTaskTypes.length > 0 && taskTypes.length === 0) {+ setTaskTypes(allTaskTypes);+ }+ }, [allTaskTypes.length]);++ const theLogs = logs+ .filter((log) => {+ const matchesSearch = log.msg?.toLowerCase().includes(search.toLowerCase());+ const matchesBackupId = log.backupId?.toLowerCase().includes(search.toLowerCase());+ const logType = getLogLevelName(log.level);+ const matchesFilter = filters.includes(logType);+ const matchesTaskType = taskTypes.includes(log.module);+ return (matchesSearch || matchesBackupId) && matchesFilter && matchesTaskType;+ })+ .sort((a, b) => new Date(b.time).getTime() - new Date(a.time).getTime());const showPagination = theLogs.length > PAGINATION_THRESHOLD;const totalPages = Math.ceil(theLogs.length / ITEMS_PER_PAGE);