v1.0.2 part 1

This commit is contained in:
Olivier Gagnon
2021-11-19 15:44:12 -05:00
parent a4a931dad7
commit b80d12b9f8
10 changed files with 179 additions and 14 deletions
+34 -2
View File
@@ -14,6 +14,7 @@ import ArrowForwardIosIcon from "@mui/icons-material/ArrowForwardIos";
import { workerScripts } from "../../Netscript/WorkerScripts";
import { startWorkerScript } from "../../NetscriptWorker";
import { GetServer } from "../../Server/AllServers";
import { Theme } from "@mui/material";
let layerCounter = 0;
@@ -65,7 +66,7 @@ interface IProps {
onClose: () => void;
}
const useStyles = makeStyles(() =>
const useStyles = makeStyles((theme: Theme) =>
createStyles({
logs: {
overflowY: "scroll",
@@ -74,6 +75,21 @@ const useStyles = makeStyles(() =>
display: "flex",
flexDirection: "column-reverse",
},
success: {
color: theme.colors.success,
},
error: {
color: theme.palette.error.main,
},
primary: {
color: theme.palette.primary.main,
},
info: {
color: theme.palette.info.main,
},
warning: {
color: theme.palette.warning.main,
},
}),
);
@@ -117,6 +133,22 @@ function LogWindow(props: IProps): React.ReactElement {
return t.slice(0, maxLength - 3) + "...";
}
function lineClass(s: string): string {
if (s.startsWith("ERROR") || s.startsWith("FAIL")) {
return classes.error;
}
if (s.startsWith("SUCCESS")) {
return classes.success;
}
if (s.startsWith("WARN")) {
return classes.warning;
}
if (s.startsWith("INFO")) {
return classes.info;
}
return classes.primary;
}
return (
<Draggable handle=".drag">
<Paper
@@ -162,7 +194,7 @@ function LogWindow(props: IProps): React.ReactElement {
<Box>
{props.script.logs.map(
(line: string, i: number): JSX.Element => (
<Typography key={i}>
<Typography key={i} className={lineClass(line)}>
{line}
<br />
</Typography>