diff --git a/js/app/controllers/UploadModule.js b/js/app/controllers/UploadModule.js index 8e767bd..b2a5619 100644 --- a/js/app/controllers/UploadModule.js +++ b/js/app/controllers/UploadModule.js @@ -4,56 +4,49 @@ * @class amdaDesktop.UploadModule * @extends amdaDesktop.AmdaModule * @brief Upload Module controller definition - * @author Elena - * @version $Id: UploadModule.js 2124 2014-02-21 14:06:14Z elena $ + * @author Elena */ Ext.define('amdaDesktop.UploadModule', { extend: 'amdaDesktop.AmdaModule', requires: [ - 'amdaUI.UploadUI' - ], - + 'amdaUI.UploadUI' + ], + contentId : 'uploadUI', - - /** - * @cfg {String} window definitions - * @required - */ - + /** + * @cfg {String} window definitions + * @required + */ width: 320, height: 510, - uiType : 'panelTabUpload', + uiType : 'panelTabUpload', helpTitle : 'Help on Upload Module', helpFile : 'uploadHelp', init : function() { - this.launcher = { - text : this.title, - iconCls : this.icon, - handler : this.createWindow, - scope : this + this.launcher = { + text : this.title, + iconCls : this.icon, + handler : this.createWindow, + scope : this }; - }, - - uploadNotification : function(url,format) - { - var me = this; - loadMask.show(); - this.createWindow(function (o) - { - var desktop = myDesktopApp.getDesktop(); - var win = desktop.getWindow(me.id); - if (win) - { - win.items.items[0].forceUpload(url,format); - win.close(); - } - loadMask.hide(); - }); - - } + }, + uploadNotification : function(url,format){ + var me = this; + loadMask.show(); + this.createWindow(function (o) + { + var desktop = myDesktopApp.getDesktop(); + var win = desktop.getWindow(me.id); + if (win){ + win.items.items[0].forceUpload(url,format); + win.close(); + } + loadMask.hide(); + }); + } }); \ No newline at end of file diff --git a/js/app/views/CatalogUI.js b/js/app/views/CatalogUI.js index cab0e19..d8e4c04 100644 --- a/js/app/views/CatalogUI.js +++ b/js/app/views/CatalogUI.js @@ -17,17 +17,14 @@ Ext.define('amdaUI.CatalogUI', { isCatalog : true, - - constructor: function(config) - { + constructor: function(config) { this.init(config); this.callParent(arguments); this.toReconfigure = true; if (this.object) this.loadObject(); }, - setObject : function (object, toReconfigure) - { + setObject : function (object, toReconfigure) { if (toReconfigure) this.toReconfigure = true; // set object @@ -39,8 +36,7 @@ Ext.define('amdaUI.CatalogUI', { /** * set params description into this.object */ - setParamInfo : function(parameters) - { + setParamInfo : function(parameters) { var params = []; Ext.Array.each(parameters, function(item, index) { params[index] = item; @@ -51,54 +47,56 @@ Ext.define('amdaUI.CatalogUI', { /** * update this.object from form - */ - updateObject : function() - { + */ + updateObject : function(){ // get the basic form - var basicForm = this.formPanel.getForm(); - var updateStatus = true; + var basicForm = this.formPanel.getForm(); + var updateStatus = true; - var fieldsWithoutName = basicForm.getFields().items; - Ext.Array.each(fieldsWithoutName, function(item, index,allItems){ - if(item !== this.fieldName) { - if (!item.isValid()) { - // set update isn't allowed - updateStatus = false; - } - } - }, this); - // if the update is allowed - if (updateStatus) { - /// real object update - // update TimeTable object with the content of form - basicForm.updateRecord(this.object); - } - // return the update status - return updateStatus; + var fieldsWithoutName = basicForm.getFields().items; + Ext.Array.each(fieldsWithoutName, function(item, index,allItems){ + if(item !== this.fieldName) { + if (!item.isValid()) { + // set update isn't allowed + updateStatus = false; + } + } + }, this); + // if the update is allowed + if (updateStatus) { + /// real object update + // update TimeTable object with the content of form + basicForm.updateRecord(this.object); + } + // return the update status + return updateStatus; }, - - updateCount : function() - { + updateCount : function() { this.object.set('nbIntervals',this.TTGrid.getStore().getTotalCount()); this.formPanel.getForm().findField('nbIntervals').setValue(this.object.get('nbIntervals')); - }, - - + }, - onAfterInit: function(result, e) { - + onAfterInit: function(result, e) + { var me = this; - - if (!result || !result.success) + if (!result) { + myDesktopApp.errorMsg(e.message); + Ext.defer(function(){Ext.Msg.toFront()},10); + + return; + } + else if (!result.success) { if (result.message) myDesktopApp.errorMsg(result.message); else myDesktopApp.errorMsg('Unknown error during catalog cache initialisation'); + + Ext.defer(function(){Ext.Msg.toFront()},10); return; } - + if (me.toReconfigure) { var fields = [], columns = [], i = 3, width, index; @@ -121,7 +119,7 @@ Ext.define('amdaUI.CatalogUI', { { index = 'param'+(i-1).toString(); fields[i+2] = Ext.create('Ext.data.Field',{ name : index }); - + if (obj.type == 1) // dateTime { columns[i] = Ext.create('Ext.grid.column.Column', { text: obj.name, sortable : false, dataIndex: index, @@ -135,9 +133,7 @@ Ext.define('amdaUI.CatalogUI', { } i++; }); - - - + var store = Ext.create('Ext.data.Store', { fields: fields, autoDestroy: false, @@ -147,10 +143,7 @@ Ext.define('amdaUI.CatalogUI', { remoteSort: true, proxy: { type: 'direct', - api : - { - read : AmdaAction.readTTCacheIntervals - }, + api : { read : AmdaAction.readTTCacheIntervals }, // remplir automatiquement tt, sharedtt , catalog, shared catalog extraParams : {'typeTT' : 'catalog'}, reader: @@ -164,9 +157,9 @@ Ext.define('amdaUI.CatalogUI', { scope : me, load: function(store,records) { // myDesktopApp.EventManager.fireEvent('refresh'); - me.TTGrid.getView().refresh(); - me.TTGrid.getSelectionModel().refresh(); - me.updateCount(); + me.TTGrid.getView().refresh(); + me.TTGrid.getSelectionModel().refresh(); + me.updateCount(); //Statistical plugin // this.fireEvent("refresh"); } @@ -184,7 +177,7 @@ Ext.define('amdaUI.CatalogUI', { // me.TTGrid.getStore().sorters.clear(); // //me.TTGrid.getStore().sorters = new Ext.util.MixedCollection(); - //set cache token to the Catalog object + //set cache token to the Catalog object me.object.set('cacheToken', result.token); me.setParamInfo(result.parameters); @@ -196,35 +189,28 @@ Ext.define('amdaUI.CatalogUI', { /** * load object catalog into this view */ - loadObject : function() - { + loadObject : function(){ // load object into form this.formPanel.getForm().loadRecord(this.object); this.status = null; - if (this.object.get('fromPlugin')) - { - if (this.object.get('objFormat') && this.object.get('objFormat') != '') - { + if (this.object.get('fromPlugin')){ + if (this.object.get('objFormat') && this.object.get('objFormat') != ''){ //From uploaded file AmdaAction.initTTCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), this.isCatalog, this.onAfterInit, this); } - else - { + else { //From tmp object (ie Statistics result) AmdaAction.initTTCacheFromTmpObject(this.object.get('folderId'), this.object.get('objName'), this.isCatalog, this.onAfterInit, this); } } - else - { + else { var typeTT = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id).linkedNode.data.nodeType; - if (this.object.get('id') == '') - { - + if (this.object.get('id') == '') { + //TODO ? } - else - { + else { //From existing TT file AmdaAction.initTTCacheFromTT(this.object.get('id'), typeTT, this.onAfterInit, this); } @@ -244,8 +230,7 @@ Ext.define('amdaUI.CatalogUI', { // store / columns are the same - not needed to reconfigure grid this.toReconfigure = false; // if the name has been modified this is a creation - if (this.fclose()) - { + if (this.fclose()) { if (this.object.isModified('name') || this.object.get('fromPlugin')) { // if object already has an id : it's a 'rename' of an existing if (this.object.get('id')){ @@ -267,16 +252,14 @@ Ext.define('amdaUI.CatalogUI', { } else { //update module.linkedNode.update(); - } - + } } }, /** * overwrite metod called by Save button */ - overwriteProcess : function(btn) - { + overwriteProcess : function(btn) { if (btn == 'cancel') return; this.fieldName.clearInvalid(); @@ -288,13 +271,12 @@ Ext.define('amdaUI.CatalogUI', { * Check if changes were made before closing window * @return true if changes */ - fclose : function() - { + fclose : function() { if (this.status == null) return false; var isDirty = this.formPanel.getForm().isDirty() || (this.status.isModified) || (this.status.nbModified > 0) || (this.status.nbNew > 0); - return isDirty; + return isDirty; }, init : function (config) @@ -310,9 +292,9 @@ Ext.define('amdaUI.CatalogUI', { validateOnChange: false, validateOnBlur: false, validFlag: false, - validator : function() { - return this.validFlag; - } + validator : function() { + return this.validFlag; + } }); var cellEditing = Ext.create('Ext.grid.plugin.CellEditing',{ @@ -348,8 +330,7 @@ Ext.define('amdaUI.CatalogUI', { //Interval is modified on the server side me.editing = true; - AmdaAction.modifyTTCacheInterval(obj, function (result, e) { - + AmdaAction.modifyTTCacheInterval(obj, function (result, e) { var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id); if (module) module.getUiContent().status = result.status; @@ -365,7 +346,7 @@ Ext.define('amdaUI.CatalogUI', { }, this); } else - me.editing = false; + me.editing = false; } } }); @@ -375,85 +356,81 @@ Ext.define('amdaUI.CatalogUI', { columns: [ ], frame: true, columnLines: true, - // selType: 'cellmodel', + // selType: 'cellmodel', plugins: [ cellEditing, { ptype : 'bufferedrenderer'} ], dockedItems: [{ xtype: 'toolbar', items: [{ - iconCls: 'icon-add', - scope: this, - handler: function(){ - - cellEditing.cancelEdit(); - var store = this.TTGrid.getStore(); - - var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0]; - var row = 0; - if (selection) - row = store.indexOf(selection) + 1; - this.TTGrid.getSelectionModel().deselectAll(); - - var me = this; - AmdaAction.addTTCacheInterval({'index' : row, 'isCatalog' : true}, function (result, e) { - this.status = result.status; - this.TTGrid.getStore().reload({ - callback : function(records, options, success) { - me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function() { - me.TTGrid.getView().select(row); - cellEditing.startEditByPosition({row: row, column: 1}); - }, me); - } - }); - }, this); - } - },{ - iconCls: 'icon-delete', - disabled: true, - itemId: 'delete', - scope: this, - handler: function(){ - var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0]; - if (selection) - { - var rowId = selection.get('cacheId'); + iconCls: 'icon-add', + scope: this, + handler: function(){ + cellEditing.cancelEdit(); + var store = this.TTGrid.getStore(); + + var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0]; + var row = 0; + if (selection) + row = store.indexOf(selection) + 1; this.TTGrid.getSelectionModel().deselectAll(); - AmdaAction.removeTTCacheIntervalFromId(rowId, this.isCatalog, function (result, e) { + + var me = this; + AmdaAction.addTTCacheInterval({'index' : row, 'isCatalog' : true}, function (result, e) { this.status = result.status; - this.TTGrid.getStore().reload(); + this.TTGrid.getStore().reload({ + callback : function(records, options, success) { + me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function() { + me.TTGrid.getView().select(row); + cellEditing.startEditByPosition({row: row, column: 1}); + }, me); + } + }); }, this); } - } + },{ + iconCls: 'icon-delete', + disabled: true, + itemId: 'delete', + scope: this, + handler: function(){ + var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0]; + if (selection) + { + var rowId = selection.get('cacheId'); + this.TTGrid.getSelectionModel().deselectAll(); + AmdaAction.removeTTCacheIntervalFromId(rowId, this.isCatalog, function (result, e) { + this.status = result.status; + this.TTGrid.getStore().reload(); + }, this); + } + } }] }] }); - this.formPanel = Ext.create('Ext.form.Panel', - { + this.formPanel = Ext.create('Ext.form.Panel', { region : 'center', layout: 'hbox', bodyStyle: {background : '#dfe8f6'}, defaults: { border : false, align: 'stretch', bodyStyle: {background : '#dfe8f6'}, padding: '3'}, fieldDefaults: { labelWidth: 80, labelAlign : 'top' }, - items: [ - { + items: [{ xtype: 'form', flex: 1, buttonAlign: 'left', - // title : 'Information', + // title : 'Information', layout: {type: 'vbox', pack: 'start', align: 'stretch'}, items : [ this.fieldName, { xtype: 'fieldcontainer', layout: 'hbox', - items: [ - { + items: [{ xtype:'datefield', fieldLabel:'Creation date', name: 'created', disabled: true, hideTrigger: true, format: 'Y/m/d H:i:s' }, { xtype: 'splitter' }, - { xtype:'textfield', fieldLabel: 'Intervals', name: 'nbIntervals', disabled: true} + { xtype:'textfield', fieldLabel: 'Intervals', name: 'nbIntervals', disabled: true } ] }, { @@ -466,13 +443,11 @@ Ext.define('amdaUI.CatalogUI', { xtype: 'component', height: 180 }], - dockedItems:[ - { + dockedItems:[{ xtype: 'toolbar', dock: 'bottom', ui: 'footer', - items: [ - { + items: [{ type: 'button', text: 'Create New Catalog', scope : this, @@ -484,7 +459,8 @@ Ext.define('amdaUI.CatalogUI', { var obj = module.linkedNode.get('object'); if (obj && obj.get('id') == '' && !obj.get('fromPlugin')) { - var me = this + var me = this; + Ext.Msg.prompt('Define Parameters', 'Please enter parameters number:', function(btn, text){ if (btn == 'ok'){ AmdaAction.initTTCache(me.isCatalog, text, me.onAfterInit, me); @@ -515,28 +491,23 @@ Ext.define('amdaUI.CatalogUI', { basicForm.updateRecord(this.object); var me = this; - this.checkIntervalsStatusForSave(function () - { + this.checkIntervalsStatusForSave(function () { //Name validation var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id); if (!module) return; module.linkedNode.isValidName(me.fieldName.getValue(), function (res) { - if (!res) - { + if (!res) { me.fieldName.validFlag = 'Error during object validation'; myDesktopApp.errorMsg(me.fieldName.validFlag); me.fieldName.validate(); return; } - if (!res.valid) - { - if (res.error) - { - if (res.error.search('subtree') != -1) - { + if (!res.valid) { + if (res.error) { + if (res.error.search('subtree') != -1) { Ext.MessageBox.show({title:'Warning', msg: res.error+'<br/>Do you want to overwrite it?', width: 300, @@ -550,8 +521,7 @@ Ext.define('amdaUI.CatalogUI', { else me.fieldName.validFlag = res.error; } - else - { + else { me.fieldName.validFlag = 'Invalid object name'; myDesktopApp.errorMsg(me.fieldName.validFlag); } @@ -565,20 +535,17 @@ Ext.define('amdaUI.CatalogUI', { }); }); } - else - { + else { Ext.Msg.alert('No intervals', 'Your time table is invalid, <br>you must have at least one interval'); } } } - }, - { + },{ type: 'button', text: 'Reset', scope : this, disabled: true, - handler: function() - { + handler: function() { // var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id); // module.createLinkedNode(); // module.createObject(); @@ -594,24 +561,20 @@ Ext.define('amdaUI.CatalogUI', { type: 'button', text: 'Visualize', scope: this, - handler: function() - { + handler: function() { var me = this; - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) - { + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) { //temporary linked node - as Visu module is 'pseudo' interactive - no 'save', no 'execute' - var temporaryNode = Ext.create('amdaModel.CatalogNode', { - leaf : true - }); + var temporaryNode = Ext.create('amdaModel.CatalogNode', { leaf : true }); if (temporaryNode) temporaryNode.set('object',me.object); module.setLinkedNode(temporaryNode); - module.createWindow(); + module.createWindow(); }); } - }] + }] }] }, { @@ -619,19 +582,15 @@ Ext.define('amdaUI.CatalogUI', { bodyStyle: {background : '#dfe8f6'}, //padding: '3', flex: 2, - items : [ - this.TTGrid - ] + items : [ this.TTGrid ] }] }); - this.TTGrid.getSelectionModel().on('selectionchange', function(selModel,selections) - { + this.TTGrid.getSelectionModel().on('selectionchange', function(selModel,selections) { this.TTGrid.down('#delete').setDisabled(selections.length === 0); }, this); - var myConf = - { + var myConf = { layout: 'border', items: [ this.formPanel, @@ -651,9 +610,7 @@ Ext.define('amdaUI.CatalogUI', { } } ] - }; - + }; Ext.apply (this, Ext.apply(arguments, myConf)); - } - + } }); diff --git a/php/api.php b/php/api.php index ba627f6..057b454 100644 --- a/php/api.php +++ b/php/api.php @@ -1,36 +1,35 @@ <?php - require('config.php'); - header('Content-Type: text/javascript'); + require('config.php'); + header('Content-Type: text/javascript'); - $actions = array(); - foreach($API as $aname => &$a){ - $methods = array(); - foreach($a['methods'] as $mname => &$m){ - $md = array( - 'name'=>$mname, - 'len'=>$m['len'] - ); - if(isset($m['formHandler']) && $m['formHandler']){ - $md['formHandler'] = true; - } - $methods[] = $md; + $actions = array(); + foreach($API as $aname => &$a){ + $methods = array(); + foreach($a['methods'] as $mname => &$m){ + $md = array( + 'name'=>$mname, + 'len'=>$m['len'] + ); + if(isset($m['formHandler']) && $m['formHandler']){ + $md['formHandler'] = true; + } + $methods[] = $md; + } + $actions[$aname] = $methods; } - $actions[$aname] = $methods; - } - $cfg = array( - 'url'=>'php/router.php', - 'type'=>'remoting', - 'id' => 'amda-provider', - 'maxRetries' => 0, - 'actions'=>$actions - ); + $cfg = array( + 'url'=>'php/router.php', + 'type'=>'remoting', + 'id' => 'amda-provider', + 'maxRetries' => 0, + 'actions'=>$actions + ); - echo 'Ext.app.REMOTING_API = '; - - echo json_encode($cfg); - echo ';'; + echo 'Ext.app.REMOTING_API = '; + echo json_encode($cfg); + echo ';'; ?> -- libgit2 0.21.2