Asset Management Dashboard

Asset Management Dashboard

A centralized overview of your organization's assets.

${value}

`; } function addTableRow(tableId) { const table = document.getElementById(tableId); const newRow = table.tBodies[0].insertRow(); newRow.innerHTML = ` `; newRow.querySelector('.delete-row-btn').addEventListener('click', (e) => e.target.closest('tr').remove()); } function filterAssets() { const filter = document.getElementById('asset-search').value.toLowerCase(); document.querySelectorAll('.asset-row').forEach(row => { row.style.display = row.textContent.toLowerCase().includes(filter) ? "" : "none"; }); } function renderChartsForTab(tabId) { Object.values(charts).forEach(chart => { if (chart) chart.destroy(); }); if (tabId === 'dashboard-overview') { const categoryData = dashboardData.assets.reduce((acc, asset) => { acc[asset.category] = (acc[asset.category] || 0) + 1; return acc; }, {}); const statusData = dashboardData.assets.reduce((acc, asset) => { acc[asset.status] = (acc[asset.status] || 0) + 1; return acc; }, {}); const barCtx = document.getElementById('assetByCategoryChart')?.getContext('2d'); if(barCtx) charts.category = new Chart(barCtx, { type: 'bar', data: { labels: Object.keys(categoryData), datasets: [{ label: 'Asset Count', data: Object.values(categoryData), backgroundColor: '#3b82f6' }] }, options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { display: false } }, scales: {y:{ticks:{color:'#4b5563'}}, x:{ticks:{color:'#4b5563'}}} } }); const doughnutCtx = document.getElementById('assetByStatusChart')?.getContext('2d'); if(doughnutCtx) charts.status = new Chart(doughnutCtx, { type: 'doughnut', data: { labels: Object.keys(statusData), datasets: [{ data: Object.values(statusData), backgroundColor: ['#dbeafe', '#d1fae5', '#fef3c7', '#fee2e2'], borderColor: '#ffffff', borderWidth: 3 }] }, options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { position: 'bottom', labels: { color: '#1f2937' }}}} }); } } 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('p', 'pt', 'a4'); const activeTab = tabs[currentTabIndex]; const addHeader = (title) => { doc.setFontSize(18); doc.text('Asset Management Report', 40, 60); doc.setFontSize(12); doc.setTextColor(100); doc.text(`Section: ${title}`, 40, 80); doc.setLineWidth(0.5); doc.line(40, 90, 555, 90); }; addHeader(activeTab.name); const tabElement = document.getElementById(activeTab.id); if (activeTab.id === 'dashboard-overview') { const canvas = await html2canvas(tabElement, { backgroundColor: '#ffffff', scale: 2 }); const imgData = canvas.toDataURL('image/png'); const pdfWidth = doc.internal.pageSize.getWidth() - 80; const pdfHeight = (canvas.height * pdfWidth) / canvas.width; doc.addImage(imgData, 'PNG', 40, 110, pdfWidth, pdfHeight); } else { const table = tabElement.querySelector('table'); if (table) doc.autoTable({ html: table, startY: 110 }); } doc.save(`Asset_Management_Report_${activeTab.name.replace(/\s/g, '_')}.pdf`); } init(); });
Scroll to Top