Changeset e13f962a493538e54cf6984e35513d9844300044

Show
Ignore:
Timestamp:
11/21/08 18:11:42 (5 years ago)
Author:
Umar Farooq <umar@omniti.com>
git-committer:
Umar Farooq <umar@omniti.com> 1227291102 +0000
git-parent:

[f67c8f851568c1e75293edbe51cd405f940bab8b]

git-author:
Umar Farooq <umar@omniti.com> 1227291102 +0000
Message:

adding initial code for templates, enabling stacking for metric plotted on left axis, and fixing showing/hiding metrics bug

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ui/web/htdocs/.htaccess

    r171b238 re13f962  
    33RewriteRule ^json/ds/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ datapoint_browse_json.php?l1=$1&l2=$2&l3=$3&l4=$4 [PT,QSA] 
    44RewriteRule ^json/ds/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ datapoint_browse_json.php?l1=$1&l2=$2&l3=$3&l4=$4&l5=$5 [PT,QSA] 
     5RewriteRule ^json/templates/([^/]+)/([^/]+)$ template_browse_json.php?l1=$1&l2=$2 [PT,QSA] 
    56RewriteRule ^json/worksheet/info/([^/]*)$ worksheet_info.php?id=$1 [PT,QSA] 
    67RewriteRule ^json/worksheet/store$ worksheet_store.php [PT,QSA] 
  • ui/web/htdocs/graph_panel.inc

    r171b238 re13f962  
    4040             }); 
    4141           } 
    42            if(redraw && maingraph) maingraph.ReconGraphRefresh({graphid: graphinfo.id}); 
     42           if(redraw && maingraph) maingraph.ReconGraphRefresh({graphid: graphinfo.id, type: graphinfo.type}); 
    4343           if(f) f(d); 
    4444           recurse--; 
     
    182182  if(maingraph) { 
    183183    if(graphinfo.id)  
    184       maingraph.ReconGraphRefresh({graphid: graphinfo.id}); 
     184      maingraph.ReconGraphRefresh({graphid: graphinfo.id, type: graphinfo.type}); 
    185185    else 
    186186      maingraph.ReconGraphReset(); 
     
    230230                displayinfo.end = ''; 
    231231                $(this).addClass("selected"); 
    232                 maingraph.ReconGraphRefresh({graphid: graphinfo.id, start: time_windows[$(this).html()], end: ''}); 
     232                maingraph.ReconGraphRefresh({graphid: graphinfo.id, start: time_windows[$(this).html()], end: '', type: graphinfo.type}); 
    233233                return false; 
    234234        }); 
     
    248248                        displayinfo.start = start.toUTCString(); 
    249249                        displayinfo.end = end.toUTCString(); 
    250                         maingraph.ReconGraphRefresh({graphid: graphinfo.id}); 
     250                        maingraph.ReconGraphRefresh({graphid: graphinfo.id, type: graphinfo.type}); 
    251251                        $('#graph_datetool .range a.btn-slide').get(0).innerHTML = formated.join(' - '); 
    252252                } 
     
    306306        <legend style="display:none;">View</legend> 
    307307        <label for="std_view"><input class="graphType" type="radio" name="graphtype" id="std_view" value="standard"/> Standard View</label> &nbsp;&nbsp;&nbsp; 
    308         <label for="stacked_view"><input class="graphType" type="radio" name="graphtype" id="stacked_view" value="stacked" /> Stacked View</label> 
     308        <label for="stacked_view"><input class="graphType" type="radio" name="graphtype" id="stacked_view" value="stacked" /> Stack Left Axis</label> 
    309309        </fieldset> 
    310310        </form> 
  • ui/web/htdocs/index.php

    rd609520 re13f962  
    7272    </script> 
    7373 
     74   <script type="text/javascript"> 
     75        jQuery(document).ready(function(){ 
     76            $("#templates").treeview({ 
     77              url: "json/templates/templateid/metric_name", 
     78              params: {} 
     79              }) 
     80        }); 
     81    </script> 
     82 
    7483<!-- search tabs --> 
    7584<script type="text/javascript"> 
  • ui/web/htdocs/js/jquery.flot.js

    r646f051 re13f962  
    44 * 
    55 */ 
    6  
    76(function($) { 
    87    function Plot(target_, data_, options_) { 
     
    9493                }, 
    9594                shadowSize: 4 
    96             }, 
     95       }, 
    9796        canvas = null,      // the canvas for the plot itself 
    9897        overlay = null,     // canvas for interactive stuff on top of plot 
     
    10241023 
    10251024        function drawSeries(series) { 
    1026             if (series.lines.show || (!series.bars.show && !series.points.show)) 
     1025 
     1026            //this module assumed we always want to show something, thus if nothing was set to show 
     1027            //it plotted lines....sometimes, we dont wanna show anything 
     1028            if (series.lines.show) // || (!series.bars.show && !series.points.show)) 
    10271029                drawSeriesLines(series); 
    10281030            if (series.bars.show) 
  • ui/web/htdocs/js/recon.js

    r171b238 re13f962  
     1 
     2function dump(arr,level) { 
     3        var dumped_text = ""; 
     4        if(!level) level = 0; 
     5         
     6        //The padding given at the beginning of the line. 
     7        var level_padding = ""; 
     8        for(var j=0;j<level+1;j++) level_padding += "    "; 
     9         
     10        if(typeof(arr) == 'object') { //Array/Hashes/Objects  
     11                for(var item in arr) { 
     12                        var value = arr[item]; 
     13                         
     14                        if(typeof(value) == 'object') { //If it is an array, 
     15                                dumped_text += level_padding + "'" + item + "' ...\n"; 
     16                                dumped_text += dump(value,level+1); 
     17                        } else { 
     18                                dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n"; 
     19                        } 
     20                } 
     21        } else { //Stings/Chars/Numbers etc. 
     22                dumped_text = "===>"+arr+"<===("+typeof(arr)+")"; 
     23        } 
     24        return dumped_text; 
     25} 
     26 
    127(function ($) { 
    228  var ReconGraph = function() { 
     
    4773          $.getJSON(url, {'cnt':this.graphinfo.cnt, 
    4874                          'start':this.graphinfo.start, 
    49                           'end':this.graphinfo.end}, 
     75                          'end':this.graphinfo.end, 
     76                          'type':this.graphinfo.type}, 
    5077                    (function(o) { return function (r) { o.ReconGraphPlot(r, function() { o.ReconGraphRefresh(); }) }})(this)); 
    5178          this.data('__recon', this); 
  • ui/web/htdocs/json_graph_flot.php

    r6cbb5ff re13f962  
    77require_once('graph_settings.inc'); 
    88 
     9$type = $_GET['type']; 
     10 
    911$start = $_GET['start']?$_GET['start']:(7*86400); 
    1012if(preg_match('/^\d+$/', $start)) 
     
    1315$cnt = $_GET['cnt']?$_GET['cnt']:400; 
    1416 
    15 $driver = new Reconnoiter_flot_Driver($start, $end, $cnt); 
     17$driver = new Reconnoiter_flot_Driver($start, $end, $cnt, $type); 
    1618$db = Reconnoiter_DB::GetDB(); 
    1719$row = $db->getGraphByID($_GET['id']); 
  • ui/web/lib/Reconnoiter_DB.php

    r171b238 re13f962  
    2020  } 
    2121  function connect() { 
    22     $this->db = new PDO("pgsql:host=localhost;dbname=reconnoiter", 
     22    $this->db = new PDO("pgsql:host=noit.office.omniti.com;dbname=reconnoiter", 
    2323                        "prism", "prism"); 
    2424    $this->db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); 
  • ui/web/lib/Reconnoiter_DataContainer.php

    r6e38cf9 re13f962  
    1414  protected $percentile; 
    1515  protected $title; 
     16  protected $type; 
    1617 
    1718  protected $master_set; 
     
    2021  protected $guides; 
    2122 
    22   function __construct($start, $end, $cnt) { 
     23  function __construct($start, $end, $cnt, $type) { 
    2324    $this->start = $start; 
    2425    $this->end = $end; 
     
    2728    $this->guides = array(); 
    2829    $this->ps_to_calc = array(0 => 'true', 95 => 'true', 100 => 'true'); 
     30    $this->type = $type; 
    2931  } 
    3032  function start() { return $this->start; } 
  • ui/web/lib/Reconnoiter_flot_Driver.php

    r715840d re13f962  
    44 
    55class Reconnoiter_flot_Driver extends Reconnoiter_DataContainer { 
    6   function __construct($start, $end, $cnt) { 
    7     parent::__construct($start, $end, $cnt); 
     6  function __construct($start, $end, $cnt, $type) { 
     7    parent::__construct($start, $end, $cnt, $type); 
    88  } 
    99  function defaultDataSetAttrs($uuid, $name, $derive, $attrs) { 
     
    3434        'yaxis' => ($this->sets_config[$name]['axis'] == 'right') ? 2 : 1, 
    3535      ); 
    36       if($this->sets_config[$name]['hidden'] != "true") { 
     36       
     37      $show_set = ($this->sets_config[$name]['hidden'] != "true") ? 1: 0; 
     38      if($show_set) { 
    3739        $ds['label'] = $ds['dataname']; 
    3840      } 
     41 
     42      //by default, points, lines, and bars are set not to show in jquery.flot.js 
     43      //if we have a numeric metric_type, draw lines 
    3944      if(get_class($set) == "Reconnoiter_DataSet") { 
    4045        $opacity = isset($this->sets_config[$name]['opacity']) ? 
    4146                     $this->sets_config[$name]['opacity'] : '0.3'; 
    42         $ds['lines'] = array ( 'show' => 'true', 'fill' => $opacity, 'lineWidth' => '1' , radius => 1 ); 
     47        $ds['lines'] = array ( 'show' => ($show_set) ? 1:0, 'fill' => $opacity, 'lineWidth' => '1' , radius => 1 ); 
    4348      } 
    44       if(get_class($set) == "Reconnoiter_ChangeSet") { 
    45         $ds['points'] = array ( 'show' => 'true', 'fill' => 'false', 'lineWidth' => 1, radius => 5 ); 
     49      //if we have a text metric type, draw points 
     50      else if(get_class($set) == "Reconnoiter_ChangeSet") { 
     51        $ds['points'] = array ( 'show' => ($show_set) ? 1:0, 'fill' => 'false', 'lineWidth' => 1, radius => 5 ); 
    4652      } 
     53 
    4754      $a[] = $ds; 
    4855    } 
     56 
     57    //hack for stacking...will ignore datasets and datapoints that are not set or not on the left axis, so 
     58    //each dataset needs to have each point set for this stacking to work 
     59    //non numeric metric are given the value 0 above, so that if stacked, they show up on the plot-line itself 
     60    if($this->type == "stacked") { 
     61        $left_count = 0; $bottom = -1; $index=0; 
     62        foreach($this->sets as $name => $set) {  
     63            if($this->sets_config[$name]['axis'] == 'left'){ 
     64                $left_count++; 
     65                if($left_count>1) { 
     66                    for ($point = 0; $point < count($a[$index]['data']); $point++){ 
     67                        if( ($a[$bottom]['data'][$point][1] != "") && ($a[$index]['data'][$point][1] != "")) {   
     68                            error_log("adding value".$a[$bottom]['data'][$point][1]); 
     69                            $tmp = $a[$index]['data'][$point][1] +  $a[$bottom]['data'][$point][1]; 
     70                            $a[$index]['data'][$point][1] = "$tmp"; 
     71                        }                 
     72                    } 
     73                }                       
     74                $bottom =  $index;  
     75            }//end if left axis 
     76            $index++; 
     77        } 
     78    }//end if stacking 
     79 
    4980    $start_ts = $a[0]['data'][0][0]; 
    5081    $finish = end($a[0]['data']); 
     
    6394    return $a; 
    6495  } 
     96 
     97 
     98 
    6599  function graphdataset($set, $config) { 
    66100    $i = 0; 
     
    76110          $desc = $set->description($ts); 
    77111          if($desc) { 
    78             $a[] = array( $ts * 1000, "$value", $desc ); 
     112            $a[] = array( $ts * 1000, "$value", $desc );        
    79113          } else { 
    80114            $a[] = array( $ts * 1000, "$value" ); 
    81115          } 
    82116        } 
    83         else $a[] = array( $ts * 1000, "" ); 
     117        else $a[] = array( $ts * 1000, "" );    
    84118        $i++; 
    85119      }