8000 Serial feature by mjkl-gh · Pull Request #309 · rjwats/esp8266-react · GitHub
[go: up one dir, main page]

Skip to content

Serial feature #309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4b372f3
Add Streamserver
mjkl-gh Jan 2, 2021
21e092c
add Streamserver to main
mjkl-gh Jan 2, 2021
f6fd0bd
Add EventConsole
mjkl-gh Dec 25, 2021
b8145c6
Merge branch 'master' of https://github.com/rjwats/esp8266-react into…
mjkl-gh Dec 25, 2021
5e3b6e2
Merge branch 'serial' of https://github.com/mjkl-gh/esp-dsmr into ser…
mjkl-gh Dec 25, 2021
d99de58
Add SerialService
mjkl-gh Feb 7, 2021
ebbf9f4
Comment out LogEventController
mjkl-gh Dec 25, 2021
5a69d33
Merge ser2net
mjkl-gh Dec 25, 2021
39a8d2d
Rename ser2net to serial
mjkl-gh Dec 25, 2021
c72cbc0
add baud to SerialStatus
mjkl-gh Feb 7, 2021
dc7b28c
WIP Serial page
mjkl-gh Feb 7, 2021
2b3996a
Merge fixes from main branch
mjkl-gh Dec 25, 2021
0c9d454
Merge remote-tracking branch 'refs/remotes/Upstream/master'
mjkl-gh Dec 25, 2021
9249d1e
WIP update serial feature to new format
mjkl-gh Jun 6, 2022
5888bdc
Merge remote-tracking branch 'Upstream/master' into SerialFeature-Fix
mjkl-gh Jun 6, 2022
cddf41e
fix Tab moved to @mui/material from @material-ui/core
mjkl-gh Jun 6, 2022
11fb837
styleguide fixes
mjkl-gh Jun 8, 2022
6725888
Fix typo in Serial status title
mjkl-gh Jun 16, 2022
70ec5fc
Set sensible defaults for serial pins for both platforms
mjkl-gh Jun 16, 2022
8710636
WIP logevent console
mjkl-gh Jun 16, 2022
a7148b4
Fix endpoint.ts and env.ts names
mjkl-gh Jun 16, 2022
0760a5e
Fix double dependency
mjkl-gh Jun 16, 2022
956aacc
Simplify serial feature
mjkl-gh Jun 19, 2022
436a00e
add numbervalue to serialsettingsform
mjkl-gh Jun 19, 2022
44b5c7e
Fix settings forms
mjkl-gh Jun 20, 2022
35f37f3
Remove unnecessary this
mjkl-gh Jun 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP logevent console
  • Loading branch information
mjkl-gh committed Jun 16, 2022
commit 87106367d6e47dcf02b44098b1d84fc5fb0db1f9
4 changes: 4 additions & 0 deletions interface/src/components/layout/LayoutMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import DeviceHubIcon from '@mui/icons-material/DeviceHub';
import SettingsIcon from '@mui/icons-material/Settings';
import LockIcon from '@mui/icons-material/Lock';
import WifiIcon from '@mui/icons-material/Wifi';
import CableIcon from '@mui/icons-material/Cable';

import { FeaturesContext } from '../../contexts/features';
import ProjectMenu from '../../project/ProjectMenu';
Expand Down Expand Up @@ -35,6 +36,9 @@ const LayoutMenu: FC = () => {
{features.mqtt && (
<LayoutMenuItem icon={DeviceHubIcon} label="MQTT" to="/mqtt" />
)}
{features.serial && (
<LayoutMenuItem icon={CableIcon} label="Serial" to="/serial" />
)}
{features.security && (
<LayoutMenuItem icon={LockIcon} label="Security" to="/security" disabled={!authenticatedContext.me.admin} />
)}
Expand Down
102 changes: 52 additions & 50 deletions interface/src/framework/serial/LogEventConsole.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React, { FC } from 'react';

import { LogEvent, LogLevel } from '../../types';
import { Theme, makeStyles, Box } from '@mui/material';
import { Box } from '@mui/system';
import { useWindowSize } from '../../components';
import { formatIsoDateTimeToHr } from "../../utils";

import { useTheme } from "@mui/material/styles"

interface LogEventConsoleProps {
events: LogEvent[];
}
Expand All @@ -16,62 +18,24 @@ interface Offsets {
const topOffset = () => document.getElementById('serial-tabs')?.getBoundingClientRect().bottom || 0;
const leftOffset = () => document.getElementById('serial-tabs')?.getBoundingClientRect().left || 0;

const useStyles = makeStyles((theme: Theme) => ({
console: {
padding: theme.spacing(2),
position: "absolute",
left: (offsets: Offsets) => offsets.leftOffset(),
right: 0,
top: (offsets: Offsets) => offsets.topOffset(),
bottom: 0,
backgroundColor: "black",
overflow: "auto"
},
entry: {
color: "#bbbbbb",
fontFamily: "Courier New, monospace",
fontSize: "14px",
letterSpacing: "normal",
whiteSpace: "nowrap"
},
file: {
color: "#00ffff"
},
debug: {
color: "#0000ff"
},
info: {
color: "#00ff00"
},
warning: {
color: "#ffff00"
},
error: {
color: "#ff0000"
},
unknown: {
color: "#ffffff"
}
}));


const LogEventConsole: FC<LogEventConsoleProps> = (props) => {
useWindowSize();
const classes = useStyles({ topOffset, leftOffset });
const { events } = props;
const theme = useTheme()

const styleLevel = (level: LogLevel) => {
switch (level) {
case LogLevel.DEBUG:
return classes.debug;
return styles.debug;
case LogLevel.INFO:
return classes.info;
return styles.info;
case LogLevel.WARNING:
return classes.warning;
return styles.warning;
case LogLevel.ERROR:
return classes.error;
return styles.error;
default:
return classes.unknown;
return styles.unknown;
}
}

Expand All @@ -95,13 +59,51 @@ const LogEventConsole: FC<LogEventConsoleProps> = (props) => {
return label.padStart(7, '\xa0');
}

const styles = {
console: {
padding: theme.spacing(2),
position: "absolute",
//left: (offsets: Offsets) => offsets.leftOffset(),
right: 0,
//top: (offsets: Offsets) => offsets.topOffset(),
bottom: 0,
backgroundColor: "black",
overflow: "auto"
},
entry: {
color: "#bbbbbb",
fontFamily: "Courier New, monospace",
fontSize: "14px",
letterSpacing: "normal",
whiteSpace: "nowrap"
},
file: {
color: "#00ffff"
},
debug: {
color: "#0000ff"
},
info: {
color: "#00ff00"
},
warning: {
color: "#ffff00"
},
error: {
color: "#ff0000"
},
unknown: {
color: "#ffffff"
}
};

return (
<Box className={classes.console}>
<Box sx={styles.console}>
{events.map(e => (
<div className={classes.entry}>
<span>{formatIsoDateTimeToHr(e.time)} </span>
<span>{e.message}</span>
</div>
<Box sx={styles.entry}>
<Box component="span">{formatIsoDateTimeToHr(e.time)} </Box>
<Box component="span">{e.message}</Box>
</Box>
))}
</Box>
);
Expand Down
2 changes: 1 addition & 1 deletion interface/src/framework/serial/LogEventController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { withSnackbar, WithSnackbarProps } from 'notistack';

import { addAccessTokenParameter } from '../../api/authentication';
import { LogEvent } from '../../types';
import { WEB_SOCKET_ROOT } from '../../api/env';
import { WEB_SOCKET_ROOT } from '../../api/endpoints';
import LogEventConsole from './LogEventConsole';

const LOG_EVENT_WEB_SOCKET_URL = WEB_SOCKET_ROOT + "serial";
Expand Down
10 changes: 4 additions & 6 deletions interface/src/framework/serial/Serial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { AuthenticatedContext } from '../../contexts/authentication';

import SerialStatusForm from './SerialStatusForm';
import SerialSettingsForm from './SerialSettingsForm';
import LogEventConsole from './LogEventConsole';

const Serial: FC= () => {
useLayoutTitle("Serial");
Expand All @@ -20,13 +19,12 @@ const Serial: FC= () => {
<>
<RouterTabs value={routerTab}>
<Tab value="status" label="Serial Status" />
<Tab value="log" label="Remote Log" />
{/* <Tab value="log" label="Remote Log" /> */}
<Tab value="settings" label="Serial Settings" disabled={!authenticatedContext.me.admin} />
</RouterTabs>
<Routes>
<Route path="status" element={SerialStatusForm} />
<Route path="log" element={LogEventConsole} />
<Route
<Route path="status" element={<SerialStatusForm />} />
<Route
path="settings"
element={
<RequireAdmin>
Expand All @@ -38,6 +36,6 @@ const Serial: FC= () => {
</Routes>
</>
);
}
};

export default Serial;
0