File size: 9,342 Bytes
f5f2bc2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
document.addEventListener('DOMContentLoaded', function() {
// Button event handlers
document.addEventListener('click', function(e) {
// Handle export button
if (e.target.closest('.export-btn')) {
alert('Exporting data... This would trigger a CSV download in a real application.');
}
// Handle filter button
if (e.target.closest('.filter-btn')) {
alert('Opening filters... This would show filter options in a real application.');
}
// Handle pagination buttons
if (e.target.closest('.pagination-btn')) {
const btn = e.target.closest('.pagination-btn');
if (!btn.classList.contains('bg-blue-600')) {
alert(`Loading page ${btn.textContent}... This would load new data in a real application.`);
}
}
// Handle time period selector
if (e.target.closest('.time-period-select')) {
const select = e.target.closest('.time-period-select');
alert(`Changed time period to ${select.value}. This would reload data with new time range in a real application.`);
}
// Handle view transaction button
if (e.target.closest('.view-btn')) {
alert('Viewing transaction details... This would open a modal in a real application.');
}
// Handle more options button
if (e.target.closest('.options-btn')) {
alert('Showing more options... This would open a dropdown menu in a real application.');
}
});
// Network selector handler
document.addEventListener('change', function(e) {
if (e.target.classList.contains('asset-select')) {
alert(`Changed asset to ${e.target.value}. This would update the chart in a real application.`);
}
});
// Sample transaction data (would be replaced with actual data in a real app)
const transactions = [
{
date: '2025-01-02 16:07:48 UTC',
type: 'Product Checkout',
product: 'Activation Upgrade',
network: 'Base',
asset: 'ETH',
amount: '$17.97',
status: 'Completed'
},
{
date: '2025-01-04 18:28:43 UTC',
type: 'Product Checkout',
product: 'Activation Upgrade',
network: 'Polygon',
asset: 'MATIC',
amount: '$5.99',
status: 'Completed'
},
{
date: '2025-01-05 07:30:34 UTC',
type: 'Product Checkout',
product: 'Activation Upgrade',
network: 'Base',
asset: 'ETH',
amount: '$17.97',
status: 'Completed'
},
{
date: '2025-01-05 13:00:08 UTC',
type: 'Product Checkout',
product: 'Activation Upgrade',
network: 'Polygon',
asset: 'USDC',
amount: '$5.99',
status: 'Completed'
},
{
date: '2025-01-06 05:21:18 UTC',
type: 'Product Checkout',
product: 'Activation Upgrade',
network: 'Polygon',
asset: 'MATIC',
amount: '$5.99',
status: 'Completed'
}
];
// Populate transaction table
const tableBody = document.getElementById('transactionTableBody');
transactions.forEach(tx => {
const row = document.createElement('tr');
const statusClass = tx.status === 'Completed' ?
'bg-green-100 text-green-800' :
'bg-yellow-100 text-yellow-800';
row.innerHTML = `
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${formatDate(tx.date)}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${tx.type}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-blue-100 text-blue-800">${tx.network}</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${tx.asset}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${tx.amount}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${statusClass}">${tx.status}</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<button class="text-blue-600 hover:text-blue-900 mr-2 view-btn">
<i data-feather="eye" class="w-4 h-4"></i>
</button>
<button class="text-gray-600 hover:text-gray-900 options-btn">
<i data-feather="more-horizontal" class="w-4 h-4"></i>
</button>
</td>
`;
tableBody.appendChild(row);
});
// Initialize charts
initCharts();
// Refresh feather icons after dynamic content is added
feather.replace();
});
function formatDate(dateString) {
const date = new Date(dateString);
return date.toLocaleDateString() + ' ' + date.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
}
function initCharts() {
// Network Volume Chart
const networkCtx = document.getElementById('networkChart').getContext('2d');
new Chart(networkCtx, {
type: 'doughnut',
data: {
labels: ['Polygon', 'Base', 'Ethereum'],
datasets: [{
data: [856.42, 348.45, 0],
backgroundColor: [
'#8247e5',
'#0052ff',
'#627eea'
],
borderWidth: 0
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
cutout: '70%',
plugins: {
legend: {
position: 'right',
labels: {
boxWidth: 12,
padding: 20,
usePointStyle: true,
pointStyle: 'circle'
}
}
}
}
});
// Timeline Chart
const timelineCtx = document.getElementById('timelineChart').getContext('2d');
new Chart(timelineCtx, {
type: 'line',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct'],
datasets: [
{
label: 'Transactions',
data: [12, 19, 15, 25, 22, 18, 24, 28, 16, 20],
borderColor: '#3b82f6',
backgroundColor: 'rgba(59, 130, 246, 0.05)',
borderWidth: 2,
tension: 0.3,
fill: true,
pointBackgroundColor: '#ffffff',
pointBorderColor: '#3b82f6',
pointBorderWidth: 2,
pointRadius: 4,
pointHoverRadius: 6
},
{
label: 'Volume (USD)',
data: [85, 120, 95, 150, 130, 110, 160, 180, 105, 145],
borderColor: '#8b5cf6',
backgroundColor: 'rgba(139, 92, 246, 0.05)',
borderWidth: 2,
tension: 0.3,
fill: true,
pointBackgroundColor: '#ffffff',
pointBorderColor: '#8b5cf6',
pointBorderWidth: 2,
pointRadius: 4,
pointHoverRadius: 6
}
]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true,
grid: {
drawBorder: false
}
},
x: {
grid: {
display: false
}
}
},
plugins: {
legend: {
position: 'top',
align: 'end',
labels: {
boxWidth: 12,
padding: 16,
usePointStyle: true,
pointStyle: 'circle'
}
},
tooltip: {
backgroundColor: '#1e293b',
titleFont: {
size: 14,
weight: 'bold'
},
bodyFont: {
size: 12
},
padding: 12,
usePointStyle: true,
callbacks: {
labelColor: function(context) {
return {
borderColor: 'transparent',
backgroundColor: context.dataset.borderColor,
borderRadius: 2
};
}
}
}
}
}
});
} |