Author: Lars Michelsen <[email protected]>
Date: Wed Aug 28 09:29:57 2013 +0200
Committer: Lars Michelsen <[email protected]>
Commit-Date: Wed Aug 28 09:29:57 2013 +0200
Some automap layout improvements
---
ChangeLog | 8 +++-
.../frontend/nagvis-js/js/NagVisStatefulObject.js | 4 ++
share/server/core/classes/GlobalMapCfg.php | 1 +
share/server/core/mapcfg/default.php | 14 +++++++
share/server/core/sources/automap.php | 1 +
share/server/core/sources/automap_pos.php | 42 ++++++++++++++------
6 files changed, 56 insertions(+), 14 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a750444..4970bfa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,12 @@ Core:
like, positions and visualisation.
* Changed default http_timeout from 10 to 2 seconds
+Automap:
+ * Added "on-demand-filter" header menu to support quick filter mechanism
+ for on demand automaps
+ * Host labels are now limited to 14 chars on automaps
+ * Again, trying to improve the default automap rendering
+
Frontend:
* All nodes with assigned childs in sidebar are now expandable. The state
is stored for each user individually.
@@ -28,8 +34,6 @@ Frontend:
request per map.
* Added optional zoom bar and mousewheel zoom handlers (ALT + wheel move)
(Must be enabled with option "zoombar=1")
- * Added "on-demand-filter" header menu to support quick filter mechanism
- for on demand automaps
* Added new option multisite_snapin_layout to render the multisite snapin
in a "tree" instead of a "list"
* FIX: Fixed centering of overview tables when opening the sidebar
diff --git a/share/frontend/nagvis-js/js/NagVisStatefulObject.js
b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
index b646498..64a6eea 100644
--- a/share/frontend/nagvis-js/js/NagVisStatefulObject.js
+++ b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
@@ -431,6 +431,10 @@ var NagVisStatefulObject = NagVisObject.extend({
}
}
+ if (this.conf.label_maxlen > 0 && sReturn.length >
this.conf.label_maxlen) {
+ sReturn = sReturn.substr(0, this.conf.label_maxlen - 2) + '...';
+ }
+
return sReturn;
},
diff --git a/share/server/core/classes/GlobalMapCfg.php
b/share/server/core/classes/GlobalMapCfg.php
index 47c64a5..a8142b0 100644
--- a/share/server/core/classes/GlobalMapCfg.php
+++ b/share/server/core/classes/GlobalMapCfg.php
@@ -162,6 +162,7 @@ class GlobalMapCfg {
'label_background',
'label_border',
'label_style',
+ 'label_maxlen',
'url_target',
'hover_childs_show',
'hover_childs_sort',
diff --git a/share/server/core/mapcfg/default.php
b/share/server/core/mapcfg/default.php
index 9c0f7e7..57e2867 100644
--- a/share/server/core/mapcfg/default.php
+++ b/share/server/core/mapcfg/default.php
@@ -604,6 +604,13 @@ $mapConfigVars = Array(
'match' => MATCH_STRING_STYLE,
'depends_on' => 'label_show',
'depends_value' => '1'),
+ 'label_maxlen' => Array(
+ 'must' => 0,
+ 'default' => 0,
+ 'match' => MATCH_INTEGER,
+ 'depends_on' => 'label_show',
+ 'depends_value' => '1'
+ ),
'only_hard_states' => Array(
'must' => 0,
@@ -972,6 +979,7 @@ $mapConfigVarMap['global'] = Array(
'label_background' => null,
'label_border' => null,
'label_style' => null,
+ 'label_maxlen' => null,
'only_hard_states' => null,
'recognize_services' => null,
'show_in_lists' => null,
@@ -1017,6 +1025,7 @@ $mapConfigVarMap['host'] = Array(
'label_background' => null,
'label_border' => null,
'label_style' => null,
+ 'label_maxlen' => null,
'only_hard_states' => null,
'recognize_services' => null,
'host_url' => 'url',
@@ -1059,6 +1068,7 @@ $mapConfigVarMap['hostgroup'] = Array(
'label_background' => null,
'label_border' => null,
'label_style' => null,
+ 'label_maxlen' => null,
'only_hard_states' => null,
'recognize_services' => null,
'hostgroup_url' => 'url',
@@ -1108,6 +1118,7 @@ $mapConfigVarMap['service'] = Array(
'label_background' => null,
'label_border' => null,
'label_style' => null,
+ 'label_maxlen' => null,
'only_hard_states' => null,
'service_url' => 'url',
'url_target' => null,
@@ -1149,6 +1160,7 @@ $mapConfigVarMap['servicegroup'] = Array(
'label_background' => null,
'label_border' => null,
'label_style' => null,
+ 'label_maxlen' => null,
'only_hard_states' => null,
'servicegroup_url' => 'url',
'url_target' => null,
@@ -1189,6 +1201,7 @@ $mapConfigVarMap['map'] = Array(
'label_background' => null,
'label_border' => null,
'label_style' => null,
+ 'label_maxlen' => null,
'only_hard_states' => null,
'map_url' => 'url',
'url_target' => null,
@@ -1319,6 +1332,7 @@ $mapConfigVarMap['dyngroup'] = array(
'label_background' => null,
'label_border' => null,
'label_style' => null,
+ 'label_maxlen' => null,
'only_hard_states' => null,
'recognize_services' => null,
'dyngroup_url' => 'url',
diff --git a/share/server/core/sources/automap.php
b/share/server/core/sources/automap.php
index 15d5ac4..e74e8fa 100644
--- a/share/server/core/sources/automap.php
+++ b/share/server/core/sources/automap.php
@@ -314,6 +314,7 @@ function automap_obj($MAPCFG, &$params, &$saved_config,
$obj_name) {
$obj['label_show'] = true;
$obj['label_border'] = 'transparent';
$obj['label_background'] = '#fff';
+ $obj['label_maxlen'] = 14;
// Header menu has z-index 100, this object's label the below+1
$obj['z'] = 98;
diff --git a/share/server/core/sources/automap_pos.php
b/share/server/core/sources/automap_pos.php
index c733409..5d8c708 100644
--- a/share/server/core/sources/automap_pos.php
+++ b/share/server/core/sources/automap_pos.php
@@ -50,9 +50,12 @@ function graphviz_config_tree(&$params, &$tree, $layer = 0) {
$str = '';
$name = $tree['host_name'];
+ if (strlen($name) > 14) {
+ $name = substr($name, 0, 12) . '...';
+ }
$str .= ' "'.$tree['object_id'].'" [ ';
- $str .= 'label="'.$tree['host_name'].'", ';
+ $str .= 'label="'.$name.'", ';
$str .= 'URL="'.$tree['object_id'].'", ';
$str .= 'tooltip="'.$tree['object_id'].'", ';
@@ -60,13 +63,18 @@ function graphviz_config_tree(&$params, &$tree, $layer = 0)
{
$height = $tree['.height'];
// This should be scaled by the choosen iconset
- if($width != 16) {
+ if($width != 22) {
$str .= 'width="'.graphviz_px2inch($width).'", ';
}
- if($height != 16) {
+ if($height != 22) {
$str .= 'height="'.graphviz_px2inch($height).'", ';
}
+ // This is the root node
+ if($layer == 0) {
+ $str .=
'pos="'.graphviz_px2inch($params['width']/2).','.graphviz_px2inch($params['height']/2).'",
';
+ }
+
// The object has configured x/y coords. Use them.
// FIXME: This does not work for some reason ...
if(isset($tree['x']) && isset($tree['y'])) {
@@ -104,12 +112,11 @@ function graphviz_config(&$params, &$tree) {
//, ranksep="0.1", nodesep="0.4", ratio=auto, bb="0,0,500,500"
$str .= ' graph [';
$str .= 'dpi="72", ';
- //ratio: expand, auto, fill, compress
- $str .= 'ratio="fill", ';
$str .= 'margin='.graphviz_px2inch($params['margin']).', ';
//$str .= 'bgcolor="'.$this->MAPCFG->getValue(0, 'background_color').'", ';
$str .= 'root="'.$tree['object_id'].'", ';
$str .= 'rankdir="'.$params['rankdir'].'", ';
+ $str .= 'center=true, ';
/* Directed (dot) only */
if($params['render_mode'] == 'directed') {
@@ -132,21 +139,32 @@ function graphviz_config(&$params, &$tree) {
$str .= 'overlap="'.$params['overlap'].'", ';
}
- $str .=
'size="'.graphviz_px2inch($params['width']).','.graphviz_px2inch($params['height']).'"];'."\n";
+ //ratio: expand, auto, fill, compress
+ //$str .= 'ratio="auto", ';
+ // enforces the size of the drawing area to this value
+ $str .=
'size="'.graphviz_px2inch($params['width']).','.graphviz_px2inch($params['height']).'!"
';
+ $str .= "];\n";
/**
* Default settings for automap nodes
*/
$str .= ' node [';
- // default margin is 0.11,0.055
- $str .= 'margin="0.0,0.0", ';
$str .= 'shape="rect", ';
+ // Show labels below the image
+ $str .= 'labelloc="b", ';
+ $str .= 'color="red", ';
+ // needs to be included for correct rendering
+ $str .= 'image="'.path('sys', 'global', 'icons').'std_medium_ok.png", ';
+
+ // default margin is 0.11,0.055
+ //$str .= 'margin="0.05,0.025", ';
+ // This may be altered by the single objects depending on the icon size
+ // -> must not be set, because it would make ignore the label text size
for calculations
+ //$str .= 'width="'.graphviz_px2inch(22).'", ';
+ //$str .= 'height="'.graphviz_px2inch(22).'", ';
// Do not use this as this would make the nodes ignore the label sizes
//$str .= 'fixedsize="true", ';
- $str .= 'color="white", ';
- // This may be altered by the single objects depending on the icon size
- $str .= 'width="'.graphviz_px2inch(16).'", ';
- $str .= 'height="'.graphviz_px2inch(16).'", ';
+
$str .= 'fontsize=10';
$str .= '];'."\n";
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins