Author: Lars Michelsen <[email protected]>
Date: Sat Mar 31 11:54:05 2012 +0200
Committer: Lars Michelsen <[email protected]>
Commit-Date: Sat Mar 31 11:54:05 2012 +0200
Fixed auto adding of view parameters
---
share/frontend/nagvis-js/classes/NagVisMapView.php | 3 ++
share/frontend/nagvis-js/js/edit.js | 10 ++++++
share/frontend/nagvis-js/js/frontend.js | 32 ++++++++++---------
share/server/core/classes/WuiViewMapAddModify.php | 20 +++++++++++-
share/server/core/sources/general.php | 6 ++-
share/userfiles/templates/default.header.html | 2 +-
6 files changed, 53 insertions(+), 20 deletions(-)
diff --git a/share/frontend/nagvis-js/classes/NagVisMapView.php
b/share/frontend/nagvis-js/classes/NagVisMapView.php
index 0abd678..24793e3 100644
--- a/share/frontend/nagvis-js/classes/NagVisMapView.php
+++ b/share/frontend/nagvis-js/classes/NagVisMapView.php
@@ -131,12 +131,15 @@ class NagVisMapView {
// It is special for them that the object individual settings have to
be
// treated and only the user specified source params must be applied
here
// (no global, no hardcoded default)
+ // FIXME: Recode to use the user_params
$userParams = $this->MAPCFG->getSourceParams(true);
if(isset($userParams['hover_menu']))
$arr['hover_menu'] = $userParams['hover_menu'];
if(isset($userParams['context_menu']))
$arr['context_menu'] = $userParams['context_menu'];
+ // This sets the user specific parameters
+ $arr['user_params'] = $this->MAPCFG->getSourceParams(true, true);
// This sets the final source parameters
$arr['params'] = $this->MAPCFG->getSourceParams();
diff --git a/share/frontend/nagvis-js/js/edit.js
b/share/frontend/nagvis-js/js/edit.js
index ccf544a..042e8fc 100644
--- a/share/frontend/nagvis-js/js/edit.js
+++ b/share/frontend/nagvis-js/js/edit.js
@@ -1014,3 +1014,13 @@ function togglePicker(id) {
o.color.showPicker();
o = null;
}
+
+function pickWindowSize(id, dimension) {
+ var o = document.getElementById(id);
+ if(dimension == 'width') {
+ o.value = pageWidth();
+ } else {
+ o.value = pageHeight() - getHeaderHeight();
+ }
+ o = null;
+}
diff --git a/share/frontend/nagvis-js/js/frontend.js
b/share/frontend/nagvis-js/js/frontend.js
index a4c1a53..5b6d215 100644
--- a/share/frontend/nagvis-js/js/frontend.js
+++ b/share/frontend/nagvis-js/js/frontend.js
@@ -1413,33 +1413,35 @@ function getOverviewRotations() {
* @return String URL part with params and values
* @author Lars Michelsen <[email protected]>
*/
-function getViewParams(update) {
- if(!isset(oViewProperties) || !isset(oViewProperties['params']))
+function getViewParams(update, userParams) {
+ if(!isset(userParams))
+ userParams = false;
+
+ if(!userParams && isset(oViewProperties['params'])) {
+ var params = oViewProperties['params'];
+ } else if(isset(oViewProperties['params'])) {
+ var params = oViewProperties['user_params'];
+ } else {
+ return '';
+ }
+
+ if(!isset(params))
return '';
// Udate the params before processing url
if(isset(update)) {
for(var param in update) {
- oViewProperties['params'][param] = update[param];
+ params[param] = update[param];
}
}
var sParams = '';
- for(var param in oViewProperties['params']) {
- if(oViewProperties['params'][param] != '') {
- sParams += '&' + param + '=' +
escapeUrlValues(oViewProperties['params'][param]);
+ for(var param in params) {
+ if(params[param] != '') {
+ sParams += '&' + param + '=' + escapeUrlValues(params[param]);
}
}
- if(!isset(oViewProperties['params']['width'])) {
- oViewProperties['params']['width'] = pageWidth();
- sParams += '&width=' +
escapeUrlValues(oViewProperties['params']['width']);
- }
- if(!isset(oViewProperties['params']['height'])) {
- oViewProperties['params']['height'] = pageHeight() - getHeaderHeight();
- sParams += '&height=' +
escapeUrlValues(oViewProperties['params']['height']);
- }
-
return sParams;
}
diff --git a/share/server/core/classes/WuiViewMapAddModify.php
b/share/server/core/classes/WuiViewMapAddModify.php
index a5fd129..1ff5fab 100644
--- a/share/server/core/classes/WuiViewMapAddModify.php
+++ b/share/server/core/classes/WuiViewMapAddModify.php
@@ -132,6 +132,9 @@ class WuiViewMapAddModify {
// Get the value set in this object if there is some set
// But don't try this when running in "update" mode
$val = $this->MAPCFG->getValue($this->attrs['object_id'], $attr,
true);
+ // In view_param mode this is inherited
+ if($this->mode == 'view_params')
+ $inherited = true;
} elseif(!$update && $this->cloneId !== null
&& $this->MAPCFG->getValue($this->cloneId, $attr, true) !==
false) {
@@ -239,10 +242,12 @@ class WuiViewMapAddModify {
if($this->MAPCFG->hasDependants($type, $propname))
$onChange =
'document.getElementById(\'update\').value=\'1\';document.getElementById(\'commit\').click();';
- // Add a checkbox to toggle the usage of an attribute. But only
add it for non-must
- // attributes.
+ // Add a checkbox to toggle the usage of an attribute. But only
add it for
+ // non-must attributes.
if(!$prop['must']) {
$checked = '';
+ // FIXME: In case of the view_params mode the dialog must
select and show the user sele
+ //if($this->mode == 'view_params') {
if($inherited === false)
$checked = ' checked';
$ret .= '<input type="checkbox"
name="toggle_'.$propname.'"'.$checked.'
onclick="toggle_option(\''.$propname.'\');'.$onChange.'" value=on />';
@@ -331,6 +336,9 @@ class WuiViewMapAddModify {
case 'color':
$ret .= $this->colorSelect($propname, $value, $hideField);
break;
+ case 'dimension':
+ $ret .= $this->inputDimension($propname, $value,
$hideField);
+ break;
case 'text':
$ret .= $this->inputField($propname, $value, $hideField);
break;
@@ -378,6 +386,14 @@ class WuiViewMapAddModify {
.'o = null;</script>';
}
+ private function inputDimension($propname, $value, $hideField) {
+ return '<div id="'.$propname.'" class=picker'.$hideField.'>'
+ .$this->inputField($propname, $value, '', $propname . '_inp')
+ .'<a href="javascript:void(0);"
onClick="pickWindowSize(\''.$propname.'_inp\', \''.$propname.'\');">'
+ .'<img src="'.cfg('paths',
'htmlimages').'internal/dimension.png" alt="'.l('Get current size').'" />'
+ .'</a></div>';
+ }
+
private function inputField($name, $value, $hideField, $id = null) {
if($id === null)
$id = $name;
diff --git a/share/server/core/sources/general.php
b/share/server/core/sources/general.php
index 68b17fe..3eabc92 100644
--- a/share/server/core/sources/general.php
+++ b/share/server/core/sources/general.php
@@ -24,12 +24,14 @@ $configVars = array(
'width' => array(
'must' => false,
'default' => '',
- 'match' => MATCH_INTEGER_EMPTY
+ 'match' => MATCH_INTEGER_EMPTY,
+ 'field_type' => 'dimension',
),
'height' => array(
'must' => false,
'default' => '',
- 'match' => MATCH_INTEGER_EMPTY
+ 'match' => MATCH_INTEGER_EMPTY,
+ 'field_type' => 'dimension',
),
);
diff --git a/share/userfiles/templates/default.header.html
b/share/userfiles/templates/default.header.html
index e0085c8..00ad9aa 100644
--- a/share/userfiles/templates/default.header.html
+++ b/share/userfiles/templates/default.header.html
@@ -36,7 +36,7 @@
<li><a href="#"
onclick="showFrontendDialog(oGeneralProperties.path_server+'?mod=Search&act=view',
'{$langSearch}')">{$langSearch}</a></li>
{/if}
{if $mod == 'Map' && $permittedEdit == true}
- <li><a href="#"
onclick="showFrontendDialog(oGeneralProperties.path_server+'?mod=Map&act=addModify&show={$currentMap}&object_id=0&mode=view_params'+getViewParams(),
'{$langModifyParams}');" class="underline">{$langModifyParams}</a></li>
+ <li><a href="#"
onclick="showFrontendDialog(oGeneralProperties.path_server+'?mod=Map&act=addModify&show={$currentMap}&object_id=0&mode=view_params'+getViewParams(null,
true), '{$langModifyParams}');" class="underline">{$langModifyParams}</a></li>
{/if}
{if $bRotation == true}
<li id="rotationStart" style="display:none"><a href="#"
onclick="switchRotation()">{$langRotationStart}</a></li>
------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins