Skip to content

Commit

Permalink
Merge 3.0.x (#53)
Browse files Browse the repository at this point in the history
* PHPCSFixer

* Add column in table of most viewed objects of a series (#49)

* TTK-26553: Wrap statistics table text (#50)

* Add services definition:

* TTK-26998: Shown OM stats (#51)

* Bugfix stats bundle (#52)

* TTK-26552: Correct operation of cleaning filters and restarting the pager

* TTK-26552: Reload to base url

* Remove .idea folder

* Update composer requirements

---------

Co-authored-by: albacodina <[email protected]>
  • Loading branch information
Yurujai and albacodina authored Oct 17, 2024
1 parent 8755cb5 commit 31202e1
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 40 deletions.
1 change: 1 addition & 0 deletions Controller/StatsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

/**
* @Route("/admin/stats")
*
* @Security("is_granted('ROLE_ACCESS_STATS')")
*/
class StatsController extends AbstractController
Expand Down
5 changes: 5 additions & 0 deletions DependencyInjection/PumukitStatsUIExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace Pumukit\StatsUIBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

class PumukitStatsUIExtension extends Extension
Expand All @@ -14,6 +16,9 @@ public function load(array $configs, ContainerBuilder $container): void
$configuration = new Configuration();
$this->processConfiguration($configuration, $configs);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('pumukit_stats_ui.yaml');

$permissions = [['role' => 'ROLE_ACCESS_STATS', 'description' => 'Access Stats']];
$newPermissions = array_merge($container->getParameter('pumukitschema.external_permissions'), $permissions);
$container->setParameter('pumukitschema.external_permissions', $newPermissions);
Expand Down
11 changes: 11 additions & 0 deletions Resources/config/pumukit_stats_ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: true


Pumukit\StatsUIBundle\Controller\:
resource: '../../Controller'
tags: [ 'controller.service_arguments' ]

4 changes: 4 additions & 0 deletions Resources/public/css/statsui.css
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@
box-shadow:0 3px 10px rgba(0,0,0,.23), 0 3px 10px rgba(0,0,0,.16);
}

.block-preview table th, .block-preview table tr {
word-break: break-all;
}

.btn-stats-search {
padding: 8px 10px;
}
Expand Down
4 changes: 2 additions & 2 deletions Resources/views/MostViewed/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
{{ title }}
</h2>
</div>
<div class="col-md-6">
<div class="col-sm-6 col-md-6">
{% include "@PumukitStatsUI/MostViewed/list.html.twig" %}
</div>
<div class="col-md-6">
<div class="col-sm-6 col-md-6">
<div id="chart-most-viewed">
<svg style="height: 400px;"></svg>
</div>
Expand Down
72 changes: 35 additions & 37 deletions Resources/views/Stats/js.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,17 @@
$('.btn-stats-calendar-remove').on('click', function(event){
event.preventDefault();
$('#form_daterangepicker').val(moment().startOf('year').format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
window.initializeAjaxRequest();
window.location = window.location.href.split("?")[0];
});
$('.btn-stats-search-remove').on('click', function(event){
event.preventDefault();
$('#title').val('');
var data = window.prepareSearch();
window.getAjaxRequest(data);
window.location = window.location.href.split("?")[0];
});
$('.btn-reset-filter').on('click',function(event) {
event.preventDefault();
$('#title').val('');
$('#form_daterangepicker').val(moment().startOf('year').format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
window.initializeAjaxRequest();
window.location = window.location.href.split("?")[0];
});
$('.ripple-wrapper').on('click', function(event) {
Expand Down Expand Up @@ -172,25 +167,25 @@
window.initializeAjaxRequest = function() {
{% if app.request.get('_route') == 'pumukit_stats_series_index' %}
window.most_viewed_series(null,null,page);
window.views(null, null,null,page, 'month');
window.most_viewed_series(null,null,null,0);
window.views(null, null,null,0, 'month');
{% endif %}
{% if app.request.get('_route') == 'pumukit_stats_mmobj_index' %}
window.most_viewed_mmobj(null,null,page);
window.views(null,null,null,page, 'month');
window.most_viewed_mmobj(null,null,null, 0);
window.views(null,null,null,0,'month');
{% endif %}
{% if app.request.get('_route') == 'pumukit_stats_series_index_id' %}
var series = "{{ app.request.attributes.get('_route_params')['id'] }}";
window.most_viewed_series_by_id(series,null, null, null, page);
window.views_series(series,null, null,null, page, 'month');
window.most_viewed_series_by_id(series,null, null, null, 0);
window.views_series(series,null, null,null, 0, 'month');
{% endif %}
{% if app.request.get('_route') == 'pumukit_stats_mmobj_index_id' %}
var mmobj = "{{ app.request.attributes.get('_route_params')['id'] }}";
window.most_viewed_mmobj_by_id(mmobj, null, null, null, page);
window.views_mmobj(mmobj,null, null, null, page, 'month');
window.most_viewed_mmobj_by_id(mmobj, null, null, null, 0);
window.views_mmobj(mmobj,null, null, null, 0, 'month');
{% endif %}
};
Expand Down Expand Up @@ -333,7 +328,7 @@
var data = window.defaultAjaxValues();
from_date = data['from_date'];
to_date = data['to_date'];
page = data['page'];
page = (page == 0) ? page : data['page'];
}
var url = "{{ path('pumukit_stats_api_mmobjmostviewed') }}";
Expand Down Expand Up @@ -371,7 +366,7 @@
"</a>" +
"</td>" +
"<td headers='recording'>" + moment(data.mmobj.recordDate).format('YYYY-MM-DD HH:mm:ss') + "</td>" +
"<td headers='series'>" + data.mmobj.series.i18nTitle[locale] + "</td>" +
"<td headers='series'>" + data.mmobj.seriesTitle + "</td>" +
"<td headers='views'>" + data.num_viewed + "</td>" +
"</tr>"
);
Expand All @@ -384,7 +379,8 @@
"<tr>" +
"<td headers='ranking'>" + (page * 10 + i) + "</td>" +
"<td headers='title'></td>" +
"<td headers='videos'></td>" +
"<td headers='recording'></td>" +
"<td headers='series'></td>" +
"<td headers='views'></td>" +
"</tr>"
);
Expand All @@ -403,7 +399,7 @@
var data = window.defaultAjaxValues();
from_date = data['from_date'];
to_date = data['to_date'];
page = data['page'];
page = (page == 0) ? page : data['page'];
}
var url = "{{ path('pumukit_schema_api_multimediaobjects') }}";
Expand Down Expand Up @@ -437,16 +433,16 @@
"</td>" +
"<td headers='recording'>" + moment(mmobj.recordDate).format('YYYY-MM-DD HH:mm:ss') + "</td>" +
"<td headers='series'>" +
"<a href='" + url.replace('__ID__', mmobj.series.id) + "'>" +
mmobj.series.i18nTitle[locale] +
"<a href='" + url.replace('__ID__', mmobj.series.split('/').pop()) + "'>" +
mmobj.seriesTitle +
"</a>" +
"</td>" +
"<td headers='views' id='"+ id +"'>" + 0 + "</td>" +
"</tr>"
);
window.getInfoMmobj(id, from_date, to_date);
window.showMmobj(mmobj);
$('.title_of_most_viewed').html(mmobj.series.i18nTitle[locale]);
$('.title_of_most_viewed').html(mmobj.seriesTitle);
}
});
};
Expand All @@ -456,7 +452,7 @@
var data = window.defaultAjaxValues();
from_date = data['from_date'];
to_date = data['to_date'];
page = data['page'];
page = (page == 0) ? page : data['page'];
group_by = data['group_by'];
}
Expand All @@ -478,7 +474,7 @@
},
success: function(response) {
var objects = response.views;
var total = 1;
var total = 0;
$('.views-table-body').html('');
objects.forEach(function(data) {
total = total + data.numView;
Expand Down Expand Up @@ -526,7 +522,7 @@
},
success: function(response) {
var objects = response.views;
var total = 1;
var total = 0;
$('.views-table-body').html('');
objects.forEach(function(data) {
total = total + data.numView;
Expand All @@ -538,6 +534,7 @@
"</tr>"
);
});
$('.total-views-objects').html(total);
$('#foot-views').html(total);
Expand All @@ -552,13 +549,14 @@
var data = window.defaultAjaxValues();
from_date = data['from_date'];
to_date = data['to_date'];
page = data['page'];
page = (page == 0) ? page : data['page'];
}
var url = "{{ path('pumukit_stats_api_mmobjmostviewed') }}";
if(criteria != null && criteria !== '') {
url = url + "?criteria[$text][$search]=" + criteria;
}
$.ajax({
url: url,
type: 'GET',
Expand Down Expand Up @@ -586,8 +584,8 @@
"</td>" +
"<td headers='recording'>" + moment(data.mmobj.recordDate).format('YYYY-MM-DD HH:mm:ss') + "</td>" +
"<td headers='series'>" +
"<a href='" + url.replace('__ID__', data.mmobj.series.id) + "'>" +
data.mmobj.series.i18nTitle[locale] +
"<a href='" + url.replace('__ID__', data.mmobj.series.split('/').pop()) + "'>" +
data.mmobj.seriesTitle +
"</a>" +
"</td>" +
"<td headers='views'>" + data.num_viewed + "</td>" +
Expand Down Expand Up @@ -622,7 +620,7 @@
var data = window.defaultAjaxValues();
from_date = data['from_date'];
to_date = data['to_date'];
page = data['page'];
page = (page == 0) ? page : data['page'];
group_by = data['group_by'];
}
Expand Down Expand Up @@ -729,13 +727,13 @@
var range;
if (num > 6){
if (page > 3 && page < num-3){
range = [1,'...',page-1,page,page+1,'...',num];
range = [0,'...',page-1,page,page+1,'...',num-1];
}else if (page <= 3){
range = [1,2,3,4,'...',num];
}else if (page >= num-2){
range = [1,'...',num-3,num-2,num-1,num];
range = [0,1,2,3,4,'...',num-1];
}else if (page >= num-3){
range = [0,'...',num-3,num-2,num-1];
} else {
range = [1,'...',page,'...',num];
range = [0,'...',page,'...',num-1];
}
}else{
range = Array.apply(null,Array(num)).map(function (x, i) { return i; });
Expand All @@ -748,7 +746,7 @@
window.createPager = function(data) {
var pages = Math.ceil(data.total / 10);
var active_page = parseInt("{{ app.request.get('page')|default(0) }}");
var active_page = data.page == 0 ? data.page : parseInt("{{ app.request.get('page')|default(0) }}");
var aPages = range(pages,active_page);
var disabled_previous = '';
var disabled_next = '';
Expand All @@ -774,7 +772,7 @@
htmlPage = "<li><a class='change_page' data-value='" + element + "'>" + (element +1 )+ "</a></li>";
}
} else {
htmlPage = "<li><a>" + (element +1 ) + "</a></li>";
htmlPage = "<li><a>" + element + "</a></li>";
}
html = html + htmlPage;
});
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"teltek"
],
"require": {
"php": ">=7.2",
"php": "^8.2",
"pumukit/pumukit": "^4.0"
},
"homepage": "https://github.com/teltek/PumukitStatsUIBundle",
Expand Down

0 comments on commit 31202e1

Please sign in to comment.