From 546b8dc44821d8757b0edd54f8ef9ab5a52fb7e0 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 14 Nov 2019 20:55:55 +0100 Subject: [PATCH] omnishell minor changes --- pandora_console/include/functions_ui.php | 148 +++++++------------ pandora_console/include/styles/omnishell.css | 6 + pandora_console/include/styles/progress.css | 1 + 3 files changed, 58 insertions(+), 97 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 0ad31cf931..d6afa8ffac 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -2915,119 +2915,73 @@ function ui_progress( * Generates a progress bar CSS based. * Requires css progress.css * - * @param array $progress Progress. - * @param string $width Width. - * @param integer $height Height in 'em'. - * @param array $color status color. - * @param boolean $return Return or paint (if false). - * @param boolean $text Text to be displayed,by default progress %. - * @param array $ajax Ajax: [ 'page' => 'page', 'data' => 'data' ] Sample: - * [ - * 'page' => 'operation/agentes/ver_agente', Target page. - * 'interval' => 100 / $agent["intervalo"], Ask every interval seconds. - * 'data' => [ Data to be sent to target page. - * 'id_agente' => $id_agente, - * 'refresh_contact' => 1, - * ], - * ]. + * @param array $data With following content: + * + * 'slices' => [ + * 'label' => [ // Name of the slice + * 'value' => value + * 'color' => color of the slice. + * ] + * ], + * 'width' => Width + * 'height' => Height in 'em' + * 'return' => Boolean, return or paint. * * @return string HTML code. */ function ui_progress_extend( - $progress, - $width='100%', - $height='2.5', - $color='#82b92e', - $return=true, - $text='', - $ajax=false + array $data ) { - if (!$progress['total']) { - $progress = 0; + if (is_array($data) === false) { + // Failed. + return false; } - $totalW = ($progress['total'] * 100); - if ($totalW > 100) { - $totalW = 100; + if (is_array($data['slices']) === false) { + // Failed. + return false; } - if ($totalW < 0) { - $totalW = 0; + if (isset($data['width']) === false) { + $data['width'] = '100'; } - if (empty($text)) { - $text = $totalW.'%'; + if (isset($data['height']) === false) { + $data['height'] = '1.3'; + } + + $total = array_reduce( + $data['slices'], + function ($carry, $item) { + $carry += $item['value']; + return $carry; + } + ); + if ($total == 0) { + return null; } - $badW = (($progress['bad'] * 100 ) / $progress['total']); - $goodW = (($progress['good'] * 100 ) / $progress['total']); - $unknownW = (($progress['unknown'] * 100 ) / $progress['total']); ui_require_css_file('progress'); - $output .= '
'; - $output .= '
'; - $output .= '
'; - $output .= '
'; + + // Main container. + $output .= '
'; + + foreach ($data['slices'] as $label => $def) { + $width = ($def['value'] * 100 / $total); + $output .= '
$value) { - $output .= ' - '.$token.':"'.$value.'",'; - } - } - - $output .= ' - page: "'.$ajax['page'].'" - }, - success: function(data) { - try { - val = JSON.parse(data); - $(".progress_main").attr("data-label", val["last_contact"]+" s"); - $(".progress").width(val["progress"]+"%"); - } catch (e) { - console.error(e); - $(".progress_text").attr("data-label", (last -1) + " s"); - if (width < 100) { - $(".progress").width((width+width_interval) + "%"); - } - } - } - }); - } else { - $(".progress_main").attr("data-label", (last -1) + " s"); - if (width < 100) { - $(".progress").width((width+width_interval) + "%"); - } - } - }, 1000); - }); - '; - } - - if (!$return) { + if (!$data['return']) { echo $output; } diff --git a/pandora_console/include/styles/omnishell.css b/pandora_console/include/styles/omnishell.css index b6dcd37826..e1d1a6ad98 100644 --- a/pandora_console/include/styles/omnishell.css +++ b/pandora_console/include/styles/omnishell.css @@ -19,6 +19,12 @@ height: 20px; } +.element-target-big { + width: 100px; + margin: 2px; + height: 100px; +} + .status-normal { background-color: #add570; } diff --git a/pandora_console/include/styles/progress.css b/pandora_console/include/styles/progress.css index f263e87fcf..c88687a204 100644 --- a/pandora_console/include/styles/progress.css +++ b/pandora_console/include/styles/progress.css @@ -4,6 +4,7 @@ position: relative; width: 100%; display: inline-block; + display: flex; } .progress_main:before { content: attr(data-label);