limit table rows in log window
authorScott Baker <smbaker@gmail.com>
Fri, 21 Nov 2014 19:08:57 +0000 (11:08 -0800)
committerScott Baker <smbaker@gmail.com>
Fri, 21 Nov 2014 19:08:57 +0000 (11:08 -0800)
planetstack/core/xoslib/dashboards/test.html
planetstack/core/xoslib/dashboards/xosAdminDashboard.html
planetstack/core/xoslib/dashboards/xosAdminWholePage.html
planetstack/core/xoslib/static/css/xosAdminDashboard.css
planetstack/core/xoslib/static/js/xoslib/xos-util.js [new file with mode: 0644]
planetstack/core/xoslib/static/js/xoslib/xosHelper.js

index 48fbc65..27b0b8d 100644 (file)
@@ -7,6 +7,7 @@
 
 <link rel="stylesheet" type="text/css" href="{% static 'css/test.css' %}" media="all" >
 
+<script src="{{ STATIC_URL }}/js/xoslib/xos-util.js"></script>
 <script src="{{ STATIC_URL }}/js/xoslib/xos-defaults.js"></script>
 <script src="{{ STATIC_URL }}/js/xoslib/xos-backbone.js"></script>
 <script src="{{ STATIC_URL }}/js/xoslib/xosHelper.js"></script>
index b5dacc9..b41ac9f 100644 (file)
@@ -9,6 +9,7 @@
 <link rel="stylesheet" type="text/css" href="{% static 'css/xosAdminDashboard.css' %}" media="all" >
 <link rel="stylesheet" type="text/css" href="{% static 'css/xosAdminSite.css' %}" media="all" >
 
+<script src="{{ STATIC_URL }}/js/xoslib/xos-util.js"></script>
 <script src="{{ STATIC_URL }}/js/xoslib/xos-defaults.js"></script>
 <script src="{{ STATIC_URL }}/js/xoslib/xos-backbone.js"></script>
 <script src="{{ STATIC_URL }}/js/xoslib/xosHelper.js"></script>
index 0bc9924..4af6093 100644 (file)
@@ -9,6 +9,7 @@
 <link rel="stylesheet" type="text/css" href="{% static 'css/xosAdminWholePage.css' %}" media="all" >
 <link rel="stylesheet" type="text/css" href="{% static 'css/xosAdminSite.css' %}" media="all" >
 
+<script src="{{ STATIC_URL }}/js/xoslib/xos-util.js"></script>
 <script src="{{ STATIC_URL }}/js/xoslib/xos-defaults.js"></script>
 <script src="{{ STATIC_URL }}/js/xoslib/xos-backbone.js"></script>
 <script src="{{ STATIC_URL }}/js/xoslib/xosHelper.js"></script>
index f4e8191..d94cb39 100644 (file)
     display: none;
 }
 
+#logPanel {
+    overflow-y: auto;
+}
+
 #logTable {
     width: 100%;
 }
diff --git a/planetstack/core/xoslib/static/js/xoslib/xos-util.js b/planetstack/core/xoslib/static/js/xoslib/xos-util.js
new file mode 100644 (file)
index 0000000..79ce0f8
--- /dev/null
@@ -0,0 +1,23 @@
+// misc utility functions
+
+// http://stackoverflow.com/questions/2117320/set-maximum-displayed-rows-count-for-html-table
+function limitTableRows(tableSelector, maxRows) {
+    var table = $(tableSelector)[0] //document.getElementById(tableId);
+    var wrapper = table.parentNode;
+    var rowsInTable = table.rows.length;
+    try {
+        var border = getComputedStyle(table.rows[0].cells[0], '').getPropertyValue('border-top-width');
+        border = border.replace('px', '') * 1;
+    } catch (e) {
+        var border = table.rows[0].cells[0].currentStyle.borderWidth;
+        border = (border.replace('px', '') * 1) / 2;
+    }
+    var height = 0;
+    if (rowsInTable > maxRows) {
+        for (var i = 0; i < maxRows; i++) {
+            height += table.rows[i].clientHeight + border;
+            //console.log("XXX " + height + " " + table.rows[i].clientHeight + " " + border);
+        }
+        wrapper.style.height = height + "px";
+    }
+}
index 98dfb88..99e47e7 100644 (file)
@@ -116,6 +116,8 @@ XOSApplication = Marionette.Application.extend({
             $(this.statusMsgId).html( templateFromId("#xos-status-template")(result) );
         }
 
+        limitTableRows(this.logTableId, 5);
+
         return logMessageId;
     },