aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <github@ainw.org> 2014-08-19 08:55:44 -0400
committerGravatar Alexis Degrugillier <github@ainw.org> 2014-08-19 08:55:44 -0400
commit393fce3e8aaef1b00ab34bf35b7e8b329a5e3dc5 (patch)
tree46569c0d93bc0c2cf53250278cb73facc7274fbe
parent5c2f3349fa4341533aad6294c896b32c4befd58f (diff)
Add a feed selector in repartition statistics.
Before we could choose the feed in the statistics only from the feed options in the main view. Now with the new drop-down list, it is possible to choose it from the statistics page. The rendering needs to be polished to be nicer.
-rw-r--r--app/Controllers/statsController.php2
-rw-r--r--app/views/stats/repartition.phtml39
-rw-r--r--p/scripts/main.js7
3 files changed, 36 insertions, 12 deletions
diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php
index 06a20c2a6..934b076a5 100644
--- a/app/Controllers/statsController.php
+++ b/app/Controllers/statsController.php
@@ -58,9 +58,11 @@ class FreshRSS_stats_Controller extends Minz_ActionController {
public function repartitionAction() {
$statsDAO = FreshRSS_Factory::createStatsDAO();
+ $categoryDAO = new FreshRSS_CategoryDAO();
$feedDAO = FreshRSS_Factory::createFeedDao();
Minz_View::appendScript(Minz_Url::display('/scripts/flotr2.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/flotr2.min.js')));
$id = Minz_Request::param ('id', null);
+ $this->view->categories = $categoryDAO->listCategories ();
$this->view->feed = $feedDAO->searchById($id);
$this->view->days = $statsDAO->getDays();
$this->view->months = $statsDAO->getMonths();
diff --git a/app/views/stats/repartition.phtml b/app/views/stats/repartition.phtml
index 09892d3c5..3dc319731 100644
--- a/app/views/stats/repartition.phtml
+++ b/app/views/stats/repartition.phtml
@@ -2,23 +2,38 @@
<div class="post content">
<a href="<?php echo _url('index', 'index'); ?>"><?php echo _t('back_to_rss_feeds'); ?></a>
-
+
+ <h1><?php echo _t('stats_repartition'); ?></h1>
+
+ <select id="feed_select">
+ <option data-url="<?php echo _url ('stats', 'repartition')?>"></option>
+ <?php foreach ($this->categories as $category) {
+ $feeds = $category->feeds ();
+ if (!empty ($feeds)) {
+ echo '<optgroup label=', $category->name(), '>';
+ foreach ($feeds as $feed) {
+ if ($this->feed && $feed->id() == $this->feed->id()){
+ echo '<option value ="', $feed->id(), '" selected data-url="', _url ('stats', 'repartition', 'id', $feed->id()), '">', $feed->name(), '</option>';
+ } else {
+ echo '<option value ="', $feed->id(), '" data-url="', _url ('stats', 'repartition', 'id', $feed->id()), '">', $feed->name(), '</option>';
+ }
+ }
+ echo '</optgroup>';
+ }
+ }?>
+ </select>
+
<?php if ($this->feed) {?>
- <h1>
- <?php echo _t('stats_repartition'), " - "; ?>
- <a href="<?php echo _url('configure', 'feed', 'id', $this->feed->id()); ?>">
- <?php echo $this->feed->name(); ?>
- </a>
- </h1>
- <?php } else {?>
- <h1><?php echo _t('stats_repartition'); ?></h1>
+ <a href="<?php echo _url('configure', 'feed', 'id', $this->feed->id()); ?>">
+ <?php echo _t('administration'); ?>
+ </a>
<?php }?>
-
+
<div class="stat">
<h2><?php echo _t('stats_entry_per_hour'); ?></h2>
<div id="statsEntryPerHour" style="height: 300px"></div>
</div>
-
+
<div class="stat">
<h2><?php echo _t('stats_entry_per_day_of_week'); ?></h2>
<div id="statsEntryPerDayOfWeek" style="height: 300px"></div>
@@ -93,7 +108,7 @@ function initStats() {
yaxis: {min: 0},
mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
});
-
+
}
initStats();
</script>
diff --git a/p/scripts/main.js b/p/scripts/main.js
index ae7b69364..4802e0941 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -1063,6 +1063,12 @@ function init_share_observers() {
});
}
+function init_stats_observers() {
+ $('#feed_select').on('change', function(e) {
+ redirect($(this).find(':selected').data('url'));
+ });
+}
+
function init_remove_observers() {
$('.post').on('click', 'a.remove', function(e) {
var remove_what = $(this).attr('data-remove');
@@ -1177,6 +1183,7 @@ function init_all() {
init_remove_observers();
init_feed_observers();
init_password_observers();
+ init_stats_observers();
}
if (window.console) {