IO-3307 Resolve bill document for imgproxy.
This commit is contained in:
@@ -46,8 +46,8 @@ function JobsDocumentsImgproxyComponent({
|
|||||||
const [modalState, setModalState] = useState({ open: false, index: 0 });
|
const [modalState, setModalState] = useState({ open: false, index: 0 });
|
||||||
|
|
||||||
const fetchThumbnails = useCallback(() => {
|
const fetchThumbnails = useCallback(() => {
|
||||||
fetchImgproxyThumbnails({ setStateCallback: setGalleryImages, jobId });
|
fetchImgproxyThumbnails({ setStateCallback: setGalleryImages, jobId, billId });
|
||||||
}, [jobId, setGalleryImages]);
|
}, [jobId, billId, setGalleryImages]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -208,8 +208,8 @@ function JobsDocumentsImgproxyComponent({
|
|||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(JobsDocumentsImgproxyComponent);
|
export default connect(mapStateToProps, mapDispatchToProps)(JobsDocumentsImgproxyComponent);
|
||||||
|
|
||||||
export const fetchImgproxyThumbnails = async ({ setStateCallback, jobId, imagesOnly }) => {
|
export const fetchImgproxyThumbnails = async ({ setStateCallback, jobId, billId, imagesOnly }) => {
|
||||||
const result = await axios.post("/media/imgproxy/thumbnails", { jobid: jobId });
|
const result = await axios.post("/media/imgproxy/thumbnails", { jobid: jobId, billid: billId });
|
||||||
const documents = result.data.reduce(
|
const documents = result.data.reduce(
|
||||||
(acc, value) => {
|
(acc, value) => {
|
||||||
if (value.type.startsWith("image")) {
|
if (value.type.startsWith("image")) {
|
||||||
|
|||||||
@@ -2846,6 +2846,26 @@ exports.GET_DOCUMENTS_BY_JOB = `
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
|
exports.GET_DOCUMENTS_BY_BILL = `
|
||||||
|
query GET_DOCUMENTS_BY_BILL($billId: uuid!) {
|
||||||
|
documents_aggregate(where: {billid: {_eq: $billId}}) {
|
||||||
|
aggregate {
|
||||||
|
sum {
|
||||||
|
size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
documents(order_by: {takenat: desc}, where: {billid: {_eq: $billId}}) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
key
|
||||||
|
type
|
||||||
|
size
|
||||||
|
takenat
|
||||||
|
extension
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
exports.QUERY_TEMPORARY_DOCS = ` query QUERY_TEMPORARY_DOCS {
|
exports.QUERY_TEMPORARY_DOCS = ` query QUERY_TEMPORARY_DOCS {
|
||||||
documents(where: { jobid: { _is_null: true } }, order_by: { takenat: desc }) {
|
documents(where: { jobid: { _is_null: true } }, order_by: { takenat: desc }) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ const {
|
|||||||
GET_DOCUMENTS_BY_JOB,
|
GET_DOCUMENTS_BY_JOB,
|
||||||
QUERY_TEMPORARY_DOCS,
|
QUERY_TEMPORARY_DOCS,
|
||||||
GET_DOCUMENTS_BY_IDS,
|
GET_DOCUMENTS_BY_IDS,
|
||||||
|
GET_DOCUMENTS_BY_BILL,
|
||||||
DELETE_MEDIA_DOCUMENTS
|
DELETE_MEDIA_DOCUMENTS
|
||||||
} = require("../graphql-client/queries");
|
} = require("../graphql-client/queries");
|
||||||
const yazl = require("yazl");
|
const yazl = require("yazl");
|
||||||
@@ -90,9 +91,11 @@ const getThumbnailUrls = async (req, res) => {
|
|||||||
//Delayed as the key structure may change slightly from what it is currently and will require evaluating mobile components.
|
//Delayed as the key structure may change slightly from what it is currently and will require evaluating mobile components.
|
||||||
const client = req.userGraphQLClient;
|
const client = req.userGraphQLClient;
|
||||||
//If there's no jobid and no billid, we're in temporary documents.
|
//If there's no jobid and no billid, we're in temporary documents.
|
||||||
const data = await (jobid
|
const data = await (
|
||||||
? client.request(GET_DOCUMENTS_BY_JOB, { jobId: jobid })
|
billid ? client.request(GET_DOCUMENTS_BY_BILL, { billId: billid }) :
|
||||||
: client.request(QUERY_TEMPORARY_DOCS));
|
jobid
|
||||||
|
? client.request(GET_DOCUMENTS_BY_JOB, { jobId: jobid })
|
||||||
|
: client.request(QUERY_TEMPORARY_DOCS));
|
||||||
|
|
||||||
const thumbResizeParams = `rs:fill:250:250:1/g:ce`;
|
const thumbResizeParams = `rs:fill:250:250:1/g:ce`;
|
||||||
const s3client = new S3Client({ region: InstanceRegion() });
|
const s3client = new S3Client({ region: InstanceRegion() });
|
||||||
|
|||||||
Reference in New Issue
Block a user