diff --git a/Resources/views/Stats/js.html.twig b/Resources/views/Stats/js.html.twig index a187a39..5f47638 100644 --- a/Resources/views/Stats/js.html.twig +++ b/Resources/views/Stats/js.html.twig @@ -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) { @@ -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 %} }; @@ -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') }}"; @@ -404,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') }}"; @@ -457,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']; } @@ -479,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; @@ -527,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; @@ -539,6 +534,7 @@ "" ); }); + $('.total-views-objects').html(total); $('#foot-views').html(total); @@ -553,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', @@ -623,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']; } @@ -749,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 = '';