1 | var JobsDataStore; |
---|
2 | var JobsColumnModel; |
---|
3 | var JobListingEditorGrid; |
---|
4 | var JobListingWindow; |
---|
5 | var JobProxy; |
---|
6 | var SearchField; |
---|
7 | var filterButton; |
---|
8 | var myfilters = { }; |
---|
9 | var myparams = { }; |
---|
10 | var mylimit = 15; |
---|
11 | var ClusterImageArgs = { }; |
---|
12 | |
---|
13 | var filterfields = [ "jid", "queue", "name", "owner" ]; |
---|
14 | |
---|
15 | var filterMenu = new Ext.menu.Menu({ |
---|
16 | id: 'filterMenu', |
---|
17 | items: [ new Ext.menu.Item({ text: 'Clear all', handler: clearFilters }) ] |
---|
18 | }); |
---|
19 | |
---|
20 | var filterButton = new Ext.MenuButton({ |
---|
21 | id: 'filtermenuknop', |
---|
22 | text: 'Filters', |
---|
23 | disabled: true, |
---|
24 | menu: filterMenu |
---|
25 | }); |
---|
26 | |
---|
27 | Ext.namespace('Ext.ux'); |
---|
28 | |
---|
29 | Ext.ux.PageSizePlugin = function() { |
---|
30 | Ext.ux.PageSizePlugin.superclass.constructor.call(this, { |
---|
31 | store: new Ext.data.SimpleStore({ |
---|
32 | fields: ['text', 'value'], |
---|
33 | data: [['10', 10], ['15', 15], ['20', 20], ['30', 30], ['50', 50], ['100', 100], ['max', 'max' ]] |
---|
34 | }), |
---|
35 | mode: 'local', |
---|
36 | displayField: 'text', |
---|
37 | valueField: 'value', |
---|
38 | editable: false, |
---|
39 | allowBlank: false, |
---|
40 | triggerAction: 'all', |
---|
41 | width: 40 |
---|
42 | }); |
---|
43 | }; |
---|
44 | |
---|
45 | Ext.extend(Ext.ux.PageSizePlugin, Ext.form.ComboBox, { |
---|
46 | init: function(paging) { |
---|
47 | paging.on('render', this.onInitView, this); |
---|
48 | }, |
---|
49 | |
---|
50 | onInitView: function(paging) { |
---|
51 | paging.add('-', |
---|
52 | this, |
---|
53 | 'jobs per page' |
---|
54 | ); |
---|
55 | this.setValue(paging.pageSize); |
---|
56 | this.on('select', this.onPageSizeChanged, paging); |
---|
57 | }, |
---|
58 | |
---|
59 | onPageSizeChanged: function(combo) { |
---|
60 | if ( combo.getValue() == 'max' ) |
---|
61 | mylimit = JobsDataStore.getTotalCount(); |
---|
62 | else |
---|
63 | mylimit = parseInt(combo.getValue()); |
---|
64 | this.pageSize = mylimit; |
---|
65 | this.doLoad(0); |
---|
66 | } |
---|
67 | }); |
---|
68 | |
---|
69 | Ext.namespace( 'Ext' ); |
---|
70 | |
---|
71 | function clearFilters() |
---|
72 | { |
---|
73 | if( inMyArrayKeys( myfilters, 'query' ) ) |
---|
74 | { |
---|
75 | SearchField.getEl().dom.value = ''; |
---|
76 | delete SearchField.store.baseParams['query']; |
---|
77 | delete myfilters['query']; |
---|
78 | delete myparams['query']; |
---|
79 | } |
---|
80 | if( inMyArrayKeys( myfilters, 'host' ) ) |
---|
81 | { |
---|
82 | delete myfilters['host']; |
---|
83 | delete myparams['host']; |
---|
84 | } |
---|
85 | if( inMyArrayKeys( myfilters, 'jid' ) ) |
---|
86 | { |
---|
87 | delete myfilters['jid']; |
---|
88 | delete myparams['jid']; |
---|
89 | } |
---|
90 | if( inMyArrayKeys( myfilters, 'queue' ) ) |
---|
91 | { |
---|
92 | delete myfilters['queue']; |
---|
93 | delete myparams['queue']; |
---|
94 | } |
---|
95 | if( inMyArrayKeys( myfilters, 'owner' ) ) |
---|
96 | { |
---|
97 | delete myfilters['owner']; |
---|
98 | delete myparams['owner']; |
---|
99 | } |
---|
100 | if( inMyArrayKeys( myfilters, 'status' ) ) |
---|
101 | { |
---|
102 | delete myfilters['status']; |
---|
103 | delete myparams['status']; |
---|
104 | } |
---|
105 | reloadJobStore(); |
---|
106 | } |
---|
107 | |
---|
108 | function makeArrayURL( somearr ) |
---|
109 | { |
---|
110 | filter_url = ''; |
---|
111 | filter_sep = ''; |
---|
112 | |
---|
113 | for( filtername in somearr ) |
---|
114 | { |
---|
115 | filter_url = filter_url + filter_sep + filtername + '=' + somearr[filtername]; |
---|
116 | filter_sep = '&'; |
---|
117 | } |
---|
118 | |
---|
119 | return filter_url; |
---|
120 | } |
---|
121 | |
---|
122 | |
---|
123 | function isset( somevar ) |
---|
124 | { |
---|
125 | try |
---|
126 | { |
---|
127 | if( eval( somevar ) ) { } |
---|
128 | } |
---|
129 | catch( err ) |
---|
130 | { |
---|
131 | return false; |
---|
132 | } |
---|
133 | return true; |
---|
134 | } |
---|
135 | |
---|
136 | function inMyArray( arr, someval ) |
---|
137 | { |
---|
138 | for( arval in arr ) |
---|
139 | { |
---|
140 | if( arval == someval ) |
---|
141 | { |
---|
142 | return true; |
---|
143 | } |
---|
144 | } |
---|
145 | return false; |
---|
146 | } |
---|
147 | |
---|
148 | function ArraySize( arr ) |
---|
149 | { |
---|
150 | count = 0; |
---|
151 | |
---|
152 | for( arkey in arr ) |
---|
153 | { |
---|
154 | count = count + 1; |
---|
155 | } |
---|
156 | |
---|
157 | return count; |
---|
158 | } |
---|
159 | |
---|
160 | function inMyArrayValues( arr, someval ) |
---|
161 | { |
---|
162 | for( arkey in arr ) |
---|
163 | { |
---|
164 | if( arr[arkey] == someval ) |
---|
165 | { |
---|
166 | return true; |
---|
167 | } |
---|
168 | } |
---|
169 | return false; |
---|
170 | } |
---|
171 | |
---|
172 | function inMyArrayKeys( arr, someval ) |
---|
173 | { |
---|
174 | for( arkey in arr ) |
---|
175 | { |
---|
176 | if( arkey == someval ) |
---|
177 | { |
---|
178 | return true; |
---|
179 | } |
---|
180 | } |
---|
181 | return false; |
---|
182 | } |
---|
183 | |
---|
184 | function joinMyArray( arr1, arr2 ) |
---|
185 | { |
---|
186 | for( arkey in arr2 ) |
---|
187 | { |
---|
188 | arr1[arkey] = arr2[arkey]; |
---|
189 | } |
---|
190 | |
---|
191 | return arr1; |
---|
192 | } |
---|
193 | |
---|
194 | function ClusterImageSelectHost( somehost ) |
---|
195 | { |
---|
196 | |
---|
197 | if( !inMyArrayKeys( myfilters, 'host' ) ) |
---|
198 | { |
---|
199 | myfilters['host'] = somehost; |
---|
200 | } |
---|
201 | else |
---|
202 | { |
---|
203 | if( myfilters['host'] == somehost ) |
---|
204 | { |
---|
205 | delete myfilters['host']; |
---|
206 | delete myparams['host']; |
---|
207 | } |
---|
208 | else |
---|
209 | { |
---|
210 | myfilters['host'] = somehost; |
---|
211 | } |
---|
212 | } |
---|
213 | |
---|
214 | reloadClusterImage(); |
---|
215 | reloadJobStore(); |
---|
216 | |
---|
217 | return false; |
---|
218 | } |
---|
219 | |
---|
220 | function reloadJobStore() |
---|
221 | { |
---|
222 | // Respect any other parameters that may have been set outside filters |
---|
223 | // |
---|
224 | myparams = joinMyArray( myparams, myfilters ); |
---|
225 | |
---|
226 | // Can't be sure if there are enough pages for new filter: reset to page 1 |
---|
227 | // |
---|
228 | myparams = joinMyArray( myparams, { start: 0, limit: mylimit } ); |
---|
229 | |
---|
230 | JobsDataStore.reload( { params: myparams } ); |
---|
231 | } |
---|
232 | |
---|
233 | function addListener(element, type, expression, bubbling) |
---|
234 | { |
---|
235 | bubbling = bubbling || false; |
---|
236 | if(window.addEventListener) |
---|
237 | { // Standard |
---|
238 | element.addEventListener(type, expression, bubbling); |
---|
239 | return true; |
---|
240 | } |
---|
241 | else if(window.attachEvent) |
---|
242 | { // IE |
---|
243 | element.attachEvent('on' + type, expression); |
---|
244 | return true; |
---|
245 | } |
---|
246 | else |
---|
247 | return false; |
---|
248 | } |
---|
249 | |
---|
250 | function makeFilterString() |
---|
251 | { |
---|
252 | var filter_str = ''; |
---|
253 | |
---|
254 | for( arkey in myfilters ) |
---|
255 | { |
---|
256 | filter_str = filter_str + ' > ' + myfilters[arkey]; |
---|
257 | } |
---|
258 | |
---|
259 | return filter_str; |
---|
260 | } |
---|
261 | |
---|
262 | var ImageLoader = function( id, url ) |
---|
263 | { |
---|
264 | this.url = url; |
---|
265 | this.image = document.getElementById( id ); |
---|
266 | this.loadEvent = null; |
---|
267 | }; |
---|
268 | |
---|
269 | ImageLoader.prototype = |
---|
270 | { |
---|
271 | load:function() |
---|
272 | { |
---|
273 | var url = this.url; |
---|
274 | var image = this.image; |
---|
275 | var loadEvent = this.loadEvent; |
---|
276 | addListener( this.image, 'load', function(e) |
---|
277 | { |
---|
278 | if( loadEvent != null ) |
---|
279 | { |
---|
280 | loadEvent( url, image ); |
---|
281 | } |
---|
282 | }, false); |
---|
283 | this.image.src = this.url; |
---|
284 | }, |
---|
285 | getImage: function() |
---|
286 | { |
---|
287 | return this.image; |
---|
288 | } |
---|
289 | }; |
---|
290 | |
---|
291 | function achorJobListing() |
---|
292 | { |
---|
293 | JobListingWindow.anchorTo( "ClusterImageWindow", "tr-br", [ 0, 10 ] ); |
---|
294 | } |
---|
295 | |
---|
296 | function setClusterImagePosition() |
---|
297 | { |
---|
298 | ci_x = (window.innerWidth - ClusterImageWindow.getSize()['width'] - 20); |
---|
299 | ClusterImageWindow.setPosition( ci_x, 10 ); |
---|
300 | } |
---|
301 | |
---|
302 | function deselectFilterMenu( menuItem, event ) |
---|
303 | { |
---|
304 | filterValue = menuItem.text; |
---|
305 | |
---|
306 | if( filterValue == SearchField.getEl().dom.value && inMyArrayKeys( myfilters, 'query' ) ) |
---|
307 | { |
---|
308 | SearchField.getEl().dom.value = ''; |
---|
309 | delete SearchField.store.baseParams['query']; |
---|
310 | } |
---|
311 | |
---|
312 | for( arkey in myfilters ) |
---|
313 | { |
---|
314 | if( myfilters[arkey] == filterValue ) |
---|
315 | { |
---|
316 | delete myfilters[arkey]; |
---|
317 | delete myparams[arkey]; |
---|
318 | } |
---|
319 | } |
---|
320 | reloadJobStore(); |
---|
321 | } |
---|
322 | |
---|
323 | function makeFilterMenu() |
---|
324 | { |
---|
325 | var filterMenu = new Ext.menu.Menu({ |
---|
326 | id: 'filterMenu', |
---|
327 | items: [ new Ext.menu.Item({ text: 'Clear all', handler: clearFilters }) ] |
---|
328 | }); |
---|
329 | |
---|
330 | if( ArraySize( myfilters ) > 0 ) |
---|
331 | { |
---|
332 | filterMenu.addSeparator(); |
---|
333 | } |
---|
334 | |
---|
335 | for( arkey in myfilters ) |
---|
336 | { |
---|
337 | filterMenu.add( new Ext.menu.CheckItem({ text: myfilters[arkey], handler: deselectFilterMenu, checked: true }) ); |
---|
338 | } |
---|
339 | |
---|
340 | if( filterButton ) |
---|
341 | { |
---|
342 | filterButton.menu = filterMenu; |
---|
343 | |
---|
344 | if( ArraySize( myfilters ) > 0 ) |
---|
345 | { |
---|
346 | filterButton.enable(); |
---|
347 | } |
---|
348 | else |
---|
349 | { |
---|
350 | filterButton.disable(); |
---|
351 | } |
---|
352 | } |
---|
353 | } |
---|
354 | |
---|
355 | function reloadClusterImage() |
---|
356 | { |
---|
357 | ClusterImageArgs['view'] = 'big-clusterimage'; |
---|
358 | |
---|
359 | filt_url = makeArrayURL( myfilters ); |
---|
360 | imag_url = makeArrayURL( ClusterImageArgs ); |
---|
361 | img_url = './image.php?' + filt_url + '&' + imag_url; |
---|
362 | |
---|
363 | var newClusterImage = new ImageLoader( 'clusterimage', img_url ); |
---|
364 | newClusterImage.loadEvent = function( url, image ) |
---|
365 | { |
---|
366 | ClusterImageWindow.getBottomToolbar().clearStatus( { useDefaults:true } ); |
---|
367 | setTimeout( "resizeClusterImage()", 250 ); |
---|
368 | setTimeout( "setClusterImagePosition()", 500 ); |
---|
369 | //setTimeout( "achorJobListing()", 1000 ); |
---|
370 | } |
---|
371 | |
---|
372 | ClusterImageWindow.getBottomToolbar().showBusy(); |
---|
373 | |
---|
374 | filter_str = 'Nodes' + makeFilterString(); |
---|
375 | ClusterImageWindow.setTitle( filter_str ); |
---|
376 | |
---|
377 | newClusterImage.load(); |
---|
378 | } |
---|
379 | |
---|
380 | function resizeClusterImage() |
---|
381 | { |
---|
382 | var ci_height = document.getElementById( "clusterimage" ).height + ClusterImageWindow.getFrameHeight(); |
---|
383 | var ci_width = document.getElementById( "clusterimage" ).width + ClusterImageWindow.getFrameWidth(); |
---|
384 | |
---|
385 | ClusterImageWindow.setSize( ci_width, ci_height ); |
---|
386 | } |
---|
387 | |
---|
388 | Ext.apply(Ext.form.VTypes, { |
---|
389 | num: function(val, field) { |
---|
390 | |
---|
391 | if (val) { |
---|
392 | var strValidChars = "0123456789"; |
---|
393 | var blnResult = true; |
---|
394 | |
---|
395 | if (val.length == 0) return false; |
---|
396 | |
---|
397 | // test strString consists of valid characters listed above |
---|
398 | for (i = 0; i < val.length && blnResult == true; i++) |
---|
399 | { |
---|
400 | strChar = val.charAt(i); |
---|
401 | if (strValidChars.indexOf(strChar) == -1) |
---|
402 | { |
---|
403 | blnResult = false; |
---|
404 | } |
---|
405 | } |
---|
406 | return blnResult; |
---|
407 | |
---|
408 | } |
---|
409 | }, |
---|
410 | numText: 'Must be numeric' |
---|
411 | }); |
---|
412 | |
---|
413 | function initJobGrid() { |
---|
414 | |
---|
415 | Ext.QuickTips.init(); |
---|
416 | |
---|
417 | function jobRowSelect( selModel ) |
---|
418 | { |
---|
419 | if( selModel.hasSelection() ) |
---|
420 | { |
---|
421 | showGraphsButton.enable(); |
---|
422 | } |
---|
423 | else |
---|
424 | { |
---|
425 | showGraphsButton.disable(); |
---|
426 | } |
---|
427 | } |
---|
428 | |
---|
429 | function jobCellClick(grid, rowIndex, columnIndex, e) |
---|
430 | { |
---|
431 | var record = grid.getStore().getAt(rowIndex); // Get the Record |
---|
432 | var fieldName = grid.getColumnModel().getDataIndex(columnIndex); |
---|
433 | var data = record.get(fieldName); |
---|
434 | var view = grid.getView(); |
---|
435 | var cell = view.getCell( rowIndex, columnIndex ); |
---|
436 | var filter_title = false; |
---|
437 | var fil_dis = 'filter'; |
---|
438 | var fil_ena = 'filterenabled'; |
---|
439 | var filterName = fieldName; |
---|
440 | |
---|
441 | if( fieldName == 'owner' || fieldName == 'jid' || fieldName == 'status' || fieldName == 'queue' || fieldName == 'nodes') |
---|
442 | { |
---|
443 | if( fieldName == 'nodes' ) |
---|
444 | { |
---|
445 | filterName = 'host'; |
---|
446 | fil_dis = 'nodesfilter'; |
---|
447 | fil_ena = 'nodesfilterenabled'; |
---|
448 | } |
---|
449 | if( inMyArrayKeys( myfilters, filterName ) ) |
---|
450 | { |
---|
451 | Ext.fly(cell).removeClass( fil_ena ); |
---|
452 | Ext.fly(cell).addClass( fil_dis ); |
---|
453 | |
---|
454 | // Remove this filter |
---|
455 | // |
---|
456 | delete myfilters[filterName]; |
---|
457 | delete myparams[filterName]; |
---|
458 | |
---|
459 | reloadJobStore(); |
---|
460 | //reloadClusterImage(); |
---|
461 | } |
---|
462 | else |
---|
463 | { |
---|
464 | Ext.fly(cell).removeClass( fil_dis ); |
---|
465 | Ext.fly(cell).addClass( fil_ena ); |
---|
466 | |
---|
467 | if( fieldName == 'nodes' ) |
---|
468 | { // Get the first node (master mom) as node filter |
---|
469 | new_data = data.split( ',' )[0]; |
---|
470 | data = new_data; |
---|
471 | } |
---|
472 | |
---|
473 | // Set filter for selected column to selected cell value |
---|
474 | // |
---|
475 | myfilters[filterName] = data; |
---|
476 | |
---|
477 | reloadJobStore(); |
---|
478 | //reloadClusterImage(); |
---|
479 | } |
---|
480 | JobListingWindow.setTitle( filter_str ); |
---|
481 | filter_title = true; |
---|
482 | filter_str = myparams.c + ' Jobs Overview' + makeFilterString(); |
---|
483 | } |
---|
484 | } |
---|
485 | |
---|
486 | function jobCellRender( value, metadata, record, rowindex, colindex, store ) |
---|
487 | { |
---|
488 | var fieldName = JobsColumnModel.getColumnById( colindex ).dataIndex; |
---|
489 | var fil_dis = 'filter'; |
---|
490 | var fil_ena = 'filterenabled'; |
---|
491 | var filterName = fieldName; |
---|
492 | |
---|
493 | if( fieldName == 'owner' || fieldName == 'jid' || fieldName == 'status' || fieldName == 'queue' || fieldName == 'nodes' ) |
---|
494 | { |
---|
495 | if( fieldName == 'nodes' ) |
---|
496 | { |
---|
497 | fil_dis = 'nodesfilter'; |
---|
498 | fil_ena = 'nodesfilterenabled'; |
---|
499 | filterName = 'host'; |
---|
500 | } |
---|
501 | if( myfilters[filterName] != null ) |
---|
502 | { |
---|
503 | metadata.css = fil_ena; |
---|
504 | } |
---|
505 | else |
---|
506 | { |
---|
507 | metadata.css = fil_dis; |
---|
508 | } |
---|
509 | } |
---|
510 | return value; |
---|
511 | } |
---|
512 | |
---|
513 | JobProxy = new Ext.data.HttpProxy({ |
---|
514 | url: 'jobstore.php', |
---|
515 | method: 'POST' |
---|
516 | }); |
---|
517 | |
---|
518 | |
---|
519 | JobsDataStore = new Ext.data.Store({ |
---|
520 | id: 'JobsDataStore', |
---|
521 | proxy: JobProxy, |
---|
522 | baseParams: { task: "GETJOBS" }, |
---|
523 | reader: new Ext.data.JsonReader({ |
---|
524 | root: 'results', |
---|
525 | totalProperty: 'total', |
---|
526 | id: 'id' |
---|
527 | },[ |
---|
528 | {name: 'jid', type: 'int', mapping: 'jid'}, |
---|
529 | {name: 'status', type: 'string', mapping: 'status'}, |
---|
530 | {name: 'owner', type: 'string', mapping: 'owner'}, |
---|
531 | {name: 'queue', type: 'string', mapping: 'queue'}, |
---|
532 | {name: 'name', type: 'string', mapping: 'name'}, |
---|
533 | {name: 'requested_time', type: 'string', mapping: 'requested_time'}, |
---|
534 | {name: 'requested_memory', type: 'string', mapping: 'requested_memory'}, |
---|
535 | {name: 'ppn', type: 'int', mapping: 'ppn'}, |
---|
536 | {name: 'nodect', type: 'int', mapping: 'nodect'}, |
---|
537 | {name: 'nodes', type: 'string', mapping: 'nodes'}, |
---|
538 | {name: 'queued_timestamp', type: 'string', mapping: 'queued_timestamp'}, |
---|
539 | {name: 'start_timestamp', type: 'string', mapping: 'start_timestamp'}, |
---|
540 | {name: 'runningtime', type: 'string', mapping: 'runningtime'} |
---|
541 | ]), |
---|
542 | sortInfo: { field: 'jid', direction: "DESC" }, |
---|
543 | remoteSort: true, |
---|
544 | listeners: |
---|
545 | { |
---|
546 | 'beforeload': |
---|
547 | { |
---|
548 | scope: this, |
---|
549 | fn: function() |
---|
550 | { |
---|
551 | if( SearchField ) |
---|
552 | { |
---|
553 | search_value = SearchField.getEl().dom.value; |
---|
554 | if( search_value == '' ) |
---|
555 | { |
---|
556 | delete SearchField.store.baseParams['query']; |
---|
557 | delete myfilters['query']; |
---|
558 | delete myparams['query']; |
---|
559 | } |
---|
560 | else |
---|
561 | { |
---|
562 | myfilters['query'] = search_value; |
---|
563 | } |
---|
564 | |
---|
565 | makeFilterMenu(); |
---|
566 | reloadClusterImage(); |
---|
567 | |
---|
568 | filter_str = myparams.c + ' Jobs Overview' + makeFilterString(); |
---|
569 | JobListingWindow.setTitle( filter_str ); |
---|
570 | } |
---|
571 | } |
---|
572 | } //, |
---|
573 | //'load': |
---|
574 | //{ |
---|
575 | // scope: this, |
---|
576 | // fn: function() |
---|
577 | // { |
---|
578 | // if( SearchField ) |
---|
579 | // { |
---|
580 | // search_value = SearchField.getEl().dom.value; |
---|
581 | |
---|
582 | // if( search_value != '' ) |
---|
583 | // { |
---|
584 | // myfilters['query'] = search_value; |
---|
585 | // } |
---|
586 | |
---|
587 | // reloadClusterImage(); |
---|
588 | |
---|
589 | // filter_str = myparams.c + ' Jobs Overview' + makeFilterString(); |
---|
590 | // JobListingWindow.setTitle( filter_str ); |
---|
591 | |
---|
592 | // if( search_value != '' ) |
---|
593 | // { |
---|
594 | // delete myfilters['query']; |
---|
595 | // } |
---|
596 | // } |
---|
597 | // } |
---|
598 | //} |
---|
599 | } |
---|
600 | }); |
---|
601 | |
---|
602 | var CheckJobs = new Ext.grid.CheckboxSelectionModel(); |
---|
603 | |
---|
604 | JobsColumnModel = new Ext.grid.ColumnModel( |
---|
605 | [ CheckJobs, |
---|
606 | { |
---|
607 | header: '#', |
---|
608 | tooltip: 'Job id', |
---|
609 | readOnly: true, |
---|
610 | dataIndex: 'jid', |
---|
611 | width: 50, |
---|
612 | hidden: false, |
---|
613 | renderer: jobCellRender |
---|
614 | },{ |
---|
615 | header: 'S', |
---|
616 | tooltip: 'Job status', |
---|
617 | readOnly: true, |
---|
618 | dataIndex: 'status', |
---|
619 | width: 20, |
---|
620 | hidden: false, |
---|
621 | renderer: jobCellRender |
---|
622 | },{ |
---|
623 | header: 'User', |
---|
624 | tooltip: 'Owner of job', |
---|
625 | readOnly: true, |
---|
626 | dataIndex: 'owner', |
---|
627 | width: 60, |
---|
628 | hidden: false, |
---|
629 | renderer: jobCellRender |
---|
630 | },{ |
---|
631 | header: 'Queue', |
---|
632 | tooltip: 'In which queue does this job reside', |
---|
633 | readOnly: true, |
---|
634 | dataIndex: 'queue', |
---|
635 | width: 60, |
---|
636 | hidden: false, |
---|
637 | renderer: jobCellRender |
---|
638 | },{ |
---|
639 | header: 'Name', |
---|
640 | tooltip: 'Name of job', |
---|
641 | readOnly: true, |
---|
642 | dataIndex: 'name', |
---|
643 | width: 100, |
---|
644 | hidden: false |
---|
645 | },{ |
---|
646 | header: 'Requested Time', |
---|
647 | tooltip: 'Amount of requested time (wallclock)', |
---|
648 | readOnly: true, |
---|
649 | dataIndex: 'requested_time', |
---|
650 | width: 100, |
---|
651 | hidden: false |
---|
652 | },{ |
---|
653 | header: 'Requested Memory', |
---|
654 | tooltip: 'Amount of requested memory', |
---|
655 | readOnly: true, |
---|
656 | dataIndex: 'requested_memory', |
---|
657 | width: 100, |
---|
658 | hidden: true |
---|
659 | },{ |
---|
660 | header: 'P', |
---|
661 | tooltip: 'Number of processors per node (PPN)', |
---|
662 | readOnly: true, |
---|
663 | dataIndex: 'ppn', |
---|
664 | width: 25, |
---|
665 | hidden: false |
---|
666 | },{ |
---|
667 | header: 'N', |
---|
668 | tooltip: 'Number of nodes (hosts)', |
---|
669 | readOnly: true, |
---|
670 | dataIndex: 'nodect', |
---|
671 | width: 25, |
---|
672 | hidden: false |
---|
673 | },{ |
---|
674 | header: 'Nodes', |
---|
675 | readOnly: true, |
---|
676 | dataIndex: 'nodes', |
---|
677 | width: 100, |
---|
678 | hidden: false, |
---|
679 | renderer: jobCellRender |
---|
680 | },{ |
---|
681 | header: 'Queued', |
---|
682 | tooltip: 'At what time did this job enter the queue', |
---|
683 | readOnly: true, |
---|
684 | dataIndex: 'queued_timestamp', |
---|
685 | width: 120, |
---|
686 | hidden: false |
---|
687 | },{ |
---|
688 | header: 'Started', |
---|
689 | tooltip: 'At what time did this job enter the running status', |
---|
690 | readOnly: true, |
---|
691 | dataIndex: 'start_timestamp', |
---|
692 | width: 120, |
---|
693 | hidden: false |
---|
694 | },{ |
---|
695 | header: 'Runningtime', |
---|
696 | tooltip: 'How long has this job been in the running status', |
---|
697 | readOnly: true, |
---|
698 | dataIndex: 'runningtime', |
---|
699 | width: 140, |
---|
700 | hidden: false |
---|
701 | }] |
---|
702 | ); |
---|
703 | JobsColumnModel.defaultSortable= true; |
---|
704 | |
---|
705 | var win; |
---|
706 | |
---|
707 | MetricsDataStore = new Ext.data.Store({ |
---|
708 | id: 'MetricsDataStore', |
---|
709 | proxy: JobProxy, |
---|
710 | autoLoad: false, |
---|
711 | baseParams: { task: "GETMETRICS" }, |
---|
712 | reader: new Ext.data.JsonReader({ |
---|
713 | root: 'names', |
---|
714 | totalProperty: 'total', |
---|
715 | id: 'id' |
---|
716 | },[{ |
---|
717 | name: 'ID' |
---|
718 | },{ |
---|
719 | name: 'name' |
---|
720 | }]) |
---|
721 | }); |
---|
722 | |
---|
723 | SearchField = new Ext.app.SearchField({ |
---|
724 | store: JobsDataStore, |
---|
725 | params: {start: 0, limit: mylimit}, |
---|
726 | width: 200 |
---|
727 | }); |
---|
728 | |
---|
729 | NodesDataStore = new Ext.data.Store({ |
---|
730 | id: 'NodesDataStore', |
---|
731 | proxy: JobProxy, |
---|
732 | autoLoad: false, |
---|
733 | baseParams: { task: "GETNODES" }, |
---|
734 | reader: new Ext.data.JsonReader({ |
---|
735 | root: 'results', |
---|
736 | totalProperty: 'total', |
---|
737 | id: 'id' |
---|
738 | },[ |
---|
739 | {name: 'c', type: 'string', mapping: 'c'}, |
---|
740 | {name: 'h', type: 'string', mapping: 'h'}, |
---|
741 | {name: 'x', type: 'string', mapping: 'x'}, |
---|
742 | {name: 'v', type: 'string', mapping: 'v'}, |
---|
743 | {name: 'l', type: 'string', mapping: 'l'}, |
---|
744 | {name: 'jr', type: 'string', mapping: 'jr'}, |
---|
745 | {name: 'js', type: 'string', mapping: 'js'} |
---|
746 | ]), |
---|
747 | listeners: { |
---|
748 | 'beforeload': { |
---|
749 | scope: this, |
---|
750 | fn: function() { |
---|
751 | var jids; |
---|
752 | |
---|
753 | var row_records = CheckJobs.getSelections(); |
---|
754 | |
---|
755 | for(var i=0; i<row_records.length; i++ ) |
---|
756 | { |
---|
757 | rsel = row_records[i]; |
---|
758 | if( !jids ) |
---|
759 | { |
---|
760 | jids = rsel.get('jid'); |
---|
761 | } |
---|
762 | else |
---|
763 | { |
---|
764 | jids = jids + ',' + rsel.get('jid'); |
---|
765 | } |
---|
766 | } |
---|
767 | NodesDataStore.baseParams.jids = jids; |
---|
768 | NodesDataStore.baseParams.c = myparams.c; |
---|
769 | } |
---|
770 | } |
---|
771 | } |
---|
772 | }); |
---|
773 | |
---|
774 | function ShowGraphs( Button, Event ) { |
---|
775 | |
---|
776 | var GraphView = new Ext.DataView({ |
---|
777 | itemSelector: 'thumb', |
---|
778 | style:'overflow:auto', |
---|
779 | multiSelect: true, |
---|
780 | store: NodesDataStore, |
---|
781 | tpl: new Ext.XTemplate( |
---|
782 | '<tpl for=".">', |
---|
783 | '<div class="rrd-float"><img src="../../graph.php?z=small&c={c}&h={h}&l={l}&v={v}&x={x}&r=job&jr={jr}&js={js}" border="0"></div>', |
---|
784 | '</tpl>' |
---|
785 | ) |
---|
786 | }); |
---|
787 | |
---|
788 | var images = new Ext.Panel({ |
---|
789 | id:'images', |
---|
790 | //title:'My Images', |
---|
791 | region:'center', |
---|
792 | bodyStyle: 'background: transparent', |
---|
793 | //margins: '2 2 2 0', |
---|
794 | layout:'fit', |
---|
795 | items: GraphView |
---|
796 | }); |
---|
797 | |
---|
798 | if(!win){ |
---|
799 | win = new Ext.Window({ |
---|
800 | animateTarget: Button, |
---|
801 | width : 500, |
---|
802 | height : 300, |
---|
803 | closeAction :'hide', |
---|
804 | collapsible: true, |
---|
805 | animCollapse: true, |
---|
806 | maximizable: true, |
---|
807 | title: 'Node graph details', |
---|
808 | layout: 'fit', |
---|
809 | tbar: new Ext.form.ComboBox({ |
---|
810 | fieldLabel: 'Metric', |
---|
811 | //hiddenName:'ID', |
---|
812 | store: MetricsDataStore, |
---|
813 | valueField:'name', |
---|
814 | displayField:'name', |
---|
815 | typeAhead: true, |
---|
816 | mode: 'remote', |
---|
817 | triggerAction: 'all', |
---|
818 | emptyText:'Select metric', |
---|
819 | selectOnFocus:true, |
---|
820 | xtype: 'combo', |
---|
821 | width:190, |
---|
822 | listeners: { |
---|
823 | select: function(combo, record, index){ |
---|
824 | var metric = record.data.name; |
---|
825 | // doe iets |
---|
826 | } |
---|
827 | } |
---|
828 | |
---|
829 | }), |
---|
830 | items: [ images ] |
---|
831 | }); |
---|
832 | } |
---|
833 | NodesDataStore.load(); |
---|
834 | win.show(Button); |
---|
835 | } |
---|
836 | |
---|
837 | showGraphsButton = new Ext.Button({ |
---|
838 | text: 'Show graphs', |
---|
839 | tooltip: 'Show node graphs for selected jobs', |
---|
840 | iconCls: 'option', |
---|
841 | disabled: true, |
---|
842 | listeners: { |
---|
843 | 'click': { |
---|
844 | scope: this, |
---|
845 | fn: ShowGraphs |
---|
846 | } |
---|
847 | } |
---|
848 | }); |
---|
849 | |
---|
850 | JobListingEditorGrid = new Ext.grid.EditorGridPanel({ |
---|
851 | id: 'JobListingEditorGrid', |
---|
852 | store: JobsDataStore, |
---|
853 | cm: JobsColumnModel, |
---|
854 | enableColLock:false, |
---|
855 | clicksToEdit:1, |
---|
856 | loadMask: true, |
---|
857 | selModel: new Ext.grid.RowSelectionModel({singleSelect:false}), |
---|
858 | stripeRows: true, |
---|
859 | sm: CheckJobs, |
---|
860 | bbar: new Ext.PagingToolbar({ |
---|
861 | pageSize: 15, |
---|
862 | store: JobsDataStore, |
---|
863 | displayInfo: true, |
---|
864 | displayMsg: 'Displaying jobs {0} - {1} out of {2} jobs total found.', |
---|
865 | emptyMsg: 'No jobs found to display', |
---|
866 | plugins: [new Ext.ux.PageSizePlugin()] |
---|
867 | }), |
---|
868 | tbar: [ SearchField, |
---|
869 | showGraphsButton, |
---|
870 | filterButton ] |
---|
871 | }); |
---|
872 | |
---|
873 | ClusterImageWindow = new Ext.Window({ |
---|
874 | id: 'ClusterImageWindow', |
---|
875 | title: 'Nodes', |
---|
876 | closable: true, |
---|
877 | collapsible: true, |
---|
878 | animCollapse: true, |
---|
879 | width: 1, |
---|
880 | height: 1, |
---|
881 | y: 15, |
---|
882 | plain: true, |
---|
883 | shadow: true, |
---|
884 | resizable: false, |
---|
885 | shadowOffset: 10, |
---|
886 | layout: 'fit', |
---|
887 | bbar: new Ext.StatusBar({ |
---|
888 | defaultText: 'Ready.', |
---|
889 | id: 'basic-statusbar', |
---|
890 | defaultIconCls: '' |
---|
891 | }) |
---|
892 | }); |
---|
893 | |
---|
894 | GraphSummaryWindow = new Ext.Window({ |
---|
895 | id: 'GraphSummaryWindow', |
---|
896 | title: 'Graph Summary', |
---|
897 | closable: true, |
---|
898 | collapsible: true, |
---|
899 | animCollapse: true, |
---|
900 | width: 500, |
---|
901 | height: 400, |
---|
902 | x: 10, |
---|
903 | y: 10, |
---|
904 | plain: true, |
---|
905 | shadow: true, |
---|
906 | resizable: true, |
---|
907 | shadowOffset: 10, |
---|
908 | layout: 'table', |
---|
909 | layoutConfig: { |
---|
910 | columns: 2 |
---|
911 | }, |
---|
912 | defaults:{border: false}, |
---|
913 | items: [{ |
---|
914 | id: 'monarchlogo', |
---|
915 | cls: 'monarch', |
---|
916 | bodyStyle: 'background: transparent', |
---|
917 | html: '<A HREF="https://subtrac.sara.nl/oss/jobmonarch/" TARGET="_blank"><IMG SRC="./jobmonarch.gif" ALT="Job Monarch" BORDER="0"></A>' |
---|
918 | //colspan: 2 |
---|
919 | },{ |
---|
920 | id: 'summarycount' |
---|
921 | },{ |
---|
922 | id: 'rjqjgraph' |
---|
923 | },{ |
---|
924 | id: 'pie', |
---|
925 | colspan: 2 |
---|
926 | }], |
---|
927 | bbar: new Ext.StatusBar({ |
---|
928 | defaultText: 'Ready.', |
---|
929 | id: 'basic-statusbar', |
---|
930 | defaultIconCls: '' |
---|
931 | }) |
---|
932 | }); |
---|
933 | |
---|
934 | JobListingWindow = new Ext.Window({ |
---|
935 | id: 'JobListingWindow', |
---|
936 | title: 'Cluster Jobs Overview', |
---|
937 | closable:true, |
---|
938 | collapsible: true, |
---|
939 | animCollapse: true, |
---|
940 | maximizable: true, |
---|
941 | y: 375, |
---|
942 | width:860, |
---|
943 | height:445, |
---|
944 | plain:true, |
---|
945 | shadow: true, |
---|
946 | shadowOffset: 10, |
---|
947 | layout: 'fit', |
---|
948 | items: JobListingEditorGrid |
---|
949 | }); |
---|
950 | |
---|
951 | JobListingEditorGrid.addListener( 'cellclick', jobCellClick ); |
---|
952 | CheckJobs.addListener( 'selectionchange', jobRowSelect ); |
---|
953 | } |
---|