-
Notifications
You must be signed in to change notification settings - Fork 0
/state and /history pages #1
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
Changes from all commits
26ed331
8d8d3c7
351dd71
be6101b
5c657b1
653325e
571c1fd
767ef97
d66db84
ea63719
d11f1ad
20facb6
8ec6b02
130dd99
4120f1f
4b675fc
bb6901b
5be7e7a
9d40aeb
963619d
cc1d0a9
73366a2
d589af7
3d37987
a803331
460c1c1
a3a87ae
9c45f6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
DATABASE_URL="file:./evolver.db" | ||
SESSION_SECRET="evolver4ever" | ||
DEFAULT_DEVICE_PORT="8080" | ||
EXCLUDED_PROPERTIES="name,vial" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import { useRouteLoaderData } from "@remix-run/react"; | ||
import clsx from "clsx"; | ||
import Ajv from "ajv"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ripped out AJV. Not going to do much / any client side validation as long as the Evolver-NG continues to respond with sane validation error messaging. |
||
import { | ||
FilterFunction, | ||
JsonData, | ||
|
@@ -11,25 +10,21 @@ import { | |
import { loader as rootLoader } from "~/root"; | ||
import { checkType } from "~/utils/checkType"; | ||
import { EvolverConfigWithoutDefaults } from "client"; | ||
import { SomeJSONSchema } from "ajv/dist/types/json-schema"; | ||
|
||
export function EditJson({ | ||
data, | ||
mode, | ||
schema, | ||
setData, | ||
}: { | ||
schema: SomeJSONSchema; | ||
data: EvolverConfigWithoutDefaults; | ||
mode: "edit" | "view"; | ||
setData: (arg0: EvolverConfigWithoutDefaults) => void; | ||
}) { | ||
const { theme } = useRouteLoaderData<typeof rootLoader>("root") ?? { | ||
theme: "dark", | ||
}; | ||
|
||
const editorTheme = theme === "dark" ? "githubDark" : "githubLight"; | ||
const ajv = new Ajv(); | ||
const validate = ajv.compile(schema); | ||
|
||
const customizeText = ({ key, value }: NodeData) => { | ||
switch (key) { | ||
|
@@ -146,7 +141,7 @@ export function EditJson({ | |
} | ||
if (mode === "edit") { | ||
if (level === 0) { | ||
return true; | ||
return false; | ||
} | ||
switch (key) { | ||
case "vials": | ||
|
@@ -211,20 +206,6 @@ export function EditJson({ | |
restrictEdit={restrictEdit} | ||
restrictAdd={restrictAdd} | ||
restrictDelete={restrictDelete} | ||
onUpdate={({ newData }) => { | ||
const valid = validate(newData); | ||
if (!valid) { | ||
const errorMessage = validate.errors | ||
?.map( | ||
(error) => | ||
`${error.instancePath}${error.instancePath ? ": " : ""}${error.message}`, | ||
) | ||
.join("\n"); | ||
// This string is returned to and displayed in json-edit-react UI | ||
return errorMessage; | ||
} | ||
// data is valid, do nothing | ||
}} | ||
setData={(data: JsonData) => | ||
setData(data as EvolverConfigWithoutDefaults) | ||
} | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { Link } from "@remix-run/react"; | ||
import { EvolverConfigWithoutDefaults } from "client"; | ||
import clsx from "clsx"; | ||
|
||
export function HardwareTable({ | ||
evolverConfig, | ||
id, | ||
hardwareName, | ||
queryParams, | ||
}: { | ||
evolverConfig: EvolverConfigWithoutDefaults; | ||
id: string; | ||
hardwareName: string; | ||
queryParams: URLSearchParams; | ||
}) { | ||
let currentVials: string[] = []; | ||
let allVials = false; | ||
if (queryParams.has("vials")) { | ||
currentVials = queryParams.get("vials")?.split(","); | ||
} else { | ||
allVials = true; | ||
} | ||
const evolverHardware = evolverConfig.hardware; | ||
|
||
const TableRows = Object.keys(evolverHardware).map((key) => { | ||
const { | ||
config: { vials }, | ||
} = evolverHardware[key]; | ||
|
||
const vialsWithLinks = vials.map((vial) => { | ||
const linkTo = `/devices/${id}/hardware/${key}/history?vials=${vial}`; | ||
const activeVial = | ||
currentVials.includes(vial.toString()) && hardwareName === key; | ||
const vialButtons = ( | ||
<Link | ||
key={vial} | ||
className={clsx( | ||
"btn", | ||
"btn-xs", | ||
"btn-outline", | ||
activeVial && "btn-active", | ||
)} | ||
to={linkTo} | ||
> | ||
{vial} | ||
</Link> | ||
); | ||
|
||
return vialButtons; | ||
}); | ||
const allButton = ( | ||
<Link | ||
className={clsx( | ||
"btn", | ||
"btn-xs", | ||
"btn-outline", | ||
allVials && key === hardwareName && "btn-active", | ||
)} | ||
key={"all"} | ||
to={`/devices/${id}/hardware/${key}/history`} | ||
> | ||
{" "} | ||
all | ||
</Link> | ||
); | ||
|
||
return ( | ||
<tr key={key} className={clsx(hardwareName === key && "bg-base-300")}> | ||
<td>{key}</td> | ||
<td className="flex gap-2"> | ||
{vialsWithLinks} | ||
{allButton} | ||
</td> | ||
</tr> | ||
); | ||
}); | ||
|
||
return ( | ||
<table className="table"> | ||
<thead> | ||
<tr> | ||
<th>name</th> | ||
<th>vials</th> | ||
</tr> | ||
</thead> | ||
<tbody>{TableRows}</tbody> | ||
</table> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { | ||
LineChart, | ||
Line, | ||
XAxis, | ||
YAxis, | ||
CartesianGrid, | ||
Tooltip, | ||
Legend, | ||
ResponsiveContainer, | ||
} from "recharts"; | ||
import { vialColors } from "~/utils/chart/colors"; | ||
|
||
const processData = (data, vials, property) => { | ||
return data.map((entry) => { | ||
const processedEntry: { [key: string]: string } = { | ||
timestamp: new Date(entry.timestamp * 1000).toLocaleTimeString(), // Convert timestamp to readable time | ||
}; | ||
|
||
vials.forEach((vial) => { | ||
processedEntry[`vial_${vial}`] = entry.data[vial]?.[property]; | ||
}); | ||
|
||
return processedEntry; | ||
}); | ||
}; | ||
|
||
export const HardwareLineChart = ({ vials, rawData, property = "raw" }) => { | ||
const formattedData = processData(rawData, vials, property); | ||
|
||
return ( | ||
<div> | ||
<div className="divider"></div> | ||
<div>property: </div> | ||
<div className="stat-value font-mono">{property}</div> | ||
<div className="divider"></div> | ||
<ResponsiveContainer width="100%" height={400}> | ||
<LineChart data={formattedData}> | ||
<CartesianGrid strokeDasharray="3 3" /> | ||
<XAxis dataKey="timestamp" /> | ||
<YAxis /> | ||
<Tooltip /> | ||
<Legend /> | ||
{vials.map((vial: number, index: number) => ( | ||
<Line | ||
key={vial} | ||
type="monotone" | ||
dataKey={`vial_${vial}`} | ||
stroke={vialColors[index % vialColors.length]} | ||
name={`Vial ${vial}`} | ||
/> | ||
))} | ||
</LineChart> | ||
</ResponsiveContainer> | ||
</div> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,11 @@ import clsx from "clsx"; | |
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just style tweaks in this file. |
||
export default function Navbar({ pathname = "" as string }): JSX.Element { | ||
return ( | ||
<div className="mb-8"> | ||
<div className="px-4 mx-auto max-w-6xl flex flex-wrap justify-between gap-10 min-h-16 items-center"> | ||
<div className=""> | ||
<div className="mx-auto max-w-6xl flex flex-wrap justify-between gap-10 min-h-16 items-center"> | ||
<div className="flex-1"> | ||
<div className="flex items-center space-x-1"> | ||
<Link to="/" className="text-3xl"> | ||
<Link to="/" className="text-3xl text-primary"> | ||
Evolver | ||
</Link> | ||
</div> | ||
|
@@ -17,8 +17,11 @@ export default function Navbar({ pathname = "" as string }): JSX.Element { | |
<Link | ||
tabIndex={0} | ||
role="button" | ||
className={clsx("link", pathname !== "/devices" && "link-hover")} | ||
to="/devices" | ||
className={clsx( | ||
"link", | ||
pathname !== "/devices/list" && "link-hover", | ||
)} | ||
to="/devices/list" | ||
> | ||
Devices | ||
</Link> | ||
|
@@ -27,7 +30,7 @@ export default function Navbar({ pathname = "" as string }): JSX.Element { | |
<ThemeController /> | ||
</div> | ||
</div> | ||
<div className="divider divider-neutral h-0 m-0"></div> | ||
<div className="divider h-0 m-0"></div> | ||
</div> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More descriptive naming of the purpose of this cookie (reight now it persists their selected theme between page refresh / visits),
.server
tells remix framework this code will only run on the server.