BOD-24 Removed URL/Thumb URL to have them dynamically created.

This commit is contained in:
Patrick Fic
2020-04-20 15:07:18 -07:00
parent 01e6e78c71
commit b3eb6fe91d
12 changed files with 122 additions and 19 deletions

View File

@@ -68,7 +68,7 @@ export function DocumentsUploadContainer({
let timestamp = Math.floor(Date.now() / 1000); let timestamp = Math.floor(Date.now() / 1000);
let public_id = fileName; let public_id = fileName;
let tags = `${bodyshop.textid},${ let tags = `${bodyshop.textid},${
tagsArray ? tagsArray.map((tag) => `{tag},`) : "" tagsArray ? tagsArray.map((tag) => `${tag},`) : ""
}`; }`;
let eager = "w_200,h_200,c_thumb"; let eager = "w_200,h_200,c_thumb";
axios axios
@@ -110,8 +110,6 @@ export function DocumentsUploadContainer({
{ {
jobid: jobId, jobid: jobId,
uploaded_by: currentUser.email, uploaded_by: currentUser.email,
url: "c",
thumb_url: "c",
key: fileName, key: fileName,
invoiceid: invoiceId, invoiceid: invoiceId,
type: fileType, type: fileType,
@@ -121,10 +119,8 @@ export function DocumentsUploadContainer({
}).then((r) => { }).then((r) => {
onSuccess({ onSuccess({
uid: r.data.insert_documents.returning[0].id, uid: r.data.insert_documents.returning[0].id,
url: r.data.insert_documents.returning[0].thumb_url,
name: r.data.insert_documents.returning[0].name, name: r.data.insert_documents.returning[0].name,
status: "done", status: "done",
full_url: r.data.insert_documents.returning[0].url,
key: r.data.insert_documents.returning[0].key, key: r.data.insert_documents.returning[0].key,
}); });
notification["success"]({ notification["success"]({

View File

@@ -1,7 +1,7 @@
import { Button, notification } from "antd"; import { Button } from "antd";
import axios from "axios";
import React from "react"; import React from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import axios from "axios";
export default function JobsDocumentsDownloadButton({ galleryImages }) { export default function JobsDocumentsDownloadButton({ galleryImages }) {
const { t } = useTranslation(); const { t } = useTranslation();

View File

@@ -11,13 +11,11 @@ function JobsDocumentsComponent({ data, jobId, refetch }) {
setgalleryImages( setgalleryImages(
data.reduce((acc, value) => { data.reduce((acc, value) => {
acc.push({ acc.push({
src: value.url, src: `${process.env.REACT_APP_CLOUDINARY_IMAGE_ENDPOINT}/${value.key}.jpg`,
thumbnail: `${ thumbnail: `${process.env.REACT_APP_CLOUDINARY_IMAGE_ENDPOINT}/h_200,w_200,c_thumb/${value.key}.jpg`,
process.env.REACT_APP_CLOUDINARY_IMAGE_ENDPOINT tags: value.type.includes("pdf")
}/h_200,w_200,c_thumb/${value.key}${ ? [{ value: "PDF", title: "PDF" }]
value.type.includes("pdf") ? ".jpg" : "" : [],
}`,
tags: value.type.includes("pdf") ? [{ value: "PDF" }] : [],
thumbnailHeight: 200, thumbnailHeight: 200,
thumbnailWidth: 200, thumbnailWidth: 200,
isSelected: false, isSelected: false,
@@ -31,7 +29,11 @@ function JobsDocumentsComponent({ data, jobId, refetch }) {
return ( return (
<div className="clearfix"> <div className="clearfix">
<DocumentsUploadContainer jobId={jobId} callbackAfterUpload={refetch} /> <DocumentsUploadContainer
jobId={jobId}
callbackAfterUpload={refetch}
tagsArray={["test"]}
/>
<JobsDocumentsDownloadButton galleryImages={galleryImages} /> <JobsDocumentsDownloadButton galleryImages={galleryImages} />
<JobsDocumentsDeleteButton <JobsDocumentsDeleteButton

View File

@@ -4,8 +4,6 @@ export const GET_DOCUMENTS_BY_JOB = gql`
query GET_DOCUMENTS_BY_JOB($jobId: uuid!) { query GET_DOCUMENTS_BY_JOB($jobId: uuid!) {
documents(where: { jobid: { _eq: $jobId } }) { documents(where: { jobid: { _eq: $jobId } }) {
id id
url
thumb_url
name name
key key
type type
@@ -18,8 +16,6 @@ export const INSERT_NEW_DOCUMENT = gql`
insert_documents(objects: $docInput) { insert_documents(objects: $docInput) {
returning { returning {
id id
url
thumb_url
name name
key key
} }

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1,6 @@
- args:
cascade: true
read_only: false
sql: "ALTER TABLE documents \r\nDROP COLUMN url ;\r\nALTER TABLE documents \r\nDROP
COLUMN thumb_url ;"
type: run_sql

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: documents
schema: public
type: drop_insert_permission

View File

@@ -0,0 +1,32 @@
- args:
permission:
allow_upsert: true
check:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- id
- created_at
- updated_at
- uploaded_by
- jobid
- name
- key
- invoiceid
- type
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: documents
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: documents
schema: public
type: drop_select_permission

View File

@@ -0,0 +1,30 @@
- args:
permission:
allow_aggregations: false
columns:
- key
- name
- type
- uploaded_by
- created_at
- updated_at
- id
- invoiceid
- jobid
computed_fields: []
filter:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
limit: null
role: user
table:
name: documents
schema: public
type: create_select_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: documents
schema: public
type: drop_update_permission

View File

@@ -0,0 +1,22 @@
- args:
permission:
columns: []
filter:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: documents
schema: public
type: create_update_permission