Skip to content

Commit eed094b

Browse files
committed
Merge remote-tracking branch 'origin/main' into use_callbacks
2 parents 888237f + ed34856 commit eed094b

14 files changed

+91
-108
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Allows monitoring of instrument PVs via a web page.
88

99
**Frontend:** [NextJS](https://nextjs.org/) using [React](https://react.dev/), [Tailwind CSS](https://tailwindcss.com/)
1010

11-
**Backend:** [pvws](https://github.com/ornl-epics/pvws)
11+
**Backend:** [pvws](https://github.com/ornl-epics/pvws) - with [our configuration here](https://github.com/ISISComputingGroup/pvws-config)
1212

1313
## Development
1414

app/components/GithubActionsScheduledJobs.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ export default function GithubActionsScheduledJobs() {
7878
repo={"IBEX"}
7979
workflowName={"project_board_checks.yml"}
8080
/>
81+
<GithubActionsJob
82+
repo={"EPICS-refl"}
83+
workflowName={"lint-and-test-nightly.yml"}
84+
/>
8185
</div>
8286
);
8387
}

app/components/InstrumentWallCard.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import Link from "next/link";
2-
import { getForegroundColour, getStatusColour } from "./getRunstateColours";
2+
import {
3+
getForegroundColour,
4+
getStatusColour,
5+
UNREACHABLE,
6+
} from "./getRunstateColours";
37
import { instListEntryWithRunstatePVandValue } from "@/app/types";
48

59
export default function InstrumentWallCard({
@@ -13,16 +17,16 @@ export default function InstrumentWallCard({
1317
href={"/instrument?name=" + instrument.name}
1418
target="_blank"
1519
className={`flex items-center justify-center text-center py-1 w-28 max-h-12 rounded-lg shadow-sm border-2 border-gray-700 dark:border-gray-200 hover:shadow-lg hover:border-black dark:hover:border-gray-700 transition-all duration-200
16-
${getStatusColour(instrument.runStateValue || "UNKNOWN")} ${getForegroundColour(
17-
instrument.runStateValue || "UNKNOWN",
20+
${getStatusColour(instrument.runStateValue || UNREACHABLE)} ${getForegroundColour(
21+
instrument.runStateValue || UNREACHABLE,
1822
)}`}
1923
>
2024
<div className="flex flex-col">
2125
<span className="text-sm font-bold line-clamp-1 w-full">
2226
{instrument.name}
2327
</span>
2428
<span className="text-xs ">
25-
{instrument.runStateValue || "UNKNOWN"}
29+
{instrument.runStateValue || UNREACHABLE}
2630
</span>
2731
</div>
2832
</Link>

app/components/TopBar.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test("GetRunstate returns the runstate when it exists and is of string type", ()
2121

2222
test("GetRunstate returns unknown when no runstate PV in array", () => {
2323
const PVArr: Array<IfcPV> = [];
24-
expect(getRunstate(PVArr)).toBe("UNKNOWN");
24+
expect(getRunstate(PVArr)).toBe("UNREACHABLE");
2525
});
2626

2727
it("renders topbar unchanged", () => {

app/components/TopBar.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { getForegroundColour, getStatusColour } from "./getRunstateColours";
1+
import {
2+
getForegroundColour,
3+
getStatusColour,
4+
UNREACHABLE,
5+
} from "./getRunstateColours";
26

37
import { DashboardArr, IfcPV } from "@/app/types";
48
import { findPVByHumanReadableName } from "@/app/components/PVutils";
@@ -11,7 +15,7 @@ export function getRunstate(runInfoPVs: Array<IfcPV>): string {
1115
if (runStatePV && runStatePV.value && typeof runStatePV.value === "string") {
1216
return runStatePV.value;
1317
}
14-
return "UNKNOWN";
18+
return UNREACHABLE;
1519
}
1620

1721
export default function TopBar({

app/components/__snapshots__/InstrumentWallCard.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ exports[`renders instrumentwallcard unchanged when runstate is unknown 1`] = `
5252
<span
5353
class="text-xs "
5454
>
55-
UNKNOWN
55+
UNREACHABLE
5656
</span>
5757
</div>
5858
</a>

app/components/__snapshots__/TopBar.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ exports[`renders topbar unchanged 1`] = `
2525
<span
2626
id="runStateSpan"
2727
>
28-
UNKNOWN
28+
UNREACHABLE
2929
</span>
3030
</h2>
3131
<h3

app/components/dehex_and_decompress.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
1-
import pako from "pako";
21
import { instList } from "@/app/types";
3-
4-
function unhexlify(str: string): string {
5-
let result = "";
6-
for (let i = 0, l = str.length; i < l; i += 2) {
7-
result += String.fromCharCode(parseInt(str.slice(i, i + 2), 16));
8-
}
9-
return result;
10-
}
11-
2+
import { unzipSync } from "zlib";
123
/**
134
* dehex_and_decompress
145
* - synonymous to dehex_and_decompress in inst_servers
156
* @param {*} input raw data
167
* @returns dehexed and decompressed data (you can choose to JSON parse it or not afterwards)
178
*/
189
export function dehex_and_decompress(input: string): string {
19-
// DEHEX
20-
const unhexed = unhexlify(input);
21-
const charData = unhexed.split("").map(function (x) {
22-
return x.charCodeAt(0);
23-
});
24-
// convert to binary
25-
const binData = new Uint8Array(charData);
26-
return pako.inflate(binData, { to: "string" });
10+
return unzipSync(Buffer.from(input, "hex")).toString();
2711
}
2812

2913
/**

app/components/getRunstateColours.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
getForegroundColour,
33
getStatusColour,
4+
UNREACHABLE,
45
} from "@/app/components/getRunstateColours";
56

67
test("getForegroundColor when runstate requires white text returns white text", () => {
@@ -22,7 +23,7 @@ test("getForegroundColor when runstate requires black text returns black text",
2223
});
2324

2425
test("getStatusColour when runstate unknown returns expected colour", () => {
25-
const result = getStatusColour("UNKNOWN");
26+
const result = getStatusColour(UNREACHABLE);
2627
expect(result).toBe("bg-[#F08080]");
2728
});
2829

app/components/getRunstateColours.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export const UNREACHABLE = "UNREACHABLE";
2+
13
const statusColourLookup = new Map<string, string>([
24
["PAUSED", "bg-red-500"],
35
["PAUSING", "bg-red-950"],
@@ -13,7 +15,7 @@ const statusColourLookup = new Map<string, string>([
1315

1416
export function getForegroundColour(status: string): string {
1517
const blackTextRunstates = [
16-
"UNKNOWN",
18+
UNREACHABLE,
1719
"RUNNING",
1820
"PROCESSING",
1921
"VETOING",

0 commit comments

Comments
 (0)