From 48ecfe0d982cdacc8f4d71fb9b709fc563b6b27a Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Wed, 26 May 2021 16:45:59 -0700 Subject: [PATCH] Media File improvements + separate DEV testing instance for cloudinary. --- bodyshop_translations.babel | 21 +++++++++++++++++++ .../documents-upload.utility.js | 4 ++-- .../jobs-detail-header-actions.component.jsx | 1 - .../jobs-documents-gallery.component.jsx | 18 ++++++++++------ client/src/graphql/documents.queries.js | 1 + client/src/translations/en_us/common.json | 3 ++- client/src/translations/es/common.json | 3 ++- client/src/translations/fr/common.json | 3 ++- 8 files changed, 42 insertions(+), 12 deletions(-) diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 0faad2b83..a4c57daea 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -10757,6 +10757,27 @@ + + updating + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + diff --git a/client/src/components/documents-upload/documents-upload.utility.js b/client/src/components/documents-upload/documents-upload.utility.js index ad5083e95..8812aefd3 100644 --- a/client/src/components/documents-upload/documents-upload.utility.js +++ b/client/src/components/documents-upload/documents-upload.utility.js @@ -128,7 +128,7 @@ export const uploadToCloudinary = async ( let takenat; if (fileType.includes("image")) { const exif = await exifr.parse(file); - console.log(`exif`, exif); + takenat = exif && exif.DateTimeOriginal; } const documentInsert = await client.mutate({ @@ -141,7 +141,7 @@ export const uploadToCloudinary = async ( uploaded_by: uploaded_by, key: key, type: fileType, - extension: extension, + extension: cloudinaryUploadResponse.data.format || extension, bodyshopid: bodyshop.id, size: cloudinaryUploadResponse.data.bytes || file.size, takenat, diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx index 9c9dd4533..1b31a210d 100644 --- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx +++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx @@ -1,7 +1,6 @@ import { DownCircleFilled } from "@ant-design/icons"; import { useApolloClient, useMutation } from "@apollo/client"; import { Button, Dropdown, Menu, notification, Popconfirm } from "antd"; -import moment from "moment"; import React, { useMemo } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; diff --git a/client/src/components/jobs-documents-gallery/jobs-documents-gallery.component.jsx b/client/src/components/jobs-documents-gallery/jobs-documents-gallery.component.jsx index 2c50c9672..e4c3d0eba 100644 --- a/client/src/components/jobs-documents-gallery/jobs-documents-gallery.component.jsx +++ b/client/src/components/jobs-documents-gallery/jobs-documents-gallery.component.jsx @@ -31,7 +31,9 @@ function JobsDocumentsComponent({ acc.images.push({ src: `${ process.env.REACT_APP_CLOUDINARY_ENDPOINT - }/${DetermineFileType(value.type)}/upload/${value.key}`, + }/${DetermineFileType(value.type)}/upload/${value.key}${ + value.extension ? `.${value.extension}` : "" + }`, thumbnail: `${ process.env.REACT_APP_CLOUDINARY_ENDPOINT }/${DetermineFileType(value.type)}/upload/${ @@ -51,13 +53,17 @@ function JobsDocumentsComponent({ let thumb; switch (fileType) { case "video": - thumb = `${process.env.REACT_APP_CLOUDINARY_ENDPOINT}/${fileType}/upload/c_fill,f_png,h_250,w_250/${value.key}`; + thumb = `${process.env.REACT_APP_CLOUDINARY_ENDPOINT}/${fileType}/upload/${process.env.REACT_APP_CLOUDINARY_THUMB_TRANSFORMATIONS}/${value.key}`; break; case "raw": thumb = `${window.location.origin}/file.png`; break; default: - thumb = `${process.env.REACT_APP_CLOUDINARY_ENDPOINT}/${fileType}/upload/${process.env.REACT_APP_CLOUDINARY_THUMB_TRANSFORMATIONS}/${value.key}`; + thumb = `${ + process.env.REACT_APP_CLOUDINARY_ENDPOINT + }/${fileType}/upload/${ + process.env.REACT_APP_CLOUDINARY_THUMB_TRANSFORMATIONS + }/${value.key}${value.extension ? `.${value.extension}` : ""}`; break; } @@ -65,9 +71,9 @@ function JobsDocumentsComponent({ acc.other.push({ src: `${ process.env.REACT_APP_CLOUDINARY_ENDPOINT - }/${fileType}/upload/${fileType === "video" ? "q_auto/" : ""}${ - value.key - }${fileType === "raw" ? `.${value.extension}` : ""}`, + }/${fileType}/upload/${value.key}${ + value.extension ? `.${value.extension}` : "" + }`, thumbnail: thumb, tags: [ { diff --git a/client/src/graphql/documents.queries.js b/client/src/graphql/documents.queries.js index 8959e49a9..d0c11f914 100644 --- a/client/src/graphql/documents.queries.js +++ b/client/src/graphql/documents.queries.js @@ -20,6 +20,7 @@ export const GET_DOCUMENTS_BY_JOB = gql` type size takenat + extension bill { id invoice_number diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 19bd55384..4dc554b3a 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -683,7 +683,8 @@ "deleting_cloudinary": "Error deleting document from storage. {{message}}", "getpresignurl": "Error obtaining presigned URL for document. {{message}}", "insert": "Unable to upload file. {{message}}", - "nodocuments": "There are no documents." + "nodocuments": "There are no documents.", + "updating": "Error updating document. {{error}}" }, "labels": { "confirmdelete": "Are you sure you want to delete these documents. This CANNOT be undone.", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index ac60ee51a..0e50e4a16 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -683,7 +683,8 @@ "deleting_cloudinary": "", "getpresignurl": "Error al obtener la URL prescrita para el documento. {{message}}", "insert": "Incapaz de cargar el archivo. {{message}}", - "nodocuments": "No hay documentos" + "nodocuments": "No hay documentos", + "updating": "" }, "labels": { "confirmdelete": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 7dc82bfce..4529a34e9 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -683,7 +683,8 @@ "deleting_cloudinary": "", "getpresignurl": "Erreur lors de l'obtention de l'URL présignée pour le document. {{message}}", "insert": "Incapable de télécharger le fichier. {{message}}", - "nodocuments": "Il n'y a pas de documents." + "nodocuments": "Il n'y a pas de documents.", + "updating": "" }, "labels": { "confirmdelete": "",