Adding new social network referral information
[ckanext-ga-report.git] / ckanext / ga_report / templates / ga_report / ga_util.html
blob:a/ckanext/ga_report/templates/ga_report/ga_util.html -> blob:b/ckanext/ga_report/templates/ga_report/ga_util.html
--- a/ckanext/ga_report/templates/ga_report/ga_util.html
+++ b/ckanext/ga_report/templates/ga_report/ga_util.html
@@ -6,13 +6,12 @@
   py:strip=""
   >
 
- <table py:def="publisher_list(groups)" class="groups">
-   <py:for each="group,title in groups">
-   <tr>
-     <td><a href="/publisher/${group.name}">${title}</a></td>
-   </tr>
-   </py:for>
- </table>
+<select name="month" py:def="month_selector(current_month, months, day)">
+    <option value='' py:attrs="{'selected': 'selected' if not current_month else None}">All months</option>
+  <py:for each="i, (val,desc) in enumerate(months)">
+    <option value='${val}' py:attrs="{'selected': 'selected' if current_month == val else None}">${desc}<py:if test="i == 0 and day"> (up to ${day})</py:if></option>
+  </py:for>
+</select>
 
 
 <table py:def="social_table(items, with_source=False)" class="table table-condensed table-bordered table-striped">
@@ -31,6 +30,42 @@
  </table>
 
 
+<div py:def="rickshaw_graph(items_json,id)">
+  <div id="chart_container_$id" class="rickshaw_chart_container">
+    <div id="y_axis_$id" class="rickshaw_y_axis"></div>
+    <div id="chart_$id" class="rickshaw_chart"></div>
+    <div id="legend_$id" class="rickshaw_legend"></div>
+    <script type="text/javascript">
+      $(function() {
+          var series = ${items_json};
+          Rickshaw.Series.zeroFill(series);
+          var palette = new Rickshaw.Color.Palette( { scheme: 'spectrum2001' } );
+          $.each(series, function(i, object) {
+              object['color'] = palette.color();
+          });
+          var graph = new Rickshaw.Graph( {
+              element: document.querySelector("#chart_$id"),
+              renderer: 'line',
+              series: series 
+          });
+          var x_axis = new Rickshaw.Graph.Axis.Time( { graph: graph } );
+          var y_axis = new Rickshaw.Graph.Axis.Y( {
+              graph: graph,
+              orientation: 'left',
+              tickFormat: Rickshaw.Fixtures.Number.formatKMBT,
+              element: document.getElementById('y_axis_$id'),
+          } );
+          var legend = new Rickshaw.Graph.Legend( {
+              element: document.querySelector('#legend_$id'),
+              graph: graph
+          } );
+          graph.render();
+      });
+    </script>
+  </div>
+</div>
+
+
 <table py:def="stat_table(items, title='Views')" class="table table-condensed table-bordered table-striped">
     <tr>
         <th>Name</th>
@@ -45,19 +80,18 @@
  </table>
 
 
-<div py:def="usage_nav(active_name,publisher)" id="minornavigation">
+<div py:def="usage_nav(active_name)" id="minornavigation">
     <div id="minornavigation-bg-left">
     <div id="minornavigation-bg-right">
-        <ul class="nav nav-pills">
-        <li py:attrs="{'class': 'active' if active_name=='Site-wide' else None}"><a py:attrs="{'class': 'active' if active_name=='Site-wide' else None}"  href="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='index')}"><img src="/images/icons/page_white_gear.png" height="16px" width="16px" alt="None" class="inline-icon "/> Site-wide</a></li>
+      <ul class="nav nav-pills">
+        <li py:attrs="{'class': 'active' if active_name=='Site-wide' else None}"><a py:attrs="{'class': 'active' if active_name=='Site-wide' else None}"  href="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='index')}"><img src="/images/icons/page_white.png" height="16px" width="16px" alt="None" class="inline-icon "/> Site-wide</a></li>
         <li py:attrs="{'class': 'active' if active_name=='Publishers' else None}">
-                <a py:attrs="{'class': 'active' if active_name=='Publishers' else None}"  href="${h.url_for(controller='ckanext.ga_report.controller:GaPublisherReport',action='index')}"><img src="/images/icons/page_white_gear.png" height="16px" width="16px" alt="None" class="inline-icon "/> Publishers</a>
+                <a py:attrs="{'class': 'active' if active_name=='Publishers' else None}"  href="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='publishers')}"><img src="/images/icons/page_white.png" height="16px" width="16px" alt="None" class="inline-icon "/> Publishers</a>
         </li>
-        <li py:if="publisher" class="active">
-                <a class="active"  href="${h.url_for(controller='ckanext.ga_report.controller:GaPublisherReport',action='read', id=publisher.name)}"><img src="/images/icons/page_white_gear.png" height="16px" width="16px" alt="None" class="inline-icon "/>${publisher.title}</a>
+        <li py:attrs="{'class': 'active' if active_name=='Datasets' else None}">
+                <a py:attrs="{'class': 'active' if active_name=='Datasets' else None}"  href="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='read')}"><img src="/images/icons/page_white.png" height="16px" width="16px" alt="None" class="inline-icon "/> Datasets</a>
         </li>
-
-        </ul>
+      </ul>
     </div>
     </div>
 </div>