From a197dec136feae5cbf770f412cb951a62ed62564 Mon Sep 17 00:00:00 2001 From: Mateja Date: Sun, 15 Nov 2020 21:39:32 +0100 Subject: AJAX select special callsign from activities finished. --- app/Http/Controllers/ReservationsController.php | 2 +- public/js/activities.js | 25 ++++++++++++++++++++++++- resources/views/pages/activities.blade.php | 7 ++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ReservationsController.php b/app/Http/Controllers/ReservationsController.php index de1ea76..1865f46 100644 --- a/app/Http/Controllers/ReservationsController.php +++ b/app/Http/Controllers/ReservationsController.php @@ -41,7 +41,7 @@ class ReservationsController extends Controller return response($data); } else { $activities = Reservation::where('approved', '1') - ->select('operatorCall', 'fromTime', 'toTime', 'frequencies', 'qso') + ->select('operatorCall', 'fromTime', 'toTime', 'specialCall', 'frequencies', 'qso') ->where('specialCall', $request->input('call-sign')) ->get() ->toArray(); diff --git a/public/js/activities.js b/public/js/activities.js index f9c19ac..94bee2d 100644 --- a/public/js/activities.js +++ b/public/js/activities.js @@ -8,8 +8,31 @@ jQuery('select#call-sign').change(fillTable); jQuery(document).ready(fillTable); function fillTable() { + tableData = jQuery('table#ajax-table>tbody').first(); + tableData.html('Loading...'); + sign = jQuery('select#call-sign').first().val(); + jQuery.post('/api/activities', {'call-sign': sign}, function (data, status) { - console.log(data); + if (status === 'success') { + if (data.data.length > 0) { + tableData.empty(); + for (var i = 0, len = data.data.length; i < len; i++) { + tr = '' + data.data[i].operatorCall + '' + + '' + data.data[i].fromTime + '' + + '' + data.data[i].toTime + '' + + '' + data.data[i].specialCall + '' + + '' + data.data[i].frequencies + '' + + '' + data.data[i].qso + ''; + tableData.append(tr); + } + } + else { + tableData.html('No data...'); + } + } + else { + tableData.html('Error!'); + } }); } diff --git a/resources/views/pages/activities.blade.php b/resources/views/pages/activities.blade.php index 0c558af..897c622 100644 --- a/resources/views/pages/activities.blade.php +++ b/resources/views/pages/activities.blade.php @@ -16,8 +16,13 @@ @endif -
+
+ + + + +
OperatorFromToSpecial CallsignFrequenciesQSO
-- cgit v1.2.3