Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions apps/OpenSign/src/primitives/GetReportDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ const ReportTable = ({
if (!templateData.error) {
const Doc = templateData;

let placeholdersArr = [];
if (Doc.Placeholders?.length > 0) {
placeholdersArr = Doc.Placeholders;
}
let signers = [];
if (Doc.Signers?.length > 0) {
Doc.Signers?.forEach((x) => {
Expand All @@ -107,6 +103,11 @@ const ReportTable = ({
signers.push(obj);
}
});
}

let placeholdersArr = [];
if (Doc.Placeholders?.length > 0) {
placeholdersArr = Doc.Placeholders;
const data = {
Name: Doc.Name,
URL: Doc.URL,
Expand Down
196 changes: 108 additions & 88 deletions apps/OpenSignServer/cloud/parsefunction/pdf/PDF.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import SignPDF from './SignPDF.min.cjs';
import fs from 'node:fs';
import axios from 'axios';
import FormData from 'form-data';
import plainplaceholder from './customSignPdf/plainplaceholder.min.js';
// import plainplaceholder from './customSignPdf/plainplaceholder.min.js';
import { plainAddPlaceholder } from 'node-signpdf/dist/helpers/index.js';
const serverUrl = process.env.SERVER_URL,
APPID = process.env.APP_ID,
Expand All @@ -19,20 +19,20 @@ async function uploadFile(a) {
console.log('err ', e), fs.unlinkSync(a);
}
}
async function updateDoc(t, s, r, i, o, n) {
async function updateDoc(t, s, r, i, n, o) {
try {
var d = {
UserPtr: { __type: 'Pointer', className: n, objectId: r },
UserPtr: { __type: 'Pointer', className: o, objectId: r },
SignedUrl: s,
Activity: 'Signed',
ipAddress: i,
};
let e;
var l = (e = o.AuditTrail && 0 < o.AuditTrail.length ? [...o.AuditTrail, d] : [d]).filter(
var l = (e = n.AuditTrail && 0 < n.AuditTrail.length ? [...n.AuditTrail, d] : [d]).filter(
e => 'Signed' === e.Activity
);
let a = !1;
!((o.Signers && 0 < o.Signers.length && l.length !== o.Signers.length) || !(a = !0));
!((n.Signers && 0 < n.Signers.length && l.length !== n.Signers.length) || !(a = !0));
var p = { SignedUrl: s, AuditTrail: e, IsCompleted: a };
await axios.put(serverUrl + '/classes/contracts_Document/' + t, p, {
headers: {
Expand Down Expand Up @@ -96,115 +96,135 @@ async function sendCompletedMail(e) {
},
});
}
async function PDF(s, r) {
async function PDF(i, n) {
try {
var i = s.params.sign,
e = s.params.docId,
o = s.params.userId,
n = await axios.get(serverUrl + '/classes/contracts_Document/' + e + '?include=ExtUserPtr', {
headers: {
'Content-Type': 'application/json',
'X-Parse-Application-Id': APPID,
'X-Parse-Master-Key': masterKEY,
},
}),
d = await axios.get(serverUrl + '/users/me', {
i.params.sign;
var e = i.params.docId,
a = i.params.userId,
o = await axios.get(
serverUrl + '/classes/contracts_Document/' + e + '?include=ExtUserPtr,Signers',
{
headers: {
'Content-Type': 'application/json',
'X-Parse-Application-Id': APPID,
'X-Parse-Master-Key': masterKEY,
},
}
),
t = await axios.get(serverUrl + '/users/me', {
headers: {
'X-Parse-Application-Id': APPID,
'X-Parse-Session-Token': s.headers.sessiontoken,
'X-Parse-Session-Token': i.headers.sessiontoken,
},
});
if (!d.data || !d.data.objectId) return { status: 'error', message: 'this user not allowed!' };
if (!t.data || !t.data.objectId) return { status: 'error', message: 'this user not allowed!' };
{
var l,
var d,
l,
p,
c,
m = JSON.stringify({ objectId: o });
let a, t;
t = o
? (l = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + m, {
c = JSON.stringify({ objectId: a });
let s, r;
r = a
? (d = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + c, {
headers: {
'X-Parse-Application-Id': APPID,
'X-Parse-Session-Token': s.headers.sessiontoken,
'X-Parse-Session-Token': i.headers.sessiontoken,
},
})).data && 0 < l.data.results.length
? ((a = l), 'contracts_Contactbook')
: ((a = await axios.get(serverUrl + '/classes/contracts_Users?where=' + m, {
headers: {
'X-Parse-Application-Id': APPID,
'X-Parse-Master-Key': masterKEY,
},
})).data && 0 < d.data.results.length
? ((s = d), 'contracts_Contactbook')
: ((s = await axios.get(serverUrl + '/classes/contracts_Users?where=' + c, {
headers: { 'X-Parse-Application-Id': APPID, 'X-Parse-Master-Key': masterKEY },
})),
'contracts_Users')
: ((p = JSON.stringify({
UserId: { __type: 'Pointer', className: '_User', objectId: d.data.objectId },
: ((l = JSON.stringify({
UserId: { __type: 'Pointer', className: '_User', objectId: t.data.objectId },
})),
(c = await axios.get(serverUrl + '/classes/contracts_Users?where=' + p, {
headers: {
'X-Parse-Application-Id': APPID,
'X-Parse-Master-Key': masterKEY,
},
})).data && 0 < c.data.results.length
? ((a = c), 'contracts_Users')
: ((a = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + p, {
(p = await axios.get(serverUrl + '/classes/contracts_Users?where=' + l, {
headers: { 'X-Parse-Application-Id': APPID, 'X-Parse-Master-Key': masterKEY },
})).data && 0 < p.data.results.length
? ((s = p), 'contracts_Users')
: ((s = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + l, {
headers: {
'X-Parse-Application-Id': APPID,
'X-Parse-Session-Token': s.headers.sessiontoken,
'X-Parse-Session-Token': i.headers.sessiontoken,
},
})),
'contracts_Contactbook'));
var g = a.data.results[0].Name,
h = a.data.results[0].Email;
if (!s.params.pdfFile) return { status: 'error', message: 'pdf file not present!' };
var m = s.data.results[0].Name,
g = s.data.results[0].Email;
if (!i.params.pdfFile) return { status: 'error', message: 'pdf file not present!' };
{
let e = Buffer.from(s.params.pdfFile, 'base64');
let e = Buffer.from(i.params.pdfFile, 'base64');
var u = process.env.PFX_BASE64,
f = Buffer.from(u, 'base64');
e = i
? plainplaceholder({
pdfBuffer: e,
reason: 'Digitally signed by Open sign for ' + g + ' <' + h + '>',
location: 'test location',
signatureLength: 1e4,
sign: i,
})
: plainAddPlaceholder({
pdfBuffer: e,
reason: 'Digitally signed by Open sign for ' + g + ' <' + h + '>',
location: 'test location',
signatureLength: 1e4,
});
var y = await new SignPDF(e, f).signPDF(),
v = `./exports/exported_file_${Math.floor(5e3 * Math.random())}.pdf`,
P = (fs.writeFileSync(v, y), await uploadFile(v));
if (P && P.imageUrl) {
const r = await updateDoc(
s.params.docId,
P.imageUrl,
a.data.results[0].objectId,
s.headers['x-real-ip'],
n.data,
t
h = Buffer.from(u, 'base64'),
f = {
UserPtr: { __type: 'Pointer', className: r, objectId: s.data.results[0].objectId },
SignedUrl: '',
Activity: 'Signed',
ipAddress: i.headers['x-real-ip'],
};
let a;
var y = (a =
o.data.AuditTrail && 0 < o.data.AuditTrail.length
? [...o.data.AuditTrail, f]
: [f]).filter(e => 'Signed' === e.Activity);
let t = !1;
!(
(o.data.Signers && 0 < o.data.Signers.length && y.length !== o.data.Signers.length) ||
!(t = !0)
);
var v,
P,
x = `./exports/exported_file_${Math.floor(5e3 * Math.random())}.pdf`,
A =
(t
? ((v = o.data.Signers?.map(e => e.Name + ' <' + e.Email + '>')),
(e =
v && 0 < v.length
? plainAddPlaceholder({
pdfBuffer: e,
reason: 'Digitally signed by Open sign for ' + v?.join(', '),
location: 'location',
signatureLength: 1e4,
})
: plainAddPlaceholder({
pdfBuffer: e,
reason: 'Digitally signed by Open sign for ' + m + ' <' + g + '>',
location: 'location',
signatureLength: 1e4,
})),
(P = await new SignPDF(e, h).signPDF()),
fs.writeFileSync(x, P))
: fs.writeFileSync(x, e),
await uploadFile(x));
if (A && A.imageUrl) {
const n = await updateDoc(
i.params.docId,
A.imageUrl,
s.data.results[0].objectId,
i.headers['x-real-ip'],
o.data,
r
);
return (
sendMail({
url: P.imageUrl,
sender: { Mail: n.data.ExtUserPtr.Email, Name: n.data.ExtUserPtr.Name },
pdfName: n.data.Name,
receiver: h,
url: A.imageUrl,
sender: { Mail: o.data.ExtUserPtr.Email, Name: o.data.ExtUserPtr.Name },
pdfName: o.data.Name,
receiver: g,
}),
r &&
r.isCompleted &&
n &&
n.isCompleted &&
sendCompletedMail({
url: P.imageUrl,
sender: { Mail: n.data.ExtUserPtr.Email, Name: 'Open sign' },
pdfName: n.data.Name,
receiver: n.data.ExtUserPtr.Email,
url: A.imageUrl,
sender: { Mail: o.data.ExtUserPtr.Email, Name: 'Open sign' },
pdfName: o.data.Name,
receiver: o.data.ExtUserPtr.Email,
}),
fs.unlinkSync(v),
console.log('New Signed PDF created called: ' + v),
'success' === r.message
? { status: 'success', data: P.imageUrl }
fs.unlinkSync(x),
console.log('New Signed PDF created called: ' + x),
'success' === n.message
? { status: 'success', data: A.imageUrl }
: { status: 'error', message: 'please provide required parameters!' }
);
}
Expand Down
Binary file removed apps/OpenSignServer/exports/exported_file_2928.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,8 @@ const TemplatePlaceholder = () => {
// save Role in entry in signerList and user
const handleAddRole = (e) => {
e.preventDefault();
setSignerObjId('')
setContractName('')
const count = signersdata.length > 0 ? signersdata.length + 1 : 1;
const Id = randomId();
const index = signersdata.length;
Expand Down Expand Up @@ -861,7 +863,7 @@ const TemplatePlaceholder = () => {
const index = signersdata.findIndex((x) => x.Id === Id);
if (index === signersdata.length - 1) {
setUniqueId(updateSigner[updateSigner.length - 1]?.Id || "");
setIsSelectId(0);
setIsSelectId(index - 1|| 0);
} else {
setUniqueId(updateSigner[index]?.Id || "");
setIsSelectId(index);
Expand Down
12 changes: 3 additions & 9 deletions microfrontends/SignDocuments/src/Component/placeHolderSign.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,18 +317,12 @@ function PlaceHolderSign() {

//function for setting position after drop signature button over pdf
const addPositionOfSignature = (item, monitor) => {
if (isMobile) {
if (selectedEmail) {
getSignerPos(item, monitor);
} else {
setIsShowEmail(true);
}
} else {
getSignerPos(item, monitor);
}
getSignerPos(item, monitor);
};

const getSignerPos = (item, monitor) => {
setSignerObjId('')
setContractName('')
if (uniqueId) {
const signer = signersdata.find((x) => x.Id === uniqueId);
if (signer) {
Expand Down
4 changes: 2 additions & 2 deletions microfrontends/SignDocuments/src/premitives/RecipientList.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ const RecipientList = (props) => {
: nonHoverStyle(ind)
}
onClick={() => {
props.setSignerObjId(obj?.objectId);
props.setSignerObjId(obj?.objectId || "");
props.setIsSelectId(ind);
props.setContractName(obj?.className);
props.setContractName(obj?.className || "");
props.setUniqueId(obj.Id);
props.setRoleName(obj.Role);
if(props.handleModal){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ export default function TourContentWithBtn({ message, isChecked }) {
return (
<div>
<p>{message}</p>
<label style={{ textAlign: "center", display: "flex" }}>
<label style={{ textAlign: "center", display: "flex", "justifyContent":'center' }}>
<input
type="checkbox"
style={{ marginRight: 3 }}
checked={isCheck}
onChange={handleCheck}
/>{" "}
<span>Don't show</span>
<span style={{color:"#787878", fontSize: 12}}>Don't show this again</span>
</label>
</div>
);
Expand Down
4 changes: 0 additions & 4 deletions microfrontends/SignDocuments/src/utils/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,13 +765,9 @@ export const handleImageResize = (
export const handleSignYourselfImageResize = (
ref,
key,
direction,
position,
xyPostion,
index,
setXyPostion,
pdfOriginalWidth,
containerWH
) => {
const updateFilter = xyPostion[index].pos.filter(
(data) => data.key === key && data.Width && data.Height
Expand Down