* Call the API to get event data from the database * @param {*} api_endpoint : API endpoint URL * @param {*} column_list : List of Columns for the selected event type * @param {*} api_params : GET parameters for the API call
(api_endpoint, column_list, api_params)
| 321 | * @param {*} api_params : GET parameters for the API call |
| 322 | */ |
| 323 | function get_event_data(api_endpoint, column_list, api_params) { |
| 324 | |
| 325 | $(document).ready(function () { |
| 326 | const table = $("#datatable").DataTable({ |
| 327 | ajax: $.fn.dataTable.pipeline({ |
| 328 | pages: 10, |
| 329 | type: "GET", |
| 330 | url: api_endpoint, |
| 331 | contentType: 'application/json; charset=utf-8', |
| 332 | data: api_params, |
| 333 | dataType: "json", |
| 334 | dataSrc: "data" |
| 335 | }), |
| 336 | autoWidth: true, |
| 337 | dom: "<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>>" + |
| 338 | "<'row'<'col-sm-12'tr>>" + |
| 339 | "<'row'<'col-sm-12 col-md-2'B><'col-sm-12 col-md-4'i><'col-sm-12 col-md-6'p>>", |
| 340 | buttons: [ |
| 341 | { |
| 342 | text: 'CSV', |
| 343 | action: function (e, dt, button, config) { |
| 344 | downloadLogData(api_endpoint, column_list, api_params, "CSV") |
| 345 | }, |
| 346 | }, |
| 347 | { |
| 348 | text: 'EXCEL', |
| 349 | action: function (e, dt, button, config) { |
| 350 | downloadLogData(api_endpoint, column_list, api_params, "EXCEL") |
| 351 | } |
| 352 | }, |
| 353 | |
| 354 | { |
| 355 | text: 'JSON', |
| 356 | action: function (e, dt, button, config) { |
| 357 | downloadLogData(api_endpoint, column_list, api_params, "JSON") |
| 358 | } |
| 359 | } |
| 360 | ], |
| 361 | columns: column_list, |
| 362 | destroy: true, |
| 363 | order: [[0, 'desc']], |
| 364 | sort: true, |
| 365 | info: true, |
| 366 | paging: true, |
| 367 | serverSide: true, |
| 368 | processing: true, |
| 369 | language: { |
| 370 | loadingRecords: ' ', |
| 371 | processing: `<div class="spinner">${translations.loading}</div>`, |
| 372 | sEmptyTable: `<div>${translations.no_records_present_message}</div>` |
| 373 | }, |
| 374 | oLanguage: { |
| 375 | sStripClasses: "", |
| 376 | sSearch: "", |
| 377 | sSearchPlaceholder: "Search filter...", |
| 378 | sInfo: "_START_ -_END_ of _TOTAL_", |
| 379 | sLengthMenu: '<span>Rows per page:</span><select class="browser-default">' + |
| 380 | '<option value="10">10</option>' + |
no test coverage detected