Digital Rights Management Dashboard

Digital Rights Management Dashboard

Digital Content Rights Overview

Monitor your digital content licenses, usage, and status.

Total Content Items

0

Active Licenses

0

Expired Licenses

0

Revoked Licenses

0

Your Digital Content

Content by Status
Content by License Type

Configure Digital Content

Add, edit, or remove your digital content entries and their rights.

Add/Edit Content Item

ID Name Type License Start Date End Date Status Actions

No content data available.

'; return; } // Aggregate data by license type const licenseTypeCounts = d3.rollup(digitalContent, v => v.length, d => d.licenseType); const chartData = Array.from(licenseTypeCounts, ([type, count]) => ({ type, count })); const width = licenseTypeChartContainer.clientWidth; const height = licenseTypeChartContainer.clientHeight - 30; // Account for title height const radius = Math.min(width, height) / 2 - 20; // Adjusted radius const svg = d3.select(licenseTypeChartContainer) .append("svg") .attr("width", width) .attr("height", height) .append("g") .attr("transform", `translate(${width / 2},${height / 2})`); const pie = d3.pie() .sort(null) .value(d => d.count); const arc = d3.arc() .innerRadius(0) .outerRadius(radius); const color = d3.scaleOrdinal(d3.schemeCategory10); // D3's default color scheme // Tooltip const tooltip = d3.select("body").append("div") .attr("class", "chart-tooltip") .style("opacity", 0); const arcs = svg.selectAll(".arc") .data(pie(chartData)) .enter().append("g") .attr("class", "arc"); arcs.append("path") .attr("d", arc) .attr("fill", d => color(d.data.type)) .on("mouseover", function(event, d) { d3.select(this).attr("fill", d3.rgb(color(d.data.type)).darker(0.5)); tooltip.transition() .duration(200) .style("opacity", .9); tooltip.html(`License Type: ${d.data.type}
Count: ${d.data.count}
Percentage: ${(d.data.count / d3.sum(chartData, d => d.count) * 100).toFixed(1)}%`) .style("left", (event.pageX + 10) + "px") .style("top", (event.pageY - 28) + "px"); }) .on("mouseout", function(d) { d3.select(this).attr("fill", color(d.data.type)); // Restore original color tooltip.transition() .duration(500) .style("opacity", 0); }); // Add text labels arcs.append("text") .attr("transform", d => `translate(${arc.centroid(d)})`) .attr("dy", "0.35em") .text(d => `${d.data.type} (${(d.data.count / d3.sum(chartData, d => d.count) * 100).toFixed(0)}%)`) .style("text-anchor", "middle") .style("font-size", "10px") .style("fill", "white") .style("pointer-events", "none"); // Prevent text from blocking mouse events on arcs } // --- PDF Download Function --- /** * Generates and downloads a PDF of the current dashboard content. */ window.downloadPdf = async function() { if (!dashboardTab) { console.error('Error: Dashboard tab content not found for PDF generation.'); return; } // Temporarily hide elements not needed in PDF const elementsToHide = document.querySelectorAll('.tab-nav, .nav-buttons, #downloadPdfButton, .chart-tooltip'); elementsToHide.forEach(el => el.style.display = 'none'); // Ensure the dashboard tab is active for capture dashboardTab.classList.add('active'); // Capture summary metrics const summaryCanvas = await html2canvas(document.querySelector('.summary-metrics'), { scale: 2, useCORS: true, logging: false }); const summaryImgData = summaryCanvas.toDataURL('image/png'); // Capture content cards const cardsCanvas = await html2canvas(contentCardsContainer, { scale: 2, useCORS: true, logging: false }); const cardsImgData = cardsCanvas.toDataURL('image/png'); // Capture content status chart const statusChartCanvas = await html2canvas(contentStatusChartContainer, { scale: 2, useCORS: true, logging: false }); const statusChartImgData = statusChartCanvas.toDataURL('image/png'); // Capture license type chart const licenseTypeChartCanvas = await html2canvas(licenseTypeChartContainer, { scale: 2, useCORS: true, logging: false }); const licenseTypeChartImgData = licenseTypeChartCanvas.toDataURL('image/png'); // Re-show hidden elements immediately after capture elementsToHide.forEach(el => el.style.display = ''); const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); let yOffset = 40; // Add title to PDF pdf.setFontSize(22); pdf.text("Digital Rights Management Report", pdfWidth / 2, yOffset, { align: 'center' }); yOffset += 20; // Add current date/time to PDF pdf.setFontSize(10); pdf.text(`Generated on: ${new Date().toLocaleString()}`, pdfWidth / 2, yOffset, { align: 'center' }); yOffset += 40; // Add Summary Metrics Image pdf.setFontSize(18); pdf.text("Summary Metrics", pdfWidth / 2, yOffset, { align: 'center' }); yOffset += 10; const summaryImgHeight = (summaryCanvas.height * (pdfWidth - 40)) / summaryCanvas.width; pdf.addImage(summaryImgData, 'PNG', 20, yOffset, pdfWidth - 40, summaryImgHeight); yOffset += summaryImgHeight + 30; // Add Content Cards Image pdf.setFontSize(18); pdf.text("Your Digital Content Overview", pdfWidth / 2, yOffset, { align: 'center' }); yOffset += 10; const cardsImgHeight = (cardsCanvas.height * (pdfWidth - 40)) / cardsCanvas.width; // Check if image fits on current page, add new page if not if (yOffset + cardsImgHeight > pdf.internal.pageSize.getHeight() - 20) { pdf.addPage(); yOffset = 40; // Reset yOffset for new page } pdf.addImage(cardsImgData, 'PNG', 20, yOffset, pdfWidth - 40, cardsImgHeight); yOffset += cardsImgHeight + 30; // Add Content by Status Chart Image pdf.setFontSize(18); pdf.text("Content by Status Chart", pdfWidth / 2, yOffset, { align: 'center' }); yOffset += 10; const statusChartImgHeight = (statusChartCanvas.height * (pdfWidth - 40)) / statusChartCanvas.width; // Check if image fits on current page, add new page if not if (yOffset + statusChartImgHeight > pdf.internal.pageSize.getHeight() - 20) { pdf.addPage(); yOffset = 40; // Reset yOffset for new page } pdf.addImage(statusChartImgData, 'PNG', 20, yOffset, pdfWidth - 40, statusChartImgHeight); yOffset += statusChartImgHeight + 30; // Add Content by License Type Chart Image pdf.setFontSize(18); pdf.text("Content by License Type Chart", pdfWidth / 2, yOffset, { align: 'center' }); yOffset += 10; const licenseTypeChartImgHeight = (licenseTypeChartCanvas.height * (pdfWidth - 40)) / licenseTypeChartCanvas.width; // Check if image fits on current page, add new page if not if (yOffset + licenseTypeChartImgHeight > pdf.internal.pageSize.getHeight() - 20) { pdf.addPage(); yOffset = 40; // Reset yOffset for new page } pdf.addImage(licenseTypeChartImgData, 'PNG', 20, yOffset, pdfWidth - 40, licenseTypeChartImgHeight); yOffset += licenseTypeChartImgHeight + 30; // Add a section for detailed content data (tabular format) pdf.addPage(); pdf.setFontSize(18); pdf.text("Detailed Content Information", pdf.internal.pageSize.getWidth() / 2, 40, { align: 'center' }); const tableData = digitalContent.map(c => [ c.id, c.contentName, c.contentType, c.licenseType, c.startDate, c.endDate || 'N/A', c.usageLimit || 'Unlimited', c.currentUsage.toLocaleString('en-US'), c.contentStatus, c.notes || 'N/A' ]); pdf.autoTable({ head: [['ID', 'Name', 'Type', 'License', 'Start Date', 'End Date', 'Usage Limit', 'Current Usage', 'Status', 'Notes']], body: tableData, startY: 60, theme: 'grid', styles: { fontSize: 6, cellPadding: 2 }, // Smaller font for many columns headStyles: { fillColor: [242, 242, 242], textColor: [51, 51, 51], fontStyle: 'bold' }, alternateRowStyles: { fillColor: [251, 251, 251] }, margin: { top: 70, left: 5, right: 5 } // Adjust margins for more columns }); pdf.save('digital_rights_management_report.pdf'); }; // --- Event Listeners and Initial Render --- downloadPdfButton.addEventListener('click', downloadPdf); // Initial setup // Sort content by start date initially digitalContent.sort((a, b) => new Date(a.startDate) - new Date(b.startDate)); updateConfigTable(); renderDashboardMetrics(); renderContentCards(); renderContentByStatusChart(); renderContentByLicenseTypeChart(); updateNavigationButtons(); // Set initial button states });
Scroll to Top