Просмотр исходного кода

reports - ottimizzazione aggiornamento grafici

ferrari 2 месяцев назад
Родитель
Сommit
ee29aa9992

+ 3 - 3
app/Http/Livewire/Reports.php

@@ -113,20 +113,20 @@ class Reports extends Component
     {
     {
         $this->courses = $this->getCoursesForSelect();
         $this->courses = $this->getCoursesForSelect();
         $this->emit('chartsUpdated');
         $this->emit('chartsUpdated');
-        $this->dispatchBrowserEvent('chartsUpdated');
+        // $this->dispatchBrowserEvent('chartsUpdated');
     }
     }
 
 
     public function updateCourseChart()
     public function updateCourseChart()
     {
     {
         $this->emit('chartsUpdated');
         $this->emit('chartsUpdated');
-        $this->dispatchBrowserEvent('chartsUpdated');
+        // $this->dispatchBrowserEvent('chartsUpdated');
     }
     }
 
 
     public function updatedSeasonFilter()
     public function updatedSeasonFilter()
     {
     {
         $this->courses = $this->getCoursesForSelect();
         $this->courses = $this->getCoursesForSelect();
         $this->emit('chartsUpdated');
         $this->emit('chartsUpdated');
-        $this->dispatchBrowserEvent('chartsUpdated');
+        // $this->dispatchBrowserEvent('chartsUpdated');
     }
     }
 
 
     public function setSeasonFilter($season)
     public function setSeasonFilter($season)

+ 4 - 2
resources/views/layouts/app.blade.php

@@ -438,8 +438,10 @@
         }
         }
         $(document).ready(function() {
         $(document).ready(function() {
             $(document).on("click",`[data-bs-trigger='hover focus']`,function() {
             $(document).on("click",`[data-bs-trigger='hover focus']`,function() {
-                $(".bs-popover-auto").css('display','none')
-                $(this).popover('hide');
+                $(".bs-popover-auto").css('display','none');
+                if (typeof $(this).popover !== "undefined") { 
+                    $(this).popover('hide');
+                }
             });
             });
         });
         });
         function newexportaction(e, dt, button, config) {
         function newexportaction(e, dt, button, config) {

+ 8 - 6
resources/views/livewire/reports.blade.php

@@ -27,7 +27,7 @@
         <div class="controls-section">
         <div class="controls-section">
             <div class="control-group">
             <div class="control-group">
                 <label for="season-filter">Stagione di Riferimento:</label>
                 <label for="season-filter">Stagione di Riferimento:</label>
-                <select class="form-select" wire:model="seasonFilter" wire:change="updateCharts">
+                <select class="form-select" wire:model="seasonFilter" {{--wire:change="updateCharts"--}}>
                     @foreach($this->getAvailableSeasons() as $season)
                     @foreach($this->getAvailableSeasons() as $season)
                     <option value="{{ $season }}">{{ $season }}</option>
                     <option value="{{ $season }}">{{ $season }}</option>
                     @endforeach
                     @endforeach
@@ -203,11 +203,6 @@
                     this.updateMonthlyTable(monthlyData);
                     this.updateMonthlyTable(monthlyData);
                 });
                 });
 
 
-                @this.call('getYearlyTotals').then(yearlyData => {
-                    console.log('Got yearly data:', yearlyData);
-                    this.updateYearlyTable(yearlyData);
-                });
-
                 @this.call('getTopCausalsByAmount').then(causalsData => {
                 @this.call('getTopCausalsByAmount').then(causalsData => {
                     console.log('Got causals data:', causalsData);
                     console.log('Got causals data:', causalsData);
                     this.createCausalsChart(originalSeasonKey, causalsData);
                     this.createCausalsChart(originalSeasonKey, causalsData);
@@ -714,8 +709,10 @@
                 container.innerHTML = tableHtml;
                 container.innerHTML = tableHtml;
             },
             },
             updateYearlyTable: function (yearlyData) {
             updateYearlyTable: function (yearlyData) {
+                console.log('here');
                 const container = document.getElementById('yearly-table');
                 const container = document.getElementById('yearly-table');
                 if (!container) return;
                 if (!container) return;
+                console.log('here2');
 
 
                 const incomeData = yearlyData.datasets[0].data;
                 const incomeData = yearlyData.datasets[0].data;
                 const expenseData = yearlyData.datasets[1].data;
                 const expenseData = yearlyData.datasets[1].data;
@@ -1279,6 +1276,11 @@
         document.addEventListener('DOMContentLoaded', function () {
         document.addEventListener('DOMContentLoaded', function () {
             setTimeout(() => {
             setTimeout(() => {
                 window.ReportsChartManager.updateMainCharts();
                 window.ReportsChartManager.updateMainCharts();
+                
+                @this.call('getYearlyTotals').then(yearlyData => {
+                    console.log('Got yearly data:', yearlyData);
+                    window.ReportsChartManager.updateYearlyTable(yearlyData);
+                });
             }, 100);
             }, 100);
         });
         });