source: trunk/web2/addons/job_monarch/js/jobgrid.js @ 542

Last change on this file since 542 was 542, checked in by ramonb, 16 years ago

not job name

File size: 5.8 KB
Line 
1var JobsDataStore;
2var JobsColumnModel;
3var JobListingEditorGrid;
4var JobListingWindow;
5var JobProxy;
6
7//Ext.onReady( initJobGrid() );
8
9function initJobGrid() {
10
11  Ext.QuickTips.init();
12
13  function jobCellClick(grid, rowIndex, columnIndex, e)
14  {
15    var fieldName = grid.getColumnModel().getDataIndex(columnIndex);
16
17    var view = grid.getView();
18    var cell = view.getCell( rowIndex, columnIndex );
19
20    if( fieldName == 'owner' || fieldName == 'jid' || fieldName == 'status' || fieldName == 'queue' )
21    {
22      Ext.fly(cell).removeClass( 'filter' );
23      Ext.fly(cell).addClass( 'filterenabled' );
24    }
25  }
26
27  function jobCellRender( value, metadata, record, rowindex, colindex, store )
28  {
29    var fieldName = JobsColumnModel.getColumnById( colindex ).dataIndex;
30
31    if( fieldName == 'owner' || fieldName == 'jid' || fieldName == 'status' || fieldName == 'queue' )
32    {
33      metadata.css = 'filter';
34    }
35    return value;
36  }
37
38  JobProxy = new Ext.data.HttpProxy({
39                url: 'jobstore.php',
40                method: 'POST'
41            });
42
43  JobsDataStore = new Ext.data.Store({
44      id: 'JobsDataStore',
45      proxy: JobProxy,
46      baseParams:{task: "LISTING"}, // this parameter is passed for any HTTP request
47      reader: new Ext.data.JsonReader({
48        root: 'results',
49        totalProperty: 'total',
50        id: 'id'
51      },[
52        {name: 'jid', type: 'int', mapping: 'jid'},
53        {name: 'status', type: 'string', mapping: 'status'},
54        {name: 'owner', type: 'string', mapping: 'owner'},
55        {name: 'queue', type: 'string', mapping: 'queue'},
56        {name: 'name', type: 'string', mapping: 'name'},
57        {name: 'requested_time', type: 'string', mapping: 'requested_time'},
58        //{name: 'requested_memory', type: 'string', mapping: 'requested_memory'},
59        {name: 'ppn', type: 'int', mapping: 'ppn'},
60        {name: 'nodect', type: 'int', mapping: 'nodect'},
61        {name: 'nodes', type: 'string', mapping: 'nodes'},
62        {name: 'queued_timestamp', type: 'string', mapping: 'queued_timestamp'},
63        {name: 'start_timestamp', type: 'string', mapping: 'start_timestamp'},
64        {name: 'runningtime', type: 'string', mapping: 'runningtime'}
65      ]),
66      sortInfo: {field: 'jid', direction: "ASC"},
67      remoteSort: true
68    });
69   
70  JobsColumnModel = new Ext.grid.ColumnModel(
71    [{
72        header: '#',
73        tooltip: 'Job id',
74        readOnly: true,
75        dataIndex: 'jid',
76        width: 50,
77        hidden: false,
78        renderer: jobCellRender
79      },{
80        header: 'S',
81        tooltip: 'Job status',
82        readOnly: true,
83        dataIndex: 'status',
84        width: 20,
85        hidden: false,
86        renderer: jobCellRender
87      },{
88        header: 'User',
89        tooltip: 'Owner of job',
90        readOnly: true,
91        dataIndex: 'owner',
92        width: 60,
93        hidden: false,
94        renderer: jobCellRender
95      },{
96        header: 'Queue',
97        tooltip: 'In which queue does this job reside',
98        readOnly: true,
99        dataIndex: 'queue',
100        width: 60,
101        hidden: false,
102        renderer: jobCellRender
103      },{
104        header: 'Name',
105        tooltip: 'Name of job',
106        readOnly: true,
107        dataIndex: 'name',
108        width: 100,
109        hidden: false
110      },{
111        header: 'Requested Time',
112        tooltip: 'Amount of requested time (wallclock)',
113        readOnly: true,
114        dataIndex: 'requested_time',
115        width: 100,
116        hidden: false
117      },{
118        header: 'Requested Memory',
119        tooltip: 'Amount of requested memory',
120        readOnly: true,
121        dataIndex: 'requested_memory',
122        width: 100,
123        hidden: true
124      },{
125        header: 'P',
126        tooltip: 'Number of processors per node (PPN)',
127        readOnly: true,
128        dataIndex: 'ppn',
129        width: 25,
130        hidden: false
131      },{
132        header: 'N',
133        tooltip: 'Number of nodes (hosts)',
134        readOnly: true,
135        dataIndex: 'nodect',
136        width: 25,
137        hidden: false
138      },{
139        header: 'Nodes',
140        readOnly: true,
141        dataIndex: 'nodes',
142        width: 100,
143        hidden: true
144      },{
145        header: 'Queued',
146        tooltip: 'At what time did this job enter the queue',
147        readOnly: true,
148        dataIndex: 'queued_timestamp',
149        width: 140,
150        hidden: false
151      },{
152        header: 'Started',
153        tooltip: 'At what time did this job enter the running status',
154        readOnly: true,
155        dataIndex: 'start_timestamp',
156        width: 140,
157        hidden: false
158      },{
159        header: 'Runningtime',
160        tooltip: 'How long has this job been in the running status',
161        readOnly: true,
162        dataIndex: 'runningtime',
163        width: 140,
164        hidden: false
165      }]
166    );
167    JobsColumnModel.defaultSortable= true;
168
169  JobListingEditorGrid =  new Ext.grid.EditorGridPanel({
170      id: 'JobListingEditorGrid',
171      store: JobsDataStore,
172      cm: JobsColumnModel,
173      enableColLock:false,
174      clicksToEdit:1,
175      selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
176      bbar: new Ext.PagingToolbar({
177                pageSize: 30,
178                store: JobsDataStore,
179                displayInfo: true,
180                displayMsg: 'Displaying jobs {0} - {1} out of {2} jobs total found.',
181                emptyMsg: 'No jobs found to display'
182            }),
183      tbar: [ new Ext.app.SearchField({
184                                store: JobsDataStore,
185                                params: {start: 0, limit: 30},
186                                width: 200
187                    })
188      ]
189    });
190
191  JobListingWindow = new Ext.Window({
192      id: 'JobListingWindow',
193      title: 'Cluster Jobs Overview',
194      closable:true,
195      collapsible: true,
196      animCollapse: true,
197      maximizable: true,
198      minimizable: true,
199      width:900,
200      height:500,
201      plain:true,
202      shadow: true,
203      shadowOffset: 10,
204      layout: 'fit',
205      items: JobListingEditorGrid
206    });
207
208  JobListingEditorGrid.addListener( 'cellclick', jobCellClick );
209}
Note: See TracBrowser for help on using the repository browser.