Changeset 566 for trunk/web2/addons


Ignore:
Timestamp:
01/23/09 14:36:56 (15 years ago)
Author:
ramonb
Message:

web2/addons/job_monarch/jobstore.php:

  • added getnodes task to retrieve node graphs
  • changed getList to getjobs

web2/addons/job_monarch/js/jobgrid.js:

  • added Graphs window popup
Location:
trunk/web2/addons/job_monarch
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/web2/addons/job_monarch/jobstore.php

    r564 r566  
    2020//
    2121$jid                    = isset($_POST['jid']) ? $_POST['jid'] : null;
     22$jids                   = isset($_POST['jids']) ? $_POST['jids'] : null;
    2223$owner                  = isset($_POST['owner']) ? $_POST['owner'] : null;
    2324$status                 = isset($_POST['status']) ? $_POST['status'] : null;
    2425$queue                  = isset($_POST['queue']) ? $_POST['queue'] : null;
    2526$host                   = isset($_POST['host']) ? $_POST['host'] : null;
     27
     28if( $jids != null )
     29{
     30        $jobids = explode( ",", $jids );
     31}
     32else
     33{
     34        $jobids = null;
     35}
    2636
    2737global $c, $clustername, $cluster;
     
    7686switch($task)
    7787{
    78     case "LISTING":
    79         getList();
     88    case "GETJOBS":
     89        getJobs();
    8090        break;         
    81     case "SUMMARY":
    82         getSummary();
     91    case "GETNODES":
     92        getNodes();
    8393        break;         
    8494    default:
     
    366376}
    367377
    368 function getList()
     378function getNodes()
     379{
     380        global $jobs, $jobids, $clustername;
     381
     382        $display_nodes  = array();
     383
     384        if( !$jobids )
     385        {
     386                return 1;
     387        }
     388        foreach( $jobs as $jobid => $jobattrs )
     389        {
     390                if( in_array( $jobid, $jobids ) )
     391                {
     392                        foreach( $jobattrs['nodes'] as $jobnode )
     393                        {
     394                                if( !in_array( $jobnode, $display_nodes) )
     395                                {
     396                                        $display_nodes[]        = $jobnode;
     397                                }
     398                        }
     399                }
     400        }
     401        //print_r( $display_nodes );
     402        $node_results   = array();
     403        $result_count   = count( $display_nodes );
     404        foreach( $display_nodes as $dnode )
     405        {
     406
     407                $nr             = array();
     408                $nr['c']        = $clustername;
     409                $nr['h']        = $dnode;
     410                $nr['x']        = '5';
     411                $nr['v']        = '0';
     412
     413                $node_results[] = $nr;
     414        }
     415        $jsonresults    = JEncode( $node_results );
     416
     417        echo '{"total":"'. $result_count .'","results":'. $jsonresults .'}';
     418}
     419
     420function getJobs()
    369421{
    370422        global $jobs, $hearbeat, $pstart, $pend;
  • trunk/web2/addons/job_monarch/js/jobgrid.js

    r564 r566  
    342342      id: 'JobsDataStore',
    343343      proxy: JobProxy,
    344       baseParams: { task: "LISTING" },
     344      baseParams: { task: "GETJOBS" },
    345345      reader: new Ext.data.JsonReader({
    346346        root: 'results',
     
    497497                    });
    498498
     499  NodesDataStore = new Ext.data.Store({
     500      id: 'NodesDataStore',
     501      proxy: JobProxy,
     502      autoLoad: false,
     503      baseParams: { task: "GETNODES" },
     504      reader: new Ext.data.JsonReader({
     505        root: 'results',
     506        totalProperty: 'total',
     507        id: 'id'
     508      },[
     509        {name: 'c', type: 'string', mapping: 'c'},
     510        {name: 'h', type: 'string', mapping: 'h'},
     511        {name: 'v', type: 'string', mapping: 'v'},
     512        {name: 'x', type: 'string', mapping: 'x'},
     513      ]),
     514      listeners: {
     515                'beforeload': {
     516                        scope: this,
     517                        fn: function() {
     518                                        var jids;
     519
     520                                        var row_records = CheckJobs.getSelections();
     521
     522                                        for(var i=0; i<row_records.length; i++ )
     523                                        {
     524                                                rsel = row_records[i];
     525                                                if( !jids )
     526                                                {
     527                                                        jids = rsel.get('jid');
     528                                                }
     529                                                else
     530                                                {
     531                                                        jids = jids + ',' + rsel.get('jid');
     532                                                }
     533                                        }
     534                                        NodesDataStore.baseParams.jids  = jids;
     535                                        NodesDataStore.baseParams.c     = myparams.c;
     536                        }
     537                }
     538        }
     539    });
     540
     541function ShowGraphs( Button, Event ) {
     542   
     543    var GraphView = new Ext.DataView({
     544        itemSelector: 'thumb',
     545        style:'overflow:auto',
     546        multiSelect: true,
     547        store: NodesDataStore,
     548        tpl: new Ext.XTemplate(
     549            '<tpl for=".">',
     550            '<div class="thumb"><img src="../../graph.php?z=small&h={h}&x={x}&v={v}&c={c}" border="0"></div>',
     551            '</tpl>'
     552        )
     553    });
     554
     555    var images = new Ext.Panel({
     556        id:'images',
     557        title:'My Images',
     558        region:'center',
     559        margins: '5 5 5 0',
     560        layout:'fit',
     561        items: GraphView
     562    });
     563
     564        if(!win){
     565            win = new Ext.Window({
     566                        width       : 500,
     567                        height      : 300,
     568                        closeAction :'hide',
     569                        items:  [ images ]
     570                    });
     571                }
     572        NodesDataStore.load();
     573        win.show();
     574}
     575
    499576  JobListingEditorGrid =  new Ext.grid.EditorGridPanel({
    500577      id: 'JobListingEditorGrid',
     
    523600                                        'click': {
    524601                                                scope: this,
    525                                                 fn: function() {
    526                                                         if(!win){
    527                                                                     win = new Ext.Window({
    528                                                                         width       : 500,
    529                                                                         height      : 300,
    530                                                                         closeAction :'hide',
    531                                                                     });
    532                                                         }
    533                                                         win.show( this );
    534                                                         alert( CheckJobs.getSelections() );
    535                                                 }
     602                                                fn: ShowGraphs
    536603                                        }
    537604                                }
Note: See TracChangeset for help on using the changeset viewer.