diff --git a/opencti-platform/opencti-front/src/components/ExportButtons.jsx b/opencti-platform/opencti-front/src/components/ExportButtons.jsx index 4b7bae10ac7b..cc39e0ae5747 100644 --- a/opencti-platform/opencti-front/src/components/ExportButtons.jsx +++ b/opencti-platform/opencti-front/src/components/ExportButtons.jsx @@ -12,7 +12,7 @@ import Tooltip from '@mui/material/Tooltip'; import ToggleButton from '@mui/material/ToggleButton'; import themeLight from './ThemeLight'; import themeDark from './ThemeDark'; -import { commitLocalUpdate } from '../relay/environment'; +import { commitLocalUpdate, MESSAGING$ } from '../relay/environment'; import { exportImage, exportPdf } from '../utils/Image'; import inject18n from './i18n'; import Loader from './Loader'; @@ -104,6 +104,7 @@ class ExportButtons extends Component { } handleOpenPdf(event) { + console.log('ANGIE - handleOpenPdf'); this.setState({ anchorElPdf: event.currentTarget }); } @@ -112,9 +113,10 @@ class ExportButtons extends Component { } exportPdf(domElementId, name, theme, background) { + console.log('ANGIE - exportPdf start'); this.setState({ exporting: true }); this.handleClosePdf(); - const { theme: currentTheme, pixelRatio = 1 } = this.props; + const { theme: currentTheme, pixelRatio = 1, t } = this.props; let timeout = 4000; if (theme !== currentTheme.palette.mode) { timeout = 6000; @@ -124,9 +126,11 @@ class ExportButtons extends Component { me.setValue(theme, 'theme'); }); } + console.log('ANGIE - exportPdf -1-'); setTimeout(() => { const buttons = document.getElementById('export-buttons'); buttons.setAttribute('style', 'display: none'); + console.log('ANGIE - exportPdf -2-'); exportPdf( domElementId, name, @@ -139,14 +143,17 @@ class ExportButtons extends Component { pixelRatio, this.adjust, ).then(() => { + console.log('ANGIE - exportPdf -3- then'); buttons.setAttribute('style', 'display: block'); - commitLocalUpdate((store) => { - const me = store.getRoot().getLinkedRecord('me'); - me.setValue(false, 'exporting'); - me.setValue(currentTheme.palette.mode, 'theme'); + }).catch(() => MESSAGING$.notifyError(t('Dashboard cannot be exported'))) + .finally(() => { + commitLocalUpdate((store) => { + const me = store.getRoot().getLinkedRecord('me'); + me.setValue(false, 'exporting'); + me.setValue(currentTheme.palette.mode, 'theme'); + }); + this.setState({ exporting: false }); }); - this.setState({ exporting: false }); - }); }, timeout); } diff --git a/opencti-platform/opencti-front/src/utils/Charts.jsx b/opencti-platform/opencti-front/src/utils/Charts.jsx index 04ca7a9593bd..01d55fd5d26a 100644 --- a/opencti-platform/opencti-front/src/utils/Charts.jsx +++ b/opencti-platform/opencti-front/src/utils/Charts.jsx @@ -786,7 +786,7 @@ export const donutChartOptions = ( legendPosition = 'bottom', reversed = false, chartColors = [], - displayLegend = true, + displayLegend = false, displayLabels = true, displayValue = true, displayTooltip = true, diff --git a/opencti-platform/opencti-front/src/utils/Image.js b/opencti-platform/opencti-front/src/utils/Image.js index a267fd69d461..70b3fac07fa3 100644 --- a/opencti-platform/opencti-front/src/utils/Image.js +++ b/opencti-platform/opencti-front/src/utils/Image.js @@ -60,11 +60,15 @@ export const exportPdf = ( pixelRatio = 1, adjust = null, ) => { + console.log('ANGIE - exportPdf in image start'); const container = document.getElementById(domElementId); const { offsetWidth, offsetHeight } = container; const imageWidth = offsetWidth * pixelRatio; const imageHeight = offsetHeight * pixelRatio; - return new Promise((resolve) => { + console.log('ANGIE - exportPdf in image params', { offsetWidth, offsetHeight, imageWidth, imageHeight, backgroundColor, name, adjust, container, pixelRatio }); + return new Promise((resolve, reject) => { + console.log(`ANGIE - exportPdf in image htmlToImage start container:${container.className}`); + console.log('ANGIE - exportPdf in image params 2', { offsetWidth, offsetHeight, imageWidth, imageHeight, backgroundColor, name, adjust, container, pixelRatio }); htmlToImage .toPng(container, { useCORS: true, @@ -83,6 +87,7 @@ export const exportPdf = ( return true; }, }) + .then((truc) => { console.log('ANGIE truc:', truc); return truc; }) .then((image) => { const docDefinition = { pageSize: { @@ -111,15 +116,21 @@ export const exportPdf = ( }, ], }; + console.log('ANGIE - exportPdf before createPdf'); const pdf = pdfMake.createPdf(docDefinition); pdf.download(`${name}.pdf`); if (adjust) { + console.log('ANGIE - exportPdf adjust'); container.setAttribute( 'style', `width:${offsetWidth}px; height:${offsetHeight}px;`, ); } resolve(); + }) + .catch((reason) => { + console.log('ANGIE error in exportPdf in image', JSON.stringify(reason)); + reject(reason); }); }); };