From ef1f3b71d827d330d50751a15b063c3c01fb8740 Mon Sep 17 00:00:00 2001 From: Chris Van Date: Fri, 18 May 2012 15:46:42 -0700 Subject: [PATCH] add "Export to JSON" to app statistics (bug 755476) --- apps/stats/templates/stats/dashboard.html | 7 ++----- apps/stats/templates/stats/report.html | 9 +++++++++ apps/stats/templates/stats/reports/addons_created.html | 6 ++---- .../stats/templates/stats/reports/addons_downloaded.html | 6 ++---- apps/stats/templates/stats/reports/addons_downloads.html | 5 ----- apps/stats/templates/stats/reports/addons_in_use.html | 6 ++---- apps/stats/templates/stats/reports/addons_updated.html | 6 ++---- apps/stats/templates/stats/reports/apps.html | 6 ++---- .../templates/stats/reports/collections_created.html | 6 ++---- apps/stats/templates/stats/reports/contributions.html | 6 ++---- apps/stats/templates/stats/reports/downloads.html | 6 ++---- apps/stats/templates/stats/reports/locales.html | 6 ++---- apps/stats/templates/stats/reports/os.html | 6 ++---- apps/stats/templates/stats/reports/ratings.html | 6 ++---- apps/stats/templates/stats/reports/reviews_created.html | 6 ++---- apps/stats/templates/stats/reports/sources.html | 6 ++---- apps/stats/templates/stats/reports/statuses.html | 6 ++---- apps/stats/templates/stats/reports/subscribers.html | 6 ++---- apps/stats/templates/stats/reports/usage.html | 8 +++----- apps/stats/templates/stats/reports/users_created.html | 6 ++---- apps/stats/templates/stats/reports/versions.html | 6 ++---- media/css/impala/stats.less | 2 +- media/css/mkt/stats.less | 2 +- media/js/impala/stats/stats.js | 5 +++-- media/js/mkt/stats/stats.js | 5 +++-- mkt/stats/templates/appstats/report.html | 9 +++++++++ mkt/stats/templates/appstats/reports/installs.html | 6 ++---- mkt/stats/templates/appstats/reports/refunds.html | 6 ++---- mkt/stats/templates/appstats/reports/revenue.html | 6 ++---- mkt/stats/templates/appstats/reports/sales.html | 6 ++---- mkt/stats/templates/appstats/reports/usage.html | 6 ++---- 31 files changed, 75 insertions(+), 109 deletions(-) create mode 100644 apps/stats/templates/stats/report.html delete mode 100644 apps/stats/templates/stats/reports/addons_downloads.html create mode 100644 mkt/stats/templates/appstats/report.html diff --git a/apps/stats/templates/stats/dashboard.html b/apps/stats/templates/stats/dashboard.html index 35d04dbd9a..a4694395d8 100644 --- a/apps/stats/templates/stats/dashboard.html +++ b/apps/stats/templates/stats/dashboard.html @@ -1,6 +1,3 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{ _('Add-on Statistics') }} - {{ _('Export as CSV') }}

-{% endblock %} +{% set title = _('Add-on Statistics') %} diff --git a/apps/stats/templates/stats/report.html b/apps/stats/templates/stats/report.html new file mode 100644 index 0000000000..cdf578c4fe --- /dev/null +++ b/apps/stats/templates/stats/report.html @@ -0,0 +1,9 @@ +{% extends 'stats/stats.html' %} + +{% block csvtitle %} +

+ {{ title }} + {{ _('Export as CSV') }} + {{ _('Export as JSON') }} +

+{% endblock %} diff --git a/apps/stats/templates/stats/reports/addons_created.html b/apps/stats/templates/stats/reports/addons_created.html index 3a079c77e5..57885f66b2 100644 --- a/apps/stats/templates/stats/reports/addons_created.html +++ b/apps/stats/templates/stats/reports/addons_created.html @@ -1,5 +1,3 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('Add-ons Created by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Add-ons Created by Date') %} diff --git a/apps/stats/templates/stats/reports/addons_downloaded.html b/apps/stats/templates/stats/reports/addons_downloaded.html index 8e11c15bfc..daec2d5d5c 100644 --- a/apps/stats/templates/stats/reports/addons_downloaded.html +++ b/apps/stats/templates/stats/reports/addons_downloaded.html @@ -1,5 +1,3 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('Add-ons Downloaded by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Add-ons Downloaded by Date') %} diff --git a/apps/stats/templates/stats/reports/addons_downloads.html b/apps/stats/templates/stats/reports/addons_downloads.html deleted file mode 100644 index 9ae7b15956..0000000000 --- a/apps/stats/templates/stats/reports/addons_downloads.html +++ /dev/null @@ -1,5 +0,0 @@ -{% extends "stats/stats.html" %} - -{% block csvtitle %} -

{{_('Add-ons in Use by Date')}}{{_('Export as CSV')}}

-{% endblock %} diff --git a/apps/stats/templates/stats/reports/addons_in_use.html b/apps/stats/templates/stats/reports/addons_in_use.html index 9ae7b15956..6485c6e22e 100644 --- a/apps/stats/templates/stats/reports/addons_in_use.html +++ b/apps/stats/templates/stats/reports/addons_in_use.html @@ -1,5 +1,3 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('Add-ons in Use by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Add-ons in Use by Date') %} diff --git a/apps/stats/templates/stats/reports/addons_updated.html b/apps/stats/templates/stats/reports/addons_updated.html index 8c3003697b..6928120f19 100644 --- a/apps/stats/templates/stats/reports/addons_updated.html +++ b/apps/stats/templates/stats/reports/addons_updated.html @@ -1,5 +1,3 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('Add-ons Updated by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Add-ons Updated by Date') %} diff --git a/apps/stats/templates/stats/reports/apps.html b/apps/stats/templates/stats/reports/apps.html index b074162999..269e6547d6 100644 --- a/apps/stats/templates/stats/reports/apps.html +++ b/apps/stats/templates/stats/reports/apps.html @@ -1,5 +1,3 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('Application usage by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Application usage by Date') %} diff --git a/apps/stats/templates/stats/reports/collections_created.html b/apps/stats/templates/stats/reports/collections_created.html index 77f7a0d5f0..2d97423465 100644 --- a/apps/stats/templates/stats/reports/collections_created.html +++ b/apps/stats/templates/stats/reports/collections_created.html @@ -1,5 +1,3 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('Collections Created by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Collections Created by Date') %} diff --git a/apps/stats/templates/stats/reports/contributions.html b/apps/stats/templates/stats/reports/contributions.html index 95dd2a2529..b29231fbb9 100644 --- a/apps/stats/templates/stats/reports/contributions.html +++ b/apps/stats/templates/stats/reports/contributions.html @@ -1,5 +1,3 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('Contributions by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Contributions by Date') %} diff --git a/apps/stats/templates/stats/reports/downloads.html b/apps/stats/templates/stats/reports/downloads.html index db287e8b16..12ab137e5d 100644 --- a/apps/stats/templates/stats/reports/downloads.html +++ b/apps/stats/templates/stats/reports/downloads.html @@ -1,8 +1,6 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('Downloads by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Downloaded by Date') %} {% block stats_note_link %} {{ _('How are downloads counted?') }} diff --git a/apps/stats/templates/stats/reports/locales.html b/apps/stats/templates/stats/reports/locales.html index 6425405626..868ae3b873 100644 --- a/apps/stats/templates/stats/reports/locales.html +++ b/apps/stats/templates/stats/reports/locales.html @@ -1,5 +1,3 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('User languages by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('User languages by Date') %} diff --git a/apps/stats/templates/stats/reports/os.html b/apps/stats/templates/stats/reports/os.html index 664f58e759..f5078371c2 100644 --- a/apps/stats/templates/stats/reports/os.html +++ b/apps/stats/templates/stats/reports/os.html @@ -1,5 +1,3 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('Platform usage by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Platform usage by Date') %} diff --git a/apps/stats/templates/stats/reports/ratings.html b/apps/stats/templates/stats/reports/ratings.html index ce5042f032..1238b554d6 100644 --- a/apps/stats/templates/stats/reports/ratings.html +++ b/apps/stats/templates/stats/reports/ratings.html @@ -1,5 +1,3 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('Ratings by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Ratings by Date') %} diff --git a/apps/stats/templates/stats/reports/reviews_created.html b/apps/stats/templates/stats/reports/reviews_created.html index a32ad01f86..0f9abdb6e6 100644 --- a/apps/stats/templates/stats/reports/reviews_created.html +++ b/apps/stats/templates/stats/reports/reviews_created.html @@ -1,5 +1,3 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('Reviews Created by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Reviews Created by Date') %} diff --git a/apps/stats/templates/stats/reports/sources.html b/apps/stats/templates/stats/reports/sources.html index 9ab225f4d5..214810cb35 100644 --- a/apps/stats/templates/stats/reports/sources.html +++ b/apps/stats/templates/stats/reports/sources.html @@ -1,8 +1,6 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('Download sources by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Download sources by Date') %} {% block stats_note_link %} {{ _('About tracking external sources...') }} diff --git a/apps/stats/templates/stats/reports/statuses.html b/apps/stats/templates/stats/reports/statuses.html index b07e056833..64e508f79f 100644 --- a/apps/stats/templates/stats/reports/statuses.html +++ b/apps/stats/templates/stats/reports/statuses.html @@ -1,5 +1,3 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('Add-on Status by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Add-on Status by Date') %} diff --git a/apps/stats/templates/stats/reports/subscribers.html b/apps/stats/templates/stats/reports/subscribers.html index 7efced8399..00b3e004f4 100644 --- a/apps/stats/templates/stats/reports/subscribers.html +++ b/apps/stats/templates/stats/reports/subscribers.html @@ -1,5 +1,3 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('Subscribers by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Subscribers by Date') %} diff --git a/apps/stats/templates/stats/reports/usage.html b/apps/stats/templates/stats/reports/usage.html index d2710c6bcd..2e0d85fb26 100644 --- a/apps/stats/templates/stats/reports/usage.html +++ b/apps/stats/templates/stats/reports/usage.html @@ -1,8 +1,6 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('Daily Users by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Daily Users by Date') %} {% block stats_note_link %} {{ _('What are daily users?') }} @@ -18,4 +16,4 @@ and locale.

{% endtrans %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/apps/stats/templates/stats/reports/users_created.html b/apps/stats/templates/stats/reports/users_created.html index 0f1ddb8c33..0e8007ca46 100644 --- a/apps/stats/templates/stats/reports/users_created.html +++ b/apps/stats/templates/stats/reports/users_created.html @@ -1,5 +1,3 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('User Signups by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('User Signups by Date') %} diff --git a/apps/stats/templates/stats/reports/versions.html b/apps/stats/templates/stats/reports/versions.html index fe83bdc255..96b540acbc 100644 --- a/apps/stats/templates/stats/reports/versions.html +++ b/apps/stats/templates/stats/reports/versions.html @@ -1,5 +1,3 @@ -{% extends "stats/stats.html" %} +{% extends 'stats/report.html' %} -{% block csvtitle %} -

{{_('Application versions by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Application versions by Date') %} diff --git a/media/css/impala/stats.less b/media/css/impala/stats.less index 568b802fa6..3767cb464b 100644 --- a/media/css/impala/stats.less +++ b/media/css/impala/stats.less @@ -300,7 +300,7 @@ aside.highlight { } } -#export_data { +#export_data_csv, #export_data_json { font: 13px "helvetica neue",arial,helvetica,sans-serif; margin-left:1em; } diff --git a/media/css/mkt/stats.less b/media/css/mkt/stats.less index 52a6a06bc7..bfeb1b7f29 100644 --- a/media/css/mkt/stats.less +++ b/media/css/mkt/stats.less @@ -188,7 +188,7 @@ aside.highlight { } } -#export_data { +#export_data_csv, #export_data_json { font: 13px "helvetica neue",arial,helvetica,sans-serif; margin-left: 1em; } diff --git a/media/js/impala/stats/stats.js b/media/js/impala/stats/stats.js index 0ed9356e45..58bdffc6f6 100644 --- a/media/js/impala/stats/stats.js +++ b/media/js/impala/stats/stats.js @@ -66,8 +66,9 @@ _.extend(view, newView); var metric = view.metric, range = normalizeRange(view.range), - url = baseURL + ([metric,'day',range.start.pretty(''),range.end.pretty('')]).join('-') + '.csv'; - $('#export_data').attr('href', url); + url = baseURL + ([metric,'day',range.start.pretty(''),range.end.pretty('')]).join('-'); + $('#export_data_csv').attr('href', url + '.csv'); + $('#export_data_json').attr('href', url + '.json'); }); })(); diff --git a/media/js/mkt/stats/stats.js b/media/js/mkt/stats/stats.js index 0ed9356e45..58bdffc6f6 100644 --- a/media/js/mkt/stats/stats.js +++ b/media/js/mkt/stats/stats.js @@ -66,8 +66,9 @@ _.extend(view, newView); var metric = view.metric, range = normalizeRange(view.range), - url = baseURL + ([metric,'day',range.start.pretty(''),range.end.pretty('')]).join('-') + '.csv'; - $('#export_data').attr('href', url); + url = baseURL + ([metric,'day',range.start.pretty(''),range.end.pretty('')]).join('-'); + $('#export_data_csv').attr('href', url + '.csv'); + $('#export_data_json').attr('href', url + '.json'); }); })(); diff --git a/mkt/stats/templates/appstats/report.html b/mkt/stats/templates/appstats/report.html new file mode 100644 index 0000000000..a0e9ce0e14 --- /dev/null +++ b/mkt/stats/templates/appstats/report.html @@ -0,0 +1,9 @@ +{% extends 'appstats/stats.html' %} + +{% block csvtitle %} +

+ {{ title }} + {{ _('Export as CSV') }} + {{ _('Export as JSON') }} +

+{% endblock %} diff --git a/mkt/stats/templates/appstats/reports/installs.html b/mkt/stats/templates/appstats/reports/installs.html index b0c0e0e6c2..8254d57344 100644 --- a/mkt/stats/templates/appstats/reports/installs.html +++ b/mkt/stats/templates/appstats/reports/installs.html @@ -1,5 +1,3 @@ -{% extends "appstats/stats.html" %} +{% extends 'appstats/report.html' %} -{% block csvtitle %} -

{{_('Installs by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Installs by Date') %} diff --git a/mkt/stats/templates/appstats/reports/refunds.html b/mkt/stats/templates/appstats/reports/refunds.html index 58f66ec21e..9561e25fab 100644 --- a/mkt/stats/templates/appstats/reports/refunds.html +++ b/mkt/stats/templates/appstats/reports/refunds.html @@ -1,5 +1,3 @@ -{% extends "appstats/reports/sales.html" %} +{% extends 'appstats/reports/sales.html' %} -{% block csvtitle %} -

{{_('Refunds by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Refunds by Date') %} diff --git a/mkt/stats/templates/appstats/reports/revenue.html b/mkt/stats/templates/appstats/reports/revenue.html index 04d1c1045d..475da08068 100644 --- a/mkt/stats/templates/appstats/reports/revenue.html +++ b/mkt/stats/templates/appstats/reports/revenue.html @@ -1,5 +1,3 @@ -{% extends "appstats/reports/sales.html" %} +{% extends 'appstats/reports/sales.html' %} -{% block csvtitle %} -

{{_('Revenue by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Revenue by Date') %} diff --git a/mkt/stats/templates/appstats/reports/sales.html b/mkt/stats/templates/appstats/reports/sales.html index 01ba1d350d..6461728345 100644 --- a/mkt/stats/templates/appstats/reports/sales.html +++ b/mkt/stats/templates/appstats/reports/sales.html @@ -1,4 +1,4 @@ -{% extends "appstats/stats.html" %} +{% extends 'appstats/report.html' %} {% block sales_select %} class="selected" @@ -22,6 +22,4 @@ {% endblock %} -{% block csvtitle %} -

{{_('Sales by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Sales by Date') %} diff --git a/mkt/stats/templates/appstats/reports/usage.html b/mkt/stats/templates/appstats/reports/usage.html index 64d1d25177..be4317818e 100644 --- a/mkt/stats/templates/appstats/reports/usage.html +++ b/mkt/stats/templates/appstats/reports/usage.html @@ -1,5 +1,3 @@ -{% extends "appstats/stats.html" %} +{% extends 'appstats/report.html' %} -{% block csvtitle %} -

{{_('Usage by Date')}}{{_('Export as CSV')}}

-{% endblock %} +{% set title = _('Usage by Date') %}