Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Zipstack/unstract into feat/UN-1451…
Browse files Browse the repository at this point in the history
…-pdm-lock-automation
  • Loading branch information
kirtimanmishrazipstack committed Jul 19, 2024
2 parents 8c2bb4b + 5d72022 commit b18fd46
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 7 deletions.
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 };

0 comments on commit b18fd46

Please sign in to comment.