Commit 851cf2f0f6fcec96d0ccfe77274e8f2812386ca2

Authored by Erdogan Furkan
1 parent 7dd36700

For now

generic_data/defaultValues.json 0 → 100644
... ... @@ -0,0 +1,195 @@
  1 +{
  2 + "plot":{
  3 + "file":{
  4 + "format":"PNG",
  5 + "output":"INTERACTIVE",
  6 + "oneFilePerInterval":false
  7 + },
  8 + "tree":{
  9 + "fullView":false
  10 + },
  11 + "page":{
  12 + "xMargin":5,
  13 + "yMargin":5,
  14 + "mode":"color",
  15 + "orientation":"landscape",
  16 + "dimension":"ISO A4",
  17 + "title":{
  18 + "position":"top",
  19 + "alignment":" center",
  20 + "color":"#000000"
  21 + },
  22 + "font":{
  23 + "name":"sans-serif",
  24 + "size":"8"
  25 + },
  26 + "layout":{
  27 + "type":"vertical",
  28 + "panelHeight":0.5,
  29 + "panelSpacing":0,
  30 + "expand":false,
  31 + "timeAxesLegend":true
  32 + }
  33 + },
  34 + "panel":{
  35 + "plotType":"timePlot",
  36 + "isotropic":false,
  37 + "title":{
  38 + "position":"top",
  39 + "alignment":" center",
  40 + "color":"#000000"
  41 + },
  42 + "font":{
  43 + "name":"sans-serif",
  44 + "size":"8"
  45 + },
  46 + "backgroundColor":"none",
  47 + "status":{
  48 + "position":"top",
  49 + "colorMap":0
  50 + }
  51 + },
  52 + "axis":{
  53 + "scale":"linear",
  54 + "tickPosition":"outwards",
  55 + "color":"#000000",
  56 + "thickness":"1",
  57 + "legend":{
  58 + "color":"#000000",
  59 + "font":{
  60 + "name":"sans-serif",
  61 + "size":"8"
  62 + }
  63 + },
  64 + "timeFormat":"dd/mm/yy",
  65 + "colorMap":"1"
  66 + },
  67 + "serie":{
  68 + "yAxis":"y-left",
  69 + "resolution":3000,
  70 + "lines":{
  71 + "style":"plain",
  72 + "width":1,
  73 + "color":"auto"
  74 + },
  75 + "symbols":{
  76 + "type":"dot",
  77 + "size":3,
  78 + "color":"auto"
  79 + },
  80 + "resamplingMode":"xparam",
  81 + "timetick":{
  82 + "type":"auto",
  83 + "step":3600,
  84 + "nbmajor":5,
  85 + "nbminor":5,
  86 + "color":"#FF0000",
  87 + "symbols":{
  88 + "type":"full-circle",
  89 + "size":10,
  90 + "color":"#FF0000"
  91 + },
  92 + "firstsymbols":{
  93 + "type":"triangle",
  94 + "size":4,
  95 + "color":"#00FF00"
  96 + },
  97 + "font":{
  98 + "name":"sans-serif",
  99 + "size":"8"
  100 + }
  101 + },
  102 + "intervaltick":{
  103 + "mode":"start-time",
  104 + "color":"#FF0000",
  105 + "symbols":{
  106 + "type":"full-circle",
  107 + "size":10,
  108 + "color":"#FF0000"
  109 + },
  110 + "font":{
  111 + "name":"sans-serif",
  112 + "size":"8"
  113 + }
  114 + },
  115 + "errorbar":{
  116 + "type":"min-max",
  117 + "lines":{
  118 + "style":"plain",
  119 + "width":1,
  120 + "color":"auto"
  121 + }
  122 + },
  123 + "projection":"XY"
  124 + },
  125 + "spectro":{
  126 + "yAxis":"y-left",
  127 + "resolution":3000
  128 + },
  129 + "histogram2D":{
  130 + "histo2DFunction":"density",
  131 + "xbinnumber":100,
  132 + "ybinnumber":100,
  133 + "smoothfactor":1
  134 + },
  135 + "sauvaud":{
  136 + "yAxis":"y-right",
  137 + "resolution":3000
  138 + },
  139 + "intervals":{
  140 + "color":"#FF0000"
  141 + },
  142 + "statusbar":{
  143 + "color":"#FF0000"
  144 + },
  145 + "legends":{
  146 + "series":{
  147 + "type":"text-only",
  148 + "position":"outside",
  149 + "text":{
  150 + "color":"#000000"
  151 + },
  152 + "border":{"color":"#000000"},
  153 + "intervalinfo":{"type":"start-stop"},
  154 + "font":{"name":"sans-serif","size":"8"}
  155 + },
  156 + "text":{
  157 + "position":"left",
  158 + "color":"#000000",
  159 + "font":{
  160 + "name":"sans-serif",
  161 + "size":"8"
  162 + }
  163 + }
  164 + },
  165 + "constants":{
  166 + "axisId":"y-left",
  167 + "line":{
  168 + "style":"plain",
  169 + "width":1,
  170 + "color":"#000000"
  171 + }
  172 + },
  173 + "textObjs":{
  174 + "yAxisId":"y-left",
  175 + "xRelative":true,
  176 + "yRelative":true,
  177 + "align":"left",
  178 + "color":"#000000",
  179 + "font":{"name":"sans-serif","size":"8"}
  180 + },
  181 + "curves":{
  182 + "line":{
  183 + "style":"plain",
  184 + "width":1,
  185 + "color":"#000000"
  186 + }
  187 + },
  188 + "fills":{
  189 + "type":"serie-constant",
  190 + "greaterColor":"none",
  191 + "lessColor":"none"
  192 + },
  193 + "filtering":{"level":1}
  194 + }
  195 +}
0 196 \ No newline at end of file
... ...
js/app/AmdaApp.js
... ... @@ -13,6 +13,7 @@ Ext.define('amdaApp.AmdaApp', {
13 13 requires: [
14 14 'Ext.window.MessageBox',
15 15 'Ext.ux.desktop.ShortcutModel',
  16 + 'amdaUI.DefaultValuesWindow',
16 17 'amdaUI.SampToolBarUI',
17 18 'amdaDesktop.DynamicModule',
18 19 'MyDesktop.Settings'
... ... @@ -417,8 +418,12 @@ Ext.define('amdaApp.AmdaApp', {
417 418 {
418 419 text : 'Workspaces',
419 420 iconCls : 'icon-ws',
420   - disabled: true,
421   - scope : this
  421 + disabled: false,
  422 + scope : this,
  423 + handler:function(obj, e){
  424 + e.stopEvent();
  425 + Ext.create('amdaUI.DefaultValuesWindow').show();
  426 + }
422 427 }, '-',
423 428 {
424 429 text : 'Logout',
... ...
js/app/models/DefaultValues.js 0 → 100644
... ... @@ -0,0 +1,44 @@
  1 +Ext.define('amdaModel.DefaultValues', {
  2 + singleton: true,
  3 + type:null,
  4 + userValues:'',
  5 +
  6 + constructor: function() {
  7 + this.getDefaultValues();
  8 + },
  9 +
  10 + getDefaultValues: function(){
  11 + var me = this;
  12 +
  13 + Ext.Ajax.request({
  14 + url: 'generic_data/defaultValues.json',
  15 + method: 'GET',
  16 + success: function(response) {
  17 + me.values = Ext.decode(response.responseText);
  18 +
  19 + // after reading generic default values, we read user defaults.
  20 + Ext.Ajax.request({
  21 + url: 'data/'+ sessionID +'/userDefaults.json',
  22 + method: 'GET',
  23 + success: function(response) {
  24 + me.userValues = Ext.decode(response.responseText);
  25 + Ext.Object.each(me.userValues, function(key,value){
  26 + var keys = key.split('_');
  27 + var obj = me.values;
  28 + for (var i = 0; i < keys.length - 1; i++) {
  29 + obj = obj[keys[i]];
  30 + }
  31 + obj[keys[keys.length - 1]] = value;
  32 + })
  33 + },
  34 + failure:function(){
  35 + // Maybe create the file ?
  36 + }
  37 + });
  38 + },
  39 + failure: function(response) {
  40 + console.error('Failed to load default values', response);
  41 + }
  42 + });
  43 + },
  44 +});
0 45 \ No newline at end of file
... ...
js/app/models/DefaultValuesModel.js 0 → 100644
... ... @@ -0,0 +1,10 @@
  1 +Ext.define('amdaModel.DefaultValuesModel', {
  2 + extend: 'Ext.data.TreeModel',
  3 + fields: [{
  4 + name: 'parameter',
  5 + type: 'string'
  6 + }, {
  7 + name: 'value',
  8 + type: 'string'
  9 + }]
  10 +});
0 11 \ No newline at end of file
... ...
js/app/models/PlotObjects/PlotObjectConfig.js
... ... @@ -15,213 +15,13 @@
15 15  
16 16 Ext.define('amdaPlotObj.PlotObjectConfig', {
17 17 singleton: true,
  18 + requires:['amdaModel.DefaultValues'],
18 19  
19   - defaultValues: {
20   - file: {
21   - format: 'PNG',
22   - output: 'INTERACTIVE',
23   - oneFilePerInterval: false
24   - },
25   - tree: {
26   - fullView: false
27   - },
28   - page: {
29   - xMargin: 5.,
30   - yMargin: 5.,
31   - mode: 'color',
32   - orientation: 'landscape',
33   - dimension: 'ISO A4',
34   - title: {
35   - position: 'top',
36   - alignment: ' center',
37   - color: '#000000'
38   - },
39   - font: {
40   - name: 'sans-serif',
41   - size: '8'
42   - },
43   - layout: {
44   - type: 'vertical',
45   - panelHeight: 0.5,
46   - panelSpacing: 0.,
47   - expand: false,
48   - timeAxesLegend: true
49   - }
50   - },
51   - panel: {
52   - plotType: 'timePlot',
53   - isotropic: false,
54   - title: {
55   - position: 'top',
56   - alignment: ' center',
57   - color: '#000000'
58   - },
59   - font: {
60   - name: 'sans-serif',
61   - size: '8'
62   - },
63   - backgroundColor: 'none',
64   - status: {
65   - position: 'top',
66   - colorMap: 0
67   - }
68   - },
69   - axis: {
70   - scale: 'linear',
71   - tickPosition: 'outwards',
72   - color: '#000000',
73   - thickness: '1',
74   - legend: {
75   - color: '#000000',
76   - font: {
77   - name: 'sans-serif',
78   - size: '8'
79   - }
80   - },
81   - timeFormat: 'dd/mm/yy',
82   - colorMap: '1'
83   - },
84   - serie: {
85   - yAxis: 'y-left',
86   - resolution: 3000,
87   - lines: {
88   - style: 'plain',
89   - width: 1,
90   - color: 'auto'
91   - },
92   - symbols: {
93   - type: 'dot',
94   - size: 3,
95   - color: 'auto'
96   - },
97   - resamplingMode: 'xparam',
98   - timetick: {
99   - type: 'auto',
100   - step: 3600,
101   - nbmajor: 5,
102   - nbminor: 5,
103   - color: '#FF0000',
104   - symbols: {
105   - type: 'full-circle',
106   - size: 10,
107   - color: '#FF0000'
108   - },
109   - firstsymbols: {
110   - type: 'triangle',
111   - size: 4,
112   - color: '#00FF00'
113   - },
114   - font: {
115   - name: 'sans-serif',
116   - size: '8'
117   - }
118   - },
119   - intervaltick: {
120   - mode: 'start-time',
121   - color: '#FF0000',
122   - symbols: {
123   - type: 'full-circle',
124   - size: 10,
125   - color: '#FF0000'
126   - },
127   - font: {
128   - name: 'sans-serif',
129   - size: '8'
130   - }
131   - },
132   - errorbar: {
133   - type: 'min-max',
134   - lines: {
135   - style: 'plain',
136   - width: 1,
137   - color: 'auto'
138   - }
139   - },
140   - projection: 'XY',
141   - },
142   - spectro: {
143   - yAxis: 'y-left',
144   - resolution: 3000
145   - },
146   - histogram2D:{
147   - histo2DFunction: 'density',
148   - xbinnumber: 100,
149   - ybinnumber: 100,
150   - smoothfactor: 1,
151   - },
152   - sauvaud: {
153   - yAxis: 'y-right',
154   - resolution: 3000
155   - },
156   - intervals: {
157   - color: "#FF0000"
158   - },
159   - statusbar: {
160   - color: "#FF0000"
161   - },
162   - legends: {
163   - series: {
164   - type: 'text-only',
165   - position: 'outside',
166   - text: {
167   - color: '#000000'
168   - },
169   - border: {
170   - color: '#000000'
171   - },
172   - intervalinfo: {
173   - type: 'start-stop'
174   - },
175   - font: {
176   - name: 'sans-serif',
177   - size: '8'
178   - }
179   - },
180   - text: {
181   - position: 'left',
182   - color: '#000000',
183   - font: {
184   - name: 'sans-serif',
185   - size: '8'
186   - }
187   - }
188   - },
189   - constants: {
190   - axisId: 'y-left',
191   - line: {
192   - style: 'plain',
193   - width: 1,
194   - color: '#000000'
195   - }
196   - },
197   - textObjs: {
198   - yAxisId: 'y-left',
199   - xRelative: true,
200   - yRelative: true,
201   - align: 'left',
202   - color: '#000000',
203   - font: {
204   - name: 'sans-serif',
205   - size: '8'
206   - }
207   - },
208   - curves: {
209   - line: {
210   - style: 'plain',
211   - width: 1,
212   - color: '#000000'
213   - }
214   - },
215   - fills: {
216   - type: 'serie-constant',
217   - greaterColor: 'none',
218   - lessColor: 'none'
219   - },
220   - filtering: {
221   - level: 1
222   - }
  20 + defaultValues: null,
  21 +
  22 + constructor: function(){
  23 + this.defaultValues = amdaModel.DefaultValues.values.plot;
223 24 },
224   -
225 25 getValueByKey: function (dataList, key) {
226 26 var value = '';
227 27 Ext.each(dataList, function (data) {
... ...
js/app/models/PlotObjects/PlotSauvaudObject.js
... ... @@ -32,10 +32,10 @@ Ext.define(&#39;amdaPlotObj.PlotSauvaudObject&#39;, {
32 32 { name: 'filtering-level', type: 'int' },
33 33 { name: 'right_dim', type: 'int' },
34 34  
35   - { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.name, type: 'boolean' },
36   - { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.type.key, type: 'string' },
37   - { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.value.key, type: 'string' },
38   - { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimkey, type: 'string' }
  35 + // { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.name, type: 'boolean' },
  36 + // { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.type.key, type: 'string' },
  37 + // { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.value.key, type: 'string' },
  38 + // { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimkey, type: 'string' }
39 39 ],
40 40  
41 41 constructor: function () {
... ...
js/app/models/PlotObjects/PlotSpectroObject.js
... ... @@ -31,10 +31,10 @@ Ext.define(&#39;amdaPlotObj.PlotSpectroObject&#39;, {
31 31 { name: 'filtering-activated', type: 'boolean' },
32 32 { name: 'filtering-level', type: 'int' },
33 33  
34   - { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.name, type: 'boolean' },
35   - { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.type.key, type: 'string' },
36   - { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.value.key, type: 'string' },
37   - { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimkey, type: 'string' }
  34 + // { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.name, type: 'boolean' },
  35 + // { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.type.key, type: 'string' },
  36 + // { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.value.key, type: 'string' },
  37 + // { name: amdaPlotObj.PlotObjectConfig.bgSubstraction.value.dimkey, type: 'string' }
38 38 ],
39 39  
40 40 constructor: function () {
... ...
js/app/views/DefaultTreeGrid.js 0 → 100644
... ... @@ -0,0 +1,191 @@
  1 +Ext.define('StatusColorPicker', {
  2 + extend: 'Ext.form.field.Picker',
  3 + alias: 'widget.statuscolorpicker',
  4 + availableColorsNew: [
  5 + "#000000", "#0000ff", "#ff0000", "#00ffff", "#ff00ff", "#008000", "#800000",
  6 + "#000080", "#808000", "#800080", "#c0c0c0", "#008080", "#ffff00", "#004040",
  7 + "#29d8d7", "#6b9842", "#73a9b4", "#1c883d", "#808080", "#4342dd", "#e84130",
  8 + "#dee2e6", "#ced4da", "#adb5bd", "#868e96", "#495057", "#343a40", "#212529",
  9 + "#ffa8a8", "#ff8787", "#ff6b6b", "#fa5252", "#f03e3e", "#e03131", "#c92a2a",
  10 + "#faa2c1", "#f783ac", "#f06595", "#e64980", "#d6336c", "#c2255c", "#a61e4d",
  11 + "#e599f7", "#da77f2", "#cc5de8", "#be4bdb", "#ae3ec9", "#9c36b5", "#862e9c",
  12 + "#b197fc", "#9775fa", "#845ef7", "#7950f2", "#7048e8", "#6741d9", "#5f3dc4",
  13 + "#91a7ff", "#748ffc", "#5c7cfa", "#4c6ef5", "#4263eb", "#3b5bdb", "#364fc7",
  14 + "#74c0fc", "#4dabf7", "#339af0", "#228be6", "#1c7ed6", "#1971c2", "#1864ab",
  15 + "#66d9e8", "#3bc9db", "#22b8cf", "#15aabf", "#1098ad", "#0c8599", "#0b7285",
  16 + "#63e6be", "#38d9a9", "#20c997", "#12b886", "#0ca678", "#099268", "#087f5b",
  17 + "#8ce99a", "#69db7c", "#51cf66", "#40c057", "#37b24d", "#2f9e44", "#2b8a3e",
  18 + "#c0eb75", "#a9e34b", "#94d82d", "#82c91e", "#74b816", "#66a80f", "#5c940d",
  19 + "#ffe066", "#ffd43b", "#fcc419", "#fab005", "#f59f00", "#f08c00", "#e67700",
  20 + "#ffc078", "#ffa94d", "#ff922b", "#fd7e14", "#f76707", "#e8590c", "#d9480f"
  21 + ],
  22 + toUpper : function(x){
  23 + return x.toUpperCase();
  24 + },
  25 + replaceColor : function(x){
  26 + return x.replace("#","");
  27 + },
  28 + createPicker: function() {
  29 + var me = this;
  30 + return Ext.create('Ext.picker.Color', {
  31 + pickerField: me,
  32 + renderTo: Ext.getBody(),
  33 + floating: true,
  34 + minWidth: 133,
  35 + maxWidth: 200,
  36 + minHeight: 225,
  37 + autoScroll:true,
  38 + focusOnShow: true,
  39 + colors: this.availableColorsNew.map(this.replaceColor).map(this.toUpper),
  40 + listeners: {
  41 + select: function(picker, color) {
  42 + me.setValue('#'+color);
  43 + me.picker.hide();
  44 + },
  45 + scope: me
  46 + }
  47 + });
  48 + }
  49 +});
  50 +
  51 +Ext.define('amdaUI.DefaultTreeGrid', {
  52 + extend: 'Ext.tree.Panel',
  53 +
  54 + requires: [
  55 + 'Ext.data.*',
  56 + 'Ext.grid.*',
  57 + 'Ext.tree.*',
  58 + 'amdaModel.DefaultValuesModel',
  59 + 'StatusColorPicker'
  60 + ],
  61 + xtype: 'tree-grid',
  62 +
  63 + reserveScrollbar: true,
  64 +
  65 + height: 300,
  66 + useArrows: true,
  67 + rootVisible: false,
  68 + multiSelect: true,
  69 + singleExpand: true,
  70 +
  71 + constructor: function() {
  72 + this.init();
  73 + this.callParent();
  74 + },
  75 +
  76 + isHexCode: function(str) {
  77 + return /^#[0-9a-fA-F]{6}$/.test(str);
  78 + },
  79 + init: function() {
  80 + var me = this;
  81 + me.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {clicksToEdit: 1,
  82 + listeners:{
  83 + beforeedit:function(editor, context,e){
  84 + if(!context.record.data.leaf)
  85 + {
  86 + return false;
  87 + }
  88 + var value = context.record.get(context.field);
  89 + if (me.isHexCode(value)) {
  90 + var colorPicker = Ext.create('StatusColorPicker', {
  91 + pickerField: context.field,
  92 + value: value,
  93 + listeners: {
  94 + select: function(picker, color) {
  95 + context.record.set(context.field, '#' + color);
  96 + me.getView().refresh();
  97 + }
  98 + }
  99 + });
  100 + editor.field = colorPicker;
  101 + }
  102 + }
  103 + }
  104 + });
  105 +
  106 + AmdaAction.getDefaultValueTree(function(res,e) {
  107 + console.log(res);
  108 + });
  109 +
  110 + Ext.apply(this, {
  111 + store: new Ext.data.TreeStore({
  112 + model: amdaModel.DefaultValuesModel,
  113 + proxy: {
  114 + type: 'direct',
  115 + directFn: AmdaAction.getDefaultValueTree
  116 + },
  117 + folderSort: true
  118 + }),
  119 + plugins: [me.cellEditing],
  120 + columns: [{
  121 + xtype: 'treecolumn', //this is so we know which column will show the tree
  122 + text: 'Parameters',
  123 + flex: 2,
  124 + sortable: true,
  125 + dataIndex: 'parameter'
  126 + },{
  127 + xtype: 'gridcolumn',
  128 + getEditor: function(record) {
  129 + var grid = this.up().grid,
  130 + cellediting = grid.findPlugin('cellediting'),
  131 + editors = cellediting.editors,
  132 + editor = editors.getByKey(this.id),
  133 + fieldType;
  134 +
  135 + if (editor) {
  136 + // Do this to avoid memory leaks
  137 + editors.remove(editor);
  138 + }
  139 + value = record.get('value');
  140 + if(me.isHexCode(value)){
  141 + fieldType = 'statuscolorpicker'
  142 + }
  143 + else if(value === 'true' || value == 'false'){
  144 + fieldType = 'combobox'
  145 + }
  146 + else{
  147 + fieldType = isNaN(parseFloat(record.get('value'))) ? 'textfield' : 'numberfield';
  148 + }
  149 + return {
  150 + xtype: fieldType,
  151 + store: (fieldType=='combobox') ? [[true, 'true'], [false, 'false']] : null,
  152 + editable: false,
  153 + value: (fieldType=='combobox') ? value : null,
  154 + allowBlank: false
  155 + };
  156 + },
  157 + text: 'Values',
  158 + flex: 1,
  159 + sortable: true,
  160 + dataIndex: 'value',
  161 + align: 'center',
  162 + renderer: function(value, meta) {
  163 + if (me.isHexCode(value)){
  164 + value = value.substring(1, 7);
  165 + return '<div style="background-color:#' + value + '; margin-left: auto; \
  166 + margin-right: auto;width:15px;height:15px;"></div>';
  167 + }
  168 + else{
  169 + return value;
  170 + }
  171 + },
  172 + },{
  173 + text: 'Reset',
  174 + width: 55,
  175 + menuDisabled: true,
  176 + xtype: 'actioncolumn',
  177 + tooltip: 'Reset to the default value',
  178 + align: 'center',
  179 + icon: 'js/resources/images/16x16/arrow_circle_double.png',
  180 + handler: function(grid, rowIndex, colIndex, actionItem, event, record, row) {
  181 + Ext.Msg.alert('Editing' + record.get('parameter'));
  182 + },
  183 + // Only leaf level tasks may be edited
  184 + isDisabled: function(view, rowIdx, colIdx, item, record) {
  185 + return !record.data.leaf;
  186 + }
  187 + }
  188 + ]
  189 + });
  190 + }
  191 +});
... ...
js/app/views/DefaultValuesWindow.js 0 → 100644
... ... @@ -0,0 +1,93 @@
  1 +
  2 +
  3 +Ext.define('amdaUI.DefaultValuesWindow',{
  4 + extend: 'Ext.window.Window',
  5 + alias: 'widget.defaultvalueswindow',
  6 +
  7 + requires:[
  8 + 'amdaUI.DefaultTreeGrid',
  9 + ],
  10 + defaultValuesGrid: null,
  11 + constructor:function(){
  12 + this.defaultValuesGrid = Ext.create('amdaUI.DefaultTreeGrid');
  13 + this.init();
  14 + this.callParent();
  15 + },
  16 +
  17 + init:function(config){
  18 +
  19 + var me=this;
  20 + Ext.apply(this, {
  21 + title: 'Default Values Grid',
  22 + width: 350,
  23 + height: 380,
  24 + closable:false,
  25 + modal:true,
  26 + resizable: false,
  27 + items: [
  28 + {
  29 + xtype: 'form',
  30 + renderTo: Ext.getBody(),
  31 + layout:'hbox',
  32 + frame: false,
  33 + items: [
  34 + {
  35 + flex:1,
  36 + items:[me.defaultValuesGrid],
  37 + },
  38 + ],
  39 +
  40 + buttons: [{
  41 + text: 'Save',
  42 + handler: function() {
  43 +
  44 + // Check to be sure that max > min
  45 +
  46 + // if(config.type != "cat"){
  47 + // var records = me.statusGrid.store.getRange();
  48 + // for (var i = 0; i < records.length; i++) {
  49 + // var record = records[i];
  50 + // if (record.get('maxVal') < record.get('minVal')) {
  51 + // invalidRecord = record;
  52 + // break;
  53 + // }
  54 + // }
  55 + // if (invalidRecord) {
  56 + // Ext.Msg.alert('Error', 'Max value must be greater than Min value', function() {
  57 + // me.statusGrid.cellEditing.startEditByPosition({row: invalidRecord, column: 0});
  58 + // invalidRecord = null;
  59 + // });
  60 + // return;
  61 + // }
  62 + // }
  63 +
  64 + // // Saving part
  65 +
  66 + // config.object.set('status',me.statusGrid.getStatusString());
  67 + // me.statusGrid.clearStore();
  68 + // me.close();
  69 + },
  70 + },
  71 + {
  72 + // to reset the form
  73 + text: 'Reset',
  74 + handler: function() {
  75 + // me.statusGrid.clearStore();
  76 + // me.statusGrid.parseStatus(config.status);
  77 + }
  78 + },
  79 + {
  80 + // To quit the window
  81 + text: 'Cancel',
  82 + handler: function() {
  83 + // me.statusGrid.clearStore();
  84 + // me.statusGrid.destroy();
  85 + me.close();
  86 + }
  87 + }]
  88 + }
  89 + ]
  90 + });
  91 + }
  92 +});
  93 +
... ...
php/classes/AmdaAction.php
... ... @@ -1694,5 +1694,55 @@ class AmdaAction
1694 1694 $cacheMgr = new CatalogCacheMgr();
1695 1695 return $cacheMgr->editColumn($id,$name, $type,$size,$description);
1696 1696 }
  1697 +
  1698 + public function getNodeValues($data,&$transformed){
  1699 + $iconCls = "task-folder";
  1700 + $expanded = true;
  1701 + foreach ($data as $parameter => $value) {
  1702 + if(is_array($value)){
  1703 + $child = [
  1704 + "parameter" => $parameter,
  1705 + "value" => "",
  1706 + "iconCls" => $iconCls,
  1707 + "expanded" => false,
  1708 + "children" => []
  1709 + ];
  1710 + $this->getNodeValues($value,$child['children']);
  1711 + $transformed[] = $child;
  1712 + }
  1713 + else{
  1714 + $child =[
  1715 + "parameter" => $parameter,
  1716 + "value" => $value,
  1717 + "iconCls" => "task",
  1718 + "leaf" => true
  1719 + ];
  1720 +
  1721 + $transformed[] = $child;
  1722 + }
  1723 + }
  1724 + }
  1725 +
  1726 + public function getDefaultValueTree(){
  1727 + $childrenToReturn = array();
  1728 + $children = [];
  1729 + if (file_exists(DATAPATH.'defaultValues.json')) {
  1730 + $json_o = json_decode(file_get_contents(DATAPATH.'defaultValues.json'), true);
  1731 + if (empty($json_o)) {
  1732 + $childrenToReturn = array();
  1733 + }
  1734 + else {
  1735 + $this->getNodeValues($json_o,$children);
  1736 + $childrenToReturn = [
  1737 + "text" => ".",
  1738 + "children" => $children
  1739 + ];
  1740 + }
  1741 + }
  1742 + else {
  1743 + $childrenToReturn = array();
  1744 + }
  1745 + return $childrenToReturn;
  1746 + }
1697 1747 }
1698 1748 ?>
... ...
php/config.php
... ... @@ -205,7 +205,9 @@ $API = array(
205 205 'deleteColumn' => array('len'=> 1),
206 206 'addColumn' => array('len' => 5),
207 207 'getCatColumnInfo' => array('len' => 1),
208   - 'editColumn' => array('len' => 5)
  208 + 'editColumn' => array('len' => 5),
  209 + // Default Values options
  210 + 'getDefaultValueTree' => array('len'=>0)
209 211 )
210 212 )
211 213 );
... ...