From 43b83af2c6eb0637425b428f57011378e3735daf Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Mon, 24 Jun 2019 11:59:17 +0200 Subject: [PATCH] Changed default images status set for css - #4195 --- .../default/module_alertsfired_rounded.png | Bin 251 -> 0 bytes .../default/module_critical_rounded.png | Bin 250 -> 0 bytes .../default/module_no_data_rounded.png | Bin 251 -> 0 bytes .../status_sets/default/module_ok_rounded.png | Bin 251 -> 0 bytes .../default/module_unknown_rounded.png | Bin 246 -> 0 bytes .../default/module_warning_rounded.png | Bin 249 -> 0 bytes pandora_console/include/ajax/module.php | 2 +- pandora_console/include/functions_modules.php | 41 +++- pandora_console/include/functions_ui.php | 179 ++++++++++++------ pandora_console/include/styles/pandora.css | 42 ++++ pandora_console/include/styles/tree.css | 4 + 11 files changed, 201 insertions(+), 67 deletions(-) delete mode 100644 pandora_console/images/status_sets/default/module_alertsfired_rounded.png delete mode 100644 pandora_console/images/status_sets/default/module_critical_rounded.png delete mode 100644 pandora_console/images/status_sets/default/module_no_data_rounded.png delete mode 100644 pandora_console/images/status_sets/default/module_ok_rounded.png delete mode 100644 pandora_console/images/status_sets/default/module_unknown_rounded.png delete mode 100644 pandora_console/images/status_sets/default/module_warning_rounded.png diff --git a/pandora_console/images/status_sets/default/module_alertsfired_rounded.png b/pandora_console/images/status_sets/default/module_alertsfired_rounded.png deleted file mode 100644 index 7a9b5ae0cdbf28de7a92696c9381bfddecbcc168..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 251 zcmeAS@N?(olHy`uVBq!ia0vp^wm>Yy!3HERP1;@sq$EpRBT9nv(@M${i&7aJQ}UBi z6+Ckj(^G>|6H_V+Po~-c70vZ@aSW-r_2$M#-UbDM*2FCvj`6NpBYRLVrs0s_ofAhK zOIWg{We?6erEHc_()d`t(o!!ZUN0cQr%Ah8+Wu;om-@;nmi#A!cD$`vzYy!3HERP1;@sq$EpRBT9nv(@M${i&7aJQ}UBi z6+Ckj(^G>|6H_V+Po~-c70vNq9xN1B^lw8dxMGCpIXXxv2zj zmNEzxFt|r>F*0A@fAaL#OD|6^m3rO;`QoY|yIGA=A|Y-Zy{Fuw5LQh#vQRMCz9-9M4-JaQ?s o$}8u~#70ZIwsY6y`Z2OG#6OnWnk?Aa2XrTcr>mdKI;Vst0D06|UjP6A diff --git a/pandora_console/images/status_sets/default/module_no_data_rounded.png b/pandora_console/images/status_sets/default/module_no_data_rounded.png deleted file mode 100644 index fd5e433ece26563296312403d351e64ecc4b0471..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 251 zcmeAS@N?(olHy`uVBq!ia0vp^wm>Yy!3HERP1;@sq$EpRBT9nv(@M${i&7aJQ}UBi z6+Ckj(^G>|6H_V+Po~-c70vZ@aSW-r_2$Mx-Ub7K)`y2!78v$i5Zqv4(kFO><0#iu z119N!;PV_Z2Su2;WB#k@U-!N`-CH}$r%Ahe_PtgoFZGpEE%&C(y?x650@Jo2G0%k+ zCz=l|m)NU4=fica&ns36@4RH@|51^dSIQ*g!UD%;HU#4r`(CvNwkpv*a%cZ)u9LJm rms^_he)7FmH_fWu2d+O8Nnj9&liDgYZ{-c3Lm50>{an^LB{Ts5@*7@o diff --git a/pandora_console/images/status_sets/default/module_ok_rounded.png b/pandora_console/images/status_sets/default/module_ok_rounded.png deleted file mode 100644 index d47f2ef4ff90a0c2d335c60e338b2f1158c22948..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 251 zcmeAS@N?(olHy`uVBq!ia0vp^wm>Yy!3HERP1;@sq$EpRBT9nv(@M${i&7aJQ}UBi z6+Ckj(^G>|6H_V+Po~-c70vZ@aSW-r_2xz(Z-ausu|ktZGleGJ0<{fIf;tbHJ$)A4 zIKU=#kVEb>>s&F5e>wO2r2Y5beZZJ36cc%eXS4Q_Ekdi$RC@fmvF13l?gOt=N}3}4 zJB5FUEG};q{uh-hXKFT4JNBujUCIK-W;R|alZ*>UjQYy!3HERP1;@sq$EpRBT9nv(@M${i&7aJQ}UBi z6+Ckj(^G>|6H_V+Po~-c70vK;aSW-r_2z~nZ-W6(>%&H-f(8~9g~sUf9tQ-kuVUb| zVBnnWAg_39-Hxlbt{ zRNdwI)cYy!3HERP1;@sq$EpRBT9nv(@M${i&7aJQ}UBi z6+Ckj(^G>|6H_V+Po~-c70vc^aSW-r_2z~lZ-aqA>%-=mj4~TaU73V7G_+V9;`B&J zW#Z)Fc)-QX%gB6v|H;!|FTFgyR90)!gHw;5MJ%~;DKjhioUgIyyH)&A2YaUl2205m zt^c6tww_J>&(>8oS+88yl}uj#V?rYvuarr~g$0hy2*%&$c|srF&9Zc>-f4eSx4HIV o%K3Zh$CcIwevvtlSj=U>py(^MH8r_+1JIcap00i_>zopr0Q5dzRR910 diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index ef998be34a..5ec365849e 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -1011,7 +1011,7 @@ if (check_login()) { $title ); - $data[5] = ui_print_module_status($module['estado'], $title, true, false, true); + $data[5] = ui_print_status_image($status, $title, true); if (!$show_context_help_first_time) { $show_context_help_first_time = true; diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 0335e851c9..8e42c186fb 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -2308,32 +2308,67 @@ function modules_get_color_status($status) return COL_UNKNOWN; } - switch ($status) { - case AGENT_MODULE_STATUS_NORMAL: - case AGENT_STATUS_NORMAL: + switch ((string) $status) { + case (string) AGENT_MODULE_STATUS_NORMAL: + case (string) AGENT_STATUS_NORMAL: + case STATUS_MODULE_OK: + case STATUS_AGENT_OK: + case STATUS_ALERT_NOT_FIRED: + case STATUS_SERVER_OK: + case STATUS_MODULE_OK_BALL: + case STATUS_AGENT_OK_BALL: + case STATUS_ALERT_NOT_FIRED_BALL: return COL_NORMAL; case AGENT_MODULE_STATUS_NOT_INIT: case AGENT_STATUS_NOT_INIT: + case STATUS_MODULE_NO_DATA: + case STATUS_AGENT_NOT_INIT: + case STATUS_AGENT_NO_DATA: + case STATUS_MODULE_NO_DATA_BALL: + case STATUS_AGENT_NO_DATA_BALL: + case STATUS_AGENT_NO_MONITORS_BALL: return COL_NOTINIT; case AGENT_MODULE_STATUS_CRITICAL_BAD: case AGENT_STATUS_CRITICAL: + case STATUS_MODULE_CRITICAL: + case STATUS_AGENT_CRITICAL: + case STATUS_MODULE_CRITICAL_BALL: + case STATUS_AGENT_CRITICAL_BALL: return COL_CRITICAL; case AGENT_MODULE_STATUS_WARNING: case AGENT_STATUS_WARNING: + case STATUS_MODULE_WARNING: + case STATUS_AGENT_WARNING: + case STATUS_MODULE_WARNING_BALL: + case STATUS_AGENT_WARNING_BALL: return COL_WARNING; case AGENT_MODULE_STATUS_CRITICAL_ALERT: case AGENT_MODULE_STATUS_WARNING_ALERT: case AGENT_STATUS_ALERT_FIRED: + case STATUS_ALERT_FIRED: + case STATUS_ALERT_FIRED_BALL: return COL_ALERTFIRED; case AGENT_MODULE_STATUS_UNKNOWN: case AGENT_STATUS_UNKNOWN: + case STATUS_MODULE_UNKNOWN: + case STATUS_AGENT_UNKNOWN: + case STATUS_AGENT_DOWN: + case STATUS_ALERT_DISABLED: + case STATUS_MODULE_UNKNOWN_BALL: + case STATUS_AGENT_UNKNOWN_BALL: + case STATUS_AGENT_DOWN_BALL: + case STATUS_ALERT_DISABLED_BALL: return COL_UNKNOWN; + case STATUS_SERVER_DOWN: + case STATUS_SERVER_DOWN_BALL: + return '#444'; + default: // Ignored. break; diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index ea07c20d6a..9ffb578a07 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -2592,12 +2592,12 @@ function ui_get_status_images_path() /** * Prints an image representing a status. * - * @param string $type Type. - * @param string $title Title. - * @param boolean $return Whether to return an output string or echo now (optional, echo by default). - * @param array $options Options to set image attributes: I.E.: style. - * @param string $path Path of the image, if not provided use the status path. - * @param boolean $rounded_image Round. + * @param string $type Type. + * @param string $title Title. + * @param boolean $return Whether to return an output string or echo now (optional, echo by default). + * @param array $options Options to set image attributes: I.E.: style. + * @param string $path Path of the image, if not provided use the status path. + * @param boolean $image_with_css Don't use an image. Draw an image with css styles. * * @return string HTML code if return parameter is true. */ @@ -2607,37 +2607,8 @@ function ui_print_status_image( $return=false, $options=false, $path=false, - $rounded_image=false + $image_with_css=false ) { - // This is for the List of Modules in Agent View. - if ($rounded_image === true) { - switch ($type) { - case 'module_ok.png': - $type = 'module_ok_rounded.png'; - break; - - case 'module_critical.png': - $type = 'module_critical_rounded.png'; - break; - - case 'module_warning.png': - $type = 'module_warning_rounded.png'; - break; - - case 'module_no_data.png': - $type = 'module_no_data_rounded.png'; - break; - - case 'module_unknown.png': - $type = 'module_unknown_rounded.png'; - break; - - default: - $type = $type; - break; - } - } - if ($path === false) { $imagepath_array = ui_get_status_images_path(); $imagepath = $imagepath_array[0]; @@ -2645,35 +2616,112 @@ function ui_print_status_image( $imagepath = $path; } - $imagepath .= '/'.$type; - - if ($options === false) { - $options = []; + if ($imagepath == 'images/status_sets/default') { + $image_with_css = true; } - $options['title'] = $title; + $imagepath .= '/'.$type; - return html_print_image($imagepath, $return, $options, false, false, false, true); + if ($image_with_css === true) { + $shape_status = get_shape_status_set($type); + return ui_print_status_sets($type, $title, $return, $shape_status); + } else { + if ($options === false) { + $options = []; + } + + $options['title'] = $title; + + return html_print_image($imagepath, $return, $options, false, false, false, true); + } +} + + +/** + * Get the shape of an image by assigning it a CSS class. Prints an image with CSS representing a status. + * + * @param string $type Module/Agent/Alert status. + * + * @return array With CSS class. + */ +function get_shape_status_set($type) +{ + switch ($type) { + // Small rectangles. + case STATUS_ALERT_NOT_FIRED: + case STATUS_ALERT_FIRED: + case STATUS_ALERT_DISABLED: + $return = ['class' => 'status_small_rectangles']; + break; + + // Rounded rectangles. + case STATUS_MODULE_OK: + case STATUS_AGENT_OK: + case STATUS_MODULE_NO_DATA: + case STATUS_AGENT_NO_DATA: + case STATUS_MODULE_CRITICAL: + case STATUS_AGENT_CRITICAL: + case STATUS_MODULE_WARNING: + case STATUS_AGENT_WARNING: + case STATUS_MODULE_UNKNOWN: + case STATUS_AGENT_UNKNOWN: + case STATUS_AGENT_DOWN: + $return = ['class' => 'status_rounded_rectangles']; + break; + + // Small squares. + case STATUS_SERVER_OK: + case STATUS_SERVER_DOWN: + $return = ['class' => 'status_small_squares']; + break; + + // Balls. + case STATUS_AGENT_CRITICAL_BALL: + case STATUS_AGENT_WARNING_BALL: + case STATUS_AGENT_DOWN_BALL: + case STATUS_AGENT_UNKNOWN_BALL: + case STATUS_AGENT_OK_BALL: + case STATUS_AGENT_NO_DATA_BALL: + case STATUS_AGENT_NO_MONITORS_BALL: + $return = ['class' => 'status_balls']; + break; + + // Small Balls. + case STATUS_MODULE_OK_BALL: + case STATUS_MODULE_CRITICAL_BALL: + case STATUS_MODULE_WARNING_BALL: + case STATUS_MODULE_NO_DATA_BALL: + case STATUS_MODULE_UNKNOWN_BALL: + case STATUS_ALERT_FIRED_BALL: + case STATUS_ALERT_NOT_FIRED_BALL: + case STATUS_ALERT_DISABLED_BALL: + $return = ['class' => 'status_small_balls']; + break; + + default: + // Ignored. + break; + } + + return $return; } /** * Prints an image representing a status. * - * @param string $status Module status. - * @param string $title Title. - * @param boolean $return Whether to return an output string or echo now (optional, echo by default). - * @param array $options Options to set image attributes: I.E.: style. - * @param boolean $rounded_image Round. + * @param string $status Module status. + * @param string $title Title. + * @param boolean $return Whether to return an output string or echo now (optional, echo by default). + * @param array $options Options to set image attributes: I.E.: style. * * @return string HTML. */ -function ui_print_module_status( +function ui_print_status_sets( $status, $title='', $return=false, - $options=false, - $rounded_image=false + $options=false ) { global $config; @@ -2681,21 +2729,26 @@ function ui_print_module_status( $options = []; } - $options['style'] .= 'width: 50px;'; - $options['style'] .= 'height: 2em;'; - $options['style'] .= 'display: inline-block;'; - - include_once __DIR__.'/functions_modules.php'; - $options['style'] .= 'background: '.modules_get_color_status($status).';'; - - if ($rounded_image === true) { - $options['style'] .= 'border-radius: 5px;'; + if (isset($options['style'])) { + $options['style'] .= ' background: '.modules_get_color_status($status).'; display: inline-block;'; + } else { + $options['style'] = 'background: '.modules_get_color_status($status).'; display: inline-block;'; } - $options['title'] = $title; - $options['data-title'] = $title; - $options['data-use_title_for_force_title'] = 1; - $options['class'] = 'forced_title'; + if (isset($options['class'])) { + $options['class'] = $options['class']; + } + + if ($title != '') { + $options['title'] = $title; + $options['data-title'] = $title; + $options['data-use_title_for_force_title'] = 1; + if (isset($options['class'])) { + $options['class'] .= ' forced_title'; + } else { + $options['class'] = 'forced_title'; + } + } $output = '
$v) { diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 06507058ee..002a20db79 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -5803,3 +5803,45 @@ div#status_pie { align-items: center; grid-template-columns: 50px auto; } + +/* + * --------------------------------------------------------------------- + * - IMAGES FOR STATUS. This replaces the images of /images/status_sets/default/ + * - Don't delete this + * --------------------------------------------------------------------- + */ +.status_small_rectangles { + width: 20px; + height: 10px; + display: inline-block; +} + +.status_rounded_rectangles { + width: 50px; + height: 2em; + display: inline-block; + border-radius: 5px; +} + +.status_small_squares, +.status_balls { + width: 12px; + height: 12px; + display: inline-block; +} + +.status_balls { + border-radius: 50%; +} + +.status_small_balls { + width: 8px; + height: 8px; + display: inline-block; + border-radius: 50%; +} +/* + * --------------------------------------------------------------------- + * - END - IMAGES FOR STATUS. Don't delete this + * --------------------------------------------------------------------- + */ diff --git a/pandora_console/include/styles/tree.css b/pandora_console/include/styles/tree.css index f35339a886..42649bd048 100644 --- a/pandora_console/include/styles/tree.css +++ b/pandora_console/include/styles/tree.css @@ -138,3 +138,7 @@ div#tree-controller-recipient { width: 98%; margin-top: 10px; } + +.tree-node > .node-content > div + div:not(.tree-node-counters) { + margin-left: 3px; +}