datastake-daf 0.6.149 → 0.6.151
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/index.js +112 -335
- package/package.json +1 -1
- package/src/@daf/core/components/Dashboard/PdfView/index.jsx +59 -102
- package/src/@daf/core/components/Dashboard/Widget/ExpandableMapWidget/ExpandableMapWidget.stories.js +1693 -0
- package/src/@daf/core/components/Dashboard/Widget/ExpandableMapWidget/hook.js +44 -0
- package/src/@daf/core/components/Dashboard/Widget/ExpandableMapWidget/index.js +55 -0
- package/src/@daf/core/components/Dashboard/Widget/index.jsx +2 -1
- package/.vscode/settings.json +0 -13
- package/public/assets/images/SVG/403.svg +0 -20
- package/public/assets/images/SVG/404.svg +0 -11
- package/public/assets/images/SVG/CADD.svg +0 -27
- package/public/assets/images/SVG/InDevelopment.svg +0 -24
- package/public/assets/images/SVG/PME.svg +0 -21
- package/public/assets/images/SVG/comment-alt.svg +0 -3
- package/public/assets/images/SVG/comment.svg +0 -3
- package/public/assets/images/SVG/coordinator.svg +0 -3
- package/public/assets/images/SVG/implementer.svg +0 -3
- package/public/assets/images/SVG/logo-horizontal.svg +0 -1
- package/public/assets/images/SVG/partner-building.svg +0 -3
- package/public/assets/images/SVG/partner.svg +0 -5
- package/public/assets/images/SVG/unavailable-info.svg +0 -16
- package/public/assets/images/SVG/vault.svg +0 -6
- package/public/assets/images/app-navigation/mmt-logo.svg +0 -32
- package/public/assets/images/app-navigation/tazama-logo.svg +0 -31
- package/public/assets/images/app-navigation/tif-logo.svg +0 -33
- package/public/assets/images/applications/arm-prev.png +0 -0
- package/public/assets/images/applications/asm-icon.svg +0 -29
- package/public/assets/images/applications/kota-logo.svg +0 -4
- package/public/assets/images/applications/mmt-logo-2.svg +0 -5
- package/public/assets/images/applications/mmt-logo.svg +0 -6
- package/public/assets/images/applications/mmt-prev.png +0 -0
- package/public/assets/images/applications/sbgi_logo.png +0 -0
- package/public/assets/images/applications/tazama-home-img.jpeg +0 -0
- package/public/assets/images/applications/tazama-logo.svg +0 -9
- package/public/assets/images/applications/tif-app.png +0 -0
- package/public/assets/images/applications/tif-logo.svg +0 -9
- package/public/assets/images/auth-bg-2.svg +0 -296
- package/public/assets/images/auth-bg.svg +0 -303
- package/public/assets/images/countries/fr.png +0 -0
- package/public/assets/images/countries/gb.png +0 -0
- package/public/assets/images/countries/sp.png +0 -0
- package/public/assets/images/dashboard/amp-dashboard/empty.png +0 -0
- package/public/assets/images/dashboard/map-icons/amp.svg +0 -28
- package/public/assets/images/dashboard/map-icons/amp_focused.svg +0 -28
- package/public/assets/images/dashboard/map-icons/amp_location_pin.svg +0 -4
- package/public/assets/images/dashboard/map-icons/datachain-icon.svg +0 -21
- package/public/assets/images/dashboard/map-icons/ellipse.svg +0 -3
- package/public/assets/images/dashboard/map-icons/lir-icon.svg +0 -3
- package/public/assets/images/dashboard/map-icons/major-incident-events-icon.svg +0 -3
- package/public/assets/images/dashboard/map-icons/minesites-location-icon.svg +0 -21
- package/public/assets/images/dashboard/map-icons/minor-incident-events-icon.svg +0 -3
- package/public/assets/images/dashboard/map-icons/moderate-incident-events-icon.svg +0 -3
- package/public/assets/images/dashboard/map-icons/other-events-icon.svg +0 -3
- package/public/assets/images/dashboard/map-icons/other-location-icon.svg +0 -21
- package/public/assets/images/dashboard/map-icons/risk-mitigation-events-icon.svg +0 -3
- package/public/assets/images/dashboard/map-icons/sca_location_pin.svg +0 -4
- package/public/assets/images/dashboard/map-icons/villages-location-icon.svg +0 -21
- package/public/assets/images/dashboard/mine-site.svg +0 -7
- package/public/assets/images/dashboard/programs/key-data.svg +0 -12
- package/public/assets/images/dashboard/programs/key-projects.svg +0 -12
- package/public/assets/images/dashboard/scl-icons/close-icon.svg +0 -4
- package/public/assets/images/dashboard/scl-icons/dot.svg +0 -3
- package/public/assets/images/dashboard/scl-icons/empty-gallery.svg +0 -5
- package/public/assets/images/dashboard/scl-icons/location-icon.svg +0 -14
- package/public/assets/images/dashboard/scl-icons/town-dot.svg +0 -3
- package/public/assets/images/dashboard/scl-icons/town-icon.svg +0 -4
- package/public/assets/images/dashboard/scl-icons/village-icon.svg +0 -6
- package/public/assets/images/dashboard/tif-products/cobalt-bg.png +0 -0
- package/public/assets/images/dashboard/tif-products/cobalt-logo.png +0 -0
- package/public/assets/images/dashboard/tif-products/gold-bg.png +0 -0
- package/public/assets/images/dashboard/tif-products/gold-logo.png +0 -0
- package/public/assets/images/datastake-logo.svg +0 -20
- package/public/assets/images/datastake-white.svg +0 -20
- package/public/assets/images/empty-box.svg +0 -5
- package/public/assets/images/find-information/business-entity.svg +0 -4
- package/public/assets/images/find-information/civil-society.svg +0 -4
- package/public/assets/images/find-information/government.svg +0 -4
- package/public/assets/images/find-information/graphs.png +0 -0
- package/public/assets/images/find-information/individual.svg +0 -11
- package/public/assets/images/find-information/non-stated-arm-group.svg +0 -4
- package/public/assets/images/find-information/other-organisation.svg +0 -4
- package/public/assets/images/find-information/state-security.svg +0 -4
- package/public/assets/images/info-channels/investor.svg +0 -4
- package/public/assets/images/info-channels/mine.svg +0 -4
- package/public/assets/images/info-channels/source.png +0 -0
- package/public/assets/images/kota-bg.jpg +0 -0
- package/public/assets/images/kota-logo-small.svg +0 -2
- package/public/assets/images/kota-logo.svg +0 -2
- package/public/assets/images/logo-new-white-icon.svg +0 -5
- package/public/assets/images/logo-new-white.svg +0 -8
- package/public/assets/images/logo-white.svg +0 -67
- package/public/assets/images/map/assessed.png +0 -0
- package/public/assets/images/map/connected.png +0 -0
- package/public/assets/images/map/disabled.png +0 -0
- package/public/assets/images/map/identified.png +0 -0
- package/public/assets/images/map/position.png +0 -0
- package/public/assets/images/map/treasure-map.png +0 -0
- package/public/assets/images/project-share-info/due-dilligence.svg +0 -3
- package/public/assets/images/project-share-info/event.svg +0 -3
- package/public/assets/images/project-share-info/location.svg +0 -3
- package/public/assets/images/project-share-info/network.svg +0 -3
- package/public/assets/images/project-share-info/stakeholder.svg +0 -10
- package/public/assets/images/tif/antelope-mine-people.png +0 -0
- package/public/assets/images/tif/gesagu-people.png +0 -0
- package/public/assets/images/tif/ironstep-people.png +0 -0
- package/public/assets/images/tif-bg.png +0 -0
- package/public/assets/images/tif-logo-small.svg +0 -3
- package/public/assets/images/tif-logo.svg +0 -9
- package/public/assets/images/verified-user-tif.png +0 -0
- package/public/assets/images/verified-user.svg +0 -100
- package/public/favicons/android-chrome-192x192.png +0 -0
- package/public/favicons/android-chrome-512x512.png +0 -0
- package/public/favicons/apple-touch-icon.png +0 -0
- package/public/favicons/favicon-16x16.png +0 -0
- package/public/favicons/favicon-32x32.png +0 -0
- package/public/favicons/favicon.ico +0 -0
- package/public/favicons/tazama/android-chrome-192x192.png +0 -0
- package/public/favicons/tazama/android-chrome-512x512.png +0 -0
- package/public/favicons/tazama/apple-touch-icon.png +0 -0
- package/public/favicons/tazama/favicon-16x16.png +0 -0
- package/public/favicons/tazama/favicon-32x32.png +0 -0
- package/public/favicons/tazama/favicon.ico +0 -0
package/package.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
// Dashboard/PdfView/index.jsx
|
|
1
2
|
import moment from "moment";
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
5
|
import { formatClassname } from "../../../../../helpers/ClassesHelper";
|
|
5
6
|
|
|
6
|
-
const PAGE_HEIGHT = 1587;
|
|
7
|
-
// margin-top: 20, bottom: 20;
|
|
7
|
+
const PAGE_HEIGHT = 1587; // Total height of a virtual PDF page
|
|
8
8
|
const FOOTER_HEIGHT = 70;
|
|
9
9
|
const HEADER_HEIGHT = 100;
|
|
10
|
+
const ROW_SPACING = 24; // Spacing between content rows
|
|
11
|
+
const CONTENT_BOTTOM_PADDING = 30; // Extra padding at the very bottom of the last section of the document
|
|
12
|
+
|
|
13
|
+
// This is the actual height available for the *flowing content* after Puppeteer
|
|
14
|
+
// applies its margins for the header and footer.
|
|
15
|
+
const USABLE_FLOW_HEIGHT_PER_PAGE = PAGE_HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT;
|
|
10
16
|
|
|
11
17
|
const Row = ({ widgets, i, onChangeHeight = () => { } }) => {
|
|
12
18
|
const ref = useRef();
|
|
@@ -19,16 +25,22 @@ const Row = ({ widgets, i, onChangeHeight = () => { } }) => {
|
|
|
19
25
|
}
|
|
20
26
|
});
|
|
21
27
|
|
|
22
|
-
|
|
28
|
+
if (ref.current) {
|
|
29
|
+
observer.observe(ref.current);
|
|
30
|
+
}
|
|
23
31
|
|
|
24
|
-
return () =>
|
|
32
|
+
return () => {
|
|
33
|
+
if (ref.current) {
|
|
34
|
+
observer.disconnect();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
25
37
|
}, []);
|
|
26
38
|
|
|
27
39
|
useEffect(() => {
|
|
28
40
|
if (height) {
|
|
29
41
|
onChangeHeight(i, { height, ref });
|
|
30
42
|
}
|
|
31
|
-
}, [height])
|
|
43
|
+
}, [height, i, onChangeHeight]);
|
|
32
44
|
|
|
33
45
|
return (
|
|
34
46
|
<section ref={ref} style={widgets.style}>
|
|
@@ -40,6 +52,8 @@ const Row = ({ widgets, i, onChangeHeight = () => { } }) => {
|
|
|
40
52
|
export default function PdfView({
|
|
41
53
|
config = [],
|
|
42
54
|
customClassName,
|
|
55
|
+
// No longer needed to directly render title/imgSrc/etc within PdfView as Puppeteer handles it
|
|
56
|
+
// but kept in props for completeness if other parts of the app use them.
|
|
43
57
|
title = 'Title',
|
|
44
58
|
imgSrc = '',
|
|
45
59
|
userId = 'IDD-0000000',
|
|
@@ -48,56 +62,54 @@ export default function PdfView({
|
|
|
48
62
|
downloadId = 'DWL-00000123',
|
|
49
63
|
}) {
|
|
50
64
|
const [sectionsConfig, setSectionsConfig] = useState({});
|
|
51
|
-
const [
|
|
65
|
+
const [pagesCount, setPagesCount] = useState(1); // Track total pages for Puppeteer footer
|
|
52
66
|
|
|
53
67
|
const doSizing = useCallback(() => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
let _page = 1;
|
|
57
|
-
|
|
68
|
+
// Ensure keys are processed in order
|
|
69
|
+
const keys = Object.keys(sectionsConfig).sort((a,b) => parseInt(a) - parseInt(b));
|
|
58
70
|
if (keys.length === config.length) {
|
|
59
|
-
let
|
|
71
|
+
let currentPageContentHeight = 0;
|
|
72
|
+
let currentPage = 1;
|
|
60
73
|
|
|
74
|
+
// Reset all page-break styles before recalculating
|
|
61
75
|
keys.forEach(k => {
|
|
62
76
|
const { ref } = sectionsConfig[k];
|
|
63
|
-
ref.current
|
|
64
|
-
|
|
65
|
-
|
|
77
|
+
if (ref.current) {
|
|
78
|
+
ref.current.style.pageBreakBefore = 'auto'; // Reset to default
|
|
79
|
+
ref.current.style.marginTop = '0px'; // Clear any previous dynamic margins
|
|
80
|
+
ref.current.style.paddingBottom = '0px'; // Clear any previous dynamic paddings
|
|
81
|
+
}
|
|
82
|
+
});
|
|
66
83
|
|
|
67
84
|
keys.forEach((k, i) => {
|
|
68
85
|
const { height, ref } = sectionsConfig[k];
|
|
86
|
+
if (!ref.current) return;
|
|
69
87
|
|
|
70
|
-
|
|
71
|
-
ref.current.style.marginTop = `${HEADER_HEIGHT}px`;
|
|
72
|
-
incrHeight += HEADER_HEIGHT;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const newHeight = incrHeight + height;
|
|
88
|
+
let spaceNeededForThisSection = height;
|
|
76
89
|
|
|
77
|
-
|
|
78
|
-
|
|
90
|
+
// Add ROW_SPACING *after* each section, except the very last one.
|
|
91
|
+
if (i < keys.length - 1) {
|
|
92
|
+
spaceNeededForThisSection += ROW_SPACING;
|
|
93
|
+
} else {
|
|
94
|
+
// Add CONTENT_BOTTOM_PADDING after the very last section of the document.
|
|
95
|
+
spaceNeededForThisSection += CONTENT_BOTTOM_PADDING;
|
|
79
96
|
}
|
|
80
97
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const { ref: topRef } = sectionsConfig[keys[i - 1]];
|
|
89
|
-
topRef.current.style.marginBottom = `${dif + HEADER_HEIGHT - 24}px`;
|
|
90
|
-
incrHeight = height + 24 + HEADER_HEIGHT;
|
|
91
|
-
// console.log('margin', dif);
|
|
92
|
-
}
|
|
98
|
+
// If placing this section on the current page would exceed the usable content area,
|
|
99
|
+
// mark it to start on a new page.
|
|
100
|
+
if (currentPageContentHeight + spaceNeededForThisSection > USABLE_FLOW_HEIGHT_PER_PAGE) {
|
|
101
|
+
ref.current.style.pageBreakBefore = 'always';
|
|
102
|
+
currentPage++;
|
|
103
|
+
// Reset current page content height to just what this new section takes.
|
|
104
|
+
currentPageContentHeight = spaceNeededForThisSection;
|
|
93
105
|
} else {
|
|
94
|
-
|
|
106
|
+
// This section fits on the current page.
|
|
107
|
+
currentPageContentHeight += spaceNeededForThisSection;
|
|
95
108
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
setPages(_pages);
|
|
109
|
+
});
|
|
110
|
+
setPagesCount(currentPage);
|
|
99
111
|
}
|
|
100
|
-
}, [sectionsConfig]);
|
|
112
|
+
}, [sectionsConfig, config.length]);
|
|
101
113
|
|
|
102
114
|
useEffect(() => {
|
|
103
115
|
doSizing();
|
|
@@ -128,70 +140,14 @@ export default function PdfView({
|
|
|
128
140
|
);
|
|
129
141
|
}, [config, onChangeHeight]);
|
|
130
142
|
|
|
131
|
-
// <div className="daf-analysis">
|
|
132
|
-
// <Header title={t('Dashboard Title')} />
|
|
133
|
-
|
|
134
|
-
// <div className="content">
|
|
135
|
-
// <div className="view-content">
|
|
136
|
-
// <div className="daf-analysis-layout">
|
|
137
|
-
// <div className='sections-cont w-pt'>
|
|
138
|
-
// <section>
|
|
139
|
-
|
|
140
143
|
return (
|
|
141
144
|
<div className={contClassName} style={{ position: 'relative' }}>
|
|
142
|
-
{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
className="flex-row dashboard-header"
|
|
149
|
-
>
|
|
150
|
-
<div className="flex flex-column justify-center flex-1">
|
|
151
|
-
<h2>{title}</h2>
|
|
152
|
-
</div>
|
|
153
|
-
<div className="flex flex-column justify-center">
|
|
154
|
-
<img src={imgSrc} alt="logo" />
|
|
155
|
-
</div>
|
|
156
|
-
</div>
|
|
157
|
-
<div
|
|
158
|
-
style={{ top: (page * PAGE_HEIGHT) - FOOTER_HEIGHT, width: '100%', height: FOOTER_HEIGHT, position: 'absolute', left: 0, zIndex: 1000000 }}
|
|
159
|
-
key={`footers-${page}`}
|
|
160
|
-
className="dashboard-footer flex-row"
|
|
161
|
-
>
|
|
162
|
-
<div className="flex flex-column justify-center">
|
|
163
|
-
<h5>{moment().format('DD MMM YYYY')}</h5>
|
|
164
|
-
</div>
|
|
165
|
-
<div className="flex flex-column justify-center">
|
|
166
|
-
<div className="flex gap-2">
|
|
167
|
-
<h5>
|
|
168
|
-
User ID:
|
|
169
|
-
{' '}
|
|
170
|
-
<strong>{userId}</strong>
|
|
171
|
-
</h5>
|
|
172
|
-
<h5>
|
|
173
|
-
Account ID:
|
|
174
|
-
{' '}
|
|
175
|
-
<strong>{accountId}</strong>
|
|
176
|
-
</h5>
|
|
177
|
-
<h5>
|
|
178
|
-
Document ID:
|
|
179
|
-
{' '}
|
|
180
|
-
<strong>{documentId}</strong>
|
|
181
|
-
</h5>
|
|
182
|
-
<h5>
|
|
183
|
-
Download ID:
|
|
184
|
-
{' '}
|
|
185
|
-
<strong>{downloadId}</strong>
|
|
186
|
-
</h5>
|
|
187
|
-
</div>
|
|
188
|
-
</div>
|
|
189
|
-
<div className="flex flex-column justify-center">
|
|
190
|
-
<h5>{page}</h5>
|
|
191
|
-
</div>
|
|
192
|
-
</div>
|
|
193
|
-
</>
|
|
194
|
-
))}
|
|
145
|
+
{/* Container for content, Puppeteer reads data-page-count from this */}
|
|
146
|
+
<div id="pdf-content-root" data-page-count={pagesCount}>
|
|
147
|
+
{renderDashboard()}
|
|
148
|
+
</div>
|
|
149
|
+
{/* The absolute positioned headers and footers are removed from here.
|
|
150
|
+
Puppeteer's headerTemplate and footerTemplate will now handle them. */}
|
|
195
151
|
</div>
|
|
196
152
|
);
|
|
197
153
|
}
|
|
@@ -204,4 +160,5 @@ PdfView.propTypes = {
|
|
|
204
160
|
userId: PropTypes.string,
|
|
205
161
|
accountId: PropTypes.string,
|
|
206
162
|
documentId: PropTypes.string,
|
|
207
|
-
|
|
163
|
+
downloadId: PropTypes.string,
|
|
164
|
+
}
|