Author:   Lars Michelsen <[email protected]>
Date:     Wed Jul 17 18:55:16 2013 +0200
Committer:   Lars Michelsen <[email protected]>
Commit-Date: Wed Jul 17 18:55:16 2013 +0200

The map source is now selectable by dropdown (when using only a single source)

---

 TODO                                              |   35 +++++++++++++++++++++
 share/server/core/classes/GlobalCore.php          |    4 +-
 share/server/core/classes/GlobalMapCfg.php        |   10 +++---
 share/server/core/classes/WuiViewMapAddModify.php |    9 +++--
 share/server/core/defines/matches.php             |    1 +
 share/server/core/mapcfg/default.php              |   10 +++++-
 6 files changed, 57 insertions(+), 12 deletions(-)

diff --git a/TODO b/TODO
index 5746d3b..10c6216 100644
--- a/TODO
+++ b/TODO
@@ -19,6 +19,41 @@ Offene Punkte:
 
 -------------------------------------------------------------------------------
 
+*** Dynamische Maps ***
+
+Aktuell gibt es neben den statischen Maps die Automap, die die Parent-/Child-
+Beziehungen darstellt, die Geomap, die eine bestimmte Menge von Hosts auf einer
+Karte darstellt.
+
+In grossen Umgebungen ist es muehsam einzelne Maps dauerhaft zu pflegen. Wenn
+die Maps einem bestimmten Schema folgen, koennte man zumindest die Objekete,
+die auf einer Karte dargestellt werden sollen, automatisch verwalten.
+
+Sprich: Wenn ein Host ueber die Konfiguration des Monitoring-Cores aufgenommen
+wird, wird er automatisch auf der Map aufgenommen. Wenn ein Host entfernt wird,
+dann wird dieser automatisch entfernt. Dieser Automatismus steuert allerdings 
nur
+das initiale Anlegen und Loeschen. Alle anderen Dinge, wie z.B. die korrekte
+Positionierung, werden wie ueblich konfiguriert.
+
+Wir nennen das Feature: "Dynamic Maps".
+
+Es wird ueber eine Map-Source realisiert. Diese nutzt folgende Optionen:
+
+dynmap_object_types="(hosts|services)"
+dynmap_object_filter="Filter: custom_variables = ID xyz"
+dynmap_init_x=20
+dynmap_init_y=700
+dynmap_offset_x=30
+dynmap_offset_y=30
+dynmap_per_row=10
+
+Beim hinzufuegen/entfernen wird ermittelt welche Objekte sich momentan im
+Raster befinden. Diese Objekte werden anhand des Namens sortiert und im
+Raster neu positioniert.
+
+Die Source muss die Positionen nur neu berechnen, wenn der Core neu gestartet
+wurde. In der Zwischenzeit kann ein Cache verwendet werden.
+
 *** state handling cleanup ***
 
 Ein Zustand bedeutet:
diff --git a/share/server/core/classes/GlobalCore.php 
b/share/server/core/classes/GlobalCore.php
index 9826cbe..79dea2a 100644
--- a/share/server/core/classes/GlobalCore.php
+++ b/share/server/core/classes/GlobalCore.php
@@ -345,8 +345,8 @@ class GlobalCore {
      */
     public function getAvailableSources() {
         return array_merge(
-          self::listDirectory(path('sys', 'global', 'sources'), 
MATCH_PHP_FILE),
-          self::listDirectory(path('sys', 'local',  'sources'), 
MATCH_PHP_FILE, null, null, null, null, false)
+          self::listDirectory(path('sys', 'global', 'sources'), 
MATCH_SOURCE_FILE),
+          self::listDirectory(path('sys', 'local',  'sources'), 
MATCH_SOURCE_FILE, null, null, null, null, false)
         );
     }
 
diff --git a/share/server/core/classes/GlobalMapCfg.php 
b/share/server/core/classes/GlobalMapCfg.php
index 586a555..0247432 100644
--- a/share/server/core/classes/GlobalMapCfg.php
+++ b/share/server/core/classes/GlobalMapCfg.php
@@ -479,14 +479,14 @@ class GlobalMapCfg {
      */
     private function fetchMapSources() {
         global $CORE;
-        foreach($CORE->getAvailableSources() AS $source_file) {
+        foreach($CORE->getAvailableSources() AS $source_name) {
             $viewParams = array();
             $configVars = array();
 
             if(file_exists(path('sys', 'local', 'sources'))) {
-                include_once(path('sys', 'local', 'sources') . '/'. 
$source_file);
+                include_once(path('sys', 'local', 'sources') . '/'. 
$source_name . '.php');
             } else {
-                include_once(path('sys', 'global', 'sources') . '/'. 
$source_file);
+                include_once(path('sys', 'global', 'sources') . '/'. 
$source_name. '.php');
             }
 
             // Add the view params of that source to the list of parameters
@@ -501,7 +501,7 @@ class GlobalMapCfg {
             foreach($configVars AS $key => $val) {
                 self::$validConfig['global'][$key] = $val;
                 // Mark this option as source parameter. Save the source file 
in the value
-                self::$validConfig['global'][$key]['source_param'] = 
$source_file;
+                self::$validConfig['global'][$key]['source_param'] = 
$source_name. '.php';
             }
         }
     }
@@ -619,7 +619,7 @@ class GlobalMapCfg {
         if(isset($params['sources'])) {
             $keys = array();
             foreach($params['sources'] AS $source) {
-                if($source != '') {
+                if($source != '' && isset(self::$viewParams[$source])) {
                     $keys = array_merge($keys, self::$viewParams[$source]);
                 }
             }
diff --git a/share/server/core/classes/WuiViewMapAddModify.php 
b/share/server/core/classes/WuiViewMapAddModify.php
index 5deb3ad..ada3626 100644
--- a/share/server/core/classes/WuiViewMapAddModify.php
+++ b/share/server/core/classes/WuiViewMapAddModify.php
@@ -292,10 +292,11 @@ class WuiViewMapAddModify {
                     $ret .= $this->selectField($propname, $options, $value, 
$hideField, $onChange);
                 break;
                 case 'dropdown':
-                    $array = isset($prop['array']) && $prop['array'];
+                    $array    = isset($prop['array']) && $prop['array'];
+                    $multiple = isset($prop['multiple']) && $prop['multiple'];
                     // If var is backend_id or var is host_name in service 
objects submit the form
                     // to update the depdant lists.
-                    if($onChange == '' && ($propname == 'backend_id'
+                    if($onChange == '' && (($multiple && $value !== 
'<<<multiple>>>')
                        || ($type == 'service' && $propname == 'host_name')))
                         $onChange = 
'document.getElementById(\'update\').value=\'1\';document.getElementById(\'commit\').click();';
 
@@ -330,14 +331,14 @@ class WuiViewMapAddModify {
                                     l('Current value is not a known option - 
falling back to input field.')));
                             }
 
-                            if ($propname === 'backend_id' && $value === 
'<<<multiple>>>')
+                            if ($array && $multiple && $value === 
'<<<multiple>>>')
                                 $value = '';
 
                             $ret .= $this->inputField($propname, $value, 
$hideField);
                             break;
                         }
 
-                        if($array) {
+                        if($array && $multiple) {
                             $options['<<<multiple>>>'] = l('>>> Select 
multiple');
                         }
 
diff --git a/share/server/core/defines/matches.php 
b/share/server/core/defines/matches.php
index ae99aac..aee5b9d 100644
--- a/share/server/core/defines/matches.php
+++ b/share/server/core/defines/matches.php
@@ -102,6 +102,7 @@ define('MATCH_HEADER_TEMPLATE_FILE', 
'/^(.+)\.header\.html$/i');
 define('MATCH_HOVER_TEMPLATE_FILE', '/^(.+)\.hover\.html$/i');
 define('MATCH_CONTEXT_TEMPLATE_FILE', '/^(.+)\.context\.html$/i');
 define('MATCH_PHP_FILE', '/^(.+\.php)$/i');
+define('MATCH_SOURCE_FILE', '/^(.+)\.php$/i');
 define('MATCH_INTEGER_PRESIGN', '/^[\+\-]?[0-9]+$/');
 define('MATCH_INTEGER_PRESIGN_EMPTY', '/^[\+\-]?[0-9]*$/');
 define('MATCH_LABEL_X', '/^([\+\-]?[0-9]+|center)$/');
diff --git a/share/server/core/mapcfg/default.php 
b/share/server/core/mapcfg/default.php
index cd2058d..1a4e26e 100644
--- a/share/server/core/mapcfg/default.php
+++ b/share/server/core/mapcfg/default.php
@@ -174,6 +174,10 @@ function listBackendIds($CORE) {
     return $backends;
 }
 
+function listSources($CORE) {
+    return $CORE->getAvailableSources();
+}
+
 $mapConfigVars = Array(
     'type' => Array(
         'must'       => 0,
@@ -201,13 +205,17 @@ $mapConfigVars = Array(
         'must'       => 0,
         'default'    => array(),
         'array'      => true,
-        'match'      => MATCH_STRING
+       'multiple'   => true,
+        'match'      => MATCH_STRING,
+        'field_type' => 'dropdown',
+        'list'       => 'listSources',
     ),
     'backend_id' => Array(
         'must'       => 0,
         'default'    => cfg('defaults', 'backend'),
         'match'      => MATCH_BACKEND_ID,
         'array'      => true,
+       'multiple'   => true,
         'field_type' => 'dropdown',
         'list'       => 'listBackendIds',
     ),


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to