Commit 073d0df38056b3ad9ba4087a20e6c17229ad10e1

Authored by Benjamin Renard
2 parents b292239c 15d50c0c

Merge branch 'FER_11500' into amdadev

js/app/models/PlotObjects/PlotIntervalsObject.js
... ... @@ -26,7 +26,9 @@ Ext.define('amdaPlotObj.PlotIntervalsObject', {
26 26 { name: 'legend-text-font-name', type: 'string', defaultValue: "sans-serif" },
27 27 { name: 'legend-text-font-size', type: 'int', defaultValue: "12" },
28 28 { name: 'legend-text-font-bold', type: 'boolean' },
29   - { name: 'legend-text-font-italic', type: 'boolean' }
  29 + { name: 'legend-text-font-italic', type: 'boolean' },
  30 + { name: 'intervals-column-show', type: 'boolean', defaultValue: false},
  31 + { name: 'intervals-param-show', type: 'string', defaultValue: ""}
30 32  
31 33 ],
32 34  
... ... @@ -64,7 +66,7 @@ Ext.define('amdaPlotObj.PlotIntervalsObject', {
64 66 {
65 67 var intervalsValues = new Object();
66 68 intervalsValues['intervals-color'] = this.get('intervals-color');
67   - intervalsValues['legend-text-activated'] = this.get('legend-text-activated');
  69 + intervalsValues['legend-text-activated'] = this.get('legend-text-activated');
68 70 intervalsValues['legend-text-value'] = this.get('legend-text-value');
69 71 intervalsValues['legend-text-position'] = this.get('legend-text-position');
70 72 intervalsValues['legend-text-color'] = this.get('legend-text-color');
... ... @@ -73,6 +75,8 @@ Ext.define('amdaPlotObj.PlotIntervalsObject', {
73 75 intervalsValues['legend-text-font-size'] = this.get('legend-text-font-size');
74 76 intervalsValues['legend-text-font-bold'] = this.get('legend-text-font-bold');
75 77 intervalsValues['legend-text-font-italic'] = this.get('legend-text-font-italic');
  78 + intervalsValues['intervals-column-show'] = this.get('intervals-column-show');
  79 + intervalsValues['intervals-param-show'] = this.get('intervals-param-show');
76 80  
77 81 return intervalsValues;
78 82 }
... ...
js/app/views/PlotComponents/PlotContextManager.js
... ... @@ -51,97 +51,55 @@ Ext.define('amdaPlotComp.PlotContextManager', {
51 51 return resPanel;
52 52 },
53 53  
54   - getIntervalCoordInfo: function (context, panel, crtTimestamp) {
55   - var intervalName = new Array();
56   - var intervalId = new Array();
57   - var intervalText = "";
58   - Ext.each(panel.intervals, function (interval) {
59   - if (crtTimestamp > interval.startTime && crtTimestamp < interval.stopTime) {
60   - intervalName.push(interval.name);
61   - intervalId.push(interval.id);
62   - }
63   - return;
64   - });
65   - if (intervalName.length > 0) {
66   - intervalText = 'TT: ' + intervalName[0] + ', id: [' + intervalId[0];
67   - for (i = 1; i < intervalName.length; i++) {
68   - if (intervalName[i] == intervalName[i - 1]) {
69   - intervalText += ', ' + intervalId[i];
70   - }
71   - else {
72   - intervalText += '] | TT: ' + intervalName[i] + ', id: [' + intervalId[i];
73   - }
74   - }
75   - intervalText += ']'
76   - }
77   - return intervalText;
78   - },
79   -
80   - getAllIntervalParams(context, panel, crtTimestamp) {
81   - var allParams = new Array();
82   -
83   - Ext.each(panel.intervals, function (interval) {
84   - if (crtTimestamp > interval.startTime && crtTimestamp < interval.stopTime && interval.params != "") {
85   - allParams.push(interval.params);
86   - }
87   - return;
88   -
89   - });
90   - return allParams;
91   - },
  54 + getIntervalsOverMouse: function (context, panel, crtTimestamp) {
  55 + var intervalsOver = {};
  56 + Ext.each(panel.parameters, function (parameter) {
  57 +
  58 + if (!parameter.ttorcat) {
  59 + return;
  60 + }
  61 +
  62 + if (!parameter.ttorcat.intervals) {
  63 + return;
  64 + }
92 65  
93   - getIntervalLinks(allintervalParams) {
94   - var links = new Array();
95   - Ext.each(allintervalParams, function (allParams) {
  66 + var columnToShow = parameter.ttorcat.hasOwnProperty('columnToShow') ? parameter.ttorcat.columnToShow : '';
  67 + var columnName = "";
96 68  
97   - var params = allParams.split('|');
  69 + if ((columnToShow != '') && parameter.ttorcat.columns) {
  70 + Ext.Object.each(parameter.ttorcat.columns, function (column_id, column_value) {
  71 + if (column_id == columnToShow) {
  72 + columnName = column_value.name;
  73 + }
  74 + });
  75 + }
98 76  
99   - Ext.each(params, function (param) {
100   - if (param.toLowerCase().startsWith("http://") || param.toLowerCase().startsWith("https://")) {
101   - links.push(param);
102   - }
103   - return;
104   - });
105   - return;
106   - });
107   - return links;
108   - },
  77 + Ext.Object.each(parameter.ttorcat.intervals, function (id, interval) {
  78 + if (crtTimestamp > interval.start && crtTimestamp < interval.stop) {
  79 + if (!intervalsOver.hasOwnProperty(parameter.ttorcat.name)) {
  80 + intervalsOver[parameter.ttorcat.name] = [];
  81 + }
  82 + var intToPush = {
  83 + 'id': id,
  84 + 'start': interval.start,
  85 + 'stop': interval.stop
  86 + };
  87 + if ((columnToShow != '') && (columnName != '') && interval.hasOwnProperty('params')) {
  88 + Ext.Object.each(interval.params, function (param_id, param_value) {
  89 + if (param_id == columnToShow) {
  90 + intToPush['info'] = columnName + ': ' + param_value;
  91 + return;
  92 + }
  93 + });
  94 + }
109 95  
110   - setIntervalsRef(links, menu) {
111   - var realLinks = new Array();
112   - for (i = 0; i < links.length; i++) {
113   - var isAlreadyHere = false
114   - for (j = 0; j < i; j++) {
115   - if (links[i] == links[j]) {
116   - isAlreadyHere = true;
117   - continue;
118   - }
119   - }
120   - if (isAlreadyHere == false) {
121   - realLinks.push(links[i]);
122   - }
123   - }
  96 + intervalsOver[parameter.ttorcat.name].push(intToPush);
124 97  
125   - Ext.each(realLinks, function (realLink) {
126   - menu.add({
127   - text: realLink,
128   - handler: function () {
129   - window.open(realLink, "_blank");
130   - }
131   - });
  98 + }
  99 + });
132 100 });
133   - return realLinks;
134   - },
135 101  
136   - isInterval: function (context, panel, crtTimestamp) {
137   - isInterval = false;
138   - Ext.each(panel.intervals, function (interval) {
139   - if (crtTimestamp > interval.startTime && crtTimestamp < interval.stopTime) {
140   - isInterval = true;
141   - }
142   - return;
143   - });
144   - return isInterval;
  102 + return intervalsOver;
145 103 },
146 104  
147 105 getInstantTimePrev :function(context)
... ... @@ -201,4 +159,4 @@ Ext.define(&#39;amdaPlotComp.PlotContextManager&#39;, {
201 159  
202 160 return axisContext.min + (pixelValue - pixelMin)/(pixelMax - pixelMin)*(axisContext.max-axisContext.min);
203 161 }
204   -});
205 162 \ No newline at end of file
  163 +});
... ...
js/app/views/PlotComponents/PlotIntervalsForm.js
... ... @@ -10,20 +10,56 @@
10 10  
11 11 Ext.define('amdaPlotComp.PlotIntervalsForm', {
12 12 extend: 'amdaPlotComp.PlotStandardForm',
  13 +
  14 + catalogsColumns: {},
  15 +
  16 + paramId: '',
13 17  
14 18 setObject : function(object) {
15 19 this.object = object.get('param-drawing-object');
16   - this.loadRecord(this.object);
  20 + paramId = object.get('paramid');
  21 + this.loadRecord(this.object);
  22 + this.updateColumnInfoCombo();
17 23 },
18   -
  24 +
  25 + updateColumnInfoCombo: function(){
  26 + var me = this;
  27 + if ((paramId.substring(0, 3) != 'cat') && (paramId.substring(0, 13) != 'sharedcatalog')) {
  28 + // Not available for TT
  29 + this.getForm().findField('intervals-column-show').setDisabled(true);
  30 + return;
  31 + }
  32 +
  33 + this.getForm().findField('intervals-column-show').setDisabled(false);
  34 + if (this.catalogsColumns.hasOwnProperty(paramId)) {
  35 + var combobox = this.getForm().findField('intervals-param-show');
  36 + combobox.store.loadData(this.catalogsColumns[paramId]);
  37 + combobox.setValue(this.object.get('intervals-param-show'));
  38 + }
  39 + else {
  40 + AmdaAction.getAllColumnNames(paramId, function(result){
  41 + if (result && result['success']) {
  42 + this.catalogsColumns[paramId] = result['result'];
  43 + me.updateColumnInfoCombo();
  44 + }
  45 + }, this);
  46 + }
  47 + },
  48 +
19 49 getFormItems: function() {
  50 + var me = this;
20 51 var legendItems = [
21 52 this.addStandardText('legend-text-value', 'Text'),
22 53 this.addStandardCombo('legend-text-position', 'Position', amdaDefaultConfigs.availableLegendTextPositions),
23 54 this.addStandardFont('legend-text-font')]
24   -
  55 +
25 56 return [
26 57 this.addColorsPicker('intervals-color', 'Color', amdaDefaultConfigs.availableColorsNew, 'none'),
  58 + this.addStandardFieldSet('Show column info','intervals-column-show', [
  59 + this.addStandardCombo('intervals-param-show', 'Parameter to show'),
  60 + ], function(name, value, oldValue) {
  61 + me.updateColumnInfoCombo();
  62 + }),
27 63 this.addStandardFieldSet('Legend', 'legend-text-activated', legendItems)
28 64 ];
29 65 }
... ...
js/app/views/PlotComponents/PlotResultImage.js
... ... @@ -30,6 +30,8 @@ Ext.define(&#39;amdaPlotComp.PlotResultImage&#39;, {
30 30  
31 31 showVerticalCursor : true,
32 32 showHorizontalCursor : true,
  33 +
  34 + tooltip: true,
33 35  
34 36 constructor: function(config) {
35 37 this.init(config);
... ... @@ -210,6 +212,7 @@ Ext.define(&#39;amdaPlotComp.PlotResultImage&#39;, {
210 212 height : config.height,
211 213 onMouseMove : config.onMouseMove,
212 214 onContextMenu : config.onContextMenu,
  215 + tooltip : null,
213 216 listeners : {
214 217 render : function(img, eOpts){
215 218 me.refreshMe();
... ... @@ -246,7 +249,18 @@ Ext.define(&#39;amdaPlotComp.PlotResultImage&#39;, {
246 249 me.onContextMenu(event.getX(), event.getY(), event.getX()-me.getPosition()[0], event.getY()-me.getPosition()[1]);
247 250 return false;
248 251 }
249   - }
  252 + },
  253 + afterrender: function(c) {
  254 + me.tooltip = Ext.create('Ext.tip.ToolTip', {
  255 + target: c.getEl(),
  256 + trackMouse: true,
  257 + dismissDelay: 0,
  258 + showDelay: 0,
  259 + hideDelay: 0,
  260 + autoHide: true,
  261 + disabled: true
  262 + });
  263 + }
250 264 }
251 265 };
252 266  
... ...
js/app/views/PlotTabResultUI.js
... ... @@ -326,8 +326,13 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
326 326 var text = '';
327 327 if (me.panelImage) {
328 328 if (!panel) {
329   - me.panelImage.resetCursor();
330 329 text += 'No panel';
  330 + me.panelImage.resetCursor();
  331 + if (me.panelImage.tooltip.isVisible()) {
  332 + me.panelImage.tooltip.update('');
  333 + me.panelImage.tooltip.setDisabled(true);
  334 + me.panelImage.tooltip.hide();
  335 + }
331 336 }
332 337 else {
333 338 text += 'Panel Id : ';
... ... @@ -350,14 +355,14 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
350 355 var yLeftText = '';
351 356 var colorText = '';
352 357 var yRightText = '';
353   - var intervalText = '';
  358 + var intervals = [];
354 359 var image=this;
355 360 Ext.each(panel.plotArea.axes, function (axis) {
356 361 switch (axis.id) {
357 362 case 'timeAxis':
358 363 var crtTimestamp = amdaPlotComp.PlotContextManager.toAxisValue(axis, panel.plotArea.x, panel.plotArea.x + panel.plotArea.width, sourceXPos);
359 364 var crtTime = new Date(crtTimestamp * 1000);
360   - intervalText = amdaPlotComp.PlotContextManager.getIntervalCoordInfo(me.crtContext, panel, crtTimestamp);
  365 + intervals = amdaPlotComp.PlotContextManager.getIntervalsOverMouse(me.crtContext, panel, crtTimestamp);
361 366 xText = crtTime.toJSON();
362 367 break;
363 368 case 'y-left':
... ... @@ -385,13 +390,34 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
385 390 text += (', Y Left : ' + yLeftText);
386 391 if (yRightText != '')
387 392 text += (', Y Right : ' + yRightText);
388   - if (intervalText != '')
389   - text += (', ' + intervalText);
390 393 if (colorText != '')
391 394 text += (', Z : '+ colorText);
  395 +
  396 + // Update tooltip
  397 + if (Object.keys(intervals).length > 0) {
  398 + var tooltipText = me.getIntervalsTooltipText(intervals);
  399 + me.panelImage.tooltip.update(tooltipText);
  400 + me.panelImage.tooltip.setDisabled(false);
  401 + if (!me.panelImage.tooltip.isVisible()) {
  402 + me.panelImage.tooltip.show();
  403 + me.panelImage.tooltip.setDisabled(false);
  404 + }
  405 + }
  406 + else if (me.panelImage.tooltip.isVisible()) {
  407 + me.panelImage.tooltip.update('');
  408 + me.panelImage.tooltip.setDisabled(true);
  409 + me.panelImage.tooltip.hide();
  410 +
  411 + }
392 412 }
393   - else
  413 + else {
394 414 me.panelImage.resetCursor();
  415 + if (me.panelImage.tooltip.isVisible()) {
  416 + me.panelImage.tooltip.update('');
  417 + me.panelImage.tooltip.setDisabled(true);
  418 + me.panelImage.tooltip.hide();
  419 + }
  420 + }
395 421 }
396 422 }
397 423 me.coordinatesField.setText(text);
... ... @@ -474,18 +500,37 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
474 500 }
475 501 ]);
476 502  
477   - if (timeAxisContext && amdaPlotComp.PlotContextManager.isInterval(me.crtContext, panel, crtTimestamp)) {
478   - var allintervalParams = amdaPlotComp.PlotContextManager.getAllIntervalParams(me.crtContext, panel, crtTimestamp);
479   - if (allintervalParams.length > 0) {
480   -
481   - var links = amdaPlotComp.PlotContextManager.getIntervalLinks(allintervalParams);
482   - if (links.length > 0) {
  503 + if (timeAxisContext) {
  504 + var intervals = amdaPlotComp.PlotContextManager.getIntervalsOverMouse(me.crtContext, panel, crtTimestamp);
  505 + if (Object.keys(intervals).length > 0) {
  506 + var links = [];
  507 + Ext.Object.each(intervals, function (ttorcatname, intervals) {
  508 + Ext.each(intervals, function (interval) {
  509 + if (interval.params) {
  510 + Ext.Object.each(interval.params, function (paramKey, paramValue) {
  511 + if (paramValue.toLowerCase().startsWith("http://") || paramValue.toLowerCase().startsWith("https://")) {
  512 + if (links.indexOf(paramValue) < 0) {
  513 + links.push(paramValue);
  514 + }
  515 + }
  516 + });
  517 + }
  518 + });
  519 + });
  520 + if (links.length > 0) {
483 521 var menu = Ext.create('Ext.menu.Menu', { plain: true });
484   - var realLinks = amdaPlotComp.PlotContextManager.setIntervalsRef(links, menu);
  522 + Ext.each(links, function (link) {
  523 + menu.add({
  524 + text: link,
  525 + handler: function () {
  526 + window.open(link, "_blank");
  527 + }
  528 + });
  529 + });
485 530 me.contextualMenu.add('-');
486 531 me.contextualMenu.add([
487 532 {
488   - text: 'Open references (' + realLinks.length + ')',
  533 + text: 'Open references (' + links.length + ')',
489 534 menu: menu,
490 535 scope: me
491 536 }]);
... ... @@ -524,6 +569,23 @@ Ext.define(&#39;amdaUI.PlotTabResultUI&#39;, {
524 569 this.panelImage.refreshMe();
525 570 },
526 571  
  572 + getIntervalsTooltipText: function(intervals) {
  573 + var intervalText = '';
  574 + Ext.Object.each(intervals, function (ttorcatname, intervals) {
  575 + intervalText += '<b>' + ttorcatname + ' :</b><br>';
  576 + Ext.each(intervals, function (interval) {
  577 + intervalText += " &bull; #" + interval.id + ': ' + new Date(parseFloat(interval.start)*1000).toISOString() + ' - ' + new Date(parseFloat(interval.stop)*1000).toISOString();
  578 + if (interval.info && interval.info != '') {
  579 + intervalText += ", " + interval.info;
  580 + }
  581 + intervalText += "<br>"
  582 + });
  583 + intervalText += '<br>';
  584 + });
  585 +
  586 + return intervalText;
  587 + },
  588 +
527 589 updateTimeTableInfo: function () {
528 590 if (!this.navToolBar)
529 591 return;
... ...
php/classes/AmdaAction.php
... ... @@ -810,6 +810,18 @@ class AmdaAction
810 810 return $objectMgr->getObject($id, $nodeType);
811 811 }
812 812  
  813 + public function getAllColumnNames($id){
  814 + $objectMgr = new CatalogMgr();
  815 + $type = (strpos($id, 'sharedcatalog') === 0) ? 'sharedcatalog' : 'catalog';
  816 + $columnInfos = $objectMgr->getCatalogParamDescription(array('id' => $id, 'type' => $type));
  817 + if (!$columnInfos['success'])
  818 + return $columnInfos;
  819 + $columnNames = array();
  820 + foreach ($columnInfos['parameters'] as $columnInfo){
  821 + $columnNames[] = array("key" => $columnInfo['id'], "value" => $columnInfo['name']);
  822 + }
  823 + return array('success' => true ,"result" => $columnNames);
  824 + }
813 825 /*
814 826 * $obj = { id: node.id, leaf: node.leaf, nodeType: node.nodeType }
815 827 */
... ...
php/config.php
... ... @@ -218,6 +218,8 @@ $API = array(
218 218 'getParametersList' => array('len' => 0),
219 219 // Reset user password
220 220 'resetPwd' => array('len' => 1),
  221 + // Get column names for a cat
  222 + 'getAllColumnNames' => array('len' => 1),
221 223  
222 224 )
223 225 )
... ...