- {groupName}
+ {name}
- {data.map((instrument) => (
+ {instruments.map((instrument) => (
))}
diff --git a/app/components/__snapshots__/Groups.test.tsx.snap b/app/components/__snapshots__/Groups.test.tsx.snap
new file mode 100644
index 0000000..7b9f060
--- /dev/null
+++ b/app/components/__snapshots__/Groups.test.tsx.snap
@@ -0,0 +1,170 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`renders groups correctly with hidden and non hidden groups 1`] = `
+
+
+
+
+ group1
+
+
+
+
+
+ Block
+
+
+ Value
+
+
+
+
+
+
+
+
+ aShownBlock
+
+
+
+
+
+
+ 2.344
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ aDifferentShownBlock
+
+
+
+
+
+
+ 3.14
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+`;
diff --git a/app/components/__snapshots__/InstrumentWallCard.test.tsx.snap b/app/components/__snapshots__/InstrumentWallCard.test.tsx.snap
new file mode 100644
index 0000000..b883226
--- /dev/null
+++ b/app/components/__snapshots__/InstrumentWallCard.test.tsx.snap
@@ -0,0 +1,61 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`renders instrumentwallcard unchanged 1`] = `
+
+`;
+
+exports[`renders instrumentwallcard unchanged when runstate is unknown 1`] = `
+
+`;
diff --git a/app/components/__snapshots__/ScienceGroup.test.tsx.snap b/app/components/__snapshots__/ScienceGroup.test.tsx.snap
new file mode 100644
index 0000000..6b65b49
--- /dev/null
+++ b/app/components/__snapshots__/ScienceGroup.test.tsx.snap
@@ -0,0 +1,69 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`renders sciencegroup unchanged 1`] = `
+
+`;
diff --git a/app/components/__snapshots__/TargetStation.test.tsx.snap b/app/components/__snapshots__/TargetStation.test.tsx.snap
new file mode 100644
index 0000000..c30da19
--- /dev/null
+++ b/app/components/__snapshots__/TargetStation.test.tsx.snap
@@ -0,0 +1,69 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`renders targetstation unchanged 1`] = `
+
+`;
diff --git a/app/components/getRunstateColours.test.ts b/app/components/getRunstateColours.test.ts
index 6bad73d..82f1f5c 100644
--- a/app/components/getRunstateColours.test.ts
+++ b/app/components/getRunstateColours.test.ts
@@ -4,7 +4,7 @@ import {
} from "@/app/components/getRunstateColours";
test("getForegroundColor when runstate requires white text returns white text", () => {
- const runstate = "WAITING";
+ const runstate = "RESUMING";
const result = getForegroundColour(runstate);
expect(result).toBe("text-white");
});
diff --git a/app/components/getRunstateColours.ts b/app/components/getRunstateColours.ts
index 4b071c7..d5303dc 100644
--- a/app/components/getRunstateColours.ts
+++ b/app/components/getRunstateColours.ts
@@ -18,12 +18,10 @@ export function getForegroundColour(status: string): string {
"PROCESSING",
"VETOING",
"SETUP",
+ "WAITING",
];
return blackTextRunstates.includes(status) ? "text-black" : "text-white";
}
export function getStatusColour(status: string): string {
- if (!statusColourLookup.has(status) || status == "UNKNOWN") {
- return "bg-[#F08080]";
- }
- return statusColourLookup.get(status)!;
+ return statusColourLookup.get(status) || "bg-[#F08080]";
}
diff --git a/app/instruments/page.tsx b/app/instruments/page.tsx
index a08832c..1182cd5 100644
--- a/app/instruments/page.tsx
+++ b/app/instruments/page.tsx
@@ -1,91 +1,11 @@
-"use client";
-import Link from "next/link";
-import { useEffect, useState } from "react";
-import { IfcPVWSMessage, IfcPVWSRequest } from "@/app/types";
-import { instListFromBytes } from "@/app/components/dehex_and_decompress";
-import useWebSocket from "react-use-websocket";
-import { instListPV, instListSubscription, socketURL } from "@/app/commonVars";
-import createInstrumentGroupsFromInstlist from "@/app/instruments/utils";
+import InstrumentsDisplay from "@/app/components/InstrumentsDisplay";
export default function Instruments() {
- const [instrumentGroups, setInstrumentGroups] = useState<
- Map
>
- >(new Map());
-
- const {
- sendJsonMessage,
- lastJsonMessage,
- }: {
- sendJsonMessage: (a: IfcPVWSRequest) => void;
- lastJsonMessage: IfcPVWSMessage;
- } = useWebSocket(socketURL, {
- shouldReconnect: (closeEvent) => true,
- });
-
- useEffect(() => {
- // On page load, subscribe to the instrument list as it's required to get each instrument.
- sendJsonMessage(instListSubscription);
- }, [sendJsonMessage]);
-
- useEffect(() => {
- // Instlist has changed
- if (!lastJsonMessage) {
- return;
- }
-
- const updatedPV: IfcPVWSMessage = lastJsonMessage;
- const updatedPVbytes: string | null | undefined = updatedPV.b64byt;
-
- if (updatedPV.pv == instListPV && updatedPVbytes != null) {
- const newInstrumentGroups = createInstrumentGroupsFromInstlist(
- instListFromBytes(updatedPVbytes),
- );
- setInstrumentGroups(newInstrumentGroups);
- }
- }, [lastJsonMessage]);
-
- if (!instrumentGroups.size) {
- return Loading... ;
- }
-
return (
-
-
-
-
- {Array.from(instrumentGroups.entries()).map(([group, insts]) => {
- return (
-
-
- {group}
-
-
- {insts.sort().map((instrument: string) => {
- return (
-
-
-
- {instrument}
-
-
-
- );
- })}
-
-
- );
- })}
-
-
-
-
+
+
);
}
diff --git a/app/instruments/utils.test.tsx b/app/instruments/utils.test.tsx
deleted file mode 100644
index c98d023..0000000
--- a/app/instruments/utils.test.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import createInstrumentGroupsFromInstlist from "@/app/instruments/utils";
-import { instList } from "@/app/types";
-
-test("createInstrumentGroupsFromInstlist adds an instrument to a group if it has one", () => {
- const instName = "ANINST";
- const groups = ["GROUP1"];
- const instList: instList = [
- {
- name: instName,
- hostName: "blah",
- groups: groups,
- isScheduled: true,
- seci: false,
- pvPrefix: "SOME:PREFIX",
- },
- ];
- const result = createInstrumentGroupsFromInstlist(instList);
- expect(result.get(groups[0])).toEqual([instName]);
-});
-
-test("createInstrumentGroupsFromInstlist ignores instrument if it has no group", () => {
- const instName = "ANINST";
- const groups: Array