Skip to content
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

added highlight plugin imports and changed workflow name to id for ma… #494

Merged
merged 5 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/workflow_manager/endpoint/destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,15 +511,15 @@ def _push_to_queue(
file_content = remote_file.read()
# Convert file content to a base64 encoded string
file_content_base64 = base64.b64encode(file_content).decode("utf-8")
q_name = f"review_queue_{self.organization_id}_{workflow.workflow_name}"
q_name = f"review_queue_{self.organization_id}_{workflow.id}"
queue_result = QueueResult(
file=file_name,
whisper_hash=meta_data["whisper-hash"],
status=QueueResultStatus.SUCCESS,
result=result,
workflow_id=str(self.workflow_id),
file_content=file_content_base64,
)
).to_dict()
# Convert the result dictionary to a JSON string
queue_result_json = json.dumps(queue_result)
conn = QueueUtils.get_queue_inst()
Expand Down
10 changes: 10 additions & 0 deletions backend/workflow_manager/endpoint/queue_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,13 @@ class QueueResult:
result: Any
workflow_id: str
file_content: str

def to_dict(self) -> Any:
return {
"file": self.file,
"whisper_hash": self.whisper_hash,
"status": self.status,
"result": self.result,
"workflow_id": self.workflow_id,
"file_content": self.file_content,
}
23 changes: 22 additions & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"@ant-design/icons": "^5.1.4",
"@react-pdf-viewer/core": "^3.12.0",
"@react-pdf-viewer/default-layout": "^3.12.0",
"@react-pdf-viewer/highlight": "^3.12.0",
"@react-pdf-viewer/page-navigation": "^3.12.0",
"@rjsf/antd": "^5.16.1",
"@rjsf/core": "^5.8.1",
Expand All @@ -26,7 +27,7 @@
"http-proxy-middleware": "^2.0.6",
"js-cookie": "^3.0.5",
"js-yaml": "^4.1.0",
"json-2-csv": "^5.5.4",
"json-2-csv": "^5.5.1",
"markdown-to-jsx": "^7.2.1",
"moment": "^2.29.4",
"moment-timezone": "^0.5.45",
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/components/custom-tools/pdf-viewer/Highlight.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.pdf-container {
position: relative;
}

.highlight {
position: absolute;
background-color: yellow;
opacity: 0.5;
}
32 changes: 29 additions & 3 deletions frontend/src/components/custom-tools/pdf-viewer/PdfViewer.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,43 @@
import { useRef } from "react";
import { Viewer, Worker } from "@react-pdf-viewer/core";
import { defaultLayoutPlugin } from "@react-pdf-viewer/default-layout";
import { pageNavigationPlugin } from "@react-pdf-viewer/page-navigation";
import PropTypes from "prop-types";
import { highlightPlugin } from "@react-pdf-viewer/highlight";
import "@react-pdf-viewer/highlight/lib/styles/index.css";
import "./Highlight.css";

function PdfViewer({ fileUrl }) {
let RenderHighlights;
try {
RenderHighlights =
require("../../../plugins/pdf-highlight/RenderHighlights").RenderHighlights;
} catch (err) {
// Do nothing, No plugin will be loaded.
}

function PdfViewer({ fileUrl, highlightData }) {
const newPlugin = defaultLayoutPlugin();
const pageNavigationPluginInstance = pageNavigationPlugin();
const parentRef = useRef(null);
let highlightPluginInstance = "";
if (RenderHighlights && highlightData) {
highlightPluginInstance = highlightPlugin({
renderHighlights: (props) => (
<RenderHighlights {...props} highlightData={highlightData} />
),
});
}

return (
<div className="doc-manager-body">
<div ref={parentRef} className="doc-manager-body">
<Worker workerUrl="https://unpkg.com/[email protected]/build/pdf.worker.min.js">
<Viewer
fileUrl={fileUrl}
plugins={[newPlugin, pageNavigationPluginInstance]}
plugins={[
newPlugin,
pageNavigationPluginInstance,
highlightPluginInstance,
]}
/>
</Worker>
</div>
Expand All @@ -21,6 +46,7 @@ function PdfViewer({ fileUrl }) {

PdfViewer.propTypes = {
fileUrl: PropTypes.any,
highlightData: PropTypes.array,
};

export { PdfViewer };
Loading