Cheering up linter

main
AdamSBlack 2022-01-07 17:59:15 +00:00
parent ad5bf47515
commit 1528b73832
No known key found for this signature in database
GPG Key ID: E66E51A97D150E28
15 changed files with 89 additions and 115 deletions

View File

@ -4,11 +4,6 @@ import React from 'react';
import { Scrollbars } from 'react-custom-scrollbars';
import DrivesTable from './tabPane';
function DeviceLastSeenMap() {
return (
<div style={{ height: "500px", width: 'calc(100%)' }}>

View File

@ -81,9 +81,6 @@ export default function SignIn(props) {
/>*/}
<Typography variant="body2" align={"left"} gutterBottom>Dongle: {device.dongle_id}</Typography>
<div>
{device.online ?
@ -92,9 +89,7 @@ export default function SignIn(props) {
}
<Chip style={{ background: '#004d40', ...stylezz }} label="Active" size="small" variant="outlined" />
</div>
</Grid>
</Grid>
</ButtonBase>

View File

@ -35,7 +35,6 @@ export default function EnhancedTable(props) {
const [state, dispatch] = useContext(DeviceContext)
const [, notifDispatch] = useContext(SnackbarContext)
>>>>>>> daa27768571b3535403613585ca93a3532ea51d2
useEffect(() => {
deviceController.getBootlogs(props.dongleId).then((res) => {
@ -70,7 +69,6 @@ export default function EnhancedTable(props) {
{/* if you don't need to support IE11, you can replace the `stableSort` call with:
rows.slice().sort(getComparator(order, orderBy)) */}
{state.dongles[props.dongleId].boot ? state.dongles[props.dongleId].boot.map((row) => {
return (
<TableRow hover>
<TableCell >{helpers.formatDate(row.date)}</TableCell>

View File

@ -1,3 +1,4 @@
/* eslint-disable */
import React from 'react';
import Box from '@mui/material/Box';
import Paper from '@mui/material/Paper';

View File

@ -101,7 +101,6 @@ export default function EnhancedTable(props) {
</TableHead>
<TableBody>
{state.dongles[props.dongleId].crash ?
state.dongles[props.dongleId].crash.length > 0 ? state.dongles[props.dongleId].crash.map(buildContent) : <p> No drives </p>
:

View File

@ -19,10 +19,6 @@ import * as deviceController from "./../../../controllers/devices";
import * as helpers from "./../../../controllers/helpers"
import ViewDrive from "./view_drive"
export default function EnhancedTable(props) {
const [deviceState, dispatch] = useContext(DeviceContext)
const [, notifDispatch] = useContext(SnackbarContext)

View File

@ -46,7 +46,7 @@ export default function SignIn(props) {
<Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
<Tabs value={value} onChange={handleChange} aria-label="basic tabs example" variant="scrollable"
scrollButtons="auto">
scrollButtons="auto">
<Tab label="Device" />
<Tab label="Drives" />
<Tab label="Crashes" />
@ -55,16 +55,16 @@ export default function SignIn(props) {
</Tabs>
</Box>
<TabPanel value={value} index={0}>
<DeviceInfo dongleId={props.dongleId}/>
<DeviceInfo dongleId={props.dongleId} />
</TabPanel>
<TabPanel value={value} index={1}>
<DrivesLogTable dongleId={props.dongleId}/>
<DrivesLogTable dongleId={props.dongleId} />
</TabPanel>
<TabPanel value={value} index={2}>
<CrashLogsTable dongleId={props.dongleId}/>
<CrashLogsTable dongleId={props.dongleId} />
</TabPanel>
<TabPanel value={value} index={3}>
<BootLogsTable dongleId={props.dongleId}/>
<BootLogsTable dongleId={props.dongleId} />
</TabPanel>
<TabPanel value={value} index={4}>
<Console dongleId={props.dongleId} />

View File

@ -9,7 +9,7 @@ import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import Tooltip from '@mui/material/Tooltip';
import React, { useContext, useState } from 'react';
import React, { useContext, useState } from 'react';
import { context as DeviceContext } from "./../../../context/devices";
import * as deviceController from "./../../../controllers/devices";
import Typography from "@mui/material/Typography"
@ -23,11 +23,11 @@ export default function EnhancedTable(props) {
const [state, setState] = useState({ loading: true, firstReqSent: false, segment: null, drive: null })
if (state.drive === null) {
setState({...state, drive: props.drive})
setState({ ...state, drive: props.drive })
}
if (props.drive !== state.drive) {
setState({...state, loading: true, firstReqSent: false, segment: null, drive: props.drive})
setState({ ...state, loading: true, firstReqSent: false, segment: null, drive: props.drive })
}
const dongle_id = props.dongleId;
@ -51,7 +51,7 @@ export default function EnhancedTable(props) {
}
// test
// test
@ -152,23 +152,23 @@ export default function EnhancedTable(props) {
directorySegments ? Object.keys(directorySegments).map((key, index) => {
return Object.keys(directorySegments[key]).map((key1, index1) => (
<TableRow hover>
<TableCell >{key}</TableCell>
<TableCell >{directorySegments[key][key1].name}</TableCell>
<TableCell>{Math.round(directorySegments[key][key1].fileSize / 1024) + ' MiB'}</TableCell>
return Object.keys(directorySegments[key]).map((key1, index1) => (
<TableRow hover>
<TableCell >{key}</TableCell>
<TableCell >{directorySegments[key][key1].name}</TableCell>
<TableCell>{Math.round(directorySegments[key][key1].fileSize / 1024) + ' MiB'}</TableCell>
<TableCell>
<Tooltip title="Open in new window">
<IconButton size="small" onClick={() => window.open(directorySegments[key][key1].url, "_blank")}>
<OpenInNewIcon fontSize="inherit" />
</IconButton>
</Tooltip>
</TableCell>
<TableCell>
<Tooltip title="Open in new window">
<IconButton size="small" onClick={() => window.open(directorySegments[key][key1].url, "_blank")}>
<OpenInNewIcon fontSize="inherit" />
</IconButton>
</Tooltip>
</TableCell>
</TableRow>
))
</TableRow>
))
}) : null

View File

@ -27,7 +27,7 @@ export default function SignIn() {
<Paper style={{ minHeight: "100%", maxHeight: "100%", margin: "0" }}>
<Scrollbars autoHeight={true} autoHeightMin="calc(100vh - 14px)" autoHeightMax="calc(100% - 14px)">
<div style={{ padding: '5px' }}>
{ deviceState ? Object.keys(deviceState.dongles).map(key => <DeviceOverview device={deviceState.dongles[key]}/>) : <p>no</p> }
{deviceState ? Object.keys(deviceState.dongles).map(key => <DeviceOverview device={deviceState.dongles[key]} />) : <p>no</p>}
</div>
@ -41,7 +41,7 @@ export default function SignIn() {
</Grid>
<Grid item xs={12} md={8} lg={9} sm={6} xl={10}>
{ deviceState.dongles['53331425'] ? <DeviceData device={deviceState.dongles['53331425']} /> : <p>no</p> }
{deviceState.dongles['53331425'] ? <DeviceData device={deviceState.dongles['53331425']} /> : <p>no</p>}
</Grid>

View File

@ -8,12 +8,12 @@ import { context as DeviceContext } from "./../../context/toast";
export default function Toast(props) {
const [ state, dispatch ] = useContext(DeviceContext)
const [state, dispatch] = useContext(DeviceContext)
const handleClose = () => {
dispatch({type: 'CLOSE_TOAST'})
dispatch({ type: 'CLOSE_TOAST' })
};
return (
@ -26,4 +26,3 @@ export default function Toast(props) {
/>
);
}

View File

@ -25,8 +25,6 @@ function process(state, action) {
}
export const Reducer = (state, action) => {
console.log("input", state, action)
switch (action.type) {
@ -83,9 +81,6 @@ export const Reducer = (state, action) => {
default:
return state;
}
};

View File

@ -1,5 +1,3 @@
const Reducer = (state, action) => {
switch (action.type) {
case 'NEW_TOAST':

View File

@ -1,22 +1,22 @@
export const reducer = (state, action) => {
switch (action.type) {
case "sign_out":
switch (action.type) {
case "sign_out":
return {
...state,
active: !state.active
}
return {
...state,
active: !state.active
}
default:
return state
}
default:
return state
}
}
export const initialState = {
signedIn: false,
user: {
id: null,
username: null,
JWT: null,
},
}
export const initialState = {
signedIn: false,
user: {
id: null,
username: null,
JWT: null,
},
}

View File

@ -1,29 +1,27 @@
import axios from "axios";
export async function getDrives(dongleId) {
const req = await axios.get(`http://localhost/retropilot/0/device/${dongleId}/drives/false`, {withCredentials: true});
const req = await axios.get(`http://localhost/retropilot/0/device/${dongleId}/drives/false`, { withCredentials: true });
return req.data
}
export async function getBootlogs(dongleId) {
const req = await axios.get(`http://localhost/retropilot/0/device/${dongleId}/bootlogs`, {withCredentials: true});
const req = await axios.get(`http://localhost/retropilot/0/device/${dongleId}/bootlogs`, { withCredentials: true });
return req.data
}
export async function getCrashlogs(dongleId) {
const req = await axios.get(`http://localhost/retropilot/0/device/${dongleId}/crashlogs`, {withCredentials: true});
const req = await axios.get(`http://localhost/retropilot/0/device/${dongleId}/crashlogs`, { withCredentials: true });
return req.data
}
export async function getDriveSegments(dongleId, drive_identifier) {
const req = await axios.get(`http://localhost/retropilot/0/device/${dongleId}/drives/${drive_identifier}/segment`, {withCredentials: true});
const req = await axios.get(`http://localhost/retropilot/0/device/${dongleId}/drives/${drive_identifier}/segment`, { withCredentials: true });
return req.data
}
export async function getAllDevices() {
const req = await axios.get(`http://localhost/retropilot/0/devices`, {withCredentials: true});
const req = await axios.get(`http://localhost/retropilot/0/devices`, { withCredentials: true });
const responseData = req.data
let dongles = {}

View File

@ -2,23 +2,23 @@
export function formatDate(timestampMs) {
return new Date(timestampMs).toISOString().replace(/T/, ' ').replace(/\..+/, '');
}
return new Date(timestampMs).toISOString().replace(/T/, ' ').replace(/\..+/, '');
}
export function formatDuration(durationSeconds) {
durationSeconds = Math.round(durationSeconds);
const secs = durationSeconds % 60;
let mins = Math.floor(durationSeconds / 60);
let hours = Math.floor(mins / 60);
mins = mins % 60;
const days = Math.floor(hours / 24);
hours = hours % 24;
export function formatDuration(durationSeconds) {
durationSeconds = Math.round(durationSeconds);
const secs = durationSeconds % 60;
let mins = Math.floor(durationSeconds / 60);
let hours = Math.floor(mins / 60);
mins = mins % 60;
const days = Math.floor(hours / 24);
hours = hours % 24;
let response = '';
if (days > 0) response += days + 'd ';
if (hours > 0 || days > 0) response += hours + 'h ';
if (hours > 0 || days > 0 || mins > 0) response += mins + 'm ';
response += secs + 's';
return response;
}
let response = '';
if (days > 0) response += days + 'd ';
if (hours > 0 || days > 0) response += hours + 'h ';
if (hours > 0 || days > 0 || mins > 0) response += mins + 'm ';
response += secs + 's';
return response;
}