Skip to content

Commit e3029ba

Browse files
committed
ehtool: streamline proofreading UI and slice traversal workflow
1 parent 1d84bd9 commit e3029ba

9 files changed

Lines changed: 1088 additions & 447 deletions

File tree

client/src/views/EHTool.js

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import React, { useState, useEffect } from "react";
2-
import { Layout, Typography } from "antd";
3-
import { BugOutlined } from "@ant-design/icons";
2+
import { Layout } from "antd";
43
import DetectionWorkflow from "./ehtool/DetectionWorkflow";
54

65
const { Content } = Layout;
7-
const { Title, Text } = Typography;
86

97
/**
108
* EHTool Main Component
@@ -36,25 +34,6 @@ function EHTool({
3634
return (
3735
<Layout style={{ height: "100%", background: "#f6f8fb" }}>
3836
<Content style={{ padding: "20px 24px" }}>
39-
<div
40-
style={{
41-
display: "flex",
42-
alignItems: "center",
43-
gap: 10,
44-
marginBottom: 12,
45-
}}
46-
>
47-
<BugOutlined style={{ fontSize: 18, color: "#1677ff" }} />
48-
<div>
49-
<Title level={5} style={{ margin: 0 }}>
50-
Mask Proofreading
51-
</Title>
52-
<Text type="secondary" style={{ fontSize: 12 }}>
53-
Review and correct instances in your volume.
54-
</Text>
55-
</div>
56-
</div>
57-
5837
<DetectionWorkflow
5938
sessionId={sessionId}
6039
setSessionId={setSessionId}

client/src/views/ehtool/DatasetLoader.js

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { Card, Form, Input, Button, message, Space, Typography } from "antd";
2+
import { Card, Form, Input, Button, Modal, Space, Typography } from "antd";
33
import { FolderOpenOutlined, UploadOutlined } from "@ant-design/icons";
44
import UnifiedFileInput from "../../components/UnifiedFileInput";
55

@@ -12,22 +12,57 @@ const { Title, Text } = Typography;
1212
function DatasetLoader({ onLoad, loading }) {
1313
const [form] = Form.useForm();
1414

15-
const handleSubmit = (values) => {
16-
const datasetPath =
17-
typeof values.datasetPath === "object"
18-
? values.datasetPath.path
19-
: values.datasetPath;
20-
const maskPath =
21-
typeof values.maskPath === "object"
22-
? values.maskPath.path
23-
: values.maskPath;
15+
const resolvePath = (value) => {
16+
if (!value) return "";
17+
if (typeof value === "string") return value.trim();
18+
return (value.path || value.folderPath || "").trim();
19+
};
20+
21+
const showValidationError = (title, description) => {
22+
Modal.error({
23+
title,
24+
content: description,
25+
okText: "Got it",
26+
});
27+
};
28+
29+
const handleSubmit = async (values) => {
30+
const datasetPath = resolvePath(values.datasetPath);
31+
const maskPath = resolvePath(values.maskPath);
32+
const projectName = (values.projectName || "").trim();
33+
34+
if (!projectName) {
35+
showValidationError(
36+
"Project name required",
37+
"Please provide a name for this proofreading session.",
38+
);
39+
return;
40+
}
2441

2542
if (!datasetPath) {
26-
message.error("Please provide a dataset path");
43+
showValidationError(
44+
"Dataset path required",
45+
"Select a dataset file/folder before starting the session.",
46+
);
2747
return;
2848
}
2949

30-
onLoad(datasetPath, maskPath, values.projectName || "Untitled Project");
50+
if (datasetPath.includes("..") || maskPath.includes("..")) {
51+
showValidationError(
52+
"Invalid path",
53+
"Paths containing '..' are not allowed. Please pick a direct file/folder path.",
54+
);
55+
return;
56+
}
57+
58+
try {
59+
await onLoad(datasetPath, maskPath, projectName || "Untitled Project");
60+
} catch (error) {
61+
showValidationError(
62+
"Failed to load dataset",
63+
"Unable to start proofreading with the provided paths. Check the selected files and try again.",
64+
);
65+
}
3166
};
3267

3368
return (
@@ -75,16 +110,11 @@ function DatasetLoader({ onLoad, loading }) {
75110
label="Dataset Path"
76111
name="datasetPath"
77112
rules={[{ required: true, message: "Please enter dataset path" }]}
78-
help="File, directory, or glob (e.g., /path/to/images/*.tif)"
79113
>
80114
<UnifiedFileInput placeholder="/path/to/dataset" />
81115
</Form.Item>
82116

83-
<Form.Item
84-
label="Mask Path (Optional)"
85-
name="maskPath"
86-
help="Mask file or directory (optional)"
87-
>
117+
<Form.Item label="Mask Path (Optional)" name="maskPath">
88118
<UnifiedFileInput placeholder="/path/to/masks" />
89119
</Form.Item>
90120

@@ -101,13 +131,6 @@ function DatasetLoader({ onLoad, loading }) {
101131
</Button>
102132
</Form.Item>
103133
</Form>
104-
105-
<div style={{ marginTop: 16 }}>
106-
<Text type="secondary" style={{ fontSize: 12 }}>
107-
Supported: single TIFF (2D/3D), image folders (PNG/JPG/TIFF), or glob
108-
patterns like `*.tif`.
109-
</Text>
110-
</div>
111134
</Card>
112135
);
113136
}

0 commit comments

Comments
 (0)