Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { getPinnedInsights } from '@/lib/evolution/history.pins';
import { jsPDF } from 'jspdf';
import autoTable from 'jspdf-autotable';
/** تصدير جميع الـ pins كـ CSV string */
export function exportPinnedAsCSV(): string {
const pins = getPinnedInsights();
if (!pins.length) return '';
const header = ['Timestamp', 'Trend', 'Confidence', 'Note'];
const rows = pins.map((p) => [
p.timestamp,
p.trend,
(p.confidence * 100).toFixed(1) + '%',
p.note,
]);
return [header, ...rows].map((r) => r.join(',')).join('\n');
}
/** تنزيل CSV كملف */
export function downloadCSV() {
const csv = exportPinnedAsCSV();
if (!csv) {
alert('No pinned insights to export.');
return;
}
const blob = new Blob([csv], { type: 'text/csv' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `insights_${new Date().toISOString().slice(0, 10)}.csv`;
a.click();
URL.revokeObjectURL(url);
}
/** تنزيل تقرير PDF بهوية HUD */
export function downloadPDF() {
const pins = getPinnedInsights();
if (!pins.length) {
alert('No pinned insights to export.');
return;
}
const doc = new jsPDF({
orientation: 'portrait',
unit: 'pt',
format: 'A4',
});
// 🎨 Header
doc.setFont('helvetica', 'bold');
doc.setFontSize(18);
doc.setTextColor('#f47b46');
doc.text('Jemy-dev OS — Annotated Insights Report', 40, 50);
// 🕓 Subheader
doc.setFontSize(10);
doc.setTextColor('#9aa1b1');
doc.text(`Generated: ${new Date().toLocaleString()}`, 40, 70);
// 🧾 Data Table
const tableData = pins.map((p, i) => [
i + 1,
new Date(p.timestamp).toLocaleString(),
p.trend,
(p.confidence * 100).toFixed(1) + '%',
p.note || '-',
]);
autoTable(doc, {
startY: 90,
head: [['#', 'Timestamp', 'Trend', 'Confidence', 'Note']],
body: tableData,
theme: 'grid',
styles: {
font: 'helvetica',
fontSize: 9,
textColor: '#e1e5f2',
lineColor: [60, 60, 60],
fillColor: [20, 25, 40],
cellPadding: 5,
},
headStyles: {
fillColor: [15, 60, 80],
textColor: '#ffffff',
fontStyle: 'bold',
},
alternateRowStyles: {
fillColor: [25, 30, 50],
},
tableLineColor: [80, 80, 80],
tableLineWidth: 0.3,
});
// ⚙️ Footer
const pageCount = doc.getNumberOfPages();
for (let i = 1; i <= pageCount; i++) {
doc.setPage(i);
doc.setFontSize(8);
doc.setTextColor('#666');
doc.text(`© ${new Date().getFullYear()} Jemy-dev OS — Predictive Phase 005`, 40, 810);
doc.text(`Page ${i} of ${pageCount}`, 500, 810);
}
doc.save(`Jemy-dev-Insights-${new Date().toISOString().slice(0, 10)}.pdf`);
}
|