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

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

job_monarch/overview.php:

  • set clusterimage height and width for Ext Window

job_monarch/libtoga.php:

  • added onclick call to node image map

job_monarch/js/jobgrid.js:

  • added seperate Window for ClusterImage?
  • added placeholder function for host selection in clusterimage
  • position window better

job_monarch/templates/overview.tpl:

job_monarch/templates/header.tpl:

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