Changeset 189 for trunk/web


Ignore:
Timestamp:
08/05/05 12:55:27 (18 years ago)
Author:
bastiaans
Message:

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

  • Removed graph timeperiod selection -> to be placed in header

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

  • Added graph timeperiod selection when browsing jobarchive
  • Now a user can change graphing timeperiods for the node detail graphs from the archive!

web/addons/toga/host_view.php:

  • Added correct parsing of timeperiod

web/addons/toga/index.php:

  • Added placement of graph timeperiod selection and variables

web/addons/toga/search.php:

  • Small cleanup
Location:
trunk/web/addons/toga
Files:
5 edited

Legend:

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

    r149 r189  
    66//$tpl->prepare();
    77
     8function datetimeToEpoch( $datetime ) {
     9
     10        //printf("datetime = %s\n", $datetime );
     11        $datetime_fields = explode( ' ', $datetime );
     12
     13        $date = $datetime_fields[0];
     14        $time = $datetime_fields[1];
     15
     16        $date_fields = explode( '-', $date );
     17
     18        $days = $date_fields[0];
     19        $months = $date_fields[1];
     20        $years = $date_fields[2];
     21
     22        //printf( "days = %s months = %s years = %s\n", $days, $months, $years );
     23
     24        $time_fields = explode( ':', $time );
     25
     26        $hours = $time_fields[0];
     27        $minutes = $time_fields[1];
     28        $seconds = $time_fields[2];
     29
     30        //printf( "hours = %s minutes = %s seconds = %s\n", $hours, $minutes, $seconds );
     31
     32        $timestamp = mktime( $hours, $minutes, $seconds, $months, $days, $years );
     33
     34        //printf( "timestamp = %s\n", $timestamp );
     35
     36        return $timestamp;
     37}
    838
    939function makeHostView() {
     
    2454        $tpl->assign("sort",$sort);
    2555        $tpl->assign("range",$range);
     56
     57        if( !is_numeric( $period_start ) ) {
     58                $period_start = datetimeToEpoch( $period_start );
     59        }
     60        if( !is_numeric( $period_stop ) ) {
     61                $period_stop = datetimeToEpoch( $period_stop );
     62        }
    2663
    2764        if($hosts_up)
  • trunk/web/addons/toga/index.php

    r178 r189  
    5959//if( isset($id) && ($id!='')) $filter[id]=$id;
    6060
     61function epochToDatetime( $epoch ) {
     62
     63        return strftime( "%d-%m-%Y %H:%M:%S", $epoch );
     64}
     65
    6166function makeHeader() {
    6267
     
    6974        global $default_refresh, $filterorder, $view;
    7075        global $TARCHD, $period_start, $period_stop, $h, $id;
     76        global $job_start, $job_stop;
    7177       
    7278        if( isset($default_metric) and !isset($m) )
     
    223229        }
    224230
    225         if( $view == "search" ) {
     231        $m = $metricname;
     232
     233
     234        $tpl->gotoBlock( "_ROOT" );
     235        $tpl->assignGlobal("view", $view);
     236
     237        if( array_key_exists( "id", $filter ) or isset($hostname) ) {
     238
     239                //print_r( $context_metrics );
     240
     241                if( !isset( $hostname ) ) {
     242
     243                        if (is_array($context_metrics) ) {
     244                                $metric_menu = "<B>Metric</B>&nbsp;&nbsp;"
     245                                        ."<SELECT NAME=\"m\" OnChange=\"".$form_name.".submit();\">\n";
     246
     247                                sort($context_metrics);
     248                                foreach( $context_metrics as $k ) {
     249                                        $url = rawurlencode($k);
     250                                        $metric_menu .= "<OPTION VALUE=\"$url\" ";
     251                                        if ($k == $metricname )
     252                                                $metric_menu .= "SELECTED";
     253                                        $metric_menu .= ">$k\n";
     254                                }
     255                                $metric_menu .= "</SELECT>\n";
     256
     257                        }
     258                }
     259
     260                $tpl->assign("metric_menu", $metric_menu );
     261
     262                if( $view == "search" or $view == "host" ) {
     263                        $tpl->newBlock("timeperiod");
     264                        if( is_numeric( $period_start ) ) {
     265                                $period_start = epochToDatetime( $period_start );
     266                        }
     267                        if( is_numeric( $period_stop ) ) {
     268                                $period_stop = epochToDatetime( $period_stop );
     269                        }
     270                        $tpl->assign("period_start", $period_start );
     271                        $tpl->assign("period_stop", $period_stop );
     272                        $tpl->assign("hostname", $hostname );
     273
     274                        if( $view == "host" ) {
     275                                $tpl->newBlock("hostview");
     276                                $tpl->assign("job_start", $job_start );
     277                                $tpl->assign("job_stop", $job_stop );
     278                        }
     279                }
     280
     281        }
     282
     283        if( $view == "search" or $view == "host" ) {
    226284
    227285                $node_menu .= "<B>&gt;</B>\n";
    228286                $node_menu .= "<B>Jobarchive</B> ";
    229                 $tpl->assign("view", "search" );
    230287                $form_name = "archive_search_form";
    231288                $tpl->assignGlobal("form_name", $form_name );
     
    234291                $form_name = "toga_form";
    235292                $tpl->assignGlobal("form_name", $form_name );
    236                 $tpl->assign("view", "overview" );
    237         }
    238 
    239         $tpl->assign("node_menu", $node_menu);
    240 
    241         if( array_key_exists( "id", $filter ) ) {
    242 
    243                 //print_r( $context_metrics );
    244 
    245                 if (is_array($context_metrics) ) {
    246                         $metric_menu = "<B>Metric</B>&nbsp;&nbsp;"
    247                                 ."<SELECT NAME=\"m\" OnChange=\"".$form_name.".submit();\">\n";
    248 
    249                         sort($context_metrics);
    250                         foreach( $context_metrics as $k ) {
    251                                 $url = rawurlencode($k);
    252                                 $metric_menu .= "<OPTION VALUE=\"$url\" ";
    253                                 if ($k == $metricname )
    254                                         $metric_menu .= "SELECTED";
    255                                 $metric_menu .= ">$k\n";
    256                         }
    257                         $metric_menu .= "</SELECT>\n";
    258 
    259                 }
    260 
    261                 $tpl->assign("metric_menu", $metric_menu );
    262         }
    263         $m = $metricname;
     293        }
    264294
    265295        if( $TARCHD ) {
     
    267297                $tpl->assignGlobal( "cluster_url", rawurlencode($clustername) );
    268298                $tpl->assignGlobal( "cluster", $clustername );
    269                 $tpl->gotoBlock( "_ROOT" );
    270         }
     299        }
     300        $tpl->gotoBlock( "_ROOT" );
     301        $tpl->assignGlobal( "cluster", $clustername );
     302        $tpl->assign("node_menu", $node_menu);
    271303
    272304        # Make sure that no data is cached..
  • trunk/web/addons/toga/search.php

    r186 r189  
    165165
    166166        return $timestamp;
    167 }
    168 
    169 function epochToDatetime( $epoch ) {
    170 
    171         return strftime( "%d-%m-%Y %H:%M:%S", $epoch );
    172167}
    173168
     
    446441                                //printf("start = %s stop = %s\n", $start, $stop );
    447442
     443                                $tpl->gotoBlock( "timeperiod" );
     444
    448445                                $tpl->assign("period_start", epochToDatetime( $period_start ) );
    449446                                $tpl->assign("period_stop", epochToDatetime( $period_stop ) );
     447
     448                                $tpl->gotoBlock( "_ROOT" );
    450449
    451450                                $hosts_up = array();
  • trunk/web/addons/toga/templates/header.tpl

    r187 r189  
    66<META http-equiv="refresh" content="{refresh}{redirect}" >
    77<LINK rel="stylesheet" href="./styles.css" type="text/css">
     8<SCRIPT LANGUAGE="javascript" SRC="ts_picker.js"></SCRIPT>
     9<SCRIPT LANGUAGE="javascript">
     10
     11        function setPeriodTimestamps() {
     12
     13                document.{form_name}.period_start.value = document.{form_name}.period_start_pick.value;
     14                document.{form_name}.period_stop.value = document.{form_name}.period_stop_pick.value;
     15        }
     16
     17</SCRIPT>
    818</HEAD>
    919<BODY BGCOLOR="#FFFFFF">
    1020
    11 <FORM ACTION="./?c={cluster}&view={view}" METHOD="GET" NAME="{form_name}">
     21<FORM ACTION="./" METHOD="GET" NAME="{form_name}">
     22<INPUT TYPE="HIDDEN" NAME="c" VALUE="{cluster}">
     23<INPUT TYPE="HIDDEN" NAME="view" VALUE="{view}">
    1224<TABLE WIDTH="100%">
    1325<TR>
     
    3547     {metric_menu} &nbsp;&nbsp;
    3648     {range_menu}&nbsp;&nbsp;
    37      {sort_menu}
     49     {sort_menu}&nbsp;&nbsp;
     50<!-- START BLOCK : timeperiod -->
     51    <INPUT TYPE="HIDDEN" NAME="period_start" VALUE="{period_start}">
     52    <INPUT TYPE="HIDDEN" NAME="period_stop" VALUE="{period_stop}">
     53    <INPUT TYPE="HIDDEN" NAME="h" VALUE="{hostname}">
     54    <BR><BR><B>Graph timeperiod/ from
     55    <INPUT TYPE="text" NAME="period_start_pick" VALUE="{period_start}" ALT="Start time" DISABLED="TRUE">
     56    <a href="javascript:show_calendar('document.{form_name}.period_start_pick', document.{form_name}.period_start_pick.value);" alt="Click to select a date/time" title="Click to select a date/time">
     57    <img src="cal.gif" width="16" height="16" border="0"></a>
     58    <a href="#" onClick="javascript: document.{form_name}.period_start_pick.value=''" alt="Click here to clear field" title="Click here to clear field">
     59    <IMG SRC="redcross.jpg" BORDER=0></A>
     60    to <INPUT TYPE="text" NAME="period_stop_pick" VALUE="{period_stop}" ALT="Stop time" DISABLED="TRUE">
     61    <a href="javascript:show_calendar('document.{form_name}.period_stop_pick', document.{form_name}.period_stop_pick.value);" alt="Click to select a date/time" title="Click to select a date/time">
     62    <img src="cal.gif" width="16" height="16" border="0"></a>
     63    <a href="#" onClick="javascript: document.{form_name}.period_stop_pick.value=''" alt="Click here to clear field" title="Click here to clear field">
     64    </B>
     65    <IMG SRC="redcross.jpg" BORDER=0></A>
     66
     67<!-- START BLOCK : hostview -->
     68    <INPUT TYPE="HIDDEN" NAME="job_start" VALUE="{job_start}">
     69    <INPUT TYPE="HIDDEN" NAME="job_stop" VALUE="{job_stop}">
     70<!-- END BLOCK : hostview -->
     71    <INPUT TYPE="submit" onClick="setPeriodTimestamps();" VALUE="Refresh graphs">
     72<!-- END BLOCK : timeperiod -->
    3873     </TD>
    3974     <TD>
  • trunk/web/addons/toga/templates/search.tpl

    r157 r189  
    11<CENTER>
    22
    3 <SCRIPT LANGUAGE="javascript" SRC="ts_picker.js"></SCRIPT>
    43<SCRIPT LANGUAGE="javascript">
    54function setSort( sortbyval ) {
     
    5049        }
    5150
    52         function setPeriodTimestamps() {
    53 
    54                 document.archive_search_form.period_start.value = document.archive_search_form.period_start_pick.value;
    55                 document.archive_search_form.period_stop.value = document.archive_search_form.period_stop_pick.value;
    56         }
    57 
    5851</SCRIPT>
    5952
    60 <FORM NAME="archive_search_form" ACTION="./">
    61 
    62 <INPUT TYPE="hidden" NAME="view" VALUE="search">
     53<!-- <FORM NAME="archive_search_form" ACTION="./"> -->
     54
     55<!-- <INPUT TYPE="hidden" NAME="view" VALUE="search"> -->
    6356
    6457<BR><BR>
     
    258251   Columns&nbsp;&nbsp;{cols_menu}
    259252   </FONT><BR>
    260 <FONT SIZE="-1">
    261     <INPUT TYPE="HIDDEN" NAME="period_start" VALUE="{period_start}">
    262     <INPUT TYPE="HIDDEN" NAME="period_stop" VALUE="{period_stop}">
    263     Graph timeperiod from
    264     <INPUT TYPE="text" NAME="period_start_pick" VALUE="{period_start}" ALT="Start time" DISABLED="TRUE">
    265     <a href="javascript:show_calendar('document.archive_search_form.period_start_pick', document.archive_search_form.period_start_pick.value);" alt="Click to select a date/time" title="Click to select a date/time">
    266     <img src="cal.gif" width="16" height="16" border="0"></a>
    267     <a href="#" onClick="javascript: document.archive_search_form.period_start_pick.value=''" alt="Click here to clear field" title="Click here to clear field">
    268     <IMG SRC="redcross.jpg" BORDER=0></A>
    269     to <INPUT TYPE="text" NAME="period_stop_pick" VALUE="{period_stop}" ALT="Stop time" DISABLED="TRUE">
    270     <a href="javascript:show_calendar('document.archive_search_form.period_stop_pick', document.archive_search_form.period_stop_pick.value);" alt="Click to select a date/time" title="Click to select a date/time">
    271     <img src="cal.gif" width="16" height="16" border="0"></a>
    272     <a href="#" onClick="javascript: document.archive_search_form.period_stop_pick.value=''" alt="Click here to clear field" title="Click here to clear field">
    273     <IMG SRC="redcross.jpg" BORDER=0></A>
    274     <INPUT TYPE="submit" onClick="setPeriodTimestamps();" VALUE="Refresh graphs">
    275    </FONT>
    276253  </TD>
    277254</TR>
Note: See TracChangeset for help on using the changeset viewer.