Spaces:
Running
Running
Download wordpress-dashboard.html from DJANTONY/tabletodash-wizard: direct link, hf CLI and curl.
- Browser
- Download file 22.4 kB
-
https://huggingface.co/spaces/DJANTONY/tabletodash-wizard/resolve/main/wordpress-dashboard.html
- Command line
-
hf download hf://spaces/DJANTONY/tabletodash-wizard/wordpress-dashboard.html
-
curl -L -o wordpress-dashboard.html https://huggingface.co/spaces/DJANTONY/tabletodash-wizard/resolve/main/wordpress-dashboard.html
22.4 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>TableToDash - WordPress Dashboard Converter</title> | |
| <link rel="stylesheet" href="style.css"> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> | |
| <script src="components/navbar.js"></script> | |
| <script src="components/footer.js"></script> | |
| <style> | |
| .dropzone { | |
| border: 2px dashed #ccc; | |
| border-radius: 8px; | |
| padding: 40px; | |
| text-align: center; | |
| cursor: pointer; | |
| transition: all 0.3s; | |
| } | |
| .dropzone.active { | |
| border-color: #3b82f6; | |
| background-color: #f0f7ff; | |
| } | |
| #previewTable { | |
| max-height: 400px; | |
| overflow-y: auto; | |
| } | |
| .chart-container { | |
| position: relative; | |
| height: 300px; | |
| margin-bottom: 2rem; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-50"> | |
| <custom-navbar></custom-navbar> | |
| <main class="container mx-auto px-4 py-8"> | |
| <div class="text-center mb-8"> | |
| <h1 class="text-3xl font-bold text-gray-800">TableToDash Converter</h1> | |
| <p class="text-gray-600 mt-2">Upload your Excel/CSV table and transform it into a WordPress dashboard</p> | |
| </div> | |
| <div class="grid grid-cols-1 lg:grid-cols-2 gap-8"> | |
| <div class="bg-white rounded-xl shadow-md p-6"> | |
| <h2 class="text-xl font-semibold mb-4">Upload Your Data</h2> | |
| <div id="dropZone" class="dropzone"> | |
| <div class="space-y-2"> | |
| <svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12 mx-auto text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor"> | |
| <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" /> | |
| </svg> | |
| <p class="text-lg font-medium">Drag & Drop your Excel/CSV file here</p> | |
| <p class="text-gray-500">or click to browse files</p> | |
| <input type="file" id="fileInput" class="hidden" accept=".xlsx,.xls,.csv"> | |
| </div> | |
| </div> | |
| <div class="mt-4 flex justify-between"> | |
| <div class="flex items-center"> | |
| <input type="checkbox" id="hasHeaders" class="mr-2" checked> | |
| <label for="hasHeaders">First row contains headers</label> | |
| </div> | |
| <button id="processBtn" class="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition disabled:opacity-50" disabled> | |
| Process File | |
| </button> | |
| </div> | |
| <div id="tablePreview" class="mt-6 hidden"> | |
| <h3 class="text-lg font-medium mb-2">Data Preview</h3> | |
| <div id="previewTable" class="border rounded-lg overflow-auto"></div> | |
| </div> | |
| </div> | |
| <div class="bg-white rounded-xl shadow-md p-6"> | |
| <h2 class="text-xl font-semibold mb-4">Dashboard Configuration</h2> | |
| <div class="space-y-4"> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Dashboard Title</label> | |
| <input type="text" id="dashboardTitle" class="w-full px-3 py-2 border border-gray-300 rounded-md" placeholder="Enter dashboard title"> | |
| </div> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Key Metrics</label> | |
| <div id="metricFields" class="space-y-2"></div> | |
| </div> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Visualizations</label> | |
| <div class="space-y-3"> | |
| <div class="flex items-center"> | |
| <input type="checkbox" id="includeBarChart" class="mr-2" checked> | |
| <label for="includeBarChart">Bar Chart</label> | |
| </div> | |
| <div class="flex items-center"> | |
| <input type="checkbox" id="includePieChart" class="mr-2" checked> | |
| <label for="includePieChart">Pie Chart</label> | |
| </div> | |
| <div class="flex items-center"> | |
| <input type="checkbox" id="includeLineChart" class="mr-2" checked> | |
| <label for="includeLineChart">Line Chart</label> | |
| </div> | |
| </div> | |
| </div> | |
| <div id="chartConfigs" class="space-y-4 hidden"> | |
| <!-- Chart configurations will be added here --> | |
| </div> | |
| <button id="generateBtn" class="w-full px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 transition disabled:opacity-50" disabled> | |
| Generate WordPress Dashboard | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <div id="dashboardPreview" class="mt-8 hidden"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h2 class="text-2xl font-bold text-gray-800">Dashboard Preview</h2> | |
| <button id="exportBtn" class="px-4 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 transition flex items-center gap-2"> | |
| Export to WordPress | |
| </button> | |
| </div> | |
| <div class="bg-white rounded-xl shadow-md p-6"> | |
| <h2 id="previewTitle" class="text-2xl font-bold mb-6"></h2> | |
| <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8" id="metricsPreview"> | |
| <!-- Metrics will be populated here --> | |
| </div> | |
| <div class="grid grid-cols-1 gap-8"> | |
| <div id="barChartContainer" class="chart-container"> | |
| <canvas id="barChart"></canvas> | |
| </div> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-8"> | |
| <div id="pieChartContainer" class="chart-container"> | |
| <canvas id="pieChart"></canvas> | |
| </div> | |
| <div id="lineChartContainer" class="chart-container"> | |
| <canvas id="lineChart"></canvas> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </main> | |
| <custom-footer></custom-footer> | |
| <script src="components/navbar.js"></script> | |
| <script src="components/footer.js"></script> | |
| <script src="script.js"></script> | |
| <script> | |
| // Initialize feather icons | |
| document.addEventListener('DOMContentLoaded', function() { | |
| feather.replace(); | |
| // Drag and drop functionality | |
| const dropZone = document.getElementById('dropZone'); | |
| const fileInput = document.getElementById('fileInput'); | |
| const processBtn = document.getElementById('processBtn'); | |
| let uploadedFile = null; | |
| dropZone.addEventListener('click', () => fileInput.click()); | |
| fileInput.addEventListener('change', (e) => { | |
| if (e.target.files.length) { | |
| uploadedFile = e.target.files[0]; | |
| processBtn.disabled = false; | |
| dropZone.classList.add('active'); | |
| } | |
| }); | |
| dropZone.addEventListener('dragover', (e) => { | |
| e.preventDefault(); | |
| dropZone.classList.add('active'); | |
| }); | |
| ['dragleave', 'dragend'].forEach(type => { | |
| dropZone.addEventListener(type, () => { | |
| dropZone.classList.remove('active'); | |
| }); | |
| }); | |
| dropZone.addEventListener('drop', (e) => { | |
| e.preventDefault(); | |
| dropZone.classList.remove('active'); | |
| if (e.dataTransfer.files.length) { | |
| fileInput.files = e.dataTransfer.files; | |
| uploadedFile = e.dataTransfer.files[0]; | |
| processBtn.disabled = false; | |
| } | |
| }); | |
| // Process file button | |
| processBtn.addEventListener('click', processFile); | |
| // Generate dashboard button | |
| document.getElementById('generateBtn').addEventListener('click', generateDashboard); | |
| // Export button | |
| document.getElementById('exportBtn').addEventListener('click', exportToWordPress); | |
| }); | |
| function processFile() { | |
| const file = uploadedFile; | |
| const reader = new FileReader(); | |
| reader.onload = function(e) { | |
| const data = new Uint8Array(e.target.result); | |
| const workbook = XLSX.read(data, { type: 'array' }); | |
| const firstSheet = workbook.Sheets[workbook.SheetNames[0]]; | |
| const jsonData = XLSX.utils.sheet_to_json(firstSheet, { header: 1 }); | |
| // Store data globally for later use | |
| window.tableData = { | |
| headers: document.getElementById('hasHeaders').checked ? jsonData[0] : jsonData[0].map((_, i) => `Column ${i+1}`), | |
| rows: document.getElementById('hasHeaders').checked ? jsonData.slice(1) : jsonData | |
| }; | |
| // Display preview | |
| displayTablePreview(); | |
| // Setup metric selection | |
| setupMetricSelection(); | |
| }; | |
| reader.readAsArrayBuffer(file); | |
| } | |
| function displayTablePreview() { | |
| const previewDiv = document.getElementById('tablePreview'); | |
| const previewTable = document.getElementById('previewTable'); | |
| previewDiv.classList.remove('hidden'); | |
| let html = '<table class="min-w-full divide-y divide-gray-200"><thead class="bg-gray-50"><tr>'; | |
| // Add headers | |
| window.tableData.headers.forEach(header => { | |
| html += `<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">${header}</th>`; | |
| }); | |
| html += '</tr></thead><tbody class="bg-white divide-y divide-gray-200">'; | |
| // Add first 5 rows | |
| window.tableData.rows.slice(0, 5).forEach(row => { | |
| html += '<tr>'; | |
| row.forEach(cell => { | |
| html += `<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${cell}</td>`; | |
| }); | |
| html += '</tr>'; | |
| }); | |
| html += '</tbody></table>'; | |
| previewTable.innerHTML = html; | |
| document.getElementById('generateBtn').disabled = false; | |
| } | |
| function setupMetricSelection() { | |
| const metricFields = document.getElementById('metricFields'); | |
| metricFields.innerHTML = ''; | |
| window.tableData.headers.forEach((header, index) => { | |
| // Skip non-numeric columns for metrics | |
| if (typeof window.tableData.rows[0][index] === 'number' || !isNaN(window.tableData.rows[0][index])) { | |
| metricFields.innerHTML += ` | |
| <div class="flex items-center space-x-3"> | |
| <input type="checkbox" id="metric-${index}" class="metric-checkbox" data-column="${index}" checked> | |
| <div class="flex-1"> | |
| <label for="metric-${index}" class="text-sm">${header}</label> | |
| <select class="mt-1 w-full border border-gray-300 rounded-md px-2 py-1 text-sm"> | |
| <option value="sum">Sum</option> | |
| <option value="avg">Average</option> | |
| <option value="min">Min</option> | |
| <option value="max">Max</option> | |
| <option value="count">Count</option> | |
| </select> | |
| </div> | |
| </div> | |
| `; | |
| } | |
| }); | |
| } | |
| function generateDashboard() { | |
| const dashboardTitle = document.getElementById('dashboardTitle').value || 'Data Dashboard'; | |
| document.getElementById('previewTitle').textContent = dashboardTitle; | |
| // Generate metrics | |
| const metricsPreview = document.getElementById('metricsPreview'); | |
| metricsPreview.innerHTML = ''; | |
| document.querySelectorAll('.metric-checkbox:checked').forEach(checkbox => { | |
| const columnIndex = parseInt(checkbox.dataset.column); | |
| const header = window.tableData.headers[columnIndex]; | |
| const operation = checkbox.parentNode.querySelector('select').value; | |
| let value; | |
| const numericValues = window.tableData.rows.map(row => parseFloat(row[columnIndex])).filter(v => !isNaN(v)); | |
| switch(operation) { | |
| case 'sum': | |
| value = numericValues.reduce((a, b) => a + b, 0).toFixed(2); | |
| break; | |
| case 'avg': | |
| value = (numericValues.reduce((a, b) => a + b, 0) / numericValues.length).toFixed(2); | |
| break; | |
| case 'min': | |
| value = Math.min(...numericValues).toFixed(2); | |
| break; | |
| case 'max': | |
| value = Math.max(...numericValues).toFixed(2); | |
| break; | |
| case 'count': | |
| value = numericValues.length; | |
| break; | |
| } | |
| metricsPreview.innerHTML += ` | |
| <div class="bg-gray-50 p-4 rounded-lg"> | |
| <div class="flex items-center justify-between"> | |
| <h3 class="text-sm font-medium text-gray-600">${header} (${operation})</h3> | |
| <div class="p-2 rounded-full bg-blue-100 text-blue-600"> | |
| <i data-feather="activity"></i> | |
| </div> | |
| </div> | |
| <p class="mt-2 text-2xl font-bold text-gray-900">${value}</p> | |
| </div> | |
| `; | |
| }); | |
| // Generate charts if selected | |
| if (document.getElementById('includeBarChart').checked) { | |
| createBarChart(); | |
| document.getElementById('barChartContainer').classList.remove('hidden'); | |
| } else { | |
| document.getElementById('barChartContainer').classList.add('hidden'); | |
| } | |
| if (document.getElementById('includePieChart').checked) { | |
| createPieChart(); | |
| document.getElementById('pieChartContainer').classList.remove('hidden'); | |
| } else { | |
| document.getElementById('pieChartContainer').classList.add('hidden'); | |
| } | |
| if (document.getElementById('includeLineChart').checked) { | |
| createLineChart(); | |
| document.getElementById('lineChartContainer').classList.remove('hidden'); | |
| } else { | |
| document.getElementById('lineChartContainer').classList.add('hidden'); | |
| } | |
| document.getElementById('dashboardPreview').classList.remove('hidden'); | |
| feather.replace(); | |
| } | |
| function createBarChart() { | |
| // Simple implementation - in a real app you'd let user select columns | |
| const ctx = document.getElementById('barChart').getContext('2d'); | |
| // Destroy previous chart if it exists | |
| if (window.barChart) window.barChart.destroy(); | |
| // Find first numeric column for demo purposes | |
| let numericColumnIndex = -1; | |
| for (let i = 0; i < window.tableData.headers.length; i++) { | |
| if (typeof window.tableData.rows[0][i] === 'number' || !isNaN(window.tableData.rows[0][i])) { | |
| numericColumnIndex = i; | |
| break; | |
| } | |
| } | |
| if (numericColumnIndex === -1) return; | |
| const labels = window.tableData.rows.slice(0, 10).map(row => row[0]); // First column as labels | |
| const data = window.tableData.rows.slice(0, 10).map(row => parseFloat(row[numericColumnIndex])); | |
| window.barChart = new Chart(ctx, { | |
| type: 'bar', | |
| data: { | |
| labels: labels, | |
| datasets: [{ | |
| label: window.tableData.headers[numericColumnIndex], | |
| data: data, | |
| backgroundColor: 'rgba(59, 130, 246, 0.5)', | |
| borderColor: 'rgba(59, 130, 246, 1)', | |
| borderWidth: 1 | |
| }] | |
| }, | |
| options: { | |
| responsive: true, | |
| maintainAspectRatio: false, | |
| scales: { | |
| y: { | |
| beginAtZero: true | |
| } | |
| } | |
| } | |
| }); | |
| } | |
| function createPieChart() { | |
| const ctx = document.getElementById('pieChart').getContext('2d'); | |
| if (window.pieChart) window.pieChart.destroy(); | |
| // Group by first column for demo purposes | |
| const groups = {}; | |
| window.tableData.rows.slice(0, 5).forEach(row => { | |
| const key = row[0]; | |
| if (!groups[key]) groups[key] = 0; | |
| groups[key]++; | |
| }); | |
| window.pieChart = new Chart(ctx, { | |
| type: 'pie', | |
| data: { | |
| labels: Object.keys(groups), | |
| datasets: [{ | |
| data: Object.values(groups), | |
| backgroundColor: [ | |
| 'rgba(255, 99, 132, 0.5)', | |
| 'rgba(54, 162, 235, 0.5)', | |
| 'rgba(255, 206, 86, 0.5)', | |
| 'rgba(75, 192, 192, 0.5)', | |
| 'rgba(153, 102, 255, 0.5)' | |
| ], | |
| borderColor: [ | |
| 'rgba(255, 99, 132, 1)', | |
| 'rgba(54, 162, 235, 1)', | |
| 'rgba(255, 206, 86, 1)', | |
| 'rgba(75, 192, 192, 1)', | |
| 'rgba(153, 102, 255, 1)' | |
| ], | |
| borderWidth: 1 | |
| }] | |
| }, | |
| options: { | |
| responsive: true, | |
| maintainAspectRatio: false | |
| } | |
| }); | |
| } | |
| function createLineChart() { | |
| const ctx = document.getElementById('lineChart').getContext('2d'); | |
| if (window.lineChart) window.lineChart.destroy(); | |
| // Find first numeric column for demo purposes | |
| let numericColumnIndex = -1; | |
| for (let i = 0; i < window.tableData.headers.length; i++) { | |
| if (typeof window.tableData.rows[0][i] === 'number' || !isNaN(window.tableData.rows[0][i])) { | |
| numericColumnIndex = i; | |
| break; | |
| } | |
| } | |
| if (numericColumnIndex === -1) return; | |
| const labels = window.tableData.rows.slice(0, 10).map(row => row[0]); // First column as labels | |
| const data = window.tableData.rows.slice(0, 10).map(row => parseFloat(row[numericColumnIndex])); | |
| window.lineChart = new Chart(ctx, { | |
| type: 'line', | |
| data: { | |
| labels: labels, | |
| datasets: [{ | |
| label: window.tableData.headers[numericColumnIndex], | |
| data: data, | |
| fill: false, | |
| backgroundColor: 'rgba(59, 130, 246, 0.5)', | |
| borderColor: 'rgba(59, 130, 246, 1)', | |
| tension: 0.1 | |
| }] | |
| }, | |
| options: { | |
| responsive: true, | |
| maintainAspectRatio: false, | |
| scales: { | |
| y: { | |
| beginAtZero: true | |
| } | |
| } | |
| } | |
| }); | |
| } | |
| function exportToWordPress() { | |
| // In a real implementation, this would generate the WordPress code | |
| alert('In a real implementation, this would generate WordPress PHP code and shortcodes that you can copy into your WordPress site.'); | |
| } | |
| </script> | |
| </body> | |
| </html> |