Commit d547a5599065bf155fd6730e04f32aec20a18a21

Authored by Hacene SI HADJ MOHAND
1 parent 0318dbe6

rm_6903 ok

js/app/models/CatalogNode.js
... ... @@ -39,7 +39,12 @@ Ext.define('amdaModel.CatalogNode', {
39 39 fnId : 'leaf-visu',
40 40 text : 'Visualize '+ this.self.objectName,
41 41 hidden : true
42   - }];
  42 + },{
  43 + fnId : 'leaf-generateTT',
  44 + text : 'Generate Time Table ',
  45 + hidden : true
  46 + }
  47 + ];
43 48  
44 49 return menuItems;
45 50 },
... ... @@ -73,5 +78,25 @@ Ext.define('amdaModel.CatalogNode', {
73 78 module.setLinkedNode(me);
74 79 module.createWindow();
75 80 });
76   - }
  81 + },
  82 + generateTT: function(node){
  83 + var catObj = Ext.create('amdaModel.TimeTable');
  84 + var timeTabNode = Ext.create('amdaModel.TimeTableNode',{leaf : true});
  85 + catObj.set('relatedCatalogId', node.get('id'));
  86 + desc = 'Generated by CDPP/Amda Catalog Module \n';
  87 + if (node.get('description'))
  88 + desc = desc + node.get('description');
  89 + catObj.set('description', desc);
  90 + timeTabNode.set('object',catObj);
  91 + var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID);
  92 + var ttRootNode = explorerTree.getRootNode().findChild('id', 'timeTable-treeRootNode', true);
  93 + amdaModel.InteractiveNode.preloadNodes(ttRootNode.getRootNode(),
  94 + function()
  95 + {
  96 + // edit newNode into Parameter Module with node as contextNode
  97 + timeTabNode.editInModule();
  98 + });
  99 +
  100 +
  101 + }
77 102 });
... ...
js/app/models/TimeTable.js
... ... @@ -121,15 +121,16 @@ Ext.define('amdaModel.TimeTable', {
121 121 extend: 'amdaModel.AmdaObject',
122 122  
123 123 fields : [
124   - {name: 'fromPlugin', type: 'boolean', defaultValue: false},
  124 + {name: 'fromPlugin', type: 'boolean', defaultValue: false},
125 125 {name: 'created', type: 'date'},
126 126 {name: 'description', type: 'string'},
127 127 {name: 'history', type: 'string'},
128 128 {name: 'nbIntervals', type: 'int'},
129 129 {name: 'objName', type: 'string', defaultValue: ""},
130 130 {name: 'objFormat', type: 'string', defaultValue: ""},
131   - {name: 'folderId', type: 'string', defaultValue: ""},
132   - {name: 'cacheToken', type: 'string', defaultValue: ""}
  131 + {name: 'folderId', type: 'string', defaultValue: ""},
  132 + {name: 'cacheToken', type: 'string', defaultValue: ""},
  133 + {name: 'relatedCatalogId', type: 'string', defaultValue: ""}
133 134 ],
134 135  
135 136 /*commit: function(){
... ...
js/app/models/TimeTableNode.js
... ... @@ -111,6 +111,10 @@ Ext.define('amdaModel.TimeTableNode', {
111 111 case 'visu':
112 112 this.visu();
113 113 break;
  114 +
  115 + case 'generateTT':
  116 + this.generateTT(this);
  117 + break;
114 118  
115 119 default:
116 120 break;
... ...
js/app/views/CatalogUI.js
... ... @@ -97,7 +97,24 @@ Ext.define('amdaUI.CatalogUI', {
97 97 this.object.set('nbIntervals',this.TTGrid.getStore().getTotalCount());
98 98 this.formPanel.getForm().findField('nbIntervals').setValue(this.object.get('nbIntervals'));
99 99 },
100   -
  100 + generateTT : function(catId){
  101 + var catObj = Ext.create('amdaModel.TimeTable');
  102 + var timeTabNode = Ext.create('amdaModel.TimeTableNode',{leaf : true});
  103 + catObj.set('relatedCatalogId', catId)
  104 + catObj.set('description', 'Generated by CDPP/Amda Catalog Module \n'+this.object.get('description'));
  105 + timeTabNode.set('object',catObj);
  106 + var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID);
  107 + var ttRootNode = explorerTree.getRootNode().findChild('id', 'timeTable-treeRootNode', true);
  108 + amdaModel.InteractiveNode.preloadNodes(ttRootNode.getRootNode(),
  109 + function()
  110 + {
  111 + // edit newNode into Parameter Module with node as contextNode
  112 + timeTabNode.editInModule();
  113 + });
  114 +
  115 +
  116 +
  117 + },
101 118 onAfterInit: function(result, e)
102 119 {
103 120 var me = this;
... ... @@ -722,7 +739,7 @@ Ext.define('amdaUI.CatalogUI', {
722 739 });
723 740 }
724 741 else {
725   - Ext.Msg.alert('No intervals', 'Your time table is invalid, <br>you must have at least one interval');
  742 + Ext.Msg.alert('No intervals', 'Your catalog is invalid, <br>you must have at least one interval');
726 743 }
727 744 }
728 745 }
... ... @@ -784,7 +801,22 @@ Ext.define(&#39;amdaUI.CatalogUI&#39;, {
784 801 }
785 802 }
786 803 ]
787   - }]
  804 + },
  805 + {
  806 + xtype: 'toolbar',
  807 + dock: 'bottom',
  808 + ui: 'footer',
  809 + items:[{
  810 + xtype: 'button',
  811 + text: 'Generate Time Table',
  812 + scope: this,
  813 + //dock: 'bottom',
  814 + //ui: 'footer',
  815 + handler: function() {
  816 + this.generateTT(this.object.get('id'));
  817 + }
  818 + }]},
  819 + ]
788 820 },
789 821 {
790 822 xtype: 'form',
... ...
js/app/views/TimeTableUI.js
... ... @@ -118,7 +118,11 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
118 118 AmdaAction.initTTCacheFromTmpObject(this.object.get('folderId'), this.object.get('objName'), false, onAfterInit);
119 119 }
120 120 }
121   - else
  121 + else if(this.object.get('relatedCatalogId') != '')
  122 + {
  123 + AmdaAction.initTTCacheFromCatalog(this.object.get('relatedCatalogId'), 'catalog' , onAfterInit);
  124 + }
  125 + else
122 126 {
123 127 var typeTT = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id).linkedNode.data.nodeType;
124 128 if (this.object.get('id') == '')
... ...
php/classes/AmdaAction.php
... ... @@ -1087,6 +1087,14 @@ class AmdaAction
1087 1087 return $cacheMgr->initFromTT($id, $type);
1088 1088 }
1089 1089  
  1090 + public function initTTCacheFromCatalog($id, $type)
  1091 + {
  1092 + $cacheMgr = new TimeTableCacheMgr();
  1093 +
  1094 + return $cacheMgr->initFromCatalog($id, $type);
  1095 + }
  1096 +
  1097 +
1090 1098 public function initForChart($id, $name, $isTmpObject, $type)
1091 1099 {
1092 1100 if ($isTmpObject && $type == 'catalog' && $id == 'cacheCat')
... ...
php/classes/TimeTableCacheMgr.php
1 1 <?php
2   -
3 2 class CacheTools
4 3 {
5 4 public static function iso2stamp($iso) {
... ... @@ -569,6 +568,7 @@ class FilterCacheObject
569 568  
570 569 function __construct() {
571 570 $this->ttMgr = new TimeTableMgr();
  571 + $this->catMgr = new CatalogMgr();
572 572 }
573 573  
574 574 public function initTTCache() {
... ... @@ -604,6 +604,32 @@ class FilterCacheObject
604 604 return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus());
605 605 }
606 606  
  607 + public function initFromCatalog($id, $typeTT) {
  608 + //Create new cache
  609 + $this->cache = new TimeTableCacheObject();
  610 +
  611 + //Load intervals from TT file and add to cache
  612 + $intervals_res = $this->catMgr->loadIntervalsFromTT($id,$typeTT);
  613 +
  614 + if (!$intervals_res['success'])
  615 + return $intervals_res;
  616 +
  617 + foreach ($intervals_res['intervals'] as $interval)
  618 + {
  619 + //Add interval
  620 + $this->cache->addInterval($interval['start'], $interval['stop']);
  621 + }
  622 +
  623 + unset($intervals_res);
  624 +
  625 + //Update cache
  626 + $this->cache->updateIndexes();
  627 +
  628 + //Save cache file
  629 + return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus());
  630 + }
  631 +
  632 +
607 633 public function initFromTmpObject($folderId, $name) {
608 634 //Create new cache
609 635 $this->cache = new TimeTableCacheObject();
... ...
php/config.php
... ... @@ -160,6 +160,7 @@ $API = array(
160 160 'initForChart'=>array('len'=>4),
161 161 'initTTCacheFromTmpObject'=>array('len'=>3),
162 162 'initTTCacheFromUploadedFile'=>array('len'=>3),
  163 + 'initTTCacheFromCatalog'=>array('len'=>2),
163 164 'readTTCacheIntervals'=>array('len'=>1),
164 165 'readIntervalsForChart'=>array('len'=>1),
165 166 'addTTCacheInterval'=>array('len'=>1),
... ...