* Function called when "search" button is clicked in the "Log explorer" display
()
| 592 | * Function called when "search" button is clicked in the "Log explorer" display |
| 593 | */ |
| 594 | function search_database() { |
| 595 | let api_endpoint = "/api/events/explore/"; |
| 596 | let api_params = {}; |
| 597 | // Get event type and module name if data explorer |
| 598 | const event_type = $("select[name='event_type'] option:selected").val(); |
| 599 | const module_name = $("select[name='module_names'] option:selected").val(); |
| 600 | // Update end point |
| 601 | api_endpoint += event_type; |
| 602 | // Set the API parameters |
| 603 | api_params.event_type = event_type; |
| 604 | api_params.module_name = module_name; |
| 605 | // Get date range |
| 606 | const start_date = $("#start_date").val(); |
| 607 | const end_date = $("#end_date").val(); |
| 608 | if (event_type === "") { |
| 609 | displayErrorMessage(translations.event_type_error); |
| 610 | } else if (start_date === "" && end_date === "") { |
| 611 | displayErrorMessage(translations.date_not_selected_error); |
| 612 | } else if (start_date === "") { |
| 613 | displayErrorMessage(translations.start_date_not_selected_error); |
| 614 | } else if (end_date === "") { |
| 615 | displayErrorMessage(translations.end_date_not_selected_error); |
| 616 | } else { |
| 617 | if (start_date <= end_date) { |
| 618 | //Hide error message |
| 619 | hideErrorMessage(); |
| 620 | // Date Range format Eg: 2020-09-10|2020-10-10 |
| 621 | api_params.date = start_date + '|' + end_date |
| 622 | // Call API and load data to table |
| 623 | load_data( |
| 624 | api_endpoint, |
| 625 | api_params |
| 626 | ); |
| 627 | } else { |
| 628 | displayErrorMessage(translations.start_date_greater_error) |
| 629 | } |
| 630 | } |
| 631 | } |
| 632 | |
| 633 | /** |
| 634 | * Function is called to hide the Error Message element in Log Explorer |
nothing calls this directly
no test coverage detected