diff --git a/src/components/device/deviceData.jsx b/src/components/device/deviceData.jsx index fee28b8..80a92e3 100644 --- a/src/components/device/deviceData.jsx +++ b/src/components/device/deviceData.jsx @@ -4,11 +4,6 @@ import React from 'react'; import { Scrollbars } from 'react-custom-scrollbars'; import DrivesTable from './tabPane'; - - - - - function DeviceLastSeenMap() { return (
@@ -21,7 +16,7 @@ function DeviceLastSeenMap() { lng: -0.142318 }} defaultZoom={17} - options={{ + options={{ styles: [ { elementType: "geometry", stylers: [{ color: "#242f3e" }] }, { elementType: "labels.text.stroke", stylers: [{ color: "#242f3e" }] }, @@ -29,7 +24,7 @@ function DeviceLastSeenMap() { { featureType: "administrative.locality", elementType: "labels.text.fill", - stylers: [{ color: "#d59563" }], + stylers: [{ color: "#d59563" }], }, { featureType: "poi", @@ -121,7 +116,7 @@ export default function SignIn(props) { }}> - + diff --git a/src/components/device/overview.jsx b/src/components/device/overview.jsx index e33a771..673878c 100644 --- a/src/components/device/overview.jsx +++ b/src/components/device/overview.jsx @@ -81,9 +81,6 @@ export default function SignIn(props) { />*/} Dongle: {device.dongle_id} - - -
{device.online ? @@ -92,9 +89,7 @@ export default function SignIn(props) { } -
-
diff --git a/src/components/device/tabPane/boot.jsx b/src/components/device/tabPane/boot.jsx index f82bb2b..19be5a6 100644 --- a/src/components/device/tabPane/boot.jsx +++ b/src/components/device/tabPane/boot.jsx @@ -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 ( {helpers.formatDate(row.date)} diff --git a/src/components/device/tabPane/console.jsx b/src/components/device/tabPane/console.jsx index f4b5b08..8d3f5e1 100644 --- a/src/components/device/tabPane/console.jsx +++ b/src/components/device/tabPane/console.jsx @@ -1,3 +1,4 @@ +/* eslint-disable */ import React from 'react'; import Box from '@mui/material/Box'; import Paper from '@mui/material/Paper'; diff --git a/src/components/device/tabPane/crash.jsx b/src/components/device/tabPane/crash.jsx index 2823073..1028c07 100644 --- a/src/components/device/tabPane/crash.jsx +++ b/src/components/device/tabPane/crash.jsx @@ -25,7 +25,7 @@ import * as helpers from "./../../../controllers/helpers" function buildContent(row) { return ( - @@ -101,7 +101,6 @@ export default function EnhancedTable(props) { - {state.dongles[props.dongleId].crash ? state.dongles[props.dongleId].crash.length > 0 ? state.dongles[props.dongleId].crash.map(buildContent) :

No drives

: diff --git a/src/components/device/tabPane/drives.jsx b/src/components/device/tabPane/drives.jsx index a5dd6d3..d762b72 100644 --- a/src/components/device/tabPane/drives.jsx +++ b/src/components/device/tabPane/drives.jsx @@ -18,10 +18,6 @@ import { context as SnackbarContext } from "./../../../context/toast"; 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) @@ -42,7 +38,7 @@ export default function EnhancedTable(props) { - + scrollButtons="auto"> @@ -55,16 +55,16 @@ export default function SignIn(props) { - + - + - + - + @@ -72,7 +72,7 @@ export default function SignIn(props) { { - + } ); diff --git a/src/components/device/tabPane/view_drive.jsx b/src/components/device/tabPane/view_drive.jsx index 16d085c..8ccda54 100644 --- a/src/components/device/tabPane/view_drive.jsx +++ b/src/components/device/tabPane/view_drive.jsx @@ -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; @@ -46,12 +46,12 @@ export default function EnhancedTable(props) { } else { setState({ ...state, loading: false, firstReqSent: true, segment: res.data }) } - + }) } -// test + // test @@ -72,14 +72,14 @@ export default function EnhancedTable(props) { try { metadata = JSON.parse(drive.metadata); - + if (metadata['InitData']) { version = metadata['InitData']['Version'] || "Unknown"; gitRemote = metadata['InitData']['GitRemote'] || "Unknown"; gitBranch = metadata['InitData']['GitBranch'] || "Unknown"; gitCommit = metadata['InitData']['GitCommit'] || "Unknown"; } - + if (metadata['CarParams']) { if (metadata['CarParams']['CarName'] !== undefined) vehicle += (metadata['CarParams']['CarName'].toUpperCase()) + " "; @@ -151,25 +151,25 @@ export default function EnhancedTable(props) { { directorySegments ? Object.keys(directorySegments).map((key, index) => { - - return Object.keys(directorySegments[key]).map((key1, index1) => ( - - {key} - {directorySegments[key][key1].name} - {Math.round(directorySegments[key][key1].fileSize / 1024) + ' MiB'} - - - window.open(directorySegments[key][key1].url, "_blank")}> - - - - + return Object.keys(directorySegments[key]).map((key1, index1) => ( + + {key} + {directorySegments[key][key1].name} + {Math.round(directorySegments[key][key1].fileSize / 1024) + ' MiB'} + + + + window.open(directorySegments[key][key1].url, "_blank")}> + + + + - - )) - + + )) + }) : null } diff --git a/src/components/views/useradmin.jsx b/src/components/views/useradmin.jsx index d27bc9c..5dafbc6 100644 --- a/src/components/views/useradmin.jsx +++ b/src/components/views/useradmin.jsx @@ -10,7 +10,7 @@ import DeviceOverview from "./../device/overview"; - + export default function SignIn() { @@ -27,8 +27,8 @@ export default function SignIn() {
- { deviceState ? Object.keys(deviceState.dongles).map(key => ) :

no

} - + {deviceState ? Object.keys(deviceState.dongles).map(key => ) :

no

} +
@@ -41,9 +41,9 @@ export default function SignIn() { - { deviceState.dongles['53331425'] ? :

no

} + {deviceState.dongles['53331425'] ? :

no

} + -
diff --git a/src/components/widgets/globalSnack.jsx b/src/components/widgets/globalSnack.jsx index 65c963d..b13770a 100644 --- a/src/components/widgets/globalSnack.jsx +++ b/src/components/widgets/globalSnack.jsx @@ -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 ( @@ -22,8 +22,7 @@ export default function Toast(props) { autoHideDuration={6000} onClose={handleClose} message={state.msg} - severity="success" + severity="success" /> ); } - \ No newline at end of file diff --git a/src/context/devices/index.js b/src/context/devices/index.js index e680f9b..7ec1b83 100644 --- a/src/context/devices/index.js +++ b/src/context/devices/index.js @@ -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; - - - } }; diff --git a/src/context/toast/reducer.js b/src/context/toast/reducer.js index f51a9a7..8f35308 100644 --- a/src/context/toast/reducer.js +++ b/src/context/toast/reducer.js @@ -1,5 +1,3 @@ - - const Reducer = (state, action) => { switch (action.type) { case 'NEW_TOAST': @@ -13,7 +11,7 @@ const Reducer = (state, action) => { ...state, open: false } - + default: return state; } diff --git a/src/context/users/reducer.js b/src/context/users/reducer.js index faded45..e465bce 100644 --- a/src/context/users/reducer.js +++ b/src/context/users/reducer.js @@ -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 - } - - default: - return state - } + return { + ...state, + active: !state.active + } + + default: + return state } - - export const initialState = { - signedIn: false, - user: { - id: null, - username: null, - JWT: null, - }, - } \ No newline at end of file +} + +export const initialState = { + signedIn: false, + user: { + id: null, + username: null, + JWT: null, + }, +} \ No newline at end of file diff --git a/src/controllers/devices.js b/src/controllers/devices.js index 7f589d6..7f54770 100644 --- a/src/controllers/devices.js +++ b/src/controllers/devices.js @@ -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 = {} @@ -49,4 +47,4 @@ export async function getAllDevices() { } return null; -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/controllers/helpers.js b/src/controllers/helpers.js index 668a362..b8b557d 100644 --- a/src/controllers/helpers.js +++ b/src/controllers/helpers.js @@ -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; - - 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; - } \ No newline at end of file +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; +} \ No newline at end of file