diff --git a/piwik/indico_piwik/static/js/statistics.js b/piwik/indico_piwik/client/index.js similarity index 97% rename from piwik/indico_piwik/static/js/statistics.js rename to piwik/indico_piwik/client/index.js index ed181c5..ac3923d 100644 --- a/piwik/indico_piwik/static/js/statistics.js +++ b/piwik/indico_piwik/client/index.js @@ -1,3 +1,8 @@ +import 'jqtree'; +import 'jquery'; +import './main.css'; +import 'indico/jquery/compat/jqplot'; + $(function() { var $t = $T.domain('piwik'); var treeDOMTarget = '#materialTree'; @@ -115,12 +120,12 @@ $(function() { * each element will be a key-pair value of date-hits. */ var get_jqplot_array_values = function(data, key, with_date) { - output = []; + const output = []; with_date = typeof with_date !== 'undefined' ? with_date : true; for (var date in data) { - hits = data[date]; - value = (with_date) ? [date, hits[key]] : hits[key]; + const hits = data[date]; + const value = (with_date) ? [date, hits[key]] : hits[key]; output.push(value); } diff --git a/piwik/indico_piwik/static/css/statistics.css b/piwik/indico_piwik/client/main.css similarity index 100% rename from piwik/indico_piwik/static/css/statistics.css rename to piwik/indico_piwik/client/main.css diff --git a/piwik/indico_piwik/controllers.py b/piwik/indico_piwik/controllers.py index b4a15fa..a4c07f4 100644 --- a/piwik/indico_piwik/controllers.py +++ b/piwik/indico_piwik/controllers.py @@ -15,6 +15,7 @@ # along with Indico; if not, see . from flask import jsonify, request +from flask_pluginengine import current_plugin from werkzeug.exceptions import NotFound from indico.modules.events.management.controllers import RHManageEventBase @@ -24,6 +25,16 @@ from indico_piwik.reports import (ReportCountries, ReportDevices, ReportDownload from indico_piwik.views import WPStatistics +class WPPiwikStatistics(WPStatistics): + @property + def additional_bundles(self): + return { + 'screen': map(lambda x: current_plugin.manifest[x], + ('main.js', 'main.css')), + 'print': () + } + + class RHPiwikBase(RHManageEventBase): def _process_args(self): from indico_piwik.plugin import PiwikPlugin @@ -38,7 +49,7 @@ class RHStatistics(RHPiwikBase): contrib_id=request.args.get('contrib_id'), start_date=request.args.get('start_date'), end_date=request.args.get('end_date')) - return WPStatistics.render_template('statistics.html', self.event, report=report) + return WPPiwikStatistics.render_template('statistics.html', self.event, report=report) class RHApiBase(RHPiwikBase): diff --git a/piwik/indico_piwik/plugin.py b/piwik/indico_piwik/plugin.py index 0c672c9..01fd047 100644 --- a/piwik/indico_piwik/plugin.py +++ b/piwik/indico_piwik/plugin.py @@ -88,12 +88,6 @@ class PiwikPlugin(IndicoPlugin): 'graph_countries': plugin_url_rule_to_js('piwik.graph_countries'), 'graph_devices': plugin_url_rule_to_js('piwik.graph_devices')}} - def register_assets(self): - self.register_js_bundle('statistics_js', 'js/statistics.js') - self.register_css_bundle('statistics_css', 'css/statistics.css') - self.register_js_bundle('jqtree_js', 'js/lib/jqTree/tree.jquery.js') - self.register_css_bundle('jqtree_css', 'js/lib/jqTree/jqtree.css') - def track_download(self, attachment, from_preview, **kwargs): if from_preview or not self.settings.get('enabled_for_downloads'): return diff --git a/piwik/indico_piwik/templates/statistics.html b/piwik/indico_piwik/templates/statistics.html index cc73f11..ebc9324 100644 --- a/piwik/indico_piwik/templates/statistics.html +++ b/piwik/indico_piwik/templates/statistics.html @@ -1,14 +1,6 @@ {% extends 'events/management/base.html' %} {% block content %} - {{ include_js_assets('jqplot_js') }} - {{ include_css_assets('jqplot_css') }} - {{ include_plugin_js_assets('jqtree_js') }} - {{ include_plugin_css_assets('jqtree_css') }} - {{ include_plugin_js_assets('statistics_js') }} - {{ include_plugin_css_assets('statistics_css') }} - -
diff --git a/piwik/package.json b/piwik/package.json new file mode 100644 index 0000000..447f2cb --- /dev/null +++ b/piwik/package.json @@ -0,0 +1,22 @@ +{ + "name": "indico-plugin-piwik", + "version": "1.0.0", + "description": "", + "main": "indico_piwik/client/index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/indico/indico-plugins.git" + }, + "author": "Indico Team ", + "license": "GPL-3.0", + "bugs": { + "url": "https://github.com/indico/indico-plugins/issues" + }, + "homepage": "https://github.com/indico/indico-plugins#readme", + "dependencies": { + "jqtree": "^1.4.4" + } +} diff --git a/piwik/webpack-bundles.json b/piwik/webpack-bundles.json new file mode 100644 index 0000000..5f28835 --- /dev/null +++ b/piwik/webpack-bundles.json @@ -0,0 +1,5 @@ +{ + "entry": { + "main": "./index.js" + } +}