From 0318dbe6b3c30e46fa683474463c051a114e1c99 Mon Sep 17 00:00:00 2001
From: Hacene SI HADJ MOHAND <hacene.si-hadj-mohand@akka.eu>
Date: Wed, 26 Jun 2019 09:47:20 +0200
Subject: [PATCH] rm_6998 ok

---
 help/statisticalHelp            |  8 --------
 help/statisticalHelpcatalogUI   |  8 ++++++++
 help/statisticalHelptimeTableUi |  8 ++++++++
 js/app/views/CatalogUI.js       | 50 ++++++++++++++++++++++++++++++++++++++++----------
 js/app/views/OperationsTT.js    |  2 +-
 js/app/views/StatisticalPlug.js |  8 +++++---
 php/classes/AmdaAction.php      | 13 ++++++++++---
 php/config.php                  |  2 +-
 8 files changed, 73 insertions(+), 26 deletions(-)
 delete mode 100644 help/statisticalHelp
 create mode 100644 help/statisticalHelpcatalogUI
 create mode 100644 help/statisticalHelptimeTableUi

diff --git a/help/statisticalHelp b/help/statisticalHelp
deleted file mode 100644
index 3b2913f..0000000
--- a/help/statisticalHelp
+++ /dev/null
@@ -1,8 +0,0 @@
-<h2>Time table statistical information</h2>
-When hitting the <b>"Apply"</b> button the following data on the edited time table are computed from the list of intervals :</br></br>
-<ul>
-<li>The <b>minimum</b> and <b>maximum</b> durations with corresponding intervals (following the '--' signs)</li></br>
-<li>The <b>mean</b>, <b>the standard deviation (St. dev)</b> and the <b>median</b> of interval durations</li><br/>
-<li>The <b>density</b> of the time table in the global time span : this is the ratio of the sum of all interval durations over the global time span, i.e. the duration of the interval starting with the min 'Start' and finishing with the max 'Stop'.</li>
-</ul>
-The <b>density</b> is an indication of the occurrence frequency of the event described in a time table.
diff --git a/help/statisticalHelpcatalogUI b/help/statisticalHelpcatalogUI
new file mode 100644
index 0000000..7fec38f
--- /dev/null
+++ b/help/statisticalHelpcatalogUI
@@ -0,0 +1,8 @@
+<h2>Catalogue statistical information</h2>
+When hitting the <b>"Apply"</b> button the following data on the edited catalogue are computed from the list of intervals :</br></br>
+<ul>
+<li>The <b>minimum</b> and <b>maximum</b> durations with corresponding intervals (following the '--' signs)</li></br>
+<li>The <b>mean</b>, <b>the standard deviation (St. dev)</b> and the <b>median</b> of interval durations</li><br/>
+<li>The <b>density</b> of the catalogue in the global time span : this is the ratio of the sum of all interval durations over the global time span, i.e. the duration of the interval starting with the min 'Start' and finishing with the max 'Stop'.</li>
+</ul>
+The <b>density</b> is an indication of the occurrence frequency of the event described in a catalogue.
diff --git a/help/statisticalHelptimeTableUi b/help/statisticalHelptimeTableUi
new file mode 100644
index 0000000..3b2913f
--- /dev/null
+++ b/help/statisticalHelptimeTableUi
@@ -0,0 +1,8 @@
+<h2>Time table statistical information</h2>
+When hitting the <b>"Apply"</b> button the following data on the edited time table are computed from the list of intervals :</br></br>
+<ul>
+<li>The <b>minimum</b> and <b>maximum</b> durations with corresponding intervals (following the '--' signs)</li></br>
+<li>The <b>mean</b>, <b>the standard deviation (St. dev)</b> and the <b>median</b> of interval durations</li><br/>
+<li>The <b>density</b> of the time table in the global time span : this is the ratio of the sum of all interval durations over the global time span, i.e. the duration of the interval starting with the min 'Start' and finishing with the max 'Stop'.</li>
+</ul>
+The <b>density</b> is an indication of the occurrence frequency of the event described in a time table.
diff --git a/js/app/views/CatalogUI.js b/js/app/views/CatalogUI.js
index 2d6bdc0..b692da4 100644
--- a/js/app/views/CatalogUI.js
+++ b/js/app/views/CatalogUI.js
@@ -12,7 +12,8 @@ Ext.define('amdaUI.CatalogUI', {
 	alias: 'widget.panelCatalog',
 	
 	requires: [
-		'Ext.grid.plugin.BufferedRenderer'
+		'Ext.grid.plugin.BufferedRenderer',
+                                        'amdaUI.StatisticalPlug'
 	],
 	
 	isCatalog : true,
@@ -46,8 +47,11 @@ Ext.define('amdaUI.CatalogUI', {
 				// show this column
 				item.show();
 			}
-		});    
-                
+		});  
+                                         // fire the refresh event (to statistical plugin)
+                                         this.fireEvent("refresh");
+                                        // global event
+                                        myDesktopApp.EventManager.fireEvent("refresh");
 	},
 	
 	/**
@@ -310,8 +314,8 @@ Ext.define('amdaUI.CatalogUI', {
 							me.TTGrid.getView().refresh();
 							me.TTGrid.getSelectionModel().refresh();
 							me.updateCount();
-						//Statistical plugin
-						//   	this.fireEvent("refresh");
+						                   //Statistical plugin
+						 	this.fireEvent("refresh");
 					} 
 				}
 			});
@@ -333,6 +337,8 @@ Ext.define('amdaUI.CatalogUI', {
 		me.TTGrid.getStore().load();
 			
 		me.status = result.status;
+                                        //Statistical plugin
+                                        me.fireEvent("refresh");
 	},
 	
 	/**
@@ -365,6 +371,8 @@ Ext.define('amdaUI.CatalogUI', {
 				AmdaAction.initTTCacheFromTT(this.object.get('id'), typeTT, this.onAfterInit, this);
 			}
 		}
+                    //Statistical plugin
+        	this.fireEvent("refresh");
 	},
 	
 	checkIntervalsStatusForSave : function(onStatusOk) {
@@ -647,6 +655,7 @@ Ext.define('amdaUI.CatalogUI', {
 							}
 						}]
 					},
+                                                                                                               
 					{  
 						xtype: 'toolbar',
 						dock: 'bottom', 
@@ -740,7 +749,25 @@ Ext.define('amdaUI.CatalogUI', {
 // 								});
 // 							}
 // 						},
-						{   
+
+                                                                                                                        ]
+					},
+                                                                                                     //statistical info 
+                                                                                                                       {
+                                                                                                                         xtype: 'toolbar',
+						dock: 'bottom', 
+						ui: 'footer',
+                                                                                                                        items:[{ 
+                                                                                                                                            xtype: 'button',
+                                                                                                                                             text: 'Statistical info',
+                                                                                                                                             scope: this,
+                                                                                                                                             //dock: 'bottom', 
+                                                                                                                                             //ui: 'footer',
+                                                                                                                                             handler: function() {
+                                                                                                                                                                   this.fireEvent('info','catalogUI');
+                                                                                                                                                                }
+                                                                                                                                             },
+                                                        			                                        {   
 							type: 'button',
 							text: 'Visualize',
 							scope: this,
@@ -755,8 +782,9 @@ Ext.define('amdaUI.CatalogUI', {
 									module.createWindow(); 
 								});     
 							}
-						}]
-					}]
+						}
+                                                                                                                        ]
+                                }]
 				},
 				{
 					xtype: 'form',               
@@ -791,8 +819,10 @@ Ext.define('amdaUI.CatalogUI', {
 						url: helpDir+'catalogHOWTO'
 					} 
 				}
-			] 
+			] ,
+                        plugins: [ {ptype: 'statisticalPlugin'} ]  
 		};	    
 		Ext.apply (this, Ext.apply(arguments, myConf));	
-	}	 
+	}
+        
 });	
diff --git a/js/app/views/OperationsTT.js b/js/app/views/OperationsTT.js
index 7da4681..c13979d 100644
--- a/js/app/views/OperationsTT.js
+++ b/js/app/views/OperationsTT.js
@@ -178,7 +178,7 @@ Ext.define('amdaUI.OperationsTT', {
 	    					minWidth: 105,
 	    					scope: this,
 	    					handler: function() {
-	    						this.parent.fireEvent('info');
+	    						this.parent.fireEvent('info','timeTableUi');
 	    					}
 	    				} 
 	              	]
diff --git a/js/app/views/StatisticalPlug.js b/js/app/views/StatisticalPlug.js
index b4ef3fe..75d014b 100644
--- a/js/app/views/StatisticalPlug.js
+++ b/js/app/views/StatisticalPlug.js
@@ -45,7 +45,7 @@ Ext.define('amdaUI.StatisticalPlug', {
 		}*/
 	},
 
-	onInfo: function() {
+	onInfo: function(type) {
 	        if (!this.win) {	   
 		    this.win = new Ext.Window({			
 			    id: 'statistical-win',
@@ -63,7 +63,8 @@ Ext.define('amdaUI.StatisticalPlug', {
 				        	type:'help',
 				        	qtip: 'Help on Statistical info',
 				        	handler: function(event, toolEl, panel){
-				        		AmdaAction.getInfo({name : 'statisticalHelp'}, function(res,e) {					    					   
+                                                                                                                        
+				        		AmdaAction.getInfo({name : 'statisticalHelp'+type}, function(res,e) {					    					   
 								    if (res.success) myDesktopApp.infoMsg(res.result);
 							 });  
 				        	}
@@ -90,8 +91,9 @@ Ext.define('amdaUI.StatisticalPlug', {
 	 */
 	statTT: function(){
 	    if (this.win) {
+                              var type =this.hostCmp[0]['id'];
 	    	var me = this;
-	    	AmdaAction.getTTCacheStatistics(function (result, e) {
+	    	AmdaAction.getTTCacheStatistics({name : type }, function (result, e) {
 	    		if (!result || !result.success)
 	    		{
 	    			if (result.message)
diff --git a/php/classes/AmdaAction.php b/php/classes/AmdaAction.php
index 3707905..84829ce 100644
--- a/php/classes/AmdaAction.php
+++ b/php/classes/AmdaAction.php
@@ -1183,9 +1183,16 @@ class AmdaAction
 		return $cacheMgr->mergeIntervals();
 	}
 
-	public function getTTCacheStatistics()
-	{
-		$cacheMgr = new TimeTableCacheMgr();
+	public function getTTCacheStatistics($obj)
+	{
+                error_log("name",$obj->name ); 
+                if($obj->name == "timeTableUi"){ 
+				$cacheMgr = new TimeTableCacheMgr();
+                 }elseif($obj->name == "catalogUI"){
+                      $cacheMgr = new CatalogCacheMgr();
+                 }else{
+                      return array('success' => false, 'message' => 'unkown type: '.$obj->name);
+               }
 		return $cacheMgr->getStatistics();
 	}
 
diff --git a/php/config.php b/php/config.php
index a62614e..d0d6088 100644
--- a/php/config.php
+++ b/php/config.php
@@ -167,7 +167,7 @@ $API = array(
 			'modifyTTCacheInterval'=>array('len'=>1),
 			'operationTTCacheIntervals'=>array('len'=>2),
 			'mergeTTCacheIntervals'=>array('len'=>0),
-			'getTTCacheStatistics'=>array('len'=>0),
+			'getTTCacheStatistics'=>array('len'=>1),
 			'sendFeedback'=>array('len'=>1),
 			'saveState'=>array('len'=>1),
 			'loadState'=>array('len'=>1),
--
libgit2 0.21.2