@@ -628,7 +628,7 @@ public static class ReportEmailService
return $@"
-
+
@@ -714,7 +714,7 @@ public static class ReportEmailService
return $@"
-
+
|
diff --git a/typescript/frontend-marios2/src/content/dashboards/SodiohomeInstallations/Installation.tsx b/typescript/frontend-marios2/src/content/dashboards/SodiohomeInstallations/Installation.tsx
index 7ffbe45e9..0257ec56a 100644
--- a/typescript/frontend-marios2/src/content/dashboards/SodiohomeInstallations/Installation.tsx
+++ b/typescript/frontend-marios2/src/content/dashboards/SodiohomeInstallations/Installation.tsx
@@ -618,6 +618,7 @@ function SodioHomeInstallation(props: singleInstallationProps) {
element={
}
/>
diff --git a/typescript/frontend-marios2/src/content/dashboards/SodiohomeInstallations/WeeklyReport.tsx b/typescript/frontend-marios2/src/content/dashboards/SodiohomeInstallations/WeeklyReport.tsx
index f19929a26..98209a2d1 100644
--- a/typescript/frontend-marios2/src/content/dashboards/SodiohomeInstallations/WeeklyReport.tsx
+++ b/typescript/frontend-marios2/src/content/dashboards/SodiohomeInstallations/WeeklyReport.tsx
@@ -27,6 +27,7 @@ import DailySection from './DailySection';
interface WeeklyReportProps {
installationId: number;
+ installationName?: string;
}
interface DailyEnergyData {
@@ -223,7 +224,7 @@ function EmailBar({ onSend, disabled }: { onSend: (email: string) => Promise([]);
@@ -340,11 +341,19 @@ function WeeklyReport({ installationId }: WeeklyReportProps) {
? `${reportPeriod.start.replace(/-/g, '')}-${reportPeriod.end.replace(/-/g, '')}`
: new Date().toISOString().split('T')[0].replace(/-/g, '');
+ const safeName = (installationName || String(installationId))
+ .replace(/\s+/g, '-')
+ .replace(/[^a-zA-Z0-9\-_]/g, '');
+
printWindow.document.write(res.data);
printWindow.document.close();
- printWindow.document.title = `inesco-energy-${installationId}-${reportType}-${dateRange}`;
+ printWindow.document.title = `${safeName}-${reportType}-${dateRange}`;
printWindow.onafterprint = () => printWindow.close();
- setTimeout(() => printWindow.print(), 500);
+ const imgs = printWindow.document.querySelectorAll('img');
+ const allLoaded = Array.from(imgs).map(img =>
+ img.complete ? Promise.resolve() : new Promise(r => { img.onload = () => r(); img.onerror = () => r(); })
+ );
+ Promise.all(allLoaded).then(() => setTimeout(() => printWindow.print(), 200));
} catch (err) {
console.error('PDF download failed', err);
} finally {
| | |