MCPcopy Create free account
hub / github.com/OWASP/Python-Honeypot / search_database

Function search_database

web/static/js/explore.js:594–631  ·  view source on GitHub ↗

* Function called when "search" button is clicked in the "Log explorer" display

()

Source from the content-addressed store, hash-verified

592 * Function called when "search" button is clicked in the "Log explorer" display
593 */
594function 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

Callers

nothing calls this directly

Calls 4

displayErrorMessageFunction · 0.85
hideErrorMessageFunction · 0.85
load_dataFunction · 0.85
$Function · 0.70

Tested by

no test coverage detected