diff --git a/.eslintrc.cjs b/.eslintrc.cjs
index b8ab4786..e0588958 100644
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -70,6 +70,9 @@ module.exports = {
"plugin:import/recommended",
"plugin:import/typescript",
],
+ rules: {
+ "max-params": ["error", 5],
+ },
},
// Node
diff --git a/app/browse/OutputReport.tsx b/app/browse/OutputReport.tsx
index be351e2e..f039947f 100644
--- a/app/browse/OutputReport.tsx
+++ b/app/browse/OutputReport.tsx
@@ -76,17 +76,17 @@ export const OutputReport = ({
)}
{module.name === "contactmap" && (
- 📊
+ 📐
)}
{module.report && (
<>
{
@@ -11,54 +11,3 @@ describe("getLastCaprievalModule", () => {
expect(result).toEqual(expected);
});
});
-describe("getPlotFromHtml", () => {
- test("should return the plotly data and layout", () => {
- const expected = {
- data: [
- {
- x: [1999, 2000, 2001, 2002],
- y: [10, 15, 13, 17],
- type: "scatter",
- },
- ],
- layout: {
- title: "Sales Growth",
- xaxis: {
- title: "Year",
- showgrid: false,
- zeroline: false,
- },
- yaxis: {
- title: "Percent",
- showline: false,
- },
- },
- };
- const input = `
-
- `;
-
- const p = getPlotFromHtml(input);
- expect(p).toEqual(expected);
- });
-});
diff --git a/app/caprieval/caprieval.server.ts b/app/caprieval/caprieval.server.ts
index e0a95165..f145d836 100644
--- a/app/caprieval/caprieval.server.ts
+++ b/app/caprieval/caprieval.server.ts
@@ -6,6 +6,7 @@ import {
listOutputFiles,
getModuleIndexPadding,
buildAnalyisPath,
+ fetchHtml,
} from "~/models/job.server";
import type { PlotlyProps } from "~/components/PlotlyPlot";
import type { DirectoryItem } from "~/bartender-client/types";
@@ -19,6 +20,7 @@ import type {
StructureTable,
} from "@i-vresse/haddock3-analysis-components";
import { BartenderError } from "~/models/errors";
+import { getDataFromHtml, getPlotFromHtml } from "~/lib/html";
// Package does not expose types, so extract them from the components
export type Table =
@@ -80,27 +82,6 @@ export async function getCaprievalModuleInfo(
return [moduleIndex, interactivness, pad];
}
-export async function getReportHtml(
- jobid: number,
- module: number,
- bartenderToken: string,
- moduleIndexPadding: number,
- isInteractive = false,
- moduleName = "caprieval"
-) {
- const shtml = await fetchHtml(
- jobid,
- module,
- isInteractive,
- bartenderToken,
- moduleIndexPadding,
- moduleName,
- `report.html`
- );
- const table = getTableFromHtml(shtml);
- return table;
-}
-
export interface CaprievalData {
scatters: PlotlyProps;
boxes: PlotlyProps;
@@ -145,30 +126,30 @@ export async function getCaprievalData({
moduleName?: string;
structurePrefix?: string;
}): Promise {
- const shtml = await fetchHtml(
+ const shtml = await fetchHtml({
jobid,
module,
isInteractive,
bartenderToken,
moduleIndexPadding,
moduleName,
- `${scatterSelection}.html`
- );
+ htmlFilename: `${scatterSelection}.html`,
+ });
const scatters = getPlotFromHtml(shtml, 1);
let bhtml: string;
if (scatterSelection === "report" && boxSelection === "report") {
// if both are report, we can reuse the html
bhtml = shtml;
} else {
- bhtml = await fetchHtml(
+ bhtml = await fetchHtml({
jobid,
module,
isInteractive,
bartenderToken,
moduleIndexPadding,
moduleName,
- `${boxSelection}.html`
- );
+ htmlFilename: `${boxSelection}.html`,
+ });
}
// plot id is always 1 for non-report plot as html file contains just one plot
const bplotId = boxSelection === "report" ? 2 : 1;
@@ -180,70 +161,25 @@ export async function getCaprievalData({
} else if (boxSelection === "report") {
thtml = bhtml;
} else {
- thtml = await fetchHtml(
+ thtml = await fetchHtml({
jobid,
module,
isInteractive,
bartenderToken,
moduleIndexPadding,
moduleName,
- `report.html`
- );
+ htmlFilename: `report.html`,
+ });
}
const table = prefixTable(getTableFromHtml(thtml), structurePrefix);
return { scatters, boxes, table };
}
-async function fetchHtml(
- jobid: number,
- module: number,
- isInteractive: boolean,
- bartenderToken: string,
- moduleIndexPadding: number,
- moduleName = "caprieval",
- htmlFilename = "report.html"
-) {
- const prefix = buildAnalyisPath({
- moduleIndex: module,
- moduleName,
- isInteractive,
- moduleIndexPadding,
- });
- const response = await getJobfile(
- jobid,
- `${prefix}${htmlFilename}`,
- bartenderToken
- );
- if (!response.ok) {
- throw new Error(`could not get ${htmlFilename}`);
- }
- return await response.text();
-}
-
-export function getPlotFromHtml(html: string, plotId = 1) {
- return getDataFromHtml(html, `data${plotId}`);
-}
-
export function getTableFromHtml(html: string, tableId = 2) {
return getDataFromHtml(html, `datatable${tableId}`);
}
-export function getDataFromHtml(html: string, id: string) {
- // this is very fragile, but much faster then using a HTML parser
- // as order of attributes is not guaranteed
- // see commit meessage of this line for benchmark
- const re = new RegExp(
- `
+
+
+
+
+
+
+ `;
+
+ const p = getPlotFromHtml(input);
+ expect(p).toEqual(expected);
+ });
+});
diff --git a/app/lib/html.ts b/app/lib/html.ts
new file mode 100644
index 00000000..42c37476
--- /dev/null
+++ b/app/lib/html.ts
@@ -0,0 +1,20 @@
+import { PlotlyProps } from "~/components/PlotlyPlot";
+
+export function getPlotFromHtml(html: string, plotId = 1) {
+ return getDataFromHtml(html, `data${plotId}`);
+}
+
+export function getDataFromHtml(html: string, id: string) {
+ // this is very fragile, but much faster then using a HTML parser
+ // as order of attributes is not guaranteed
+ // see commit meessage of this line for benchmark
+ const re = new RegExp(
+ `