Ignore:
Timestamp:
06/16/05 11:22:29 (19 years ago)
Author:
bastiaans
Message:

web/addons/toga/libtoga.php:

  • Fixed couple of dbase selecting bugs

web/addons/toga/cal.gif:

  • Image for date/time selector

web/addons/toga/templates/search.tpl:

  • Removed bogus/wrong extra hidden fields messing up the search (leftover from overview template)

web/addons/toga/ts_picker.js:

  • javascript for calendar date/time selector

web/addons/toga/libtoga.js:

  • Our misc. javascript functions

web/addons/toga/bricks.jpg:

  • Image for archive link

web/addons/toga/search.php:

  • Now displays jobs of search in same manner as overview

web/addons/toga/ts_validatetime.js:

  • javascript to validate time in calendar
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/addons/toga/search.php

    r140 r141  
    3030}
    3131
     32function makeTime( $time ) {
     33
     34        $days = intval( $time / 86400 );
     35        $time = ($days>0) ? $time % ($days * 86400) : $time;
     36
     37        //printf( "time = %s, days = %s\n", $time, $days );
     38
     39        $date_str = '';
     40        $day_str = '';
     41
     42        if( $days > 0 ) {
     43                if( $days > 1 )
     44                        $day_str .= $days . ' days';
     45                else
     46                        $day_str .= $days . ' day';
     47        }
     48
     49        $hours = intval( $time / 3600 );
     50        $time = $hours ? $time % ($hours * 3600) : $time;
     51
     52        //printf( "time = %s, days = %s, hours = %s\n", $time, $days, $hours );
     53
     54        if( $hours > 0 ) {
     55                $date_str .= $hours . ':';
     56                $date_unit = 'hours';
     57        }
     58
     59        $minutes = intval( $time / 60 );
     60        $seconds = $minutes ? $time % ($minutes * 60) : $time;
     61
     62        if( $minutes > 0 ) {
     63
     64                if( $minutes >= 10 )
     65                        $date_str .= $minutes . ':';
     66                else
     67                        $date_str .= '0' . $minutes . ':';
     68
     69                $date_unit = (!isset($date_unit)) ? 'minutes' : $date_unit;
     70        } else {
     71                if($hours > 0 ) {
     72                        $date_str .= '00:';
     73                        $date_unit = (!isset($date_unit)) ? 'minutes' : $date_unit;
     74                }
     75        }
     76
     77
     78        $date_unit = (!isset($date_unit)) ? 'seconds' : $date_unit;
     79
     80        if( $seconds > 0 ) {
     81
     82                if( $seconds >= 10 )
     83                        $date_str .= $seconds . ' ' . $date_unit;
     84                else
     85                        $date_str .= '0' . $seconds . ' ' . $date_unit;
     86
     87        } else if ( $hours > 0 or $minutes > 0 )
     88
     89                $date_str .= '00 ' . $date_unit;
     90
     91        if( $days > 0) {
     92
     93                if( $hours > 0 or $minutes > 0 or $seconds > 0 )
     94                        $date_str = $day_str . ' - ' . $date_str;
     95                else
     96                        $date_str = $day_str;
     97        }
     98
     99        return $date_str;
     100}
     101
     102function makeDate( $time ) {
     103        return strftime( "%a %d %b %Y %H:%M:%S", $time );
     104}
     105
     106function timeToEpoch( $time ) {
     107
     108        $time_fields = explode( ':', $time );
     109
     110        if( count($time_fields) == 3 ) {
     111
     112                $hours = $time_fields[0];
     113                $minutes = $time_fields[1];
     114                $seconds = $time_fields[2];
     115
     116        } else if( count($time_fields) == 2 ) {
     117
     118                $hours = 0;
     119                $minutes = $time_fields[0];
     120                $seconds = $time_fields[1];
     121
     122        } else if( count($time_fields) == 1 ) {
     123
     124                $hours = 0;
     125                $minutes = 0;
     126                $seconds = $time_fields[0];
     127        }
     128
     129        $myepoch = intval( $seconds + (intval( $minutes * 60 )) + (intval( $hours * 3600 )) );
     130
     131        return $myepoch;
     132}
     133
    32134function makeSearchPage() {
    33135        global $clustername, $tpl, $id, $user, $name, $start_from_time, $start_to_time, $queue;
     
    52154                foreach( $search_ids as $foundid ) {
    53155
    54                         printf("found job %s\n", $foundid );
     156                        $job = $tdb->getJobArray( $foundid );
     157                        $nodes = $tdb->getNodesForJob( $foundid );
     158
     159                        $tpl->newBlock( "node" );
     160                        $tpl->assign( "id", $job[id] );
     161                        $tpl->assign( "state", $job[status] );
     162                        $tpl->assign( "user", $job[owner] );
     163                        $tpl->assign( "queue", $job[queue] );
     164                        $tpl->assign( "name", $job[name] );
     165                        $tpl->assign( "req_cpu", makeTime( TimeToEpoch( $job[requested_time] ) ) );
     166                        $tpl->assign( "req_memory", $job[requested_memory] );
     167
     168                        $nodes_nr = count( $nodes );
     169                        $domain = $job[domain];
     170                        $ppn = (int) $job[ppn] ? $job[ppn] : 1;
     171                        $cpus = $nodes_nr * $ppn;
     172
     173                        $tpl->assign( "nodes", $nodes_nr );
     174                        $tpl->assign( "cpus", $cpus );
     175
     176                        $runningtime = intval( $job[stop_timestamp] - $job[start_timestamp] );
     177                        $tpl->assign( "started", makeDate( $job[start_timestamp] ) );
     178                        $tpl->assign( "finished", makeDate( $job[stop_timestamp] ) );
     179                        $tpl->assign( "runningtime", makeTime( $runningtime ) );
     180                       
     181                        print_r( $job );
     182                        print_r( $nodes );
    55183                        //output jobzooi
    56184
Note: See TracChangeset for help on using the changeset viewer.