Commit 69c5bc1eff495fc452ce0546199e3ce919427324

Authored by Benjamin Renard
1 parent ca4c6ce0

Add modif. time for data mining (#7063) + Add the possibility to resample a data…

… mining request under a ref. parameter (#7018)
js/app/models/Search.js
@@ -24,10 +24,13 @@ Ext.define('amdaModel.Search', { @@ -24,10 +24,13 @@ Ext.define('amdaModel.Search', {
24 {name: 'sampling', type: 'int', defaultValue: '600'}, 24 {name: 'sampling', type: 'int', defaultValue: '600'},
25 {name: 'gap', type: 'int', defaultValue: '5'}, 25 {name: 'gap', type: 'int', defaultValue: '5'},
26 {name: 'description', type: 'string'}, 26 {name: 'description', type: 'string'},
27 - {name: 'expression', type: 'string'} 27 + {name: 'expression', type: 'string'},
  28 + {name: 'last_update', type: 'int', defaultValue: 0},
  29 + {name: 'sampling_mode', type: 'string', defaultValue: 'timestep'}, // 'timestep' or 'refparam'
  30 + {name: 'reference_param', type: 'string'} // only used if 'sampling_mode' is 'refparam'
28 ], 31 ],
29 32
30 - propertiesToCopy : 'id,name,sampling,gap,description,expression', 33 + propertiesToCopy : 'id,name,sampling,gap,description,expression,last_update,sampling_mode,reference_param',
31 34
32 getJsonValues : function(hasId){ 35 getJsonValues : function(hasId){
33 36
@@ -38,6 +41,8 @@ Ext.define('amdaModel.Search', { @@ -38,6 +41,8 @@ Ext.define('amdaModel.Search', {
38 myValues.name = this.get('name'); 41 myValues.name = this.get('name');
39 myValues.sampling = this.get('sampling'); 42 myValues.sampling = this.get('sampling');
40 myValues.gap = this.get('gap'); 43 myValues.gap = this.get('gap');
  44 + myValues.sampling_mode = this.get('sampling_mode');
  45 + myValues.reference_param = this.get('reference_param');
41 myValues.description = this.get('description'); 46 myValues.description = this.get('description');
42 myValues.expression = this.get('expression').replace(/\n/g," ");; 47 myValues.expression = this.get('expression').replace(/\n/g," ");;
43 myValues.timesrc = this.get('timesrc'); 48 myValues.timesrc = this.get('timesrc');
@@ -73,4 +78,4 @@ Ext.define('amdaModel.Search', { @@ -73,4 +78,4 @@ Ext.define('amdaModel.Search', {
73 return myValues; 78 return myValues;
74 } 79 }
75 80
76 -});  
77 \ No newline at end of file 81 \ No newline at end of file
  82 +});
js/app/views/SearchUI.js
@@ -298,9 +298,9 @@ Ext.define('amdaUI.SearchUI', @@ -298,9 +298,9 @@ Ext.define('amdaUI.SearchUI',
298 this.fieldName = new Ext.form.field.Text({ 298 this.fieldName = new Ext.form.field.Text({
299 labelAlign: 'top', itemId: 'formParamName', 299 labelAlign: 'top', itemId: 'formParamName',
300 fieldLabel: 'Request Name', 300 fieldLabel: 'Request Name',
  301 + labelPad: 0,
301 name : 'name', 302 name : 'name',
302 - width: 375,  
303 - colspan: 3, 303 + width: 165,
304 allowBlank : false, 304 allowBlank : false,
305 stripCharsRe: /(^\s+|\s+$)/g, 305 stripCharsRe: /(^\s+|\s+$)/g,
306 validateOnChange: false, 306 validateOnChange: false,
@@ -315,6 +315,7 @@ Ext.define('amdaUI.SearchUI', @@ -315,6 +315,7 @@ Ext.define('amdaUI.SearchUI',
315 this.constructionField = new extensions.SelectableTextArea( 315 this.constructionField = new extensions.SelectableTextArea(
316 { 316 {
317 labelAlign: 'top', 317 labelAlign: 'top',
  318 + labelPad: 0,
318 itemId: 'formSearchCondition', 319 itemId: 'formSearchCondition',
319 fieldLabel:'<img amda_clicktip="constructParameter" src="js/resources/images/16x16/info_mini.png"/>&nbsp;Data Mining Condition', 320 fieldLabel:'<img amda_clicktip="constructParameter" src="js/resources/images/16x16/info_mini.png"/>&nbsp;Data Mining Condition',
320 allowBlank : false, blankText : 'Condition expression is required', 321 allowBlank : false, blankText : 'Condition expression is required',
@@ -322,7 +323,7 @@ Ext.define(&#39;amdaUI.SearchUI&#39;, @@ -322,7 +323,7 @@ Ext.define(&#39;amdaUI.SearchUI&#39;,
322 validateOnChange: false, 323 validateOnChange: false,
323 validateOnBlur: false, 324 validateOnBlur: false,
324 validator : this.isBalanced, 325 validator : this.isBalanced,
325 - flex : 2.5, 326 + flex : 2,
326 listeners : 327 listeners :
327 { 328 {
328 render : function(o,op) 329 render : function(o,op)
@@ -421,6 +422,90 @@ Ext.define(&#39;amdaUI.SearchUI&#39;, @@ -421,6 +422,90 @@ Ext.define(&#39;amdaUI.SearchUI&#39;,
421 } 422 }
422 }); 423 });
423 424
  425 + var samplingmode_store = new Ext.data.ArrayStore({
  426 + fields: ['id', 'name'],
  427 + data: [
  428 + ['timestep', 'Time Step'],
  429 + ['refparam', 'Ref. Parameter']
  430 + ]
  431 + });
  432 +
  433 + this.timeStepField = new Ext.form.NumberField({
  434 + fieldLabel: '<img amda_clicktip="resamplingStep" src="js/resources/images/16x16/info_mini.png"/>&nbsp;Time Step (sec)',
  435 + labelAlign: 'top',
  436 + labelPad: 0,
  437 + blankText : 'Time Step is required',
  438 + name : 'sampling',
  439 + minValue : 0.001,
  440 + decimalPrecision : 10,
  441 + hideTrigger: true,
  442 + width: 165,
  443 + validateOnBlur: false
  444 + });
  445 +
  446 + this.refParamField = new Ext.form.TextField({
  447 + fieldLabel: '<img amda_clicktip="resamplingRefParam" src="js/resources/images/16x16/info_mini.png"/>&nbsp;Reference Param.',
  448 + labelAlign: 'top',
  449 + labelPad: 0,
  450 + name : 'reference_param',
  451 + width: 165,
  452 + hidden: true,
  453 + listeners: {
  454 + afterrender: function(field, eOpts ){
  455 + var paramTarget = new Ext.dd.DropTarget(field.el.dom,
  456 + {
  457 + ddGroup: 'explorerTree',
  458 + notifyEnter: function(ddSource, e, data) {
  459 + },
  460 + notifyDrop: function(ddSource, e, data) {
  461 + var selectedRecord = ddSource.dragData.records[0];
  462 + switch (selectedRecord.$className) {
  463 + case 'amdaModel.LocalParamNode' :
  464 + case 'amdaModel.RemoteParamNode' :
  465 + case 'amdaModel.RemoteSimuParamNode' :
  466 + if (!selectedRecord.get('isParameter') || selectedRecord.get('disable'))
  467 + return false;
  468 + if (selectedRecord.get('alias') != "" )
  469 + field.setValue("#"+selectedRecord.get('alias'));
  470 + else
  471 + field.setValue(selectedRecord.get('id'));
  472 + return true;
  473 + case 'amdaModel.AliasNode' :
  474 + if (!selectedRecord.isLeaf())
  475 + return false;
  476 + field.setValue("#"+selectedRecord.get('text'));
  477 + return true;
  478 + case 'amdaModel.DerivedParamNode' :
  479 + if (!selectedRecord.isLeaf())
  480 + return false;
  481 + field.setValue("ws_"+selectedRecord.get('text'));
  482 + return true;
  483 + case 'amdaModel.MyDataParamNode' :
  484 + if (!selectedRecord.isLeaf())
  485 + return false;
  486 + field.setValue("wsd_"+selectedRecord.get('text'));
  487 + return true;
  488 + default:
  489 + return false;
  490 + }
  491 + return true;
  492 + }
  493 + }
  494 + );
  495 + },
  496 + scope: this
  497 + }
  498 + });
  499 +
  500 + this.samplingDefContainer = new Ext.container.Container({
  501 + border: false,
  502 + items: [
  503 + this.timeStepField,
  504 + this.refParamField
  505 + ],
  506 + width: 165
  507 + });
  508 +
424 this.formPanel = new Ext.form.Panel( 509 this.formPanel = new Ext.form.Panel(
425 { 510 {
426 region : 'center', 511 region : 'center',
@@ -430,7 +515,7 @@ Ext.define(&#39;amdaUI.SearchUI&#39;, @@ -430,7 +515,7 @@ Ext.define(&#39;amdaUI.SearchUI&#39;,
430 layout : { 515 layout : {
431 type : 'vbox', 516 type : 'vbox',
432 align: 'stretch', 517 align: 'stretch',
433 - defaultMargins : { top:15, bottom:0, left: 15, right:15} 518 + defaultMargins: {top: 5, left:5, bottom:10, right:10}
434 }, 519 },
435 id: 'formSearch', 520 id: 'formSearch',
436 defaults: { 521 defaults: {
@@ -455,29 +540,57 @@ Ext.define(&#39;amdaUI.SearchUI&#39;, @@ -455,29 +540,57 @@ Ext.define(&#39;amdaUI.SearchUI&#39;,
455 }, 540 },
456 defaultType: 'textfield', 541 defaultType: 'textfield',
457 defaults: { 542 defaults: {
458 - labelAlign: 'top' 543 + labelAlign: 'top',
  544 + labelPad: 0
459 }, 545 },
460 items: [ 546 items: [
461 this.fieldName, 547 this.fieldName,
  548 + { xtype: 'component', width: 45},
462 { 549 {
463 - xtype :'displayfield', width: 165,  
464 - hideLabel: true,  
465 - value: '<b>Averaging/Interpolation</b>&nbsp;<img amda_clicktip="resamplingStep" src="js/resources/images/16x16/info_mini.png"/>' 550 + fieldLabel: 'Last modification',
  551 + xtype: 'displayfield',
  552 + name : 'last_update',
  553 + width: 165,
  554 + renderer: function(value, field) {
  555 + var tpl = new Ext.XTemplate('<p style="font-style:italic;color:gray;margin:0;">{date}</>');
  556 + var mod_date = 'Not saved';
  557 + if (value > 0)
  558 + mod_date = Ext.Date.format(new Date(value*1000), "Y-m-d\\TH:i:s");
  559 + return tpl.apply({date: mod_date});
  560 + },
  561 + },
  562 + {
  563 + xtype: 'combo',
  564 + fieldLabel: 'Sampling mode',
  565 + name: 'sampling_mode',
  566 + queryMode: 'local',
  567 + editable: false,
  568 + valueField: 'id',
  569 + displayField: 'name',
  570 + store: samplingmode_store,
  571 + value: samplingmode_store.first(),
  572 + width: 165,
  573 + listeners: {
  574 + change: function(field, value) {
  575 + this.timeStepField.setVisible(value != 'refparam');
  576 + this.refParamField.setVisible(value == 'refparam');
  577 + },
  578 + scope: this
  579 + }
  580 + },
  581 + {
  582 + xtype:'component', width: 45
466 }, 583 },
467 - { xtype: 'component', width: 45 }, 584 + this.samplingDefContainer,
468 { 585 {
469 xtype :'displayfield', width: 165, 586 xtype :'displayfield', width: 165,
470 - hideLabel: true,  
471 - value: '<b>Data Gap</b>&nbsp;<img amda_clicktip="dataGap" src="js/resources/images/16x16/info_mini.png"/>' 587 + hideLabel: true,
  588 + fieldStyle: 'display:inline-block;text-align:right',
  589 + value: '<b style="top: 50%;position: relative;">Data Gap&nbsp;<img amda_clicktip="dataGap" src="js/resources/images/16x16/info_mini.png"/></b>'
472 }, 590 },
473 { 591 {
474 - xtype: 'numberfield', name: 'sampling',  
475 - allowBlank : false, blankText : 'Time Step is required',  
476 - fieldLabel: 'Time Step (sec)', minValue : 0.001,  
477 - labelAlign: 'top', hideTrigger: true, width: 165,  
478 - validateOnBlur: false 592 + xtype:'component', width: 45
479 }, 593 },
480 - { xtype: 'component', width: 45 },  
481 { 594 {
482 xtype: 'numberfield', name: 'gap', 595 xtype: 'numberfield', name: 'gap',
483 fieldLabel: 'if no data for interval', minValue : 1, 596 fieldLabel: 'if no data for interval', minValue : 1,
php/classes/DerivedParamMgr.php
@@ -324,7 +324,6 @@ class DerivedParamMgr extends AmdaObjectMgr @@ -324,7 +324,6 @@ class DerivedParamMgr extends AmdaObjectMgr
324 324
325 $attributesToReturn['id'] = $objToGet->getAttribute('xml:id'); 325 $attributesToReturn['id'] = $objToGet->getAttribute('xml:id');
326 $attributes = $objToGet -> childNodes; 326 $attributes = $objToGet -> childNodes;
327 - $last_update = 0;  
328 foreach($attributes as $attribute) 327 foreach($attributes as $attribute)
329 { 328 {
330 if ($attribute->tagName === "buildchain") $attributesToReturn[$attribute->tagName] = $this->setAlias($attribute->nodeValue); 329 if ($attribute->tagName === "buildchain") $attributesToReturn[$attribute->tagName] = $this->setAlias($attribute->nodeValue);
php/classes/RequestMgr.php
@@ -132,7 +132,9 @@ class RequestMgr extends AmdaObjectMgr @@ -132,7 +132,9 @@ class RequestMgr extends AmdaObjectMgr
132 } 132 }
133 } 133 }
134 //if Start Time - Stop Time 134 //if Start Time - Stop Time
135 - if (!$obj->timeTables) $obj = $this->convertTime($obj); 135 + if (!$obj->timeTables) $obj = $this->convertTime($obj);
  136 + if (empty($obj->last_update))
  137 + $obj->last_update = filemtime(USERREQDIR.$id);
136 138
137 return $obj; 139 return $obj;
138 } 140 }
@@ -192,6 +194,7 @@ class RequestMgr extends AmdaObjectMgr @@ -192,6 +194,7 @@ class RequestMgr extends AmdaObjectMgr
192 194
193 $this->descFileName = USERREQDIR.$this->id; 195 $this->descFileName = USERREQDIR.$this->id;
194 $p->id = $this->id; 196 $p->id = $this->id;
  197 + $p->last_update = time();
195 // save request as json 198 // save request as json
196 $file = fopen($this->descFileName, 'w'); 199 $file = fopen($this->descFileName, 'w');
197 fwrite($file, json_encode($p)); 200 fwrite($file, json_encode($p));
@@ -199,7 +202,7 @@ class RequestMgr extends AmdaObjectMgr @@ -199,7 +202,7 @@ class RequestMgr extends AmdaObjectMgr
199 202
200 $this -> addToContent($p, $folder); 203 $this -> addToContent($p, $folder);
201 204
202 - return array('id' => $this->id, 'info' => $info) + $additional; 205 + return array('id' => $this->id, 'info' => $info, 'last_update' => $p->last_update) + $additional;
203 } 206 }
204 207
205 public static function checkRequest($obj) 208 public static function checkRequest($obj)