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',
'', __('All'), AGENT_STATUS_ALL, true);
$table->data[1][2] = __('Only disabled agents');
$table->data[1][3] = html_print_checkbox ("disabled", 1, $disabled,
true, false);
$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] .= '<span id="agent_loading" class="invisible">';
@ -176,10 +176,11 @@ ui_require_jquery_file ('pandora.controls');
var disabled;
$("#checkbox-disabled").click(function () {
disabled = this.checked ? 1 : 0;
$("#id_group").trigger("change");
$("#disabled").click(function () {
disabled = this.value;
$("#id_group").trigger("change");
});
$("#id_group").pandoraSelectGroupAgent ({
@ -199,5 +200,10 @@ ui_require_jquery_file ('pandora.controls');
$("#status_agents").change(function() {
$("#id_group").trigger("change");
});
disabled = 2;
$("#id_group").trigger("change");
});
</script>

View File

@ -222,7 +222,9 @@ $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 (array(0 => 'Only enabled',1 => 'Only disabled'), 'disabled',2,'',__('All'),
2,true,'','','','','width:30%;');
$table->data[2][0] = __('Agents');
$table->data[2][0] .= '<span id="agent_loading" class="invisible">';
$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 () {
var idAgents = Array();
@ -591,22 +601,28 @@ $(document).ready (function () {
});
$("#id_group").pandoraSelectGroupAgent ({
status_agents: function () {
return $("#status_agents").val();
},
agentSelect: "select#id_agents",
privilege: "AW",
status_agents: function () {
return $("#status_agents").val();
},
recursion: function() {return recursion}
recursion: function() {
return recursion;
},
disabled: function() {
return disabled;
}
});
$("#status_agents").change(function() {
$("#id_group").trigger("change");
});
$("#id_group").pandoraSelectGroupAgentDisabled ({
agentSelect: "select#id_agents",
recursion: function() {return recursion}
});
disabled = 2;
$("#id_group").trigger("change");
});
function changeIcons() {

View File

@ -35,7 +35,6 @@
$("option[value!=0]", $select).remove ();
if (! config.callbackBefore (this))
return;
var opts = {
"page" : "godmode/groups/group_list",
"get_group_agents" : 1,
@ -43,15 +42,15 @@
"recursion" : config.recursion,
"filter_agents_json" : config.filter_agents_json,
"disabled" : (typeof config.disabled === "function")
? (config.disabled() ? 1 : 0)
: (config.disabled ? 1 : 0),
? (config.disabled())
: (config.disabled),
"status_agents" : config.status_agents,
"add_alert_bulk_op" : config.add_alert_bulk_op,
"privilege" : config.privilege,
// Add a key prefix to avoid auto sorting in js object conversion
"keys_prefix" : "_"
};
if(opts['disabled'] == 1 || opts['disabled'] == 0){
jQuery.post ("ajax.php",
opts,
function (data, status) {
@ -73,6 +72,57 @@
},
"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"
);
}
});
});
};