- Timestamp:
- 07/11/08 11:05:46 (15 years ago)
- Location:
- trunk/web2/addons/job_monarch
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web2/addons/job_monarch/jobstore.php
r537 r538 7 7 // Supplied by ExtJS when DataStore has remoteSort: true 8 8 // 9 $sortfield = $_POST["sort"]; 10 $sortorder = $_POST["dir"]; // ASC or DESC 9 $sortfield = isset($_POST['sort'] ) ? $_POST["sort"] : "jid"; 10 $sortorder = isset($_POST['dir'] ) ? $_POST["dir"] : "ASC"; // ASC or DESC 11 12 // Search query from ext.SearchField 13 // 14 $query = isset($_POST['query']) ? $_POST['query'] : null; 11 15 12 16 global $c, $clustername, $cluster; … … 19 23 $pend = (int) $_POST['limit']; 20 24 25 //echo $pend.'p '; 21 26 // Need to fool Ganglia here: or it won't parse XML for our cluster 22 27 // … … 53 58 $task = $HTTP_POST_VARS['task']; 54 59 } 55 56 //getList();57 60 58 61 switch($task) … … 64 67 echo "{failure:true}"; 65 68 break; 69 } 70 71 function quickSearchJobs( $jobs, $query ) 72 { 73 $searchresults = array(); 74 75 foreach( $jobs as $jobid => $jobattrs ) 76 { 77 if( $query != null ) 78 { 79 if( strpos( $jobattrs['jid'], $query ) !== false ) 80 { 81 $searchresults[$jobid] = $jobattrs; 82 } 83 if( strpos( $jobattrs['owner'], $query ) !== false ) 84 { 85 $searchresults[$jobid] = $jobattrs; 86 } 87 if( strpos( $jobattrs['queue'], $query ) !== false ) 88 { 89 $searchresults[$jobid] = $jobattrs; 90 } 91 if( strpos( $jobattrs['name'], $query ) !== false ) 92 { 93 $searchresults[$jobid] = $jobattrs; 94 } 95 } 96 } 97 98 return $searchresults; 66 99 } 67 100 … … 181 214 { 182 215 global $jobs, $hearbeat, $pstart, $pend; 183 global $sortfield, $sortorder ;184 185 $job_count = count( $jobs );216 global $sortfield, $sortorder, $query; 217 218 $job_count = count( $jobs ); 186 219 187 220 if( $job_count == 0 ) 188 221 { 189 echo ' crap({"total":"0", "results":""})';222 echo '({"total":"0", "results":""})'; 190 223 return 0; 191 224 } 192 225 193 $jobresults = array(); 194 195 $cur_job = 0; 196 197 198 // sorteer jobs op sortorder en sortfield 199 200 //if( $pstart > 0 ) { 201 //echo $pstart; 202 //echo $pend; } 203 226 $jobresults = array(); 227 228 $cur_job = 0; 204 229 205 230 $sorted_jobs = sortJobs( $jobs, $sortfield, $sortorder ); 206 231 207 $result_count = count( $sorted_jobs ); 232 if( $query != null ) 233 { 234 $jobs = quickSearchJobs( $jobs, $query ); 235 } 236 $result_count = count( $jobs ); 208 237 209 238 foreach( $sorted_jobs as $jobid => $jobattrs ) … … 214 243 //} 215 244 216 if( ( $cur_job < $pstart ) || ( ($cur_job - $pstart) >= $pend ) ) 217 { 218 $cur_job = $cur_job + 1; 245 if( ! array_key_exists( $jobid, $jobs ) ) 246 { 219 247 continue; 220 248 } 221 249 250 $jr = array(); 222 251 $jr['jid'] = strval( $jobid ); 223 252 $jr['status'] = $jobs[$jobid]['status']; … … 261 290 } 262 291 263 $cur_job = $cur_job + 1; 292 if( ( $cur_job < $pstart ) || ( ($cur_job - $pstart) >= $pend ) ) 293 { 294 $cur_job = $cur_job + 1; 295 continue; 296 } 297 else 298 { 299 $cur_job = $cur_job + 1; 300 } 264 301 265 302 $jobresults[] = $jr; … … 273 310 } 274 311 275 // Encodes a SQL array into a JSON formated string 312 // Encodes a SQL array into a JSON formated string: so that Javascript may understand it 313 // 276 314 function JEncode( $arr ) 277 315 { 278 if (version_compare(PHP_VERSION,"5.2","<"))316 if( version_compare( PHP_VERSION, "5.2", "<" ) ) 279 317 { 280 require_once( "./JSON.php");//if php<5.2 need JSON class281 282 $json = new Services_JSON(); //instantiate new json object283 $data = $json->encode( $arr);//encode the data in json format318 require_once( "./JSON.php" ); //if php<5.2 need JSON class 319 320 $json = new Services_JSON(); //instantiate new json object 321 $data = $json->encode( $arr ); //encode the data in json format 284 322 } 285 323 else 286 324 { 287 $data = json_encode( $arr);//encode the data in json format325 $data = json_encode( $arr ); //encode the data in json format 288 326 } 289 327 -
trunk/web2/addons/job_monarch/js/jobgrid.js
r537 r538 149 149 store: JobsDataStore, 150 150 displayInfo: true 151 }) 151 }), 152 tbar: [ new Ext.app.SearchField({ 153 store: JobsDataStore, 154 params: {start: 0, limit: 30}, 155 width: 200 156 }) 157 ] 152 158 }); 153 159 -
trunk/web2/addons/job_monarch/templates/header.tpl
r537 r538 11 11 <script type="text/javascript" src="./lib/extjs/ext-all.js"></script> 12 12 <script type="text/javascript" src="./lib/extjs/ext-all-debug.js"></script> 13 13 <script type="text/javascript" src="./lib/extjs/searchfield.js"></script> 14 14 <script type="text/javascript" src="./js/jobgrid.js"></script> 15 15 <script type="text/javascript">
Note: See TracChangeset
for help on using the changeset viewer.