Skip to content

Commit

Permalink
Frontend for event statistics
Browse files Browse the repository at this point in the history
Some minor styling adjustments
  • Loading branch information
MusikAnimal committed Feb 9, 2018
1 parent 4e80db4 commit 073ab39
Show file tree
Hide file tree
Showing 85 changed files with 386 additions and 86 deletions.
7 changes: 7 additions & 0 deletions app/Resources/assets/css/application.scss
Expand Up @@ -147,6 +147,13 @@ body {
}
}

.gm-table {
td:not(:first-child),
th:not(:first-child) {
text-align: center;
}
}

@media (max-width: $bootstrap-sm) {
.footer-links {
display: block;
Expand Down
7 changes: 6 additions & 1 deletion app/Resources/assets/css/events.scss
Expand Up @@ -23,7 +23,8 @@
}
}

.event-stats {
.event-stats,
.event-wiki-stats {
margin: 36px 0;
}

Expand All @@ -37,6 +38,10 @@
}
}

.event-stats-status {
margin-top: 8px;
}

.event-section {
h3 {
font-size: 24px;
Expand Down
22 changes: 22 additions & 0 deletions app/Resources/assets/js/events.js
Expand Up @@ -57,6 +57,28 @@ $(function () {
});
});
});

/**
* Listener for calculate statistics button, which hits the
* process event endpoint, firing off a job.
*/
$('.event-process-btn').on('click', function () {
document.activeElement.blur();

$(this).addClass('disabled').text($.i18n('updating'));
$('.event-export-btn').addClass('disabled');
$('.event-stats-status').text($.i18n('updating-desc'));

$.get(baseUrl + 'events/process/' + $(this).data('event-id')).done(function (data) {
$(this).removeClass('disabled').text($.i18n('update-data'));
$('.event-export-btn').removeClass('disabled');
$('.event-stats-status').text('');

// TODO: Make controller return HTML and update view with
// rendered Twig template, rather than having to refresh.
window.location.reload(true);
}.bind(this));
});
});

/**
Expand Down
102 changes: 77 additions & 25 deletions app/Resources/views/events/show.html.twig
Expand Up @@ -27,22 +27,31 @@
</h1>
</div>

<div class="btn-group pull-right event-export">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-export"></span>
{{ msg('export') }}
<span class="caret"></span>
<div class="pull-right text-right">
<button class="btn btn-default event-process-btn" data-event-id="{{ event.id }}">
{{ msg('update-data') }}
</button>
<ul class="dropdown-menu">
<li>
<a href="#">{{ msg('export-totals-wiki-table') }}</a>
</li>
<li>
<a href="#">{{ msg('export-raw-data-csv') }}</a>
</li>
</ul>
<div class="btn-group event-export">
<button type="button" class="btn btn-default dropdown-toggle event-export-btn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-export"></span>
{{ msg('export') }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a href="#">{{ msg('export-totals-wiki-table') }}</a>
</li>
<li>
<a href="#">{{ msg('export-raw-data-csv') }}</a>
</li>
</ul>
</div>
<div class="event-stats-status">
{% if event.updated != null %}
{{ msg('last-updated', [event.updated|date_format]) }}
{% endif %}
</div>
</div>
<a href="#" class="btn btn-default pull-right">{{ msg('calculate-totals') }}</a>

<table class="event-metadata">
<tr>
Expand Down Expand Up @@ -73,18 +82,61 @@
</table>

{% set colSize = 12 // (event.statistics|length + 1) %}
<div class="row event-stats">
<div class="col-sm-{{ colSize }} text-center{% if colSize is even %} col-sm-offset-1{% endif %}">
<h4>{{ msg('participants') }}</h4>
<h3>{{ event.numParticipants|num_format }}</h3>
</div>
{% for stat in event.statistics %}
<div class="col-sm-{{ colSize }} text-center">
<h4>{{ msg(stat.metric, [stat.offset]) }}</h4>
<h3>{{ stat.value|num_format }}</h3>
{% if event.wikis|length > 1 %}
{% set metricOrder = [] %}
<table class="table gm-table event-wiki-stats">
<thead>
<tr>
<th></th>
<th>{{ msg('participants') }}</th>
{% for stat in event.statistics %}
{% set metricOrder = metricOrder|merge([stat.metric]) %}
<th>{{ msg(stat.metric, [stat.offset]) }}</th>
{% endfor %}
</tr>
<tr>
<th>{{ msg('totals') }}</th>
<th>{{ event.numParticipants }}</th>
{% for stat in event.statistics %}
<th>{{ stat.value|num_format }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
<tr class="event-wiki-stats-summary">
</tr>
{% for wiki in event.wikis %}
<tr>
<td>{{ wiki.domain }}</td>
<td>&mdash;</td>
{% for metric in metricOrder %}
{% set stat = wiki.statistic(metric) %}
<td>
{% if stat != null %}
{{ stat.value|num_format }}
{% else %}
&mdash;
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="row event-stats">
<div class="col-sm-{{ colSize }} text-center{% if colSize is even %} col-sm-offset-1{% endif %}">
<h4>{{ msg('participants') }}</h4>
<h3>{{ event.numParticipants|num_format }}</h3>
</div>
{% endfor %}
</div>
{% for stat in event.statistics %}
<div class="col-sm-{{ colSize }} text-center">
<h4>{{ msg(stat.metric, [stat.offset]) }}</h4>
<h3>{{ stat.value|num_format }}</h3>
</div>
{% endfor %}
</div>
{% endif %}

{% set content %}
{{ form_errors(form) }}
Expand Down
30 changes: 16 additions & 14 deletions app/Resources/views/programs/index.html.twig
Expand Up @@ -19,13 +19,12 @@
<thead>
<tr>
<th>{{ msg('program') }}</th>
<th class="text-center text-nowrap"></th>
<th class="text-center text-nowrap">{{ msg('events') }}</th>
<th class="text-center text-nowrap">{{ msg('participants') }}</th>
<th class="text-center text-nowrap">{{ msg('new-editors') }}</th>
<th class="text-center text-nowrap">{{ msg('day-retention', [30]) }}</th>
<th class="text-center text-nowrap">{{ msg('pages-created') }}</th>
<th class="text-center text-nowrap">{{ msg('pages-improved') }}</th>
<th class="text-nowrap"></th>
<th class="text-nowrap">{{ msg('events') }}</th>
<th class="text-nowrap">{{ msg('participants') }}</th>
{% for metric, offset in metrics %}
<th class="text-nowrap">{{ msg(metric, [offset]) }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
Expand All @@ -34,7 +33,7 @@
<td>
<a href="{{ path('Program', {'title': program.title}) }}">{{ program.displayTitle }}</a>
</td>
<td class="text-center text-nowrap">
<td class="text-nowrap">
<a href="{{ path('EditProgram', {'title': program.title}) }}"
class="program-action program-action__edit text-muted">
<span class="glyphicon glyphicon-cog"></span>
Expand All @@ -45,12 +44,15 @@
<span class="glyphicon glyphicon-trash"></span>
</a>
</td>
<td class="text-center text-nowrap">{{ program.numEvents }}</td>
<td class="text-center text-nowrap">0</td>
<td class="text-center text-nowrap">0</td>
<td class="text-center text-nowrap">0</td>
<td class="text-center text-nowrap">0</td>
<td class="text-center text-nowrap">0</td>
<td class="text-nowrap">{{ program.numEvents }}</td>
<td class="text-nowrap">
{# {{ program.numParticipants }} #}
</td>
{% for metric in metrics|keys %}
<td class="text-nowrap">
{# {{ program.statistic(metric).value }} #}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
Expand Down
24 changes: 11 additions & 13 deletions app/Resources/views/programs/show.html.twig
Expand Up @@ -36,21 +36,20 @@
<thead>
<tr>
<th>{{ msg('event') }}</th>
<th class="text-center text-nowrap"></th>
<th class="text-center text-nowrap">{{ msg('participants') }}</th>
<th class="text-center text-nowrap">{{ msg('new-editors') }}</th>
<th class="text-center text-nowrap">{{ msg('day-retention', [30]) }}</th>
<th class="text-center text-nowrap">{{ msg('pages-created') }}</th>
<th class="text-center text-nowrap">{{ msg('pages-improved') }}</th>
<th class="text-nowrap"></th>
<th class="text-nowrap">{{ msg('participants') }}</th>
{% for metric, offset in metrics %}
<th class="text-nowrap">{{ msg(metric, [offset]) }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for event in program.events %}
<tr class="event-entry text-center">
<tr class="event-entry">
<td>
<a href="{{ path('Event', {'programTitle': program.title, 'title': event.title}) }}">{{ event.displayTitle }}</a>
</td>
<td class="text-center text-nowrap">
<td class="text-nowrap">
<a href="{{ path('EditEvent', {'programTitle': program.title, 'title': event.title}) }}"
class="event-action event-action__edit text-muted">
<span class="glyphicon glyphicon-cog"></span>
Expand All @@ -61,11 +60,10 @@
<span class="glyphicon glyphicon-trash"></span>
</a>
</td>
<td class="text-center text-nowrap">{{ event.numParticipants }}</td>
<td class="text-center text-nowrap">0</td>
<td class="text-center text-nowrap">0</td>
<td class="text-center text-nowrap">0</td>
<td class="text-center text-nowrap">0</td>
<td class="text-nowrap">{{ event.numParticipants }}</td>
{% for metric in metrics|keys %}
<td class="text-nowrap">{{ event.statistic(metric).value }}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
Expand Down
1 change: 1 addition & 0 deletions i18n/ar.json
Expand Up @@ -13,5 +13,6 @@
"optional": "اختياري",
"report-issue": "أبلغ عن خلل",
"submit": "قدّم",
"totals": " الإجمالي",
"view-source": "اعرض المصدر"
}
1 change: 1 addition & 0 deletions i18n/as.json
Expand Up @@ -5,5 +5,6 @@
"help-translate": "অনুবাদ কৰাত সহায় কৰক",
"no-results": "কোনো ফলাফল নাই",
"report-issue": "অভিযোগ দাখিল কৰক",
"totals": "মুঠ",
"view-source": "উৎস চাওক"
}
1 change: 1 addition & 0 deletions i18n/azb.json
Expand Up @@ -5,5 +5,6 @@
"help-translate": "چئویرمه‌یه کؤمک",
"no-results": "هئچ بیر سوْنوج تاپیلمادی",
"report-issue": "بیر مسأله‌نی راپورت ائدین",
"totals": "توْپلام",
"view-source": "قایناغا باخ"
}
1 change: 1 addition & 0 deletions i18n/ba.json
Expand Up @@ -5,5 +5,6 @@
"help-translate": "Тәржемә менән ярҙам итергә",
"no-results": "Бер нимә лә табылманы",
"report-issue": "Проблема хаҡында хәбәр итергә",
"totals": "Һөҙөмтәләр",
"view-source": "Сығанаҡты ҡарарға"
}
1 change: 1 addition & 0 deletions i18n/be-tarask.json
Expand Up @@ -6,5 +6,6 @@
"help-translate": "Дапамога зь перакладамі",
"no-results": "Нічога ня знойдзена",
"report-issue": "Паведаміць пра праблему",
"totals": "Агулам",
"view-source": "Паказаць крыніцу"
}
1 change: 1 addition & 0 deletions i18n/be.json
Expand Up @@ -8,5 +8,6 @@
"help-translate": "Дапамажыце перакласці",
"no-results": "Нічога не знойдзена",
"report-issue": "Паведаміць аб праблеме",
"totals": "Вынікі",
"view-source": "Паказаць зыходны тэкст"
}
1 change: 1 addition & 0 deletions i18n/bn.json
Expand Up @@ -15,5 +15,6 @@
"optional": "ঐচ্ছিক",
"report-issue": "একটি সমস্যা প্রতিবেদন করুন",
"submit": "জমা দিন",
"totals": "মোট",
"view-source": "উৎস দেখুন"
}
1 change: 1 addition & 0 deletions i18n/br.json
Expand Up @@ -8,5 +8,6 @@
"help-translate": "Sikour da dreiñ",
"no-results": "N'eus bet kavet disoc'h ebet",
"report-issue": "Titourañ un draen",
"totals": "Holladoù",
"view-source": "Sellet ouzh tarzh an destenn"
}
1 change: 1 addition & 0 deletions i18n/bs.json
Expand Up @@ -15,5 +15,6 @@
"optional": "Neobavezno",
"report-issue": "Prijavi problem",
"submit": "Pošalji",
"totals": "Ukupno",
"view-source": "Pogledaj izvor"
}
1 change: 1 addition & 0 deletions i18n/ca.json
Expand Up @@ -6,5 +6,6 @@
"help-translate": "Ajudeu a traduir",
"no-results": "No s'han trobat resultats.",
"report-issue": "Informa d'un problema",
"totals": "Totals",
"view-source": "Mostra el codi"
}
1 change: 1 addition & 0 deletions i18n/ckb.json
Expand Up @@ -13,5 +13,6 @@
"optional": "دڵخوازانە",
"report-issue": "ڕاپۆرت دان لەسەر کێشەیەک",
"submit": "ناردن",
"totals": "سەرجەمەکان",
"view-source": "بینینی سەرچاوە"
}
1 change: 1 addition & 0 deletions i18n/cs.json
Expand Up @@ -14,5 +14,6 @@
"optional": "nepovinné",
"report-issue": "Nahlásit problém",
"submit": "Odeslat",
"totals": "Součty",
"view-source": "Zobrazit zdrojový kód"
}
1 change: 1 addition & 0 deletions i18n/da.json
Expand Up @@ -15,5 +15,6 @@
"optional": "valgfri",
"report-issue": "Rapporter et problem",
"submit": "Udfør",
"totals": "I alt",
"view-source": "Vis kildekode"
}
1 change: 1 addition & 0 deletions i18n/de.json
Expand Up @@ -15,5 +15,6 @@
"optional": "optional",
"report-issue": "Ein Problem melden",
"submit": "Absenden",
"totals": "Summen",
"view-source": "Quellcode ansehen"
}
1 change: 1 addition & 0 deletions i18n/diq.json
Expand Up @@ -7,5 +7,6 @@
"help-translate": "Destegê tadayışi",
"no-results": "Peyniye nêvêniyaya",
"report-issue": "Problemi rapor ke",
"totals": "Pêro piya",
"view-source": "Çımey bıvêne"
}
1 change: 1 addition & 0 deletions i18n/el.json
Expand Up @@ -8,5 +8,6 @@
"help-translate": "Βοηθήστε στη μετάφραση",
"no-results": "Δεν βρέθηκαν αποτελέσματα",
"report-issue": "Αναφέρετε ένα πρόβλημα",
"totals": "Σύνολα",
"view-source": "Προβολή κώδικα"
}

0 comments on commit 073ab39

Please sign in to comment.