From e727f7c276a63d515f1fc89c040b4e732056d17b Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Fri, 12 Feb 2021 11:28:13 +0100 Subject: [PATCH] Added modals and fixed some bugs --- .../massive/massive_add_action_alerts.php | 67 ++++++------- .../godmode/massive/massive_add_alerts.php | 14 ++- .../godmode/massive/massive_add_profiles.php | 48 +++++---- .../godmode/massive/massive_copy_modules.php | 60 +++++++----- .../massive/massive_delete_action_alerts.php | 45 ++++++--- .../godmode/massive/massive_delete_agents.php | 64 ++++++------ .../godmode/massive/massive_delete_alerts.php | 49 ++++++---- .../massive/massive_delete_modules.php | 71 +++++++------- .../massive/massive_delete_profiles.php | 48 +++++---- .../godmode/massive/massive_edit_agents.php | 85 +++++++++------- .../godmode/massive/massive_edit_modules.php | 93 +++++++++--------- .../godmode/massive/massive_edit_plugins.php | 44 ++++++--- .../massive/massive_enable_disable_alerts.php | 39 +++++--- .../godmode/massive/massive_operations.php | 84 ++++++++++------ .../massive/massive_standby_alerts.php | 43 +++++--- .../include/functions_massive_operations.php | 97 +++++++++++++++++++ pandora_console/include/functions_ui.php | 3 +- .../include/javascript/massive_operations.js | 93 ++++++++++++++++++ pandora_console/include/styles/pandora.css | 1 + 19 files changed, 690 insertions(+), 358 deletions(-) create mode 100644 pandora_console/include/functions_massive_operations.php create mode 100644 pandora_console/include/javascript/massive_operations.js diff --git a/pandora_console/godmode/massive/massive_add_action_alerts.php b/pandora_console/godmode/massive/massive_add_action_alerts.php index 7bfbbee09f..f9a02c8545 100755 --- a/pandora_console/godmode/massive/massive_add_action_alerts.php +++ b/pandora_console/godmode/massive/massive_add_action_alerts.php @@ -1,17 +1,32 @@ data[1][0] .= ''; $table->data[1][1] = html_print_select([], 'id_agents[]', 0, false, __('Any'), '', true, true); $table->data[2][0] = __('Alert templates'); -$table->data[2][0] .= ''; $table->data[2][1] = html_print_select([], 'id_alert_templates[]', '', '', '', '', true, true, true, '', $alert_templates == 0); $table->data[2][2] = __('When select agents'); $table->data[2][2] .= '
'; @@ -251,10 +263,8 @@ $agents_with_templates_json = json_encode($agents_with_templates_json); echo ""; -echo '
'; -html_print_input_hidden('add', 1); -html_print_submit_button(__('Add'), 'go', false, 'class="sub add"'); -echo '
'; +attachActionButton('add', 'create', $table->width); + echo ''; echo ''; @@ -265,23 +275,8 @@ ui_require_jquery_file('pandora.controls'); ?> - - "+value+""; }); $("#id_alert_templates").append (options); - $("#template_loading").hide (); + hideSpinner(); $select_template.enable (); }, "json" diff --git a/pandora_console/include/functions_massive_operations.php b/pandora_console/include/functions_massive_operations.php new file mode 100644 index 0000000000..389d87ddcc --- /dev/null +++ b/pandora_console/include/functions_massive_operations.php @@ -0,0 +1,97 @@ + 'action-buttons', + 'style' => sprintf('width: %s', $tableWidth), + 'content' => html_print_input_hidden( + $action, + 1 + ).html_print_button( + __($caption), + 'go', + false, + '', + sprintf('class="sub %s"', $class), + true + ), + ], + $return + ); +} diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index fcf9adce0d..8cb234db8e 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -6277,8 +6277,9 @@ function ui_print_reveal_password(string $name, bool $return=false) /** * Generate a spinner box for waiting times + * TIP: It's made for Massive Operations, but it migth used in entire project. * - * @param string $text Text for show in spinner. English Loading for default. + * @param string $text Text for show in spinner. English term Loading for default. * @param boolean $return If true, return the string with the formed element. * * @return string diff --git a/pandora_console/include/javascript/massive_operations.js b/pandora_console/include/javascript/massive_operations.js new file mode 100644 index 0000000000..dd1c8acd13 --- /dev/null +++ b/pandora_console/include/javascript/massive_operations.js @@ -0,0 +1,93 @@ +/** global $ */ +function massiveOperationValidation(contents, totalCount, limit, thisForm) { + var output = false; + + // If the amount of changes exceed the limit, the operation stops. + if (totalCount > limit) { + // Set the content. + $("#massive_modal") + .empty() + .html(contents.html); + // Set the title. + $("#massive_modal").prop("title", contents.title); + // Build the dialog for show the mesage. + $("#massive_modal").dialog({ + resizable: true, + draggable: true, + modal: true, + width: 800, + buttons: [ + { + text: "OK", + click: function() { + hideSpinner(); + $(this).dialog("close"); + return false; + } + } + ], + overlay: { + opacity: 0.5, + background: "black" + }, + closeOnEscape: false, + open: function(event, ui) { + $(".ui-dialog-titlebar-close").hide(); + } + }); + + return false; + } else { + confirmDialog({ + title: contents.title, + message: contents.question, + ok: contents.ok, + cancel: contents.cancel, + onAccept: function() { + showSpinner(); + output = true; + $("#" + thisForm).submit(); + }, + onDeny: function() { + hideSpinner(); + return false; + } + }); + } + + return output; +} + +/* +function showMassiveOperationMessage(message) { + $("#massive_modal") + .empty() + .html(message); + + $("#massive_modal").prop("title", "Massive operations"); + + $("#massive_modal").dialog({ + resizable: true, + draggable: true, + modal: true, + width: 800, + buttons: [ + { + text: "OK", + click: function() { + $(this).dialog("close"); + hideSpinner(); + } + } + ], + overlay: { + opacity: 0.5, + background: "black" + }, + closeOnEscape: false, + open: function(event, ui) { + $(".ui-dialog-titlebar-close").hide(); + } + }); +} +*/ diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index c2cb379ea4..79e5572823 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -813,6 +813,7 @@ p.center { border: 2px solid #82b92e; box-shadow: 2px 2px 2px #9dbba1; padding: 20px; + z-index: 100; } .tactical_set legend {