Spaces:
Running
Running
File size: 34,928 Bytes
20345c8 | 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 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 | // Initialize Lucide Icons
lucide.createIcons();
// Page Management
const pages = {
'dashboard': {
title: 'Enterprise Dashboard',
subtitle: 'Real-time analytics and reporting'
},
'revenue': {
title: 'Revenue Analytics',
subtitle: 'Detailed revenue breakdown and forecasting'
},
'patient-intelligence': {
title: 'Patient Intelligence',
subtitle: 'Demographics, conditions, and patient analytics'
},
'expiring-patients': {
title: 'Expiring Patient Reports',
subtitle: 'Monitor and manage patient expiration risk'
},
'renewal-reports': {
title: 'Renewal & Approval Reports',
subtitle: 'Track renewal rates and approval metrics'
},
'provider-performance': {
title: 'Provider Performance',
subtitle: 'Provider analytics and performance tracking'
},
'appointment-reports': {
title: 'Appointment Reports',
subtitle: 'Appointment analytics and scheduling insights'
},
'one-click-reports': {
title: 'One-Click Reports',
subtitle: 'Pre-built reports for instant insights'
},
'custom-reports': {
title: 'Custom Reports Builder',
subtitle: 'Build, save, and schedule custom reports'
}
};
// Chart instances storage
const charts = {};
// Initialize the application
document.addEventListener('DOMContentLoaded', function() {
initializeCharts();
initializeEventListeners();
});
// Page Navigation
function showPage(pageId) {
// Hide all pages
document.querySelectorAll('.page').forEach(page => {
page.classList.remove('active');
});
// Show selected page
const pageElement = document.getElementById(pageId);
if (pageElement) {
pageElement.classList.add('active');
// Update page title
const pageInfo = pages[pageId];
if (pageInfo) {
document.getElementById('page-title').textContent = pageInfo.title;
document.getElementById('page-subtitle').textContent = pageInfo.subtitle;
}
// Update navigation active state
document.querySelectorAll('.nav-item').forEach(item => {
item.classList.remove('active', 'bg-primary-light', 'text-primary');
item.classList.add('text-gray-700', 'hover:bg-gray-100');
});
const activeNav = document.querySelector(`[onclick="showPage('${pageId}')"]`);
if (activeNav) {
activeNav.classList.add('active', 'bg-primary-light', 'text-primary');
activeNav.classList.remove('text-gray-700', 'hover:bg-gray-100');
}
// Refresh charts for the new page
setTimeout(() => {
refreshPageCharts(pageId);
}, 100);
}
}
// Slide-out Panel Management
function openSlideOut(panelId) {
const panel = document.getElementById('slide-out-panel');
panel.classList.add('open');
// Load panel content based on panelId
loadPanelContent(panelId);
}
function closeSlideOut() {
const panel = document.getElementById('slide-out-panel');
panel.classList.remove('open');
}
// Modal Management
function openModal(modalId) {
const modal = document.getElementById(modalId);
if (modal) {
modal.classList.remove('hidden');
modal.classList.add('flex');
}
}
function closeModal(modalId) {
const modal = document.getElementById(modalId);
if (modal) {
modal.classList.add('hidden');
modal.classList.remove('flex');
}
}
// Initialize Charts
function initializeCharts() {
// Revenue Trend Chart
const revenueCtx = document.getElementById('revenueTrendChart');
if (revenueCtx) {
charts.revenueTrend = new Chart(revenueCtx, {
type: 'line',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
datasets: [{
label: 'Revenue ($)',
data: [320000, 350000, 380000, 420000, 450000, 480000, 510000, 540000, 580000, 620000, 650000, 690000],
borderColor: '#0e9692',
backgroundColor: 'rgba(14, 150, 146, 0.1)',
borderWidth: 3,
fill: true,
tension: 0.4
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
display: false
},
tooltip: {
mode: 'index',
intersect: false
}
},
scales: {
y: {
beginAtZero: false,
grid: {
display: true,
color: 'rgba(0, 0, 0, 0.05)'
},
ticks: {
callback: function(value) {
return '$' + (value / 1000).toFixed(0) + 'K';
}
}
},
x: {
grid: {
display: false
}
}
}
}
});
}
// Patient Distribution Chart
const patientCtx = document.getElementById('patientDistributionChart');
if (patientCtx) {
charts.patientDistribution = new Chart(patientCtx, {
type: 'doughnut',
data: {
labels: ['Chronic Pain', 'Anxiety', 'Sleep Disorders', 'PTSD', 'Cancer', 'Other'],
datasets: [{
data: [35, 25, 15, 12, 8, 5],
backgroundColor: [
'#0e9692',
'#10b981',
'#3b82f6',
'#8b5cf6',
'#ec4899',
'#6b7280'
],
borderWidth: 0
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'bottom',
labels: {
padding: 20,
usePointStyle: true
}
}
}
}
});
}
// Expiring Chart
const expiringCtx = document.getElementById('expiringChart');
if (expiringCtx) {
charts.expiring = new Chart(expiringCtx, {
type: 'doughnut',
data: {
labels: ['Expiring', 'Active'],
datasets: [{
data: [312, 8430],
backgroundColor: ['#f59e0b', '#0e9692'],
borderWidth: 0
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
display: false
}
}
}
});
}
// Revenue by Category Chart
const categoryCtx = document.getElementById('revenueByCategoryChart');
if (categoryCtx) {
charts.revenueByCategory = new Chart(categoryCtx, {
type: 'bar',
data: {
labels: ['Consultations', 'Products', 'Renewals', 'Follow-ups', 'Other'],
datasets: [{
label: 'Revenue ($)',
data: [185000, 245000, 98000, 65000, 42000],
backgroundColor: '#0e9692',
borderRadius: 6
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
display: false
}
},
scales: {
y: {
beginAtZero: true,
grid: {
display: true,
color: 'rgba(0, 0, 0, 0.05)'
},
ticks: {
callback: function(value) {
return '$' + (value / 1000).toFixed(0) + 'K';
}
}
},
x: {
grid: {
display: false
}
}
}
}
});
}
// Monthly Revenue Chart
const monthlyCtx = document.getElementById('monthlyRevenueChart');
if (monthlyCtx) {
charts.monthlyRevenue = new Chart(monthlyCtx, {
type: 'line',
data: {
labels: ['Week 1', 'Week 2', 'Week 3', 'Week 4'],
datasets: [{
label: 'Current Month',
data: [85000, 92000, 98000, 105000],
borderColor: '#0e9692',
backgroundColor: 'rgba(14, 150, 146, 0.1)',
borderWidth: 3,
fill: true,
tension: 0.4
}, {
label: 'Previous Month',
data: [82000, 88000, 91000, 95000],
borderColor: '#9ca3af',
backgroundColor: 'transparent',
borderWidth: 2,
borderDash: [5, 5],
tension: 0.4
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'top',
labels: {
usePointStyle: true
}
}
},
scales: {
y: {
beginAtZero: false,
grid: {
display: true,
color: 'rgba(0, 0, 0, 0.05)'
},
ticks: {
callback: function(value) {
return '$' + (value / 1000).toFixed(0) + 'K';
}
}
},
x: {
grid: {
display: false
}
}
}
}
});
}
// Age Distribution Chart
const ageCtx = document.getElementById('ageDistributionChart');
if (ageCtx) {
charts.ageDistribution = new Chart(ageCtx, {
type: 'bar',
data: {
labels: ['18-25', '26-35', '36-45', '46-55', '56-65', '65+'],
datasets: [{
label: 'Patients',
data: [12, 28, 35, 25, 15, 5],
backgroundColor: '#0e9692',
borderRadius: 6
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
display: false
}
},
scales: {
y: {
beginAtZero: true,
grid: {
display: true,
color: 'rgba(0, 0, 0, 0.05)'
},
ticks: {
callback: function(value) {
return value + '%';
}
}
},
x: {
grid: {
display: false
}
}
}
}
});
}
// Conditions Chart
const conditionsCtx = document.getElementById('conditionsChart');
if (conditionsCtx) {
charts.conditions = new Chart(conditionsCtx, {
type: 'polarArea',
data: {
labels: ['Chronic Pain', 'Anxiety', 'Insomnia', 'PTSD', 'Cancer', 'Migraine'],
datasets: [{
data: [42, 28, 15, 8, 4, 3],
backgroundColor: [
'#0e9692',
'#10b981',
'#3b82f6',
'#8b5cf6',
'#ec4899',
'#f59e0b'
],
borderWidth: 0
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'bottom',
labels: {
padding: 20,
usePointStyle: true
}
}
}
}
});
}
// Growth Gauge Chart
const growthCtx = document.getElementById('growthGauge');
if (growthCtx) {
charts.growthGauge = new Chart(growthCtx, {
type: 'doughnut',
data: {
labels: ['Growth', 'Remaining'],
datasets: [{
data: [24.8, 75.2],
backgroundColor: ['#0e9692', '#e5e7eb'],
borderWidth: 0
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
display: false
},
tooltip: {
callbacks: {
label: function(context) {
return context.label + ': ' + context.parsed + '%';
}
}
}
},
cutout: '80%'
}
});
}
// Provider Trend Chart for slide-out
const providerTrendCtx = document.getElementById('providerTrendChart');
if (providerTrendCtx) {
charts.providerTrend = new Chart(providerTrendCtx, {
type: 'line',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
datasets: [{
label: 'Satisfaction Score',
data: [88, 90, 92, 91, 94, 95],
borderColor: '#0e9692',
backgroundColor: 'rgba(14, 150, 146, 0.1)',
borderWidth: 3,
fill: true,
tension: 0.4
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
display: false
}
},
scales: {
y: {
beginAtZero: false,
min: 85,
max: 100,
grid: {
display: true,
color: 'rgba(0, 0, 0, 0.05)'
},
ticks: {
callback: function(value) {
return value + '%';
}
}
},
x: {
grid: {
display: false
}
}
}
}
});
}
}
// Initialize Event Listeners
function initializeEventListeners() {
// Close modals when clicking outside
document.querySelectorAll('[id$="-modal"]').forEach(modal => {
modal.addEventListener('click', function(e) {
if (e.target === this) {
closeModal(modal.id);
}
});
});
// Close slide-out when clicking outside
const slideOut = document.getElementById('slide-out-panel');
if (slideOut) {
slideOut.addEventListener('click', function(e) {
if (e.target === this) {
closeSlideOut();
}
});
}
// Close report detail panel when clicking outside
const reportPanel = document.getElementById('report-detail-panel');
if (reportPanel) {
reportPanel.addEventListener('click', function(e) {
if (e.target === this) {
closeSlideOut();
}
});
}
// Escape key to close modals
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
closeSlideOut();
closeModal('report-detail-panel');
document.querySelectorAll('[id$="-modal"]').forEach(modal => {
if (!modal.classList.contains('hidden')) {
closeModal(modal.id);
}
});
}
});
// Initialize drag and drop for custom reports
initializeDragAndDrop();
}
// Refresh charts for specific page
function refreshPageCharts(pageId) {
switch(pageId) {
case 'dashboard':
if (charts.revenueTrend) charts.revenueTrend.update();
if (charts.patientDistribution) charts.patientDistribution.update();
if (charts.expiring) charts.expiring.update();
break;
case 'revenue':
if (charts.revenueByCategory) charts.revenueByCategory.update();
if (charts.monthlyRevenue) charts.monthlyRevenue.update();
if (charts.growthGauge) charts.growthGauge.update();
break;
case 'patient-intelligence':
if (charts.ageDistribution) charts.ageDistribution.update();
if (charts.conditions) charts.conditions.update();
break;
}
}
// Load panel content
function loadPanelContent(panelId) {
// In a real application, this would fetch content from a server
// For demo, we'll just update some elements
console.log('Loading panel content for:', panelId);
}
// Generate Report
function generateReport(reportType) {
const reports = {
'monthly-performance': {
title: 'Monthly Performance Report',
message: 'Generating comprehensive monthly performance report...'
},
'provider-metrics': {
title: 'Provider Metrics Report',
message: 'Creating detailed provider performance analysis...'
},
'expiration-risk': {
title: 'Expiration Risk Report',
message: 'Compiling expiration risk assessment...'
},
'ai-recommendations': {
title: 'AI Recommendations Report',
message: 'Generating personalized AI recommendations...'
}
};
const report = reports[reportType];
if (report) {
// Show loading state
const button = event.target.closest('button');
const originalText = button ? button.innerHTML : '';
if (button) {
button.innerHTML = '<i data-lucide="loader-2" class="w-4 h-4 animate-spin"></i> Generating...';
button.disabled = true;
}
// Simulate report generation
setTimeout(() => {
if (button) {
button.innerHTML = originalText;
button.disabled = false;
}
// Show success message
alert(`β
${report.title} generated successfully!`);
// In a real app, this would download the report
console.log(`Generated report: ${reportType}`);
}, 1500);
}
}
// Export Report
function exportReport() {
// Show loading
const button = event.target;
const originalText = button.innerHTML;
button.innerHTML = '<i data-lucide="loader-2" class="w-4 h-4 animate-spin"></i> Exporting...';
button.disabled = true;
// Simulate export process
setTimeout(() => {
button.innerHTML = originalText;
button.disabled = false;
closeModal('export-modal');
// Show success
alert('β
Report exported successfully! The download will begin shortly.');
}, 2000);
}
// Initialize tooltips
function initializeTooltips() {
// This would initialize tooltip library in a real app
console.log('Tooltips initialized');
}
// Custom Reports Functions
function initializeDragAndDrop() {
const draggableComponents = document.querySelectorAll('.draggable-component');
const reportCanvas = document.getElementById('report-canvas');
draggableComponents.forEach(component => {
component.addEventListener('dragstart', function(e) {
e.dataTransfer.setData('text/plain', this.dataset.component);
this.classList.add('opacity-50');
});
component.addEventListener('dragend', function() {
this.classList.remove('opacity-50');
});
});
if (reportCanvas) {
reportCanvas.addEventListener('dragover', function(e) {
e.preventDefault();
this.classList.add('border-primary', 'border-solid');
this.classList.remove('border-dashed', 'border-gray-300');
});
reportCanvas.addEventListener('dragleave', function() {
this.classList.remove('border-primary', 'border-solid');
this.classList.add('border-dashed', 'border-gray-300');
});
reportCanvas.addEventListener('drop', function(e) {
e.preventDefault();
this.classList.remove('border-primary', 'border-solid');
this.classList.add('border-dashed', 'border-gray-300');
const componentType = e.dataTransfer.getData('text/plain');
addComponentToCanvas(componentType);
});
}
}
function addComponentToCanvas(type) {
const canvas = document.getElementById('report-canvas');
// Remove placeholder if present
const placeholder = canvas.querySelector('.text-center');
if (placeholder) {
placeholder.remove();
}
let componentHTML = '';
switch(type) {
case 'kpi':
componentHTML = `
<div class="bg-gray-50 rounded-lg p-6 border border-gray-200">
<div class="flex items-center justify-between mb-4">
<h4 class="font-medium text-gray-900">KPI Component</h4>
<button onclick="removeComponent(this)" class="text-gray-400 hover:text-gray-600">
<i data-lucide="x" class="w-4 h-4"></i>
</button>
</div>
<div class="grid grid-cols-2 gap-4">
<div class="bg-white rounded-lg p-4">
<p class="text-sm text-gray-600">Metric 1</p>
<p class="text-xl font-bold text-gray-900">$12,450</p>
</div>
<div class="bg-white rounded-lg p-4">
<p class="text-sm text-gray-600">Metric 2</p>
<p class="text-xl font-bold text-gray-900">84.2%</p>
</div>
</div>
</div>
`;
break;
case 'chart':
componentHTML = `
<div class="bg-gray-50 rounded-lg p-6 border border-gray-200">
<div class="flex items-center justify-between mb-4">
<h4 class="font-medium text-gray-900">Chart Component</h4>
<div class="flex items-center space-x-2">
<select class="border border-gray-300 rounded-lg px-2 py-1 text-sm">
<option>Line Chart</option>
<option>Bar Chart</option>
<option>Pie Chart</option>
</select>
<button onclick="removeComponent(this)" class="text-gray-400 hover:text-gray-600">
<i data-lucide="x" class="w-4 h-4"></i>
</button>
</div>
</div>
<div class="h-48 bg-white rounded-lg flex items-center justify-center">
<div class="text-center">
<i data-lucide="pie-chart" class="w-8 h-8 text-gray-400 mx-auto mb-2"></i>
<p class="text-sm text-gray-600">Chart preview will appear here</p>
</div>
</div>
</div>
`;
break;
case 'table':
componentHTML = `
<div class="bg-gray-50 rounded-lg p-6 border border-gray-200">
<div class="flex items-center justify-between mb-4">
<h4 class="font-medium text-gray-900">Table Component</h4>
<button onclick="removeComponent(this)" class="text-gray-400 hover:text-gray-600">
<i data-lucide="x" class="w-4 h-4"></i>
</button>
</div>
<div class="bg-white rounded-lg overflow-hidden">
<table class="min-w-full">
<thead class="bg-gray-100">
<tr>
<th class="px-4 py-2 text-left text-sm font-medium text-gray-700">Column 1</th>
<th class="px-4 py-2 text-left text-sm font-medium text-gray-700">Column 2</th>
<th class="px-4 py-2 text-left text-sm font-medium text-gray-700">Column 3</th>
</tr>
</thead>
<tbody>
<tr class="border-b border-gray-200">
<td class="px-4 py-2 text-sm text-gray-700">Data 1</td>
<td class="px-4 py-2 text-sm text-gray-700">Data 2</td>
<td class="px-4 py-2 text-sm text-gray-700">Data 3</td>
</tr>
<tr>
<td class="px-4 py-2 text-sm text-gray-700">Data 4</td>
<td class="px-4 py-2 text-sm text-gray-700">Data 5</td>
<td class="px-4 py-2 text-sm text-gray-700">Data 6</td>
</tr>
</tbody>
</table>
</div>
</div>
`;
break;
case 'filter':
componentHTML = `
<div class="bg-gray-50 rounded-lg p-6 border border-gray-200">
<div class="flex items-center justify-between mb-4">
<h4 class="font-medium text-gray-900">Filter Component</h4>
<button onclick="removeComponent(this)" class="text-gray-400 hover:text-gray-600">
<i data-lucide="x" class="w-4 h-4"></i>
</button>
</div>
<div class="flex flex-wrap gap-3">
<select class="border border-gray-300 rounded-lg px-4 py-2 text-sm">
<option>Date Range</option>
<option>Last 7 days</option>
<option>Last 30 days</option>
<option>Last quarter</option>
</select>
<select class="border border-gray-300 rounded-lg px-4 py-2 text-sm">
<option>Location</option>
<option>All locations</option>
<option>Downtown Clinic</option>
<option>Westside Clinic</option>
</select>
<select class="border border-gray-300 rounded-lg px-4 py-2 text-sm">
<option>Provider</option>
<option>All providers</option>
<option>Dr. Smith</option>
<option>Dr. Johnson</option>
</select>
</div>
</div>
`;
break;
}
canvas.insertAdjacentHTML('beforeend', componentHTML);
lucide.createIcons();
}
function removeComponent(button) {
const component = button.closest('.bg-gray-50');
if (component) {
component.remove();
// Show placeholder if canvas is empty
const canvas = document.getElementById('report-canvas');
if (canvas.children.length === 0) {
canvas.innerHTML = `
<div class="text-center py-12">
<i data-lucide="layout" class="w-12 h-12 text-gray-400 mx-auto mb-4"></i>
<p class="text-gray-600">Drag and drop components here to build your report</p>
<p class="text-sm text-gray-500 mt-1">Start by dragging components from the left panel</p>
</div>
`;
}
}
}
function clearCanvas() {
const canvas = document.getElementById('report-canvas');
if (canvas) {
canvas.innerHTML = `
<div class="text-center py-12">
<i data-lucide="layout" class="w-12 h-12 text-gray-400 mx-auto mb-4"></i>
<p class="text-gray-600">Drag and drop components here to build your report</p>
<p class="text-sm text-gray-500 mt-1">Start by dragging components from the left panel</p>
</div>
`;
}
}
function saveCustomReport() {
const button = event.target;
const originalText = button.innerHTML;
button.innerHTML = '<i data-lucide="loader-2" class="w-4 h-4 animate-spin"></i> Saving...';
button.disabled = true;
setTimeout(() => {
button.innerHTML = originalText;
button.disabled = false;
alert('β
Custom report saved successfully!');
}, 1500);
}
function generateCustomReport() {
const button = event.target;
const originalText = button.innerHTML;
button.innerHTML = '<i data-lucide="loader-2" class="w-4 h-4 animate-spin"></i> Generating...';
button.disabled = true;
setTimeout(() => {
button.innerHTML = originalText;
button.disabled = false;
alert('β
Custom report generated successfully!\n\nThe report has been added to your saved reports and is ready for export.');
}, 2000);
}
function previewReport() {
alert('π Report Preview\n\nThis would open a preview of your custom report in a new window or modal.');
}
function createNewReport() {
const button = event.target;
const originalText = button.innerHTML;
button.innerHTML = '<i data-lucide="loader-2" class="w-4 h-4 animate-spin"></i> Creating...';
button.disabled = true;
setTimeout(() => {
button.innerHTML = originalText;
button.disabled = false;
closeModal('new-report-modal');
alert('β
New report template created!\n\nYou can now start building your custom report by dragging components to the canvas.');
}, 1500);
}
function runReport(reportId) {
const button = event.target;
const originalText = button.innerHTML;
button.innerHTML = '<i data-lucide="loader-2" class="w-4 h-4 animate-spin"></i> Running...';
button.disabled = true;
setTimeout(() => {
button.innerHTML = originalText;
button.disabled = false;
alert(`β
Report "${reportId}" executed successfully!\n\nThe report has been generated and is ready for review.`);
}, 2000);
}
function deleteReport(reportId) {
if (confirm(`Are you sure you want to delete the "${reportId}" report? This action cannot be undone.`)) {
const button = event.target;
const row = button.closest('tr');
button.innerHTML = '<i data-lucide="loader-2" class="w-4 h-4 animate-spin"></i>';
button.disabled = true;
setTimeout(() => {
row.style.opacity = '0.5';
setTimeout(() => {
row.remove();
alert(`β
Report "${reportId}" has been deleted.`);
}, 300);
}, 1000);
}
}
function saveReportConfig() {
const button = event.target;
const originalText = button.innerHTML;
button.innerHTML = '<i data-lucide="loader-2" class="w-4 h-4 animate-spin"></i> Saving...';
button.disabled = true;
setTimeout(() => {
button.innerHTML = originalText;
button.disabled = false;
closeSlideOut();
alert('β
Report configuration saved successfully!');
}, 1500);
}
function testReport() {
const button = event.target;
const originalText = button.innerHTML;
button.innerHTML = '<i data-lucide="loader-2" class="w-4 h-4 animate-spin"></i> Testing...';
button.disabled = true;
setTimeout(() => {
button.innerHTML = originalText;
button.disabled = false;
alert('β
Report test completed successfully!\n\nThe test report has been generated and sent to your email for review.');
}, 2000);
}
// Search functionality
function initializeSearch() {
const searchInput = document.querySelector('input[placeholder="Search reports..."]');
if (searchInput) {
searchInput.addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
const query = this.value.trim();
if (query) {
performSearch(query);
}
}
});
}
}
function performSearch(query) {
console.log('Searching for:', query);
// In a real app, this would make an API call
alert(`Searching for: ${query}\n\nThis would show search results in a real application.`);
}
// Initialize search on load
initializeSearch(); |