Changeset 141 for trunk/web


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
Location:
trunk/web/addons/toga
Files:
5 added
3 edited

Legend:

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

    r140 r141  
    158158                foreach( $result as $result_row )
    159159
    160                         $nodes[] = $this->getNodeArray( $result_row['id'] );
     160                        $nodes[] = $this->getNodeArray( $result_row[node_id] );
    161161
    162162                return $nodes;
     
    171171                foreach( $result as $result_row )
    172172
    173                         $jobs[] = $this->getJobArray( $result_row['id'] );
     173                        $jobs[] = $this->getJobArray( $result_row[job_id] );
    174174
    175175                return $jobs;
     
    197197                        $map_key = explode( '_', $mykey );
    198198
    199                         $newkey = $map_key[1];
     199                        $rmap_key = array_reverse( $map_key );
     200                        array_pop( $rmap_key );
     201                        $map_key = array_reverse( $rmap_key );
     202                       
     203                        $newkey = implode( '_', $map_key );
    200204                       
    201205                        $myar[$newkey] = $result_row[$mykey];
     
    212216                        $this->connect();
    213217
     218                printf( "query = [%s]\n", $query );
    214219                $result = pg_query( $this->conn, $query );
    215220
     
    294299
    295300        function graph( $descr ) {
     301//      monitor2:/data/toga/rrds/LISA Cluster/gb-r15n11.irc.sara.nl# rrdtool graph /var/www/ganglia/test1.png --start 1118683231 --end 1118750431 --width 300 --height 400 DEF:'1'='./1118647515/load_one.rrd':'sum':AVERAGE DEF:'2'='./1118690723/load_one.rrd':'sum':AVERAGE DEF:'3'='./1118733925/load_one.rrd':'sum':AVERAGE AREA:1#555555:"load_one" AREA:2#555555 AREA:3#555555
     302//      380x461
     303//      monitor2:/data/toga/rrds/LISA Cluster/gb-r15n11.irc.sara.nl#
    296304                //$command = $this->rrdbin . " graph - --start $start --end $end ".
    297305                        "--width $width --height $height $upper_limit $lower_limit ".
  • 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
  • trunk/web/addons/toga/templates/search.tpl

    r140 r141  
    11<CENTER>
    22</FORM>
     3
    34<SCRIPT LANGUAGE="javascript" SRC="ts_picker.js"></SCRIPT>
    4 <SCRIPT TYPE="text/javascript" SRC="libtoga.js"></SCRIPT>
     5<SCRIPT LANGUAGE="javascript" SRC="libtoga.js"></SCRIPT>
    56<SCRIPT LANGUAGE="javascript">
    67
     
    151152
    152153</TABLE>
    153 </FORM>
    154154<BR><BR>
    155155<!-- START BLOCK : search_results -->
    156 <SCRIPT TYPE="text/javascript" SRC="libtoga.js"></SCRIPT>
    157156
    158157<INPUT TYPE="HIDDEN" NAME="sortby" VALUE="{sortby}">
    159158<INPUT TYPE="HIDDEN" NAME="sortorder" VALUE="{sortorder}">
    160 <INPUT TYPE="HIDDEN" NAME="c" VALUE="{clustername}">
    161 <INPUT TYPE="HIDDEN" NAME="queue" VALUE="{f_queue}">
    162 <INPUT TYPE="HIDDEN" NAME="state" VALUE="{f_state}">
    163 <INPUT TYPE="HIDDEN" NAME="user" VALUE="{f_user}">
    164 <INPUT TYPE="HIDDEN" NAME="id" VALUE="{f_id}">
    165159<INPUT TYPE="HIDDEN" NAME="filterorder" VALUE="{f_order}">
    166160
     
    217211    <INPUT TYPE="HIDDEN" NAME="start" VALUE="{start}">
    218212    <INPUT TYPE="HIDDEN" NAME="stop" VALUE="{stop}">
    219     Set graph timeperiod from <INPUT TYPE="text" NAME="period_start_pick" VALUE="{start}" SIZE=12 ALT="Start time"><a href="javascript:show_calendar('document.search_form.period_start_pick', document.search_form.period_start_pick.value);"><img src="cal.gif" width="16" height="16" border="0"></a> to <INPUT TYPE="text" NAME="period_stop_pick" VALUE="{stop}" SIZE=12 ALT="Stop time"><a href="javascript:show_calendar('document.toga_form.period_stop_pick', document.search_form.period_stop_pick.value);"><img src="cal.gif" width="16" height="16" border="0"></a><INPUT TYPE="submit" onClick="setPeriodTimestamps();" VALUE="Refresh graphs">
     213    Set graph timeperiod from
     214    <INPUT TYPE="text" NAME="period_start_pick" VALUE="{start}" SIZE=12 ALT="Start time" DISABLED="TRUE">
     215    <a href="javascript:show_calendar('document.archive_search_form.period_start_pick', document.archive_search_form.period_start_pick.value);"><img src="cal.gif" width="16" height="16" border="0"></a>
     216    to <INPUT TYPE="text" NAME="period_stop_pick" VALUE="{stop}" SIZE=12 ALT="Stop time" DISABLED="TRUE">
     217    <a href="javascript:show_calendar('document.archive_search_form.period_stop_pick', document.archive_search_form.period_stop_pick.value);"><img src="cal.gif" width="16" height="16" border="0"></a>
     218    <INPUT TYPE="submit" onClick="setPeriodTimestamps();" VALUE="Refresh graphs">
    220219   </FONT>
    221220  </TD>
Note: See TracChangeset for help on using the changeset viewer.