WIP
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import type React from 'react';
|
||||
|
||||
import { Button } from '@app/components/generic/button/Button';
|
||||
import { Card } from '@app/components/generic/Card';
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import React from 'react';
|
||||
import type React from 'react';
|
||||
|
||||
import { AnimatePresence, m } from 'framer-motion';
|
||||
import { FiFilePlus } from 'react-icons/fi';
|
||||
import useSWR from 'swr';
|
||||
|
||||
import { Button } from '@app/components/generic/button/Button';
|
||||
import { Card } from '@app/components/generic/Card';
|
||||
import { fetcher } from '@core/utils/fetcher';
|
||||
import { useAppSelector } from '@hooks/useAppSelector';
|
||||
@@ -29,22 +31,27 @@ export const FileBrowser = (): JSX.Element => {
|
||||
const connectionParams = useAppSelector(
|
||||
(state) => state.app.connectionParams,
|
||||
);
|
||||
const darkMode = useAppSelector((state) => state.app.darkMode);
|
||||
const appState = useAppSelector((state) => state.app);
|
||||
const meshtasticState = useAppSelector((state) => state.meshtastic);
|
||||
|
||||
const { data } = useSWR<Files>(
|
||||
`${connectionParams.HTTP.tls ? 'https' : 'http'}://${
|
||||
connectionParams.HTTP.address
|
||||
}/json/spiffs/browse/static`,
|
||||
}${
|
||||
meshtasticState.radio.hardware.firmwareVersion.includes('1.2')
|
||||
? '/json/spiffs/browse/static'
|
||||
: '/json/fs/browse/static'
|
||||
}`,
|
||||
fetcher,
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="flex h-full p-4">
|
||||
<Card className="flex-grow flex-col">
|
||||
<div className="flex h-10 w-full rounded-t-md border-b border-gray-300 px-4 text-lg font-semibold shadow-md dark:border-gray-600 dark:bg-zinc-700 dark:text-white">
|
||||
<div className="my-auto w-1/3">FileName</div>
|
||||
<div className="my-auto w-1/3">Actions</div>
|
||||
</div>
|
||||
<Card
|
||||
title="File Browser"
|
||||
actions={<Button icon={<FiFilePlus />}>Upload File</Button>}
|
||||
className="flex-grow flex-col"
|
||||
>
|
||||
<div className="h-full px-4">
|
||||
<AnimatePresence>
|
||||
{(!data || data?.data.files.length === 0) && (
|
||||
@@ -55,7 +62,7 @@ export const FileBrowser = (): JSX.Element => {
|
||||
exit={{ opacity: 0 }}
|
||||
className="m-auto h-64 w-64 text-green-500"
|
||||
src={`/placeholders/${
|
||||
darkMode ? 'Files Dark.svg' : 'Files.svg'
|
||||
appState.darkMode ? 'Files Dark.svg' : 'Files.svg'
|
||||
}`}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React from 'react';
|
||||
import type React from 'react';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { FiFile, FiInfo } from 'react-icons/fi';
|
||||
import { MdSubject } from 'react-icons/md';
|
||||
@@ -14,7 +15,7 @@ import { Logs } from '@pages/Extensions/Logs';
|
||||
import { Debug } from './Debug';
|
||||
|
||||
export const Extensions = (): JSX.Element => {
|
||||
const [selectedExtension, setSelectedExtension] = React.useState<
|
||||
const [selectedExtension, setSelectedExtension] = useState<
|
||||
'info' | 'logs' | 'fileBrowser' | 'rangeTest' | 'debug'
|
||||
>('info');
|
||||
|
||||
@@ -29,6 +30,7 @@ export const Extensions = (): JSX.Element => {
|
||||
setSelectedExtension('info');
|
||||
}}
|
||||
icon={<FiInfo />}
|
||||
active={selectedExtension === 'info'}
|
||||
title="Node Info"
|
||||
/>
|
||||
<ExternalSection
|
||||
@@ -36,6 +38,7 @@ export const Extensions = (): JSX.Element => {
|
||||
setSelectedExtension('logs');
|
||||
}}
|
||||
icon={<MdSubject />}
|
||||
active={selectedExtension === 'logs'}
|
||||
title="Logs"
|
||||
/>
|
||||
<ExternalSection
|
||||
@@ -43,6 +46,7 @@ export const Extensions = (): JSX.Element => {
|
||||
setSelectedExtension('fileBrowser');
|
||||
}}
|
||||
icon={<FiFile />}
|
||||
active={selectedExtension === 'fileBrowser'}
|
||||
title="File Browser"
|
||||
/>
|
||||
<ExternalSection
|
||||
@@ -50,6 +54,7 @@ export const Extensions = (): JSX.Element => {
|
||||
setSelectedExtension('rangeTest');
|
||||
}}
|
||||
icon={<RiPinDistanceFill />}
|
||||
active={selectedExtension === 'rangeTest'}
|
||||
title="Range Test"
|
||||
/>
|
||||
<ExternalSection
|
||||
@@ -57,6 +62,7 @@ export const Extensions = (): JSX.Element => {
|
||||
setSelectedExtension('debug');
|
||||
}}
|
||||
icon={<VscDebug />}
|
||||
active={selectedExtension === 'debug'}
|
||||
title="Debug"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import React from 'react';
|
||||
import type React from 'react';
|
||||
|
||||
import { FiRefreshCw } from 'react-icons/fi';
|
||||
import JSONPretty from 'react-json-pretty';
|
||||
|
||||
import { Button } from '@app/components/generic/button/Button';
|
||||
import { Card } from '@app/components/generic/Card';
|
||||
import { Hashicon } from '@emeraldpay/hashicon-react';
|
||||
import { useAppSelector } from '@hooks/useAppSelector';
|
||||
@@ -17,8 +19,16 @@ export const Info = (): JSX.Element => {
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col gap-4 p-4 md:flex-row">
|
||||
<Card className="md:w-1/4">
|
||||
<div className="flex h-full flex-col gap-4 p-4 xl:flex-row">
|
||||
<Card
|
||||
title="Connected Node Details"
|
||||
actions={
|
||||
<Button className="truncate" icon={<FiRefreshCw />}>
|
||||
Refresh Node info
|
||||
</Button>
|
||||
}
|
||||
className="xl:w-3/5"
|
||||
>
|
||||
<div className="m-auto flex flex-col gap-2">
|
||||
<Hashicon value={hardwareInfo.myNodeNum.toString()} size={180} />
|
||||
<div className="text-center text-lg font-medium dark:text-white">
|
||||
@@ -27,7 +37,7 @@ export const Info = (): JSX.Element => {
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card className="flex-grow">
|
||||
<Card title="Debug Information" className="flex-grow">
|
||||
<JSONPretty className="overflow-y-auto" data={hardwareInfo} />
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import type React from 'react';
|
||||
|
||||
import { AnimatePresence, m } from 'framer-motion';
|
||||
import { FiArrowRight, FiPaperclip } from 'react-icons/fi';
|
||||
import { FiArrowRight, FiPaperclip, FiX } from 'react-icons/fi';
|
||||
|
||||
import { Button } from '@app/components/generic/button/Button';
|
||||
import { Card } from '@app/components/generic/Card';
|
||||
import { useAppSelector } from '@hooks/useAppSelector';
|
||||
import { Protobuf, Types } from '@meshtastic/meshtasticjs';
|
||||
|
||||
export const Logs = (): JSX.Element => {
|
||||
const logs = useAppSelector((state) => state.meshtastic.logs);
|
||||
const darkMode = useAppSelector((state) => state.app.darkMode);
|
||||
const meshtasticState = useAppSelector((state) => state.meshtastic);
|
||||
const appState = useAppSelector((state) => state.app);
|
||||
|
||||
type lookupType = { [key: number]: string };
|
||||
|
||||
@@ -49,14 +50,18 @@ export const Logs = (): JSX.Element => {
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col gap-4 p-4">
|
||||
<Card className="flex-grow overflow-y-auto">
|
||||
<Card
|
||||
title="Device Logs"
|
||||
actions={<Button icon={<FiX />}>Clear Logs</Button>}
|
||||
className="flex-grow overflow-y-auto"
|
||||
>
|
||||
<table className="table-cell flex-grow">
|
||||
<tbody
|
||||
className="
|
||||
block h-full flex-col overflow-y-auto font-mono text-xs dark:text-gray-400"
|
||||
>
|
||||
<AnimatePresence>
|
||||
{logs.length === 0 && (
|
||||
{meshtasticState.logs.length === 0 && (
|
||||
<div className="flex h-full w-full">
|
||||
<m.img
|
||||
initial={{ opacity: 0 }}
|
||||
@@ -64,13 +69,13 @@ export const Logs = (): JSX.Element => {
|
||||
exit={{ opacity: 0 }}
|
||||
className="m-auto h-64 w-64 text-green-500"
|
||||
src={`/placeholders/${
|
||||
darkMode ? 'View Code Dark.svg' : 'View Code.svg'
|
||||
appState.darkMode ? 'View Code Dark.svg' : 'View Code.svg'
|
||||
}`}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
{logs.map((log, index) => (
|
||||
{meshtasticState.logs.map((log, index) => (
|
||||
// <ContextMenu
|
||||
// key={index}
|
||||
// items={
|
||||
|
||||
Reference in New Issue
Block a user