ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MRovere/ReferenceWebGUI/browseWindow_UI.js
Revision: 1.2
Committed: Wed Mar 10 12:12:17 2010 UTC (15 years, 1 month ago) by rovere
Content type: application/javascript
Branch: MAIN
Changes since 1.1: +1 -1 lines
Log Message:
* xmlTextArea_UI.js: adapted code to run with new repository.
References to extjs are now absolute, whereas references to
local js files are all realtive.

* uploadWindow_UI.js: adapted code to run with new repository.
References to extjs are now absolute, whereas references to
local js files are all realtive.

* subSysCombo_UI.js: adapted code to run with new repository.
References to extjs are now absolute, whereas references to
local js files are all realtive.

* relValUploadWindow_UI.js: References to cgi-bin
script are all absolute.

* refGridPanel_UI.js: References to cgi-bin
script are all absolute.

* localTagCombo_UI.js: adapted code to run with new repository.
References to extjs are now absolute, whereas references to
local js files are all realtive. References to cgi-bin
script are all absolute.

* index.html: adapted code to run with new repository.
References to extjs are now absolute, whereas references to
local js files are all realtive.

* goodForRun_UI.js: adapted code to run with new repository.
References to extjs are now absolute, whereas references to
local js files are all realtive.

* dbsCombo_UI.js: adapted code to run with new repository.
References to extjs are now absolute, whereas references to
local js files are all realtive.

* browseWindow_UI.js: adapted code to run out-of-the box
using the new CVS repository (UserCode/MRovere inside CMSSW)

File Contents

# User Rev Content
1 rovere 1.1 Ext.ns('browseWindow_UI');
2    
3     Array.prototype.unique = function () {
4     var r = new Array();
5     o:for(var i = 0, n = this.length; i < n; i++)
6     {
7     for(var x = 0, y = r.length; x < y; x++)
8     {
9     if(r[x]==this[i])
10     {
11     continue o;
12     }
13     }
14     r[r.length] = this[i];
15     }
16     return r;
17     };
18    
19     //var nextOne = true ;
20    
21     // Ext.Ajax.on('requestComplete', function(conn, resp, opts)
22     // {
23     // alert('Ajax finished and returned') ;
24     // nextOne = true ;
25     // }) ;
26    
27    
28 rovere 1.2 Ext.BLANK_IMAGE_URL = '/ext/resources/images/default/s.gif';
29 rovere 1.1
30     browseWindow_UI.Window = Ext.extend(Ext.Window,
31     {
32     consoleLog:false
33     ,initComponent:function()
34     {
35     // hard coded config - cannot be changed from outside
36     var config =
37     {
38     items:{
39     xtype:'form'
40     ,frame:true
41     ,defaults:{anchor:'-20'}
42     ,items:[
43     {
44     xtype: 'dbscombo'
45     ,noCache: false
46     ,consoleLog: false
47     }
48     ,{
49     xtype: 'localtagcombo'
50     ,noCache:true
51     ,consoleLog: false
52     // ,id: 'localtagcombo'
53     }
54     ,{
55     xtype:'subsyscombo'
56     ,noCache: true
57     ,consoleLog: false
58     }
59     ,{
60     xtype: 'goodforrunUI'
61     ,consoleLog: false
62     , buttonLabel: 'Select'
63     }
64     ,{
65     xtype: 'refgridpanel'
66     ,consoleLog: false
67     }
68     ]
69     }
70     }; // eo config
71     // apply config
72     Ext.apply(this,Ext.apply(this.initialConfig, config));
73    
74     //call parent
75     browseWindow_UI.Window.superclass.initComponent.apply(this, arguments);
76     if(this.consoleLog)
77     console.log('browseWindow_UI.Window initComponent called');
78    
79     } // eo initComponent
80    
81     // The next function MUST be called as a callback
82     // method of the show method. This is so because
83     // I need to refer to some components that are not there after the window rendered
84     // but are there only after the window is shown (the button
85     // for the goodRun new widget
86     ,setConnections:function(){
87     if(this.consoleLog)
88     console.log('browseWindow_UI.setConnections called') ;
89    
90     this.loadMask = new Ext.LoadMask(Ext.getBody(), {msg:'Loading...<br/>Please wait.'});
91    
92     // Install proper hooks to main windows components that have to communicate
93     // each others.
94     // We put them here because they already exists in the HTML document
95     var dbIndex = this.items.itemAt(0).items.findIndex('xtype', 'dbscombo') ;
96     this.db = this.items.itemAt(0).items.itemAt(dbIndex);
97     if(this.consoleLog)
98     console.log('browseWindow_UI.onRender the Database cmp should be ', this.db) ;
99    
100     var tagsIndex = this.items.itemAt(0).items.findIndex('xtype', 'localtagcombo') ;
101     this.tags = this.items.itemAt(0).items.itemAt(tagsIndex);
102     if(this.consoleLog)
103     console.log('browseWindow_UI.onRender the local tags cmp should be ', this.tags) ;
104    
105     var subsysIndex = this.items.itemAt(0).items.findIndex('xtype', 'subsyscombo') ;
106     this.subsystems = this.items.itemAt(0).items.itemAt(subsysIndex);
107     if(this.consoleLog)
108     console.log('browseWindow_UI.onRender the subsystems cmp should be ', this.subsystems) ;
109    
110     var gridIndex = this.items.itemAt(0).items.findIndex('xtype', 'refgridpanel') ;
111     this.grid = this.items.itemAt(0).items.itemAt(gridIndex);
112     if(this.consoleLog)
113     console.log('browseWindow_UI.onRender the main grid cmp should be ', this.grid) ;
114    
115     this.grid_prep = this.grid.getBottomToolbar().findById('cms_orcoff_prep') ;
116     if(this.consoleLog)
117     console.log('browseWindow_UI.onRender the orcoff_prep Button cmp should be ',this.grid_prep) ;
118    
119     this.grid_prod = this.grid.getBottomToolbar().findById('cms_orcoff_prod') ;
120     if(this.consoleLog)
121     console.log('browseWindow_UI.onRender the orcoff_prod Button cmp should be ', this.grid_prod) ;
122    
123     var goodrunIndex = this.items.itemAt(0).items.findIndex('xtype', 'goodforrunUI') ;
124     this.goodRun = this.items.itemAt(0).items.itemAt(goodrunIndex);
125     if(this.consoleLog)
126     console.log('browseWindow_UI.onRender the main GoodRun cmp should be ', this.goodRun) ;
127    
128     // install communication between components using event handlers!!!!
129     // LOCAL TAGS BEHAVIOUR
130     this.tags.store.on(
131     {
132     scope:this
133     ,beforeload:this.addBaseParams
134     ,stopEvent:true
135     });
136     this.tags.on(
137     {
138     scope: this
139     ,collapse:function()
140     {
141     if(this.consoleLog)
142     console.log('tags\' collapse fired ', this.tags.getValue()) ;
143     this.grid.store.load();
144     }
145     ,change:function(){this.grid.store.load();}
146     }
147     );
148    
149     // SUBSYSTEM BEHAVIOUR
150     this.subsystems.store.on(
151     {
152     scope:this
153     ,beforeload:this.addBaseParams
154     ,stopEvent:true
155     });
156     this.subsystems.on(
157     {
158     scope: this
159     ,collapse:function()
160     {
161     if(this.consoleLog)
162     console.log('subsystems\' collapse fired ', this.tags.getValue()) ;
163     this.grid.store.load();
164     }
165     ,change:function(){this.grid.store.load();}
166     }
167     );
168    
169     // GRID BEHAVIOR
170     this.grid.store.on(
171     {
172     scope:this
173     ,beforeload:this.addBaseParamsToGrid
174     ,stopEvent:true
175     }
176     );
177    
178     // GRID TOOLBAR BUTTON BEHAVIOR
179     this.grid_prep.on(
180     {
181     scope: this
182     ,click: this.checkGridButton
183     }
184     );
185     this.grid_prod.on(
186     {
187     scope: this
188     ,click: this.checkGridButton
189     }
190     );
191    
192     // DATABASE BEHAVIOUR
193     this.db.on(
194     {
195     scope:this
196     ,select:function(){
197     if(this.consoleLog)
198     console.log('browseWindow_UI.onRender: actual db value at \'select\' is: ', this.db.getValue());
199     if(this.db.getValue() !== this.db.oldState)
200     {
201     this.addBaseParamsToGrid();
202     this.tags.store.setBaseParam('dbname', this.db.getValue());
203     this.subsystems.store.setBaseParam('dbname', this.db.getValue());
204     this.tags.clearValue();
205     this.subsystems.clearValue();
206     this.grid.store.load();
207     }
208     }
209     ,stopEvent:true
210     }
211     );
212    
213     // GOOD_FOR_RUN BEHAVIUOR
214     if(this.consoleLog)
215     console.log('browseWindow_UI.onRender: Button for selecting a specific run is: ', this.goodRun.testButton) ;
216     this.goodRun.testButton.on(
217     {
218     scope: this
219     ,click: function()
220     {
221     this.grid.store.setBaseParam('specificRun', this.goodRun.getValue());
222     this.grid.store.load();
223     }
224     }
225     );
226     } // eo function setConnections
227    
228     ,addBaseParams:function()
229     {
230     if(this.consoleLog)
231     console.log('browseWindow_UI installing db name to stores\' base params: ', this.db.getValue());
232     this.tags.store.setBaseParam('dbname', this.db.getValue());
233     this.subsystems.store.setBaseParam('dbname', this.db.getValue());
234     }
235     ,addBaseParamsToGrid:function()
236     {
237     if(this.consoleLog)
238     console.log('browseWindow_UI.addBaseParamsToGrid: installing grid\'s base params: localtag ->', this.tags.getValue(), ' subsystem->', this.subsystems.getValue());
239     this.grid.store.setBaseParam('dbname', this.db.getValue());
240     this.grid.store.setBaseParam('localtag', this.tags.getValue());
241     this.grid.store.setBaseParam('subsystem', this.subsystems.getValue());
242     }
243     ,checkGridButton:function(btn, evt)
244     {
245     var tags_runs = new Array() ;
246     for(var i = 0 ; i < this.grid.store.data.length ; ++i)
247     {
248     tags_runs[i] = this.grid.store.data.items[i].data.Tag + '--StartRun_' + this.grid.store.data.items[i].data.StartRun ;
249     }
250     tags_runs = tags_runs.unique() ;
251     var tag = '' ;
252     var run = '' ;
253     for(var j = 0 ; j <tags_runs.length ; ++j)
254     {
255     var tagrun = tags_runs[j].split(/--StartRun_/) ;
256     tag += tagrun[0] + (j==tags_runs.length-1 ? '' : '-@-') ;
257     run += tagrun[1] + (j==tags_runs.length-1 ? '' : '-') ;
258     }
259     // debugger ;
260     this.loadMask.show() ;
261     Ext.Ajax.request(
262     {
263     url : '/cgi-bin/ReferencePythonCLI/driver.py'
264     ,method : 'post'
265     ,params :
266     {
267     action: 'checkDB'
268     ,db: btn.id
269     ,tag: tag
270     ,run: run
271     } // eo params
272     ,scope:this
273     ,success: function(response, request){
274     var obj = Ext.util.JSON.decode(response.responseText) ;
275     for(var i = 0 ; i < this.grid.store.data.length ; ++i)
276     {
277     for(var j = 0 ;j < obj.rows.length; ++j)
278     {
279     if(this.grid.store.data.items[i].data.Tag == obj.rows[j].tag &&
280     this.grid.store.data.items[i].data.StartRun == obj.rows[j].run)
281     {
282     this.grid.store.data.items[i].data[btn.id] = obj.rows[j][btn.id] ;
283     }
284     } // eo loop on JSON response from AJAX
285     } // eo loop on grid rows
286     this.grid.getView().refresh() ;
287     this.loadMask.hide() ;
288     } //eo function success
289     } //eo Ajax
290     ); //eo Ajax.request
291     } //eo checkGridButton function
292     }
293     );
294    
295     Ext.reg('browseWindow', browseWindow_UI.Window);
296    
297