1 | var JobsDataStore; |
---|
2 | var JobsColumnModel; |
---|
3 | var JobListingEditorGrid; |
---|
4 | var JobListingWindow; |
---|
5 | var JobProxy; |
---|
6 | var myfilters = { }; |
---|
7 | var myparams = { }; |
---|
8 | |
---|
9 | var filterfields = [ "jid", "queue", "name", "owner" ]; |
---|
10 | |
---|
11 | function isset( somevar ) |
---|
12 | { |
---|
13 | try |
---|
14 | { |
---|
15 | if( eval( somevar ) ) { } |
---|
16 | } |
---|
17 | catch( err ) |
---|
18 | { |
---|
19 | return false; |
---|
20 | } |
---|
21 | return true; |
---|
22 | } |
---|
23 | |
---|
24 | function inMyArray( arr, someval ) |
---|
25 | { |
---|
26 | for( arval in arr ) |
---|
27 | { |
---|
28 | if( arval == someval ) |
---|
29 | { |
---|
30 | return true; |
---|
31 | } |
---|
32 | } |
---|
33 | return false; |
---|
34 | } |
---|
35 | |
---|
36 | function inMyArrayValues( arr, someval ) |
---|
37 | { |
---|
38 | for( arkey in arr ) |
---|
39 | { |
---|
40 | if( arr[arkey] == someval ) |
---|
41 | { |
---|
42 | return true; |
---|
43 | } |
---|
44 | } |
---|
45 | return false; |
---|
46 | } |
---|
47 | |
---|
48 | function inMyArrayKeys( arr, someval ) |
---|
49 | { |
---|
50 | for( arkey in arr ) |
---|
51 | { |
---|
52 | if( arkey == someval ) |
---|
53 | { |
---|
54 | return true; |
---|
55 | } |
---|
56 | } |
---|
57 | return false; |
---|
58 | } |
---|
59 | |
---|
60 | function joinMyArray( arr1, arr2 ) |
---|
61 | { |
---|
62 | for( arkey in arr2 ) |
---|
63 | { |
---|
64 | arr1[arkey] = arr2[arkey]; |
---|
65 | } |
---|
66 | |
---|
67 | return arr1; |
---|
68 | } |
---|
69 | |
---|
70 | function initJobGrid() { |
---|
71 | |
---|
72 | Ext.QuickTips.init(); |
---|
73 | |
---|
74 | function jobCellClick(grid, rowIndex, columnIndex, e) |
---|
75 | { |
---|
76 | var record = grid.getStore().getAt(rowIndex); // Get the Record |
---|
77 | var fieldName = grid.getColumnModel().getDataIndex(columnIndex); |
---|
78 | var data = record.get(fieldName); |
---|
79 | var view = grid.getView(); |
---|
80 | var cell = view.getCell( rowIndex, columnIndex ); |
---|
81 | |
---|
82 | if( fieldName == 'owner' || fieldName == 'jid' || fieldName == 'status' || fieldName == 'queue' ) |
---|
83 | { |
---|
84 | if( !isset( myfilters[fieldName] ) ) |
---|
85 | { |
---|
86 | Ext.fly(cell).removeClass( 'filterenabled' ); |
---|
87 | Ext.fly(cell).addClass( 'filter' ); |
---|
88 | |
---|
89 | // Remove this filter |
---|
90 | // |
---|
91 | delete myfilters[fieldName]; |
---|
92 | delete myparams[fieldName]; |
---|
93 | |
---|
94 | // Respect any other parameters that may have been set outside filters |
---|
95 | // |
---|
96 | myparams = joinMyArray( myparams, myfilters ); |
---|
97 | |
---|
98 | // Can't be sure if there are enough pages for new filter: reset to page 1 |
---|
99 | // |
---|
100 | myparams = joinMyArray( myparams, { start: 0, limit: 30 } ); |
---|
101 | |
---|
102 | grid.getStore().reload( { params: myparams } ); |
---|
103 | } |
---|
104 | else |
---|
105 | { |
---|
106 | Ext.fly(cell).removeClass( 'filter' ); |
---|
107 | Ext.fly(cell).addClass( 'filterenabled' ); |
---|
108 | |
---|
109 | // Set filter for selected column to selected cell value |
---|
110 | // |
---|
111 | myfilters[fieldName] = data; |
---|
112 | |
---|
113 | myparams = joinMyArray( myparams, myfilters ); |
---|
114 | myparams = joinMyArray( myparams, { start: 0, limit: 30 } ); |
---|
115 | |
---|
116 | grid.getStore().reload( { params: myparams } ); |
---|
117 | } |
---|
118 | } |
---|
119 | } |
---|
120 | |
---|
121 | function jobCellRender( value, metadata, record, rowindex, colindex, store ) |
---|
122 | { |
---|
123 | var fieldName = JobsColumnModel.getColumnById( colindex ).dataIndex; |
---|
124 | |
---|
125 | if( fieldName == 'owner' || fieldName == 'jid' || fieldName == 'status' || fieldName == 'queue' ) |
---|
126 | { |
---|
127 | if( myfilters[fieldName] != null ) |
---|
128 | { |
---|
129 | metadata.css = 'filterenabled'; |
---|
130 | } |
---|
131 | else |
---|
132 | { |
---|
133 | metadata.css = 'filter'; |
---|
134 | } |
---|
135 | } |
---|
136 | return value; |
---|
137 | } |
---|
138 | |
---|
139 | JobProxy = new Ext.data.HttpProxy({ |
---|
140 | url: 'jobstore.php', |
---|
141 | method: 'POST' |
---|
142 | }); |
---|
143 | |
---|
144 | JobsDataStore = new Ext.data.Store({ |
---|
145 | id: 'JobsDataStore', |
---|
146 | proxy: JobProxy, |
---|
147 | baseParams:{task: "LISTING"}, // this parameter is passed for any HTTP request |
---|
148 | reader: new Ext.data.JsonReader({ |
---|
149 | root: 'results', |
---|
150 | totalProperty: 'total', |
---|
151 | id: 'id' |
---|
152 | },[ |
---|
153 | {name: 'jid', type: 'int', mapping: 'jid'}, |
---|
154 | {name: 'status', type: 'string', mapping: 'status'}, |
---|
155 | {name: 'owner', type: 'string', mapping: 'owner'}, |
---|
156 | {name: 'queue', type: 'string', mapping: 'queue'}, |
---|
157 | {name: 'name', type: 'string', mapping: 'name'}, |
---|
158 | {name: 'requested_time', type: 'string', mapping: 'requested_time'}, |
---|
159 | //{name: 'requested_memory', type: 'string', mapping: 'requested_memory'}, |
---|
160 | {name: 'ppn', type: 'int', mapping: 'ppn'}, |
---|
161 | {name: 'nodect', type: 'int', mapping: 'nodect'}, |
---|
162 | {name: 'nodes', type: 'string', mapping: 'nodes'}, |
---|
163 | {name: 'queued_timestamp', type: 'string', mapping: 'queued_timestamp'}, |
---|
164 | {name: 'start_timestamp', type: 'string', mapping: 'start_timestamp'}, |
---|
165 | {name: 'runningtime', type: 'string', mapping: 'runningtime'} |
---|
166 | ]), |
---|
167 | sortInfo: {field: 'jid', direction: "ASC"}, |
---|
168 | remoteSort: true |
---|
169 | }); |
---|
170 | |
---|
171 | JobsColumnModel = new Ext.grid.ColumnModel( |
---|
172 | [{ |
---|
173 | header: '#', |
---|
174 | tooltip: 'Job id', |
---|
175 | readOnly: true, |
---|
176 | dataIndex: 'jid', |
---|
177 | width: 50, |
---|
178 | hidden: false, |
---|
179 | renderer: jobCellRender |
---|
180 | },{ |
---|
181 | header: 'S', |
---|
182 | tooltip: 'Job status', |
---|
183 | readOnly: true, |
---|
184 | dataIndex: 'status', |
---|
185 | width: 20, |
---|
186 | hidden: false, |
---|
187 | renderer: jobCellRender |
---|
188 | },{ |
---|
189 | header: 'User', |
---|
190 | tooltip: 'Owner of job', |
---|
191 | readOnly: true, |
---|
192 | dataIndex: 'owner', |
---|
193 | width: 60, |
---|
194 | hidden: false, |
---|
195 | renderer: jobCellRender |
---|
196 | },{ |
---|
197 | header: 'Queue', |
---|
198 | tooltip: 'In which queue does this job reside', |
---|
199 | readOnly: true, |
---|
200 | dataIndex: 'queue', |
---|
201 | width: 60, |
---|
202 | hidden: false, |
---|
203 | renderer: jobCellRender |
---|
204 | },{ |
---|
205 | header: 'Name', |
---|
206 | tooltip: 'Name of job', |
---|
207 | readOnly: true, |
---|
208 | dataIndex: 'name', |
---|
209 | width: 100, |
---|
210 | hidden: false |
---|
211 | },{ |
---|
212 | header: 'Requested Time', |
---|
213 | tooltip: 'Amount of requested time (wallclock)', |
---|
214 | readOnly: true, |
---|
215 | dataIndex: 'requested_time', |
---|
216 | width: 100, |
---|
217 | hidden: false |
---|
218 | },{ |
---|
219 | header: 'Requested Memory', |
---|
220 | tooltip: 'Amount of requested memory', |
---|
221 | readOnly: true, |
---|
222 | dataIndex: 'requested_memory', |
---|
223 | width: 100, |
---|
224 | hidden: true |
---|
225 | },{ |
---|
226 | header: 'P', |
---|
227 | tooltip: 'Number of processors per node (PPN)', |
---|
228 | readOnly: true, |
---|
229 | dataIndex: 'ppn', |
---|
230 | width: 25, |
---|
231 | hidden: false |
---|
232 | },{ |
---|
233 | header: 'N', |
---|
234 | tooltip: 'Number of nodes (hosts)', |
---|
235 | readOnly: true, |
---|
236 | dataIndex: 'nodect', |
---|
237 | width: 25, |
---|
238 | hidden: false |
---|
239 | },{ |
---|
240 | header: 'Nodes', |
---|
241 | readOnly: true, |
---|
242 | dataIndex: 'nodes', |
---|
243 | width: 100, |
---|
244 | hidden: true |
---|
245 | },{ |
---|
246 | header: 'Queued', |
---|
247 | tooltip: 'At what time did this job enter the queue', |
---|
248 | readOnly: true, |
---|
249 | dataIndex: 'queued_timestamp', |
---|
250 | width: 140, |
---|
251 | hidden: false |
---|
252 | },{ |
---|
253 | header: 'Started', |
---|
254 | tooltip: 'At what time did this job enter the running status', |
---|
255 | readOnly: true, |
---|
256 | dataIndex: 'start_timestamp', |
---|
257 | width: 140, |
---|
258 | hidden: false |
---|
259 | },{ |
---|
260 | header: 'Runningtime', |
---|
261 | tooltip: 'How long has this job been in the running status', |
---|
262 | readOnly: true, |
---|
263 | dataIndex: 'runningtime', |
---|
264 | width: 140, |
---|
265 | hidden: false |
---|
266 | }] |
---|
267 | ); |
---|
268 | JobsColumnModel.defaultSortable= true; |
---|
269 | |
---|
270 | JobListingEditorGrid = new Ext.grid.EditorGridPanel({ |
---|
271 | id: 'JobListingEditorGrid', |
---|
272 | store: JobsDataStore, |
---|
273 | cm: JobsColumnModel, |
---|
274 | enableColLock:false, |
---|
275 | clicksToEdit:1, |
---|
276 | loadMask: true, |
---|
277 | selModel: new Ext.grid.RowSelectionModel({singleSelect:false}), |
---|
278 | bbar: new Ext.PagingToolbar({ |
---|
279 | pageSize: 30, |
---|
280 | store: JobsDataStore, |
---|
281 | displayInfo: true, |
---|
282 | displayMsg: 'Displaying jobs {0} - {1} out of {2} jobs total found.', |
---|
283 | emptyMsg: 'No jobs found to display' |
---|
284 | }), |
---|
285 | tbar: [ new Ext.app.SearchField({ |
---|
286 | store: JobsDataStore, |
---|
287 | params: {start: 0, limit: 30}, |
---|
288 | width: 200 |
---|
289 | }) |
---|
290 | ] |
---|
291 | }); |
---|
292 | |
---|
293 | JobListingWindow = new Ext.Window({ |
---|
294 | id: 'JobListingWindow', |
---|
295 | title: 'Cluster Jobs Overview', |
---|
296 | closable:true, |
---|
297 | collapsible: true, |
---|
298 | animCollapse: true, |
---|
299 | maximizable: true, |
---|
300 | width:900, |
---|
301 | height:500, |
---|
302 | plain:true, |
---|
303 | shadow: true, |
---|
304 | shadowOffset: 10, |
---|
305 | layout: 'fit', |
---|
306 | items: JobListingEditorGrid |
---|
307 | }); |
---|
308 | |
---|
309 | JobListingEditorGrid.addListener( 'cellclick', jobCellClick ); |
---|
310 | } |
---|