4646
4747display_errors ();
4848
49+ // in general, if there can be lots of something,
50+ // show this many and a link to show all.
51+ // TODO: jobs in a batch
52+ //
4953define ("PAGE_SIZE " , 20 );
5054
5155function return_link () {
@@ -405,6 +409,7 @@ function handle_admin_app($user) {
405409 show_batches ($ batches , PAGE_SIZE , null , $ app );
406410 page_tail ();
407411}
412+
408413function handle_admin_all ($ user ) {
409414 page_head ("Administer batches (all apps) " );
410415 $ batches = BoincBatch::enum ("true order by id desc " );
@@ -471,11 +476,12 @@ function handle_batch_stats($user) {
471476 page_tail ();
472477}
473478
479+ define ('COLOR_SUCCESS ' , 'green ' );
480+ define ('COLOR_FAIL ' , 'red ' );
481+ define ('COLOR_IN_PROGRESS ' , 'deepskyblue ' );
482+ define ('COLOR_UNSENT ' , 'gray ' );
483+
474484// return HTML for a color-coded batch progress bar
475- // green: successfully completed jobs
476- // red: failed
477- // light green: in progress
478- // light gray: unsent
479485//
480486function progress_bar ($ batch , $ wus , $ width ) {
481487 $ nsuccess = $ batch ->njobs_success ;
@@ -488,25 +494,29 @@ function progress_bar($batch, $wus, $width) {
488494 $ w_unsent = $ width *$ nunsent /$ batch ->njobs ;
489495 $ x = '<table height=20><tr> ' ;
490496 if ($ w_fail ) {
491- $ x .= " <td width= $ w_fail bgcolor=red ></td> " ;
497+ $ x .= sprintf ( ' <td width=%d bgcolor=%s ></td> ' , $ w_fail , COLOR_FAIL ) ;
492498 }
493499 if ($ w_success ) {
494- $ x .= " <td width= $ w_success bgcolor=green ></td> " ;
500+ $ x .= sprintf ( ' <td width=%d bgcolor=%s ></td> ' , $ w_success , COLOR_SUCCESS ) ;
495501 }
496502 if ($ w_prog ) {
497- $ x .= " <td width= $ w_prog bgcolor=lightgreen ></td> " ;
503+ $ x .= sprintf ( ' <td width=%d bgcolor=%s ></td> ' , $ w_prog , COLOR_IN_PROGRESS ) ;
498504 }
499505 if ($ w_unsent ) {
500- $ x .= " <td width= $ w_unsent bgcolor=gray ></td> " ;
506+ $ x .= sprintf ( ' <td width=%d bgcolor=%s ></td> ' , $ w_unsent , COLOR_UNSENT ) ;
501507 }
502- $ x .= " </tr></table>
508+ $ x .= sprintf ( ' </tr></table>
503509 <strong>
504- <font color=red> $ nerror failed</font> ·
505- <font color=green> $ nsuccess completed</font> ·
506- <font color=lightgreen> $ nin_prog in progress</font> ·
507- <font color=gray> $ nunsent unsent</font>
508- </strong>
509- " ;
510+ <font color=%s>%d failed</font> ·
511+ <font color=%s>%d completed</font> ·
512+ <font color=%s>%d in progress</font> ·
513+ <font color=%s>%d unsent</font>
514+ </strong> ' ,
515+ COLOR_FAIL , $ nerror ,
516+ COLOR_SUCCESS , $ nsuccess ,
517+ COLOR_IN_PROGRESS , $ nin_prog ,
518+ COLOR_UNSENT , $ nunsent
519+ );
510520 return $ x ;
511521}
512522
@@ -605,16 +615,16 @@ function handle_query_batch($user) {
605615 switch ($ wu ->status ) {
606616 case WU_SUCCESS :
607617 $ resultid = $ wu ->canonical_resultid ;
608- $ y = '<font color="green ">completed</font> ' ;
618+ $ y = sprintf ( '<font color="%s ">completed</font> ' , COLOR_SUCCESS ) ;
609619 break ;
610620 case WU_ERROR :
611- $ y = '<font color="red ">failed</font> ' ;
621+ $ y = sprintf ( '<font color="%s ">failed</font> ' , COLOR_FAIL ) ;
612622 break ;
613623 case WU_IN_PROGRESS :
614- $ y = '<font color="lightgreen ">in progress</font> ' ;
624+ $ y = sprintf ( '<font color="%s ">in progress</font> ' , COLOR_IN_PROGRESS ) ;
615625 break ;
616626 case WU_UNSENT :
617- $ y = '<font color="gray ">unsent</font> ' ;
627+ $ y = sprintf ( '<font color="%s ">unsent</font> ' , COLOR_UNSENT ) ;
618628 break ;
619629 }
620630 $ x = [
@@ -816,6 +826,8 @@ function handle_retire_batch($user) {
816826 }
817827}
818828
829+ // retire multiple batches
830+ //
819831function handle_retire_multi ($ user ) {
820832 $ batches = BoincBatch::enum (
821833 sprintf ('user_id=%d and state=%d ' , $ user ->id , BATCH_STATE_COMPLETE )
@@ -832,6 +844,8 @@ function handle_retire_multi($user) {
832844 page_tail ();
833845}
834846
847+ // given a list of batches, show the ones in a given state
848+ //
835849function show_batches_in_state ($ batches , $ state ) {
836850 switch ($ state ) {
837851 case BATCH_STATE_IN_PROGRESS :
0 commit comments