diff --git a/frontend/app/components/hocs/withReport.tsx b/frontend/app/components/hocs/withReport.tsx index d5f77adc9..4984796d7 100644 --- a/frontend/app/components/hocs/withReport.tsx +++ b/frontend/app/components/hocs/withReport.tsx @@ -4,6 +4,8 @@ import { jsPDF } from "jspdf"; import { useStore } from 'App/mstore'; import { observer, useObserver } from 'mobx-react-lite'; import { connect } from 'react-redux'; +import { fileNameFormat } from 'App/utils'; +import { toast } from 'react-toastify'; interface Props { site: any } @@ -17,21 +19,32 @@ export default function withReport
(
const dashboard: any = useObserver(() => dashboardStore.selectedDashboard);
const widgets: any = useObserver(() => dashboard?.widgets);
const period = useObserver(() => dashboardStore.period);
- console.log('site', site)
const addFooters = (doc) => {
const pageCount = doc.internal.getNumberOfPages();
for(var i = 1; i <= pageCount; i++) {
doc.setPage(i);
- doc.setFontSize(10);
+ doc.setFontSize(8);
doc.setTextColor(136,136,136);
- doc.text('Page ' + String(i) + ' of ' + String(pageCount), 196,285,null,null,"right");
+ doc.text('Page ' + String(i) + ' of ' + String(pageCount), 200,290,null,null,"right");
+ doc.addImage('/logo-open-replay-grey.png', 'png', 10, 288, 20, 0);
}
}
+
+ const renderPromise = async (): Promise (
doc.addMetadata('Keywords', 'OpenReplay Report');
doc.addMetadata('Creator', 'OpenReplay');
doc.addMetadata('Producer', 'OpenReplay');
- doc.addMetadata('CreationDate', new Date().toISOString());
+ doc.addMetadata('CreationDate', now);
const parentElement = document.getElementById('report') as HTMLElement;
@@ -71,8 +84,12 @@ export default function withReport (
pageDiv.id = `page-${index}`;
pageDiv.style.backgroundColor = '#f6f6f6';
pageDiv.style.gridAutoRows = 'min-content';
- pageDiv.style.padding = '30px';
+ pageDiv.style.padding = '50px';
pageDiv.style.height = '490mm';
+
+ if (index > 0) {
+ pageDiv.style.paddingTop = '100px';
+ }
if (index === 0) {
const header = document.getElementById('report-header')?.cloneNode(true) as HTMLElement;
@@ -93,8 +110,9 @@ export default function withReport (
doc.addImage(pageImage, 'PNG', 0, 0, 210, 0);
if (i === pages.length - 1) {
addFooters(doc);
- doc.save('report.pdf');
+ doc.save(fileNameFormat(dashboard.name + '_Report_' + Date.now(), '.pdf'));
rportLayer!.innerHTML = '';
+ cb();
} else {
doc.addPage();
}
@@ -105,17 +123,18 @@ export default function withReport (
return (
<>
(
opacity: '0',
}}
>
+