From ee75091c445820673333022a31cd20039bae5a5e Mon Sep 17 00:00:00 2001 From: Louis Bailleul Date: Wed, 2 Dec 2015 12:52:08 +0000 Subject: [PATCH 1/2] Use browser width to scale cpu and bandwidth graphs on device overview --- html/pages/device/overview/ports.inc.php | 16 ++++++++++++++-- html/pages/device/overview/processors.inc.php | 16 +++++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/html/pages/device/overview/ports.inc.php b/html/pages/device/overview/ports.inc.php index 89cf626de..7701b29cd 100644 --- a/html/pages/device/overview/ports.inc.php +++ b/html/pages/device/overview/ports.inc.php @@ -10,8 +10,17 @@ if ($ports['total']) { '; - $graph_array['height'] = '100'; - $graph_array['width'] = '485'; + if($_SESSION['screen_width']) { + if($_SESSION['screen_width'] > 970) { + $graph_array['width'] = round(($_SESSION['screen_width'] - 190 )/2,0); + $graph_array['height'] = round($graph_array['width'] /3); + } + else { + $graph_array['width'] = $_SESSION['screen_width'] - 110; + $graph_array['height'] = round($graph_array['width'] /3); + } + } + $graph_array['to'] = $config['time']['now']; $graph_array['device'] = $device['device_id']; $graph_array['type'] = 'device_bits'; @@ -19,6 +28,9 @@ if ($ports['total']) { $graph_array['legend'] = 'no'; $graph = generate_lazy_graph_tag($graph_array); + #Generate tooltip + $graph_array['width'] = 210; + $graph_array['height'] = 100; $link_array = $graph_array; $link_array['page'] = 'graphs'; unset($link_array['height'], $link_array['width']); diff --git a/html/pages/device/overview/processors.inc.php b/html/pages/device/overview/processors.inc.php index 3aae5f5f8..ca6bac04b 100644 --- a/html/pages/device/overview/processors.inc.php +++ b/html/pages/device/overview/processors.inc.php @@ -64,9 +64,18 @@ if (count($processors)) { if ($config['cpu_details_overview'] === false) { + if($_SESSION['screen_width']) { + if($_SESSION['screen_width'] > 970) { + $graph_array['width'] = round(($_SESSION['screen_width'] - 190 )/2,0); + $graph_array['height'] = round($graph_array['width'] /3); + } + else { + $graph_array['width'] = $_SESSION['screen_width'] - 110; + $graph_array['height'] = round($graph_array['width'] /3); + } + } + //Generate average cpu graph - $graph_array['height'] = '100'; - $graph_array['width'] = '485'; $graph_array['device'] = $device['device_id']; $graph_array['type'] = 'device_processor'; $graph = generate_lazy_graph_tag($graph_array); @@ -78,7 +87,8 @@ if (count($processors)) { $link = generate_url($link_array); //Generate tooltip - $graph_array['width'] = '210'; + $graph_array['width']=210; + $graph_array['height']=100; $overlib_content = generate_overlib_content($graph_array, $device['hostname'].' - CPU usage'); echo ' From b40bd2f467faa48cce15e456afb0ea913d692a19 Mon Sep 17 00:00:00 2001 From: Louis Bailleul Date: Mon, 21 Dec 2015 13:26:48 +0000 Subject: [PATCH 2/2] Rebase --- html/includes/functions.inc.php | 7 +++++++ html/pages/device/overview/ports.inc.php | 6 ++++-- html/pages/device/overview/processors.inc.php | 6 ++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index b30325590..fa9664636 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -473,10 +473,17 @@ function generate_lazy_graph_tag($args) { case 'height': $h = $arg; break; + case 'lazy_w': + $lazy_w = $arg; + break; } $urlargs[] = $key."=".urlencode($arg); } + if(isset($lazy_w)) { + $w=$lazy_w; + } + if ($config['enable_lazy_load'] === true) { return ''; } diff --git a/html/pages/device/overview/ports.inc.php b/html/pages/device/overview/ports.inc.php index 7701b29cd..1d9ce8459 100644 --- a/html/pages/device/overview/ports.inc.php +++ b/html/pages/device/overview/ports.inc.php @@ -12,12 +12,14 @@ if ($ports['total']) { if($_SESSION['screen_width']) { if($_SESSION['screen_width'] > 970) { - $graph_array['width'] = round(($_SESSION['screen_width'] - 190 )/2,0); + $graph_array['width'] = round(($_SESSION['screen_width'] - 390 )/2,0); $graph_array['height'] = round($graph_array['width'] /3); + $graph_array['lazy_w'] = $graph_array['width'] + 80; } else { - $graph_array['width'] = $_SESSION['screen_width'] - 110; + $graph_array['width'] = $_SESSION['screen_width'] - 190; $graph_array['height'] = round($graph_array['width'] /3); + $graph_array['lazy_w'] = $graph_array['width'] + 80; } } diff --git a/html/pages/device/overview/processors.inc.php b/html/pages/device/overview/processors.inc.php index ca6bac04b..6fbd0250c 100644 --- a/html/pages/device/overview/processors.inc.php +++ b/html/pages/device/overview/processors.inc.php @@ -66,12 +66,14 @@ if (count($processors)) { if($_SESSION['screen_width']) { if($_SESSION['screen_width'] > 970) { - $graph_array['width'] = round(($_SESSION['screen_width'] - 190 )/2,0); + $graph_array['width'] = round(($_SESSION['screen_width'] - 390 )/2,0); $graph_array['height'] = round($graph_array['width'] /3); + $graph_array['lazy_w'] = $graph_array['width'] + 80; } else { - $graph_array['width'] = $_SESSION['screen_width'] - 110; + $graph_array['width'] = $_SESSION['screen_width'] - 190; $graph_array['height'] = round($graph_array['width'] /3); + $graph_array['lazy_w'] = $graph_array['width'] + 80; } }