Added temporary document handling IO-69

This commit is contained in:
Patrick Fic
2021-02-12 11:25:34 -08:00
parent 675c38b19a
commit 77a06014cf
44 changed files with 1018 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
<babeledit_project version="1.2" be_version="2.7.1">
<babeledit_project be_version="2.7.1" version="1.2">
<!--
BabelEdit project file
@@ -4252,6 +4252,32 @@
</concept_node>
</children>
</folder_node>
<folder_node>
<name>temporarydocs</name>
<children>
<concept_node>
<name>view</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
</children>
</folder_node>
<folder_node>
<name>timetickets</name>
<children>
@@ -9089,6 +9115,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>reassign</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>selectallimages</name>
<definition_loaded>false</definition_loaded>
@@ -9288,6 +9335,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>newjobid</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>upload</name>
<definition_loaded>false</definition_loaded>
@@ -20668,6 +20736,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>temporarydocs</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>timetickets</name>
<definition_loaded>false</definition_loaded>
@@ -27250,6 +27339,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>temporarydocs</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>timetickets</name>
<definition_loaded>false</definition_loaded>
@@ -28008,6 +28118,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>temporarydocs</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>timetickets</name>
<definition_loaded>false</definition_loaded>

View File

@@ -14,7 +14,7 @@
.imex-flex-row {
display: flex;
justify-content: flex-start;
//flex-wrap: wrap;
flex-wrap: wrap;
align-items: center;
&__grow {

View File

@@ -127,12 +127,13 @@ export const uploadToCloudinary = async (
variables: {
docInput: [
{
jobid: jobId,
...(jobId ? { jobid: jobId } : {}),
...(billId ? { billid: billId } : {}),
uploaded_by: uploaded_by,
key: key,
billid: billId,
type: fileType,
extension: extension,
bodyshopid: bodyshop.id,
},
],
},
@@ -163,7 +164,6 @@ export const uploadToCloudinary = async (
};
export function DetermineFileType(filetype) {
console.log("Checking Type", filetype, filetype.startsWith("video"));
if (!filetype) return "auto";
else if (filetype.startsWith("image")) return "image";
else if (filetype.startsWith("video")) return "video";

View File

@@ -265,7 +265,11 @@ function Header({
<Menu.Item key="shop">
<Link to="/manage/shop">{t("menus.header.shop_config")}</Link>
</Menu.Item>
<Menu.Item key="temporarydocs">
<Link to="/manage/temporarydocs">
{t("menus.header.temporarydocs")}
</Link>
</Menu.Item>
<Menu.Item key="shop-templates">
<Link to="/manage/shop/templates">
{t("menus.header.shop_templates")}

View File

@@ -113,6 +113,7 @@ export function JobDetailCards({ setPrintCenterContext }) {
actions: { refetch: refetch },
context: {
id: data.jobs_by_pk.id,
job: data.jobs_by_pk,
type: "job",
},
});

View File

@@ -55,6 +55,7 @@ export function JobsDetailHeader({
actions: { refetch: refetch },
context: {
id: job.id,
job: job,
type: "job",
},
});

View File

@@ -102,6 +102,9 @@ export function JobsDetailTotals({
name: TemplateList("payment").payment_receipt.key,
variables: { id: p.id },
}}
messageObject={{
to: job.ownr_ea,
}}
/>
</td>
</tr>

View File

@@ -0,0 +1,111 @@
import { Button, Form, Popover, notification } from "antd";
import React, { useState, useMemo } from "react";
import { useTranslation } from "react-i18next";
import JobSearchSelect from "../job-search-select/job-search-select.component";
import { useMutation } from "@apollo/react-hooks";
import { UPDATE_DOCUMENT } from "../../graphql/documents.queries";
import axios from "axios";
export default function JobsDocumentsGalleryReassign({ galleryImages }) {
const { t } = useTranslation();
const [form] = Form.useForm();
const selectedImages = useMemo(() => {
return [
...galleryImages.images.filter((image) => image.isSelected),
...galleryImages.other.filter((image) => image.isSelected),
];
}, [galleryImages]);
const [visible, setVisible] = useState(false);
const [loading, setLoading] = useState(false);
const [updateDocument] = useMutation(UPDATE_DOCUMENT);
const updateImage = async (i, jobid) => {
//Move the cloudinary image
console.log(i);
//Update it in the database.
const result = await updateDocument({
variables: {
id: i.id,
document: {
key: i.public_id,
jobid: jobid,
},
},
});
if (!!result.errors) {
notification["error"]({
message: t("documents.errors.updating", {
message: JSON.stringify(result.errors),
}),
});
} else {
notification["success"]({
message: t("documents.successes.updated"),
});
}
};
const handleFinish = async ({ jobid }) => {
setLoading(true);
const res = await axios.post("/media/rename", {
documents: selectedImages.map((i) => {
return { id: i.id, from: i.key, to: i.key.replace("null", jobid) };
}),
});
console.log(res.data);
const proms = [];
res.data
.filter((d) => !d.error)
.forEach((d) => {
proms.push(updateImage(d, jobid));
});
await Promise.all(proms);
setVisible(false);
setLoading(false);
};
const popContent = (
<div>
<Form onFinish={handleFinish} layout="vertical" form={form}>
<Form.Item
label={t("documents.labels.newjobid")}
style={{ width: "20rem" }}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
name={"jobid"}
>
<JobSearchSelect />
</Form.Item>
</Form>
<Button onClick={() => form.submit()}>
{t("general.actions.submit")}
</Button>
</div>
);
return (
<Popover content={popContent} visible={visible}>
<Button
disabled={selectedImages.length < 1}
onClick={() => setVisible(true)}
loading={loading}
>
{t("documents.actions.reassign")}
</Button>
</Popover>
);
}

View File

@@ -1,13 +1,15 @@
import { FileExcelFilled } from "@ant-design/icons";
import { Card, Space } from "antd";
import { Card } from "antd";
import React, { useEffect, useState } from "react";
import Gallery from "react-grid-gallery";
import { useTranslation } from "react-i18next";
import DocumentsUploadComponent from "../documents-upload/documents-upload.component";
import { DetermineFileType } from "../documents-upload/documents-upload.utility";
import JobsDocumentsDownloadButton from "./jobs-document-gallery.download.component";
import JobsDocumentsGalleryReassign from "./jobs-document-gallery.reassign.component";
import JobsDocumentsDeleteButton from "./jobs-documents-gallery.delete.component";
import JobsDocumentsGallerySelectAllComponent from "./jobs-documents-gallery.selectall.component";
function JobsDocumentsComponent({
data,
jobId,
@@ -97,18 +99,17 @@ function JobsDocumentsComponent({
return (
<div className="clearfix">
<div>
<Space>
<JobsDocumentsGallerySelectAllComponent
galleryImages={galleryImages}
setGalleryImages={setgalleryImages}
/>
<JobsDocumentsDownloadButton galleryImages={galleryImages} />
<JobsDocumentsDeleteButton
galleryImages={galleryImages}
deletionCallback={billsCallback || refetch}
/>
</Space>
<div className="imex-flex-row">
<JobsDocumentsGallerySelectAllComponent
galleryImages={galleryImages}
setGalleryImages={setgalleryImages}
/>
<JobsDocumentsDownloadButton galleryImages={galleryImages} />
<JobsDocumentsDeleteButton
galleryImages={galleryImages}
deletionCallback={billsCallback || refetch}
/>
<JobsDocumentsGalleryReassign galleryImages={galleryImages} />
</div>
<DocumentsUploadComponent
jobId={jobId}

View File

@@ -1,4 +1,4 @@
import { Button } from "antd";
import { Button, Space } from "antd";
import React from "react";
import { useTranslation } from "react-i18next";

View File

@@ -22,6 +22,7 @@ export function PrintCenterItemComponent({
bodyshop,
disabled,
}) {
const { context } = printCenterModal;
const renderToNewWindow = async () => {
await GenerateDocument(
{
@@ -45,7 +46,7 @@ export function PrintCenterItemComponent({
name: item.key,
variables: { id: id },
},
{},
{ to: context.job && context.job.ownr_ea },
"e"
);
}}

View File

@@ -50,6 +50,8 @@ const ret = {
"shop:rbac": 5,
"shop:templates": 4,
"temporarydocs:view": 2,
"timetickets:enter": 3,
"timetickets:list": 3,
"timetickets:edit": 4,

View File

@@ -512,6 +512,18 @@ export default function ShopInfoRbacComponent({ form }) {
>
<InputNumber />
</Form.Item>
<Form.Item
label={t("bodyshop.fields.rbac.temporarydocs.view")}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
name={["md_rbac", "temporarydocs:view"]}
>
<InputNumber />
</Form.Item>
</LayoutFormRow>
</div>
);

View File

@@ -105,6 +105,7 @@ export function JobDetailCards({ setPrintCenterContext }) {
actions: { refetch: refetch },
context: {
id: data.jobs_by_pk.id,
job: data.jobs_by_pk,
type: "job",
},
});

View File

@@ -45,3 +45,33 @@ export const DELETE_DOCUMENT = gql`
}
}
`;
export const QUERY_TEMPORARY_DOCS = gql`
query QUERY_TEMPORARY_DOCS {
documents(
where: { jobid: { _is_null: true } }
order_by: { updated_at: desc }
) {
id
name
key
type
extension
}
}
`;
export const UPDATE_DOCUMENT = gql`
mutation UPDATE_DOCUMENT($id: uuid!, $document: documents_set_input!) {
update_documents_by_pk(pk_columns: { id: $id }, _set: $document) {
billid
bodyshopid
extension
id
jobid
name
type
key
}
}
`;

View File

@@ -119,6 +119,9 @@ const AccountingPayments = lazy(() =>
const AllJobs = lazy(() => import("../jobs-all/jobs-all.container"));
const JobsClose = lazy(() => import("../jobs-close/jobs-close.container"));
const JobsAdmin = lazy(() => import("../jobs-admin/jobs-admin.page"));
const TempDocs = lazy(() =>
import("../temporary-docs/temporary-docs.container")
);
const ShopCsiPageContainer = lazy(() =>
import("../shop-csi/shop-csi.container.page")
@@ -234,6 +237,11 @@ export function Manage({ match, conflict }) {
component={JobsDetailPage}
/>
</Switch>
<Route
exact
path={`${match.path}/temporarydocs/`}
component={TempDocs}
/>
<Route
exact
path={`${match.path}/courtesycars/`}

View File

@@ -0,0 +1,25 @@
import { useQuery } from "@apollo/react-hooks";
import React from "react";
import AlertComponent from "../../components/alert/alert.component";
import JobsDocumentsComponent from "../../components/jobs-documents-gallery/jobs-documents-gallery.component";
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
import { QUERY_TEMPORARY_DOCS } from "../../graphql/documents.queries";
export default function TemporaryDocsComponent() {
const { loading, error, data, refetch } = useQuery(QUERY_TEMPORARY_DOCS);
if (loading) return <LoadingSpinner />;
if (error) return <AlertComponent message={error.message} type="error" />;
return (
<div>
<div>Buttons to move and assign things.</div>
<JobsDocumentsComponent
data={data ? data.documents : []}
jobId={null}
billId={null}
refetch={refetch}
/>
</div>
);
}

View File

@@ -0,0 +1,45 @@
import React, { useEffect } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
import {
setBreadcrumbs,
setSelectedHeader,
} from "../../redux/application/application.actions";
import { selectBodyshop } from "../../redux/user/user.selectors";
import TemporaryDocsComponent from "./temporary-docs.component";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
});
const mapDispatchToProps = (dispatch) => ({
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
setSelectedHeader: (key) => dispatch(setSelectedHeader(key)),
});
export function TempDocumentsContainer({ setBreadcrumbs, setSelectedHeader }) {
const { t } = useTranslation();
useEffect(() => {
document.title = t("titles.temporarydocs");
setSelectedHeader("temporarydocs");
setBreadcrumbs([
{
link: "/manage/temporarydocs",
label: t("titles.bc.temporarydocs"),
},
]);
}, [t, setBreadcrumbs, setSelectedHeader]);
return (
<RbacWrapper action="temporarydocs:view">
<TemporaryDocsComponent />
</RbacWrapper>
);
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(TempDocumentsContainer);

View File

@@ -287,6 +287,9 @@
"templates": "Shop -> Templates",
"vendors": "Shop -> Vendors"
},
"temporarydocs": {
"view": "Temporary Docs -> View"
},
"timetickets": {
"edit": "Time Tickets -> Edit",
"enter": "Time Tickets -> Enter",
@@ -594,6 +597,7 @@
"actions": {
"delete": "Delete Selected Documents",
"download": "Download Selected Documents",
"reassign": "Reassign to another Job",
"selectallimages": "Select All Images",
"selectallotherdocuments": "Select All Other Documents"
},
@@ -607,6 +611,7 @@
"labels": {
"confirmdelete": "Are you sure you want to delete these documents. This CANNOT be undone.",
"doctype": "Document Type",
"newjobid": "Assign to Job",
"upload": "Upload"
},
"successes": {
@@ -1237,6 +1242,7 @@
"shop_csi": "CSI",
"shop_templates": "Templates",
"shop_vendors": "Vendors",
"temporarydocs": "Temporary Documents",
"timetickets": "Time Tickets",
"vehicles": "Vehicles"
},
@@ -1672,6 +1678,7 @@
"shop-csi": "CSI Responses",
"shop-templates": "Shop Templates",
"shop-vendors": "Vendors",
"temporarydocs": "Temporary Documents",
"timetickets": "Time Tickets",
"vehicle-details": "Vehicle: {{vehicle}}",
"vehicles": "Vehicles"
@@ -1709,6 +1716,7 @@
"shop-csi": "CSI Responses | $t(titles.app)",
"shop-templates": "Shop Templates | $t(titles.app)",
"shop_vendors": "Vendors | $t(titles.app)",
"temporarydocs": "Temporary Documents | $t(titles.app)",
"timetickets": "Time Tickets | $t(titles.app)",
"vehicledetail": "Vehicle Details {{vehicle}} | $t(titles.app)",
"vehicles": "All Vehicles | $t(titles.app)"

View File

@@ -287,6 +287,9 @@
"templates": "",
"vendors": ""
},
"temporarydocs": {
"view": ""
},
"timetickets": {
"edit": "",
"enter": "",
@@ -594,6 +597,7 @@
"actions": {
"delete": "",
"download": "",
"reassign": "",
"selectallimages": "",
"selectallotherdocuments": ""
},
@@ -607,6 +611,7 @@
"labels": {
"confirmdelete": "",
"doctype": "",
"newjobid": "",
"upload": "Subir"
},
"successes": {
@@ -1237,6 +1242,7 @@
"shop_csi": "",
"shop_templates": "",
"shop_vendors": "Vendedores",
"temporarydocs": "",
"timetickets": "",
"vehicles": "Vehículos"
},
@@ -1672,6 +1678,7 @@
"shop-csi": "",
"shop-templates": "",
"shop-vendors": "",
"temporarydocs": "",
"timetickets": "",
"vehicle-details": "",
"vehicles": ""
@@ -1709,6 +1716,7 @@
"shop-csi": "",
"shop-templates": "",
"shop_vendors": "Vendedores | $t(titles.app)",
"temporarydocs": "",
"timetickets": "",
"vehicledetail": "Detalles del vehículo {{vehicle}} | $t(titles.app)",
"vehicles": "Todos los vehiculos | $t(titles.app)"

View File

@@ -287,6 +287,9 @@
"templates": "",
"vendors": ""
},
"temporarydocs": {
"view": ""
},
"timetickets": {
"edit": "",
"enter": "",
@@ -594,6 +597,7 @@
"actions": {
"delete": "",
"download": "",
"reassign": "",
"selectallimages": "",
"selectallotherdocuments": ""
},
@@ -607,6 +611,7 @@
"labels": {
"confirmdelete": "",
"doctype": "",
"newjobid": "",
"upload": "Télécharger"
},
"successes": {
@@ -1237,6 +1242,7 @@
"shop_csi": "",
"shop_templates": "",
"shop_vendors": "Vendeurs",
"temporarydocs": "",
"timetickets": "",
"vehicles": "Véhicules"
},
@@ -1672,6 +1678,7 @@
"shop-csi": "",
"shop-templates": "",
"shop-vendors": "",
"temporarydocs": "",
"timetickets": "",
"vehicle-details": "",
"vehicles": ""
@@ -1709,6 +1716,7 @@
"shop-csi": "",
"shop-templates": "",
"shop_vendors": "Vendeurs | $t(titles.app)",
"temporarydocs": "",
"timetickets": "",
"vehicledetail": "Détails du véhicule {{vehicle} | $t(titles.app)",
"vehicles": "Tous les véhicules | $t(titles.app)"

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."documents" ALTER COLUMN "jobid" SET NOT NULL;
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."documents" ALTER COLUMN "jobid" DROP NOT NULL;
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."documents" DROP COLUMN "bodyshopid";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."documents" ADD COLUMN "bodyshopid" uuid NULL;
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: alter table "public"."documents" drop constraint "documents_bodyshopid_fkey";
type: run_sql

View File

@@ -0,0 +1,10 @@
- args:
cascade: false
read_only: false
sql: |-
alter table "public"."documents"
add constraint "documents_bodyshopid_fkey"
foreign key ("bodyshopid")
references "public"."bodyshops"
("id") on update cascade on delete cascade;
type: run_sql

View File

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

View File

@@ -0,0 +1,36 @@
- args:
role: user
table:
name: documents
schema: public
type: drop_insert_permission
- args:
permission:
check:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- billid
- bodyshopid
- created_at
- extension
- id
- jobid
- key
- name
- type
- updated_at
- uploaded_by
set: {}
role: user
table:
name: documents
schema: public
type: create_insert_permission

View File

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

View File

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

View File

@@ -0,0 +1,12 @@
- args:
relationship: documents
table:
name: bodyshops
schema: public
type: drop_relationship
- args:
relationship: bodyshop
table:
name: documents
schema: public
type: drop_relationship

View File

@@ -0,0 +1,20 @@
- args:
name: documents
table:
name: bodyshops
schema: public
using:
foreign_key_constraint_on:
column: bodyshopid
table:
name: documents
schema: public
type: create_array_relationship
- args:
name: bodyshop
table:
name: documents
schema: public
using:
foreign_key_constraint_on: bodyshopid
type: create_object_relationship

View File

@@ -0,0 +1,36 @@
- args:
role: user
table:
name: documents
schema: public
type: drop_insert_permission
- args:
permission:
check:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- billid
- bodyshopid
- created_at
- extension
- id
- jobid
- key
- name
- type
- updated_at
- uploaded_by
set: {}
role: user
table:
name: documents
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,45 @@
- args:
role: user
table:
name: documents
schema: public
type: drop_insert_permission
- args:
permission:
check:
_or:
- job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
- bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- billid
- bodyshopid
- created_at
- extension
- id
- jobid
- key
- name
- type
- updated_at
- uploaded_by
set: {}
role: user
table:
name: documents
schema: public
type: create_insert_permission

View File

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

View File

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

View File

@@ -0,0 +1,23 @@
- args:
role: user
table:
name: documents
schema: public
type: drop_delete_permission
- args:
permission:
filter:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: documents
schema: public
type: create_delete_permission

View File

@@ -0,0 +1,32 @@
- args:
role: user
table:
name: documents
schema: public
type: drop_delete_permission
- args:
permission:
filter:
_or:
- job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
- bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: documents
schema: public
type: create_delete_permission

View File

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

View File

@@ -0,0 +1,45 @@
- args:
role: user
table:
name: documents
schema: public
type: drop_update_permission
- args:
permission:
columns:
- extension
- key
- name
- type
- uploaded_by
- created_at
- updated_at
- billid
- bodyshopid
- id
- jobid
filter:
_or:
- job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
- bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
set: {}
role: user
table:
name: documents
schema: public
type: create_update_permission

View File

@@ -670,6 +670,13 @@ tables:
table:
schema: public
name: csiquestions
- name: documents
using:
foreign_key_constraint_on:
column: bodyshopid
table:
schema: public
name: documents
- name: employees
using:
foreign_key_constraint_on:
@@ -1433,6 +1440,9 @@ tables:
- name: bill
using:
foreign_key_constraint_on: billid
- name: bodyshop
using:
foreign_key_constraint_on: bodyshopid
- name: job
using:
foreign_key_constraint_on: jobid
@@ -1440,8 +1450,17 @@ tables:
- role: user
permission:
check:
job:
bodyshop:
_or:
- job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
- bodyshop:
associations:
_and:
- user:
@@ -1451,6 +1470,7 @@ tables:
_eq: true
columns:
- billid
- bodyshopid
- created_at
- extension
- id
@@ -1465,6 +1485,7 @@ tables:
permission:
columns:
- billid
- bodyshopid
- created_at
- extension
- id
@@ -1475,8 +1496,17 @@ tables:
- updated_at
- uploaded_by
filter:
job:
bodyshop:
_or:
- job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
- bodyshop:
associations:
_and:
- user:
@@ -1487,10 +1517,30 @@ tables:
update_permissions:
- role: user
permission:
columns: []
columns:
- extension
- key
- name
- type
- uploaded_by
- created_at
- updated_at
- billid
- bodyshopid
- id
- jobid
filter:
job:
bodyshop:
_or:
- job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
- bodyshop:
associations:
_and:
- user:
@@ -1503,8 +1553,17 @@ tables:
- role: user
permission:
filter:
job:
bodyshop:
_or:
- job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
- bodyshop:
associations:
_and:
- user:

View File

@@ -76,6 +76,7 @@ app.post(
media.createSignedUploadURL
);
app.post("/media/download", fb.validateFirebaseIdToken, media.downloadFiles);
app.post("/media/rename", fb.validateFirebaseIdToken, media.renameKeys);
//SMS/Twilio Paths
var smsReceive = require("./server/sms/receive");

View File

@@ -28,3 +28,31 @@ exports.downloadFiles = (req, res) => {
});
res.send(url);
};
exports.renameKeys = async (req, res) => {
const { documents } = req.body;
//{id: "", from: "", to:""}
const proms = [];
console.log("Documents", documents);
documents.forEach((d) => {
proms.push(
(async () => {
try {
const res = {
id: d.id,
...(await cloudinary.uploader.rename(d.from, d.to)),
};
return res;
} catch (error) {
return { id: d.id, from: d.from, error: error };
}
})()
);
});
let result;
result = await Promise.all(proms);
res.send(result);
};