Commit 21ff9173a5d419d1df4ce090f5a6daf61906d8f7

Authored by Benjamin Renard
2 parents 315ba40a 42c4ccd3

Merge FER_9660 into develop

js/app/views/CatalogUI.js
... ... @@ -483,7 +483,8 @@ Ext.define('amdaUI.CatalogUI', {
483 483 sortable: true,
484 484 dataIndex: obj.id,
485 485 menuDisabled: false,
486   - minWidth: 50
  486 + minWidth: 50,
  487 + paramColumn: true
487 488 };
488 489 switch (obj.type) {
489 490 case 0: //double
... ... @@ -503,12 +504,10 @@ Ext.define('amdaUI.CatalogUI', {
503 504 dateFormat: 'Y-m-d\\TH:i:s.u',
504 505 convert: function (value, rec) {
505 506 if (!Ext.isDate(value)) {
506   - var valueString = new String(value);
507   - return new Date(valueString.replace(/\-/g, '\/').replace(/[T|Z]/g, ' '));
  507 + return new Date(value);
508 508 }
509 509 return value;
510 510 }
511   -
512 511 });
513 512 column = Ext.apply({}, column, {
514 513 xtype: 'datecolumn',
... ... @@ -519,7 +518,18 @@ Ext.define('amdaUI.CatalogUI', {
519 518 hideTrigger: true,
520 519 format: 'Y-m-d\\TH:i:s.u'
521 520 },
522   - filter: {type: 'date', dateFormat: 'Y-m-d'}
  521 + filter: {type: 'date', dateFormat: 'Y-m-d'},
  522 + renderer: function (value) {
  523 + if (value != null) {
  524 + if (Ext.isDate(value)) {
  525 + return Ext.Date.format(value, 'Y-m-d\\TH:i:s.u');
  526 + } else {
  527 + return Ext.Date.format(new Date(value), 'Y-m-d\\TH:i:s.u');
  528 + }
  529 + } else {
  530 + return value;
  531 + }
  532 + }
523 533 });
524 534 break;
525 535 case 2: //string
... ... @@ -565,7 +575,6 @@ Ext.define('amdaUI.CatalogUI', {
565 575 fieldsConfig.push(field);
566 576 columnsConfig.push(column);
567 577 });
568   -
569 578 var store = Ext.create('Ext.data.Store', {
570 579 fields: fieldsConfig,
571 580 autoDestroy: false,
... ... @@ -842,8 +851,157 @@ Ext.define('amdaUI.CatalogUI', {
842 851 }
843 852 }
844 853 },
  854 +
  855 + columnForm: function(isNew, self, me , columnInfo = null){
  856 +
  857 +
  858 + // Different avaible types
  859 + var types = Ext.create('Ext.data.Store', {
  860 + fields: ['type', 'name'],
  861 + data : [
  862 + {"type":2, "name":"String"},
  863 + {"type":3, "name":"Integer"},
  864 + {"type":0, "name":"Float"},
  865 + {"type":1,"name":"TIme"}
  866 + ]
  867 + });
  868 +
  869 + // Window for the creation of the new Column
  870 + var window = Ext.create('Ext.window.Window', {
  871 + title: (isNew) ? 'New Column' : 'Edit Column',
  872 + width: 275,
  873 + height: 155,
  874 + closable:false,
  875 + modal:true,
  876 + resizable: false,
  877 + items: [
  878 + {
  879 + xtype: 'form',
  880 + layout: 'form',
  881 + id: 'simpleForm',
  882 + frame: true,
  883 + bodyPadding: '5 5 0',
  884 + fieldDefaults: {
  885 + msgTarget: 'side',
  886 + labelWidth: 85
  887 + },
  888 + items: [{
  889 + // Name
  890 + xtype:'textfield',
  891 + fieldLabel: 'Column Name',
  892 + name: 'nameColumn',
  893 + value: (isNew) ? null : columnInfo.name,
  894 + allowBlank: false,
  895 + tooltip: 'Enter the name of the column you want to create'
  896 + },{
  897 + // Type
  898 + xtype: 'combobox',
  899 + fieldLabel: 'Data Type',
  900 + name:'typeColumn',
  901 + store:types,
  902 + allowBlank: false,
  903 + value : (isNew) ? null : columnInfo.type,
  904 + queryMode: 'local',
  905 + displayField: 'name',
  906 + valueField: 'type',
  907 + editable: false,
  908 + tooltip: 'Enter the type of data you want to put in this column'
  909 + },
  910 + {
  911 + // Size
  912 + xtype:'numberfield',
  913 + fieldLabel: 'Size',
  914 + name: 'sizeColumn',
  915 + value: (isNew) ? 1 : columnInfo.size,
  916 + maxValue: 3,
  917 + minValue: 1,
  918 + allowBlank: false,
  919 + tooltip: 'For exemple: 1 for scalar type or 3 for a vector'
  920 + }],
  921 +
  922 + buttons: [{
  923 + text: 'Save',
  924 + handler: function() {
  925 + // If the form is correctly filled, we continue
  926 + if(this.up('form').getForm().isValid()){
  927 + if(isNew){
  928 + var newColumnPrefix='added_param_id_';
  929 + var nbAddedColumn= 0;
  930 + Ext.each(self.TTGrid.headerCt.getGridColumns(), function(column){
  931 + if(column.dataIndex.substr(0, 15) == newColumnPrefix){
  932 + nbAddedColumn++;
  933 + }
  934 + });
  935 +
  936 + AmdaAction.addColumn(newColumnPrefix+nbAddedColumn,
  937 + this.up('form').getForm().findField('nameColumn').getValue(),
  938 + this.up('form').getForm().findField('typeColumn').getValue(),
  939 + this.up('form').getForm().findField('sizeColumn').getValue(),
  940 + function(result, e){
  941 + if(result){
  942 + me.toReconfigure = true;
  943 + me.onAfterInit(result);
  944 + window.close();
  945 + }
  946 + });
  947 + }
  948 + else{
  949 + var newName = null;
  950 + var newType = null;
  951 + var newSize = null;
  952 +
  953 + // Check if there is modifications
  954 + if(this.up('form').getForm().findField('nameColumn').getValue() != columnInfo.name){
  955 + newName = this.up('form').getForm().findField('nameColumn').getValue();
  956 + }
  957 + if(this.up('form').getForm().findField('typeColumn').getValue() != columnInfo.type){
  958 + newType = this.up('form').getForm().findField('typeColumn').getValue();
  959 + }
  960 + if(this.up('form').getForm().findField('sizeColumn').getValue() != columnInfo.size){
  961 + newSize = this.up('form').getForm().findField('sizeColumn').getValue();
  962 + }
  963 +
  964 + if(newName != null || newType != null || newSize != null)
  965 + {
  966 + AmdaAction.editColumn(columnInfo.id, newName, newType, newSize, function(result, e){
  967 + if(result){
  968 + me.toReconfigure = true;
  969 + me.onAfterInit(result);
  970 + window.close();
  971 + }
  972 + });
  973 +
  974 + }
  975 + else{
  976 + window.close();
  977 + }
  978 + }
  979 + }
  980 + },
  981 + },
  982 + {
  983 + // to reset the form
  984 + text: 'Reset',
  985 + handler: function() {
  986 + this.up('form').getForm().reset();
  987 + }
  988 + },
  989 + {
  990 + // To quit the window
  991 + text: 'Cancel',
  992 + handler: function() {
  993 + window.close();
  994 + }
  995 + }]
  996 + }
  997 + ]
  998 + }).show();
  999 +
  1000 + },
  1001 +
845 1002 init: function (config)
846 1003 {
  1004 + var me = this;
847 1005 this.object = config.object;
848 1006 this.fieldName = new Ext.form.field.Text({
849 1007 fieldLabel: 'Name',
... ... @@ -928,7 +1086,7 @@ Ext.define('amdaUI.CatalogUI', {
928 1086  
929 1087 ]
930 1088 };
931   -
  1089 + const self = this;
932 1090 this.TTGrid = Ext.create('Ext.grid.Panel', {
933 1091 height: 530,
934 1092 features: [filters],
... ... @@ -957,8 +1115,74 @@ Ext.define('amdaUI.CatalogUI', {
957 1115 // selType: 'cellmodel',
958 1116 plugins: [cellEditing, {ptype: 'bufferedrenderer'}],
959 1117 listeners: {
960   - afterrender: function () {
  1118 + afterrender: function ( ) {
961 1119 this.TTGrid.headerCt.resizer.tracker.gridBugFix = true;
  1120 + // Adding "Delete Column" in the menu
  1121 + var menu = this.TTGrid.headerCt.getMenu();
  1122 + menu.on('beforeshow',function(){
  1123 + var deleteName='delete_column';
  1124 + var editName= 'edit_column';
  1125 + var isDeleteinMenu = false;
  1126 + var isEditInMenu = false;
  1127 + // Is there already the delete or edit item in the menu
  1128 + Ext.each(menu.items.items, function(items){
  1129 + if(items.name == deleteName){
  1130 + isDeleteinMenu = true;
  1131 + }
  1132 + if(items.name == editName){
  1133 + isEditInMenu = true;
  1134 + }
  1135 +
  1136 + });
  1137 + // Computing the number of parameters in the catalog
  1138 + var nbParamColumns=0;
  1139 + Ext.each(this.TTGrid.headerCt.getGridColumns(), function(column){
  1140 + if(column.paramColumn){
  1141 + nbParamColumns++
  1142 + }
  1143 + });
  1144 +
  1145 + // Adding the "Edit Column" if conditions satisfied
  1146 + if(!isEditInMenu){
  1147 + menu.add({
  1148 + text: 'Edit Column',
  1149 + iconCls: 'icon-parameters',
  1150 + name: editName,
  1151 + handler: function(item,e) {
  1152 + AmdaAction.getCatColumnInfo(menu.activeHeader.dataIndex,function(result, e){
  1153 + if(result){
  1154 + me.columnForm(false, self,me, result);
  1155 + }
  1156 + });
  1157 + }
  1158 + });
  1159 + }
  1160 +
  1161 + // Adding the "Delete Column" if conditions satisfied
  1162 + if(!isDeleteinMenu){
  1163 + menu.add({
  1164 + text: 'Delete Column',
  1165 + iconCls: 'icon-delete',
  1166 + disabled:false,
  1167 + name: deleteName,
  1168 + handler: function(item,e) {
  1169 + AmdaAction.deleteColumn(menu.activeHeader.dataIndex,function(result, e){
  1170 + me.toReconfigure = true;
  1171 + me.onAfterInit(result);
  1172 + });
  1173 + }
  1174 + });
  1175 + }
  1176 +
  1177 + Ext.each(menu.items.items, function(item){
  1178 + if(item.name == deleteName){
  1179 + item.setDisabled(!menu.activeHeader.paramColumn || nbParamColumns <= 1);
  1180 + }
  1181 + if(item.name == editName){
  1182 + item.setDisabled(!menu.activeHeader.paramColumn);
  1183 + }
  1184 + });
  1185 + }, this);
962 1186 },
963 1187 scope: this
964 1188 },
... ... @@ -966,6 +1190,7 @@ Ext.define(&#39;amdaUI.CatalogUI&#39;, {
966 1190 xtype: 'toolbar',
967 1191 items: [{
968 1192 iconCls: 'icon-add',
  1193 + text:'New line',
969 1194 scope: this,
970 1195 handler: function () {
971 1196 cellEditing.cancelEdit();
... ... @@ -992,9 +1217,11 @@ Ext.define(&#39;amdaUI.CatalogUI&#39;, {
992 1217 }
993 1218 }, this);
994 1219 }
995   - }, {
  1220 + },
  1221 + {
996 1222 iconCls: 'icon-delete',
997 1223 disabled: true,
  1224 + text:'Delete Line',
998 1225 itemId: 'delete',
999 1226 scope: this,
1000 1227 handler: function () {
... ... @@ -1011,6 +1238,16 @@ Ext.define(&#39;amdaUI.CatalogUI&#39;, {
1011 1238 }, this);
1012 1239 }
1013 1240 }
  1241 + },
  1242 + '-',{
  1243 + iconCls: 'icon-add',
  1244 + text:'New Column(s)',
  1245 + itemId: 'column_add',
  1246 + scope: this,
  1247 + handler: function () {
  1248 +
  1249 + me.columnForm(true, self,me);
  1250 + }
1014 1251 }, '->',
1015 1252 {
1016 1253 text: 'Clear Filters',
... ...
php/classes/AmdaAction.php
... ... @@ -1652,5 +1652,26 @@ class AmdaAction
1652 1652 );
1653 1653 return $this->executeRequest($args, FunctionTypeEnumClass::PARAMINFO);
1654 1654 }
  1655 +
  1656 + public function deleteColumn($id){
  1657 + $cacheMgr = new CatalogCacheMgr();
  1658 +
  1659 + return $cacheMgr->deleteColumn($id);
  1660 + }
  1661 +
  1662 + public function addColumn($id, $name, $type, $size){
  1663 + $cacheMgr = new CatalogCacheMgr();
  1664 + return $cacheMgr->addColumn($id,$name, $type,$size);
  1665 + }
  1666 +
  1667 + public function getCatColumnInfo($id){
  1668 + $cacheMgr = new CatalogCacheMgr();
  1669 + return $cacheMgr->getCatColumnInfo($id);
  1670 + }
  1671 +
  1672 + public function editColumn($id, $name, $type, $size){
  1673 + $cacheMgr = new CatalogCacheMgr();
  1674 + return $cacheMgr->editColumn($id,$name, $type,$size);
  1675 + }
1655 1676 }
1656 1677 ?>
... ...
php/classes/CatalogCacheMgr.php
... ... @@ -7,6 +7,7 @@
7 7 class CatalogCacheMgr extends TimeTableCacheMgr
8 8 {
9 9 const DEFAULT_PARAM_ID_PREFIX = 'cat_param_id_';
  10 + const DEFAULT_NEW_PARAM_ID_PREFIX = 'added_param_id_';
10 11 private $isForVisu = FALSE;
11 12  
12 13 function __construct($isForVisu = FALSE) {
... ... @@ -24,7 +25,7 @@ class CatalogCacheMgr extends TimeTableCacheMgr
24 25 $this->cache = new CatalogCacheObject();
25 26 if (!empty($options['nparams'])) {
26 27 for ($i = 0; $i < (int)$options['nparams']; $i++) {
27   - $this->cache->addParameter(CatalogCacheMgr::DEFAULT_PARAM_ID_PREFIX.(string)($i+1), 'column_'.(string)($i+1), 1, 0, "");
  28 + $this->cache->addParameter(CatalogCacheMgr::DEFAULT_PARAM_ID_PREFIX.(string)($i+1), 'column_'.(string)($i+1), 1, 0, "", FALSE);
28 29 }
29 30 }
30 31 else if (!empty($options['parameters'])) {
... ... @@ -43,7 +44,7 @@ class CatalogCacheMgr extends TimeTableCacheMgr
43 44 if (isset($parameter['description'])) {
44 45 $description = $parameter['description'];
45 46 }
46   - $this->cache->addParameter($id, $parameter['name'], intval($parameter['size']), intval($parameter['type']), $description);
  47 + $this->cache->addParameter($id, $parameter['name'], intval($parameter['size']), intval($parameter['type']), $description, FALSE);
47 48 ++$index;
48 49 }
49 50 }
... ... @@ -72,7 +73,7 @@ class CatalogCacheMgr extends TimeTableCacheMgr
72 73 if (isset($parameter['description'])) {
73 74 $description = $parameter['description'];
74 75 }
75   - $this->cache->addParameter($parameter['id'], $parameter['name'], intval($parameter['size']), intval($parameter['type']), $parameter['description']);
  76 + $this->cache->addParameter($parameter['id'], $parameter['name'], intval($parameter['size']), intval($parameter['type']), $parameter['description'], FALSE);
76 77 }
77 78  
78 79 return $result+ array('parameters' => $info['parameters']);
... ... @@ -147,5 +148,42 @@ class CatalogCacheMgr extends TimeTableCacheMgr
147 148  
148 149 return $result + array('parameters' => $parameters_chart);
149 150 }
  151 +
  152 + public function deleteColumn($id){
  153 + if (!$this->loadFromFile())
  154 + return array('success' => false, 'message' => 'Cannot load cache file');
  155 +
  156 + $result = $this->cache->deleteParameter($id);
  157 + if ($result){
  158 + $this->saveToFile();
  159 + }
  160 + return array('success' => $result , 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus(),'parameters' => $this->cache->getParametersInfo());
  161 + }
  162 +
  163 + public function addColumn($id,$name, $type,$size){
  164 + if (!$this->loadFromFile())
  165 + return array('success' => false, 'message' => 'Cannot load cache file');
  166 + $isNew=true;
  167 + $this->cache->addParameter($id,$name, $size, $type, "", $isNew);
  168 + $this->saveToFile();
  169 + return array('success' => true , 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus(),'parameters' => $this->cache->getParametersInfo());
  170 + }
  171 +
  172 + public function getCatColumnInfo($id){
  173 + if (!$this->loadFromFile())
  174 + return array('success' => false, 'message' => 'Cannot load cache file');
  175 +
  176 + return $this->cache->getParameterInfo($id);
  177 + }
  178 +
  179 + public function editColumn($id,$name, $type,$size){
  180 + if (!$this->loadFromFile())
  181 + return array('success' => false, 'message' => 'Cannot load cache file');
  182 +
  183 + $this->cache->editParameter($id,$name, $type, $size);
  184 +
  185 + $this->saveToFile();
  186 + return array('success' => true , 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus(),'parameters' => $this->cache->getParametersInfo());
  187 + }
150 188 }
151 189 ?>
... ...
php/classes/CatalogCacheObject.php
... ... @@ -26,7 +26,7 @@ class CatalogCacheObject extends TimeTableCacheObject
26 26 return $intervalObj;
27 27 }
28 28  
29   - public function addParameter($id, $name, $size, $type, $description)
  29 + public function addParameter($id, $name, $size, $type, $description, $isNew = false)
30 30 {
31 31 $this->parameters[] = array(
32 32 'id' => $id,
... ... @@ -35,12 +35,53 @@ class CatalogCacheObject extends TimeTableCacheObject
35 35 'type' => $type,
36 36 'description' => $description,
37 37 );
  38 + if($isNew){
  39 + $this->isModified = $isNew;
  40 + }
  41 + }
  42 +
  43 + public function deleteParameter($id){
  44 + foreach($this->parameters as $index=>$param){
  45 + if($id == $param['id']){
  46 + unset($this->parameters[$index]);
  47 + $this->parameters = array_values($this->parameters);
  48 + $this->isModified = TRUE;
  49 + return true;
  50 + }
  51 + }
  52 + return false;
  53 + }
  54 +
  55 + public function editParameter($id, $name, $type, $size)
  56 + {
  57 + foreach ($this->parameters as $index=>$param){
  58 + if($id == $param['id']){
  59 + if(isset($name))
  60 + $this->parameters[$index]['name'] = $name;
  61 + if(isset($type))
  62 + $this->parameters[$index]['type'] = $type;
  63 + if(isset($size))
  64 + $this->parameters[$index]['size'] = $size;
  65 + $this->isModified = TRUE;
  66 + return true;
  67 + }
  68 + }
  69 + return false;
38 70 }
39 71  
40 72 public function getParametersInfo() {
41 73 return $this->parameters;
42 74 }
43 75  
  76 + public function getParameterInfo($id){
  77 + foreach ($this->parameters as $index=>$param){
  78 + if($id == $param['id']){
  79 + return $param;
  80 + }
  81 + }
  82 + return false;
  83 + }
  84 +
44 85 public function writeAdditionalHeaderBin($handle)
45 86 {
46 87 //Params Number
... ... @@ -127,7 +168,7 @@ class CatalogCacheObject extends TimeTableCacheObject
127 168 $description .= chr($res['description']);
128 169 }
129 170  
130   - $this->addParameter($id, $name, $size, $type, $description);
  171 + $this->addParameter($id, $name, $size, $type, $description, FALSE);
131 172 }
132 173 return true;
133 174 }
... ...
php/config.php
... ... @@ -198,6 +198,11 @@ $API = array(
198 198 'isSharedObjectNameAlreadyUsed' => array('len'=>1),
199 199 'getRequestByProcessId' => array('len'=>1),
200 200 'parseTemplatedParam' => array('len'=>1),
  201 + // Furkan - New Catalog Options
  202 + 'deleteColumn' => array('len'=> 1),
  203 + 'addColumn' => array('len' => 4),
  204 + 'getCatColumnInfo' => array('len' => 1),
  205 + 'editColumn' => array('len' => 4)
201 206 )
202 207 )
203 208 );
... ...