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

svn-commit at lists.omniti.com svn-commit at lists.omniti.com
Wed Oct 15 23:38:02 EDT 2008


Author: jesus
Date: 2008-10-15 23:38:01 -0400 (Wed, 15 Oct 2008)
New Revision: 500

Added:
   trunk/ui/web/htdocs/ws_search_graphs.inc
Modified:
   trunk/ui/web/htdocs/css/style.css
   trunk/ui/web/htdocs/index.php
   trunk/ui/web/htdocs/js/recon.js
   trunk/ui/web/htdocs/search_saved_graphs.inc
   trunk/ui/web/htdocs/worksheet_controls.inc
   trunk/ui/web/lib/Reconnoiter_DB.php
Log:
more refactoring, added stubs for worksheet work, refs #22

Modified: trunk/ui/web/htdocs/css/style.css
===================================================================
--- trunk/ui/web/htdocs/css/style.css	2008-10-15 22:19:44 UTC (rev 499)
+++ trunk/ui/web/htdocs/css/style.css	2008-10-16 03:38:01 UTC (rev 500)
@@ -349,6 +349,19 @@
 	outline-style:none;
 	outline-width:0;
 }
+#ws-first
+{
+	background:transparent none repeat scroll 0 0;
+	margin-top:1em;
+	padding:15px;
+}
+#ws-second
+{
+	background:transparent none repeat scroll 0 0;
+	margin-top:1em;
+	overflow:auto;
+	padding:15px;
+}
 #first
 {
 	background:transparent none repeat scroll 0 0;
@@ -560,34 +573,34 @@
 border:1px solid #333;
 padding:0 3px;
 }
-#graphlist p.paginate {
+.graphlist p.paginate {
 text-align:right;
 }
-#graphlist span.searchselect {
+.graphlist span.searchselect {
 border:1px solid #CCCCCC;
 display:inline;
 margin:0 4px;
 padding:0 4px;
 }
-#graphlist {
+.graphlist {
 overflow:auto;
 }
-#graphlist ul {
+.graphlist ul {
 list-style-image:none;
 list-style-position:outside;
 list-style-type:none;
 }
-#graphlist ul li {
+.graphlist ul li {
 display:block;
 margin-bottom:4px;
 padding:2px 0;
 }
-#graphlist ul li a {
+.graphlist ul li a {
 background:transparent url(../images/icon-graphs.png) no-repeat scroll 0 1px;
 font-size:12px;
 padding-left:25px;
 }
-#graphlist ul li ul li {
+.graphlist ul li ul li {
 border-left:1px solid #C0BBBD;
 color:#82787B;
 display:inline;
@@ -595,31 +608,33 @@
 margin-bottom:6px;
 padding:0 5px;
 }
-#graphlist ul li ul li.xx {
+.graphlist ul li ul li.xx {
 border-left:medium none;
 color:#82787B;
 display:inline;
 font-size:10px;
 padding-left:15px;
 }
-#graphlist ul li ul li a.addtows {
+.graphlist ul li ul li a em {
+color:#82787B;
+padding-left:3px;
+}
+.graphlist ul li ul li a.addtows {
 background:transparent url(../images/icon-addws.png) no-repeat scroll 0 0;
 display:inline;
+font-size:10px;
+padding-left:20px;
 }
-#graphlist ul li ul li a em {
-color:#82787B;
-padding-left:3px;
-}
-#graphlist ul li ul li a.editgraph {
+.graphlist ul li ul li a.editgraph {
 background:transparent url(../images/icon-editgraph.png) no-repeat scroll 0 0;
 display:inline;
 font-size:10px;
-padding-left:25px;
+padding-left:20px;
 }
-#graphlist ul li ul li a.deletegraph {
+.graphlist ul li ul li a.deletegraph {
 background:transparent url(../images/icon-deletegraph.png) no-repeat scroll 0 0;
 display:inline;
-padding-left:25px;
+padding-left:20px;
 font-size:10px;
 }
 div.plot-area {

Modified: trunk/ui/web/htdocs/index.php
===================================================================
--- trunk/ui/web/htdocs/index.php	2008-10-15 22:19:44 UTC (rev 499)
+++ trunk/ui/web/htdocs/index.php	2008-10-16 03:38:01 UTC (rev 500)
@@ -83,6 +83,17 @@
 			$(this).addClass('selected');
 			return false;
 		}).filter(':first').click();
+
+		var wstabContainers = $('div.ws-tabs > div');
+		wstabContainers.hide().filter(':first').show();
+		
+		$('div.ws-tabs ul.tabNavigation a').click(function () {
+			wstabContainers.hide();
+			wstabContainers.filter(this.hash).show();
+			$('div.ws-tabs ul.tabNavigation a').removeClass('selected');
+			$(this).addClass('selected');
+			return false;
+		}).filter(':first').click();
 	});
 </script>
 

Modified: trunk/ui/web/htdocs/js/recon.js
===================================================================
--- trunk/ui/web/htdocs/js/recon.js	2008-10-15 22:19:44 UTC (rev 499)
+++ trunk/ui/web/htdocs/js/recon.js	2008-10-16 03:38:01 UTC (rev 500)
@@ -103,3 +103,91 @@
                 ReconGraphReset: ReconGraph.reset
               });
 })(jQuery);
+
+function perform_graph_search(domid, wsmode, string, offset, limit) {
+  $.getJSON('json/graph/search',
+            { 'q' : string, 'o' : offset, 'l' : limit },
+            function(r) {
+              var summary = r.count + ' graph' + (r.count == 1 ? '' : 's' ) + ' found for \'' + htmlentities(r.query) + '\'';
+              if(r.error) summary = 'Error: ' + htmlentities(r.error);
+              $(domid + " > p.graph-search-summary").html(summary).fadeIn('fast');
+              var c = new Number(r.count);
+              var l = new Number(r.limit);
+              var o = new Number(r.offset);
+              var page = $(domid + " > p.paginate");
+              page.html('');
+              if(c > l) {
+                if(o > 0) {
+                  var po = Math.max(o-l, 0);
+                  $('<a/>').html( (po+1) + ' - ' + (po+l) )
+                           .click(function() {
+                             perform_datapoint_search(domid,wsmode,string,po,r.limit);
+                             return false;
+                           }).appendTo(page);
+                }
+                page.append($('<span/>').html((o+1) + '-' + (o+l)).addClass('searchselect'));
+                if(o + l < c) {
+                  var po = o + l;
+                  $('<a/>').html( (po + 1) + '-' + (po+l) )
+                           .click(function() {
+                             perform_datapoint_search(domid,wsmode,string,po,r.limit);
+                             return false;
+                           }).appendTo(page);
+                }
+                page.slideDown('fast');
+              }
+              else page.slideUp('fast');
+              $(domid + " > ul.graph-searchresults > li").remove();
+              for(var i=0; r.results && i<r.results.length; i++) {
+                var g = r.results[i];
+                var add = $('<a href="#"/>');
+                add.html('Add').addClass('addtows');
+                add.click(
+                  (function(graphid) {
+                      return function() {
+                        add_graph_to_worksheet(graphid);
+                        return false;
+                      }
+                   })(g.graphid)
+                );
+                var edit = $('<a href="#"/>');
+                edit.html('Edit').addClass('editgraph');
+                edit.click(
+                  (function(graphid) {
+                      return function() {
+                        set_current_graph_id(graphid);
+                        return false;
+                      }
+                   })(g.graphid)
+                );
+                var li = $('<li/>');
+                var del = $('<a href="#"/>');
+                del.html('Forget').addClass('deletegraph');
+                del.click(
+                  (function(graphid, li) {
+                      return function() {
+                        $.getJSON('json/graph/forget/' + graphid,
+                          function (r) {
+                            if(r.error) { alert(r.error); }
+                            else {
+                              perform_graph_search(domid,wsmode,string,o,l);
+                            }
+                          });
+                        return false;
+                      }
+                   })(g.graphid, li)
+                );
+                var ul = $('<ul/>');
+                ul.append($('<li/>').html(g.last_update));
+                if(wsmode) {
+                  ul.append($('<li/>').append(add));
+                }
+                else {
+                  ul.append($('<li/>').append(edit));
+                  ul.append($('<li/>').append(del));
+                }
+                li.append($('<a/>').html(g.title)).append(ul);
+                $(domid + " > ul.graph-searchresults").append(li);
+              }
+            });
+}

Modified: trunk/ui/web/htdocs/search_saved_graphs.inc
===================================================================
--- trunk/ui/web/htdocs/search_saved_graphs.inc	2008-10-15 22:19:44 UTC (rev 499)
+++ trunk/ui/web/htdocs/search_saved_graphs.inc	2008-10-16 03:38:01 UTC (rev 500)
@@ -1,86 +1,13 @@
 <script type="text/javascript">
 <!--
-function perform_graph_search(string, offset, limit) {
-  $.getJSON('json/graph/search',
-            { 'q' : string, 'o' : offset, 'l' : limit },
-            function(r) {
-              var summary = r.count + ' graph' + (r.count == 1 ? '' : 's' ) + ' found for \'' + htmlentities(r.query) + '\'';
-              if(r.error) summary = 'Error: ' + htmlentities(r.error);
-              $("#graphlist > p.graph-search-summary").html(summary).fadeIn('fast');
-              var c = new Number(r.count);
-              var l = new Number(r.limit);
-              var o = new Number(r.offset);
-              var page = $("#graphlist > p.paginate");
-              page.html('');
-              if(c > l) {
-                if(o > 0) {
-                  var po = Math.max(o-l, 0);
-                  $('<a/>').html( (po+1) + ' - ' + (po+l) )
-                           .click(function() {
-                             perform_datapoint_search(string,po,r.limit);
-                             return false;
-                           }).appendTo(page);
-                }
-                page.append($('<span/>').html((o+1) + '-' + (o+l)).addClass('searchselect'));
-                if(o + l < c) {
-                  var po = o + l;
-                  $('<a/>').html( (po + 1) + '-' + (po+l) )
-                           .click(function() {
-                             perform_datapoint_search(string,po,r.limit);
-                             return false;
-                           }).appendTo(page);
-                }
-                page.slideDown('fast');
-              }
-              else page.slideUp('fast');
-              $("#graph-searchresults > li").remove();
-              for(var i=0; r.results && i<r.results.length; i++) {
-                var g = r.results[i];
-                var a = $('<a href="#"/>');
-                a.html('Edit').addClass('editgraph');
-                a.click(
-                  (function(graphid) {
-                      return function() {
-                        set_current_graph_id(graphid);
-                        return false;
-                      }
-                   })(g.graphid)
-                );
-                var li = $('<li/>');;
-                var del = $('<a href="#"/>');
-                del.html('Forget').addClass('deletegraph');
-                del.click(
-                  (function(graphid, li) {
-                      return function() {
-                        $.getJSON('json/graph/forget/' + graphid,
-                          function (r) {
-                            if(r.error) { alert(r.error); }
-                            else {
-                              perform_graph_search(string,o,l);
-                            }
-                          });
-                        return false;
-                      }
-                   })(g.graphid, li)
-                );
-                li.append($('<a/>').html(g.title))
-                  .append($('<ul/>').append($('<li/>').html(g.last_update))
-                                    .append($('<li/>').append(a))
-                                    .append($('<li/>').append(del)));
-                $("#graph-searchresults").append(li);
-              }
-            });
-}
 $(document).ready(function(){
         $("#graph-searchform").submit(function() {
-                perform_graph_search($("#graph-searchinput").val(), 0, 25);
+                perform_graph_search("#graphlist", false, $("#graph-searchinput").val(), 0, 25);
                 return false;
         });
 });
 -->
 </script>
-
-</script>
 <h4 id="graph-searchterms"></h4>
 <div id="graph-searchform-container" style="margin:.5em 0 2em 0;padding-bottom:1em;border-bottom: solid 1px #e6e4e5;">
 <form id="graph-searchform">
@@ -90,8 +17,8 @@
   </fieldset>
 </form>
 </div>
-<div id="graphlist">
+<div id="graphlist" class="graphlist">
   <p class="graph-search-summary"></p>
-  <ul id="graph-searchresults">
+  <ul class="graph-searchresults">
   </ul>
 </div>

Modified: trunk/ui/web/htdocs/worksheet_controls.inc
===================================================================
--- trunk/ui/web/htdocs/worksheet_controls.inc	2008-10-15 22:19:44 UTC (rev 499)
+++ trunk/ui/web/htdocs/worksheet_controls.inc	2008-10-16 03:38:01 UTC (rev 500)
@@ -1,32 +1,16 @@
 		<h3 id="worksheet_controls">Worksheet Controls</h3>
-		<span class="worksheet">
-			<div id="searchform" style="margin:1em 0 1em 0;padding-bottom:1em;border-bottom: solid 1px #c4c4c4;">
-			<form name="form" id="form">
-				<label for="jumpMenu">User:</label>
-				<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)">
-					<option>theo at omniti.com</option>
-					<option>loremipsum at mail.freelotto.com</option>
-				</select>
-			</form>
-			</div>
-			<div style="clear:both;">
-			<input name="New Worksheet" type="button" value="New worksheet" style="float:right;" />
-			<h4 style="margin:.5em 0 1em 0;">20 Worksheets</h4>
-			</div>
-			<div id="worksheetlist">
-				<ul>
-					<li><a href="#">sed do eiusmod tempor incididunt</a></li>
-					<li><a href="#">sed do eiusmod tempor incididunt</a></li>
-					<li class="selected"><a href="#">sed do eiusmod tempor incididunt</a></li>
-					<li><a href="#">sed do eiusmod tempor incididunt</a></li>
-					<li><a href="#">sed do eiusmod tempor incididunt</a></li>
-					<li><a href="#">sed do eiusmod tempor incididunt</a></li>
-					<li><a href="#">sed do eiusmod tempor incididunt</a></li>
-					<li><a href="#">sed do eiusmod tempor incididunt</a></li>
-					<li><a href="#">sed do eiusmod tempor incididunt</a></li>
-					<li><a href="#">sed do eiusmod tempor incididunt</a></li>
-					<li><a href="#">sed do eiusmod tempor incididunt</a></li>
-					<li><a href="#">sed do eiusmod tempor incididunt</a></li>
-				</ul>
-			</div>
-		</span>
+                <span class="search">
+                        <div class="ws-tabs">
+                                <ul class="tabNavigation">
+                                        <li class="ws-first"><a href="#ws-first">WorkSheets</a></li>
+                                        <li class="ws-second"><a href="#ws-second">Find Graphs</a></li>
+                                </ul><br clear="all" />
+
+                                <div id="ws-first"><!-- search -->
+                                <?php include('ws_search_simple.inc') ?>
+                                </div>
+                                <div id="ws-second"><!-- saved graphs -->
+                                <?php include('ws_search_graphs.inc') ?>
+                                </div>
+                        </div>
+                </span>

Added: trunk/ui/web/htdocs/ws_search_graphs.inc
===================================================================
--- trunk/ui/web/htdocs/ws_search_graphs.inc	                        (rev 0)
+++ trunk/ui/web/htdocs/ws_search_graphs.inc	2008-10-16 03:38:01 UTC (rev 500)
@@ -0,0 +1,24 @@
+<script type="text/javascript">
+<!--
+$(document).ready(function(){
+        $("#ws-graph-searchform").submit(function() {
+                perform_graph_search("#ws-graphlist", true, $("#ws-graph-searchinput").val(), 0, 25);
+                return false;
+        });
+});
+-->
+</script>
+<h4 id="ws-graph-searchterms"></h4>
+<div id="ws-graph-searchform-container" style="margin:.5em 0 2em 0;padding-bottom:1em;border-bottom: solid 1px #e6e4e5;">
+<form id="ws-graph-searchform">
+  <fieldset>
+  <legend style="display:none;">Search</legend>
+  <label for="keyword" style="display:none;">Keyword</label> <input type="text" id="ws-graph-searchinput" style="width:220px;" /> <input type="submit" value="Search" />
+  </fieldset>
+</form>
+</div>
+<div id="ws-graphlist" class="graphlist">
+  <p class="graph-search-summary"></p>
+  <ul class="graph-searchresults">
+  </ul>
+</div>

Modified: trunk/ui/web/lib/Reconnoiter_DB.php
===================================================================
--- trunk/ui/web/lib/Reconnoiter_DB.php	2008-10-15 22:19:44 UTC (rev 499)
+++ trunk/ui/web/lib/Reconnoiter_DB.php	2008-10-16 03:38:01 UTC (rev 500)
@@ -284,6 +284,60 @@
     }
     return $rv;
   }
+  function getWorksheetByID($id) {
+    $sth = $this->db->prepare("select *
+                                 from prism.saved_worksheets
+                                 join prism.saved_worksheets_dep
+                                using (sheetid)
+                                where sheetid=?");
+    $sth->execute(array($id));
+    $a = array();
+    while($row = $sth->fetch()) {
+      $a[] = $row;
+    }
+    return $a;
+  }
+  function saveWorksheet($ws) {
+    $id = '';
+    if($ws['id']) {
+      $id = $ws['id'];
+      unset($ws['id']);
+    }
+    $this->db->beginTransaction();
+    try {
+      if($id) {
+        $sth = $this->db->prepare("update prism.saved_worksheets
+                                      set title=?, saved=(saved or ?),
+                                          last_update=current_timestamp
+                                    where sheetid=?");
+        $sth->execute(array($ws['title'],$ws['saved'],$id));
+        if($sth->rowCount() != 1) throw(new Exception('No such worksheet: '.$id));
+        $sth = $this->db->prepare("delete from prism.saved_worksheets_dep
+                                    where sheetid=?");
+        $sth->execute(array($ws['id']));
+      }
+      else {
+        $id = Reconnoiter_UUID::generate();
+        $sth = $this->db->prepare("insert into prism.saved_worksheets
+                                               (sheetid, title,
+                                                last_update)
+                                        values (?, ?, current_timestamp)");
+        $sth->execute(array($id, $ws['title']));
+      }
+      $sth = $this->db->prepare("insert into prism.saved_worksheets_dep
+                                             (sheetid, ordering, graphid)
+                                      values (?,?,?)");
+      $ordering = 0;
+      foreach($ws['graphs'] as $graphid) {
+        $sth->execute(array($id,$ordering++,$graphid));
+      }
+      $this->db->commit();
+    }
+    catch(PDOException $e) {
+      $this->db->rollback();
+      throw(new Exception('DB: ' . $e->getMessage()));
+    }
+  }
   function getGraphByID($id) {
     $sth = $this->db->prepare("select *
                                  from prism.saved_graphs



More information about the Reconnoiter-devel mailing list