Piwik: move to webpack

This commit is contained in:
Pedro Ferreira 2018-03-01 18:56:27 +01:00 committed by Adrian Moennich
parent c563d577fc
commit 11606355b4
7 changed files with 47 additions and 18 deletions

View File

@ -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);
}

View File

@ -15,6 +15,7 @@
# along with Indico; if not, see <http://www.gnu.org/licenses/>.
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):

View File

@ -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

View File

@ -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') }}
<div id="statsWidgetsWrapper">
<!-- Header -->
<div class="statsWidget full edge">

22
piwik/package.json Normal file
View File

@ -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 <indico.team@cern.ch>",
"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"
}
}

View File

@ -0,0 +1,5 @@
{
"entry": {
"main": "./index.js"
}
}