Author: Lars Michelsen <[email protected]>
Date: Wed Nov 6 22:43:44 2013 +0100
Committer: Lars Michelsen <[email protected]>
Commit-Date: Wed Nov 6 22:43:44 2013 +0100
The "zoom" parameter can be configured to "fill" to make the view fill the
whole viewport of the browser
---
ChangeLog | 4 ++
docs/en_US/map_config_format_description.html | 7 +++
.../frontend/nagvis-js/js/NagVisStatefulObject.js | 16 ++++++
share/frontend/nagvis-js/js/frontend.js | 51 ++++++++++++++++++-
share/frontend/nagvis-js/js/nagvis.js | 4 +-
share/server/core/defines/matches.php | 1 +
share/server/core/mapcfg/default.php | 19 ++++----
7 files changed, 89 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b1f0bf5..9909f63 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,8 @@ Core:
user can then modify all the objects, for example change their options
like, positions and visualisation.
* Changed default http_timeout from 10 to 2 seconds
+ * Added new iconset std_area, which can be used to create maps which are
+ visible from a greater distance
Automap:
* Added "on-demand-filter" header menu to support quick filter mechanism
@@ -39,6 +41,8 @@ Frontend:
* Summary states of maps can now be displayed in the sidebar menu (must be
enabled by setting header_show_states=1 in [defaults] section in global
configuration)
+ * The "zoom" parameter can be configured to "fill" to make the view fill the
+ whole viewport of the browser
* FIX: Fixed centering of overview tables when opening the sidebar
* FIX: Fixed mouse pointer confusions when adding a new object and hovering
another menu which then shows up the hover menu
diff --git a/docs/en_US/map_config_format_description.html
b/docs/en_US/map_config_format_description.html
index 2059977..a9bf83c 100644
--- a/docs/en_US/map_config_format_description.html
+++ b/docs/en_US/map_config_format_description.html
@@ -264,6 +264,13 @@
<td> url_target </td><td> _self </td><td> Target of the Icon link,
this option adapts <a target=""> (_self is same window) </td>
</tr>
<tr>
+ <td>zoom</td>
+ <td>100</td>
+ <td>Zoom factor of the map. Can be set to any percentage value
that the map objects should
+ be zoomed in or out (<font color="#ff0000">New in
1.7b1</font>). Since 1.8b1 this can be
+ set to "fill", the map is being zoomed to fill the
browsers viewport.</td>
+ </tr>
+ <tr>
<td>zoombar</td>
<td>inherited (<a
href="nagvis_config_format_description.html">nagvis.ini.php</a>)</td>
<td>Enables a floating bar to make the map zooming controllable by
this bar or by using the
diff --git a/share/frontend/nagvis-js/js/NagVisStatefulObject.js
b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
index 64a6eea..53c4de9 100644
--- a/share/frontend/nagvis-js/js/NagVisStatefulObject.js
+++ b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
@@ -1002,6 +1002,22 @@ var NagVisStatefulObject = NagVisObject.extend({
return 0;
},
+ getObjLeft: function () {
+ if (this.conf.x.split(',').length > 1) {
+ return Math.min.apply(Math, this.parseCoords(this.conf.x, 'x'));
+ } else {
+ return this.parseCoord(this.conf.x, 'x');
+ }
+ },
+
+ getObjTop: function () {
+ if (this.conf.x.split(',').length > 1) {
+ return Math.min.apply(Math, this.parseCoords(this.conf.y, 'y'));
+ } else {
+ return this.parseCoord(this.conf.y, 'y');
+ }
+ },
+
parseIconControls: function () {
// Simply make it dragable. Maybe will be extended in the future...
makeDragable([this.conf.object_id+'-icondiv'], this.saveObject,
this.moveObject);
diff --git a/share/frontend/nagvis-js/js/frontend.js
b/share/frontend/nagvis-js/js/frontend.js
index b047162..4ceddb2 100644
--- a/share/frontend/nagvis-js/js/frontend.js
+++ b/share/frontend/nagvis-js/js/frontend.js
@@ -1468,6 +1468,44 @@ function getOverviewRotations() {
return
getSyncRequest(oGeneralProperties.path_server+'?mod=Overview&act=getOverviewRotations')
}
+/**
+ * Calculates which zoom factor shal be used to zoom the map
+ * to fill the whole screen. To reach this, it must loop
+ * all map objects to get the extreme coordinates of top/left
+ * and bottom/right. Mixing this with the width/height of the
+ * viewport, this function calculates the correct zoom factor.
+ */
+function set_fill_zoom_factor() {
+ var obj, zoom;
+ var c_top = null, c_left = null, c_bottom = null, c_right = null;
+ var o_top, o_left, o_bottom, o_right;
+ for(var i in oMapObjects) {
+ obj = oMapObjects[i];
+ if (obj && obj.getObjLeft && obj.getObjTop && obj.getObjHeight &&
obj.getObjWidth) {
+ o_top = obj.getObjTop();
+ if (c_top === null || o_top < c_top)
+ c_top = o_top;
+
+ o_left = obj.getObjLeft();
+ if (c_left === null || o_left < c_left)
+ c_left = o_left;
+
+ o_bottom = o_top + obj.getObjHeight();
+ if (c_bottom === null || o_bottom > c_bottom)
+ c_bottom = o_bottom;
+
+ o_right = o_left + obj.getObjWidth();
+ if (c_right === null || o_right > c_right)
+ c_right = o_right;
+ }
+ }
+
+ var border = 40; // border per side in px * 2
+ var zoom_y = parseInt((pageHeight() - border) / parseFloat(c_bottom) *
100);
+ var zoom_x = parseInt((pageWidth() - border)/ parseFloat(c_right) * 100);
+ set_zoom(Math.min(zoom_y, zoom_x));
+}
+
function set_zoom(val) {
setViewParam('zoom', val);
if(workerTimeoutID)
@@ -1476,7 +1514,10 @@ function set_zoom(val) {
}
function zoom(how) {
- var cur_zoom = parseInt(getViewParam('zoom'));
+ var cur_zoom = getZoomFactor();
+ // This is not really correct. Assume
+ if (cur_zoom == 'fill')
+ cur_zoom = 100;
var new_zoom = 100;
if (how != 0) {
new_zoom = cur_zoom + how;
@@ -1569,7 +1610,7 @@ function zoombarDragStop(event) {
g_left_clicked = false;
// Get the zoom value
- var zoom = parseInt(getViewParam('zoom'));
+ var zoom = getZoomFactor();
var val = parseInt((100 - (parseInt(g_drag_ind.style.top.replace('px',
'')) + 3)) / 100 * 200);
if (val != zoom) {
if (val <= 0)
@@ -1612,7 +1653,7 @@ function mouse_release(event) {
}
function updateZoomIndicator() {
- var zoom = parseInt(getViewParam('zoom'));
+ var zoom = getZoomFactor();
var ind = document.getElementById('zoombar-drag_ind');
// zoom is 0 to 200, the bar is 0px to 100px, the
@@ -1849,6 +1890,10 @@ function parseMapHandler(oObjects, params) {
eventlog("worker", "info", "Parsing "+type+" objects");
setMapObjects(oObjects);
+ // Maybe force page reload when the map shal fill the viewport
+ if (getViewParam('zoom') == 'fill')
+ set_fill_zoom_factor();
+
// Set map basics
// Needs to be called after the summary state of the map is known
setMapBasics(oPageProperties);
diff --git a/share/frontend/nagvis-js/js/nagvis.js
b/share/frontend/nagvis-js/js/nagvis.js
index f38d45b..a007613 100644
--- a/share/frontend/nagvis-js/js/nagvis.js
+++ b/share/frontend/nagvis-js/js/nagvis.js
@@ -1273,7 +1273,9 @@ function getZoomFactor() {
return g_zoom_factor; // only compute once
var zoom = getViewParam('zoom');
- if(zoom === null)
+ // Fill: At first use 100% zoom. Later, when everything has been rendered,
+ // calculate the fill zoom factor and re-render with this option.
+ if (zoom === null || zoom == 'fill')
g_zoom_factor = 100;
else
g_zoom_factor = parseInt(zoom);
diff --git a/share/server/core/defines/matches.php
b/share/server/core/defines/matches.php
index a6cf96a..00b1fe8 100644
--- a/share/server/core/defines/matches.php
+++ b/share/server/core/defines/matches.php
@@ -94,6 +94,7 @@ define('MATCH_ROLE_NAME', '/^[0-9A-Za-z_\-\.\@\s]+$/');
define('MATCH_DYN_GROUP_TYPES', '/^(?:host|service)$/');
define('MATCH_DYN_OBJECT_TYPES',
'/^(?:host|service|hostgroup|servicegroup)$/');
define('MATCH_LIVESTATUS_FILTER', '/^(?:Filter: .*\\\n)+$/i');
+define('MATCH_ZOOM_FACTOR', '/^(?:[0-9]+|fill)$/');
define('MATCH_URI_PART', '/^[a-zA-Z0-9\-_]*$/');
diff --git a/share/server/core/mapcfg/default.php
b/share/server/core/mapcfg/default.php
index 57e2867..6da917b 100644
--- a/share/server/core/mapcfg/default.php
+++ b/share/server/core/mapcfg/default.php
@@ -90,14 +90,15 @@ function listDynGroupTypes($CORE) {
function listZoomFactors($CORE) {
return Array(
- 10 => ' 10%',
- 25 => ' 25%',
- 50 => ' 50%',
- 75 => ' 75%',
- 100 => '100%',
- 125 => '125%',
- 150 => '150%',
- 200 => '200%',
+ 10 => ' 10%',
+ 25 => ' 25%',
+ 50 => ' 50%',
+ 75 => ' 75%',
+ 100 => '100%',
+ 125 => '125%',
+ 150 => '150%',
+ 200 => '200%',
+ 'fill' => l('Fill screen'),
);
}
@@ -682,7 +683,7 @@ $mapConfigVars = Array(
'zoom' => Array(
'must' => 0,
'default' => 100,
- 'match' => MATCH_INTEGER,
+ 'match' => MATCH_ZOOM_FACTOR,
'field_type' => 'dropdown',
'list' => 'listZoomFactors',
),
------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins