[Nagvis-checkins] SF.net Git: nagvis: FIX: Fixed state handling events like sounds and coloring of
Brought to you by:
larsi-
From: lars <la...@us...> - 2013-10-11 21:21:01
|
Author: Lars Michelsen <lm...@la...> Date: Fri Oct 11 23:20:49 2013 +0200 Committer: Lars Michelsen <lm...@la...> Commit-Date: Fri Oct 11 23:20:49 2013 +0200 FIX: Fixed state handling events like sounds and coloring of lines --- share/frontend/nagvis-js/classes/NagVisMapView.php | 2 +- .../nagvis-js/classes/NagVisOverviewView.php | 2 +- share/server/core/classes/GlobalMainCfg.php | 31 ++++++++++++++------ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/share/frontend/nagvis-js/classes/NagVisMapView.php b/share/frontend/nagvis-js/classes/NagVisMapView.php index 518bdcd..945dd5a 100644 --- a/share/frontend/nagvis-js/classes/NagVisMapView.php +++ b/share/frontend/nagvis-js/classes/NagVisMapView.php @@ -89,7 +89,7 @@ class NagVisMapView { 'workerProperties' => $_MAINCFG->parseWorkerProperties(), 'rotationProperties' => json_encode($this->aRotation), 'viewProperties' => $this->parseViewProperties(), - 'stateProperties' => json_encode($_MAINCFG->getStateWeight()), + 'stateProperties' => json_encode($_MAINCFG->getStateWeightJS()), 'userProperties' => $USERCFG->doGetAsJson(), 'mapName' => $this->name, 'fileAges' => json_encode(Array( diff --git a/share/frontend/nagvis-js/classes/NagVisOverviewView.php b/share/frontend/nagvis-js/classes/NagVisOverviewView.php index f8dfc5e..2772744 100644 --- a/share/frontend/nagvis-js/classes/NagVisOverviewView.php +++ b/share/frontend/nagvis-js/classes/NagVisOverviewView.php @@ -48,7 +48,7 @@ class NagVisOverviewView { $aData = Array( 'generalProperties' => $_MAINCFG->parseGeneralProperties(), 'workerProperties' => $_MAINCFG->parseWorkerProperties(), - 'stateProperties' => json_encode($_MAINCFG->getStateWeight()), + 'stateProperties' => json_encode($_MAINCFG->getStateWeightJS()), 'userProperties' => $USERCFG->doGetAsJson(), 'fileAges' => json_encode(Array( 'maincfg' => $_MAINCFG->getConfigFileAge(), diff --git a/share/server/core/classes/GlobalMainCfg.php b/share/server/core/classes/GlobalMainCfg.php index 3351c93..86fecbf 100644 --- a/share/server/core/classes/GlobalMainCfg.php +++ b/share/server/core/classes/GlobalMainCfg.php @@ -1987,10 +1987,9 @@ class GlobalMainCfg { )); } - /**$ - * Parses the state weight configuration array - * - * @author Lars Michelsen <la...@ve...> + /** + * Populates the state weight structure, provided by hardcoded defaults + * and maybe the user configuration */ private function parseStateWeight() { $arr = Array(); @@ -1998,11 +1997,6 @@ class GlobalMainCfg { foreach($this->validConfig['states'] AS $lowState => $aVal) { $key = explode('_', $lowState); - // First create array when not exists - if(!isset($arr[strtoupper($key[0])])) { - $arr[strtoupper($key[0])] = Array(); - } - // Convert state values to int $last_part = $key[sizeof($key) - 1]; if($last_part != 'color' && $last_part != 'bgcolor' && $last_part != 'sound') { @@ -2012,6 +2006,12 @@ class GlobalMainCfg { } $state = state_num(strtoupper($key[0])); + + // First create array when not exists + if(!isset($arr[$state])) { + $arr[$state] = Array(); + } + if(isset($key[1]) && isset($key[2])) { // at the moment only bg colors of substates $arr[$state][$key[1].'_'.$key[2]] = $val; @@ -2038,6 +2038,19 @@ class GlobalMainCfg { } /** + * Returns an array with the state weight configuration for the + * JS frontend, which is not yet aware of numeric state codes. So + * translate the states here. + */ + public function getStateWeightJS() { + $arr = array(); + foreach ($this->stateWeight AS $state => $val) { + $arr[state_str($state)] = $val; + } + return $arr; + } + + /** * FIXME: Below you will find all WUI specific function. All need to be reviewed */ |