diff --git a/generic_data/defaultValues.json b/generic_data/defaultValues.json new file mode 100644 index 0000000..79669cf --- /dev/null +++ b/generic_data/defaultValues.json @@ -0,0 +1,195 @@ +{ + "plot":{ + "file":{ + "format":"PNG", + "output":"INTERACTIVE", + "oneFilePerInterval":false + }, + "tree":{ + "fullView":false + }, + "page":{ + "xMargin":5, + "yMargin":5, + "mode":"color", + "orientation":"landscape", + "dimension":"ISO A4", + "title":{ + "position":"top", + "alignment":" center", + "color":"#000000" + }, + "font":{ + "name":"sans-serif", + "size":"8" + }, + "layout":{ + "type":"vertical", + "panelHeight":0.5, + "panelSpacing":0, + "expand":false, + "timeAxesLegend":true + } + }, + "panel":{ + "plotType":"timePlot", + "isotropic":false, + "title":{ + "position":"top", + "alignment":" center", + "color":"#000000" + }, + "font":{ + "name":"sans-serif", + "size":"8" + }, + "backgroundColor":"none", + "status":{ + "position":"top", + "colorMap":0 + } + }, + "axis":{ + "scale":"linear", + "tickPosition":"outwards", + "color":"#000000", + "thickness":"1", + "legend":{ + "color":"#000000", + "font":{ + "name":"sans-serif", + "size":"8" + } + }, + "timeFormat":"dd/mm/yy", + "colorMap":"1" + }, + "serie":{ + "yAxis":"y-left", + "resolution":3000, + "lines":{ + "style":"plain", + "width":1, + "color":"auto" + }, + "symbols":{ + "type":"dot", + "size":3, + "color":"auto" + }, + "resamplingMode":"xparam", + "timetick":{ + "type":"auto", + "step":3600, + "nbmajor":5, + "nbminor":5, + "color":"#FF0000", + "symbols":{ + "type":"full-circle", + "size":10, + "color":"#FF0000" + }, + "firstsymbols":{ + "type":"triangle", + "size":4, + "color":"#00FF00" + }, + "font":{ + "name":"sans-serif", + "size":"8" + } + }, + "intervaltick":{ + "mode":"start-time", + "color":"#FF0000", + "symbols":{ + "type":"full-circle", + "size":10, + "color":"#FF0000" + }, + "font":{ + "name":"sans-serif", + "size":"8" + } + }, + "errorbar":{ + "type":"min-max", + "lines":{ + "style":"plain", + "width":1, + "color":"auto" + } + }, + "projection":"XY" + }, + "spectro":{ + "yAxis":"y-left", + "resolution":3000 + }, + "histogram2D":{ + "histo2DFunction":"density", + "xbinnumber":100, + "ybinnumber":100, + "smoothfactor":1 + }, + "sauvaud":{ + "yAxis":"y-right", + "resolution":3000 + }, + "intervals":{ + "color":"#FF0000" + }, + "statusbar":{ + "color":"#FF0000" + }, + "legends":{ + "series":{ + "type":"text-only", + "position":"outside", + "text":{ + "color":"#000000" + }, + "border":{"color":"#000000"}, + "intervalinfo":{"type":"start-stop"}, + "font":{"name":"sans-serif","size":"8"} + }, + "text":{ + "position":"left", + "color":"#000000", + "font":{ + "name":"sans-serif", + "size":"8" + } + } + }, + "constants":{ + "axisId":"y-left", + "line":{ + "style":"plain", + "width":1, + "color":"#000000" + } + }, + "textObjs":{ + "yAxisId":"y-left", + "xRelative":true, + "yRelative":true, + "align":"left", + "color":"#000000", + "font":{"name":"sans-serif","size":"8"} + }, + "curves":{ + "line":{ + "style":"plain", + "width":1, + "color":"#000000" + } + }, + "fills":{ + "type":"serie-constant", + "greaterColor":"none", + "lessColor":"none" + }, + "filtering":{"level":1} + } +} \ No newline at end of file diff --git a/js/app/AmdaApp.js b/js/app/AmdaApp.js index 0e6c83b..2c44792 100755 --- a/js/app/AmdaApp.js +++ b/js/app/AmdaApp.js @@ -13,6 +13,7 @@ Ext.define('amdaApp.AmdaApp', { requires: [ 'Ext.window.MessageBox', 'Ext.ux.desktop.ShortcutModel', + 'amdaUI.DefaultValuesWindow', 'amdaUI.SampToolBarUI', 'amdaDesktop.DynamicModule', 'MyDesktop.Settings' @@ -417,8 +418,12 @@ Ext.define('amdaApp.AmdaApp', { { text : 'Workspaces', iconCls : 'icon-ws', - disabled: true, - scope : this + disabled: false, + scope : this, + handler:function(obj, e){ + e.stopEvent(); + Ext.create('amdaUI.DefaultValuesWindow').show(); + } }, '-', { text : 'Logout', diff --git a/js/app/models/DefaultValues.js b/js/app/models/DefaultValues.js new file mode 100644 index 0000000..2ee6765 --- /dev/null +++ b/js/app/models/DefaultValues.js @@ -0,0 +1,44 @@ +Ext.define('amdaModel.DefaultValues', { + singleton: true, + type:null, + userValues:'', + + constructor: function() { + this.getDefaultValues(); + }, + + getDefaultValues: function(){ + var me = this; + + Ext.Ajax.request({ + url: 'generic_data/defaultValues.json', + method: 'GET', + success: function(response) { + me.values = Ext.decode(response.responseText); + + // after reading generic default values, we read user defaults. + Ext.Ajax.request({ + url: 'data/'+ sessionID +'/userDefaults.json', + method: 'GET', + success: function(response) { + me.userValues = Ext.decode(response.responseText); + Ext.Object.each(me.userValues, function(key,value){ + var keys = key.split('_'); + var obj = me.values; + for (var i = 0; i < keys.length - 1; i++) { + obj = obj[keys[i]]; + } + obj[keys[keys.length - 1]] = value; + }) + }, + failure:function(){ + // Maybe create the file ? + } + }); + }, + failure: function(response) { + console.error('Failed to load default values', response); + } + }); + }, +}); \ No newline at end of file diff --git a/js/app/models/DefaultValuesModel.js b/js/app/models/DefaultValuesModel.js new file mode 100644 index 0000000..b34a222 --- /dev/null +++ b/js/app/models/DefaultValuesModel.js @@ -0,0 +1,10 @@ +Ext.define('amdaModel.DefaultValuesModel', { + extend: 'Ext.data.TreeModel', + fields: [{ + name: 'parameter', + type: 'string' + }, { + name: 'value', + type: 'string' + }] +}); \ No newline at end of file diff --git a/js/app/models/PlotObjects/PlotObjectConfig.js b/js/app/models/PlotObjects/PlotObjectConfig.js index 6dc0f86..1a9d29d 100644 --- a/js/app/models/PlotObjects/PlotObjectConfig.js +++ b/js/app/models/PlotObjects/PlotObjectConfig.js @@ -15,213 +15,13 @@ Ext.define('amdaPlotObj.PlotObjectConfig', { singleton: true, + requires:['amdaModel.DefaultValues'], - defaultValues: { - file: { - format: 'PNG', - output: 'INTERACTIVE', - oneFilePerInterval: false - }, - tree: { - fullView: false - }, - page: { - xMargin: 5., - yMargin: 5., - mode: 'color', - orientation: 'landscape', - dimension: 'ISO A4', - title: { - position: 'top', - alignment: ' center', - color: '#000000' - }, - font: { - name: 'sans-serif', - size: '8' - }, - layout: { - type: 'vertical', - panelHeight: 0.5, - panelSpacing: 0., - expand: false, - timeAxesLegend: true - } - }, - panel: { - plotType: 'timePlot', - isotropic: false, - title: { - position: 'top', - alignment: ' center', - color: '#000000' - }, - font: { - name: 'sans-serif', - size: '8' - }, - backgroundColor: 'none', - status: { - position: 'top', - colorMap: 0 - } - }, - axis: { - scale: 'linear', - tickPosition: 'outwards', - color: '#000000', - thickness: '1', - legend: { - color: '#000000', - font: { - name: 'sans-serif', - size: '8' - } - }, - timeFormat: 'dd/mm/yy', - colorMap: '1' - }, - serie: { - yAxis: 'y-left', - resolution: 3000, - lines: { - style: 'plain', - width: 1, - color: 'auto' - }, - symbols: { - type: 'dot', - size: 3, - color: 'auto' - }, - resamplingMode: 'xparam', - timetick: { - type: 'auto', - step: 3600, - nbmajor: 5, - nbminor: 5, - color: '#FF0000', - symbols: { - type: 'full-circle', - size: 10, - color: '#FF0000' - }, - firstsymbols: { - type: 'triangle', - size: 4, - color: '#00FF00' - }, - font: { - name: 'sans-serif', - size: '8' - } - }, - intervaltick: { - mode: 'start-time', - color: '#FF0000', - symbols: { - type: 'full-circle', - size: 10, - color: '#FF0000' - }, - font: { - name: 'sans-serif', - size: '8' - } - }, - errorbar: { - type: 'min-max', - lines: { - style: 'plain', - width: 1, - color: 'auto' - } - }, - projection: 'XY', - }, - spectro: { - yAxis: 'y-left', - resolution: 3000 - }, - histogram2D:{ - histo2DFunction: 'density', - xbinnumber: 100, - ybinnumber: 100, - smoothfactor: 1, - }, - sauvaud: { - yAxis: 'y-right', - resolution: 3000 - }, - intervals: { - color: "#FF0000" - }, - statusbar: { - color: "#FF0000" - }, - legends: { - series: { - type: 'text-only', - position: 'outside', - text: { - color: '#000000' - }, - border: { - color: '#000000' - }, - intervalinfo: { - type: 'start-stop' - }, - font: { - name: 'sans-serif', - size: '8' - } - }, - text: { - position: 'left', - color: '#000000', - font: { - name: 'sans-serif', - size: '8' - } - } - }, - constants: { - axisId: 'y-left', - line: { - style: 'plain', - width: 1, - color: '#000000' - } - }, - textObjs: { - yAxisId: 'y-left', - xRelative: true, - yRelative: true, - align: 'left', - color: '#000000', - font: { - name: 'sans-serif', - size: '8' - } - }, - curves: { - line: { - style: 'plain', - width: 1, - color: '#000000' - } - }, - fills: { - type: 'serie-constant', - greaterColor: 'none', - lessColor: 'none' - }, - filtering: { - level: 1 - } + defaultValues: null, + + constructor: function(){ + this.defaultValues = amdaModel.DefaultValues.values.plot; }, - getValueByKey: function (dataList, key) { var value = ''; Ext.each(dataList, function (data) { diff --git a/js/app/models/PlotObjects/PlotSauvaudObject.js b/js/app/models/PlotObjects/PlotSauvaudObject.js index 92fa79d..15ee4a9 100644 --- a/js/app/models/PlotObjects/PlotSauvaudObject.js +++ b/js/app/models/PlotObjects/PlotSauvaudObject.js @@ -32,10 +32,10 @@ Ext.define('amdaPlotObj.PlotSauvaudObject', { { name: 'filtering-level', type: 'int' }, { name: 'right_dim', type: 'int' }, - { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.name, type: 'boolean' }, - { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.type.key, type: 'string' }, - { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.value.key, type: 'string' }, - { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimkey, type: 'string' } + // { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.name, type: 'boolean' }, + // { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.type.key, type: 'string' }, + // { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.value.key, type: 'string' }, + // { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimkey, type: 'string' } ], constructor: function () { diff --git a/js/app/models/PlotObjects/PlotSpectroObject.js b/js/app/models/PlotObjects/PlotSpectroObject.js index 3b76bc7..4bd0a60 100644 --- a/js/app/models/PlotObjects/PlotSpectroObject.js +++ b/js/app/models/PlotObjects/PlotSpectroObject.js @@ -31,10 +31,10 @@ Ext.define('amdaPlotObj.PlotSpectroObject', { { name: 'filtering-activated', type: 'boolean' }, { name: 'filtering-level', type: 'int' }, - { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.name, type: 'boolean' }, - { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.type.key, type: 'string' }, - { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.value.key, type: 'string' }, - { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimkey, type: 'string' } + // { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.name, type: 'boolean' }, + // { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.type.key, type: 'string' }, + // { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.value.key, type: 'string' }, + // { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimkey, type: 'string' } ], constructor: function () { diff --git a/js/app/views/DefaultTreeGrid.js b/js/app/views/DefaultTreeGrid.js new file mode 100644 index 0000000..e9824c4 --- /dev/null +++ b/js/app/views/DefaultTreeGrid.js @@ -0,0 +1,191 @@ +Ext.define('StatusColorPicker', { + extend: 'Ext.form.field.Picker', + alias: 'widget.statuscolorpicker', + availableColorsNew: [ + "#000000", "#0000ff", "#ff0000", "#00ffff", "#ff00ff", "#008000", "#800000", + "#000080", "#808000", "#800080", "#c0c0c0", "#008080", "#ffff00", "#004040", + "#29d8d7", "#6b9842", "#73a9b4", "#1c883d", "#808080", "#4342dd", "#e84130", + "#dee2e6", "#ced4da", "#adb5bd", "#868e96", "#495057", "#343a40", "#212529", + "#ffa8a8", "#ff8787", "#ff6b6b", "#fa5252", "#f03e3e", "#e03131", "#c92a2a", + "#faa2c1", "#f783ac", "#f06595", "#e64980", "#d6336c", "#c2255c", "#a61e4d", + "#e599f7", "#da77f2", "#cc5de8", "#be4bdb", "#ae3ec9", "#9c36b5", "#862e9c", + "#b197fc", "#9775fa", "#845ef7", "#7950f2", "#7048e8", "#6741d9", "#5f3dc4", + "#91a7ff", "#748ffc", "#5c7cfa", "#4c6ef5", "#4263eb", "#3b5bdb", "#364fc7", + "#74c0fc", "#4dabf7", "#339af0", "#228be6", "#1c7ed6", "#1971c2", "#1864ab", + "#66d9e8", "#3bc9db", "#22b8cf", "#15aabf", "#1098ad", "#0c8599", "#0b7285", + "#63e6be", "#38d9a9", "#20c997", "#12b886", "#0ca678", "#099268", "#087f5b", + "#8ce99a", "#69db7c", "#51cf66", "#40c057", "#37b24d", "#2f9e44", "#2b8a3e", + "#c0eb75", "#a9e34b", "#94d82d", "#82c91e", "#74b816", "#66a80f", "#5c940d", + "#ffe066", "#ffd43b", "#fcc419", "#fab005", "#f59f00", "#f08c00", "#e67700", + "#ffc078", "#ffa94d", "#ff922b", "#fd7e14", "#f76707", "#e8590c", "#d9480f" + ], + toUpper : function(x){ + return x.toUpperCase(); + }, + replaceColor : function(x){ + return x.replace("#",""); + }, + createPicker: function() { + var me = this; + return Ext.create('Ext.picker.Color', { + pickerField: me, + renderTo: Ext.getBody(), + floating: true, + minWidth: 133, + maxWidth: 200, + minHeight: 225, + autoScroll:true, + focusOnShow: true, + colors: this.availableColorsNew.map(this.replaceColor).map(this.toUpper), + listeners: { + select: function(picker, color) { + me.setValue('#'+color); + me.picker.hide(); + }, + scope: me + } + }); + } +}); + +Ext.define('amdaUI.DefaultTreeGrid', { + extend: 'Ext.tree.Panel', + + requires: [ + 'Ext.data.*', + 'Ext.grid.*', + 'Ext.tree.*', + 'amdaModel.DefaultValuesModel', + 'StatusColorPicker' + ], + xtype: 'tree-grid', + + reserveScrollbar: true, + + height: 300, + useArrows: true, + rootVisible: false, + multiSelect: true, + singleExpand: true, + + constructor: function() { + this.init(); + this.callParent(); + }, + + isHexCode: function(str) { + return /^#[0-9a-fA-F]{6}$/.test(str); + }, + init: function() { + var me = this; + me.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {clicksToEdit: 1, + listeners:{ + beforeedit:function(editor, context,e){ + if(!context.record.data.leaf) + { + return false; + } + var value = context.record.get(context.field); + if (me.isHexCode(value)) { + var colorPicker = Ext.create('StatusColorPicker', { + pickerField: context.field, + value: value, + listeners: { + select: function(picker, color) { + context.record.set(context.field, '#' + color); + me.getView().refresh(); + } + } + }); + editor.field = colorPicker; + } + } + } + }); + + AmdaAction.getDefaultValueTree(function(res,e) { + console.log(res); + }); + + Ext.apply(this, { + store: new Ext.data.TreeStore({ + model: amdaModel.DefaultValuesModel, + proxy: { + type: 'direct', + directFn: AmdaAction.getDefaultValueTree + }, + folderSort: true + }), + plugins: [me.cellEditing], + columns: [{ + xtype: 'treecolumn', //this is so we know which column will show the tree + text: 'Parameters', + flex: 2, + sortable: true, + dataIndex: 'parameter' + },{ + xtype: 'gridcolumn', + getEditor: function(record) { + var grid = this.up().grid, + cellediting = grid.findPlugin('cellediting'), + editors = cellediting.editors, + editor = editors.getByKey(this.id), + fieldType; + + if (editor) { + // Do this to avoid memory leaks + editors.remove(editor); + } + value = record.get('value'); + if(me.isHexCode(value)){ + fieldType = 'statuscolorpicker' + } + else if(value === 'true' || value == 'false'){ + fieldType = 'combobox' + } + else{ + fieldType = isNaN(parseFloat(record.get('value'))) ? 'textfield' : 'numberfield'; + } + return { + xtype: fieldType, + store: (fieldType=='combobox') ? [[true, 'true'], [false, 'false']] : null, + editable: false, + value: (fieldType=='combobox') ? value : null, + allowBlank: false + }; + }, + text: 'Values', + flex: 1, + sortable: true, + dataIndex: 'value', + align: 'center', + renderer: function(value, meta) { + if (me.isHexCode(value)){ + value = value.substring(1, 7); + return '<div style="background-color:#' + value + '; margin-left: auto; \ + margin-right: auto;width:15px;height:15px;"></div>'; + } + else{ + return value; + } + }, + },{ + text: 'Reset', + width: 55, + menuDisabled: true, + xtype: 'actioncolumn', + tooltip: 'Reset to the default value', + align: 'center', + icon: 'js/resources/images/16x16/arrow_circle_double.png', + handler: function(grid, rowIndex, colIndex, actionItem, event, record, row) { + Ext.Msg.alert('Editing' + record.get('parameter')); + }, + // Only leaf level tasks may be edited + isDisabled: function(view, rowIdx, colIdx, item, record) { + return !record.data.leaf; + } + } + ] + }); + } +}); diff --git a/js/app/views/DefaultValuesWindow.js b/js/app/views/DefaultValuesWindow.js new file mode 100644 index 0000000..99d29d3 --- /dev/null +++ b/js/app/views/DefaultValuesWindow.js @@ -0,0 +1,93 @@ + + +Ext.define('amdaUI.DefaultValuesWindow',{ + extend: 'Ext.window.Window', + alias: 'widget.defaultvalueswindow', + + requires:[ + 'amdaUI.DefaultTreeGrid', + ], + defaultValuesGrid: null, + constructor:function(){ + this.defaultValuesGrid = Ext.create('amdaUI.DefaultTreeGrid'); + this.init(); + this.callParent(); + }, + + init:function(config){ + + var me=this; + Ext.apply(this, { + title: 'Default Values Grid', + width: 350, + height: 380, + closable:false, + modal:true, + resizable: false, + items: [ + { + xtype: 'form', + renderTo: Ext.getBody(), + layout:'hbox', + frame: false, + items: [ + { + flex:1, + items:[me.defaultValuesGrid], + }, + ], + + buttons: [{ + text: 'Save', + handler: function() { + + // Check to be sure that max > min + + // if(config.type != "cat"){ + // var records = me.statusGrid.store.getRange(); + // for (var i = 0; i < records.length; i++) { + // var record = records[i]; + // if (record.get('maxVal') < record.get('minVal')) { + // invalidRecord = record; + // break; + // } + // } + // if (invalidRecord) { + // Ext.Msg.alert('Error', 'Max value must be greater than Min value', function() { + // me.statusGrid.cellEditing.startEditByPosition({row: invalidRecord, column: 0}); + // invalidRecord = null; + // }); + // return; + // } + // } + + // // Saving part + + // config.object.set('status',me.statusGrid.getStatusString()); + // me.statusGrid.clearStore(); + // me.close(); + }, + }, + { + // to reset the form + text: 'Reset', + handler: function() { + // me.statusGrid.clearStore(); + // me.statusGrid.parseStatus(config.status); + } + }, + { + // To quit the window + text: 'Cancel', + handler: function() { + // me.statusGrid.clearStore(); + // me.statusGrid.destroy(); + me.close(); + } + }] + } + ] + }); + } +}); + diff --git a/php/classes/AmdaAction.php b/php/classes/AmdaAction.php index f0fe36d..d6bfb76 100644 --- a/php/classes/AmdaAction.php +++ b/php/classes/AmdaAction.php @@ -1694,5 +1694,55 @@ class AmdaAction $cacheMgr = new CatalogCacheMgr(); return $cacheMgr->editColumn($id,$name, $type,$size,$description); } + + public function getNodeValues($data,&$transformed){ + $iconCls = "task-folder"; + $expanded = true; + foreach ($data as $parameter => $value) { + if(is_array($value)){ + $child = [ + "parameter" => $parameter, + "value" => "", + "iconCls" => $iconCls, + "expanded" => false, + "children" => [] + ]; + $this->getNodeValues($value,$child['children']); + $transformed[] = $child; + } + else{ + $child =[ + "parameter" => $parameter, + "value" => $value, + "iconCls" => "task", + "leaf" => true + ]; + + $transformed[] = $child; + } + } + } + + public function getDefaultValueTree(){ + $childrenToReturn = array(); + $children = []; + if (file_exists(DATAPATH.'defaultValues.json')) { + $json_o = json_decode(file_get_contents(DATAPATH.'defaultValues.json'), true); + if (empty($json_o)) { + $childrenToReturn = array(); + } + else { + $this->getNodeValues($json_o,$children); + $childrenToReturn = [ + "text" => ".", + "children" => $children + ]; + } + } + else { + $childrenToReturn = array(); + } + return $childrenToReturn; + } } ?> diff --git a/php/config.php b/php/config.php index e182765..86736f5 100644 --- a/php/config.php +++ b/php/config.php @@ -205,7 +205,9 @@ $API = array( 'deleteColumn' => array('len'=> 1), 'addColumn' => array('len' => 5), 'getCatColumnInfo' => array('len' => 1), - 'editColumn' => array('len' => 5) + 'editColumn' => array('len' => 5), + // Default Values options + 'getDefaultValueTree' => array('len'=>0) ) ) ); -- libgit2 0.21.2