mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
move massive aperation edit agent pandora_enterprise#8564
This commit is contained in:
parent
5650758e5a
commit
e58bc4f96a
@ -169,154 +169,6 @@ if ($delete === true) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$table = new stdClass;
|
|
||||||
$table->id = 'delete_table';
|
|
||||||
$table->class = 'databox filters';
|
|
||||||
$table->width = '100%';
|
|
||||||
$table->data = [];
|
|
||||||
$table->style = [];
|
|
||||||
$table->style[0] = 'font-weight: bold;';
|
|
||||||
$table->style[2] = 'font-weight: bold';
|
|
||||||
$table->size = [];
|
|
||||||
$table->size[0] = '15%';
|
|
||||||
$table->size[1] = '35%';
|
|
||||||
$table->size[2] = '15%';
|
|
||||||
$table->size[3] = '35%';
|
|
||||||
|
|
||||||
$table->data = [];
|
|
||||||
$table->data[0][0] = __('Group');
|
|
||||||
$table->data[0][1] = html_print_select_groups(
|
|
||||||
false,
|
|
||||||
'AW',
|
|
||||||
true,
|
|
||||||
'id_group',
|
|
||||||
$id_group,
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
'',
|
|
||||||
true
|
|
||||||
);
|
|
||||||
$table->data[0][2] = __('Group recursion');
|
|
||||||
$table->data[0][3] = html_print_checkbox(
|
|
||||||
'recursion',
|
|
||||||
1,
|
|
||||||
$recursion,
|
|
||||||
true,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
$status_list = [];
|
|
||||||
$status_list[AGENT_STATUS_NORMAL] = __('Normal');
|
|
||||||
$status_list[AGENT_STATUS_WARNING] = __('Warning');
|
|
||||||
$status_list[AGENT_STATUS_CRITICAL] = __('Critical');
|
|
||||||
$status_list[AGENT_STATUS_UNKNOWN] = __('Unknown');
|
|
||||||
$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal');
|
|
||||||
$status_list[AGENT_STATUS_NOT_INIT] = __('Not init');
|
|
||||||
$table->data[1][0] = __('Status');
|
|
||||||
$table->data[1][1] = html_print_select(
|
|
||||||
$status_list,
|
|
||||||
'status_agents',
|
|
||||||
'selected',
|
|
||||||
'',
|
|
||||||
__('All'),
|
|
||||||
AGENT_STATUS_ALL,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
$table->data[1][2] = __('Show agents');
|
|
||||||
$table->data[1][3] = html_print_select(
|
|
||||||
[
|
|
||||||
0 => 'Only enabled',
|
|
||||||
1 => 'Only disabled',
|
|
||||||
],
|
|
||||||
'disabled',
|
|
||||||
2,
|
|
||||||
'',
|
|
||||||
__('All'),
|
|
||||||
2,
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
true,
|
|
||||||
'',
|
|
||||||
false,
|
|
||||||
'width:30%;'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (is_metaconsole() === true) {
|
|
||||||
$servers = metaconsole_get_servers();
|
|
||||||
$server_fields = [];
|
|
||||||
foreach ($servers as $key => $server) {
|
|
||||||
$server_fields[$key] = $server['server_name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$table->data[2][2] = __('Node');
|
|
||||||
$table->data[2][3] = html_print_select(
|
|
||||||
$server_fields,
|
|
||||||
'nodes[]',
|
|
||||||
0,
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
'',
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
'',
|
|
||||||
false,
|
|
||||||
'min-width: 500px; max-width: 500px; max-height: 100px',
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$table->data[3][0] = __('Agents');
|
|
||||||
$table->data[3][0] .= '<span id="agent_loading" class="invisible">';
|
|
||||||
$table->data[3][0] .= html_print_image('images/spinner.png', true);
|
|
||||||
$table->data[3][0] .= '</span>';
|
|
||||||
|
|
||||||
$agents = [];
|
|
||||||
if (is_metaconsole() === false) {
|
|
||||||
$agents = agents_get_group_agents(
|
|
||||||
array_keys(users_get_groups($config['id_user'], 'AW', false)),
|
|
||||||
['disabled' => 2],
|
|
||||||
'none'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$table->data[3][1] = html_print_select(
|
|
||||||
$agents,
|
|
||||||
'id_agents[]',
|
|
||||||
0,
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
'',
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
'',
|
|
||||||
false,
|
|
||||||
'min-width: 500px; max-width: 500px; max-height: 100px',
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
$url = 'index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_agents';
|
$url = 'index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_agents';
|
||||||
if (is_metaconsole() === true) {
|
if (is_metaconsole() === true) {
|
||||||
@ -324,10 +176,15 @@ if (is_metaconsole() === true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo '<form method="post" id="form_agent" action="'.$url.'">';
|
echo '<form method="post" id="form_agent" action="'.$url.'">';
|
||||||
html_print_table($table);
|
|
||||||
|
$params = [
|
||||||
|
'id_group' => $id_group,
|
||||||
|
'recursion' => $recursion,
|
||||||
|
];
|
||||||
|
echo get_table_inputs_masive_agents($params);
|
||||||
|
|
||||||
if (is_metaconsole() === true || is_management_allowed() === true) {
|
if (is_metaconsole() === true || is_management_allowed() === true) {
|
||||||
attachActionButton('delete', 'delete', $table->width);
|
attachActionButton('delete', 'delete', '100%');
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</form>';
|
echo '</form>';
|
||||||
@ -342,54 +199,6 @@ ui_require_jquery_file('pandora.controls');
|
|||||||
$(document).ready (function () {
|
$(document).ready (function () {
|
||||||
// Check Metaconsole.
|
// Check Metaconsole.
|
||||||
var metaconsole = '<?php echo (is_metaconsole() === true) ? 1 : 0; ?>';
|
var metaconsole = '<?php echo (is_metaconsole() === true) ? 1 : 0; ?>';
|
||||||
|
form_controls_massive_operations_agents(metaconsole);
|
||||||
// Listeners.
|
|
||||||
var recursion;
|
|
||||||
$("#checkbox-recursion").click(function () {
|
|
||||||
recursion = this.checked ? 1 : 0;
|
|
||||||
$("#id_group").trigger("change");
|
|
||||||
});
|
|
||||||
|
|
||||||
var disabled;
|
|
||||||
$("#disabled").change(function () {
|
|
||||||
disabled = this.value;
|
|
||||||
$("#id_group").trigger("change");
|
|
||||||
});
|
|
||||||
|
|
||||||
var nodes;
|
|
||||||
$("#nodes").change(function () {
|
|
||||||
nodes = $("#nodes").val();
|
|
||||||
$("#id_group").trigger("change");
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#status_agents").change(function() {
|
|
||||||
$("#id_group").trigger("change");
|
|
||||||
});
|
|
||||||
|
|
||||||
// Build data.
|
|
||||||
var data = {
|
|
||||||
status_agents: function () {
|
|
||||||
return $("#status_agents").val();
|
|
||||||
},
|
|
||||||
agentSelect: "select#id_agents",
|
|
||||||
privilege: "AW",
|
|
||||||
recursion: function() {
|
|
||||||
return recursion;
|
|
||||||
},
|
|
||||||
disabled: function() {
|
|
||||||
return disabled;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
if (metaconsole == 1) {
|
|
||||||
data.serialized = true;
|
|
||||||
data.serialized_separator = '|';
|
|
||||||
data.nodes = function() {
|
|
||||||
return nodes;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Change agents.
|
|
||||||
$("#id_group").pandoraSelectGroupAgent(data);
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -68,11 +68,6 @@ $options_agents = [
|
|||||||
'edit_agents' => __('Bulk agent edit'),
|
'edit_agents' => __('Bulk agent edit'),
|
||||||
'delete_agents' => __('Bulk agent delete'),
|
'delete_agents' => __('Bulk agent delete'),
|
||||||
];
|
];
|
||||||
if (is_metaconsole() === true) {
|
|
||||||
$options_agents = [
|
|
||||||
'delete_agents' => __('Bulk agent delete'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (check_acl($config['id_user'], 0, 'UM')) {
|
if (check_acl($config['id_user'], 0, 'UM')) {
|
||||||
$options_users = [
|
$options_users = [
|
||||||
|
@ -95,3 +95,168 @@ function attachActionButton(
|
|||||||
$return
|
$return
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get table inputs for massive operation agents edit and delete.
|
||||||
|
*
|
||||||
|
* @param array $params Params.
|
||||||
|
*
|
||||||
|
* @return string Output.
|
||||||
|
*/
|
||||||
|
function get_table_inputs_masive_agents($params)
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$table = new stdClass;
|
||||||
|
$table->id = 'delete_table';
|
||||||
|
$table->class = 'databox filters';
|
||||||
|
$table->width = '100%';
|
||||||
|
$table->data = [];
|
||||||
|
$table->style = [];
|
||||||
|
$table->style[0] = 'font-weight: bold;';
|
||||||
|
$table->style[2] = 'font-weight: bold';
|
||||||
|
$table->size = [];
|
||||||
|
$table->size[0] = '15%';
|
||||||
|
$table->size[1] = '35%';
|
||||||
|
$table->size[2] = '15%';
|
||||||
|
$table->size[3] = '35%';
|
||||||
|
|
||||||
|
$table->data = [];
|
||||||
|
$table->data[0][0] = __('Group');
|
||||||
|
$table->data[0][1] = html_print_select_groups(
|
||||||
|
false,
|
||||||
|
'AW',
|
||||||
|
true,
|
||||||
|
'id_group',
|
||||||
|
$params['id_group'],
|
||||||
|
false,
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
true
|
||||||
|
);
|
||||||
|
$table->data[0][2] = __('Group recursion');
|
||||||
|
$table->data[0][3] = html_print_checkbox(
|
||||||
|
'recursion',
|
||||||
|
1,
|
||||||
|
$params['recursion'],
|
||||||
|
true,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
$status_list = [];
|
||||||
|
$status_list[AGENT_STATUS_NORMAL] = __('Normal');
|
||||||
|
$status_list[AGENT_STATUS_WARNING] = __('Warning');
|
||||||
|
$status_list[AGENT_STATUS_CRITICAL] = __('Critical');
|
||||||
|
$status_list[AGENT_STATUS_UNKNOWN] = __('Unknown');
|
||||||
|
$status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal');
|
||||||
|
$status_list[AGENT_STATUS_NOT_INIT] = __('Not init');
|
||||||
|
$table->data[1][0] = __('Status');
|
||||||
|
$table->data[1][1] = html_print_select(
|
||||||
|
$status_list,
|
||||||
|
'status_agents',
|
||||||
|
'selected',
|
||||||
|
'',
|
||||||
|
__('All'),
|
||||||
|
AGENT_STATUS_ALL,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$table->data[1][2] = __('Show agents');
|
||||||
|
$table->data[1][3] = html_print_select(
|
||||||
|
[
|
||||||
|
0 => 'Only enabled',
|
||||||
|
1 => 'Only disabled',
|
||||||
|
],
|
||||||
|
'disabled',
|
||||||
|
2,
|
||||||
|
'',
|
||||||
|
__('All'),
|
||||||
|
2,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
'',
|
||||||
|
false,
|
||||||
|
'width:30%;'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (is_metaconsole() === true) {
|
||||||
|
$servers = metaconsole_get_servers();
|
||||||
|
$server_fields = [];
|
||||||
|
foreach ($servers as $key => $server) {
|
||||||
|
$server_fields[$key] = $server['server_name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$table->data[2][2] = __('Node');
|
||||||
|
$table->data[2][3] = html_print_select(
|
||||||
|
$server_fields,
|
||||||
|
'nodes[]',
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
'',
|
||||||
|
false,
|
||||||
|
'min-width: 500px; max-width: 500px; max-height: 100px',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
'',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$table->data[3][0] = __('Agents');
|
||||||
|
$table->data[3][0] .= '<span id="agent_loading" class="invisible">';
|
||||||
|
$table->data[3][0] .= html_print_image('images/spinner.png', true);
|
||||||
|
$table->data[3][0] .= '</span>';
|
||||||
|
|
||||||
|
$agents = [];
|
||||||
|
if (is_metaconsole() === false) {
|
||||||
|
$agents = agents_get_group_agents(
|
||||||
|
array_keys(users_get_groups($config['id_user'], 'AW', false)),
|
||||||
|
['disabled' => 2],
|
||||||
|
'none'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$table->data[3][1] = html_print_select(
|
||||||
|
$agents,
|
||||||
|
'id_agents[]',
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
'',
|
||||||
|
false,
|
||||||
|
'min-width: 500px; max-width: 500px; max-height: 100px',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
'',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$output = html_print_table($table, true);
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
@ -94,3 +94,55 @@ function showMassiveOperationMessage(message) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
function form_controls_massive_operations_agents(metaconsole) {
|
||||||
|
// Listeners.
|
||||||
|
var recursion;
|
||||||
|
$("#checkbox-recursion").click(function() {
|
||||||
|
recursion = this.checked ? 1 : 0;
|
||||||
|
$("#id_group").trigger("change");
|
||||||
|
});
|
||||||
|
|
||||||
|
var disabled;
|
||||||
|
$("#disabled").change(function() {
|
||||||
|
disabled = this.value;
|
||||||
|
$("#id_group").trigger("change");
|
||||||
|
});
|
||||||
|
|
||||||
|
var nodes;
|
||||||
|
$("#nodes").change(function() {
|
||||||
|
nodes = $("#nodes").val();
|
||||||
|
$("#id_group").trigger("change");
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#status_agents").change(function() {
|
||||||
|
$("#id_group").trigger("change");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Build data.
|
||||||
|
var data = {
|
||||||
|
status_agents: function() {
|
||||||
|
return $("#status_agents").val();
|
||||||
|
},
|
||||||
|
agentSelect: "select#id_agents",
|
||||||
|
privilege: "AW",
|
||||||
|
recursion: function() {
|
||||||
|
return recursion;
|
||||||
|
},
|
||||||
|
disabled: function() {
|
||||||
|
return disabled;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (metaconsole == 1) {
|
||||||
|
data.serialized = true;
|
||||||
|
data.serialized_separator = "|";
|
||||||
|
data.nodes = function() {
|
||||||
|
return nodes;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Change agents.
|
||||||
|
$("#id_group").pandoraSelectGroupAgent(data);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user