From b87930137acf88936fb541f53ab4dab1697e4d03 Mon Sep 17 00:00:00 2001
From: Udo Walter
Date: Mon, 28 Nov 2016 18:27:32 +0100
Subject: new ui
---
.../templates/columnChooser.html | 47 ++++++++++++++++++++++
1 file changed, 47 insertions(+)
create mode 100644 modules-available/statistics_reporting/templates/columnChooser.html
(limited to 'modules-available/statistics_reporting/templates/columnChooser.html')
diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html
new file mode 100644
index 00000000..62e20a4a
--- /dev/null
+++ b/modules-available/statistics_reporting/templates/columnChooser.html
@@ -0,0 +1,47 @@
+
@@ -24,23 +24,38 @@
\ No newline at end of file
--
cgit v1.2.3-55-g7522
From f616a8cc375c2228def671800be40fac2072b27b Mon Sep 17 00:00:00 2001
From: Udo Walter
Date: Tue, 20 Dec 2016 14:49:17 +0100
Subject: [statistics_reporting] added time bounds slider
---
modules-available/statistics_reporting/config.json | 2 +-
.../inc/statisticreporting.inc.php | 119 +++++++++++++++++----
.../lang/de/template-tags.json | 3 +-
.../lang/en/template-tags.json | 7 +-
modules-available/statistics_reporting/style.css | 24 ++++-
.../templates/columnChooser.html | 52 ++++++++-
6 files changed, 175 insertions(+), 32 deletions(-)
(limited to 'modules-available/statistics_reporting/templates/columnChooser.html')
diff --git a/modules-available/statistics_reporting/config.json b/modules-available/statistics_reporting/config.json
index 8115acf2..1a9c7fe7 100644
--- a/modules-available/statistics_reporting/config.json
+++ b/modules-available/statistics_reporting/config.json
@@ -1,4 +1,4 @@
{
"category": "main.content",
- "dependencies": [ "js_stupidtable"]
+ "dependencies": [ "js_stupidtable", "js_jqueryui" ]
}
diff --git a/modules-available/statistics_reporting/inc/statisticreporting.inc.php b/modules-available/statistics_reporting/inc/statisticreporting.inc.php
index 69a4d516..7652bbdc 100644
--- a/modules-available/statistics_reporting/inc/statisticreporting.inc.php
+++ b/modules-available/statistics_reporting/inc/statisticreporting.inc.php
@@ -7,14 +7,16 @@ class StatisticReporting
public static function getClientStatistics($cutOffTimeInSeconds, $lowerTimeBound = 0, $upperTimeBound = 24) {
$queryTime = time() - $cutOffTimeInSeconds;
$res = Database::simpleQuery("SELECT t1.name, timeSum, avgTime, offlineSum, loginCount, lastLogout, lastStart FROM (
- SELECT machine.hostname AS 'name', machine.machineuuid AS 'uuid', SUM(CAST(statistic.data AS UNSIGNED)) AS 'timeSum', AVG(CAST(statistic.data AS UNSIGNED)) AS 'avgTime', COUNT(*) AS 'loginCount', MAX(statistic.dateline + (statistic.data *1)) AS 'lastLogout'
- FROM statistic INNER JOIN machine ON statistic.machineuuid = machine.machineuuid
- WHERE typeid = '~session-length' AND dateline>=$queryTime AND ((FROM_UNIXTIME(dateline+statistic.data, '%H')*1 >= $lowerTimeBound) AND (FROM_UNIXTIME(dateline, '%H')*1 < $upperTimeBound))
+ SELECT machine.hostname AS 'name', machine.machineuuid AS 'uuid', SUM(CAST(sessionTable.length AS UNSIGNED)) AS 'timeSum', AVG(CAST(sessionTable.length AS UNSIGNED)) AS 'avgTime', COUNT(*) AS 'loginCount', MAX(sessionTable.dateline + sessionTable.data) AS 'lastLogout'
+ FROM ".self::getBoundedTableQueryString('~session-length', $lowerTimeBound, $upperTimeBound)." sessionTable
+ INNER JOIN machine ON sessionTable.machineuuid = machine.machineuuid
+ WHERE sessionTable.dateline>=$queryTime
GROUP BY machine.machineuuid
) t1 INNER JOIN (
- SELECT machine.hostname AS 'name', machine.machineuuid AS 'uuid', SUM(CAST(statistic.data AS UNSIGNED)) AS 'offlineSum', MAX(statistic.dateline) AS 'lastStart'
- FROM statistic INNER JOIN machine ON statistic.machineuuid = machine.machineuuid
- WHERE typeid = '~offline-length' AND dateline>=$queryTime AND ((FROM_UNIXTIME(dateline+statistic.data, '%H')*1 >= $lowerTimeBound) AND (FROM_UNIXTIME(dateline, '%H')*1 < $upperTimeBound))
+ SELECT machine.hostname AS 'name', machine.machineuuid AS 'uuid', SUM(CAST(offlineTable.length AS UNSIGNED)) AS 'offlineSum', MAX(offlineTable.dateline) AS 'lastStart'
+ FROM ".self::getBoundedTableQueryString('~offline-length', $lowerTimeBound, $upperTimeBound)." offlineTable
+ INNER JOIN machine ON offlineTable.machineuuid = machine.machineuuid
+ WHERE offlineTable.dateline>=$queryTime
GROUP BY machine.machineuuid
) t2 ON t1.uuid = t2.uuid");
return $res;
@@ -22,17 +24,20 @@ class StatisticReporting
public static function getLocationStatistics($cutOffTimeInSeconds, $lowerTimeBound = 0, $upperTimeBound = 24) {
$queryTime = time() - $cutOffTimeInSeconds;
+
$res = Database::simpleQuery("SELECT t1.locName, timeSum, avgTime, offlineSum, loginCount FROM (
- SELECT location.locationname AS 'locName', SUM(CAST(statistic.data AS UNSIGNED)) AS 'timeSum', AVG(CAST(statistic.data AS UNSIGNED)) AS 'avgTime', COUNT(*) AS 'loginCount'
- FROM statistic INNER JOIN machine ON statistic.machineuuid = machine.machineuuid
- INNER JOIN location ON machine.locationid = location.locationid
- WHERE statistic.typeid = '~session-length' AND dateline>=$queryTime AND ((FROM_UNIXTIME(dateline+statistic.data, '%H')*1 >= $lowerTimeBound) AND (FROM_UNIXTIME(dateline, '%H')*1 < $upperTimeBound))
+ SELECT location.locationname AS 'locName', SUM(CAST(sessionTable.length AS UNSIGNED)) AS 'timeSum', AVG(CAST(sessionTable.length AS UNSIGNED)) AS 'avgTime', COUNT(sessionTable.length) AS 'loginCount'
+ FROM ".self::getBoundedTableQueryString('~session-length', $lowerTimeBound, $upperTimeBound)." sessionTable
+ INNER JOIN machine ON sessionTable.machineuuid = machine.machineuuid
+ INNER JOIN location ON machine.locationid = location.locationid
+ WHERE sessionTable.dateline >= $queryTime
GROUP By location.locationname
) t1 INNER JOIN (
- SELECT location.locationname AS 'locName', SUM(CAST(statistic.data AS UNSIGNED)) AS 'offlineSum'
- FROM statistic INNER JOIN machine ON statistic.machineuuid = machine.machineuuid
- INNER JOIN location ON machine.locationid = location.locationid
- WHERE statistic.typeid = '~offline-length' AND dateline>=$queryTime AND ((FROM_UNIXTIME(dateline+statistic.data, '%H')*1 >= $lowerTimeBound) AND (FROM_UNIXTIME(dateline, '%H')*1 < $upperTimeBound))
+ SELECT location.locationname AS 'locName', SUM(CAST(offlineTable.length AS UNSIGNED)) AS 'offlineSum'
+ FROM ".self::getBoundedTableQueryString('~offline-length', $lowerTimeBound, $upperTimeBound)." offlineTable
+ INNER JOIN machine ON offlineTable.machineuuid = machine.machineuuid
+ INNER JOIN location ON machine.locationid = location.locationid
+ WHERE offlineTable.dateline >= $queryTime
GROUP By location.locationname
) t2 ON t1.locName = t2.locName");
return $res;
@@ -57,18 +62,17 @@ class StatisticReporting
// AND(betweenBounds OR
upper but begins in bound )
public static function getOverallStatistics ($cutOffTimeInSeconds, $lowerTimeBound = 0, $upperTimeBound = 24) {
$queryTime = time() - $cutOffTimeInSeconds;
- $res = Database::simpleQuery("SELECT SUM(CAST(data AS UNSIGNED)), AVG(CAST(data AS UNSIGNED)), COUNT(*) FROM statistic WHERE typeid = '~session-length' AND dateline>=$queryTime
- AND (((FROM_UNIXTIME(dateline+data, '%H')*1 >= $lowerTimeBound) AND (FROM_UNIXTIME(dateline, '%H')*1 < $upperTimeBound))
- )
-
- ");
+ $res = Database::simpleQuery("SELECT SUM(CAST(sessionTable.length AS UNSIGNED)), AVG(CAST(sessionTable.length AS UNSIGNED)), COUNT(*)
+ FROM ".self::getBoundedTableQueryString('~session-length', $lowerTimeBound, $upperTimeBound)." sessionTable
+ WHERE sessionTable.dateline>=$queryTime");
return $res;
}
public static function getTotalOfflineStatistics($cutOffTimeInSeconds, $lowerTimeBound = 0, $upperTimeBound = 24) {
$queryTime = time() - $cutOffTimeInSeconds;
- $res = Database::simpleQuery("SELECT SUM(CAST(data AS UNSIGNED)) FROM statistic WHERE typeid='~offline-length' AND dateline>=$queryTime
- AND ((FROM_UNIXTIME(dateline+data, '%H')*1 >= $lowerTimeBound) AND (FROM_UNIXTIME(dateline, '%H')*1 < $upperTimeBound))");
+ $res = Database::simpleQuery("SELECT SUM(CAST(offlineTable.length AS UNSIGNED))
+ FROM ".self::getBoundedTableQueryString('~offline-length', $lowerTimeBound, $upperTimeBound)." offlineTable
+ WHERE offlineTable.dateline>=$queryTime");
return $res;
}
@@ -77,4 +81,75 @@ class StatisticReporting
return intdiv($seconds, 3600*24).'d '.intdiv($seconds%(3600*24), 3600).'h '.intdiv($seconds%3600, 60).'m '.($seconds%60).'s';
}
-}
\ No newline at end of file
+
+ private static function getBoundedTableQueryString($typeid, $lowerTimeBound, $upperTimeBound)
+ {
+ $lowerFormat = "'%y-%m-%d $lowerTimeBound:00:00'";
+ $upperFormat = "'%y-%m-%d ".($upperTimeBound-1).":59:59'";
+ $queryString = "
+ select
+
+ @startLower := UNIX_TIMESTAMP(FROM_UNIXTIME(dateline, $lowerFormat)),
+ @startUpper := UNIX_TIMESTAMP(FROM_UNIXTIME(dateline, $upperFormat)),
+ @endLower := UNIX_TIMESTAMP(FROM_UNIXTIME(dateline+data, $lowerFormat)),
+ @endUpper := UNIX_TIMESTAMP(FROM_UNIXTIME(dateline+data, $upperFormat)),
+
+ (CAST(data AS SIGNED)
+ - IF(
+ dateline > @startUpper,
+ UNIX_TIMESTAMP(FROM_UNIXTIME(dateline, $lowerFormat) + INTERVAL 1 DAY) - dateline,
+ IF(
+ dateline < @startLower,
+ @startLower - dateline,
+ 0
+ )
+ )
+ - IF(
+ dateline+data > @endUpper,
+ dateline+data - (@endUpper + 1),
+ IF(
+ dateline+data < @endLower,
+ dateline+data - (UNIX_TIMESTAMP(FROM_UNIXTIME(dateline+data, $upperFormat) - INTERVAL 1 DAY) + 1),
+ 0
+ )
+ )
+ - ( TO_DAYS(FROM_UNIXTIME(dateline+data, '%y-%m-%d')) - TO_DAYS(FROM_UNIXTIME(dateline, '%y-%m-%d'))
+ - 2
+ + IF(dateline <= @startUpper, 1, 0)
+ + IF(dateline+data >= @endLower, 1, 0)
+ ) * ((24 - ($upperTimeBound - $lowerTimeBound)) * 3600)
+
+ - IF(
+ @leftBound := IF(dateline <= @startUpper, @startUpper, UNIX_TIMESTAMP(FROM_UNIXTIME(dateline, $upperFormat) + INTERVAL 1 DAY))
+ < @rightBound := IF(dateline+data >= @endLower, @endLower, UNIX_TIMESTAMP(FROM_UNIXTIME(dateline+data, $lowerFormat) - INTERVAL 1 DAY)),
+ IF(
+ @timeDiff := (
+ (date_format(from_unixtime(@leftBound), '%H') -
+ date_format(convert_tz(from_unixtime(@leftBound), @@session.time_zone, '+00:00'), '%H') + 24) % 24
+ -
+ (date_format(from_unixtime(@rightBound), '%H') -
+ date_format(convert_tz(from_unixtime(@rightBound), @@session.time_zone, '+00:00'), '%H') + 24) % 24) = 1
+ AND ($lowerTimeBound >= 2 OR $upperTimeBound <= 2),
+ 3600,
+ IF(@timeDiff = -1 AND ($lowerTimeBound >= 3 OR $upperTimeBound <= 3), -3600, 0)
+ ),
+ 0
+ )
+
+ ) as 'length',
+ dateline,
+ data,
+ machineuuid
+
+ from statistic
+ where typeid = '$typeid' and (
+ (UNIX_TIMESTAMP(FROM_UNIXTIME(dateline, $lowerFormat)) <= dateline and dateline <= UNIX_TIMESTAMP(FROM_UNIXTIME(dateline, $upperFormat))) or
+ (UNIX_TIMESTAMP(FROM_UNIXTIME(dateline+data, $lowerFormat)) <= dateline+data and dateline+data <= UNIX_TIMESTAMP(FROM_UNIXTIME(dateline+data, $upperFormat)))
+ )
+ ";
+ return "(".$queryString.")";
+ }
+
+
+}
+
diff --git a/modules-available/statistics_reporting/lang/de/template-tags.json b/modules-available/statistics_reporting/lang/de/template-tags.json
index 521b0607..f2500db0 100644
--- a/modules-available/statistics_reporting/lang/de/template-tags.json
+++ b/modules-available/statistics_reporting/lang/de/template-tags.json
@@ -24,5 +24,6 @@
"lang_last7": "Letzten 7 Tage",
"lang_last14": "Letzten 14 Tage",
"lang_last30": "Letzten 30 Tage",
- "lang_last90": "Letzten 90 Tage"
+ "lang_last90": "Letzten 90 Tage",
+ "lang_apply": "Anwenden"
}
\ No newline at end of file
diff --git a/modules-available/statistics_reporting/lang/en/template-tags.json b/modules-available/statistics_reporting/lang/en/template-tags.json
index c3900e31..8fa97719 100644
--- a/modules-available/statistics_reporting/lang/en/template-tags.json
+++ b/modules-available/statistics_reporting/lang/en/template-tags.json
@@ -5,7 +5,7 @@
"lang_vm": "VM",
"lang_totalLogins": "Total Logins",
"lang_overallOfftime": "Overall time offline",
- "lang_totalOffTime": "Total time offline",
+ "lang_totalOffTime": "Total Time Offline",
"lang_clientLogout": "Last VM Logout",
"lang_clientStart": "Last Client Boot",
"lang_room": "Room",
@@ -18,11 +18,12 @@
"lang_hostname": "Client Name",
"lang_location": "Location",
"lang_avgSessionLength": "Average Session Length",
- "lang_totalTime": "Gesamte Zeit",
+ "lang_totalTime": "Total Time",
"lang_last1": "Last 24 hours",
"lang_last2": "Last 48 hours",
"lang_last7": "Last 7 days",
"lang_last14": "Last 14 days",
"lang_last30": "Last 30 days",
- "lang_last90": "Last 90 days"
+ "lang_last90": "Last 90 days",
+ "lang_apply": "Apply"
}
\ No newline at end of file
diff --git a/modules-available/statistics_reporting/style.css b/modules-available/statistics_reporting/style.css
index b0875a7d..d7fa7a2f 100644
--- a/modules-available/statistics_reporting/style.css
+++ b/modules-available/statistics_reporting/style.css
@@ -2,7 +2,7 @@
margin-bottom: 10px;
}
-.top-row select, .top-row .btn-group {
+.top-row > * {
margin-right: 10px;
margin-bottom: 10px;
}
@@ -13,4 +13,26 @@
.buttonbar {
margin-bottom: 20px;
+}
+
+#slider {
+ display: inline-block;
+ width: 160px;
+ margin-left: 20px;
+ margin-bottom: 3px;
+ margin-right: 20px;
+}
+
+#lower-handle, #upper-handle {
+ width: 3em;
+ height: 1.6em;
+ top: 50%;
+ margin-top: -.8em;
+ margin-left: -1.5em;
+ text-align: center;
+ line-height: 1.6em;
+}
+
+#applybound {
+ display: none;
}
\ No newline at end of file
diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html
index 9e6f51d2..319f9702 100644
--- a/modules-available/statistics_reporting/templates/columnChooser.html
+++ b/modules-available/statistics_reporting/templates/columnChooser.html
@@ -8,7 +8,7 @@
-
@@ -30,7 +36,30 @@
\ No newline at end of file
--
cgit v1.2.3-55-g7522
From f74dfc9488cf4733b18a11b90307183bafbc01f8 Mon Sep 17 00:00:00 2001
From: Udo Walter
Date: Thu, 22 Dec 2016 13:59:12 +0100
Subject: [statistics_reporting] changed average to median
---
.../inc/statisticreporting.inc.php | 26 +++++++++++++++++-----
.../lang/de/template-tags.json | 2 +-
.../lang/en/template-tags.json | 2 +-
.../statistics_reporting/page.inc.php | 8 ++++---
.../statistics_reporting/templates/_page.html | 12 +++++-----
.../templates/columnChooser.html | 2 +-
6 files changed, 34 insertions(+), 18 deletions(-)
(limited to 'modules-available/statistics_reporting/templates/columnChooser.html')
diff --git a/modules-available/statistics_reporting/inc/statisticreporting.inc.php b/modules-available/statistics_reporting/inc/statisticreporting.inc.php
index 9212a09c..d98ec168 100644
--- a/modules-available/statistics_reporting/inc/statisticreporting.inc.php
+++ b/modules-available/statistics_reporting/inc/statisticreporting.inc.php
@@ -6,8 +6,8 @@ class StatisticReporting
public static function getClientStatistics($cutOffTimeInSeconds, $lowerTimeBound = 0, $upperTimeBound = 24) {
$queryTime = time() - $cutOffTimeInSeconds;
- $res = Database::simpleQuery("SELECT t1.name, timeSum, avgTime, offlineSum, loginCount, lastLogout, lastStart, shortSessions FROM (
- SELECT machine.hostname AS 'name', machine.machineuuid AS 'uuid', SUM(CAST(sessionTable.length AS UNSIGNED)) AS 'timeSum', AVG(CAST(sessionTable.length AS UNSIGNED)) AS 'avgTime', COUNT(*) AS 'loginCount', MAX(sessionTable.dateline + sessionTable.data) AS 'lastLogout'
+ $res = Database::simpleQuery("SELECT t1.name, timeSum, medianTime, offlineSum, loginCount, lastLogout, lastStart, shortSessions FROM (
+ SELECT machine.hostname AS 'name', machine.machineuuid AS 'uuid', SUM(CAST(sessionTable.length AS UNSIGNED)) AS 'timeSum', GROUP_CONCAT(sessionTable.length) AS 'medianTime', COUNT(*) AS 'loginCount', MAX(sessionTable.dateline + sessionTable.data) AS 'lastLogout'
FROM ".self::getBoundedTableQueryString('~session-length', $lowerTimeBound, $upperTimeBound)." sessionTable
INNER JOIN machine ON sessionTable.machineuuid = machine.machineuuid
WHERE sessionTable.dateline>=$queryTime AND sessionTable.data >= 60
@@ -37,8 +37,8 @@ class StatisticReporting
public static function getLocationStatistics($cutOffTimeInSeconds, $lowerTimeBound = 0, $upperTimeBound = 24) {
$queryTime = time() - $cutOffTimeInSeconds;
- $res = Database::simpleQuery("SELECT t1.locName, timeSum, avgTime, offlineSum, loginCount, shortSessions FROM (
- SELECT IFNULL(location.locationname, '') AS 'locName', SUM(CAST(sessionTable.length AS UNSIGNED)) AS 'timeSum', AVG(CAST(sessionTable.length AS UNSIGNED)) AS 'avgTime', COUNT(sessionTable.length) AS 'loginCount'
+ $res = Database::simpleQuery("SELECT t1.locName, timeSum, medianTime, offlineSum, loginCount, shortSessions FROM (
+ SELECT IFNULL(location.locationname, '') AS 'locName', SUM(CAST(sessionTable.length AS UNSIGNED)) AS 'timeSum', GROUP_CONCAT(sessionTable.length) AS 'medianTime', COUNT(sessionTable.length) AS 'loginCount'
FROM ".self::getBoundedTableQueryString('~session-length', $lowerTimeBound, $upperTimeBound)." sessionTable
INNER JOIN machine ON sessionTable.machineuuid = machine.machineuuid
LEFT JOIN location ON machine.locationid = location.locationid
@@ -87,8 +87,8 @@ class StatisticReporting
public static function getOverallStatistics ($cutOffTimeInSeconds, $lowerTimeBound = 0, $upperTimeBound = 24) {
$queryTime = time() - $cutOffTimeInSeconds;
- $res = Database::simpleQuery("SELECT sum, avg, countLong, countShort FROM
- ( SELECT SUM(CAST(sessionTable.length AS UNSIGNED)) AS sum, AVG(CAST(sessionTable.length AS UNSIGNED)) AS avg, COUNT(*) AS countLong
+ $res = Database::simpleQuery("SELECT sum, median, countLong, countShort FROM
+ ( SELECT SUM(CAST(sessionTable.length AS UNSIGNED)) AS sum, GROUP_CONCAT(sessionTable.length) AS median, COUNT(*) AS countLong
FROM ".self::getBoundedTableQueryString('~session-length', $lowerTimeBound, $upperTimeBound)." sessionTable
WHERE sessionTable.dateline>=$queryTime AND sessionTable.data >= 60
) t1
@@ -113,6 +113,20 @@ class StatisticReporting
return intdiv($seconds, 3600*24).'d '.intdiv($seconds%(3600*24), 3600).'h '.intdiv($seconds%3600, 60).'m '.($seconds%60).'s';
}
+ public static function calcMedian($string) {
+ $arr = explode(",", $string);
+ sort($arr, SORT_NUMERIC);
+ $count = count($arr); //total numbers in array
+ $middleval = floor(($count-1)/2); // find the middle value, or the lowest middle value
+ if($count % 2) { // odd number, middle is the median
+ $median = $arr[(int) $middleval];
+ } else { // even number, calculate avg of 2 medians
+ $low = $arr[(int) $middleval];
+ $high = $arr[(int) $middleval+1];
+ $median = (($low+$high)/2);
+ }
+ return round($median);
+ }
private static function getBoundedTableQueryString($typeid, $lowerTimeBound, $upperTimeBound)
{
diff --git a/modules-available/statistics_reporting/lang/de/template-tags.json b/modules-available/statistics_reporting/lang/de/template-tags.json
index f2500db0..c5494205 100644
--- a/modules-available/statistics_reporting/lang/de/template-tags.json
+++ b/modules-available/statistics_reporting/lang/de/template-tags.json
@@ -17,7 +17,7 @@
"lang_pervm": "Pro VM",
"lang_hostname": "Client Name",
"lang_location": "Raum",
- "lang_avgSessionLength": "Durchschnittliche Sitzungsdauer",
+ "lang_medianSessionLength": "Mittlere Sitzungsdauer",
"lang_totalTime": "Gesamte Zeit",
"lang_last1": "Letzten 24 Stunden",
"lang_last2": "Letzten 48 Stunden",
diff --git a/modules-available/statistics_reporting/lang/en/template-tags.json b/modules-available/statistics_reporting/lang/en/template-tags.json
index 8fa97719..de91621f 100644
--- a/modules-available/statistics_reporting/lang/en/template-tags.json
+++ b/modules-available/statistics_reporting/lang/en/template-tags.json
@@ -17,7 +17,7 @@
"lang_pervm": "Per VM",
"lang_hostname": "Client Name",
"lang_location": "Location",
- "lang_avgSessionLength": "Average Session Length",
+ "lang_medianSessionLength": "Median Session Length",
"lang_totalTime": "Total Time",
"lang_last1": "Last 24 hours",
"lang_last2": "Last 48 hours",
diff --git a/modules-available/statistics_reporting/page.inc.php b/modules-available/statistics_reporting/page.inc.php
index 9417d2da..0dd4f243 100644
--- a/modules-available/statistics_reporting/page.inc.php
+++ b/modules-available/statistics_reporting/page.inc.php
@@ -35,7 +35,7 @@ class Page_Statistics_Reporting extends Page
// total time online, average time online, total number of logins
$res = StatisticReporting::getOverallStatistics($cutOffTimer, $lowerTimeBound, $upperTimeBound);
$row = $res->fetch(PDO::FETCH_NUM);
- $data = array('time' => StatisticReporting::formatSeconds($row[0]), 'avgTime' => StatisticReporting::formatSeconds($row[1]), 'totalLogins' => $row[2]);
+ $data = array('time' => StatisticReporting::formatSeconds($row[0]), 'medianTime' => StatisticReporting::formatSeconds(StatisticReporting::calcMedian($row[1])), 'totalLogins' => $row[2]);
//total time offline
$res = StatisticReporting::getTotalOfflineStatistics($cutOffTimer, $lowerTimeBound, $upperTimeBound);
@@ -46,16 +46,18 @@ class Page_Statistics_Reporting extends Page
$res = StatisticReporting::getLocationStatistics($cutOffTimer, $lowerTimeBound, $upperTimeBound);
$data[] = array('perLocation' => array());
while ($row = $res->fetch(PDO::FETCH_NUM)) {
+ $median = StatisticReporting::calcMedian(StatisticReporting::calcMedian($row[2]));
$data['perLocation'][] = array('location' => $row[0], 'time' => StatisticReporting::formatSeconds($row[1]), 'timeInSeconds' => $row[1],
- 'avgTime' => StatisticReporting::formatSeconds($row[2]), 'avgTimeInSeconds' => $row[2], 'offTime' => StatisticReporting::formatSeconds($row[3]), 'offlineTimeInSeconds' => $row[3], 'loginCount' => $row[4]);
+ 'medianTime' => StatisticReporting::formatSeconds($median), 'medianTimeInSeconds' => $median, 'offTime' => StatisticReporting::formatSeconds($row[3]), 'offlineTimeInSeconds' => $row[3], 'loginCount' => $row[4]);
}
// per client
$res = StatisticReporting::getClientStatistics($cutOffTimer, $lowerTimeBound, $upperTimeBound);
$data[] = array('perClient' => array());
while ($row = $res->fetch(PDO::FETCH_NUM)) {
+ $median = StatisticReporting::calcMedian(StatisticReporting::calcMedian($row[2]));
$data['perClient'][] = array('hostname' => $row[0], 'time' => StatisticReporting::formatSeconds($row[1]), 'timeInSeconds' => $row[1],
- 'avgTime' => StatisticReporting::formatSeconds($row[2]), 'avgTimeInSeconds' => $row[2], 'offTime' => StatisticReporting::formatSeconds($row[3]), 'offlineTimeInSeconds' => $row[3], 'loginCount' => $row[4],
+ 'medianTime' => StatisticReporting::formatSeconds($median), 'medianTimeInSeconds' => $median, 'offTime' => StatisticReporting::formatSeconds($row[3]), 'offlineTimeInSeconds' => $row[3], 'loginCount' => $row[4],
'lastLogout' => date(DATE_RSS,$row[5]), 'lastLogoutUnixtime' => $row[5], 'lastStart' => date(DATE_RSS,$row[6]), 'lastStartUnixtime' => $row[6]);
}
diff --git a/modules-available/statistics_reporting/templates/_page.html b/modules-available/statistics_reporting/templates/_page.html
index 720fb37a..7cfb424c 100644
--- a/modules-available/statistics_reporting/templates/_page.html
+++ b/modules-available/statistics_reporting/templates/_page.html
@@ -6,7 +6,7 @@
|
{{lang_totalTime}} |
- {{lang_avgSessionLength}} |
+ {{lang_medianSessionLength}} |
{{lang_totalLogins}} |
{{lang_overallOfftime}} |
@@ -15,7 +15,7 @@
{{lang_total}} |
{{time}} |
- {{avgTime}} |
+ {{medianTime}} |
{{totalLogins}} |
{{totalOfftime}} |
@@ -30,7 +30,7 @@
{{lang_location}} |
{{lang_totalTime}} |
- {{lang_avgSessionLength}} |
+ {{lang_medianSessionLength}} |
{{lang_totalLogins}} |
{{lang_totalOffTime}} |
@@ -40,7 +40,7 @@
{{location}} |
{{time}} |
- {{avgTime}} |
+ {{medianTime}} |
{{loginCount}} |
{{offTime}} |
@@ -56,7 +56,7 @@
{{lang_hostname}} |
{{lang_totalTime}} |
- {{lang_avgSessionLength}} |
+ {{lang_medianSessionLength}} |
{{lang_totalLogins}} |
{{lang_totalOffTime}} |
{{lang_clientLogout}} |
@@ -68,7 +68,7 @@
{{hostname}} |
{{time}} |
- {{avgTime}} |
+ {{medianTime}} |
{{loginCount}} |
{{offTime}} |
{{lastLogout}} |
diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html
index 319f9702..d79f542b 100644
--- a/modules-available/statistics_reporting/templates/columnChooser.html
+++ b/modules-available/statistics_reporting/templates/columnChooser.html
@@ -25,7 +25,7 @@
-
+
--
cgit v1.2.3-55-g7522
From 3a2dae96362b1187ae4b9d89904d23b6a7da87cb Mon Sep 17 00:00:00 2001
From: Udo Walter
Date: Thu, 22 Dec 2016 15:08:36 +0100
Subject: [statistics_reporting] added short sessions to ui
---
.../lang/de/template-tags.json | 3 ++-
.../lang/en/template-tags.json | 3 ++-
.../statistics_reporting/page.inc.php | 10 ++++-----
.../statistics_reporting/templates/_page.html | 26 +++++++++++++---------
.../templates/columnChooser.html | 3 ++-
5 files changed, 27 insertions(+), 18 deletions(-)
(limited to 'modules-available/statistics_reporting/templates/columnChooser.html')
diff --git a/modules-available/statistics_reporting/lang/de/template-tags.json b/modules-available/statistics_reporting/lang/de/template-tags.json
index c5494205..68b68250 100644
--- a/modules-available/statistics_reporting/lang/de/template-tags.json
+++ b/modules-available/statistics_reporting/lang/de/template-tags.json
@@ -3,7 +3,8 @@
"lang_countLogins": "Anzahl Logins",
"lang_client": "Client",
"lang_vm": "VM",
- "lang_totalLogins": "Gesamt Logins",
+ "lang_sessions": "Sitzungen \u2265 60s",
+ "lang_shortSessions": "Sitzungen < 60s",
"lang_overallOfftime": "Insgesamte Zeit Offline",
"lang_totalOffTime": "Gesamtzeit Offline",
"lang_clientLogout": "Letzter VM Logout",
diff --git a/modules-available/statistics_reporting/lang/en/template-tags.json b/modules-available/statistics_reporting/lang/en/template-tags.json
index de91621f..b9e0c61d 100644
--- a/modules-available/statistics_reporting/lang/en/template-tags.json
+++ b/modules-available/statistics_reporting/lang/en/template-tags.json
@@ -3,7 +3,8 @@
"lang_countLogins": "Number of Logins",
"lang_client": "Client",
"lang_vm": "VM",
- "lang_totalLogins": "Total Logins",
+ "lang_sessions": "Sessions \u2265 60s",
+ "lang_shortSessions": "Sessions < 60s",
"lang_overallOfftime": "Overall time offline",
"lang_totalOffTime": "Total Time Offline",
"lang_clientLogout": "Last VM Logout",
diff --git a/modules-available/statistics_reporting/page.inc.php b/modules-available/statistics_reporting/page.inc.php
index de13cdb3..f0f56e87 100644
--- a/modules-available/statistics_reporting/page.inc.php
+++ b/modules-available/statistics_reporting/page.inc.php
@@ -35,7 +35,7 @@ class Page_Statistics_Reporting extends Page
// total time online, average time online, total number of logins
$res = StatisticReporting::getOverallStatistics($cutOffTimer, $lowerTimeBound, $upperTimeBound);
$row = $res->fetch(PDO::FETCH_NUM);
- $data = array('time' => StatisticReporting::formatSeconds($row[0]), 'medianTime' => StatisticReporting::formatSeconds(StatisticReporting::calcMedian($row[1])), 'totalLogins' => $row[2], 'shortSessions' => $row[3]);
+ $data = array('time' => StatisticReporting::formatSeconds($row[0]), 'medianTime' => StatisticReporting::formatSeconds(StatisticReporting::calcMedian($row[1])), 'sessions' => $row[2], 'shortSessions' => $row[3]);
//total time offline
$res = StatisticReporting::getTotalOfflineStatistics($cutOffTimer, $lowerTimeBound, $upperTimeBound);
@@ -48,7 +48,7 @@ class Page_Statistics_Reporting extends Page
while ($row = $res->fetch(PDO::FETCH_NUM)) {
$median = StatisticReporting::calcMedian(StatisticReporting::calcMedian($row[2]));
$data['perLocation'][] = array('location' => $row[0], 'time' => StatisticReporting::formatSeconds($row[1]), 'timeInSeconds' => $row[1],
- 'medianTime' => StatisticReporting::formatSeconds($median), 'medianTimeInSeconds' => $median, 'offTime' => StatisticReporting::formatSeconds($row[3]), 'offlineTimeInSeconds' => $row[3], 'loginCount' => $row[4], 'shortSessions' => $row[5]);
+ 'medianTime' => StatisticReporting::formatSeconds($median), 'medianTimeInSeconds' => $median, 'offTime' => StatisticReporting::formatSeconds($row[3]), 'offlineTimeInSeconds' => $row[3], 'sessions' => $row[4], 'shortSessions' => $row[5]);
}
// per client
@@ -57,7 +57,7 @@ class Page_Statistics_Reporting extends Page
while ($row = $res->fetch(PDO::FETCH_NUM)) {
$median = StatisticReporting::calcMedian(StatisticReporting::calcMedian($row[2]));
$data['perClient'][] = array('hostname' => $row[0], 'time' => StatisticReporting::formatSeconds($row[1]), 'timeInSeconds' => $row[1],
- 'medianTime' => StatisticReporting::formatSeconds($median), 'medianTimeInSeconds' => $median, 'offTime' => StatisticReporting::formatSeconds($row[3]), 'offlineTimeInSeconds' => $row[3], 'loginCount' => $row[4],
+ 'medianTime' => StatisticReporting::formatSeconds($median), 'medianTimeInSeconds' => $median, 'offTime' => StatisticReporting::formatSeconds($row[3]), 'offlineTimeInSeconds' => $row[3], 'sessions' => $row[4],
'lastLogout' => date(DATE_RSS,$row[5]), 'lastLogoutUnixtime' => $row[5], 'lastStart' => date(DATE_RSS,$row[6]), 'lastStartUnixtime' => $row[6], 'shortSessions' => $row[7]);
}
@@ -65,14 +65,14 @@ class Page_Statistics_Reporting extends Page
$res = StatisticReporting::getUserStatistics($cutOffTimer, $lowerTimeBound, $upperTimeBound);
$data[] = array('perUser' => array());
while ($row = $res->fetch(PDO::FETCH_NUM)) {
- $data['perUser'][] = array('user' => $row[0], 'loginCount' => $row[1]);
+ $data['perUser'][] = array('user' => $row[0], 'sessions' => $row[1]);
}
// per vm
$res = StatisticReporting::getVMStatistics($cutOffTimer, $lowerTimeBound, $upperTimeBound);
$data[] = array('perVM' => array());
while ($row = $res->fetch(PDO::FETCH_NUM)) {
- $data['perVM'][] = array('vm' => $row[0], 'loginCount' => $row[1]);
+ $data['perVM'][] = array('vm' => $row[0], 'sessions' => $row[1]);
}
Render::addTemplate('columnChooser');
diff --git a/modules-available/statistics_reporting/templates/_page.html b/modules-available/statistics_reporting/templates/_page.html
index 7cfb424c..d2aaecde 100644
--- a/modules-available/statistics_reporting/templates/_page.html
+++ b/modules-available/statistics_reporting/templates/_page.html
@@ -7,7 +7,8 @@
|
{{lang_totalTime}} |
{{lang_medianSessionLength}} |
- {{lang_totalLogins}} |
+ {{lang_sessions}} |
+ {{lang_shortSessions}} |
{{lang_overallOfftime}} |
@@ -16,7 +17,8 @@
{{lang_total}} |
{{time}} |
{{medianTime}} |
-
{{totalLogins}} |
+
{{sessions}} |
+
{{shortSessions}} |
{{totalOfftime}} |
@@ -31,7 +33,8 @@
{{lang_location}} |
{{lang_totalTime}} |
{{lang_medianSessionLength}} |
-
{{lang_totalLogins}} |
+
{{lang_sessions}} |
+
{{lang_shortSessions}} |
{{lang_totalOffTime}} |
@@ -41,7 +44,8 @@
{{location}} |
{{time}} |
{{medianTime}} |
-
{{loginCount}} |
+
{{sessions}} |
+
{{shortSessions}} |
{{offTime}} |
{{/perLocation}}
@@ -57,7 +61,8 @@
{{lang_hostname}} |
{{lang_totalTime}} |
{{lang_medianSessionLength}} |
-
{{lang_totalLogins}} |
+
{{lang_sessions}} |
+
{{lang_shortSessions}} |
{{lang_totalOffTime}} |
{{lang_clientLogout}} |
{{lang_clientStart}} |
@@ -69,7 +74,8 @@
{{hostname}} |
{{time}} |
{{medianTime}} |
-
{{loginCount}} |
+
{{sessions}} |
+
{{shortSessions}} |
{{offTime}} |
{{lastLogout}} |
{{lastStart}} |
@@ -85,14 +91,14 @@
{{lang_user}} |
- {{lang_totalLogins}} |
+ {{lang_sessions}} |
{{#perUser}}
{{user}} |
- {{loginCount}} |
+ {{sessions}} |
{{/perUser}}
@@ -105,14 +111,14 @@
{{lang_vm}} |
- {{lang_totalLogins}} |
+ {{lang_sessions}} |
{{#perVM}}
{{vm}} |
- {{loginCount}} |
+ {{sessions}} |
{{/perVM}}
diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html
index d79f542b..49c9a75d 100644
--- a/modules-available/statistics_reporting/templates/columnChooser.html
+++ b/modules-available/statistics_reporting/templates/columnChooser.html
@@ -26,7 +26,8 @@
-
+
+
--
cgit v1.2.3-55-g7522
From 8c9c28df0401f0bc89ab1cfc05332e6e1727d0d3 Mon Sep 17 00:00:00 2001
From: Udo Walter
Date: Fri, 23 Dec 2016 17:24:05 +0100
Subject: [statistics_reporting] added location column in client table
---
.../statistics_reporting/inc/statisticreporting.inc.php | 8 +++++---
.../statistics_reporting/lang/de/template-tags.json | 3 ++-
.../statistics_reporting/lang/en/template-tags.json | 3 ++-
modules-available/statistics_reporting/templates/_page.html | 4 +++-
.../statistics_reporting/templates/columnChooser.html | 12 ++++++++++++
5 files changed, 24 insertions(+), 6 deletions(-)
(limited to 'modules-available/statistics_reporting/templates/columnChooser.html')
diff --git a/modules-available/statistics_reporting/inc/statisticreporting.inc.php b/modules-available/statistics_reporting/inc/statisticreporting.inc.php
index 9941b078..b75c6eaa 100644
--- a/modules-available/statistics_reporting/inc/statisticreporting.inc.php
+++ b/modules-available/statistics_reporting/inc/statisticreporting.inc.php
@@ -5,8 +5,9 @@ class StatisticReporting
{
public static function getClientStatistics($cutOff, $lowerTimeBound = 0, $upperTimeBound = 24) {
+ $notassigned = Dictionary::translateFile('template-tags', 'lang_notassigned');
$res = Database::simpleQuery("SELECT t1.name, timeSum, medianTime, offlineSum, longSessions, lastLogout, lastStart, shortSessions, locName FROM (
- SELECT machine.hostname AS 'name', machine.machineuuid AS 'uuid', SUM(CAST(sessionTable.length AS UNSIGNED)) AS 'timeSum', GROUP_CONCAT(sessionTable.length) AS 'medianTime', SUM(sessionTable.length >= 60) AS 'longSessions', SUM(sessionTable.length < 60) AS 'shortSessions',MAX(sessionTable.dateline + sessionTable.data) AS 'lastLogout', IFNULL(location.locationname, 'NOT ASSIGNED') AS 'locName'
+ SELECT machine.hostname AS 'name', machine.machineuuid AS 'uuid', SUM(CAST(sessionTable.length AS UNSIGNED)) AS 'timeSum', GROUP_CONCAT(sessionTable.length) AS 'medianTime', SUM(sessionTable.length >= 60) AS 'longSessions', SUM(sessionTable.length < 60) AS 'shortSessions',MAX(sessionTable.dateline + sessionTable.data) AS 'lastLogout', IFNULL(location.locationname, '$notassigned') AS 'locName'
FROM ".self::getBoundedTableQueryString('~session-length', $lowerTimeBound, $upperTimeBound, $cutOff)." sessionTable
INNER JOIN machine ON sessionTable.machineuuid = machine.machineuuid
LEFT JOIN location ON machine.locationid = location.locationid
@@ -24,15 +25,16 @@ class StatisticReporting
// IFNULL(location.locationname, 'NOT ASSIGNED') - NOT ASSIGNED string can be replaced with anything (name of the null-ids in the table)
public static function getLocationStatistics($cutOff, $lowerTimeBound = 0, $upperTimeBound = 24) {
+ $notassigned = Dictionary::translateFile('template-tags', 'lang_notassigned');
$res = Database::simpleQuery("SELECT t1.locName, timeSum, medianTime, offlineSum, longSessions, shortSessions FROM (
- SELECT IFNULL(location.locationname, 'NOT ASSIGNED') AS 'locName', SUM(CAST(sessionTable.length AS UNSIGNED)) AS 'timeSum', GROUP_CONCAT(sessionTable.length) AS 'medianTime', SUM(sessionTable.length >= 60) AS 'longSessions', SUM(sessionTable.length < 60) AS 'shortSessions'
+ SELECT IFNULL(location.locationname, '$notassigned') AS 'locName', SUM(CAST(sessionTable.length AS UNSIGNED)) AS 'timeSum', GROUP_CONCAT(sessionTable.length) AS 'medianTime', SUM(sessionTable.length >= 60) AS 'longSessions', SUM(sessionTable.length < 60) AS 'shortSessions'
FROM ".self::getBoundedTableQueryString('~session-length', $lowerTimeBound, $upperTimeBound, $cutOff)." sessionTable
INNER JOIN machine ON sessionTable.machineuuid = machine.machineuuid
LEFT JOIN location ON machine.locationid = location.locationid
GROUP BY location.locationname
) t1
INNER JOIN (
- SELECT IFNULL(location.locationname, 'NOT ASSIGNED') AS 'locName', SUM(CAST(offlineTable.length AS UNSIGNED)) AS 'offlineSum'
+ SELECT IFNULL(location.locationname, '$notassigned') AS 'locName', SUM(CAST(offlineTable.length AS UNSIGNED)) AS 'offlineSum'
FROM ".self::getBoundedTableQueryString('~offline-length', $lowerTimeBound, $upperTimeBound, $cutOff)." offlineTable
INNER JOIN machine ON offlineTable.machineuuid = machine.machineuuid
LEFT JOIN location ON machine.locationid = location.locationid
diff --git a/modules-available/statistics_reporting/lang/de/template-tags.json b/modules-available/statistics_reporting/lang/de/template-tags.json
index 207949a9..841e87bd 100644
--- a/modules-available/statistics_reporting/lang/de/template-tags.json
+++ b/modules-available/statistics_reporting/lang/de/template-tags.json
@@ -26,5 +26,6 @@
"lang_last14": "Letzten 14 Tage",
"lang_last30": "Letzten 30 Tage",
"lang_last90": "Letzten 90 Tage",
- "lang_apply": "Anwenden"
+ "lang_apply": "Anwenden",
+ "lang_notassigned": "NICHT ZUGEWIESEN"
}
\ No newline at end of file
diff --git a/modules-available/statistics_reporting/lang/en/template-tags.json b/modules-available/statistics_reporting/lang/en/template-tags.json
index e9430960..73b3c2fc 100644
--- a/modules-available/statistics_reporting/lang/en/template-tags.json
+++ b/modules-available/statistics_reporting/lang/en/template-tags.json
@@ -26,5 +26,6 @@
"lang_last14": "Last 14 days",
"lang_last30": "Last 30 days",
"lang_last90": "Last 90 days",
- "lang_apply": "Apply"
+ "lang_apply": "Apply",
+ "lang_notassigned": "NOT ASSIGNED"
}
\ No newline at end of file
diff --git a/modules-available/statistics_reporting/templates/_page.html b/modules-available/statistics_reporting/templates/_page.html
index d2aaecde..fbdde6d5 100644
--- a/modules-available/statistics_reporting/templates/_page.html
+++ b/modules-available/statistics_reporting/templates/_page.html
@@ -41,7 +41,7 @@
{{#perLocation}}
- {{location}} |
+ {{location}} |
{{time}} |
{{medianTime}} |
{{sessions}} |
@@ -59,6 +59,7 @@
{{lang_hostname}} |
+ {{lang_location}} |
{{lang_totalTime}} |
{{lang_medianSessionLength}} |
{{lang_sessions}} |
@@ -72,6 +73,7 @@
{{#perClient}}
{{hostname}} |
+ {{locationName}} |
{{time}} |
{{medianTime}} |
{{sessions}} |
diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html
index 49c9a75d..06cd6770 100644
--- a/modules-available/statistics_reporting/templates/columnChooser.html
+++ b/modules-available/statistics_reporting/templates/columnChooser.html
@@ -24,6 +24,7 @@
+
@@ -69,9 +70,20 @@
var arrow = data.direction === dir.ASC ? "down" : "up";
th.eq(data.column).append(' ');
});
+
+ $(".locationLink").click(function(e) {
+ e.preventDefault();
+ $('#select-table').val('perlocation');
+ chooseTable('perlocation');
+ var target = $(".locationName:contains('"+$(this).text()+"'):first");
+ $(window).scrollTop(target.offset().top - $(window).height()/2);
+ target.parent().css( "background-color", "#f8ff99" );
+ return false;
+ });
});
function chooseTable(v) {
+ $("tr").removeAttr('style');
$("[id^=table-]").hide();
$('#table-'+v).show();
$("[id^=button-]").hide();
--
cgit v1.2.3-55-g7522
From 3234034aa5f8c886b45b0905a9072aed942c383b Mon Sep 17 00:00:00 2001
From: Udo Walter
Date: Thu, 29 Dec 2016 15:11:23 +0100
Subject: [statistics_reporting] small label changes
---
modules-available/statistics_reporting/lang/de/template-tags.json | 3 ++-
modules-available/statistics_reporting/lang/en/template-tags.json | 3 ++-
modules-available/statistics_reporting/templates/_page.html | 6 +++---
modules-available/statistics_reporting/templates/columnChooser.html | 1 +
4 files changed, 8 insertions(+), 5 deletions(-)
(limited to 'modules-available/statistics_reporting/templates/columnChooser.html')
diff --git a/modules-available/statistics_reporting/lang/de/template-tags.json b/modules-available/statistics_reporting/lang/de/template-tags.json
index 841e87bd..7dcec880 100644
--- a/modules-available/statistics_reporting/lang/de/template-tags.json
+++ b/modules-available/statistics_reporting/lang/de/template-tags.json
@@ -3,7 +3,8 @@
"lang_countLogins": "Anzahl Logins",
"lang_client": "Client",
"lang_vm": "VM",
- "lang_sessions": "Sitzungen \u2265 60s",
+ "lang_sessions": "Sitzungen",
+ "lang_longSessions": "Sitzungen \u2265 60s",
"lang_shortSessions": "Sitzungen < 60s",
"lang_overallOfftime": "Insgesamte Zeit Offline",
"lang_totalOffTime": "Gesamtzeit Offline",
diff --git a/modules-available/statistics_reporting/lang/en/template-tags.json b/modules-available/statistics_reporting/lang/en/template-tags.json
index 73b3c2fc..366a10de 100644
--- a/modules-available/statistics_reporting/lang/en/template-tags.json
+++ b/modules-available/statistics_reporting/lang/en/template-tags.json
@@ -3,7 +3,8 @@
"lang_countLogins": "Number of Logins",
"lang_client": "Client",
"lang_vm": "VM",
- "lang_sessions": "Sessions \u2265 60s",
+ "lang_sessions": "Sessions",
+ "lang_longSessions": "Sessions \u2265 60s",
"lang_shortSessions": "Sessions < 60s",
"lang_overallOfftime": "Overall time offline",
"lang_totalOffTime": "Total Time Offline",
diff --git a/modules-available/statistics_reporting/templates/_page.html b/modules-available/statistics_reporting/templates/_page.html
index fbdde6d5..649ef2d3 100644
--- a/modules-available/statistics_reporting/templates/_page.html
+++ b/modules-available/statistics_reporting/templates/_page.html
@@ -7,7 +7,7 @@
|
{{lang_totalTime}} |
{{lang_medianSessionLength}} |
- {{lang_sessions}} |
+ {{lang_longSessions}} |
{{lang_shortSessions}} |
{{lang_overallOfftime}} |
@@ -33,7 +33,7 @@
{{lang_location}} |
{{lang_totalTime}} |
{{lang_medianSessionLength}} |
- {{lang_sessions}} |
+ {{lang_longSessions}} |
{{lang_shortSessions}} |
{{lang_totalOffTime}} |
@@ -62,7 +62,7 @@
{{lang_location}} |
{{lang_totalTime}} |
{{lang_medianSessionLength}} |
- {{lang_sessions}} |
+ {{lang_longSessions}} |
{{lang_shortSessions}} |
{{lang_totalOffTime}} |
{{lang_clientLogout}} |
diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html
index 06cd6770..09551fc1 100644
--- a/modules-available/statistics_reporting/templates/columnChooser.html
+++ b/modules-available/statistics_reporting/templates/columnChooser.html
@@ -28,6 +28,7 @@
+
--
cgit v1.2.3-55-g7522
From 9cd078d34d5f3172e8e770fce3c3ec7d6445a460 Mon Sep 17 00:00:00 2001
From: Udo Walter
Date: Mon, 16 Jan 2017 18:59:46 +0100
Subject: [statistics_reporting] added ui to disable the reporting
---
.../lang/de/template-tags.json | 4 +-
.../lang/en/template-tags.json | 4 +-
.../statistics_reporting/page.inc.php | 45 ++++++++++++++-------
modules-available/statistics_reporting/style.css | 4 ++
.../templates/columnChooser.html | 46 +++++++++++++++++++++-
5 files changed, 85 insertions(+), 18 deletions(-)
(limited to 'modules-available/statistics_reporting/templates/columnChooser.html')
diff --git a/modules-available/statistics_reporting/lang/de/template-tags.json b/modules-available/statistics_reporting/lang/de/template-tags.json
index 7dcec880..73c39e1e 100644
--- a/modules-available/statistics_reporting/lang/de/template-tags.json
+++ b/modules-available/statistics_reporting/lang/de/template-tags.json
@@ -28,5 +28,7 @@
"lang_last30": "Letzten 30 Tage",
"lang_last90": "Letzten 90 Tage",
"lang_apply": "Anwenden",
- "lang_notassigned": "NICHT ZUGEWIESEN"
+ "lang_save": "Speichern",
+ "lang_notassigned": "NICHT ZUGEWIESEN",
+ "lang_reportingDescription": "Helfen Sie uns bwLehrpool, durch das wöchentliche, automatische Verschicken eines anonymisierten Statistikberichts, zu verbessern."
}
\ No newline at end of file
diff --git a/modules-available/statistics_reporting/lang/en/template-tags.json b/modules-available/statistics_reporting/lang/en/template-tags.json
index 366a10de..90d59b38 100644
--- a/modules-available/statistics_reporting/lang/en/template-tags.json
+++ b/modules-available/statistics_reporting/lang/en/template-tags.json
@@ -28,5 +28,7 @@
"lang_last30": "Last 30 days",
"lang_last90": "Last 90 days",
"lang_apply": "Apply",
- "lang_notassigned": "NOT ASSIGNED"
+ "lang_save": "Save",
+ "lang_notassigned": "NOT ASSIGNED",
+ "lang_reportingDescription": "Help us improve bwLehrpool by automatically sending an anonymized statistics report once per week."
}
\ No newline at end of file
diff --git a/modules-available/statistics_reporting/page.inc.php b/modules-available/statistics_reporting/page.inc.php
index 941bf12f..1428848a 100644
--- a/modules-available/statistics_reporting/page.inc.php
+++ b/modules-available/statistics_reporting/page.inc.php
@@ -4,6 +4,8 @@
class Page_Statistics_Reporting extends Page
{
+ private $action = false;
+
/**
* Called before any page rendering happens - early hook to check parameters etc.
*/
@@ -15,6 +17,8 @@ class Page_Statistics_Reporting extends Page
Message::addError('main.no-permission');
Util::redirect('?do=Main'); // does not return
}
+
+ $this->action = Request::any('action', 'show', 'string');
}
/**
@@ -22,20 +26,31 @@ class Page_Statistics_Reporting extends Page
*/
protected function doRender()
{
- // timespan you want to see = Days selected * seconds per Day (86400)
- // default = 14 days
- GetData::$from = strtotime("- ".(Request::get('cutoff', 14, 'int') - 1)." days 00:00:00");
- GetData::$to = time();
- GetData::$lowerTimeBound = Request::get('lower', 0, 'int');
- GetData::$upperTimeBound = Request::get('upper', 24, 'int');
-
- $data = array_merge(GetData::total(), array('perLocation' => array(), 'perClient' => array(), 'perUser' => array(), 'perVM' => array()));
- $data['perLocation'] = GetData::perLocation();
- $data['perClient'] = GetData::perClient();
- $data['perUser'] = GetData::perUser();
- $data['perVM'] = GetData::perVM();
-
- Render::addTemplate('columnChooser');
- Render::addTemplate('_page', $data);
+ if ($this->action === 'show') {
+ // timespan you want to see. default = last 7 days
+ GetData::$from = strtotime("- " . (Request::get('cutoff', 14, 'int') - 1) . " days 00:00:00");
+ GetData::$to = time();
+ GetData::$lowerTimeBound = Request::get('lower', 0, 'int');
+ GetData::$upperTimeBound = Request::get('upper', 24, 'int');
+
+ $data = array_merge(GetData::total(), array('perLocation' => array(), 'perClient' => array(), 'perUser' => array(), 'perVM' => array()));
+ $data['perLocation'] = GetData::perLocation();
+ $data['perClient'] = GetData::perClient();
+ $data['perUser'] = GetData::perUser();
+ $data['perVM'] = GetData::perVM();
+
+ Render::addTemplate('columnChooser');
+ Render::addTemplate('_page', $data);
+ }
+ }
+
+ protected function doAjax()
+ {
+ $this->action = Request::any('action', false, 'string');
+ if ($this->action === 'setReporting') {
+ Property::set("reportingStatus", Request::get('reporting', "on", 'string'));
+ } elseif ($this->action === 'getReporting') {
+ echo Property::get("reportingStatus", "on");
+ }
}
}
diff --git a/modules-available/statistics_reporting/style.css b/modules-available/statistics_reporting/style.css
index d7fa7a2f..4f314b14 100644
--- a/modules-available/statistics_reporting/style.css
+++ b/modules-available/statistics_reporting/style.css
@@ -7,6 +7,10 @@
margin-bottom: 10px;
}
+.top-row #button-settings {
+ margin-right: 0;
+}
+
.buttonbar button {
margin-bottom: 4px;
}
diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html
index 09551fc1..47fef2a5 100644
--- a/modules-available/statistics_reporting/templates/columnChooser.html
+++ b/modules-available/statistics_reporting/templates/columnChooser.html
@@ -22,6 +22,7 @@
+
@@ -37,6 +38,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
--
cgit v1.2.3-55-g7522
From 886e13e1af47ba6488ba3c5146d96e48e08403ad Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Thu, 19 Jan 2017 16:03:06 +0100
Subject: [statistics_reporting] Overhaul remote reporting structure; default
to off
---
inc/util.inc.php | 52 ++++++++++++++
.../statistics_reporting/hooks/cron.inc.php | 37 ++++------
.../statistics_reporting/inc/remotereport.inc.php | 84 ++++++++++++++++++++++
.../statistics_reporting/page.inc.php | 22 +++---
.../templates/columnChooser.html | 4 +-
5 files changed, 166 insertions(+), 33 deletions(-)
create mode 100644 modules-available/statistics_reporting/inc/remotereport.inc.php
(limited to 'modules-available/statistics_reporting/templates/columnChooser.html')
diff --git a/inc/util.inc.php b/inc/util.inc.php
index 671028ed..d454d18d 100644
--- a/inc/util.inc.php
+++ b/inc/util.inc.php
@@ -365,4 +365,56 @@ SADFACE;
exit(0);
}
+ /**
+ * Return a binary string of given length, containing
+ * random bytes. If $secure is given, only methods of
+ * obtaining cryptographically strong random bytes will
+ * be used, otherwise, weaker methods might be used.
+ *
+ * @param int $length number of bytes to return
+ * @param bool $secure true = only use strong random sources
+ * @return string|bool string of requested length, false on error
+ */
+ public static function randomBytes($length, $secure)
+ {
+ if (function_exists('random_bytes')) {
+ return random_bytes($length);
+ }
+ if ($secure) {
+ if (function_exists('openssl_random_pseudo_bytes')) {
+ $bytes = openssl_random_pseudo_bytes($length, $ok);
+ if ($bytes !== false && $ok) {
+ return $bytes;
+ }
+ }
+ $file = '/dev/random';
+ } else {
+ $file = '/dev/urandom';
+ }
+ $fh = @fopen($file, 'r');
+ if ($fh !== false) {
+ $bytes = fread($fh, $length);
+ while ($bytes !== false && strlen($bytes) < $length) {
+ $new = fread($fh, $length - strlen($bytes));
+ if ($new === false) {
+ $bytes = false;
+ break;
+ }
+ $bytes .= $new;
+ }
+ fclose($fh);
+ if ($bytes !== false) {
+ return $bytes;
+ }
+ }
+ if ($secure) {
+ return false;
+ }
+ $bytes = '';
+ while ($length > 0) {
+ $bytes .= chr(mt_rand(0, 255));
+ }
+ return $bytes;
+ }
+
}
diff --git a/modules-available/statistics_reporting/hooks/cron.inc.php b/modules-available/statistics_reporting/hooks/cron.inc.php
index bd427e64..a48f74c2 100644
--- a/modules-available/statistics_reporting/hooks/cron.inc.php
+++ b/modules-available/statistics_reporting/hooks/cron.inc.php
@@ -1,32 +1,23 @@
"statistics", "data" => $statisticsReport);
- $data = array_merge(GetData::total(true), array('perLocation' => array(), 'perClient' => array(), 'perUser' => array(), 'perVM' => array()));
- $data['perLocation'] = GetData::perLocation(true);
- $data['perClient'] = GetData::perClient(true);
- $data['perUser'] = GetData::perUser(true);
- $data['perVM'] = GetData::perVM(true);
+ $result = Download::asStringPost(CONFIG_REPORTING_URL, $params, 30, $code);
-
- $statisticsReport = json_encode($data);
-
- $params = array("action" => "statistics", "data" => $statisticsReport);
-
- Download::asStringPost(CONFIG_REPORTING_URL, $params, 300, $code);
-
- if ($code != 200) {
- EventLog::warning("Statistics Reporting: ".$code);
+ if ($code != 200) {
+ EventLog::warning("Statistics Reporting failed: " . $code, $result);
+ }
}
-}
+}
\ No newline at end of file
diff --git a/modules-available/statistics_reporting/inc/remotereport.inc.php b/modules-available/statistics_reporting/inc/remotereport.inc.php
new file mode 100644
index 00000000..0bf4e7e2
--- /dev/null
+++ b/modules-available/statistics_reporting/inc/remotereport.inc.php
@@ -0,0 +1,84 @@
+action = Request::any('action', false, 'string');
- if ($this->action === 'setReporting') {
- Property::set("reportingStatus", Request::get('reporting', "on", 'string'));
- } elseif ($this->action === 'getReporting') {
- echo Property::get("reportingStatus", "on");
+ $this->action = Request::any('action', false, 'string');
+ if ($this->action === 'setReporting') {
+ if (!User::isLoggedIn()) {
+ die("No.");
+ }
+ $state = Request::post('reporting', false, 'string');
+ if ($state === false) {
+ die('Missing setting value.');
}
+ RemoteReport::setReportingEnabled($state);
+ } elseif ($this->action === 'getReporting') {
+ echo RemoteReport::isReportingEnabled() ? 'on' : '';
+ } else {
+ echo 'Invalid action.';
}
}
+
}
diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html
index 47fef2a5..513bc36b 100644
--- a/modules-available/statistics_reporting/templates/columnChooser.html
+++ b/modules-available/statistics_reporting/templates/columnChooser.html
@@ -189,8 +189,8 @@
function saveSettings() {
$.ajax({
url: '?do=statistics_reporting',
- type: 'GET',
- data: { action: "setReporting", reporting: $("#checkbox-reporting").is(":checked") ? "on" : "off" }
+ type: 'POST',
+ data: { action: "setReporting", reporting: $("#checkbox-reporting").is(":checked") ? "on" : "off", token: TOKEN }
});
}
\ No newline at end of file
--
cgit v1.2.3-55-g7522
From ac4dba11670f93289ca6318c3c06b49bf4ec0811 Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Wed, 1 Feb 2017 12:02:09 +0100
Subject: [statistics_reporting] Fix loadForm() and further js interaction if
sessionStorage is still empty
---
.../statistics_reporting/templates/columnChooser.html | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
(limited to 'modules-available/statistics_reporting/templates/columnChooser.html')
diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html
index 513bc36b..cfaf086c 100644
--- a/modules-available/statistics_reporting/templates/columnChooser.html
+++ b/modules-available/statistics_reporting/templates/columnChooser.html
@@ -159,9 +159,12 @@
var cutoff = getQueryVariable("cutoff");
$('#select-cutoff').val(cutoff ? cutoff : 7);
- sessionStorage.getItem("buttons").split(" ").forEach(function(button) {
- toggleButton(button.substr(7));
- });
+ var buttons = sessionStorage.getItem("buttons");
+ if (buttons) {
+ buttons.split(" ").forEach(function (button) {
+ toggleButton(button.substr(7));
+ });
+ }
}
function getQueryVariable(variable)
--
cgit v1.2.3-55-g7522
From 51ce2ee32af69eb7e18c716605ad060a21c0de01 Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Wed, 1 Feb 2017 13:45:51 +0100
Subject: [statistics_reporting] Fix sort arrow direction
---
modules-available/statistics_reporting/templates/columnChooser.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules-available/statistics_reporting/templates/columnChooser.html')
diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html
index cfaf086c..86903583 100644
--- a/modules-available/statistics_reporting/templates/columnChooser.html
+++ b/modules-available/statistics_reporting/templates/columnChooser.html
@@ -93,7 +93,7 @@
var th = $(this).find("th");
th.find(".arrow").remove();
var dir = $.fn.stupidtable.dir;
- var arrow = data.direction === dir.ASC ? "down" : "up";
+ var arrow = data.direction === dir.ASC ? "up" : "down";
th.eq(data.column).append(' ');
});
--
cgit v1.2.3-55-g7522
From c53f811e83b6cf7124e2d5f26554276436f3b7cd Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Wed, 1 Feb 2017 15:58:19 +0100
Subject: [statistics_reporting] Show hand-cursor for sortable columns
---
modules-available/statistics_reporting/style.css | 6 +-
.../statistics_reporting/templates/_page.html | 238 ++++++++++-----------
.../templates/columnChooser.html | 3 +-
3 files changed, 112 insertions(+), 135 deletions(-)
(limited to 'modules-available/statistics_reporting/templates/columnChooser.html')
diff --git a/modules-available/statistics_reporting/style.css b/modules-available/statistics_reporting/style.css
index 4f314b14..81dc74b0 100644
--- a/modules-available/statistics_reporting/style.css
+++ b/modules-available/statistics_reporting/style.css
@@ -37,6 +37,6 @@
line-height: 1.6em;
}
-#applybound {
- display: none;
-}
\ No newline at end of file
+th[data-sort] {
+ cursor: pointer;
+}
diff --git a/modules-available/statistics_reporting/templates/_page.html b/modules-available/statistics_reporting/templates/_page.html
index 39726d51..1f4ac52c 100644
--- a/modules-available/statistics_reporting/templates/_page.html
+++ b/modules-available/statistics_reporting/templates/_page.html
@@ -1,133 +1,111 @@
-
-
-
-
-
-
- |
- {{lang_totalTime}} |
- {{lang_medianSessionLength}} |
- {{lang_longSessions}} |
- {{lang_shortSessions}} |
- {{lang_overallOfftime}} |
-
-
-
-
- {{lang_total}} |
- {{time_s}} |
- {{medianTime_s}} |
- {{sessions}} |
- {{shortSessions}} |
- {{totalOfftime_s}} |
-
-
-
-
-
-
-
-
-
-
- {{lang_location}} |
- {{lang_totalTime}} |
- {{lang_medianSessionLength}} |
- {{lang_longSessions}} |
- {{lang_shortSessions}} |
- {{lang_totalOffTime}} |
-
-
-
- {{#perLocation}}
-
- {{location}} |
- {{time_s}} |
- {{medianTime_s}} |
- {{sessions}} |
- {{shortSessions}} |
- {{offTime_s}} |
-
- {{/perLocation}}
-
-
-
-
-
-
-
-
-
- {{lang_hostname}} |
- {{lang_location}} |
- {{lang_totalTime}} |
- {{lang_medianSessionLength}} |
- {{lang_longSessions}} |
- {{lang_shortSessions}} |
- {{lang_totalOffTime}} |
- {{lang_clientLogout}} |
- {{lang_clientStart}} |
-
-
-
- {{#perClient}}
-
- {{hostname}} |
- {{location}} |
- {{time_s}} |
- {{medianTime_s}} |
- {{sessions}} |
- {{shortSessions}} |
- {{offTime_s}} |
- {{lastLogout_s}} |
- {{lastStart_s}} |
-
- {{/perClient}}
-
-
-
-
-
-
-
-
-
- {{lang_user}} |
- {{lang_sessions}} |
-
-
-
- {{#perUser}}
-
- {{user}} |
- {{sessions}} |
-
- {{/perUser}}
-
-
-
-
-
-
-
-
-
- {{lang_vm}} |
- {{lang_sessions}} |
-
-
-
- {{#perVM}}
-
- {{vm}} |
- {{sessions}} |
-
- {{/perVM}}
-
-
-
-
-
+
+
+
+ |
+ {{lang_totalTime}} |
+ {{lang_medianSessionLength}} |
+ {{lang_longSessions}} |
+ {{lang_shortSessions}} |
+ {{lang_overallOfftime}} |
+
+
+
+
+ {{lang_total}} |
+ {{time_s}} |
+ {{medianTime_s}} |
+ {{sessions}} |
+ {{shortSessions}} |
+ {{totalOfftime_s}} |
+
+
+
+
+
+
+ {{lang_location}} |
+ {{lang_totalTime}} |
+ {{lang_medianSessionLength}} |
+ {{lang_longSessions}} |
+ {{lang_shortSessions}} |
+ {{lang_totalOffTime}} |
+
+
+
+ {{#perLocation}}
+
+ {{location}} |
+ {{time_s}} |
+ {{medianTime_s}} |
+ {{sessions}} |
+ {{shortSessions}} |
+ {{offTime_s}} |
+
+ {{/perLocation}}
+
+
+
+
+
+ {{lang_hostname}} |
+ {{lang_location}} |
+ {{lang_totalTime}} |
+ {{lang_medianSessionLength}} |
+ {{lang_longSessions}} |
+ {{lang_shortSessions}} |
+ {{lang_totalOffTime}} |
+ {{lang_clientLogout}} |
+ {{lang_clientStart}} |
+
+
+
+ {{#perClient}}
+
+ {{hostname}} |
+ {{location}} |
+ {{time_s}} |
+ {{medianTime_s}} |
+ {{sessions}} |
+ {{shortSessions}} |
+ {{offTime_s}} |
+ {{lastLogout_s}} |
+ {{lastStart_s}} |
+
+ {{/perClient}}
+
+
+
+
+
+ {{lang_user}} |
+ {{lang_sessions}} |
+
+
+
+ {{#perUser}}
+
+ {{user}} |
+ {{sessions}} |
+
+ {{/perUser}}
+
+
+
+
+
+ {{lang_vm}} |
+ {{lang_sessions}} |
+
+
+
+ {{#perVM}}
+
+ {{vm}} |
+ {{sessions}} |
+
+ {{/perVM}}
+
+
diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html
index 86903583..c51250bd 100644
--- a/modules-available/statistics_reporting/templates/columnChooser.html
+++ b/modules-available/statistics_reporting/templates/columnChooser.html
@@ -21,7 +21,7 @@
-
+
@@ -38,7 +38,6 @@
-
--
cgit v1.2.3-55-g7522
From 452a0a49d0e9bef75667e488b37580dd5688a923 Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Thu, 2 Feb 2017 16:06:40 +0100
Subject: [statistics_reporting] Move logic js -> php (for export feature)
---
.../statistics_reporting/page.inc.php | 111 ++++++++++++--
.../statistics_reporting/templates/_page.html | 111 --------------
.../templates/columnChooser.html | 169 +++++++--------------
.../templates/table-client.html | 30 ++++
.../templates/table-location.html | 24 +++
.../templates/table-total.html | 22 +++
.../statistics_reporting/templates/table-user.html | 16 ++
.../statistics_reporting/templates/table-vm.html | 19 +++
8 files changed, 268 insertions(+), 234 deletions(-)
delete mode 100644 modules-available/statistics_reporting/templates/_page.html
create mode 100644 modules-available/statistics_reporting/templates/table-client.html
create mode 100644 modules-available/statistics_reporting/templates/table-location.html
create mode 100644 modules-available/statistics_reporting/templates/table-total.html
create mode 100644 modules-available/statistics_reporting/templates/table-user.html
create mode 100644 modules-available/statistics_reporting/templates/table-vm.html
(limited to 'modules-available/statistics_reporting/templates/columnChooser.html')
diff --git a/modules-available/statistics_reporting/page.inc.php b/modules-available/statistics_reporting/page.inc.php
index 81d44e15..235cebb7 100644
--- a/modules-available/statistics_reporting/page.inc.php
+++ b/modules-available/statistics_reporting/page.inc.php
@@ -4,7 +4,22 @@
class Page_Statistics_Reporting extends Page
{
- private $action = false;
+ private $action;
+ private $type;
+
+ // "Constants"
+ private $days;
+
+ /**
+ * @var array Names of columns that are being used by the various tables
+ */
+ private $COLUMNS = array('col_lastlogout', 'col_laststart', 'col_location', 'col_longsessions', 'col_mediantime',
+ 'col_sessions', 'col_shortsessions', 'col_timeoffline', 'col_totaltime');
+
+ /**
+ * @var array Names of the tables we can display
+ */
+ private $TABLES = array('total', 'location', 'client', 'user', 'vm');
/**
* Called before any page rendering happens - early hook to check parameters etc.
@@ -19,6 +34,15 @@ class Page_Statistics_Reporting extends Page
}
$this->action = Request::any('action', 'show', 'string');
+ $this->type = Request::get('type', 'total', 'string');
+ $this->days = Request::get('cutoff', 7, 'int');
+ $this->lower = Request::get('lower', 8, 'int');
+ $this->upper = Request::get('upper', 20, 'int');
+
+ if (!in_array($this->type, $this->TABLES)) {
+ Message::addError('invalid-table-type', $this->type);
+ $this->type = 'total';
+ }
}
/**
@@ -27,20 +51,67 @@ class Page_Statistics_Reporting extends Page
protected function doRender()
{
if ($this->action === 'show') {
+
+ /*
+ * Leave these here for the translate module
+ * Dictionary::translate('col_lastlogout');
+ * Dictionary::translate('col_laststart');
+ * Dictionary::translate('col_location');
+ * Dictionary::translate('col_longsessions');
+ * Dictionary::translate('col_mediantime');
+ * Dictionary::translate('col_sessions');
+ * Dictionary::translate('col_shortsessions');
+ * Dictionary::translate('col_timeoffline');
+ * Dictionary::translate('col_totaltime');
+ * Dictionary::translate('table_total');
+ * Dictionary::translate('table_location');
+ * Dictionary::translate('table_client');
+ * Dictionary::translate('table_user');
+ * Dictionary::translate('table_vm');
+ */
+
+ $data = array(
+ 'columns' => array(),
+ 'tables' => array(),
+ 'days' => array()
+ );
+
+ foreach ($this->COLUMNS as $column) {
+ $data['columns'][] = array(
+ 'id' => $column,
+ 'name' => Dictionary::translate($column, true),
+ 'checked' => Request::get($column, 'on', 'string') === 'on' ? 'checked' : '',
+ );
+ }
+
+ foreach ($this->TABLES as $table) {
+ $data['tables'][] = array(
+ 'name' => Dictionary::translate('table_' . $table, true),
+ 'value' => $table,
+ 'selected' => ($this->type === $table) ? 'selected' : '',
+ );
+ }
+
+ foreach (array(1,2,5,7,14,30,90) as $day) {
+ $data['days'][] = array(
+ 'days' => $day,
+ 'selected' => ($day === $this->days) ? 'selected' : '',
+ );
+ }
+
+ $data['lower'] = $this->lower;
+ $data['upper'] = $this->upper;
+
+ Render::addTemplate('columnChooser', $data);
+
// timespan you want to see. default = last 7 days
- GetData::$from = strtotime("- " . (Request::get('cutoff', 7, 'int') - 1) . " days 00:00:00");
+ GetData::$from = strtotime("- " . ($this->days - 1) . " days 00:00:00");
GetData::$to = time();
- GetData::$lowerTimeBound = Request::get('lower', 0, 'int');
- GetData::$upperTimeBound = Request::get('upper', 24, 'int');
-
- $data = GetData::total(GETDATA_PRINTABLE);
- $data['perLocation'] = GetData::perLocation(GETDATA_PRINTABLE);
- $data['perClient'] = GetData::perClient(GETDATA_PRINTABLE);
- $data['perUser'] = GetData::perUser(GETDATA_PRINTABLE);
- $data['perVM'] = GetData::perVM(GETDATA_PRINTABLE);
+ GetData::$lowerTimeBound = $this->lower;
+ GetData::$upperTimeBound = $this->upper;
- Render::addTemplate('columnChooser');
- Render::addTemplate('_page', $data);
+ $data['data'] = $this->fetchData(GETDATA_PRINTABLE);
+ Render::addTemplate('table-' . $this->type, $data);
}
}
@@ -63,4 +134,20 @@ class Page_Statistics_Reporting extends Page
}
}
+ private function fetchData($flags)
+ {
+ switch ($this->type) {
+ case 'total':
+ return GetData::total($flags);
+ case 'location':
+ return GetData::perLocation($flags);
+ case 'client':
+ return GetData::perClient($flags);
+ case 'user':
+ return GetData::perUser($flags);
+ case 'vm':
+ return GetData::perVM($flags);
+ }
+ }
+
}
diff --git a/modules-available/statistics_reporting/templates/_page.html b/modules-available/statistics_reporting/templates/_page.html
deleted file mode 100644
index 1f4ac52c..00000000
--- a/modules-available/statistics_reporting/templates/_page.html
+++ /dev/null
@@ -1,111 +0,0 @@
-
-
-
- |
- {{lang_totalTime}} |
- {{lang_medianSessionLength}} |
- {{lang_longSessions}} |
- {{lang_shortSessions}} |
- {{lang_overallOfftime}} |
-
-
-
-
- {{lang_total}} |
- {{time_s}} |
- {{medianTime_s}} |
- {{sessions}} |
- {{shortSessions}} |
- {{totalOfftime_s}} |
-
-
-
-
-
-
- {{lang_location}} |
- {{lang_totalTime}} |
- {{lang_medianSessionLength}} |
- {{lang_longSessions}} |
- {{lang_shortSessions}} |
- {{lang_totalOffTime}} |
-
-
-
- {{#perLocation}}
-
- {{location}} |
- {{time_s}} |
- {{medianTime_s}} |
- {{sessions}} |
- {{shortSessions}} |
- {{offTime_s}} |
-
- {{/perLocation}}
-
-
-
-
-
- {{lang_hostname}} |
- {{lang_location}} |
- {{lang_totalTime}} |
- {{lang_medianSessionLength}} |
- {{lang_longSessions}} |
- {{lang_shortSessions}} |
- {{lang_totalOffTime}} |
- {{lang_clientLogout}} |
- {{lang_clientStart}} |
-
-
-
- {{#perClient}}
-
- {{hostname}} |
- {{location}} |
- {{time_s}} |
- {{medianTime_s}} |
- {{sessions}} |
- {{shortSessions}} |
- {{offTime_s}} |
- {{lastLogout_s}} |
- {{lastStart_s}} |
-
- {{/perClient}}
-
-
-
-
-
- {{lang_user}} |
- {{lang_sessions}} |
-
-
-
- {{#perUser}}
-
- {{user}} |
- {{sessions}} |
-
- {{/perUser}}
-
-
-
-
-
- {{lang_vm}} |
- {{lang_sessions}} |
-
-
-
- {{#perVM}}
-
- {{vm}} |
- {{sessions}} |
-
- {{/perVM}}
-
-
-
-
-
diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html
index c51250bd..b5cf4ec8 100644
--- a/modules-available/statistics_reporting/templates/columnChooser.html
+++ b/modules-available/statistics_reporting/templates/columnChooser.html
@@ -1,41 +1,39 @@
@@ -17,13 +17,13 @@
{{hostname}} |
{{location}} |
- {{time_s}} |
- {{medianTime_s}} |
- {{sessions}} |
- {{shortSessions}} |
- {{offTime_s}} |
- {{lastLogout_s}} |
- {{lastStart_s}} |
+ {{time_s}} |
+ {{medianTime_s}} |
+ {{sessions}} |
+ {{shortSessions}} |
+ {{offTime_s}} |
+ {{lastLogout_s}} |
+ {{lastStart_s}} |
{{/data}}
diff --git a/modules-available/statistics_reporting/templates/table-location.html b/modules-available/statistics_reporting/templates/table-location.html
index 55fa8e6f..02292e5b 100644
--- a/modules-available/statistics_reporting/templates/table-location.html
+++ b/modules-available/statistics_reporting/templates/table-location.html
@@ -2,22 +2,22 @@
{{lang_location}} |
- {{lang_totalTime}} |
- {{lang_medianSessionLength}} |
- {{lang_longSessions}} |
- {{lang_shortSessions}} |
- {{lang_totalOffTime}} |
+ {{lang_totalTime}} |
+ {{lang_medianSessionLength}} |
+ {{lang_longSessions}} |
+ {{lang_shortSessions}} |
+ {{lang_totalOffTime}} |
{{#data}}
{{location}} |
- {{time_s}} |
- {{medianTime_s}} |
- {{sessions}} |
- {{shortSessions}} |
- {{offTime_s}} |
+ {{time_s}} |
+ {{medianTime_s}} |
+ {{sessions}} |
+ {{shortSessions}} |
+ {{offTime_s}} |
{{/data}}
diff --git a/modules-available/statistics_reporting/templates/table-total.html b/modules-available/statistics_reporting/templates/table-total.html
index 2e100ae5..e59dda25 100644
--- a/modules-available/statistics_reporting/templates/table-total.html
+++ b/modules-available/statistics_reporting/templates/table-total.html
@@ -2,21 +2,21 @@
|
- {{lang_totalTime}} |
- {{lang_medianSessionLength}} |
- {{lang_longSessions}} |
- {{lang_shortSessions}} |
- {{lang_totalOffTime}} |
+ {{lang_totalTime}} |
+ {{lang_medianSessionLength}} |
+ {{lang_longSessions}} |
+ {{lang_shortSessions}} |
+ {{lang_totalOffTime}} |
{{lang_total}} |
- {{data.time_s}} |
- {{data.medianTime_s}} |
- {{data.sessions}} |
- {{data.shortSessions}} |
- {{data.totalOfftime_s}} |
+ {{data.time_s}} |
+ {{data.medianTime_s}} |
+ {{data.sessions}} |
+ {{data.shortSessions}} |
+ {{data.totalOfftime_s}} |
--
cgit v1.2.3-55-g7522
From 5a6575b1c07997ba1af20952f435290ce8ce970c Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Wed, 8 Feb 2017 12:13:57 +0100
Subject: [statistics_reporting] Nag user if statistics reporting is disabled
---
.../hooks/main-warning.inc.php | 5 +++
.../statistics_reporting/inc/remotereport.inc.php | 2 +-
.../lang/de/template-tags.json | 4 +-
.../lang/en/template-tags.json | 4 +-
.../statistics_reporting/page.inc.php | 26 ++++++++++++-
.../templates/columnChooser.html | 43 ++++++++++++----------
6 files changed, 60 insertions(+), 24 deletions(-)
create mode 100644 modules-available/statistics_reporting/hooks/main-warning.inc.php
(limited to 'modules-available/statistics_reporting/templates/columnChooser.html')
diff --git a/modules-available/statistics_reporting/hooks/main-warning.inc.php b/modules-available/statistics_reporting/hooks/main-warning.inc.php
new file mode 100644
index 00000000..33381c9f
--- /dev/null
+++ b/modules-available/statistics_reporting/hooks/main-warning.inc.php
@@ -0,0 +1,5 @@
+doExport();
// Does not return
}
+ // Get report - fetch data exactly the way it would automatically be reported
+ // so the user can know what is going on
+ if ($this->action === 'getreport') {
+ $report = RemoteReport::generateReport(strtotime('-7 days'), time('now'));
+ Header('Content-Disposition: attachment; filename=remote-report.json');
+ Header('Content-Type: application/json; charset=utf-8');
+ die(json_encode($report));
+ }
}
/**
@@ -105,6 +113,13 @@ class Page_Statistics_Reporting extends Page
$data['lower'] = $this->lower;
$data['upper'] = $this->upper;
+ if (RemoteReport::isReportingEnabled()) {
+ $data['settingsButtonClass'] = 'default';
+ $data['reportChecked'] = 'checked';
+ } else {
+ $data['settingsButtonClass'] = 'danger';
+ }
+
Render::addTemplate('columnChooser', $data);
$data['data'] = $this->fetchData(GETDATA_PRINTABLE);
@@ -124,8 +139,15 @@ class Page_Statistics_Reporting extends Page
die('Missing setting value.');
}
RemoteReport::setReportingEnabled($state);
- } elseif ($this->action === 'getReporting') {
- echo RemoteReport::isReportingEnabled() ? 'on' : '';
+ $data = array();
+ if (RemoteReport::isReportingEnabled()) {
+ $data['class'] = 'default';
+ $data['checked'] = true;
+ } else {
+ $data['class'] = 'danger';
+ }
+ Header('Content-Type: application/json; charset=utf-8');
+ die(json_encode($data));
} else {
echo 'Invalid action.';
}
diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html
index efc1f355..9707c970 100644
--- a/modules-available/statistics_reporting/templates/columnChooser.html
+++ b/modules-available/statistics_reporting/templates/columnChooser.html
@@ -2,7 +2,7 @@
-
+
{{lang_displaySelection}}
@@ -72,8 +72,12 @@