From 86263051110fdfaacdef81c4286e4956eaf9574a Mon Sep 17 00:00:00 2001 From: elena Date: Thu, 10 Sep 2015 14:13:45 +0200 Subject: [PATCH] visu second draft --- js/app/views/VisuUI.js | 8 ++++---- php/classes/AmdaAction.php | 18 +++++++++++++++++- php/classes/CatalogMgr.php | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ php/config.php | 12 +++++++++--- 4 files changed, 98 insertions(+), 8 deletions(-) diff --git a/js/app/views/VisuUI.js b/js/app/views/VisuUI.js index adce4c4..6d881f1 100644 --- a/js/app/views/VisuUI.js +++ b/js/app/views/VisuUI.js @@ -74,7 +74,7 @@ Ext.define('amdaUI.VisuUI', { Ext.Array.each(result.parameters, function(obj) { - index = 'param'+(i+2).toString(); + index = 'param'+i.toString(); fields[i] = Ext.create('Ext.data.Field', { name : index, id: index, text : obj.name, convert: function(value, record) { return parseFloat(value); @@ -105,10 +105,10 @@ Ext.define('amdaUI.VisuUI', { type: 'direct', api : { - read : AmdaAction.readTTCacheIntervals + read : AmdaAction.readIntervalsForChart }, // remplir automatiquement tt, sharedtt , catalog, shared catalog - extraParams : {'typeTT' : 'catalog'}, + extraParams : {'typeTT' : 'catalog', 'id' : me.object.get('id')}, reader: { type: 'json', @@ -128,7 +128,7 @@ Ext.define('amdaUI.VisuUI', { } - AmdaAction.initTTCacheFromTT(this.object.get('id'), 'catalog', onAfterInit); + AmdaAction.initForChartFromTT(this.object.get('id'), 'catalog', onAfterInit); }, diff --git a/php/classes/AmdaAction.php b/php/classes/AmdaAction.php index 2e9efab..20b3271 100644 --- a/php/classes/AmdaAction.php +++ b/php/classes/AmdaAction.php @@ -954,6 +954,14 @@ class AmdaAction { return $cacheMgr->initFromTT($id, $type); } + public function initForChartFromTT($id, $type) + { + if ($type == 'catalog') $objMgr = new CatalogMgr(); + + + return $objMgr->initForChartFromTT($id, $type); + } + public function initTTCacheFromTmpObject($folderId, $name, $isCatalog = false) { if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr(); @@ -978,7 +986,15 @@ class AmdaAction { return $cacheMgr->getIntervals($o->start,$o->limit,$o->sort,$o->filter); } - + + public function readIntervalsForChart($o) + { + if ($o->typeTT == 'catalog') $objMgr = new CatalogMgr(); + + + return $objMgr->getIntervalsForChart($o->id, $o->typeTT); + } + public function saveTTCacheIntervalsInTT($o) { $cacheMgr = new TimeTableCacheMgr(); diff --git a/php/classes/CatalogMgr.php b/php/classes/CatalogMgr.php index e57c63f..7cbdd81 100644 --- a/php/classes/CatalogMgr.php +++ b/php/classes/CatalogMgr.php @@ -249,6 +249,74 @@ class CatalogMgr extends TimeTableMgr { } + public function initForChartFromTT($id, $typeTT) + { + $intervals_res = $this->loadIntervalsFromTT($id,$typeTT); + + if (!$intervals_res['success']) + return $intervals_res; + + $paramHeaders = []; + + foreach ( $intervals_res['parameters'] as $param ) { + + if ($param['size'] > 1) { + + for ($i = 0; $i < $param['size']; $i++) { + $paramComp = array(); + $paramComp['id'] = $param['id'].'_'.$i; + $paramComp['name'] = $param['name'].'_'.$i; + // $paramComp['size'] = 1; + + $paramHeaders[] = $paramComp; + } + } + else { + $paramHeaders[] = $param; + } + } + + unset($intervals_res); + + return array('success' => true, 'parameters' => $paramHeaders); + } + + public function getIntervalsForChart($id, $type) { + + $intervals_res = $this->loadIntervalsFromTT($id,$type); + + if (!$intervals_res['success']) + return $intervals_res; + + $newIntervals = array(); + + foreach ($intervals_res['intervals'] as $interval) + { + $newIntervalComp = array(); + $k = 0; + + for ( $j = 0; $j < count($interval['paramTable']); $j++ ) { + + $param = $interval['paramTable'][$j]; + $tempArr = explode(',',$param); + + if (count($tempArr) > 1) { + for ($i = 0; $i < count($tempArr); $i++) { + $newIntervalComp['param'.$k] = $tempArr[$i]; + $k++; + } + } + else { + $newIntervalComp['param'.$k] = $param; + $k++; + } + } + $newIntervals[] = $newIntervalComp; + } + + return array('success' => true, 'intervals' => $newIntervals); + + } } ?> diff --git a/php/config.php b/php/config.php index a7be0b0..b285f47 100644 --- a/php/config.php +++ b/php/config.php @@ -241,9 +241,9 @@ $API = array( 'modifyObject'=>array( 'len'=>1 ), - 'validNameObject'=>array( - 'len'=>1 - ), + 'validNameObject'=>array( + 'len'=>1 + ), 'getJobs'=>array( 'len'=>0 ), @@ -278,6 +278,9 @@ $API = array( 'initTTCacheFromTT' => array( 'len'=>2 ), + 'initForChartFromTT' => array( + 'len'=>2 + ), 'initTTCacheFromTmpObject' => array( 'len'=>3 ), @@ -287,6 +290,9 @@ $API = array( 'readTTCacheIntervals'=>array( 'len'=>1 ), + 'readIntervalsForChart'=>array( + 'len'=>1 + ), 'addTTCacheInterval'=>array ( 'len'=>1 ), -- libgit2 0.21.2