`;
}
function simulateStatusChange() {
dashboardData.nodes.forEach(node => {
if(node.type === 'service') {
const statuses = ['Healthy', 'Warning', 'Critical'];
node.status = statuses[Math.floor(Math.random() * statuses.length)];
}
});
renderAllContent();
showTab(0);
}
function addTableRow(tableId) {
const table = document.getElementById(tableId);
const newRow = table.tBodies[0].insertRow();
let cellsHtml = '';
if (tableId.includes('nodes')) {
cellsHtml = ` `;
} else {
cellsHtml = ` `;
}
newRow.innerHTML = `${cellsHtml} `;
newRow.querySelector('.delete-row-btn').addEventListener('click', (e) => e.target.closest('tr').remove());
}
function navigateTabs(direction) {
const newIndex = currentTabIndex + direction;
if (newIndex >= 0 && newIndex < tabs.length) showTab(newIndex);
}
function updateNavButtons() {
prevTabBtn.disabled = currentTabIndex === 0;
nextTabBtn.disabled = currentTabIndex === tabs.length - 1;
}
async function generatePDF() {
const { jsPDF } = window.jspdf;
const doc = new jsPDF();
doc.setFontSize(18); doc.text('Application Architecture Report', 14, 22);
// Capture Diagram as Image
const diagramContainer = document.getElementById('architecture-diagram-container');
if(diagramContainer) {
doc.setFontSize(12); doc.text("Architecture Diagram", 14, 30);
const canvas = await html2canvas(diagramContainer, { backgroundColor: '#ffffff' });
const imgData = canvas.toDataURL('image/png');
const imgProps = doc.getImageProperties(imgData);
const pdfWidth = doc.internal.pageSize.getWidth() - 28;
const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width;
doc.addImage(imgData, 'PNG', 14, 35, pdfWidth, pdfHeight);
}
// Add Service Details Table
doc.addPage();
doc.setFontSize(18); doc.text('Application Architecture Report', 14, 22);
doc.setFontSize(12); doc.text("Service Details", 14, 30);
const table = document.querySelector('#service-details .data-table');
if(table) {
doc.autoTable({ html: table, startY: 35 });
}
doc.save(`Application_Architecture_Report.pdf`);
}
init();
});
