UX console in progres... (Added hierachy mode in modules list)

This commit is contained in:
Arturo Gonzalez 2017-01-18 17:33:28 +01:00
parent fe6f924d7a
commit 55063a20dc
3 changed files with 120 additions and 27 deletions

View File

@ -101,6 +101,7 @@ if (strstr($sec2, "enterprise/godmode/policies/policies") !== false) {
}
$show_creation = false;
$checked = get_parameter("checked");
if (($policy_page) || (isset($agent))) {
if ($policy_page) {
@ -115,6 +116,16 @@ if (($policy_page) || (isset($agent))) {
// Create module/type combo
echo '<form id="create_module_type" method="post" action="'.$url.'">';
echo '<td class="datos" style="font-weight: bold;">';
echo __('Show in hierachy mode');
if ($checked == "true") {
$checked = true;
}
else {
$checked = false;
}
html_print_checkbox ('status_hierachy_mode', "", $checked, false, false, "onChange=change_mod_filter();");
echo '</td>';
echo '<td class="datos" style="font-weight: bold;">';
echo __("Type");
html_print_select ($modules, 'moduletype', '', '', '', '', false, false, false, '', false, 'max-width:300px;' );
html_print_input_hidden ('edit_module', 1);
@ -450,12 +461,23 @@ switch ($config["dbtype"]) {
else {
$limit_sql = '';
}
$sql = sprintf("SELECT %s
FROM tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE %s %s %s %s %s",
$params, $basic_where, $where, $where_tags, $order_sql, $limit_sql);
if ($checked) {
$sql = sprintf("SELECT *
FROM tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE %s %s %s %s %s",
$basic_where, $where, $where_tags, $order_sql, $limit_sql);
}
else {
$sql = sprintf("SELECT %s
FROM tagente_modulo
LEFT JOIN tmodule_group
ON tagente_modulo.id_module_group = tmodule_group.id_mg
WHERE %s %s %s %s %s",
$params, $basic_where, $where, $where_tags, $order_sql, $limit_sql);
}
$modules = db_get_all_rows_sql($sql);
break;
@ -465,12 +487,24 @@ switch ($config["dbtype"]) {
$set['limit'] = $limit;
$set['offset'] = $offset;
}
$sql = sprintf("SELECT %s
FROM tagente_modulo
LEFT JOIN tmodule_group
ON tmodule_group.id_mg = tagente_modulo.id_module_group
WHERE %s %s %s %s",
$params, $basic_where, $where, $where_tags, $order_sql);
if ($checked) {
$sql = sprintf("SELECT *
FROM tagente_modulo
LEFT JOIN tmodule_group
ON tmodule_group.id_mg = tagente_modulo.id_module_group
WHERE %s %s %s %s",
$basic_where, $where, $where_tags, $order_sql);
}
else {
$sql = sprintf("SELECT %s
FROM tagente_modulo
LEFT JOIN tmodule_group
ON tmodule_group.id_mg = tagente_modulo.id_module_group
WHERE %s %s %s %s",
$params, $basic_where, $where, $where_tags, $order_sql);
}
$modules = oracle_recode_query ($sql, $set, 'AND', false);
break;
}
@ -555,6 +589,15 @@ foreach($tempRows as $row) {
$numericModules[$row['id_tipo']] = true;
}
if ($checked) {
$modules_hierachy = array();
$modules_hierachy = get_hierachy_modules_tree($modules);
$modules_dt = get_dt_from_modules_tree($modules_hierachy);
$modules = $modules_dt;
}
foreach ($modules as $module) {
if (! check_acl ($config["id_user"], $group, "AW", $id_agente) && ! check_acl ($config["id_user"], $group, "AD", $id_agente)) {
continue;
@ -570,20 +613,29 @@ foreach ($modules as $module) {
$module_group2 = $module["id_module_group"];
$data = array ();
if ($module['id_module_group'] != $last_modulegroup) {
$last_modulegroup = $module['id_module_group'];
$data[0] = '<strong>'.modules_get_modulegroup_name ($last_modulegroup).'</strong>';
$i = array_push ($table->data, $data);
$table->rowstyle[$i - 1] = 'text-align: center';
$table->rowclass[$i - 1] = 'datos3';
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK)
$table->colspan[$i - 1][0] = 10;
else
$table->colspan[$i - 1][0] = 8;
$data = array ();
if (!$checked) {
if ($module['id_module_group'] != $last_modulegroup) {
$last_modulegroup = $module['id_module_group'];
$data[0] = '<strong>'.modules_get_modulegroup_name ($last_modulegroup).'</strong>';
$i = array_push ($table->data, $data);
$table->rowstyle[$i - 1] = 'text-align: center';
$table->rowclass[$i - 1] = 'datos3';
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK)
$table->colspan[$i - 1][0] = 10;
else
$table->colspan[$i - 1][0] = 8;
$data = array ();
}
}
$data[0] = "";
if (isset($module['deep']) && ($module['deep'] != 0)) {
$data[0] .= str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $module['deep']);
$data[0] .= html_print_image("images/icono_escuadra.png", true, array("style" => 'padding-bottom: inherit;')) . "&nbsp;&nbsp;";
}
if ($module['quiet']) {
$data[0] .= html_print_image("images/dot_green.disabled.png",
true, array("border" => '0', "title" => __('Quiet'),
@ -764,3 +816,22 @@ if (check_acl ($config['id_user'], $agent['id_grupo'], "AW")) {
echo '</form>';
}
?>
<script type="text/javascript">
function change_mod_filter() {
var checked = $("#checkbox-status_hierachy_mode").is(":checked");
if (/checked/.test(window.location)) {
var url = window.location.toString();
if (checked) {
window.location = url.replace("checked=false", "checked=true");
}
else {
window.location = url.replace("checked=true", "checked=false");
}
}
else {
window.location = window.location + "&checked=true";
}
}
</script>

View File

@ -852,9 +852,14 @@ if ($list_modules) {
$data[2] .= '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;id_agente='.$id_agente.'&amp;tab=module&amp;id_agent_module='.$module["id_agente_modulo"].'&amp;edit_module='.$module["id_modulo"].'">' . html_print_image("images/config.png", true, array("alt" => '0', "border" => "", "title" => __('Edit'))) . '</a>';
$data[3] = "";
if (isset($module['deep']) && ($module['deep'] != 0)) {
$data[3] .= str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $module['deep']);
$data[3] .= html_print_image("images/icono_escuadra.png", true, array("style" => 'padding-bottom: inherit;')) . "&nbsp;&nbsp;";
}
if ($module['quiet']) {
$data[3] .= html_print_image("images/dot_green.disabled.png", true,
array("border" => '0', "title" => __('Quiet'), "alt" => ""))

View File

@ -186,6 +186,20 @@ ui_toggle($html_toggle,
*/
});
function change_module_filter () {
hierachy_mode = $("#checkbox-status_hierachy_mode").is(":checked");
if (hierachy_mode) {
$("#status_module_group").disable();
$("#status_filter_monitor").disable();
$("#status_module_group").val(-1);
$("#status_filter_monitor").val(-1);
}
else {
$("#status_module_group").enable();
$("#status_filter_monitor").enable();
}
}
function order_module_list(sort_field_param, sort_rows_param) {
sort_field = sort_field_param;
sort_rows = sort_rows_param;
@ -263,6 +277,9 @@ ui_toggle($html_toggle,
$("#status_filter_monitor").val(-1);
$("#status_module_group").val(-1);
$("input[name='status_text_monitor']").val("");
$("#checkbox-status_hierachy_mode").prop("checked", false);
$("#status_module_group").enable();
$("#status_filter_monitor").enable();
filter_modules();
}
@ -453,7 +470,7 @@ function print_form_filter_monitors($id_agent, $status_filter_monitor = -1,
}
$table->data[0][5] = html_print_select ($rows_select,'status_module_group', $status_module_group, '', '',0, true);
$table->data[0][6] = __('Show in hierachy mode');
$table->data[0][6] .= html_print_checkbox ('status_hierachy_mode', "", false, true);
$table->data[0][6] .= html_print_checkbox ('status_hierachy_mode', "", false, true, false, "onChange=change_module_filter();");
$table->data[0][7] = html_print_button(__('Filter'), 'filter', false, 'filter_modules();', 'class="sub search"', true);
$table->data[0][8] = '&nbsp;' . html_print_button(__('Reset'), 'filter', false, 'reset_filter_modules();', 'class="sub upd" style="margin-top:0px;"', true);
$form_text .= html_print_table($table, true);