MCPcopy
hub / github.com/cita-777/metapi / ProxyLogs

Function ProxyLogs

src/web/pages/ProxyLogs.tsx:653–2316  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

651}
652
653export default function ProxyLogs() {
654 const location = useLocation();
655 const navigate = useNavigate();
656 const initialRouteState = useMemo(() => readProxyLogsRouteState(location.search), [location.search]);
657 const [logs, setLogs] = useState<ProxyLogListItem[]>([]);
658 const [summary, setSummary] = useState<ProxyLogsSummary>(EMPTY_SUMMARY);
659 const [total, setTotal] = useState(0);
660 const [loading, setLoading] = useState(true);
661 const [statusFilter, setStatusFilter] = useState<ProxyLogStatusFilter>(initialRouteState.status);
662 const [searchInput, setSearchInput] = useState(initialRouteState.search);
663 const deferredSearchInput = useDeferredValue(searchInput.trim());
664 const [clientFilter, setClientFilter] = useState(initialRouteState.client);
665 const [siteFilter, setSiteFilter] = useState<number | null>(initialRouteState.siteId);
666 const [fromInput, setFromInput] = useState(initialRouteState.from);
667 const [toInput, setToInput] = useState(initialRouteState.to);
668 const [expanded, setExpanded] = useState<number | null>(null);
669 const [page, setPage] = useState(initialRouteState.page);
670 const [pageSize, setPageSize] = useState(initialRouteState.pageSize);
671 const [detailById, setDetailById] = useState<Record<number, ProxyLogDetailState>>({});
672 const [showFilters, setShowFilters] = useState(false);
673 const [sites, setSites] = useState<Array<{ id: number; name: string; status?: string | null }>>([]);
674 const [clientOptions, setClientOptions] = useState<ProxyLogClientOption[]>([]);
675 const [autoRefresh, setAutoRefresh] = useState(false);
676 const [showDebugSettingsModal, setShowDebugSettingsModal] = useState(false);
677 const [debugPanelLoading, setDebugPanelLoading] = useState(false);
678 const [debugPanelSaving, setDebugPanelSaving] = useState(false);
679 const [debugTracePanelExpanded, setDebugTracePanelExpanded] = useState(() => readStoredDebugTracePanelExpanded());
680 const [debugSettings, setDebugSettings] = useState<ProxyDebugSettingsState>(DEFAULT_PROXY_DEBUG_SETTINGS);
681 const [debugDraftSettings, setDebugDraftSettings] = useState<ProxyDebugSettingsState>(DEFAULT_PROXY_DEBUG_SETTINGS);
682 const [debugTraces, setDebugTraces] = useState<ProxyDebugTraceListItem[]>([]);
683 const [debugTracePage, setDebugTracePage] = useState(1);
684 const [selectedDebugTraceId, setSelectedDebugTraceId] = useState<number | null>(null);
685 const [showDebugTraceDetailModal, setShowDebugTraceDetailModal] = useState(false);
686 const [debugDetailById, setDebugDetailById] = useState<Record<number, ProxyDebugTraceDetailState>>({});
687 const isMobile = useIsMobile(768);
688 const toast = useToast();
689 const loadSeq = useRef(0);
690 const selectedDebugTraceIdRef = useRef<number | null>(null);
691 const debugDetailByIdRef = useRef<Record<number, ProxyDebugTraceDetailState>>({});
692 const debugDetailInFlightRef = useRef<Set<number>>(new Set());
693 const fromApiBoundary = toApiTimeBoundary(fromInput);
694 const toApiBoundaryValue = toApiTimeBoundary(toInput);
695 const hasInvalidTimeRange = Boolean(
696 fromApiBoundary
697 && toApiBoundaryValue
698 && new Date(fromApiBoundary).getTime() >= new Date(toApiBoundaryValue).getTime(),
699 );
700
701 useEffect(() => {
702 const next = readProxyLogsRouteState(location.search);
703 setStatusFilter((current) => (current === next.status ? current : next.status));
704 setSearchInput((current) => (current === next.search ? current : next.search));
705 setClientFilter((current) => (current === next.client ? current : next.client));
706 setSiteFilter((current) => (current === next.siteId ? current : next.siteId));
707 setFromInput((current) => (current === next.from ? current : next.from));
708 setToInput((current) => (current === next.to ? current : next.to));
709 setPage((current) => (current === next.page ? current : next.page));
710 setPageSize((current) => (current === next.pageSize ? current : next.pageSize));

Callers

nothing calls this directly

Calls 15

readProxyLogsRouteStateFunction · 0.85
useIsMobileFunction · 0.85
useToastFunction · 0.85
toApiTimeBoundaryFunction · 0.85
loadSitesFunction · 0.85
parseStoredDebugPreviewFunction · 0.85
copyTextToClipboardFunction · 0.85

Tested by

no test coverage detected