#167 JS development of hashchange-dependant tabbing mechanism, and of Rickshaw graphs with separate legends.
[ckanext-ga-report.git] / ckanext / ga_report / templates / ga_report / site / index.html
blob:a/ckanext/ga_report/templates/ga_report/site/index.html -> blob:b/ckanext/ga_report/templates/ga_report/site/index.html
--- a/ckanext/ga_report/templates/ga_report/site/index.html
+++ b/ckanext/ga_report/templates/ga_report/site/index.html
@@ -12,6 +12,7 @@
     <link rel="stylesheet" type="text/css" href="/css/ga_report.css"/>
     <script type="text/javascript" src="/scripts/ckanext_ga_reports.js"></script>
     <script type="text/javascript" src="/scripts/vendor/jquery.sparkline.modified.js"></script>
+    <script type="text/javascript" src="/scripts/rickshaw_ie7_shim.js"></script>
     <script type="text/javascript" src="/scripts/vendor/d3.v2.js"></script>
     <script type="text/javascript" src="/scripts/vendor/d3.layout.min.js"></script>
     <script type="text/javascript" src="/scripts/vendor/rickshaw.min.js"></script>
@@ -37,15 +38,6 @@
   <div py:match="content">
       <h1>Site Usage</h1>
       ${usage_nav('Site-wide')}
-
-      <form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='index')}" method="get">
-          <div class="controls">
-
-          ${month_selector(c.month, c.months, c.day)}
-
-           <input class="btn button btn-primary" type='submit' value="Update"/>
-          </div>
-       </form>
 
     <div class="tabbable">
       <ul class="nav nav-tabs">
@@ -79,16 +71,16 @@
       </ul>
       <div class="tab-content">
         <div class="tab-pane" id="totals">
-             <table class="table table-condensed table-bordered table-striped">
+             <table class="ga-reports-table table table-condensed table-bordered table-striped">
             	 <tr>
             	   <th>Name</th>
-            	   <th>Value</th>
+            	   <th class="td-numeric">Value</th>
             	   <th>History</th>
             	 </tr>
                 <py:for each="name, value, graph in c.global_totals">
                     <tr>
                         <td>${name}</td>
-                        <td>${value}</td>
+                        <td class="td-numeric">${value}</td>
                         <td class="sparkline-cell">
                           <span class="sparkline" sparkTooltips="${','.join([x for x,y in graph])}">
                             ${','.join([y for x,y in graph])}
@@ -101,35 +93,67 @@
          <div class="tab-pane" id="browsers_versions">
              ${rickshaw_graph(c.browser_versions_graph,'browser-versions',mode='stack')}
              <p>Note: Where a browser has a large number of versions, these have been grouped together.</p>
+             <form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='index')}" method="get">
+               <label>Show stats table for:</label>
+               ${month_selector(c.month, c.months, c.day)}
+             </form>
              ${stat_table(c.browser_versions)}
          </div>
          <div class="tab-pane" id="browsers_names">
              ${rickshaw_graph(c.browsers_graph,'browsers',mode='stack')}
+             <form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='index')}" method="get">
+               <label>Show stats table for:</label>
+               ${month_selector(c.month, c.months, c.day)}
+             </form>
              ${stat_table(c.browsers)}
          </div>
          <div class="tab-pane" id="os">
              ${rickshaw_graph(c.os_graph,'os',mode='stack')}
+             <form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='index')}" method="get">
+               <label>Show stats table for:</label>
+               ${month_selector(c.month, c.months, c.day)}
+             </form>
              ${stat_table(c.os)}
          </div>
          <div class="tab-pane" id="os_versions">
              ${rickshaw_graph(c.os_versions_graph,'os_versions',mode='stack')}
+             <form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='index')}" method="get">
+               <label>Show stats table for:</label>
+               ${month_selector(c.month, c.months, c.day)}
+             </form>
              ${stat_table(c.os_versions)}
          </div>
         <div class="tab-pane" id="social_referrals_totals">
             <p>Number of visits that were referred from social networks</p>
+             <form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='index')}" method="get">
+               <label>Show stats table for:</label>
+               ${month_selector(c.month, c.months, c.day)}
+             </form>
             ${social_table(c.social_referrer_totals)}
         </div>
         <div class="tab-pane" id="social_networks">
              ${rickshaw_graph(c.social_networks_graph, 'social_networks',mode='stack')}
             <p>Percentage of visits that were referred from these social networks</p>
+             <form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='index')}" method="get">
+               <label>Show stats table for:</label>
+               ${month_selector(c.month, c.months, c.day)}
+             </form>
              ${stat_table(c.social_networks, 'Visits')}
         </div>
         <div class="tab-pane" id="languages">
              ${rickshaw_graph(c.languages_graph,'languages',mode='stack')}
+             <form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='index')}" method="get">
+               <label>Show stats table for:</label>
+               ${month_selector(c.month, c.months, c.day)}
+             </form>
              ${stat_table(c.languages)}
         </div>
         <div class="tab-pane" id="country">
              ${rickshaw_graph(c.country_graph,'country',mode='stack')}
+             <form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='index')}" method="get">
+               <label>Show stats table for:</label>
+               ${month_selector(c.month, c.months, c.day)}
+             </form>
              ${stat_table(c.country)}
         </div>
        </div>
@@ -142,7 +166,13 @@
       $(function() {
         CKAN.GA_Reports.bind_sparklines();
         CKAN.GA_Reports.bind_sidebar();
-        $(window).trigger('hashchange');
+        CKAN.GA_Reports.bind_month_selector();
+        if (!window.location.hash) {
+          window.location.hash='totals';
+        }
+        else {
+          $(window).trigger('hashchange');
+        }
       });  
     </script>
   </py:def>