ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MRovere/ReferenceWebGUI/browseWindow_UI.js
Revision: 1.4
Committed: Tue May 18 09:33:52 2010 UTC (14 years, 11 months ago) by rovere
Content type: application/javascript
Branch: MAIN
CVS Tags: JSON-release-pp-2012Nov23, JSON-release-pp-20121026, HEAD
Changes since 1.3: +38 -140 lines
Error occurred while calculating annotation data.
Log Message:
* browseWindow_UI.js, dbsCombo_UI.js, goodForRun_UI.js,
localTagCombo_UI.js, subSysCombo_UI.js, uploadWindow_UI.js,
xmlTextArea_UI.js: All the logic of the connections between the
component of the window has been moved the the new Event Manager.
Minor stylish changes.

File Contents

# Content
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 if(r[x]==this[i])
9 continue o;
10 r[r.length] = this[i];
11 }
12 return r;
13 };
14
15 //var nextOne = true ;
16 Ext.BLANK_IMAGE_URL = '/ext/resources/images/default/s.gif';
17
18 browseWindow_UI.Window = Ext.extend(
19 Ext.Window,
20 {
21 consoleLog:false
22 ,constructor: function(config)
23 {
24 // Create a new config object containing our computed properties
25 // *plus* whatever was in the config parameter.
26 var cfg =
27 {
28 items:{
29 xtype:'form'
30 ,frame:true
31 ,defaults:{anchor:'-20'}
32 ,items:[
33 {
34 xtype: 'dbscombo'
35 ,noCache: false
36 ,consoleLog: false
37 }
38 ,{
39 xtype: 'localtagcombo'
40 ,noCache:true
41 ,consoleLog: false
42 // ,id: 'localtagcombo'
43 }
44 ,{
45 xtype:'subsyscombo'
46 ,noCache: true
47 ,consoleLog: false
48 }
49 ,{
50 xtype: 'goodforrunUI'
51 ,consoleLog: false
52 , buttonLabel: 'Select'
53 }
54 ,{
55 xtype: 'refgridpanel'
56 ,consoleLog: false
57 }
58 ]
59 }
60 }; // eo cfg
61 // Now we copy our own ad-hoc static configuration on top of the actual one
62 // given at construction time. The receiving object is cfg, the source is config.
63 // The returned object is the sum of the 2, stored again in config.
64 config = Ext.apply(cfg, config);
65
66 browseWindow_UI.Window.superclass.constructor.call(this, config);
67 }
68
69 // The next function MUST be called as a callback
70 // method of the show method. This is so because
71 // I need to refer to some components that are not there after the window rendered
72 // but are there only after the window is shown (the button
73 // for the goodRun new widget
74 ,setConnections:function(){
75 if(this.consoleLog)
76 console.log('browseWindow_UI.setConnections called') ;
77
78 // Install proper hooks to main windows components that have to communicate
79 // each others.
80 // We put them here because they already exists in the HTML document
81 var dbIndex = this.items.itemAt(0).items.findIndex('xtype', 'dbscombo') ;
82 this.db = this.items.itemAt(0).items.itemAt(dbIndex);
83 if(this.consoleLog)
84 console.log('browseWindow_UI.onRender the Database cmp should be ', this.db) ;
85
86 var tagsIndex = this.items.itemAt(0).items.findIndex('xtype', 'localtagcombo') ;
87 this.tags = this.items.itemAt(0).items.itemAt(tagsIndex);
88 if(this.consoleLog)
89 console.log('browseWindow_UI.onRender the local tags cmp should be ', this.tags) ;
90
91 var subsysIndex = this.items.itemAt(0).items.findIndex('xtype', 'subsyscombo') ;
92 this.subsystems = this.items.itemAt(0).items.itemAt(subsysIndex);
93 if(this.consoleLog)
94 console.log('browseWindow_UI.onRender the subsystems cmp should be ', this.subsystems) ;
95
96 var gridIndex = this.items.itemAt(0).items.findIndex('xtype', 'refgridpanel') ;
97 this.grid = this.items.itemAt(0).items.itemAt(gridIndex);
98 if(this.consoleLog)
99 console.log('browseWindow_UI.onRender the main grid cmp should be ', this.grid) ;
100
101 this.grid_prep = this.grid.getBottomToolbar().findById('cms_orcoff_prep') ;
102 if(this.consoleLog)
103 console.log('browseWindow_UI.onRender the orcoff_prep Button cmp should be ',this.grid_prep) ;
104
105 this.grid_prod = this.grid.getBottomToolbar().findById('cms_orcoff_prod') ;
106 if(this.consoleLog)
107 console.log('browseWindow_UI.onRender the orcoff_prod Button cmp should be ', this.grid_prod) ;
108
109 var goodrunIndex = this.items.itemAt(0).items.findIndex('xtype', 'goodforrunUI') ;
110 this.goodRun = this.items.itemAt(0).items.itemAt(goodrunIndex);
111 if(this.consoleLog)
112 console.log('browseWindow_UI.onRender the main GoodRun cmp should be ', this.goodRun) ;
113
114 // install communication between components using event handlers!!!!
115
116 // GRID TOOLBAR BUTTON BEHAVIOR
117 /*
118 this.grid_prep.on(
119 {
120 scope: this
121 ,click: this.checkGridButton
122 }
123 );
124 */
125 this.grid_prod.on({ scope: this
126 ,click: this.checkGridButton});
127
128 MyApp.eventManager.on('selectedDB', function(value)
129 { this.grid.store.setBaseParam('dbname', value);
130 this.grid.store.load();}, this);
131 MyApp.eventManager.on('SubsysSelected', function(value)
132 { this.grid.store.setBaseParam('subsystem', value);
133 this.grid.store.load();}, this);
134 MyApp.eventManager.on('LTSelected', function(value)
135 { this.grid.store.setBaseParam('localtag', value);
136 this.grid.store.load();}, this);
137 MyApp.eventManager.on('GoodForRunClicked', function(value)
138 { this.grid.store.setBaseParam('specificRun', value);
139 this.grid.store.load();}, this);
140 } // eo function setConnections
141
142 ,checkGridButton:function(btn, evt)
143 {
144 var tags_runs = new Array() ;
145 for(var i = 0 ; i < this.grid.store.data.length ; ++i)
146 {
147 tags_runs[i] = this.grid.store.data.items[i].data.Tag + '--StartRun_' + this.grid.store.data.items[i].data.StartRun ;
148 }
149 tags_runs = tags_runs.unique() ;
150 var tag = '' ;
151 var run = '' ;
152 for(var j = 0 ; j <tags_runs.length ; ++j)
153 {
154 var tagrun = tags_runs[j].split(/--StartRun_/) ;
155 tag += tagrun[0] + (j==tags_runs.length-1 ? '' : '-@-') ;
156 run += tagrun[1] + (j==tags_runs.length-1 ? '' : '-') ;
157 }
158 // this.loadMask.show() ;
159 Ext.Ajax.request(
160 {
161 url : '/cgi-bin/ReferencePythonCLI/driver.py'
162 ,method : 'post'
163 ,params :
164 {
165 action: 'checkDB'
166 ,db: btn.id
167 ,tag: tag
168 ,run: run
169 } // eo params
170 ,scope:this
171 ,success: function(response, request){
172 var obj = Ext.util.JSON.decode(response.responseText) ;
173 for(var i = 0 ; i < this.grid.store.data.length ; ++i)
174 {
175 for(var j = 0 ;j < obj.rows.length; ++j)
176 {
177 if(this.grid.store.data.items[i].data.Tag == obj.rows[j].tag &&
178 this.grid.store.data.items[i].data.StartRun == obj.rows[j].run)
179 {
180 this.grid.store.data.items[i].data[btn.id] = obj.rows[j][btn.id] ;
181 }
182 } // eo loop on JSON response from AJAX
183 } // eo loop on grid rows
184 this.grid.getView().refresh() ;
185 // this.loadMask.hide() ;
186 } //eo function success
187 } //eo Ajax
188 ); //eo Ajax.request
189 } //eo checkGridButton function
190 }
191 );
192
193 Ext.reg('browseWindow', browseWindow_UI.Window);
194
195