Mercurial > lada > lada-client
annotate app/controller/Sql.js @ 237:bc2d46a67bbd
Added configuration varibale to define the set of all available columns.
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Tue, 23 Jul 2013 11:28:46 +0200 |
parents | 78134e20e62d |
children | 4ca858026191 |
rev | line source |
---|---|
31
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
1 var queries = new Array('query1', 'query2'); |
6
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
2 Ext.define('Lada.controller.Sql', { |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
3 extend: 'Ext.app.Controller', |
8
e4fcb4ddd782
Moved stored SQL into its own file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
6
diff
changeset
|
4 stores: [ |
235
78134e20e62d
Added new model and store for Queries.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
147
diff
changeset
|
5 'Proben', // List of found Proben |
78134e20e62d
Added new model and store for Queries.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
147
diff
changeset
|
6 'Queries' |
8
e4fcb4ddd782
Moved stored SQL into its own file.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
6
diff
changeset
|
7 ], |
6
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
8 init: function() { |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
9 console.log('Initialising the Sql controller'); |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
10 this.control({ |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
11 // CSS like selector to select element in the viewport. See |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
12 // ComponentQuery documentation for more details. |
31
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
13 '#search': { |
6
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
14 // Map the "render" event to the given function. |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
15 render: this.onPanelRendered, |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
16 // Map Doubleclick on rows of the probenlist. |
28
4d60b9ebce15
Renamed sql modul into search. Further display The query selection as Combobox
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
25
diff
changeset
|
17 select: this.selectSql |
31
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
18 }, |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
19 '#SearchBtn': { |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
20 // Map click event on Button. |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
21 click: this.search |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
22 }, |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
23 '#ResetBtn': { |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
24 // Map click event on Button. |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
25 click: this.reset |
6
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
26 } |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
27 }); |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
28 }, |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
29 onPanelRendered: function() { |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
30 console.log('The panel was rendered'); |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
31 }, |
28
4d60b9ebce15
Renamed sql modul into search. Further display The query selection as Combobox
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
25
diff
changeset
|
32 selectSql: function(element, record, index) { |
31
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
33 var selection = element.getValue() - 1; |
25
f964a50bfe57
Restructured the application. Fixed layouts etc.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
17
diff
changeset
|
34 console.log('Selected SQL ' + selection); |
31
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
35 for (var i = 0; i < queries.length; ++i) { |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
36 var toHide = Ext.getCmp(queries[i]); |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
37 toHide.hide(); |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
38 } |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
39 var toShow = Ext.getCmp(queries[selection]); |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
40 var buttons = Ext.getCmp('SearchBtnPanel'); |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
41 this.reset(); |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
42 toShow.show(); |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
43 buttons.show(); |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
44 }, |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
45 search: function(element, record, index) { |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
46 var result = Ext.getCmp('result'); |
28
4d60b9ebce15
Renamed sql modul into search. Further display The query selection as Combobox
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
25
diff
changeset
|
47 console.log('Loading store'); |
36
2a67e062519b
Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
35
diff
changeset
|
48 |
2a67e062519b
Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
35
diff
changeset
|
49 // Get search parameters: |
2a67e062519b
Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
35
diff
changeset
|
50 var searchParams = {}; |
2a67e062519b
Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
35
diff
changeset
|
51 if (Ext.getCmp('search').getValue() == 1) { |
96
ecb0c0cf386b
Only add search params if the user actually set them in the form.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
36
diff
changeset
|
52 var mst = Ext.getCmp('mst').getValue(); |
ecb0c0cf386b
Only add search params if the user actually set them in the form.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
36
diff
changeset
|
53 var uwb = Ext.getCmp('uwb').getValue(); |
ecb0c0cf386b
Only add search params if the user actually set them in the form.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
36
diff
changeset
|
54 if (mst !== null) { |
139
df6e36dd57ee
Changed params probe -> probeId, mst -> mstId, uwb -> umwId
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
120
diff
changeset
|
55 searchParams['mstId'] = mst; |
96
ecb0c0cf386b
Only add search params if the user actually set them in the form.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
36
diff
changeset
|
56 } |
ecb0c0cf386b
Only add search params if the user actually set them in the form.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
36
diff
changeset
|
57 if (uwb !== null) { |
139
df6e36dd57ee
Changed params probe -> probeId, mst -> mstId, uwb -> umwId
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
120
diff
changeset
|
58 searchParams['umwId'] = uwb; |
96
ecb0c0cf386b
Only add search params if the user actually set them in the form.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
36
diff
changeset
|
59 } |
36
2a67e062519b
Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
35
diff
changeset
|
60 } else { |
2a67e062519b
Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
35
diff
changeset
|
61 // Get date object an convert it into a timestamp (ms since epoch) |
97
9a549ca6e664
Only getTimte from datefield if the value is not null.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
96
diff
changeset
|
62 var datefield = Ext.getCmp('pbegin').getValue(); |
9a549ca6e664
Only getTimte from datefield if the value is not null.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
96
diff
changeset
|
63 if (datefield !== null) { |
9a549ca6e664
Only getTimte from datefield if the value is not null.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
96
diff
changeset
|
64 var ts = Ext.getCmp('pbegin').getValue().getTime(); |
96
ecb0c0cf386b
Only add search params if the user actually set them in the form.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
36
diff
changeset
|
65 searchParams['begin'] = ts; |
ecb0c0cf386b
Only add search params if the user actually set them in the form.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
36
diff
changeset
|
66 } |
36
2a67e062519b
Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
35
diff
changeset
|
67 } |
2a67e062519b
Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
35
diff
changeset
|
68 result.getStore().load({ |
2a67e062519b
Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
35
diff
changeset
|
69 params: searchParams |
2a67e062519b
Implemted search. When user clicks on the search buttons parameters are
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
35
diff
changeset
|
70 }); |
28
4d60b9ebce15
Renamed sql modul into search. Further display The query selection as Combobox
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
25
diff
changeset
|
71 console.log('Store loaded'); |
25
f964a50bfe57
Restructured the application. Fixed layouts etc.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
17
diff
changeset
|
72 result.show(); |
31
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
73 }, |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
74 reset: function(element, record, index) { |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
75 var buttons = Ext.getCmp('SearchBtnPanel'); |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
76 var result = Ext.getCmp('result'); |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
77 for (var i = 0; i < queries.length; ++i) { |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
78 var toHide = Ext.getCmp(queries[i]); |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
79 toHide.hide(); |
897e3100c6da
Changed logic of the Probenauswahl. Now logic works like the BFS version.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
28
diff
changeset
|
80 } |
147
5da0b56bf9bf
Do no hide the earch buttons and the resultlist on reset.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
139
diff
changeset
|
81 //result.hide(); |
5da0b56bf9bf
Do no hide the earch buttons and the resultlist on reset.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
139
diff
changeset
|
82 //buttons.hide(); |
6
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
83 } |
8e79bda4d55b
Added a list to select predefined SQL Statement for the Proben list.
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff
changeset
|
84 }); |