Merge branch '37-agregar-filtros-a-masivas-agentes-integria-4333' into 'develop'

Disabled and enabled or all agents selector in agent massive operations - #37

See merge request !103
This commit is contained in:
Enrique Camargo 2017-02-01 17:38:26 +01:00
commit 3fe4518464
3 changed files with 92 additions and 20 deletions

View File

@ -120,9 +120,9 @@ $table->data[1][0] = __('Status');
$table->data[1][1] = html_print_select($status_list, 'status_agents', 'selected', $table->data[1][1] = html_print_select($status_list, 'status_agents', 'selected',
'', __('All'), AGENT_STATUS_ALL, true); '', __('All'), AGENT_STATUS_ALL, true);
$table->data[1][2] = __('Only disabled agents'); $table->data[1][2] = __('Show agents');
$table->data[1][3] = html_print_checkbox ("disabled", 1, $disabled, $table->data[1][3] = html_print_select (array(0 => 'Only enabled',1 => 'Only disabled'), 'disabled',2,'',__('All'),
true, false); 2,true,'','','','','width:30%;');
$table->data[2][0] = __('Agents'); $table->data[2][0] = __('Agents');
$table->data[2][0] .= '<span id="agent_loading" class="invisible">'; $table->data[2][0] .= '<span id="agent_loading" class="invisible">';
@ -176,10 +176,11 @@ ui_require_jquery_file ('pandora.controls');
var disabled; var disabled;
$("#checkbox-disabled").click(function () { $("#disabled").click(function () {
disabled = this.checked ? 1 : 0;
disabled = this.value;
$("#id_group").trigger("change");
$("#id_group").trigger("change");
}); });
$("#id_group").pandoraSelectGroupAgent ({ $("#id_group").pandoraSelectGroupAgent ({
@ -199,5 +200,10 @@ ui_require_jquery_file ('pandora.controls');
$("#status_agents").change(function() { $("#status_agents").change(function() {
$("#id_group").trigger("change"); $("#id_group").trigger("change");
}); });
disabled = 2;
$("#id_group").trigger("change");
}); });
</script> </script>

View File

@ -222,7 +222,9 @@ $status_list[AGENT_STATUS_NOT_INIT] = __('Not init');
$table->data[1][0] = __('Status'); $table->data[1][0] = __('Status');
$table->data[1][1] = html_print_select($status_list, 'status_agents', 'selected', $table->data[1][1] = html_print_select($status_list, 'status_agents', 'selected',
'', __('All'), AGENT_STATUS_ALL, true); '', __('All'), AGENT_STATUS_ALL, true);
$table->data[1][2] = __('Show agents');
$table->data[1][3] = html_print_select (array(0 => 'Only enabled',1 => 'Only disabled'), 'disabled',2,'',__('All'),
2,true,'','','','','width:30%;');
$table->data[2][0] = __('Agents'); $table->data[2][0] = __('Agents');
$table->data[2][0] .= '<span id="agent_loading" class="invisible">'; $table->data[2][0] .= '<span id="agent_loading" class="invisible">';
$table->data[2][0] .= html_print_image('images/spinner.png', true); $table->data[2][0] .= html_print_image('images/spinner.png', true);
@ -550,6 +552,14 @@ $(document).ready (function () {
} }
}); });
var disabled;
$("#disabled").click(function () {
disabled = this.value;
$("#id_group").trigger("change");
});
$("#id_agents").change (function () { $("#id_agents").change (function () {
var idAgents = Array(); var idAgents = Array();
@ -591,22 +601,28 @@ $(document).ready (function () {
}); });
$("#id_group").pandoraSelectGroupAgent ({ $("#id_group").pandoraSelectGroupAgent ({
status_agents: function () {
return $("#status_agents").val();
},
agentSelect: "select#id_agents", agentSelect: "select#id_agents",
privilege: "AW", privilege: "AW",
status_agents: function () { recursion: function() {
return $("#status_agents").val(); return recursion;
}, },
recursion: function() {return recursion} disabled: function() {
return disabled;
}
}); });
$("#status_agents").change(function() { $("#status_agents").change(function() {
$("#id_group").trigger("change"); $("#id_group").trigger("change");
}); });
$("#id_group").pandoraSelectGroupAgentDisabled ({
agentSelect: "select#id_agents", disabled = 2;
recursion: function() {return recursion}
}); $("#id_group").trigger("change");
}); });
function changeIcons() { function changeIcons() {

View File

@ -35,7 +35,6 @@
$("option[value!=0]", $select).remove (); $("option[value!=0]", $select).remove ();
if (! config.callbackBefore (this)) if (! config.callbackBefore (this))
return; return;
var opts = { var opts = {
"page" : "godmode/groups/group_list", "page" : "godmode/groups/group_list",
"get_group_agents" : 1, "get_group_agents" : 1,
@ -43,15 +42,15 @@
"recursion" : config.recursion, "recursion" : config.recursion,
"filter_agents_json" : config.filter_agents_json, "filter_agents_json" : config.filter_agents_json,
"disabled" : (typeof config.disabled === "function") "disabled" : (typeof config.disabled === "function")
? (config.disabled() ? 1 : 0) ? (config.disabled())
: (config.disabled ? 1 : 0), : (config.disabled),
"status_agents" : config.status_agents, "status_agents" : config.status_agents,
"add_alert_bulk_op" : config.add_alert_bulk_op, "add_alert_bulk_op" : config.add_alert_bulk_op,
"privilege" : config.privilege, "privilege" : config.privilege,
// Add a key prefix to avoid auto sorting in js object conversion // Add a key prefix to avoid auto sorting in js object conversion
"keys_prefix" : "_" "keys_prefix" : "_"
}; };
if(opts['disabled'] == 1 || opts['disabled'] == 0){
jQuery.post ("ajax.php", jQuery.post ("ajax.php",
opts, opts,
function (data, status) { function (data, status) {
@ -73,6 +72,57 @@
}, },
"json" "json"
); );
}
else{
opts['disabled'] = 0;
jQuery.post ("ajax.php",
opts,
function (data, status) {
jQuery.each (data, function (id, value) {
// Remove keys_prefix from the index
id = id.substring(1);
if (id !== 'keycount') {
config.callbackPre ();
option = $("<option></option>")
.attr ("value", id)
.html (value);
config.callbackPost (id, value, option);
$(config.agentSelect).append (option);
}
});
$(config.loading).hide ();
$select.enable ();
config.callbackAfter ();
},
"json"
);
opts['disabled'] = 1;
jQuery.post ("ajax.php",
opts,
function (data, status) {
jQuery.each (data, function (id, value) {
// Remove keys_prefix from the index
id = id.substring(1);
if (id !== 'keycount') {
config.callbackPre ();
option = $("<option></option>")
.attr ("value", id)
.html (value);
config.callbackPost (id, value, option);
$(config.agentSelect).append (option);
}
});
$(config.loading).hide ();
$select.enable ();
config.callbackAfter ();
},
"json"
);
}
}); });
}); });
}; };