diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index e33bd5a..0f094cf 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -9,7 +9,6 @@ class DashboardController extends Controller { public function index(){ - // dd('public insanity'); return view('dashboard.index'); } @@ -50,8 +49,6 @@ class DashboardController extends Controller 'services' => $stats ]); } - // app/Http/Controllers/DashboardController.php - // app/Http/Controllers/DashboardController.php public function details(Request $request, $id) { $service = DB::table('subscription_services')->where('id', $id)->first(); @@ -77,7 +74,6 @@ class DashboardController extends Controller return view('dashboard.details', compact('service', 'subscribers')); } - // app/Http/Controllers/DashboardController.php public function subscriberProfile(Request $request, $serviceId, $msisdn) { $service = DB::table('subscription_services')->where('id', $serviceId)->first(); diff --git a/info.md b/info.md index 411b532..4e8d463 100644 --- a/info.md +++ b/info.md @@ -35,3 +35,9 @@ techappsuser@206.225.84.201:/home/techappsuser/DockerProjects/subscription_services/src/ + +\App\Models\User::create([ + 'name' => 'Admin User', + 'email' => 'kwesi@click-mobile.com', + 'password' => Hash::make('franctic@233') +]); diff --git a/public/assets/js/dashboard.js b/public/assets/js/dashboard.js index 3fb852d..e61465f 100644 --- a/public/assets/js/dashboard.js +++ b/public/assets/js/dashboard.js @@ -1,6 +1,5 @@ // public/js/dashboard.js $(document).ready(function() { - console.log(base_url); function fetchDashboardStats() { $.ajax({ url: base_url + '/api/dashboard/stats', @@ -83,4 +82,53 @@ $(document).ready(function() { // Todo: Refresh data every 5 minutes (300000 ms) automatically without page reload // setInterval(fetchDashboardStats, 300000); + + $('#syncTriggerBtn').on('click', function() { + let btn = $(this); + let icon = $('#syncIcon'); + let text = $('#syncText'); + + // Disable button and add spinning effect + btn.prop('disabled', true); + icon.addClass('spinner-border spinner-border-sm'); + text.text('Syncing...'); + + $.ajax({ + url: base_url + '/api/subscriptions/sync', + method: 'POST', + data: { + _token: $('meta[name="csrf-token"]').attr('content') + }, + success: function(response) { + // Use SweetAlert2 for a clean success alert + Swal.fire({ + icon: 'success', + title: 'Synchronized!', + text: response.message, + timer: 2000, + showConfirmButton: false + }); + + // Refresh dashboard data instantly to reflect updated counts + fetchDashboardStats(); + }, + error: function(xhr) { + let errorMsg = xhr.responseJSON && xhr.responseJSON.message + ? xhr.responseJSON.message + : 'An unexpected error occurred during synchronization.'; + + Swal.fire({ + icon: 'error', + title: 'Sync Failed', + text: errorMsg + }); + }, + complete: function() { + // Restore button state + btn.prop('disabled', false); + icon.removeClass('spinner-border spinner-border-sm'); + text.text('Sync Now'); + } + }); + }); }); \ No newline at end of file diff --git a/resources/views/dashboard/index.blade.php b/resources/views/dashboard/index.blade.php index 2b9a9a8..df6b3bf 100644 --- a/resources/views/dashboard/index.blade.php +++ b/resources/views/dashboard/index.blade.php @@ -2,7 +2,15 @@ @section('content')