source: trunk/web2/addons/job_monarch/js/monarch.js @ 600

Last change on this file since 600 was 600, checked in by ramonb, 15 years ago

job_monarch/js/monarch.js:

  • only jobs with status 'R' are selectable
  • graphPanel is now window toolbar in stead of item
  • apply layouts after resizing graphWindow
  • graph Metric combobox is now moved to graphView's toolbar
  • added Lightbox2 image href's for graph image popup/slider, group by jid

job_monarch/jobstore.php:

  • also return jid now, for Lightbox2 grouping

job_monarch/templates/header.tpl:

  • added Lightbox css and js
File size: 23.3 KB
Line 
1var JobsDataStore;
2var JobsColumnModel;
3var JobListingEditorGrid;
4var JobListingWindow;
5var JobProxy;
6var SearchField;
7var filterButton;
8
9// Extra header to prevent browser caching
10//
11Ext.Ajax.defaultHeaders =
12{
13        'If-Modified-Since':    'Sat, 1 Jan 2005 00:00:00 GMT'
14};
15
16// associative filter array
17//
18var myfilters = { };
19
20// any other datastore params
21//
22var myparams = { };
23
24// (default) paging size
25//
26var mylimit = 15;
27
28var ClusterImageArgs = { };
29
30var filterfields = [ "jid", "queue", "name", "owner" ];
31
32var graphWindowBehaviour = 'tabbed-new-window';
33var previousGraphWindow;
34
35var filterMenu = new Ext.menu.Menu(
36{
37        id:     'filterMenu',
38        items:  [ new Ext.menu.Item({ text: 'Clear all', handler: clearFilters }) ]
39});
40
41var filterButton = new Ext.MenuButton(
42{
43        id:             'filtermenuknop',
44        text:           'Filters',
45        toolip:         'Click to change filter options',
46        disabled:       true,
47        menu:           filterMenu,
48        listeners:
49        {
50                'click':
51                {
52                        scope:  this,
53                        fn:     function( myButton, event )
54                                {       // immediatly show menu when button is clicked
55                                        myButton.menu.show( myButton.getEl() );
56                                }
57                }
58        }
59});
60
61function checkGraphWindowOption( item, checked )
62{
63        graphWindowBehaviour    = item.id;
64}
65
66var graphMenu = new Ext.menu.Menu(
67{
68        id:     'graphMenu',
69        items:
70        [{
71                id:             'new-window',
72                text:           'Each job in new window',
73                checked:        false,
74                group:          'graphwindow',
75                handler:        checkGraphWindowOption
76        },{
77                id:             'tabbed-new-window',
78                text:           'Each job in a seperate tab, in new window',
79                checked:        true,
80                group:          'graphwindow',
81                handler:        checkGraphWindowOption
82        },{
83                id:             'tabbed-prev-window',
84                text:           'Each job in a seperate tab, in last opened window',
85                checked:        false,
86                group:          'graphwindow',
87                handler:        checkGraphWindowOption
88        }]
89});
90
91var showGraphsButton = new Ext.MenuButton(
92{
93        id:             'showgraphbutton',
94        text:           'Show graphs',
95        disabled:       true,
96        menu:           graphMenu,
97        listeners:
98        {
99                'click':
100                {
101                        scope:  this,
102                        fn:     ShowGraphs
103                }
104        }
105});
106
107Ext.namespace('Ext.ux');
108
109Ext.ux.PageSizePlugin = function()
110{
111        Ext.ux.PageSizePlugin.superclass.constructor.call(this,
112        {
113                store:  new Ext.data.SimpleStore(
114                {
115                        fields: ['text', 'value'],
116                        data:   [['10', 10], ['15', 15], ['20', 20], ['30', 30], ['50', 50], ['100', 100], ['max', 'max' ]]
117                }),
118                mode:           'local',
119                displayField:   'text',
120                valueField:     'value',
121                editable:       false,
122                allowBlank:     false,
123                triggerAction:  'all',
124                width:          40
125        });
126};
127
128Ext.extend(Ext.ux.PageSizePlugin, Ext.form.ComboBox,
129{
130        init:                   function(paging)
131                                {
132                                        paging.on('render', this.onInitView, this);
133                                },
134   
135        onInitView:             function(paging)
136                                {
137                                        paging.add('-',
138                                        this,
139                                        'jobs per page'
140                                        );
141                                        this.setValue(paging.pageSize);
142                                        this.on('select', this.onPageSizeChanged, paging);
143                                },
144
145        onPageSizeChanged:      function(combo)
146                                {
147                                        if ( combo.getValue() == 'max' )
148                                        {
149                                                mylimit = JobsDataStore.getTotalCount();
150                                        }
151                                        else
152                                        {
153                                                mylimit = parseInt(combo.getValue());
154                                        }
155                                        this.pageSize = mylimit;
156                                        this.doLoad(0);
157                                }
158});
159
160Ext.namespace( 'Ext' );
161
162function clearFilters()
163{
164        if( inMyArrayKeys( myfilters, 'query' ) )
165        {
166                SearchField.getEl().dom.value = '';
167                delete SearchField.store.baseParams['query'];
168                delete myfilters['query'];
169                delete myparams['query'];
170        }
171        if( inMyArrayKeys( myfilters, 'host' ) )
172        {
173                delete myfilters['host'];
174                delete myparams['host'];
175        }
176        if( inMyArrayKeys( myfilters, 'jid' ) )
177        {
178                delete myfilters['jid'];
179                delete myparams['jid'];
180        }
181        if( inMyArrayKeys( myfilters, 'queue' ) )
182        {
183                delete myfilters['queue'];
184                delete myparams['queue'];
185        }
186        if( inMyArrayKeys( myfilters, 'owner' ) )
187        {
188                delete myfilters['owner'];
189                delete myparams['owner'];
190        }
191        if( inMyArrayKeys( myfilters, 'status' ) )
192        {
193                delete myfilters['status'];
194                delete myparams['status'];
195        }
196        reloadJobStore();
197}
198
199function makeArrayURL( somearr )
200{
201        filter_url = '';
202        filter_sep = '';
203
204        for( filtername in somearr )
205        {
206                filter_url = filter_url + filter_sep + filtername + '=' + somearr[filtername];
207                filter_sep = '&';
208        }
209
210        return filter_url;
211}
212
213
214function isset( somevar )
215{
216        try
217        {
218                if( eval( somevar ) ) { }
219        }
220        catch( err )
221        {
222                return false;
223        }
224        return true;
225}
226
227function inMyArray( arr, someval )
228{
229        for( arval in arr )
230        {
231                if( arval == someval )
232                {
233                        return true;
234                }
235        }
236        return false;
237}
238
239function ArraySize( arr )
240{
241        count = 0;
242
243        for( arkey in arr )
244        {
245                count = count + 1;
246        }
247
248        return count;
249}
250
251function inMyArrayValues( arr, someval )
252{
253        for( arkey in arr )
254        {
255                if( arr[arkey] == someval )
256                {
257                        return true;
258                }
259        }
260        return false;
261}
262
263function inMyArrayKeys( arr, someval )
264{
265        for( arkey in arr )
266        {
267                if( arkey == someval )
268                {
269                        return true;
270                }
271        }
272        return false;
273}
274
275function joinMyArray( arr1, arr2 )
276{
277        for( arkey in arr2 )
278        {
279                arr1[arkey] = arr2[arkey];
280        }
281
282        return arr1;
283}
284
285function ClusterImageSelectHost( somehost )
286{
287        if( !inMyArrayKeys( myfilters, 'host' ) )
288        {
289                myfilters['host'] = somehost;
290        }
291        else
292        {
293                if( myfilters['host'] == somehost )
294                {
295                        delete myfilters['host'];
296                        delete myparams['host'];
297                }
298                else
299                {
300                        myfilters['host'] = somehost;
301                }
302        }
303
304        reloadClusterImage();
305        reloadJobStore();
306
307        // returning false causes a image reload
308        //
309        return false;
310}
311
312function reloadJobStore()
313{
314        // Respect any other parameters that may have been set outside filters
315        //
316        myparams = joinMyArray( myparams, myfilters );
317
318        // Can't be sure if there are enough pages for new filter: reset to page 1
319        //
320        myparams = joinMyArray( myparams, { start: 0, limit: mylimit } );
321
322        JobsDataStore.reload( { params: myparams } );
323}
324
325function addListener(element, type, expression, bubbling)
326{
327        bubbling = bubbling || false;
328
329        if(window.addEventListener)
330        { // Standard
331                element.addEventListener(type, expression, bubbling);
332                return true;
333        } 
334        else if(window.attachEvent) 
335        { // IE
336                element.attachEvent('on' + type, expression);
337                return true;
338        }
339        else 
340        {
341                return false;
342        }
343}
344
345function makeFilterString()
346{
347        var filter_str = '';
348
349        for( arkey in myfilters )
350        {
351                filter_str = filter_str + ' > ' + myfilters[arkey];
352        }
353
354        return filter_str;
355}
356
357var ImageLoader = function( id, url )
358{
359        this.url = url;
360        this.image = document.getElementById( id );
361        this.loadEvent = null;
362};
363
364ImageLoader.prototype = 
365{
366        load:           function()
367                        {
368                                var url         = this.url;
369                                var image       = this.image;
370                                var loadEvent   = this.loadEvent;
371                                addListener( this.image, 'load',
372                                        function(e)
373                                        {
374                                                if( loadEvent != null )
375                                                {
376                                                        loadEvent( url, image );
377                                                }
378                                        }, false);
379                                this.image.src = this.url;
380                        },
381        getImage:       function()
382                        {
383                                return this.image;
384                        }
385};
386
387function achorJobListing()
388{
389        JobListingWindow.anchorTo( "ClusterImageWindow", "tr-br", [ 0, 10 ] );
390}
391
392function setClusterImagePosition()
393{
394        ci_x = (window.innerWidth - ClusterImageWindow.getSize()['width'] - 20); 
395        ClusterImageWindow.setPosition( ci_x, 10 );
396}
397
398function deselectFilterMenu( menuItem, event )
399{
400        filterValue = menuItem.text;
401
402        if( filterValue == SearchField.getEl().dom.value && inMyArrayKeys( myfilters, 'query' ) )
403        {
404                SearchField.getEl().dom.value = '';
405                delete SearchField.store.baseParams['query'];
406        }
407
408        for( arkey in myfilters )
409        {
410                if( myfilters[arkey] == filterValue )
411                {
412                        delete myfilters[arkey];
413                        delete myparams[arkey];
414                }
415        }
416        reloadJobStore();
417}
418
419function makeFilterMenu()
420{
421        var filterMenu = new Ext.menu.Menu(
422        {
423                id:     'filterMenu',
424                items:  [ new Ext.menu.Item({ text: 'Clear all', handler: clearFilters }) ]
425        });
426
427        if( ArraySize( myfilters ) > 0 )
428        {
429                filterMenu.addSeparator();
430        }
431
432        for( arkey in myfilters )
433        {
434                filterMenu.add( new Ext.menu.CheckItem({ text: myfilters[arkey], handler: deselectFilterMenu, checked: true }) );
435        }
436
437        if( filterButton )
438        {
439                filterButton.menu = filterMenu;
440
441                if( ArraySize( myfilters ) > 0 )
442                {
443                        filterButton.enable();
444                }
445                else
446                {
447                        filterButton.disable();
448                }
449        }
450}
451
452function reloadClusterImage()
453{
454        ClusterImageArgs['view']        = 'big-clusterimage';
455
456        filt_url                        = makeArrayURL( myfilters );
457        imag_url                        = makeArrayURL( ClusterImageArgs );
458        img_url                         = './image.php?' + filt_url + '&' + imag_url;
459
460        var newClusterImage             = new ImageLoader( 'clusterimage', img_url );
461        newClusterImage.loadEvent       = function( url, image ) 
462        {
463                ClusterImageWindow.getBottomToolbar().clearStatus( { useDefaults:true } );
464                setTimeout( "resizeClusterImage()", 250 );
465                setTimeout( "setClusterImagePosition()", 500 );
466                //setTimeout( "achorJobListing()", 1000 );
467        }
468
469        ClusterImageWindow.getBottomToolbar().showBusy();
470
471        filter_str = 'Nodes' + makeFilterString();
472        ClusterImageWindow.setTitle( filter_str );
473
474        newClusterImage.load();
475}
476
477function resizeClusterImage()
478{
479        var ci_height   = document.getElementById( "clusterimage" ).height + ClusterImageWindow.getFrameHeight();
480        var ci_width    = document.getElementById( "clusterimage" ).width + ClusterImageWindow.getFrameWidth();
481
482        ClusterImageWindow.setSize( ci_width, ci_height );
483}
484
485Ext.apply(Ext.form.VTypes,
486{
487        num:            function(val, field)
488                        {
489                                if (val) 
490                                {
491                                        var strValidChars = "0123456789";
492                                        var blnResult = true;
493
494                                        if (val.length == 0) return false;
495
496                                        //  test strString consists of valid characters listed above
497                                        for (i = 0; i < val.length && blnResult == true; i++)
498                                        {
499                                                strChar = val.charAt(i);
500                                                if (strValidChars.indexOf(strChar) == -1)
501                                                {
502                                                        blnResult = false;
503                                                }
504                                        }
505                                        return blnResult;
506
507                                }
508                        },
509        numText:        'Must be numeric'
510});
511
512function jobBeforeRowSelect( mySelectionModel, rowIndex, keepExisting, myRecord )
513{
514        if( myRecord.get('status') == 'Q' )
515        {       // return false: dont select row if queued
516                return false;
517        }
518
519        return true;
520}
521
522function jobRowSelect( mySelectionModel, rowIndex, myRecord ) 
523{
524        if( mySelectionModel.hasSelection() )
525        {
526                showGraphsButton.enable();
527
528                return 0;
529        }
530
531        showGraphsButton.disable();
532}
533
534function jobCellClick(grid, rowIndex, columnIndex, e)
535{
536        var record              = grid.getStore().getAt(rowIndex);  // Get the Record
537        var fieldName           = grid.getColumnModel().getDataIndex(columnIndex);
538        var data                = record.get(fieldName);
539        var view                = grid.getView();
540        var cell                = view.getCell( rowIndex, columnIndex );
541        var filter_title        = false;
542        var fil_dis             = 'filter';
543        var fil_ena             = 'filterenabled';
544        var filterName          = fieldName;
545
546        if( fieldName == 'owner' || fieldName == 'jid' || fieldName == 'status' || fieldName == 'queue' || fieldName == 'nodes')
547        {
548                if( fieldName == 'nodes' )
549                {
550                        filterName      = 'host';
551                        fil_dis         = 'nodesfilter';
552                        fil_ena         = 'nodesfilterenabled';
553                }
554                if( inMyArrayKeys( myfilters, filterName ) )
555                {
556                        Ext.fly(cell).removeClass( fil_ena );
557                        Ext.fly(cell).addClass( fil_dis );
558
559                        // Remove this filter
560                        //
561                        delete myfilters[filterName];
562                        delete myparams[filterName];
563
564                        reloadJobStore();
565                        //reloadClusterImage();
566                }
567                else
568                {
569                        Ext.fly(cell).removeClass( fil_dis );
570                        Ext.fly(cell).addClass( fil_ena );
571
572                        if( fieldName == 'nodes' )
573                        { // Get the first node (master mom) as node filter
574                                new_data = data.split( ',' )[0];
575                                data = new_data;
576                        }
577
578                        // Set filter for selected column to selected cell value
579                        //
580                        myfilters[filterName] = data;
581
582                        reloadJobStore();
583                        //reloadClusterImage();
584                }
585                JobListingWindow.setTitle( filter_str );
586
587                filter_title    = true;
588                filter_str      = myparams.c + ' Jobs Overview' + makeFilterString();
589        }
590}
591
592function jobCellRender( value, metadata, record, rowindex, colindex, store )
593{
594        var fieldName   = JobsColumnModel.getColumnById( colindex ).dataIndex;
595        var fil_dis     = 'filter';
596        var fil_ena     = 'filterenabled';
597        var filterName  = fieldName;
598
599        if( fieldName == 'owner' || fieldName == 'jid' || fieldName == 'status' || fieldName == 'queue' || fieldName == 'nodes' )
600        {
601                if( fieldName == 'nodes' )
602                {
603                        fil_dis         = 'nodesfilter';
604                        fil_ena         = 'nodesfilterenabled';
605                        filterName      = 'host';
606                }
607                if( myfilters[filterName] != null )
608                {
609                        metadata.css    = fil_ena;
610                }
611                else
612                {
613                        metadata.css    = fil_dis;
614                }
615        }
616        return value;
617}
618
619var JobProxy = new Ext.data.HttpProxy(
620{
621        url:            'jobstore.php',
622        method:         'POST'
623});
624
625JobsDataStore = new Ext.data.Store(
626{
627        id:             'JobsDataStore',
628        proxy:          JobProxy,
629        baseParams:     { task: "GETJOBS" },
630        reader:
631                new Ext.data.JsonReader(
632                {
633                        root:           'results',
634                        totalProperty:  'total',
635                        id:             'id'
636                },
637                [
638                        {name: 'jid', type: 'int', mapping: 'jid'},
639                        {name: 'status', type: 'string', mapping: 'status'},
640                        {name: 'owner', type: 'string', mapping: 'owner'},
641                        {name: 'queue', type: 'string', mapping: 'queue'},
642                        {name: 'name', type: 'string', mapping: 'name'},
643                        {name: 'requested_time', type: 'string', mapping: 'requested_time'},
644                        {name: 'requested_memory', type: 'string', mapping: 'requested_memory'},
645                        {name: 'ppn', type: 'int', mapping: 'ppn'},
646                        {name: 'nodect', type: 'int', mapping: 'nodect'},
647                        {name: 'nodes', type: 'string', mapping: 'nodes'},
648                        {name: 'queued_timestamp', type: 'string', mapping: 'queued_timestamp'},
649                        {name: 'start_timestamp', type: 'string', mapping: 'start_timestamp'},
650                        {name: 'runningtime', type: 'string', mapping: 'runningtime'}
651                ]),
652        sortInfo: 
653        { 
654                field:          'jid', 
655                direction:      "DESC" 
656        },
657        remoteSort: true,
658        listeners:
659        { 
660                'beforeload':
661                {
662                        scope: this,
663                        fn:
664
665                        function( myStore, myOptions )
666                        {
667                                // Add a (bogus) timestamp, to create a unique url and prevent browser caching
668                                //
669                                myStore.proxy.url       = 'jobstore.php?timestamp=' + new Date().getTime();
670
671                                if( SearchField )
672                                {
673                                        search_value = SearchField.getEl().dom.value;
674                                        if( search_value == '' )
675                                        {
676                                                delete SearchField.store.baseParams['query'];
677                                                delete myfilters['query'];
678                                                delete myparams['query'];
679                                        }
680                                        else
681                                        {
682                                                myfilters['query']      = search_value;
683                                        }
684
685                                        makeFilterMenu();
686                                        reloadClusterImage();
687
688                                        filter_str = myparams.c + ' Jobs Overview' + makeFilterString();
689                                        JobListingWindow.setTitle( filter_str );
690                                }
691                        }
692                }
693        }
694});
695   
696var CheckJobs =
697
698        new Ext.grid.CheckboxSelectionModel(
699        {
700                listeners:
701                {
702                        'beforerowselect':
703                        {
704                                scope:  this,
705                                fn:     jobBeforeRowSelect
706                        },
707                        'rowselect':
708                        {
709                                scope:  this,
710                                fn:     jobRowSelect
711                        },
712                        'rowdeselect':
713                        {
714                                scope:  this,
715                                fn:     jobRowSelect
716                        }
717                },
718        });
719
720JobsColumnModel = new Ext.grid.ColumnModel(
721[
722        CheckJobs,
723        {
724                header:         '#',
725                tooltip:        'Job id',
726                readOnly:       true,
727                dataIndex:      'jid',
728                width:          50,
729                hidden:         false,
730                renderer:       jobCellRender
731        },{
732                header:         'S',
733                tooltip:        'Job status',
734                readOnly:       true,
735                dataIndex:      'status',
736                width:          20,
737                hidden:         false,
738                renderer:       jobCellRender
739        },{
740                header:         'User',
741                tooltip:        'Owner of job',
742                readOnly:       true,
743                dataIndex:      'owner',
744                width:          60,
745                hidden:         false,
746                renderer:       jobCellRender
747        },{
748                header:         'Queue',
749                tooltip:        'In which queue does this job reside',
750                readOnly:       true,
751                dataIndex:      'queue',
752                width:          60,
753                hidden:         false,
754                renderer:       jobCellRender
755        },{
756                header:         'Name',
757                tooltip:        'Name of job',
758                readOnly:       true,
759                dataIndex:      'name',
760                width:          100,
761                hidden:         false
762        },{
763                header:         'Requested Time',
764                tooltip:        'Amount of requested time (wallclock)',
765                readOnly:       true,
766                dataIndex:      'requested_time',
767                width:          100,
768                hidden:         false
769        },{
770                header:         'Requested Memory',
771                tooltip:        'Amount of requested memory',
772                readOnly:       true,
773                dataIndex:      'requested_memory',
774                width:          100,
775                hidden:         true
776        },{
777                header:         'P',
778                tooltip:        'Number of processors per node (PPN)',
779                readOnly:       true,
780                dataIndex:      'ppn',
781                width:          25,
782                hidden:         false
783        },{
784                header:         'N',
785                tooltip:        'Number of nodes (hosts)',
786                readOnly:       true,
787                dataIndex:      'nodect',
788                width:          25,
789                hidden:         false
790        },{
791                header:         'Nodes',
792                readOnly:       true,
793                dataIndex:      'nodes',
794                width:          100,
795                hidden:         false,
796                renderer:       jobCellRender
797        },{
798                header:         'Queued',
799                tooltip:        'At what time did this job enter the queue',
800                readOnly:       true,
801                dataIndex:      'queued_timestamp',
802                width:          120,
803                hidden:         false
804        },{
805                header:         'Started',
806                tooltip:        'At what time did this job enter the running status',
807                readOnly:       true,
808                dataIndex:      'start_timestamp',
809                width:          120,
810                hidden:         false
811        },{
812                header:         'Runningtime',
813                tooltip:        'How long has this job been in the running status',
814                readOnly:       true,
815                dataIndex:      'runningtime',
816                width:          140,
817                hidden:         false
818        }]
819);
820
821JobsColumnModel.defaultSortable = true;
822
823var win;
824
825MetricsDataStore = new Ext.data.Store(
826{
827        id:             'MetricsDataStore',
828        proxy:          JobProxy,
829        autoLoad:       false,
830        baseParams:     { task: "GETMETRICS" },
831        reader:
832                new Ext.data.JsonReader(
833                {
834                        root: 'names',
835                        totalProperty: 'total',
836                        id: 'id'
837                },
838                [{
839                        name: 'ID'
840                },{
841                        name: 'name'
842                }]
843                )
844});
845
846SearchField     = new Ext.app.SearchField(
847                {
848                        store:  JobsDataStore,
849                        params: {start: 0, limit: mylimit},
850                        width:  200
851                });
852
853function createNodesDataStore( cluster, jid )
854{
855        nodesDataStore =
856
857                new Ext.data.Store(
858                {
859                        //id:           'NodesDataStore',
860                        proxy:          new Ext.data.HttpProxy(
861                        {
862                                url:            'jobstore.php',
863                                method:         'POST'
864                        }),
865                        autoLoad:       true,
866                        baseParams:
867                        {
868                                'task':                 "GETNODES",
869                                'c':                    cluster,
870                                'jid':                  jid
871                        },
872                        reader: new Ext.data.JsonReader(
873                        {
874                                root:           'results',
875                                totalProperty:  'total',
876                                id:             'id'
877                        },[
878                                {name: 'c', type: 'string', mapping: 'c'},
879                                {name: 'h', type: 'string', mapping: 'h'},
880                                {name: 'x', type: 'string', mapping: 'x'},
881                                {name: 'v', type: 'string', mapping: 'v'},
882                                {name: 'l', type: 'string', mapping: 'l'},
883                                {name: 'jr', type: 'string', mapping: 'jr'},
884                                {name: 'js', type: 'string', mapping: 'js'},
885                                {name: 'jid', type: 'string', mapping: 'jid'}
886                        ]),
887                        listeners:
888                        { 
889                                'beforeload':
890                                {
891                                        scope: this,
892                                        fn:
893
894                                        function( myStore, myOptions )
895                                        {
896                                                // Add a (bogus) timestamp, to create a unique url and prevent browser caching
897                                                //
898                                                myStore.proxy.url       = 'jobstore.php?timestamp=' + new Date().getTime();
899                                        }
900                                }
901                        }
902
903                });
904
905        return nodesDataStore;
906}
907
908function createGraphView( store, jid )
909{
910        var graphView =
911       
912                new Ext.DataView(
913                {
914                        id:             jid,   
915                        itemSelector:   'thumb',
916                        title:          jid,
917                        style:          'overflow:auto',
918                        multiSelect:    true,
919                        autoHeight:     true,
920                        autoShow:       true,
921                        //autoScroll:   true,
922                        loadMask:       true,
923                        store:          store,
924                        layout:         'fit',
925                        closable:       true,
926                        tpl:
927                       
928                                new Ext.XTemplate(
929                                        '<tpl for=".">',
930                                        '<div class="rrd-float"><a href="../../graph.php?z=large&c={c}&h={h}&l={l}&v={v}\&x={x}&r=job&jr={jr}&js={js}" border="0" rel="lightbox[{jid}]"><img src="../../graph.php?z=small&c={c}&h={h}&l={l}&v={v}&x={x}&r=job&jr={jr}&js={js}" border="0"></a></div>',
931                                        '</tpl>'
932                                )
933                });
934
935        return graphView;
936}
937
938function createGraphPanel( view )
939{
940        var graphPanel = 
941
942                new Ext.TabPanel(
943                {
944                        id:             'tabPanel',
945                        region:         'center',
946                        bodyStyle:      'background: transparent',
947                        autoShow:       true,
948                        autoHeight:     true,
949                        autoWidth:      true,
950                        autoScroll:     true,
951                        resizeTabs:     true,
952                        minTabWidth:    60,
953                        //tabWidth:     135,
954                        //closeable:    true,
955                        enableTabScroll:true,
956                        resizeTabs:     true,
957                        // RB TODO: range combobox; hour, day, week, etc
958
959                        tbar:
960                        [
961                                new Ext.form.ComboBox(
962                                {
963                                        fieldLabel:     'Metric',
964                                        store:          MetricsDataStore,
965                                        valueField:     'name',
966                                        displayField:   'name',
967                                        typeAhead:      true,
968                                        mode:           'remote',
969                                        triggerAction:  'all',
970                                        emptyText:      'load_one',
971                                        selectOnFocus:  true,
972                                        xtype:          'combo',
973                                        width:          190,
974                                        listeners:
975                                        {
976                                                select: 
977                                                               
978                                                function(combo, record, index)
979                                                {
980                                                        var metric = record.data.name;
981                                                        // doe iets
982
983                                                        // RB: misschien zo metric opgeven aan datastore?
984                                                        //items[0].items[0].getStore().baseParams.metric = metric;
985                                                }
986                                        }
987                                })
988                        ]
989                });
990
991        return graphPanel;
992}
993
994function createGraphWindow( panel, Button )
995{
996        graphWindow =
997
998                new Ext.Window(
999                {
1000                        animateTarget:  Button,
1001                        width:          500,
1002                        height:         300,
1003                        closeAction:    'hide',
1004                        collapsible:    true,
1005                        animCollapse:   true,
1006                        maximizable:    true,
1007                        //autoScroll:   true,
1008                        //defaults:     {autoScroll:true},
1009                        title:          'Node graph details',
1010                        tbar:           panel,
1011               
1012                        listeners:
1013                        {
1014                                resize:
1015
1016                                function(  myWindow, width, height )
1017                                {
1018                                        var myPanel     = myWindow.items.get( 'tabPanel' );
1019                                        var myView      = myPanel.getActiveTab();
1020
1021                                        myPanel.doLayout();
1022                                        myWindow.doLayout();
1023                                }
1024                        }
1025                });
1026
1027        return graphWindow;
1028}
1029
1030function ShowGraphs( Button, Event ) 
1031{
1032        var row_records         = CheckJobs.getSelections();
1033        var graphJids           = Array();
1034        var windowCount         = 0;
1035        var tabCount            = 0;
1036
1037        for( var i=0; i<row_records.length; i++ )
1038        {
1039                rsel            = row_records[i];
1040                jid             = rsel.get('jid');
1041
1042                if( graphJids[windowCount] == undefined )
1043                {
1044                        graphJids[windowCount]  = Array();
1045                }
1046
1047                graphJids[windowCount][tabCount]        = jid;
1048
1049                if( (i+1) < row_records.length )
1050                {
1051                        if( graphWindowBehaviour == 'new-window' )
1052                        {
1053                                windowCount++;
1054                        }
1055                        else
1056                        {
1057                                tabCount++;
1058                        }
1059                }
1060        }
1061
1062        for( var w=0; w<=windowCount; w++ )
1063        {
1064                if( ( graphWindowBehaviour == 'tabbed-prev-window' ) && ( previousGraphWindow != null ) && ( previousGraphPanel != null ) )
1065                {
1066                        myWindow        = previousGraphWindow;
1067                        myPanel         = previousGraphPanel;
1068                }
1069                else
1070                {
1071                        myPanel         = createGraphPanel();
1072                        myWindow        = createGraphWindow( myPanel, Button );
1073
1074                        myWindow.add( myPanel );
1075                }
1076
1077                for( var t=0; t<=tabCount; t++ )
1078                {
1079                        nodeDatastore   = createNodesDataStore( myparams.c, graphJids[w][t] );
1080                        graphView       = createGraphView( nodeDatastore, graphJids[w][t] );
1081
1082                        nodeDatastore.removeAll();
1083
1084                        lastView        = myPanel.add( graphView );
1085
1086                        myPanel.doLayout();
1087                }
1088
1089                myPanel.setActiveTab( lastView );
1090
1091                myWindow.show( Button );
1092                myWindow.doLayout();
1093
1094                previousGraphWindow     = myWindow;
1095                previousGraphPanel      = myPanel;
1096        }
1097}
1098
1099var JobListingEditorGrid =
1100
1101        new Ext.grid.EditorGridPanel(
1102        {
1103                id:             'JobListingEditorGrid',
1104                store:          JobsDataStore,
1105                cm:             JobsColumnModel,
1106                enableColLock:  false,
1107                clicksToEdit:   1,
1108                loadMask:       true,
1109                selModel:       new Ext.grid.RowSelectionModel( { singleSelect: false } ),
1110                stripeRows:     true,
1111                sm:             CheckJobs,
1112                listeners:
1113                {
1114                        'cellclick':
1115                        {
1116                                scope:  this,
1117                                fn:     jobCellClick
1118                        }
1119                },
1120                bbar:
1121       
1122                new Ext.PagingToolbar(
1123                {
1124                        pageSize:       15,
1125                        store:          JobsDataStore,
1126                        displayInfo:    true,
1127                        displayMsg:     'Displaying jobs {0} - {1} out of {2} jobs total found.',
1128                        emptyMsg:       'No jobs found to display',
1129                        plugins:        [ new Ext.ux.PageSizePlugin() ]
1130                }),
1131
1132                tbar: 
1133                [ 
1134                        SearchField,
1135                        showGraphsButton,
1136                        filterButton 
1137                ]
1138        });
1139
1140var ClusterImageWindow =
1141
1142        new Ext.Window(
1143        {
1144                id:             'ClusterImageWindow',
1145                title:          'Nodes',
1146                closable:       true,
1147                collapsible:    true,
1148                animCollapse:   true,
1149                width:          1,
1150                height:         1,
1151                y:              15,
1152                plain:          true,
1153                shadow:         true,
1154                resizable:      false,
1155                shadowOffset:   10,
1156                layout:         'fit',
1157                bbar: 
1158               
1159                        new Ext.StatusBar(
1160                        {
1161                                defaultText:    'Ready.',
1162                                id:             'basic-statusbar',
1163                                defaultIconCls: ''
1164                        })
1165        });
1166
1167var GraphSummaryWindow =
1168
1169        new Ext.Window(
1170        {
1171                id:             'GraphSummaryWindow',
1172                title:          'Graph Summary',
1173                closable:       true,
1174                collapsible:    true,
1175                animCollapse:   true,
1176                width:          500,
1177                height:         400,
1178                x:              10,
1179                y:              10,
1180                plain:          true,
1181                shadow:         true,
1182                resizable:      true,
1183                shadowOffset:   10,
1184                layout:         'table',
1185                layoutConfig: 
1186                {
1187                        columns: 2
1188                },
1189                defaults:       { border: false },
1190                items: 
1191                [
1192                        {
1193                                id:             'monarchlogo',
1194                                cls:            'monarch',
1195                                bodyStyle:      'background: transparent',
1196                                html:           '<A HREF="https://subtrac.sara.nl/oss/jobmonarch/" TARGET="_blank"><IMG SRC="./jobmonarch.gif" ALT="Job Monarch" BORDER="0"></A>'
1197                                //colspan: 2
1198                        },{
1199                                id:             'summarycount'
1200                        },{
1201                                id:             'rjqjgraph'
1202                        },{
1203                                id:             'pie',
1204                                colspan:        2
1205                        }
1206                ],
1207                bbar:
1208               
1209                        new Ext.StatusBar(
1210                        {
1211                                defaultText:    'Ready.',
1212                                id:             'basic-statusbar',
1213                                defaultIconCls: ''
1214                        })
1215        });
1216
1217var JobListingWindow =
1218
1219        new Ext.Window(
1220        {
1221                id:             'JobListingWindow',
1222                title:          'Cluster Jobs Overview',
1223                closable:       true,
1224                collapsible:    true,
1225                animCollapse:   true,
1226                maximizable:    true,
1227                y:              375,
1228                width:          860,
1229                height:         445,
1230                plain:          true,
1231                shadow:         true,
1232                shadowOffset:   10,
1233                layout:         'fit',
1234                items:          JobListingEditorGrid
1235        });
Note: See TracBrowser for help on using the repository browser.