From 4ced185f2e35a7457d14726e6c4769d1b3118ea2 Mon Sep 17 00:00:00 2001
From: Sandy Walsh <sandy.walsh@rackspace.com>
Date: Tue, 28 Feb 2012 21:35:07 -0600
Subject: [PATCH] cleanup UI and add search

---
 templates/base.html    |  4 ++--
 templates/index.html   | 39 +++++++++++++++++++++++++++------------
 templates/rows.html    |  5 ++++-
 templates/welcome.html |  2 +-
 urls.py                | 21 ++++++++++++++++-----
 5 files changed, 50 insertions(+), 21 deletions(-)

diff --git a/templates/base.html b/templates/base.html
index f39ea88..5c9d741 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -30,7 +30,7 @@ under the License.
             .fancy {
               font-family: 'Kaushan Script';
               font-style: normal;
-              padding-bottom: 1em;
+              padding-bottom: 0em;
               font-size: 3em;
               color:#C63520;
             }
@@ -86,7 +86,7 @@ under the License.
                 margin-bottom:1em;
             }
             .std-height {
-                height:5em;
+                height:30em;
                 overflow-y:scroll;
                 overflow-x:hidden;
             }
diff --git a/templates/index.html b/templates/index.html
index 47967bd..497f375 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -10,6 +10,16 @@
             {
                 $("#row_expansion_" + row_id).load('/' + tenant_id + '/expand/' + row_id);
             };
+
+            function search_form(tenant_id)
+            {
+                var field = $("#field").val();
+                var value = $("#query").val();
+                var data = {'field':field, 'value':value};
+                $("#detail").load('/' + tenant_id + '/search/', data);
+                return false;
+            };
+
 {% endblock %}
 
 {% block extra_init_js %}            
@@ -19,28 +29,33 @@
 
 {% block body %}
         <div style='float:right;'>{{state.tenant.email}} (TID:{{state.tenant.tenant_id}}) - {{state.tenant.project_name}} <a href='/logout'>logout</a></div>
-        <div class='status-title'>Recent Host Activity</div>
+        <div class='status-title'>Recent Activity</div>
         <div id='host-box' class='status std-height'>
             <div id='host_activity' class='status-inner'>
                 {% include "host_status.html" %}
             </div>
         </div>
 
-        <div class='status-title'>Recent Instance Activity</div>
-        <div id='instance-box' class='status std-height'>
-            <div id='instance_activity' class='status-inner'>
-                {% include "instance_status.html" %}
-           </div>
-        </div>
-        <!--
         <div class='status-title'>Commands</div>
         <div class='status'>
-            <div class='status-inner'>
-                <input type=text style='width:100%; background-color:black;color:white;'
-                        value='<custom query here>'/>
+            <div class='status-inner' style='padding-bottom:0em; margin-bottom:0em; margin-top:1em'>
+                <div>
+                <form action="">
+                <select id='field'>
+                   <option value='routing_key'>source
+                   <option value='nova_tenant'>tenant
+                   <option>service
+                   <option>host
+                   <option>event
+                   <option selected='true'>instance
+                </select>
+                <input type='text' id='query' size='60' value=''/>
+                <input type='submit' value='Search' onclick='return search_form({{state.tenant.tenant_id}});'/>
+                </form>
+                </div>
             </div>
         </div>
-        -->
+
         <div class='status-title'>Details</div>
         <div class='status'>
             <div id='detail' class='status-inner'>
diff --git a/templates/rows.html b/templates/rows.html
index d4ab9d3..d2570a1 100644
--- a/templates/rows.html
+++ b/templates/rows.html
@@ -9,6 +9,9 @@
     <td class='title'>instance</td>
     <td class='title'>when</td>
 </th>
+{% if not rows %}
+<tr><td>No results</td></tr>
+{% endif %}
 {% for row in rows %}
 <tr {% if row.highlight %}style='background-color:#FFD88F;'{% endif %} >
     <td>
@@ -37,7 +40,7 @@
         {% endif %}
         </a>
     </td>
-    <td class='cell-border'><a href='#' onclick='details({{state.tenant.tenant_id}}, "when", {{row.id}});'>{% if show_absolute_time %}{{row.when}}{%else%}{{row.when|timesince:utc}} ago{%endif%}</a></td>
+    <td class='cell-border'><a href='#' onclick='details({{state.tenant.tenant_id}}, "when", {{row.id}});'>{% if show_absolute_time %}{{row.when}} (+{{row.when.microsecond}}){%else%}{{row.when|timesince:utc}} ago{%endif%}</a></td>
 </tr>
 {% if allow_expansion %}
 <tr>
diff --git a/templates/welcome.html b/templates/welcome.html
index c86a069..43e8216 100644
--- a/templates/welcome.html
+++ b/templates/welcome.html
@@ -15,7 +15,7 @@
             <ul>
             <li>Get a <a href='/new_tenant'>StackTach Tenant ID</a>
             <li>Add <pre>--notification_driver=nova.notifier.rabbit_notifier</pre> and 
-            <li><pre>--notification_topics=info,monitor</pre> to your nova.conf file.
+            <li><pre>--notification_topics=notifications,monitor</pre> to your nova.conf file.
             <li>Configure and run the <a target='_blank' href='https://github.com/Rackspace/StackTach'>StackTach Worker</a> somewhere in your Nova development environment. 
             <li>Restart Nova and visit http://[your server]/[your_tenant_id]/ to see your Nova installation in action!
             </ul>
diff --git a/urls.py b/urls.py
index 5ae73fa..08885f1 100644
--- a/urls.py
+++ b/urls.py
@@ -1,9 +1,20 @@
 from django.conf.urls.defaults import patterns, include, url
 
-# Uncomment the next two lines to enable the admin:
-# from django.contrib import admin
-# admin.autodiscover()
-
 urlpatterns = patterns('',
-    url(r'^', include('stacktach.url')),
+    url(r'^$', 'stacktach.views.welcome', name='welcome'),
+    url(r'new_tenant', 'stacktach.views.new_tenant', name='new_tenant'),
+    url(r'logout', 'stacktach.views.logout', name='logout'),
+    url(r'^(?P<tenant_id>\d+)/$', 'stacktach.views.home', name='home'),
+    url(r'^(?P<tenant_id>\d+)/data/$', 'stacktach.views.data',
+        name='data'),
+    url(r'^(?P<tenant_id>\d+)/details/(?P<column>\w+)/(?P<row_id>\d+)/$',
+        'stacktach.views.details', name='details'),
+    url(r'^(?P<tenant_id>\d+)/search/$',
+        'stacktach.views.search', name='search'),
+    url(r'^(?P<tenant_id>\d+)/expand/(?P<row_id>\d+)/$',
+        'stacktach.views.expand', name='expand'),
+    url(r'^(?P<tenant_id>\d+)/host_status/$', 
+        'stacktach.views.host_status', name='host_status'),
+    url(r'^(?P<tenant_id>\d+)/instance_status/$',
+        'stacktach.views.instance_status', name='instance_status'),
 )