Просмотр исходного кода

Add BIENNIALLY & TRIENNIALLY stats on TaskMonitor (#3721)

* Add BIENNIALLY & TRIENNIALLY stats on TaskMonitor

* Fixed Prettier on previous commit JS files.

* Amend. Applying prettier on JS and PHP files.
caos30 2 лет назад
Родитель
Сommit
98bc6cdb63
5 измененных файлов с 21 добавлено и 2 удалено
  1. 6 0
      bin/v-export-rrd
  2. 2 0
      web/js/src/rrdCharts.js
  3. 1 1
      web/list/rrd/ajax.php
  4. 10 1
      web/list/rrd/index.php
  5. 2 0
      web/templates/pages/list_rrd.php

+ 6 - 0
bin/v-export-rrd

@@ -132,6 +132,12 @@ elif [ "$timespan" = "monthly" ]; then
 elif [ "$timespan" = "yearly" ]; then
 	start=$(date -d "1 year ago" +%s)
 	step=172800
+elif [ "$timespan" = "biennially" ]; then
+        start=$(date -d "2 year ago" +%s)
+        step=345600
+elif [ "$timespan" = "triennially" ]; then
+        start=$(date -d "3 year ago" +%s)
+        step=518400
 else
 	start=$(date -d "1 day ago" +%s)
 	# every 5min

+ 2 - 0
web/js/src/rrdCharts.js

@@ -61,6 +61,8 @@ function formatLabel(date, period) {
 		weekly: { weekday: 'short', day: 'numeric' },
 		monthly: { month: 'short', day: 'numeric' },
 		yearly: { month: 'long' },
+		biennially: { month: 'long', year: 'numeric' },
+		triennially: { month: 'long', year: 'numeric' },
 	};
 
 	return date.toLocaleString([], options[period]);

+ 1 - 1
web/list/rrd/ajax.php

@@ -11,7 +11,7 @@ if ($_SESSION["userContext"] != "admin") {
 
 $requestPayload = json_decode(file_get_contents("php://input"), true);
 
-$allowedPeriods = ["daily", "weekly", "monthly", "yearly"];
+$allowedPeriods = ["daily", "weekly", "monthly", "yearly", "biennially", "triennially"];
 
 if (!empty($requestPayload["period"]) && in_array($requestPayload["period"], $allowedPeriods)) {
 	$period = $requestPayload["period"];

+ 10 - 1
web/list/rrd/index.php

@@ -27,7 +27,16 @@ if (empty($_GET["period"])) {
 */
 if (empty($_GET["period"])) {
 	$period = "daily";
-} elseif (!in_array($_GET["period"], ["daily", "weekly", "monthly", "yearly"])) {
+} elseif (
+	!in_array($_GET["period"], [
+		"daily",
+		"weekly",
+		"monthly",
+		"yearly",
+		"biennially",
+		"triennially",
+	])
+) {
 	$period = "daily";
 } else {
 	$period = $_GET["period"];

+ 2 - 0
web/templates/pages/list_rrd.php

@@ -14,6 +14,8 @@
 			<a class="toolbar-link<?php if ((!empty($period)) && ($period == 'weekly')) echo " selected" ?>" href="?period=weekly"><?= _("Weekly") ?></a>
 			<a class="toolbar-link<?php if ((!empty($period)) && ($period == 'monthly')) echo " selected" ?>" href="?period=monthly"><?= _("Monthly") ?></a>
 			<a class="toolbar-link<?php if ((!empty($period)) && ($period == 'yearly')) echo " selected" ?>" href="?period=yearly"><?= _("Yearly") ?></a>
+                        <a class="toolbar-link<?php if ((!empty($period)) && ($period == 'biennially')) echo " selected" ?>" href="?period=biennially"><?= _("Biennially") ?></a>
+                        <a class="toolbar-link<?php if ((!empty($period)) && ($period == 'triennially')) echo " selected" ?>" href="?period=triennially"><?= _("Trienially") ?></a>
 		</div>
 	</div>
 </div>