From 9f9d64f020b252d70941b4e7cbedaa790ef4c7a6 Mon Sep 17 00:00:00 2001
From: mdtrooper
Date: Fri, 28 Aug 2009 16:52:10 +0000
Subject: [PATCH] 2009-08-28 Miguel de Dios
* extensions/module_groups, extensions/module_groups/icon_menu.png,
extensions/module_groups.php: add extension to show table of modules where
the columns is the modules group and the rows is the agents group. And
this extension use as example in wiki openideas.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1890 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
pandora_console/ChangeLog | 7 +
pandora_console/extensions/module_groups.php | 135 ++++++++++++++++++
.../extensions/module_groups/icon_menu.png | Bin 0 -> 779 bytes
3 files changed, 142 insertions(+)
create mode 100644 pandora_console/extensions/module_groups.php
create mode 100755 pandora_console/extensions/module_groups/icon_menu.png
diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog
index af47eb431d..29d51303cf 100644
--- a/pandora_console/ChangeLog
+++ b/pandora_console/ChangeLog
@@ -1,3 +1,10 @@
+2009-08-28 Miguel de Dios
+
+ * extensions/module_groups, extensions/module_groups/icon_menu.png,
+ extensions/module_groups.php: add extension to show table of modules where
+ the columns is the modules group and the rows is the agents group. And
+ this extension use as example in wiki openideas.
+
2009-08-28 Miguel de Dios
* include/functions_db.php: add function get_all_model_groups for to
diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php
new file mode 100644
index 0000000000..c9f10f6e4c
--- /dev/null
+++ b/pandora_console/extensions/module_groups.php
@@ -0,0 +1,135 @@
+" . __("Combine table of agent group and module group") . "";
+
+ echo "" . __("This table show in columns the modules group and for rows agents group. The cell show all modules") . "
";
+
+
+ $agentGroups = get_user_groups ($config['id_user']);
+ $modelGroups = get_all_model_groups();
+ array_walk($modelGroups, 'translate'); //Translate all head titles to language is set
+
+ $head = $modelGroups;
+ array_unshift($head, ' ');
+
+ //Metaobject use in print_table
+ $table = null;
+ $table->align[0] = 'right'; //Align to right the first column.
+ $table->style[0] = 'color: #ffffff; background-color: #778866; font-weight: bolder;';
+ $table->head = $head;
+
+ //The content of table
+ $tableData = array();
+ //Create rows and celds
+ foreach ($agentGroups as $idAgentGroup => $name) {
+
+ $row = array();
+
+ array_push($row, $name);
+
+ foreach ($modelGroups as $idModelGroup => $modelGroup) {
+ $query = sprintf($sql,$idAgentGroup, $idModelGroup);
+ $rowsDB = get_db_all_rows_sql ($query);
+
+ $states = array();
+ if ($rowsDB !== false) {
+ foreach ($rowsDB as $rowDB) {
+ $states[$rowDB['estado']] = $rowDB['count'];
+ }
+ }
+
+ $count = 0;
+ foreach ($states as $idState => $state) {
+ $count = $state;
+ }
+
+ $color = 'transparent'; //Defaut color for cell
+ if ($count == 0) {
+ $color = '#babdb6'; //Grey when the cell for this model group and agent group hasn't modules.
+ }
+ else {
+ if (array_key_exists(0,$states) && (count($states) == 1))
+ $color = '#8ae234'; //Green when the cell for this model group and agent has OK state all modules.
+ else {
+ if (array_key_exists(1,$states))
+ $color = '#cc0000'; //Red when the cell for this model group and agent has at least one module in critical state and the rest in any state.
+ else
+ $color = '#fce94f'; //Yellow when the cell for this model group and agent has at least one in warning state and the rest in green state.
+ }
+ }
+
+ array_push($row,
+ '
+ ' . $count . ' modules
');
+ }
+ array_push($tableData,$row);
+ }
+ $table->data = $tableData;
+
+ print_table($table);
+
+ echo "" . __("The colours meaning:") .
+ "
" .
+ '-
+
' .
+ __("Grey when the cell for this model group and agent group hasn't modules.") . " " .
+ '-
+
' .
+ __("Green when the cell for this model group and agent has OK state all modules.") . " " .
+ '
' .
+ __("Red when the cell for this model group and agent has at least one module in critical state and the rest in any state.") . " " .
+ '
' .
+ __("Yellow when the cell for this model group and agent has at least one in warning state and the rest in green state.") . " " .
+ "
" .
+ "
";
+}
+
+add_operation_menu_option("Modules groups", 'estado', 'module_groups/icon_menu.png');
+add_extension_main_function('mainModuleGroups');
+?>
diff --git a/pandora_console/extensions/module_groups/icon_menu.png b/pandora_console/extensions/module_groups/icon_menu.png
new file mode 100755
index 0000000000000000000000000000000000000000..a706306eae76b41efaeec3d79d4e98c8eddc38e6
GIT binary patch
literal 779
zcmV+m1N8ifP)Px#24YJ`L;wH)0002_L%V+f000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iXM<
z3o13_SNQG#001>~MObu0Z*6U5Zgc=BV<{jqFfcSAN?~htVjxp=Wod3@ataDVa%Ew3
zWn>_CX>@2HRA^-&M@dakklBlG0006?NklF>zqzgr-CUHqKm17
z(J>=2FF`OciopoCOaE>iqMLOJ4?$h5$VN~Kg=JzVA<)QZkb(u~cF;^07|oQux!3)D
ze@_RS7_P$a>Gy;0=flIpqmd_1?$e_bXDx*b&pFSWWhF>H*
zC!*paR!k)GK_u2GLl5~r7@%Q0qiz2T23YoVy{MzGBZP|1LMn~?v>|2*6dfQt)i5%2
z)i~wHnPc>A@NJLBUq@j_7%`^Mt4uV90*3;75*3+7cYW$~AFFsdK>rSb-HxBqZcxz>
zTB&TpHUSipNCS#Q?r0~1)G5So+K
zHHyPQ^rlwSmO$6hkOZihj;2g>7pTQaRIC8?ElcL@M`T?`QaQu{m|KGCDmJhdN)f}3
z`e9&ef%L>Qn1Z#CCOx`>wzm=$p|*xhQ!C~lJ1Eczve5%tMKjrH698-8B0Xl1d=yP4
zV}&>_o+R0avz&z;HxLd|GCoW~;x|MR{WG$5MNL0TrD>b(yek~+Mm%JV!9S-8k
zdk5pgxPhVL?MLl6&Vg15k^!{{i9ROY&1anzTt3v!y}W|olT=$-CSwNsBB}cYng%u-
z9Im|-&sZF6YGsN4#p~_Z-9{Q_rp5X{hLw^7O
literal 0
HcmV?d00001