Add summary and activity screens, remove private datasets from counts
[ckanext-dga-stats.git] / ckanext / dga_stats / templates / ckanext / stats / index.html
blob:a/ckanext/dga_stats/templates/ckanext/stats/index.html -> blob:b/ckanext/dga_stats/templates/ckanext/stats/index.html
{% extends "page.html" %} {% extends "page.html" %}
   
{% block breadcrumb_content %} {% block breadcrumb_content %}
<li class="active">{{ 'Statistics' }}</li> <li class="active">{{ 'Statistics' }}</li>
{% endblock %} {% endblock %}
   
{% block primary_content %} {% block primary_content %}
<article class="module"> <article class="module">
<section id="summary" class="module-content tab-content"> {% if h.check_access('sysadmin') %}
<h2>{{ _('Summary') }}</h2> <section id="stats-activity-counts" class="module-content tab-content">
{% if c.summary_stats %}  
<table class="table table-chunky table-bordered table-striped">  
<thead>  
<tr>  
<th>{{ _('Measure') }}</th>  
<th class="metric">{{ _('Value') }}</th>  
</tr>  
</thead>  
<tbody>  
{% for measure,value in c.summary_stats %}  
<tr>  
<td>{{measure}}</td>  
<td class="metric">{{ value }}</td>  
</tr>  
{% endfor %}  
</tbody>  
</table>  
{% else %}  
<p class="empty">{{ _('No groups') }}</p>  
{% endif %}  
</section>  
<section id="activity-counts" class="module-content tab-content">  
<h2>{{ _('Site Activity Log') }}</h2> <h2>{{ _('Site Activity Log') }}</h2>
{% if c.activity_counts %} {% if c.activity_counts %}
<table class="table table-chunky table-bordered table-striped"> <table class="table table-chunky table-bordered table-striped">
<thead> <thead>
<tr> <tr>
<th>{{ _('Month') }}</th> <th>{{ _('Month') }}</th>
<th>{{ _('Activity Type') }}</th> <th>{{ _('Activity Type') }}</th>
<th class="metric">{{ _('Count') }}</th> <th class="metric">{{ _('Count') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for month, type, count in c.activity_counts %} {% for month, type, count in c.activity_counts %}
<tr> <tr>
<td>{{ month }}</td> <td>{{ month }}</td>
<td>{{ type }}</td> <td>{{ type }}</td>
<td class="metric">{{ count }}</td> <td class="metric">{{ count }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
{% else %} {% else %}
<p class="empty">{{ _('No groups') }}</p> <p class="empty">{{ _('No groups') }}</p>
{% endif %} {% endif %}
</section> </section>
  <section id="stats-recent-datasets" class="module-content tab-content">
  <h2>{{ _('Recent Datasets') }}</h2>
  {% if c.recent_datasets %}
  <table class="table table-chunky table-bordered table-striped">
  <thead>
  <tr>
  <th>{{ _('Date') }}</th>
  <th>{{ _('Dataset') }}</th>
  <th>{{ _('New/Modified') }}</th>
  </tr>
  </thead>
  <tbody>
  {% for date,package,newmodified in c.recent_datasets %}
  <tr>
  <td>{{ date }}</td>
  <td>{{ h.link_to(package.title or package.name, h.url_for(controller='package', action='read', id=package.name)) }}</td>
  <td>{{ newmodified }}</td>
  </tr>
  {% endfor %}
  </tbody>
  </table>
  {% else %}
  <p class="empty">{{ _('No groups') }}</p>
  {% endif %}
  </section>
  <section id="stats-user-access-list" class="module-content tab-content">
  <h2>{{ _('User Access List') }}</h2>
  {% if c.user_access_list %}
  <table class="table table-chunky table-bordered table-striped">
  <thead>
  <tr>
  <th>{{ _('Username') }}</th>
  <th>{{ _('Sysadmin') }}</th>
  <th class="metric">{{ _('Organisational Role') }}</th>
  </tr>
  </thead>
  <tbody>
  {% for username,sysadmin,role in c.user_access_list %}
  <tr>
  <td>{{ username }}</td>
  <td>{{ sysadmin }}</td>
  <td>{{ role }}</td>
  </tr>
  {% endfor %}
  </tbody>
  </table>
  {% else %}
  <p class="empty">{{ _('No groups') }}</p>
  {% endif %}
  </section>
  {% endif %}
<section id="stats-total-datasets" class="module-content tab-content active"> <section id="stats-total-datasets" class="module-content tab-content active">
<h2>{{ _('Total number of Datasets') }}</h2> <h2>{{ _('Total number of Datasets') }}</h2>
   
{% set xaxis = {'mode': 'time', 'timeformat': '%y-%b'} %} {% set xaxis = {'mode': 'time', 'timeformat': '%y-%b'} %}
{% set yaxis = {'min': 0} %} {% set yaxis = {'min': 0} %}
<table class="table table-chunky table-bordered table-striped" data-module="plot" data-module-xaxis="{{ h.dump_json(xaxis) }}" data-module-yaxis="{{ h.dump_json(yaxis) }}"> <table class="table table-chunky table-bordered table-striped" data-module="plot" data-module-xaxis="{{ h.dump_json(xaxis) }}" data-module-yaxis="{{ h.dump_json(yaxis) }}">
<thead> <thead>
<tr> <tr>
<th>{{ _("Date") }}</th> <th>{{ _("Date") }}</th>
<th>{{ _("Total datasets") }}</th> <th>{{ _("Total datasets") }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for row in c.raw_packages_by_week %} {% for row in c.raw_packages_by_week %}
<tr> <tr>
<th data-type="date" data-value="{{ row.date.strftime("%s") }}"><time datetime="{{ row.date.isoformat() }}">{{ h.render_datetime(row.date) }}</time></th> <th data-type="date" data-value="{{ row.date.strftime("%s") }}"><time datetime="{{ row.date.isoformat() }}">{{ h.render_datetime(row.date) }}</time></th>
<td>{{ row.total_packages }}</td> <td>{{ row.total_packages }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</section> </section>
   
<section id="stats-dataset-revisions" class="module-content tab-content"> <section id="stats-dataset-revisions" class="module-content tab-content">
<h2>{{ _('Dataset Revisions per Week') }}</h2> <h2>{{ _('Dataset Revisions per Week') }}</h2>
   
{% set xaxis = {'mode': 'time', 'timeformat': '%y-%b'} %} {% set xaxis = {'mode': 'time', 'timeformat': '%y-%b'} %}
{% set lines = {'fill': 1} %} {% set lines = {'fill': 1} %}
<table class="table table-chunky table-bordered table-striped" data-module="plot" data-module-xaxis="{{ h.dump_json(xaxis) }}" data-module-lines="{{ h.dump_json(lines) }}"> <table class="table table-chunky table-bordered table-striped" data-module="plot" data-module-xaxis="{{ h.dump_json(xaxis) }}" data-module-lines="{{ h.dump_json(lines) }}">
<thead> <thead>
<tr> <tr>
<th>{{ _("Date") }}</th> <th>{{ _("Date") }}</th>
<th>{{ _("All dataset revisions") }}</th> <th>{{ _("All dataset revisions") }}</th>
<th>{{ _("New datasets") }}</th> <th>{{ _("New datasets") }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for row in c.raw_all_package_revisions %} {% for row in c.raw_all_package_revisions %}
<tr> <tr>
<th data-type="date" data-value="{{ row.date.strftime("%s") }}"><time datetime="{{ row.date.isoformat() }}">{{ h.render_datetime(row.date) }}</time></th> <th data-type="date" data-value="{{ row.date.strftime("%s") }}"><time datetime="{{ row.date.isoformat() }}">{{ h.render_datetime(row.date) }}</time></th>
<td>{{ row.total_revisions }}</td> <td>{{ row.total_revisions }}</td>
<td>{{ c.raw_new_datasets[loop.index0].new_packages }}</td> <td>{{ c.raw_new_datasets[loop.index0].new_packages }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</section> </section>
   
<section id="stats-top-rated" class="module-content tab-content">  
<h2>{{ _('Top Rated Datasets') }}</h2>  
{% if c.top_rated_packages %}  
<table class="table table-chunky table-bordered table-striped">  
<thead>  
<tr>  
<th>Dataset</th>  
<th class="metric">{{ _('Average rating') }}</th>  
<th class="metric">{{ _('Number of ratings') }}</th>  
</tr>  
</thead>  
<tbody>  
{% for package, rating, num_ratings in c.top_rated_packages %}  
<tr>  
<th>{{ h.link_to(package.title or package.name, h.url_for(controller='package', action='read', id=package.name)) }}</th>  
<td class="metric">{{ rating }}</td>  
<td class="metric">{{ num_ratings }}</td>  
</tr>  
{% endfor %}  
</tbody>  
</table>  
{% else %}  
<p class="empty">{{ _('No ratings') }}</p>  
{% endif %}  
</section>  
   
<section id="stats-most-edited" class="module-content tab-content"> <section id="stats-most-edited" class="module-content tab-content">
<h2>{{ _('Most Edited Datasets') }}</h2> <h2>{{ _('Most Edited Datasets') }}</h2>
{% if c.most_edited_packages %} {% if c.most_edited_packages %}
<table class="table table-chunky table-bordered table-striped"> <table class="table table-chunky table-bordered table-striped">
<thead> <thead>
<tr> <tr>
<th>{{ _('Dataset') }}</th> <th>{{ _('Dataset') }}</th>
<th class="metric">{{ _('Number of edits') }}</th> <th class="metric">{{ _('Number of edits') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for package, edits in c.most_edited_packages %} {% for package, edits in c.most_edited_packages %}
<tr py:for="package, edits in c.most_edited_packages"> <tr py:for="package, edits in c.most_edited_packages">
<td>{{ h.link_to(package.title or package.name, h.url_for(controller='package', action='read', id=package.name)) }}</td> <td>{{ h.link_to(package.title or package.name, h.url_for(controller='package', action='read', id=package.name)) }}</td>
<td class="metric">{{ edits }}</td> <td class="metric">{{ edits }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
{% else %} {% else %}
<p class="empty">{{ _('No edited datasets') }}</p> <p class="empty">{{ _('No edited datasets') }}</p>
{% endif %} {% endif %}
</section> </section>
   
<section id="stats-largest-groups" class="module-content tab-content"> <section id="stats-largest-groups" class="module-content tab-content">
<h2>{{ _('Largest Groups') }}</h2> <h2>{{ _('Largest Groups') }}</h2>
{% if c.largest_groups %} {% if c.largest_groups %}
<table class="table table-chunky table-bordered table-striped"> <table class="table table-chunky table-bordered table-striped">
<thead> <thead>
<tr> <tr>
<th>{{ _('Group') }}</th> <th>{{ _('Group') }}</th>
<th class="metric">{{ _('Number of datasets') }}</th> <th class="metric">{{ _('Number of datasets') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for group, num_packages in c.largest_groups %} {% for group, num_packages in c.largest_groups %}
<tr> <tr>
<td>{{ h.link_to(group.title or group.name, h.url_for(controller='group', action='read', id=group.name)) }}</td> <td>{{ h.link_to(group.title or group.name, h.url_for(controller='group', action='read', id=group.name)) }}</td>
<td class="metric">{{ num_packages }}</td> <td class="metric">{{ num_packages }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
{% else %} {% else %}
<p class="empty">{{ _('No groups') }}</p> <p class="empty">{{ _('No groups') }}</p>
{% endif %} {% endif %}
</section> </section>
<section id="stats-largest-groups" class="module-content tab-content"> <section id="stats-by-org" class="module-content tab-content">
<h2>{{ _('Largest Groups') }}</h2> <h2>{{ _('Datasets by Organization') }}</h2>
{% if c.largest_groups %} {% if c.by_org %}
<table class="table table-chunky table-bordered table-striped"> <table class="table table-chunky table-bordered table-striped">
<thead> <thead>
<tr> <tr>
<th>{{ _('Group') }}</th> <th>{{ _('Organisation') }}</th>
  <th>{{ _('Public/Archived') }}</th>
<th class="metric">{{ _('Number of datasets') }}</th> <th class="metric">{{ _('Number of datasets') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for group, num_packages in c.largest_groups %} {% for group,private, num_packages in c.by_org %}
<tr> {% if private == False or h.check_access('sysadmin') %}
<td>{{ h.link_to(group.title or group.name, h.url_for(controller='group', action='read', id=group.name)) }}</td> <tr>
  <td>{{ h.link_to(group.title or group.name, h.url_for(controller='organization', action='read', id=group.name)) }}</td>
  {% if private == True %}
  <td>Archived</td>
  {% else %}
  <td>Public</td>
  {% endif %}
<td class="metric">{{ num_packages }}</td> <td class="metric">{{ num_packages }}</td>
</tr> </tr>
{% endfor %} {% endif %}
</tbody> {% endfor %}
</table> </tbody>
{% else %} </table>
<p class="empty">{{ _('No groups') }}</p> {% else %}
{% endif %} <p class="empty">{{ _('No groups') }}</p>
</section> {% endif %}
  </section>
<section id="stats-top-tags" class="module-content tab-content"> <section id="stats-res-by-org" class="module-content tab-content">
<h2>{{ _('Top Tags') }}</h2> <h2>{{ _('Resources by Organization') }}</h2>
<table class="table table-chunky table-bordered table-striped"> {% if c.res_by_org %}
<thead> <table class="table table-chunky table-bordered table-striped">
<tr> <thead>
<th>{{ _('Tag Name') }}</th> <tr>
<th class="metric">{{ _('Number of Datasets') }}</th> <th>{{ _('Organisation') }}</th>
</tr> <th>{{ _('Tabular') }}</th>
</thead> <th>{{ _('Spatial') }}</th>
<tbody> <th>{{ _('Other') }}</th>
{% for tag, num_packages in c.top_tags %} <th class="metric">{{ _('Total') }}</th>
<tr> </tr>
<td>{{ h.link_to(tag.name, h.url_for(controller='package', action='search', tags=tag.name)) }}</td> </thead>
<td class="metric">{{ num_packages }}</td> <tbody>
</tr> {% for group,t,s,o,tot in c.res_by_org %}
{% endfor %} <tr>
</tbody> <td>{{ h.link_to(group.title or group.name, h.url_for(controller='organization', action='read', id=group.name)) }}</td>
</table> <td>{{ t }}</td>
</section> <td>{{ s }}</td>
  <td>{{ o }}</td>
<section id="stats-most-owned" class="module-content tab-content"> <td class="metric">{{ tot }}</td>
<h2>{{ _('Users Owning Most Datasets') }}</h2> </tr>
<table class="table table-chunky table-bordered table-striped"> {% endfor %}
<thead> </tbody>
<tr> </table>
<th>{{ _('User') }}</th> {% else %}
<th class="metric">{{ _('Number of Datasets') }}</th> <p class="empty">{{ _('No groups') }}</p>
</tr> {% endif %}
</thead> </section>
<tbody> <section id="stats-activity-org" class="module-content tab-content">
{% for user, num_packages in c.top_package_owners %} <h2>{{ _('Most Active Organisations') }}</h2>
<tr> {% if c.top_active_orgs %}
<td class="media">{{ h.linked_user(user) }}</td> <table class="table table-chunky table-bordered table-striped">
<td class="metric">{{ num_packages }}</td> <thead>
</tr> <tr>
{% endfor %} <th>{{ _('Organisation') }}</th>
</tbody> <th class="metric">{{ _('Number of datasets updated recently') }}</th>
</table> </tr>
  </thead>
  <tbody>
  {% for group, num_packages in c.top_active_orgs %}
  <tr>
  <td>{{ h.link_to(group.title or group.name, h.url_for(controller='organization', action='read', id=group.name)) }}</td>
  <td class="metric">{{ num_packages }}</td>
  </tr>
  {% endfor %}
  </tbody>
  </table>
  {% else %}
  <p class="empty">{{ _('No groups') }}</p>
  {% endif %}
  </section>
  <section id="stats-summary" class="module-content tab-content">
  <h2>{{ _('Summary') }}</h2>
  {% if c.summary_stats %}
  <table class="table table-chunky table-bordered table-striped">
  <thead>
  <tr>
  <th>{{ _('Measure') }}</th>
  <th class="metric">{{ _('Value') }}</th>
  </tr>
  </thead>
  <tbody>
  {% for measure,value in c.summary_stats %}
  {% if 'Archived' not in measure or h.check_access('sysadmin') %}
  <tr>
  <td>{{measure}}</td>
  <td class="metric">{{ value }}</td>
  </tr>
  {% endif %}
  {% endfor %}
  </tbody>
  </table>
  {% else %}
  <p class="empty">{{ _('No groups') }}</p>
  {% endif %}
</section> </section>
</article> </article>
{% endblock %} {% endblock %}
   
{% block secondary_content %} {% block secondary_content %}
<section class="module module-narrow"> <section class="module module-narrow">
<h2 class="module-heading"><i class="icon-bar-chart icon-medium"></i> {{ _('Statistics Menu') }}</h2> <h2 class="module-heading"><i class="icon-bar-chart icon-medium"></i> {{ _('Statistics Menu') }}</h2>
<nav data-module="stats-nav"> <nav data-module="stats-nav">
<ul class="unstyled nav nav-simple"> <ul class="unstyled nav nav-simple">
<li class="nav-item"><a href="#summary" data-toggle="tab">{{ _('Summary') }}</a></li> {% if h.check_access('sysadmin') %}
<li class="nav-item"><a href="#activity-counts" data-toggle="tab">{{ _('Site Activity Log') }}</a></li> <li class="nav-item"><a href="#stats-recent-datasets" data-toggle="tab">{{ _('Recent Datasets') }}</a></li>
<li class="nav-item active"><a href="#stats-total-datasets" data-toggle="tab">{{ _('Total Number of Datasets') }}</a></li> <li class="nav-item"><a href="#stats-user-access-list" data-toggle="tab">{{ _('User Access List') }}</a></li>
  {% endif %}
  <li class="nav-item"><a href="#stats-total-datasets" data-toggle="tab">{{ _('Total Number of Datasets') }}</a></li>
<li class="nav-item"><a href="#stats-dataset-revisions" data-toggle="tab">{{ _('Dataset Revisions per Week') }}</a></li> <li class="nav-item"><a href="#stats-dataset-revisions" data-toggle="tab">{{ _('Dataset Revisions per Week') }}</a></li>
<li class="nav-item"><a href="#stats-top-rated" data-toggle="tab">{{ _('Top Rated Datasets') }}</a></li>  
<li class="nav-item"><a href="#stats-most-edited" data-toggle="tab">{{ _('Most Edited Datasets') }}</a></li> <li class="nav-item"><a href="#stats-most-edited" data-toggle="tab">{{ _('Most Edited Datasets') }}</a></li>
<li class="nav-item"><a href="#stats-largest-groups" data-toggle="tab">{{ _('Largest Groups') }}</a></li> <li class="nav-item"><a href="#stats-by-org" data-toggle="tab">{{ _('Datasets by Organization') }}</a></li>
<li class="nav-item"><a href="#stats-top-tags" data-toggle="tab">{{ _('Top Tags') }}</a></li> <li class="nav-item"><a href="#stats-res-by-org" data-toggle="tab">{{ _('Resources by Organization') }}</a></li>
<li class="nav-item"><a href="#stats-most-owned" data-toggle="tab">{{ _('Users Owning Most Datasets') }}</a></li> <li class="nav-item"><a href="#stats-activity-org" data-toggle="tab">{{ _('Most Active Organisations') }}</a></li>
  <li class="nav-item active"><a href="//data.gov.au/site-usage" data-toggle="tab">Site Analytics</a></li>
  <li class="nav-item active"><a href="#stats-summary" data-toggle="tab">{{ _('Summary') }}</a></li>
</ul> </ul>
</nav> </nav>
</section> </section>
{% endblock %} {% endblock %}
   
{% block scripts %} {% block scripts %}
{{ super() }} {{ super() }}
{# {#
Hellish hack to get excanvas to work in IE8. We disable html5shiv from Hellish hack to get excanvas to work in IE8. We disable html5shiv from
overriding the createElement() method on this page. overriding the createElement() method on this page.
See: http://stackoverflow.com/questions/10208062/using-flot-with-bootstrap-ie8-incompatibility See: http://stackoverflow.com/questions/10208062/using-flot-with-bootstrap-ie8-incompatibility
#} #}
{% resource "vendor/block_html5_shim" %} {% resource "vendor/block_html5_shim" %}
{% resource "ckanext_dga_stats/stats" %} {% resource "ckanext_dga_stats/stats" %}
{% endblock %} {% endblock %}