ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MRovere/ReferenceWebGUI/relValUploadWindow_UI.js
Revision: 1.3
Committed: Fri Mar 12 12:25:34 2010 UTC (15 years, 1 month ago) by rovere
Content type: application/javascript
Branch: MAIN
CVS Tags: JSON-release-pp-2012Nov23, JSON-release-pp-20121026, R01-00-00, HEAD
Changes since 1.2: +328 -328 lines
Error occurred while calculating annotation data.
Log Message:
* xmlTextArea_UI.js (Module): improved OO design, moving static
configuration stuff directly in the constructor, and not in the
initComponent method.

* uploadWindow_UI.js (Module): improved OO design, moving static
configuration stuff directly in the constructor, and not in the
initComponent method.

* subSysCombo_UI.js (Module): improved OO design, moving static
configuration stuff directly in the constructor, and not in the
initComponent method.

* relValUploadWindow_UI.js (Module): improved OO design, moving static
configuration stuff directly in the constructor, and not in the
initComponent method.

* refGridPanel_UI.js (Module): improved OO design, moving static
configuration stuff directly in the constructor, and not in the
initComponent method.

* localTagCombo_UI.js (Module): improved OO design, moving static
configuration stuff directly in the constructor, and not in the
initComponent method.

* fileUploadField_UI.js (Module): improved OO design, moving static
configuration stuff directly in the constructor, and not in the
initComponent method.

* dbsCombo_UI.js: improved OO design, moving static
configuration stuff directly in the constructor, and not in the
initComponent method.

* browseWindow_UI.js: improved OO design, moving static
configuration stuff directly in the constructor, and not in the
initComponent method.

File Contents

# Content
1 Ext.ns('relValUploadWindow_UI');
2
3 Ext.BLANK_IMAGE_URL = '/ext/resources/images/default/s.gif';
4
5 relValUploadWindow_UI.Window = Ext.extend(
6 Ext.Window,
7 {
8 consoleLog:false
9 ,constructor:function(config)
10 {
11 // hard coded config - cannot be changed from outside
12 var cfg =
13 {
14 items:{
15 xtype:'form'
16 // ,formId: 'newRecordForm'
17 ,id: 'newRecordFormId'
18 ,frame:true
19 ,defaults:{anchor:'-10'}
20 ,fileUpload: true
21 ,items:[
22 {
23 xtype: 'dbscombo'
24 ,noCache: false
25 ,consoleLog: false
26 }
27 ,{
28 xtype: 'localtagcombo'
29 ,noCache:true
30 ,consoleLog: false
31 ,forceSelection:false
32 // ,id: 'localtagcombo'
33 }
34 ,{
35 xtype:'subsyscombo'
36 ,noCache: true
37 ,consoleLog: false
38 ,forceSelection: false
39 }
40 ,{
41 xtype:'textfield'
42 ,fieldLabel: 'Version'
43 ,id: 'version'
44 }
45 ,{
46 xtype: 'xmlTextAreaUI'
47 ,consoleLog:false
48 ,parentForm: 'newRecordFormId'
49 ,grow: false
50 }
51 ] // eo form items
52 } // eo window items
53 ,buttons:[
54 {
55 text: 'Commit'
56 ,handler: this.commit
57 ,scope: this
58 },
59 {
60 text: 'Close'
61 ,handler: function(){window.location.href = '.';} // HORRIBLE!!!!
62 }
63 ] // oe buttons items
64 ,height: 'auto'
65 // ,y: 100
66 }; // eo config
67 // apply config
68 config = Ext.apply(cfg, config) ;
69
70 //call parent
71 relValUploadWindow_UI.Window.superclass.constructor.call(this, config);
72 if(this.consoleLog)
73 console.log('relValUploadWindow_UI.Window constructor called');
74 } // eo fcn constructor
75
76 // The next function MUST be called as a callback
77 // method of the show method. This is so because
78 // I need to refer to some components that are not there after the window rendered
79 // but are there only after the window is shown (the button
80 // for the goodRun new widget
81 ,setConnections:function()
82 {
83 if(this.consoleLog)
84 console.log('relValUploadWindow_UI.setConnections called') ;
85
86 // Install proper hooks to main windows components that have to communicate
87 // each others.
88 // We put them here because they already exists in the HTML document
89 var dbIndex = this.items.itemAt(0).items.findIndex('xtype', 'dbscombo') ;
90 this.db = this.items.itemAt(0).items.itemAt(dbIndex);
91 if(this.consoleLog)
92 console.log('relValUploadWindow_UI.onRender the Database cmp should be ', this.db) ;
93
94 var tagsIndex = this.items.itemAt(0).items.findIndex('xtype', 'localtagcombo') ;
95 this.tags = this.items.itemAt(0).items.itemAt(tagsIndex);
96 if(this.consoleLog)
97 console.log('relValUploadWindow_UI.onRender the local tags cmp should be ', this.tags) ;
98
99 var subsysIndex = this.items.itemAt(0).items.findIndex('xtype', 'subsyscombo') ;
100 this.subsystems = this.items.itemAt(0).items.itemAt(subsysIndex);
101 if(this.consoleLog)
102 console.log('relValUploadWindow_UI.onRender the subsystems cmp should be ', this.subsystems) ;
103
104 var versionIndex = this.items.itemAt(0).items.findIndex('fieldLabel', 'Version') ;
105 this.version = this.items.itemAt(0).items.itemAt(versionIndex);
106 if(this.consoleLog)
107 console.log('relValUploadWindow_UI.onRender the version cmp should be ', this.version) ;
108
109 var xmlUI = this.items.itemAt(0).items.findIndex('xtype', 'xmlTextAreaUI') ;
110 this.xmlTextArea = this.items.itemAt(0).items.itemAt(xmlUI);
111 this.loadFromPreviousBtn = this.items.itemAt(0).items.itemAt(xmlUI).loadFromPreviousButton;
112 if(this.consoleLog)
113 console.log('relValUploadWindow_UI.onRender the loadFromPrevious should be ', this.loadFromPreviousBtn) ;
114
115 // install communication between components using event handlers!!!!
116 // LOCAL TAGS BEHAVIOUR
117 this.tags.store.on(
118 {
119 scope:this
120 ,beforeload:this.addBaseParams
121 ,stopEvent:true
122 });
123
124 // SUBSYSTEM BEHAVIOUR
125 this.subsystems.store.on(
126 {
127 scope:this
128 ,beforeload:this.addBaseParams
129 ,stopEvent:true
130 });
131
132 // DATABASE BEHAVIOUR
133 this.db.on(
134 {
135 scope:this
136 ,select:function(){
137 if(this.consoleLog)
138 console.log('relValUploadWindow_UI.onRender: actual db value at \'select\' is: ', this.db.getValue());
139 if(this.db.getValue() !== this.db.oldState)
140 {
141 this.tags.store.setBaseParam('dbname', this.db.getValue());
142 this.subsystems.store.setBaseParam('dbname', this.db.getValue());
143 this.tags.clearValue();
144 this.subsystems.clearValue();
145 this.version.setValue('') ;
146 }
147 }
148 ,stopEvent:true
149 }
150 );
151
152 // LOAD FROM PREVIOUS BUTTON BEHAVIOUR
153 this.loadFromPreviousBtn.on(
154 {
155 scope: this
156 ,click:function(btn, event)
157 {
158 if(this.consoleLog)
159 console.log('RefuploadForm loadFromPreviousBtn fired a click event');
160 if(this.checkForm() ==0)
161 {
162 Ext.Ajax.request(
163 {
164 url : '/cgi-bin/ReferencePythonCLI/driver.py'
165 ,method : 'post'
166 ,params :
167 {
168 action: 'getPreviousXML'
169 ,dbname: this.db.getValue()
170 ,localtag: this.tags.getValue()
171 ,subsystem: this.subsystems.getValue()
172 ,specificRun: this.version.getValue()
173 }
174 ,success: function(response, request)
175 {
176 var obj = Ext.util.JSON.decode(response.responseText);
177 // debugger;
178 if(obj.rows.length > 0)
179 {
180 this.xmlTextArea.setValue(Base64.decode(obj.rows[0].XML)) ;
181 if(this.consoleLog)
182 console.log('uploadForm: setting xmlTextArea.validated to true');
183 this.xmlTextArea.validated = true ;
184 }
185 else
186 {
187 Ext.Msg.show(
188 {
189 title: 'Error'
190 ,msg: 'No data Available'
191 ,icon: Ext.MessageBox.INFO
192 ,buttons: Ext.Msg.OK
193 // ,width: 350
194 }) ;
195 }
196 }
197 // ,failure: this.parseResponse
198 ,scope:this
199 // success: parseData,
200 // failure: function() {Debbie.connectionLost(380,500) ;}
201 }
202 );
203 }
204 }
205 });
206 } // eo function setConnections
207
208 ,addBaseParams:function()
209 {
210 if(this.consoleLog)
211 console.log('relValUploadWindow_UI installing db name to stores\' base params: ', this.db.getValue());
212 this.tags.store.setBaseParam('dbname', this.db.getValue());
213 this.subsystems.store.setBaseParam('dbname', this.db.getValue());
214 }
215 ,checkForm: function()
216 {
217 var errors = '' ;
218 if(!this.db.getValue())
219 errors += 'Database is mandatory';
220 if(!this.tags.getValue())
221 errors += '<br/>LocalTag is mandatory';
222 if(!this.subsystems.getValue())
223 errors += '<br/>SubSystem is mandatory';
224 // if(!this.version.getValue())
225 // errors += '<br/>Since is mandatory';
226 if(errors !=='')
227 {
228 Ext.Msg.show(
229 {
230 title: 'Errors'
231 ,msg: errors
232 ,icon: Ext.MessageBox.QUESTION
233 ,buttons: Ext.Msg.OK
234 ,width: 350
235 }) ;
236 return 1;
237 }
238 return 0;
239 } // eo function checkForm
240 ,checkXML: function()
241 {
242 var errors = '' ;
243 if(!this.xmlTextArea.getValue())
244 errors += 'XML file is mandatory';
245 if(errors !=='')
246 {
247 Ext.Msg.show(
248 {
249 title: 'Errors'
250 ,msg: errors
251 ,icon: Ext.MessageBox.QUESTION
252 ,buttons: Ext.Msg.OK
253 ,width: 350
254 }) ;
255 return 1;
256 }
257 return 0;
258 } // eo function checkXML
259 ,commit: function(button, event)
260 {
261 // just quit if there are non filled form values
262 // the detailed alert message is displayed by
263 // the checkForm function
264 if(this.checkForm()==1)
265 return ;
266 if(this.checkXML() == 1)
267 return ;
268 if(!this.xmlTextArea.validated)
269 {
270 Ext.Msg.show(
271 {
272 title: 'Warning'
273 ,msg: 'Please validate XML before commiting to DB'
274 ,icon: Ext.MessageBox.QUESTION
275 ,buttons: Ext.Msg.OK
276 ,width: 350
277 }) ;
278 return ;
279 }
280 // Ask confirmation to the user and display a brief
281 // summary of what is going to be uploaded into DB
282 var mesg = 'Databse: ' + this.db.getValue() ;
283 mesg += '<br/>LocalTag: ' + this.tags.getValue() ;
284 mesg += '<br/>SubSystem: ' + this.subsystems.getValue() ;
285 // mesg += '<br/>Version: ' + this.version.getValue() ;
286 Ext.Msg.show(
287 {
288 title: 'Summary'
289 ,msg: mesg
290 ,icon: Ext.MessageBox.QUESTION
291 ,buttons: Ext.Msg.YESNO
292 ,width: 350
293 ,fn: this.doCommit
294 ,scope: this
295 }) ;
296 }// eo function commit
297 ,doCommit:function(btn, text)
298 {
299 if(btn == 'yes')
300 {
301 Ext.Ajax.request(
302 {
303 url : '/cgi-bin/ReferencePythonCLI/driver.py'
304 ,method : 'post'
305 ,params :
306 {
307 action: 'commitRelval'
308 ,xmlString : Base64.encode(this.xmlTextArea.getValue())
309 ,dbname: this.db.getValue()
310 ,localtag: this.tags.getValue()
311 ,subsystem: this.subsystems.getValue()
312 // ,specificRun: this.version.getValue()
313 }
314 ,scope:this
315 ,success: this.parseCommitResponse
316 // failure: function() {Debbie.connectionLost(380,500) ;}
317 }
318 );
319 }
320 } //eo function doCommit
321 ,parseCommitResponse: function(response, request)
322 {
323 var obj = Ext.util.JSON.decode(response.responseText) ;
324 var mesg = obj.loaded ? "OK" : "Failed" ;
325 if(!obj.loaded)
326 mesg += '<br/>Reason: ' + obj.err_msg ;
327 Ext.Msg.show(
328 {
329 title: 'Info'
330 ,msg: mesg
331 ,icon: Ext.MessageBox.INFO
332 ,buttons: Ext.Msg.OK
333 // ,width: 350
334 }) ;
335 }
336 }
337 );
338
339 Ext.reg('RelValUploadWindow', relValUploadWindow_UI.Window);
340
341