Update dashboard, kb, memory +4 more (+28 ~18 -1)
This commit is contained in:
@@ -743,6 +743,9 @@
|
||||
<div class="note-viewer-header">
|
||||
<h2 id="viewerTitle">Titlu</h2>
|
||||
<a id="viewerPath" href="#" class="viewer-path" target="_blank"></a>
|
||||
<button class="btn btn-ghost" onclick="downloadNotePDF()" id="downloadNotePdfBtn" title="Download as PDF">
|
||||
<i data-lucide="download"></i>
|
||||
</button>
|
||||
<button class="btn btn-ghost" onclick="closeNote()">
|
||||
<i data-lucide="x"></i>
|
||||
</button>
|
||||
@@ -1214,6 +1217,52 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadNotePDF() {
|
||||
const title = document.getElementById('viewerTitle').textContent;
|
||||
const viewerPath = document.getElementById('viewerPath').textContent;
|
||||
const filename = title.replace(/[^a-zA-Z0-9_-]/g, '_') + '.pdf';
|
||||
|
||||
try {
|
||||
// Get the raw markdown content from cache (not the HTML)
|
||||
let markdownContent = '';
|
||||
const noteFile = Object.keys(notesCache).find(f => {
|
||||
const note = notesIndex.find(n => n.file === f && n.title === title);
|
||||
return !!note;
|
||||
});
|
||||
|
||||
if (noteFile && notesCache[noteFile]) {
|
||||
markdownContent = notesCache[noteFile];
|
||||
} else {
|
||||
alert('Markdown content not found');
|
||||
return;
|
||||
}
|
||||
|
||||
// Send to backend API
|
||||
const response = await fetch('api/pdf', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ markdown: markdownContent, filename: filename })
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
alert('Eroare: ' + (error.error || 'Unknown error'));
|
||||
return;
|
||||
}
|
||||
|
||||
const blob = await response.blob();
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = filename;
|
||||
link.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
} catch (e) {
|
||||
console.error('PDF error:', e);
|
||||
alert('Eroare: ' + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
function closeNote() {
|
||||
document.getElementById('noteViewer').classList.remove('active');
|
||||
document.body.style.overflow = '';
|
||||
|
||||
Reference in New Issue
Block a user