repartition.phtml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. declare(strict_types=1);
  3. /** @var FreshRSS_ViewStats $this */
  4. $this->partial('aside_subscription');
  5. $feedname = _t('admin.stats.all_feeds');
  6. ?>
  7. <nav class="nav_menu">
  8. <a class="btn toggle_aside" href="#aside_feed"><?= _i('category') ?></a>
  9. <select id="feed_select" class="select-change">
  10. <option data-url="<?= _url('stats', 'repartition') ?>"><?= _t('admin.stats.all_feeds') ?></option>
  11. <?php foreach ($this->categories as $category) {
  12. $feeds = $category->feeds();
  13. if (!empty($feeds)) {
  14. echo '<optgroup label="', $category->name(), '">';
  15. foreach ($feeds as $feed) {
  16. if ($this->feed !== null && $feed->id() == $this->feed->id()) {
  17. echo '<option value="', $feed->id(), '" selected="selected" data-url="',
  18. _url('stats', 'repartition', 'id', $feed->id()), '">', $feed->name(), '</option>';
  19. $feedname = $feed->name();
  20. } else {
  21. echo '<option value="', $feed->id(), '" data-url="',
  22. _url('stats', 'repartition', 'id', $feed->id()), '">', $feed->name(), '</option>';
  23. }
  24. }
  25. echo '</optgroup>';
  26. }
  27. }?>
  28. </select>
  29. <?php if ($this->feed !== null) {?>
  30. <a class="btn" href="<?= _url('subscription', 'feed', 'id', $this->feed->id()) ?>">
  31. <?= _i('configure') ?> <?= _t('gen.action.manage') ?>
  32. </a>
  33. <?php }?>
  34. </nav>
  35. <main class="post">
  36. <h1><?= _t('admin.stats.repartition', $feedname) ?></h1>
  37. <div class="box double-width">
  38. <div class="box-title"><h2><?= _t('admin.stats.overview') ?></h2></div>
  39. <div class="box-content scrollbar-thin">
  40. <table>
  41. <tr>
  42. <th><?= _t('admin.stats.status_total') ?></th>
  43. <th><?= _i('read') ?> <?= _t('admin.stats.status_read') ?></th>
  44. <th><?= _i('unread') ?> <?= _t('admin.stats.status_unread') ?></th>
  45. <th><?= _i('starred') ?> <?= _t('admin.stats.status_favorites') ?></th>
  46. </tr>
  47. <tr>
  48. <?php
  49. $feedID = $this->feed !== null ? $this->feed->id() : 0;
  50. if ($feedID === 0) { ?>
  51. <td class="numeric"><?= $this->repartition['total'] ?? -1 ?></td>
  52. <td class="numeric"><?= $this->repartition['count_reads'] ?? -1 ?></td>
  53. <td class="numeric"><?= $this->repartition['count_unreads'] ?? -1 ?></td>
  54. <td class="numeric"><a href="<?= _url('index', 'index', 'get', 's') ?>" title="<?= _t('gen.action.filter') ?>"><?= $this->repartition['count_favorites'] ?? -1 ?></a></td>
  55. <?php
  56. } else {
  57. ?>
  58. <td class="numeric"><a href="<?= _url('index', 'index', 'get', 'f_' . $feedID, 'state', FreshRSS_Entry::STATE_ALL) ?>" title="<?= _t('gen.action.filter') ?>"><?= $this->repartition['total'] ?? -1 ?></a></td>
  59. <td class="numeric"><a href="<?= _url('index', 'index', 'get', 'f_' . $feedID, 'state', FreshRSS_Entry::STATE_READ) ?>" title="<?= _t('gen.action.filter') ?>"><?= $this->repartition['count_reads'] ?? -1 ?></a></td>
  60. <td class="numeric"><a href="<?= _url('index', 'index', 'get', 'f_' . $feedID, 'state', FreshRSS_Entry::STATE_NOT_READ) ?>" title="<?= _t('gen.action.filter') ?>"><?= $this->repartition['count_unreads'] ?? -1 ?></a></td>
  61. <td class="numeric"><a href="<?= _url('index', 'index', 'get', 'f_' . $feedID, 'state', FreshRSS_Entry::STATE_FAVORITE) ?>" title="<?= _t('gen.action.filter') ?>"><?= $this->repartition['count_favorites'] ?? -1 ?></a></td>
  62. <?php } ?>
  63. </tr>
  64. </table>
  65. </div>
  66. </div>
  67. <div class="box double-width double-height">
  68. <div class="box-title"><h2><?= _t('admin.stats.entry_per_hour', $this->averageHour) ?></h2></div>
  69. <div class="box-content scrollbar-thin">
  70. <canvas id="statsEntriesPerHour"></canvas>
  71. <script class="jsonData-stats" type="application/json">
  72. <?php
  73. echo json_encode([
  74. 'canvasID' => 'statsEntriesPerHour',
  75. 'charttype' => 'bar',
  76. 'data' => $this->repartitionHour,
  77. 'label' => _t('admin.stats.entry_count'),
  78. 'xAxisLabels' => $this->hours24Labels
  79. ], JSON_UNESCAPED_UNICODE);
  80. ?></script>
  81. </div>
  82. </div>
  83. <br />
  84. <div class="box">
  85. <div class="box-title"><h2><?= _t('admin.stats.entry_per_day_of_week', $this->averageDayOfWeek) ?></h2></div>
  86. <div class="box-content scrollbar-thin">
  87. <canvas id="statsEntriesPerDayOfWeek"></canvas>
  88. <script class="jsonData-stats" type="application/json">
  89. <?php
  90. echo json_encode([
  91. 'canvasID' => 'statsEntriesPerDayOfWeek',
  92. 'charttype' => 'bar',
  93. 'data' => $this->repartitionDayOfWeek,
  94. 'label' => _t('admin.stats.entry_count'),
  95. 'xAxisLabels' => $this->days,
  96. ], JSON_UNESCAPED_UNICODE);
  97. ?></script>
  98. </div>
  99. </div>
  100. <div class="box">
  101. <div class="box-title"><h2><?= _t('admin.stats.entry_per_month', $this->averageMonth) ?></h2></div>
  102. <div class="box-content scrollbar-thin">
  103. <canvas id="statsEntriesPerMonth"></canvas>
  104. <script class="jsonData-stats" type="application/json">
  105. <?php
  106. echo json_encode([
  107. 'canvasID' => 'statsEntriesPerMonth',
  108. 'charttype' => 'bar',
  109. 'data' => $this->repartitionMonth,
  110. 'label' => _t('admin.stats.entry_count'),
  111. 'xAxisLabels' => $this->months,
  112. ], JSON_UNESCAPED_UNICODE);
  113. ?></script>
  114. </div>
  115. </div>
  116. </main>
  117. <script src="../scripts/statsWithChartjs.js?<?= @filemtime(PUBLIC_PATH . '/scripts/statsWithChartjs.js') ?>"></script>