chore: remove old code pt 2
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
.DivToScroll{
|
||||
background-color: color-mix(in srgb, canvas, #000 5%);
|
||||
border: 1px solid color-mix(in srgb, canvas, #000 15%);
|
||||
border-radius: 4px 0 4px 0;
|
||||
color: #3B3C3E;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
left: -1px;
|
||||
padding: 10px 7px 5px;
|
||||
}
|
||||
|
||||
.DivWithScroll{
|
||||
height:50vh;
|
||||
width:100vh;
|
||||
overflow:scroll;
|
||||
overflow-x:hidden;
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
import { useState } from 'react';
|
||||
import { DATA } from "../../assets/data";
|
||||
import styles from './Logging.module.css';
|
||||
|
||||
|
||||
// const dataType = DATA as { id: string; level: "debug"|"info"|"warn"|"error"; msg: string; timestamp?: string };
|
||||
type Level = "debug" | "info" | "warn" | "error";
|
||||
|
||||
// make optional fields optional
|
||||
type LogEntry = {
|
||||
id: string;
|
||||
level: Level;
|
||||
timestamp?: string;
|
||||
msg?: string;
|
||||
type?: "speech" | "sensor" | "system" | string;
|
||||
|
||||
};
|
||||
|
||||
function getLevelColor(level: Level) {
|
||||
switch (level) {
|
||||
case "debug":
|
||||
return "gray";
|
||||
case "info":
|
||||
return "blue";
|
||||
case "warn":
|
||||
return "red";
|
||||
case "error":
|
||||
return "red";
|
||||
default:
|
||||
return "black";
|
||||
}
|
||||
}
|
||||
|
||||
function Logging() {
|
||||
const [logs, setLogs] = useState<LogEntry[]>([]);
|
||||
|
||||
const logDiv = (
|
||||
<div className={styles.DivToScroll}>
|
||||
<div className={styles.DivWithScroll}>
|
||||
{logs.map((log) => (
|
||||
<div
|
||||
key={log.id}
|
||||
style={{
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
padding: "4px 0",
|
||||
}}
|
||||
>
|
||||
<span style={{ color: "darkgrey", minWidth: 120, textAlign: "left" }}>
|
||||
[{log.timestamp}]
|
||||
</span>
|
||||
<span style={{ flex: 1, textAlign: "center" }}>
|
||||
{log.msg ? log.msg : "No message"}
|
||||
</span>
|
||||
<span style={{ color: getLevelColor(log.level), minWidth: 80, textAlign: "right" }}>
|
||||
({log.level})
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
return (
|
||||
<>
|
||||
<h1>Log Screen</h1>
|
||||
{ logDiv }
|
||||
<div className="card">
|
||||
<button onClick={() => setLogs(DATA)}>
|
||||
Load sample logs
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default Logging
|
||||
Reference in New Issue
Block a user