[Reconnoiter-devel] [reconnoiter commit] r438 - in trunk/ui/web: htdocs htdocs/css htdocs/js lib

svn-commit at lists.omniti.com svn-commit at lists.omniti.com
Mon Sep 22 08:04:14 EDT 2008


Author: jesus
Date: 2008-09-22 08:04:14 -0400 (Mon, 22 Sep 2008)
New Revision: 438

Added:
   trunk/ui/web/htdocs/datapoint_search_json.php
   trunk/ui/web/htdocs/js/jquery.jeditable.pack.js
Modified:
   trunk/ui/web/htdocs/.htaccess
   trunk/ui/web/htdocs/css/style.css
   trunk/ui/web/htdocs/graph_controls.inc
   trunk/ui/web/htdocs/main.php
   trunk/ui/web/htdocs/search_simple.inc
   trunk/ui/web/lib/Reconnoiter_DB.php
Log:
search, albeit useless, refs #22

Modified: trunk/ui/web/htdocs/.htaccess
===================================================================
--- trunk/ui/web/htdocs/.htaccess	2008-09-21 23:54:44 UTC (rev 437)
+++ trunk/ui/web/htdocs/.htaccess	2008-09-22 12:04:14 UTC (rev 438)
@@ -5,4 +5,4 @@
 RewriteRule ^json/graph/info/([^/]+)$ graph_info.php?id=$1 [PT,QSA]
 RewriteRule ^json/graph/store$ graph_store.php [PT,QSA]
 RewriteRule ^amcharts/graph/settings/([^/]+) graph_settings.php?id=$1 [PT,QSA]
-
+RewriteRule ^json/datapoint/search$ datapoint_search_json.php [PT,QSA]

Modified: trunk/ui/web/htdocs/css/style.css
===================================================================
--- trunk/ui/web/htdocs/css/style.css	2008-09-21 23:54:44 UTC (rev 437)
+++ trunk/ui/web/htdocs/css/style.css	2008-09-22 12:04:14 UTC (rev 438)
@@ -198,7 +198,7 @@
 .ac {font-size: 10px;font-weight:normal;text-transform:uppercase;color:#82787b;}
 
 /* search list */
-#searchlist {height:450px;overflow:auto;}
+#searchlist {overflow:auto;}
 #searchlist ul a {list-style:none;}
 #searchlist ul li {display:block;padding:2px 0;margin-bottom:4px;}
 #searchlist ul li a {background:url(../images/icon-data.png) 0 1px no-repeat;padding-left:15px;}
@@ -206,7 +206,7 @@
 
 /* browse list */
 #browselist span {display:block; white-space: nowrap;}
-#browselist {height:600px;overflow:auto;}
+#browselist {overflow:auto;}
 #browselist ul {list-style:none;}
 #searchlist ul li {display:block;padding:2px 0;}
 #browselist ul li span {background:url(../images/icon-min-max.png) 0 3px no-repeat;padding-left:15px;}
@@ -230,7 +230,7 @@
 #browselist ul li ul li ul li ul li ul li span.text {background:url(../images/icon-data-txt.png) 60px 1px no-repeat;padding-left:75px;}
 
 /* graph list */
-#graphlist {height:450px;overflow:auto;}
+#graphlist {overflow:auto;}
 #graphlist ul {list-style:none;}
 #graphlist ul li {display:block;padding:2px 0;margin-bottom:4px;}
 #graphlist ul li a {background:url(../images/icon-graphs.png) 0 1px no-repeat;padding-left:15px;}

Added: trunk/ui/web/htdocs/datapoint_search_json.php
===================================================================
--- trunk/ui/web/htdocs/datapoint_search_json.php	                        (rev 0)
+++ trunk/ui/web/htdocs/datapoint_search_json.php	2008-09-22 12:04:14 UTC (rev 438)
@@ -0,0 +1,12 @@
+<?php
+
+require_once('Reconnoiter_DB.php');
+
+$db = Reconnoiter_DB::GetDB();
+$rows = $db->get_datapoints($_GET['q'], $_GET['o'], $_GET['l']);
+print json_encode(array(
+  'query' => $_GET['q'],
+  'offset' => $_GET['o'],
+  'limit' => $_GET['l'],
+  'results' => $rows
+));

Modified: trunk/ui/web/htdocs/graph_controls.inc
===================================================================
--- trunk/ui/web/htdocs/graph_controls.inc	2008-09-21 23:54:44 UTC (rev 437)
+++ trunk/ui/web/htdocs/graph_controls.inc	2008-09-22 12:04:14 UTC (rev 438)
@@ -21,7 +21,7 @@
     $("#flashcontent").slideUp("normal");
   }
 }
-function update_current_graph() {
+function update_current_graph(redraw) {
   if(recurse > 0) return;
   var str = JSON.stringify(graphinfo);
   //$("#payload").html(str);
@@ -36,7 +36,7 @@
            }
            recurse--;
            //$("#payload").html(JSON.stringify(graphinfo));
-           redraw_current_graph();
+           if(redraw) redraw_current_graph();
          }, 'json');
 }
 function graph_add_datapoint(d) {
@@ -44,7 +44,7 @@
   if(d.name == undefined) { d.name = d.metric_name; }
   graphinfo.datapoints.push(d);
   gtool_add_datapoint(d);
-  update_current_graph();
+  update_current_graph(true);
 }
 function gtool_add_datapoint(d) {
   var o = $("#datapointeditor").clone();
@@ -55,12 +55,12 @@
     $(this).siblings().removeClass("axison");
     $(this).addClass("axison");
     d.axis = $(this).hasClass("axisl") ? "l" : "r";
-    update_current_graph();
+    update_current_graph(true);
   });
   if(!d.hidden){o.find('input[@name="view"]').attr("checked","checked");}
   o.find('input[@name="view"]').change(function(){
     d.hidden = !($(this).attr("checked"));
-    update_current_graph();
+    update_current_graph(true);
   }).change();
 
   o.find('.deletedatapoint').click(function(){
@@ -70,7 +70,7 @@
         break;
       }
     }
-    update_current_graph();
+    update_current_graph(true);
     refresh_graph_from_json(graphinfo);
     return false;
   });
@@ -83,38 +83,43 @@
     if(d.derive){o.find('input[@name="derive"]').attr("checked","checked");}
     o.find('input[@name="derive"]').change(function(){
       d.derive = ($(this).attr("checked"));
-      update_current_graph();
+      update_current_graph(true);
     }).change();
 
     o.find('input[@name="math1"]').val(d.math1);
     o.find('input[@name="math1"]').change(function(){
       d.math1 = $(this).val();
-      update_current_graph();
+      update_current_graph(true);
     });
     o.find('input[@name="math2"]').val(d.math2);
     o.find('input[@name="math2"]').change(function(){
       d.math2 = $(this).val();
-      update_current_graph();
+      update_current_graph(true);
     });
   }
 
-  o.find(".datatitle").html("[" + d.sid + "-" + d.metric_name + "] " + d.name);
+  o.find(".datatitle").html(d.name);
   recurse--;
   $("#gtool #dataPoints").append(o.children());
 }
 function refresh_graph_from_json(j) {
-   graphinfo = j;
-   if(graphinfo.datapoints == undefined) graphinfo.datapoints = Array();
-   $("h2#graphTitle").html(graphinfo.title);
-   $("input[@name='graphtype']:checked").removeAttr("checked");
-   $("input[@name='graphtype']")
-     .filter(function(i){return $(this).val() == graphinfo.type;})
-     .attr("checked","checked");
-   $("#dataPoints").empty();
-   for(var i=0; i<graphinfo.datapoints.length; i++) {
-     gtool_add_datapoint(graphinfo.datapoints[i]);
-   }
-   redraw_current_graph();
+  graphinfo = j;
+  if(graphinfo.datapoints == undefined) graphinfo.datapoints = Array();
+  $("h2#graphTitle").html(graphinfo.title ? graphinfo.title : 'Graph Title (click to edit)');
+  $("h2#graphTitle").editable(function(value, settings) { 
+      graphinfo.title = value;
+      update_current_graph(false);
+      return(value);
+    }, { });
+  $("input[@name='graphtype']:checked").removeAttr("checked");
+  $("input[@name='graphtype']")
+    .filter(function(i){return $(this).val() == graphinfo.type;})
+    .attr("checked","checked");
+  $("#dataPoints").empty();
+  for(var i=0; i<graphinfo.datapoints.length; i++) {
+    gtool_add_datapoint(graphinfo.datapoints[i]);
+  }
+  redraw_current_graph();
 }
 function fetch_graph_info(id) {
  $.getJSON("graph_info.php",{id: id}, refresh_graph_from_json);
@@ -150,7 +155,7 @@
         });    
         $(".graphType").change(function(){
                 graphinfo.type = $(this).val();
-		update_current_graph();
+		update_current_graph(true);
         });
         $("#gtool-error").click(function(){
           $("#gtool-error").fadeOut("slow");

Added: trunk/ui/web/htdocs/js/jquery.jeditable.pack.js
===================================================================
--- trunk/ui/web/htdocs/js/jquery.jeditable.pack.js	                        (rev 0)
+++ trunk/ui/web/htdocs/js/jquery.jeditable.pack.js	2008-09-22 12:04:14 UTC (rev 438)
@@ -0,0 +1 @@
+eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(5($){$.Q.b=5(E,16){4 1={E:E,A:\'29\',F:\'F\',i:\'Y\',g:\'X\',k:\'X\',z:\'12\',O:\'l\',1j:\'28\',1k:\'26...\',D:\'25 24 23\',s:{},n:{}};3(16){$.N(1,16)}4 13=$.b.f[1.i].13||5(){};4 a=$.b.f[1.i].a||5(){};4 L=$.b.f[1.i].L||$.b.f[\'C\'].L;4 x=$.b.f[1.i].x||$.b.f[\'C\'].x;4 u=$.b.f[1.i].u||$.b.f[\'C\'].u;4 h=$.b.f[1.i].h||$.b.f[\'C\'].h;4 U=1.U||5(){};3(!$.y($(7)[1.z])){$.Q[1.z]=5(Q){q Q?7.22(1.z,Q):7.21(1.z)}}$(7).j(\'20\',1.1Z);1.1s=\'X\'==1.g;1.1r=\'X\'==1.k;q 7.17(5(){4 2=7;4 1u=$(2).g();4 1t=$(2).k();3(!$.T($(7).9())){$(7).9(1.D)}$(7)[1.z](5(e){3(2.M){q}3(0==$(2).g()){1.g=1u;1.k=1t}c{3(1.g!=\'S\'){1.g=1.1s?$(2).g():1.g}3(1.k!=\'S\'){1.k=1.1r?$(2).k():1.k}}3($(7).9().1q().1p(/;/,\'\')==1.D.1q().1p(/;/,\'\')){$(7).9(\'\')}2.M=1l;2.w=$(2).9();$(2).9(\'\');4 8=$(\'<8/>\');3(1.14){3(\'1o\'==1.14){8.j(\'15\',$(2).j(\'15\'))}c{8.j(\'15\',1.14)}}3(1.H){3(\'1o\'==1.H){8.j(\'H\',$(2).j(\'H\'));8.1n(\'1m\',$(2).1n(\'1m\'))}c{8.j(\'H\',1.H)}}4 6=u.d(8,[1,2]);4 G;3(1.1i){4 t=1f(5(){6.1g=1l;x.d(8,[1.1k,1,2])},1Y);4 s={};s[1.F]=2.F;3($.y(1.s)){$.N(s,1.s.d(2,[2.w,1]))}c{$.N(s,1.s)}$.1X({i:1.1j,1W:1.1i,P:s,1V:v,1U:5(1h){1T.1e(t);G=1h;6.1g=v}})}c 3(1.P){G=1.P;3($.y(1.P)){G=1.P.d(2,[2.w,1])}}c{G=2.w}x.d(8,[G,1,2]);6.j(\'A\',1.A);L.d(8,[1,2]);$(2).p(8);13.d(8,[1,2]);$(\':6:1S:1R:1b\',8).1Q();3(1.o){6.o()}6.1P(5(e){3(e.1O==27){e.1d();h.d(8,[1,2])}});4 t;3(\'l\'==1.O){6.W(5(e){t=1f(5(){h.d(8,[1,2])},1N)})}c 3(\'a\'==1.O){6.W(5(e){8.a()})}c 3($.y(1.O)){6.W(5(e){1.O.d(2,[6.B(),1])})}c{6.W(5(e){})}8.a(5(e){3(t){1e(t)}e.1d();3(v!==a.d(8,[1,2])){3($.y(1.E)){4 V=1.E.d(2,[6.B(),1]);$(2).9(V);2.M=v;U.d(2,[2.1c,1]);3(!$.T($(2).9())){$(2).9(1.D)}}c{4 n={};n[1.A]=6.B();n[1.F]=2.F;3($.y(1.n)){$.N(n,1.n.d(2,[2.w,1]))}!
 c{$.N(n,
1.n)}3(\'1M\'==1.1L){n[\'1K\']=\'1J\'}$(2).9(1.1I);$.1H(1.E,n,5(V){$(2).9(V);2.M=v;U.d(2,[2.1c,1]);3(!$.T($(2).9())){$(2).9(1.D)}})}}q v})});7.h=5(){$(2).9(2.w);2.M=v;3(!$.T($(2).9())){$(2).9(1.D)}}})};$.b={f:{C:{u:5(1,m){4 6=$(\'<6 i="1G">\');$(7).p(6);q(6)},x:5(K,1,m){$(\':6:1b\',7).B(K)},h:5(1,m){m.h()},L:5(1,m){4 8=7;3(1.a){3(1.a.1a(/>$/)){4 a=$(1.a).12(5(){3(a.j("i")!="a"){8.a()}});}c{4 a=$(\'<19 i="a">\');a.9(1.a)}$(7).p(a)}3(1.l){3(1.l.1a(/>$/)){4 l=$(1.l);}c{4 l=$(\'<19 i="l">\');l.9(1.l)}$(7).p(l);$(l).12(5(z){3($.y($.b.f[1.i].h)){4 h=$.b.f[1.i].h}c{4 h=$.b.f[\'C\'].h}h.d(8,[1,m]);q v})}}},Y:{u:5(1,m){4 6=$(\'<6>\');3(1.g!=\'S\'){6.g(1.g)}3(1.k!=\'S\'){6.k(1.k)}6.j(\'1F\',\'1E\');$(7).p(6);q(6)}},r:{u:5(1,m){4 r=$(\'<r>\');3(1.11){r.j(\'11\',1.11)}c{r.k(1.k)}3(1.10){r.j(\'10\',1.10)}c{r.g(1.g)}$(7).p(r);q(r)}},o:{u:5(1,m){4 o=$(\'<o>\');$(7).p(o);q(o)},x:5(K,1,m){3(1D==K.1C){1B(\'4 I = \'+K);1A(4 J 1z I){3(!I.1y(J)){18}3(\'R\'==J){18}4 Z=$(\'<Z>\').B(J).p(I[J]);$(\'o\',7).p(Z)}}$(\'o\',7).1x().17(5(){3($(7).B()==I[\'R\']||$(7).Y()==m.w){$(7).j(\'R\',\'R\')}})}}},1w:5(A,6){$.b.f[A]=6}}})(1v);',62,134,'|settings|self|if|var|function|input|this|form|html|submit|editable|else|apply||types|width|reset|type|attr|height|cancel|original|submitdata|select|append|return|textarea|loaddata||element|false|revert|content|isFunction|event|name|val|defaults|placeholder|target|id|input_content|style|json|key|string|buttons|editing|extend|onblur|data|fn|selected|none|trim|callback|str|blur|auto|text|option|cols|rows|click|plugin|cssclass|class|options|each|continue|button|match|first|innerHTML|preventDefault|clearTimeout|setTimeout|disabled|result|loadurl|loadtype|loadtext|true|display|css|inherit|replace|toLowerCase|autoheight|autowidth|savedheight|savedwidth|jQuery|addInputType|children|hasOwnProperty|in|for|eval|constructor|String|off|autocomplete|hidden|post|indicator|put|_method|method|PUT|500|keyCode|keydown|focus|enabled|visible|window|success|async|url|ajax|100|tooltip|title|trigger|bind|edit|to|Click|Loa!
 ding||GE
T|value'.split('|'),0,{}))

Modified: trunk/ui/web/htdocs/main.php
===================================================================
--- trunk/ui/web/htdocs/main.php	2008-09-21 23:54:44 UTC (rev 437)
+++ trunk/ui/web/htdocs/main.php	2008-09-22 12:04:14 UTC (rev 438)
@@ -6,6 +6,7 @@
 <link href="css/style.css" rel="stylesheet" type="text/css" />
 <script src="js/json2.js"></script>
 <script src="js/jquery.min.js"></script>
+<script src="js/jquery.jeditable.pack.js"></script>
 <script src="js/jquery.cookie.js" type="text/javascript"></script>
 <script src="js/jquery.treeview.js" type="text/javascript"></script>
 <script src="js/jquery.treeview.async.js" type="text/javascript"></script>

Modified: trunk/ui/web/htdocs/search_simple.inc
===================================================================
--- trunk/ui/web/htdocs/search_simple.inc	2008-09-21 23:54:44 UTC (rev 437)
+++ trunk/ui/web/htdocs/search_simple.inc	2008-09-22 12:04:14 UTC (rev 438)
@@ -1,41 +1,50 @@
-					<!--h2>Search</h2-->
-					<h4>&quot;ngm&quot; and &quot;my shot&quot;</h4>
-					<p>5360 data points found</p>
-					<div id="searchform" style="margin:.5em 0 2em 0;padding-bottom:1em;border-bottom: solid 1px #e6e4e5;">
-					 <form name="form2" id="form2">
-						<fieldset>
-						<legend style="display:none;">Search</legend>
-						<label for="search_new"><input type="radio" name="search_new" id="search_new" value="New Search" /> New Search</label> &nbsp;&nbsp;&nbsp;
-						<label for="search_within"><input type="radio" name="search_within" id="search_within" value="Search within Result" /> Search within Result</label><br />
-						<label for="keyword" style="display:none;">Keyword</label> <input type="text" id="keyword" style="width:220px;" /> <input type="submit" value="Submit" />
-						</fieldset>
-					</form>
-					</div>
-					<div id="searchlist">
-						<ul>
-							<li><a href="#">sed do eiusmod tempor incididunt ut labore</a></li>
-							<li><a href="#">sed do eiusmod tempor incididunt ut labore</a></li>
-							<li><a href="#">sed do eiusmod tempor incididunt ut labore</a></li>
-							<li><a href="#">sed do eiusmod tempor incididunt ut labore</a></li>
-							<li><a href="#">sed do eiusmod tempor incididunt ut labore</a></li>
-							<li><a href="#">sed do eiusmod tempor incididunt ut labore</a></li>
-							<li class="txt"><a href="#">text data sed do eiusmod tempor incididunt ut labore</a></li>
-							<li class="txt"><a href="#">text data sed do eiusmod tempor incididunt ut labore</a></li>
-							<li><a href="#">sed do eiusmod tempor incididunt ut labore</a></li>
-							<li><a href="#">sed do eiusmod tempor incididunt ut labore</a></li>
-							<li><a href="#">sed do eiusmod tempor incididunt ut labore</a></li>
-							<li class="txt"><a href="#">text data sed do eiusmod tempor incididunt ut labore</a></li>
-							<li class="txt"><a href="#">text data sed do eiusmod tempor incididunt ut labore</a></li>
-							<li><a href="#">sed do eiusmod tempor incididunt ut labore</a></li>
-							<li><a href="#">sed do eiusmod tempor incididunt ut labore</a></li>
-							<li class="txt"><a href="#">text data sed do eiusmod tempor incididunt ut labore</a></li>
-							<li class="txt"><a href="#">text data sed do eiusmod tempor incididunt ut labore</a></li>
-							<li><a href="#">sed do eiusmod tempor incididunt ut labore</a></li>
-							<li><a href="#">sed do eiusmod tempor incididunt ut labore</a></li>
-							<li><a href="#">sed do eiusmod tempor incididunt ut labore</a></li>
-							<li class="txt"><a href="#">text data sed do eiusmod tempor incididunt ut labore</a></li>
-							<li class="txt"><a href="#">text data sed do eiusmod tempor incididunt ut labore</a></li>
-							<li><a href="#">sed do eiusmod tempor incididunt ut labore</a></li>
-							<li><a href="#">sed do eiusmod tempor incididunt ut labore</a></li>
-						</ul>
-					</div>
+<script type="text/javascript">
+<!--
+function perform_datapoint_search(string, offset, limit) {
+  $.getJSON('json/datapoint/search',
+            { 'q' : string, 'o' : offset, 'l' : limit },
+            function(r) {
+              $("#searchresults > li").remove();
+              for(var i=0; i<r.results.length; i++) {
+                var ds = r.results[i];
+                var a = $('<a href="#"/>');
+                var li = $('<li/>');
+                a.html(ds.target + '`' + ds.name + '`' + ds.metric_name);
+                a.click(
+                  (function(ds_c) {
+                      return function() {
+                        graph_add_datapoint({'sid':ds_c.sid,
+                                             'metric_name':ds_c.metric_name,
+                                             'metric_type':ds_c.metric_type
+                                            });
+                        return false;
+                      }
+                   })(ds)
+                );
+                if(ds.metric_type == 'text') li.addClass('txt');
+                $("#searchresults").append(li.append(a));
+              }
+            });
+}
+$(document).ready(function(){
+        $("#datapoint-searchform").submit(function() {
+                perform_datapoint_search($("#searchinput").val(), 0, 25);
+                return false;
+        });
+});
+-->
+</script>
+<h4 id="searchterms"></h4>
+<p id="searchsummary"></p>
+<div id="datapoint-searchform-container" style="margin:.5em 0 2em 0;padding-bottom:1em;border-bottom: solid 1px #e6e4e5;">
+<form id="datapoint-searchform">
+  <fieldset>
+  <legend style="display:none;">Search</legend>
+  <label for="keyword" style="display:none;">Keyword</label> <input type="text" id="searchinput" style="width:220px;" /> 
+  </fieldset>
+</form>
+</div>
+<div id="searchlist">
+  <ul id="searchresults">
+  </ul>
+</div>

Modified: trunk/ui/web/lib/Reconnoiter_DB.php
===================================================================
--- trunk/ui/web/lib/Reconnoiter_DB.php	2008-09-21 23:54:44 UTC (rev 437)
+++ trunk/ui/web/lib/Reconnoiter_DB.php	2008-09-22 12:04:14 UTC (rev 438)
@@ -64,6 +64,20 @@
   function valid_source_variables() {
     return array('module', 'remote_address', 'target', 'name', 'metric_name');
   }
+  function get_datapoints($searchstring, $offset, $limit) {
+    $sth = $this->db->prepare("
+      select *
+        from stratcon.mv_loading_dock_check_s c
+        join stratcon.metric_name_summary m using (sid)
+       where active = true
+    order by target, module, name, remote_address
+       limit ?
+      offset ?");
+    $sth->execute(array($limit, $offset));
+    $a = array();
+    while($row = $sth->fetch()) $a[] = $row;
+    return $a;
+  }
   function get_sources($want, $fixate, $active = true) {
     $vars = $this->valid_source_variables();
     if(!in_array($want, $vars)) return array();
@@ -216,7 +230,9 @@
     try {
       if($id) {
         $sth = $this->db->prepare("update prism.saved_graphs
-                                      set json=?, title=? where graphid=?");
+                                      set json=?, title=?,
+                                          last_update=current_timestamp
+                                    where graphid=?");
         $sth->execute(array($json,$graph['title'],$id));
         if($sth->rowCount() != 1) throw(new Exception('No such graph: '.$id));
         $sth = $this->db->prepare("delete from prism.saved_graphs_dep
@@ -226,8 +242,9 @@
       else {
         $id = Reconnoiter_UUID::generate();
         $sth = $this->db->prepare("insert into prism.saved_graphs
-                                               (graphid, json, title)
-                                        values (?, ?, ?)");
+                                               (graphid, json, title,
+                                                last_update)
+                                        values (?, ?, ?, current_timestamp)");
         $sth->execute(array($id, $json, $graph['title']));
       }
       $sth = $this->db->prepare("insert into prism.saved_graphs_dep



More information about the Reconnoiter-devel mailing list