import React from 'react'; import { DefaultExtensionType, defaultStyles, FileIcon } from 'react-file-icon'; import { FiMenu, FiTrash, FiUploadCloud } from 'react-icons/fi'; import useSWR from 'swr'; import { Card } from '@app/components/generic/Card'; import { IconButton } from '@app/components/generic/IconButton.jsx'; import fetcher from '@app/core/utils/fetcher.js'; import { useAppSelector } from '@app/hooks/redux'; import { PrimaryTemplate } from '@components/templates/PrimaryTemplate'; export interface RangeTestProps { navOpen?: boolean; setNavOpen?: React.Dispatch>; } interface IFile { name: string; nameModified: string; size: number; } interface IFiles { data: { files: IFile[]; filesystem: { free: number; total: number; used: number; }; }; status: boolean; } export const Files = ({ navOpen, setNavOpen }: RangeTestProps): JSX.Element => { const hostOverrideEnabled = useAppSelector( (state) => state.meshtastic.hostOverrideEnabled, ); const hostOverride = useAppSelector((state) => state.meshtastic.hostOverride); const connectionURL = hostOverrideEnabled ? hostOverride : import.meta.env.NODE_ENV === 'production' ? window.location.hostname : (import.meta.env.SNOWPACK_PUBLIC_DEVICE_IP as string) ?? 'http://meshtastic.local'; const { data } = useSWR( `http://${connectionURL}/json/spiffs/browse/static`, fetcher, ); return ( } onClick={(): void => { setNavOpen && setNavOpen(!navOpen); }} /> } >
{data ? (
{JSON.stringify(data.data.filesystem.used)} bytes total
) : (
Loading...
)}
} />} className="md:w-1/3" > {data ? (
{data.data.files.map((file: IFile) => (
=> { // await fetch( // `http://${connectionURL}/json/spiffs/delete/static?remove=${file.name}`, // { // method: 'DELETE', // }, // ); // }} icon={} />
))}
) : (
Loading...
)}
); };