accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [3/7] accumulo git commit: ACCUMULO-1480 Added vertical tabs, fixed filtering code
Date Thu, 10 Nov 2016 22:18:43 GMT
ACCUMULO-1480 Added vertical tabs, fixed filtering code


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/a22a8842
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/a22a8842
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/a22a8842

Branch: refs/heads/master
Commit: a22a88423675dd433a8c3ac582d60328a4fd821e
Parents: 3ca9d31
Author: Luis Tavarez <zeravat@outlook.com>
Authored: Wed Oct 26 15:09:41 2016 -0400
Committer: Luis Tavarez <zeravat@outlook.com>
Committed: Wed Oct 26 15:09:41 2016 -0400

----------------------------------------------------------------------
 .../monitor/servlets/TablesServlet.java         | 45 ++++++----
 .../org/apache/accumulo/monitor/util/Table.java | 92 +++++++-------------
 .../monitor/src/main/resources/web/screen.css   | 37 ++++++++
 3 files changed, 94 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/a22a8842/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/TablesServlet.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/TablesServlet.java
b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/TablesServlet.java
index 361cf7d..d8528f1 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/TablesServlet.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/TablesServlet.java
@@ -117,13 +117,18 @@ public class TablesServlet extends BasicServlet {
     Map<String,Double> compactingByTable = TableInfoUtil.summarizeTableStats(Monitor.getMmi());
     TableManager tableManager = TableManager.getInstance();
 
-    //String namespace = BasicServlet.getCookieValue(req, "namespaceDropdown." + BasicServlet.encode(page)
+ "." + BasicServlet.encode(tableName) + "." + "selected");
-    
-    //Tables.getNameToIdMap(Monitor.getContext().getInstance()).entrySet().stream().filter(matchesNamespace("accumulo")).forEach(tableName_tableId
-> { String tableName = tableName_tableId.getKey();
-    // Change this from here
-    for (Entry<String,String> tableName_tableId : Tables.getNameToIdMap(Monitor.getContext().getInstance()).entrySet())
{
+    String page = req.getRequestURI();
+
+    String namespace = BasicServlet.getCookieValue(req, "namespaceDropdown." + BasicServlet.encode(page)
+ "." + BasicServlet.encode("tableList") + "."
+        + "selected");
+
+    if (namespace == null) {
+      namespace = "*";
+    }
+
+    Tables.getNameToIdMap(Monitor.getContext().getInstance()).entrySet().stream().filter(matchesNamespace(namespace)).forEach(tableName_tableId
-> {
+
       String tableName = tableName_tableId.getKey();
-      // to here
       String tableId = tableName_tableId.getValue();
       TableInfo tableInfo = tableStats.get(tableName);
       Double holdTime = compactingByTable.get(tableId);
@@ -144,24 +149,28 @@ public class TablesServlet extends BasicServlet {
       row.add(tableInfo);
       row.add(tableInfo);
       tableList.addRow(row);
-    //});
-    }
+    });
 
     SortedMap<String,String> namespaces = Namespaces.getNameToIdMap(Monitor.getContext().getInstance());
     tableList.setNamespaces(namespaces);
 
     tableList.generate(req, sb);
   }
-  
-	private static Predicate<Entry<String, String>> matchesNamespace(String namespace)
{
-		return new Predicate<Entry<String,String>>() {
-			public boolean test(Entry<String,String> t) {
-				return t.getKey().startsWith(namespace + ".");
-			};
-		};
-	}
-
-	private void doTableDetails(HttpServletRequest req, StringBuilder sb, Map<String,String>
tidToNameMap, String tableId) {
+
+  private static Predicate<Entry<String,String>> matchesNamespace(String namespace)
{
+    return new Predicate<Entry<String,String>>() {
+      public boolean test(Entry<String,String> t) {
+        if (namespace.equals("*")) {
+          return true;
+        } else if (namespace.equals("-")) {
+          return !t.getKey().contains(".");
+        }
+        return t.getKey().startsWith(namespace + ".");
+      };
+    };
+  }
+
+  private void doTableDetails(HttpServletRequest req, StringBuilder sb, Map<String,String>
tidToNameMap, String tableId) {
     String displayName = Tables.getPrintableTableNameFromId(tidToNameMap, tableId);
     Instance instance = Monitor.getContext().getInstance();
     TreeSet<String> locs = new TreeSet<>();

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a22a8842/server/monitor/src/main/java/org/apache/accumulo/monitor/util/Table.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/Table.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/Table.java
index 3f6b904..1979a9c 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/Table.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/Table.java
@@ -146,7 +146,24 @@ public class Table {
       showLegend = showStr != null && Boolean.parseBoolean(showStr);
     }
 
-    sb.append("<div>\n");
+    String redir = BasicServlet.currentPage(req);
+
+    if (namespaces != null) {
+      sb.append("<div id=\"filters\">\n");
+      String namespace = BasicServlet.getCookieValue(req, "namespaceDropdown." + BasicServlet.encode(page)
+ "." + BasicServlet.encode(tableName) + "."
+          + "selected");
+      if (namespace == null) {
+        namespace = "*";
+      }
+      sb.append("<div class='left show'><dl>\n");
+      doDropdownMenu(redir, page, tableName, sb, namespaces, namespace);
+      sb.append("</dl></div>\n");
+      sb.append("</div>\n");
+      sb.append("<div id=\"tables\">\n");
+    } else {
+      sb.append("<div>\n");
+    }
+
     sb.append("<a name='").append(tableName).append("'>&nbsp;</a>\n");
     sb.append("<table id='").append(tableName).append("' class='sortable'>\n");
     sb.append("<caption");
@@ -158,7 +175,6 @@ public class Table {
     if (subcaption != null && !subcaption.isEmpty())
       sb.append("<span class='table-subcaption'>").append(subcaption).append("</span><br
/>\n");
 
-    String redir = BasicServlet.currentPage(req);
     if (numLegends > 0) {
       String legendUrl = String.format("/op?action=toggleLegend&redir=%s&page=%s&table=%s&show=%s",
redir, page, tableName, !showLegend);
       sb.append("<a href='").append(legendUrl).append("'>").append(showLegend ? "Hide"
: "Show").append("&nbsp;Legend</a>\n");
@@ -182,56 +198,6 @@ public class Table {
     }
     if (showLegend && numLegends > 0)
       sb.append("</dl></div>\n");
-    ArrayList<TableRow> newRows = new ArrayList<>();
-
-    if (namespaces != null) {
-
-      String namespace = BasicServlet.getCookieValue(req, "namespaceDropdown." + BasicServlet.encode(page)
+ "." + BasicServlet.encode(tableName) + "."
-          + "selected");
-      if (namespace != null) {
-        sb.append("<p>Selected&nbsp;is&nbsp;").append(namespace).append("</p>");
-        
-        // Once this is implemented on the TablesServlet, delete it from here
-
-        for (TableRow row : rows) {
-          boolean first = true;
-          for (int i = 0; i < row.size(); ++i) {
-            if (first) {
-              try {
-                String tableNameStr = columns.get(i).getCellType().format(row.get(i));
-                if (namespace.equals("All")) {
-
-                  newRows.add(row);
-                } else {
-                  if (tableNameStr.contains(".")) {
-
-                    if (tableNameStr.contains(namespace + ".")) {
-
-                      newRows.add(row);
-                    }
-                  } else if (namespace.equals("DEFAULT")) {
-
-                    newRows.add(row);
-                  }
-
-                }
-              } catch (Exception ex) {
-                throw new RuntimeException("Unable to process column " + i, ex);
-              }
-              first = false;
-            }
-          }
-        }
-
-      } else {
-        newRows = rows;
-      }
-      sb.append("<div class='left show'><dl>\n");
-      doDropdownMenu(redir, page, tableName, sb, namespaces);
-      sb.append("</dl></div>\n");
-    } else {
-      newRows = rows;
-    }
 
     sb.append("</caption>\n");
     sb.append("<tr>");
@@ -243,13 +209,13 @@ public class Table {
     }
     sb.append("</tr>\n");
     // don't sort if no columns are sortable or if there aren't enough rows
-    if (newRows.size() > 1 && sortCol > -1) {
-      Collections.sort(newRows, TableRow.getComparator(sortCol, columns.get(sortCol).getCellType()));
+    if (rows.size() > 1 && sortCol > -1) {
+      Collections.sort(rows, TableRow.getComparator(sortCol, columns.get(sortCol).getCellType()));
       if (!sortAscending)
-        Collections.reverse(newRows);
+        Collections.reverse(rows);
     }
     boolean highlight = true;
-    for (TableRow row : newRows) {
+    for (TableRow row : rows) {
       for (int i = 0; i < row.size(); ++i) {
         try {
           row.set(i, columns.get(i).getCellType().format(row.get(i)));
@@ -260,7 +226,7 @@ public class Table {
       row(sb, highlight, columns, row);
       highlight = !highlight;
     }
-    if (newRows.isEmpty())
+    if (rows.isEmpty())
       sb.append("<tr><td class='center' colspan='").append(columns.size()).append("'><i>Empty</i></td></tr>\n");
     sb.append("</table>\n</div>\n\n");
   }
@@ -281,20 +247,22 @@ public class Table {
     sb.append("</tr>\n");
   }
 
-  private static void doDropdownMenu(String redir, String page, String tableName, StringBuilder
sb, SortedMap<String,String> namespaces) {
+  private static void doDropdownMenu(String redir, String page, String tableName, StringBuilder
sb, SortedMap<String,String> namespaces, String namespace) {
 
     String namespaceUrl = String.format("/op?action=namespace&redir=%s&page=%s&table=%s&selected=",
redir, page, tableName);
 
-    sb.append("<ul>\n");
-    sb.append("<li><a href=\"").append(namespaceUrl).append("All\">All</a></li>");
+    sb.append("<ul id=\"namespaces\">\n");
+    sb.append("<li><a ").append(namespace.equals("*") ? "class=\"active\" " : "").append("href=\"").append(namespaceUrl).append("*\">*</a></li>");
     for (String key : namespaces.keySet()) {
       if (key.equals("")) {
-        sb.append("<li><a href=\"").append(namespaceUrl).append("DEFAULT\">DEFAULT</a></li>");
+        sb.append("<li><a ").append(namespace.equals("-") ? "class=\"active\" "
: "").append("href=\"").append(namespaceUrl).append("-\">-</a></li>");
       } else {
-        sb.append("<li><a href=\"").append(namespaceUrl).append(key).append("\">").append(key).append("</a></li>");
+        sb.append("<li><a ").append(namespace.equals(key) ? "class=\"active\" "
: "").append("href=\"").append(namespaceUrl).append(key).append("\">")
+            .append(key).append("</a></li>");
       }
     }
     sb.append("</ul>\n");
+
   }
 
   public void setNamespaces(SortedMap<String,String> namespaces) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a22a8842/server/monitor/src/main/resources/web/screen.css
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/resources/web/screen.css b/server/monitor/src/main/resources/web/screen.css
index 7aa49a0..694cd1b 100644
--- a/server/monitor/src/main/resources/web/screen.css
+++ b/server/monitor/src/main/resources/web/screen.css
@@ -390,3 +390,40 @@ pre.logevent {
     text-align: left;
     color: red;
 }
+
+#filters {
+    overflow-y: scroll;
+    height: 100%;
+    width: 200px;
+    float: left;
+}
+
+#tables {
+    overflow-y: scroll;
+    height: 100%;
+    margin-left: 205px;
+}
+
+#namespaces {
+    list-style-type: none;
+    padding: 0;
+    margin: 0;
+    background-color: #FFF;
+}
+
+#namespaces li a {
+    display: block;
+    color: black;
+    text-align: center;
+    padding: 14px 16px;
+    font-weight: bold;
+    text-decoration: none;
+}
+
+#namespaces li a:hover:not(.active) {
+    background-color: #eee;
+}
+
+.active {
+    background-color: #cef4b5;
+}


Mime
View raw message