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)
---
.../templates/table-location.html | 24 ++++++++++++++++++++++
1 file changed, 24 insertions(+)
create mode 100644 modules-available/statistics_reporting/templates/table-location.html
(limited to 'modules-available/statistics_reporting/templates/table-location.html')
diff --git a/modules-available/statistics_reporting/templates/table-location.html b/modules-available/statistics_reporting/templates/table-location.html
new file mode 100644
index 00000000..55fa8e6f
--- /dev/null
+++ b/modules-available/statistics_reporting/templates/table-location.html
@@ -0,0 +1,24 @@
+
+
+
+ {{lang_location}} |
+ {{lang_totalTime}} |
+ {{lang_medianSessionLength}} |
+ {{lang_longSessions}} |
+ {{lang_shortSessions}} |
+ {{lang_totalOffTime}} |
+
+
+
+ {{#data}}
+
+ {{location}} |
+ {{time_s}} |
+ {{medianTime_s}} |
+ {{sessions}} |
+ {{shortSessions}} |
+ {{offTime_s}} |
+
+ {{/data}}
+
+
--
cgit v1.2.3-55-g7522
From 3428949ab80ad023693834a789008f230728493a Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Tue, 7 Feb 2017 14:33:04 +0100
Subject: [statistics_reporting] Fix hiding of checkboxes not matching any
column
---
.../statistics_reporting/page.inc.php | 2 +-
.../templates/columnChooser.html | 28 +++++-----------------
.../templates/table-client.html | 28 +++++++++++-----------
.../templates/table-location.html | 20 ++++++++--------
.../templates/table-total.html | 20 ++++++++--------
5 files changed, 41 insertions(+), 57 deletions(-)
(limited to 'modules-available/statistics_reporting/templates/table-location.html')
diff --git a/modules-available/statistics_reporting/page.inc.php b/modules-available/statistics_reporting/page.inc.php
index 8ae9ec92..06f9cfb6 100644
--- a/modules-available/statistics_reporting/page.inc.php
+++ b/modules-available/statistics_reporting/page.inc.php
@@ -81,7 +81,7 @@ class Page_Statistics_Reporting extends Page
foreach ($this->COLUMNS as $column) {
$data['columns'][] = array(
- 'id' => $column,
+ 'id' => 'col_' . $column,
'name' => Dictionary::translateFile('template-tags', 'lang_' . $column, true),
'checked' => Request::get($column, 'on', 'string') === 'on' ? 'checked' : '',
);
diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html
index 83d1b9e1..efc1f355 100644
--- a/modules-available/statistics_reporting/templates/columnChooser.html
+++ b/modules-available/statistics_reporting/templates/columnChooser.html
@@ -34,11 +34,11 @@
@@ -117,18 +117,12 @@
th.eq(data.column).append(' ');
});
- if (getParameter("type") == "location" && getParameter("location")) {
- var target = $(".locationName:contains('"+decodeURIComponent(getParameter("location")).replace(/\+/g, " ")+"'):first");
- $(window).scrollTop(target.offset().top - $(window).height()/2);
- target.parent().css( "background-color", "#f8ff99" );
- }
-
$(".locationLink").click(function(e) {
e.preventDefault();
var form = $('#controlsForm');
$('').attr('type', 'hidden')
.attr('name', "location")
- .attr('value', $(this).text())
+ .attr('value', $(this).data('lid'))
.appendTo(form);
form.find('#select-table').val("location");
form.submit();
@@ -174,14 +168,4 @@
data: { action: "setReporting", reporting: $("#checkbox-reporting").is(":checked") ? "on" : "off", token: TOKEN }
});
}
-
- function getParameter(name) {
- var query = window.location.search.substring(1);
- var vars = query.split("&");
- for (var i=0;i
\ No newline at end of file
diff --git a/modules-available/statistics_reporting/templates/table-client.html b/modules-available/statistics_reporting/templates/table-client.html
index e53a49d6..2bb79447 100644
--- a/modules-available/statistics_reporting/templates/table-client.html
+++ b/modules-available/statistics_reporting/templates/table-client.html
@@ -3,13 +3,13 @@
{{lang_hostname}} |
{{lang_location}} |
- {{lang_totalTime}} |
- {{lang_medianSessionLength}} |
- {{lang_longSessions}} |
- {{lang_shortSessions}} |
- {{lang_totalOffTime}} |
- {{lang_lastLogout}} |
- {{lang_lastStart}} |
+ {{lang_totalTime}} |
+ {{lang_medianSessionLength}} |
+ {{lang_longSessions}} |
+ {{lang_shortSessions}} |
+ {{lang_totalOffTime}} |
+ {{lang_lastLogout}} |
+ {{lang_lastStart}} |
@@ -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 47db4f25c7b2d257c176bf5616bb60d8745a4a07 Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Tue, 7 Feb 2017 14:57:03 +0100
Subject: [statistics_reporting] Fix location highlighting (do it server side)
---
modules-available/statistics_reporting/page.inc.php | 11 ++++++++++-
.../statistics_reporting/templates/table-client.html | 2 +-
.../statistics_reporting/templates/table-location.html | 2 +-
3 files changed, 12 insertions(+), 3 deletions(-)
(limited to 'modules-available/statistics_reporting/templates/table-location.html')
diff --git a/modules-available/statistics_reporting/page.inc.php b/modules-available/statistics_reporting/page.inc.php
index 06f9cfb6..90188121 100644
--- a/modules-available/statistics_reporting/page.inc.php
+++ b/modules-available/statistics_reporting/page.inc.php
@@ -209,7 +209,16 @@ class Page_Statistics_Reporting extends Page
case 'total':
return GetData::total($flags);
case 'location':
- return GetData::perLocation($flags);
+ $data = GetData::perLocation($flags);
+ $highlight = Request::get('location', false, 'int');
+ if ($highlight !== false) {
+ foreach ($data as &$row) {
+ if ($row['locationId'] == $highlight) {
+ $row['highlight'] = true;
+ }
+ }
+ }
+ return $data;
case 'client':
return GetData::perClient($flags);
case 'user':
diff --git a/modules-available/statistics_reporting/templates/table-client.html b/modules-available/statistics_reporting/templates/table-client.html
index 2bb79447..2fb2f574 100644
--- a/modules-available/statistics_reporting/templates/table-client.html
+++ b/modules-available/statistics_reporting/templates/table-client.html
@@ -16,7 +16,7 @@
{{#data}}
{{hostname}} |
- {{location}} |
+ {{location}} |
{{time_s}} |
{{medianTime_s}} |
{{sessions}} |
diff --git a/modules-available/statistics_reporting/templates/table-location.html b/modules-available/statistics_reporting/templates/table-location.html
index 02292e5b..9479b7af 100644
--- a/modules-available/statistics_reporting/templates/table-location.html
+++ b/modules-available/statistics_reporting/templates/table-location.html
@@ -11,7 +11,7 @@
{{#data}}
-
+
{{location}} |
{{time_s}} |
{{medianTime_s}} |
--
cgit v1.2.3-55-g7522
From 3a09daee1ebaf014536e14e82ca0fd4c2c92a41f Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Wed, 8 Feb 2017 13:38:04 +0100
Subject: [statistics_reporting] Consistent field naming across classes,
templates etc.
---
.../statistics_reporting/inc/getdata.inc.php | 46 +++++++++++-----------
.../statistics_reporting/inc/queries.inc.php | 8 ++--
.../templates/table-client.html | 8 ++--
.../templates/table-location.html | 8 ++--
.../templates/table-total.html | 8 ++--
5 files changed, 39 insertions(+), 39 deletions(-)
(limited to 'modules-available/statistics_reporting/templates/table-location.html')
diff --git a/modules-available/statistics_reporting/inc/getdata.inc.php b/modules-available/statistics_reporting/inc/getdata.inc.php
index 9604d652..83f118e6 100644
--- a/modules-available/statistics_reporting/inc/getdata.inc.php
+++ b/modules-available/statistics_reporting/inc/getdata.inc.php
@@ -17,17 +17,17 @@ class GetData
// total time online, average time online, total number of logins
$res = Queries::getOverallStatistics(self::$from, self::$to, self::$lowerTimeBound, self::$upperTimeBound);
$row = $res->fetch(PDO::FETCH_ASSOC);
- $data = array('time' => $row['sum'], 'medianTime' => self::calcMedian($row['median']), 'sessions' => $row['longSessions'], 'shortSessions' => $row['shortSessions']);
+ $data = array('totalTime' => $row['sum'], 'medianSessionLength' => self::calcMedian($row['median']), 'longSessions' => $row['longSessions'], 'shortSessions' => $row['shortSessions']);
//total time offline
$res = Queries::getTotalOfflineStatistics(self::$from, self::$to, self::$lowerTimeBound, self::$upperTimeBound);
$row = $res->fetch(PDO::FETCH_ASSOC);
- $data = array_merge($data, array('totalOfftime' => $row['timeOff']));
+ $data['totalOffTime'] = $row['timeOff'];
if ($printable) {
- $data["time_s"] = self::formatSeconds($data["time"]);
- $data["medianTime_s"] = self::formatSeconds($data["medianTime"]);
- $data["totalOfftime_s"] = self::formatSeconds($data["totalOfftime"]);
+ $data["totalTime_s"] = self::formatSeconds($data["totalTime"]);
+ $data["medianSessionLength_s"] = self::formatSeconds($data["medianSessionLength"]);
+ $data["totalOffTime_s"] = self::formatSeconds($data["totalOffTime"]);
}
return $data;
@@ -40,22 +40,22 @@ class GetData
$res = Queries::getLocationStatistics(self::$from, self::$to, self::$lowerTimeBound, self::$upperTimeBound);
$data = array();
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $median = self::calcMedian(self::calcMedian($row['medianTime']));
+ $median = self::calcMedian(self::calcMedian($row['medianSessionLength']));
$entry = array(
'location' => ($anonymize ? $row['locHash'] : $row['locName']),
- 'time' => $row['timeSum'],
- 'medianTime' => $median,
- 'offTime' => $row['offlineSum'],
- 'sessions' => $row['longSessions'],
+ 'totalTime' => $row['timeSum'],
+ 'medianSessionLength' => $median,
+ 'totalOffTime' => $row['offlineSum'],
+ 'longSessions' => $row['longSessions'],
'shortSessions' => $row['shortSessions']
);
if (!$anonymize) {
$entry['locationId'] = $row['locId'];
}
if ($printable) {
- $entry['time_s'] = self::formatSeconds($row['timeSum']);
- $entry['medianTime_s'] = self::formatSeconds($median);
- $entry['offTime_s'] = self::formatSeconds($row['offlineSum']);
+ $entry['totalTime_s'] = self::formatSeconds($row['timeSum']);
+ $entry['medianSessionLength_s'] = self::formatSeconds($median);
+ $entry['totalOffTime_s'] = self::formatSeconds($row['offlineSum']);
}
$data[] = $entry;
}
@@ -69,15 +69,15 @@ class GetData
$res = Queries::getClientStatistics(self::$from, self::$to, self::$lowerTimeBound, self::$upperTimeBound);
$data = array();
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $median = self::calcMedian(self::calcMedian($row['medianTime']));
+ $median = self::calcMedian(self::calcMedian($row['medianSessionLength']));
$entry = array(
'hostname' => ($anonymize ? $row['clientHash'] : $row['clientName']),
- 'time' => $row['timeSum'],
- 'medianTime' => $median,
- 'offTime' => $row['offlineSum'],
+ 'totalTime' => $row['timeSum'],
+ 'medianSessionLength' => $median,
+ 'totalOffTime' => $row['offlineSum'],
'lastStart' => $row['lastStart'],
'lastLogout' => $row['lastLogout'],
- 'sessions' => $row['longSessions'],
+ 'longSessions' => $row['longSessions'],
'shortSessions' => $row['shortSessions'],
'location' => ($anonymize ? $row['locHash'] : $row['locName']),
);
@@ -85,11 +85,11 @@ class GetData
$entry['locationId'] = $row['locId'];
}
if ($printable) {
- $entry['time_s'] = self::formatSeconds($row['timeSum']);
- $entry['medianTime_s'] = self::formatSeconds($median);
- $entry['offTime_s'] = self::formatSeconds($row['offlineSum']);
- $entry['lastStart_s'] = date(DATE_RSS, $row['lastStart']);
- $entry['lastLogout_s'] = date(DATE_RSS, $row['lastLogout']);
+ $entry['totalTime_s'] = self::formatSeconds($row['timeSum']);
+ $entry['medianSessionLength_s'] = self::formatSeconds($median);
+ $entry['totalOffTime_s'] = self::formatSeconds($row['offlineSum']);
+ $entry['lastStart_s'] = date(DATE_ISO8601, $row['lastStart']);
+ $entry['lastLogout_s'] = date(DATE_ISO8601, $row['lastLogout']);
}
$data[] = $entry;
}
diff --git a/modules-available/statistics_reporting/inc/queries.inc.php b/modules-available/statistics_reporting/inc/queries.inc.php
index 7a56414b..1d1d3a44 100644
--- a/modules-available/statistics_reporting/inc/queries.inc.php
+++ b/modules-available/statistics_reporting/inc/queries.inc.php
@@ -8,8 +8,8 @@ class Queries
public static function getClientStatistics($from, $to, $lowerTimeBound = 0, $upperTimeBound = 24, $excludeToday = false) {
$notassigned = Dictionary::translate('notAssigned', true);
Database::exec("SET SESSION group_concat_max_len = 1000000000");
- $res = Database::simpleQuery("SELECT t1.name AS clientName, timeSum, medianTime, offlineSum, lastStart, lastLogout, longSessions, shortSessions, locId, locName, MD5(CONCAT(locId, :salt)) AS locHash, MD5(CONCAT(t1.uuid, :salt)) AS clientHash 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, '$notassigned') AS 'locName', location.locationid AS 'locId'
+ $res = Database::simpleQuery("SELECT t1.name AS clientName, timeSum, medianSessionLength, offlineSum, lastStart, lastLogout, longSessions, shortSessions, locId, locName, MD5(CONCAT(locId, :salt)) AS locHash, MD5(CONCAT(t1.uuid, :salt)) AS clientHash FROM (
+ SELECT machine.hostname AS 'name', machine.machineuuid AS 'uuid', SUM(CAST(sessionTable.length AS UNSIGNED)) AS 'timeSum', GROUP_CONCAT(sessionTable.length) AS 'medianSessionLength', 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', location.locationid AS 'locId'
FROM ".self::getBoundedTableQueryString('~session-length', $from, $to, $lowerTimeBound, $upperTimeBound)." sessionTable
INNER JOIN machine ON sessionTable.machineuuid = machine.machineuuid
LEFT JOIN location ON machine.locationid = location.locationid
@@ -30,8 +30,8 @@ class Queries
public static function getLocationStatistics($from, $to, $lowerTimeBound = 0, $upperTimeBound = 24, $excludeToday = false) {
$notassigned = Dictionary::translate('notAssigned', true);
Database::exec("SET SESSION group_concat_max_len = 1000000000");
- $res = Database::simpleQuery("SELECT t1.locId, t1.locName AS locName, MD5(CONCAT(t1.locId, :salt)) AS locHash, timeSum, medianTime, offlineSum, longSessions, shortSessions FROM (
- SELECT IFNULL(location.locationname, '$notassigned') AS 'locName', location.locationid AS 'locId', 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'
+ $res = Database::simpleQuery("SELECT t1.locId, t1.locName AS locName, MD5(CONCAT(t1.locId, :salt)) AS locHash, timeSum, medianSessionLength, offlineSum, longSessions, shortSessions FROM (
+ SELECT IFNULL(location.locationname, '$notassigned') AS 'locName', location.locationid AS 'locId', SUM(CAST(sessionTable.length AS UNSIGNED)) AS 'timeSum', GROUP_CONCAT(sessionTable.length) AS 'medianSessionLength', SUM(sessionTable.length >= 60) AS 'longSessions', SUM(sessionTable.length < 60) AS 'shortSessions'
FROM ".self::getBoundedTableQueryString('~session-length', $from, $to, $lowerTimeBound, $upperTimeBound)." sessionTable
INNER JOIN machine ON sessionTable.machineuuid = machine.machineuuid
LEFT JOIN location ON machine.locationid = location.locationid
diff --git a/modules-available/statistics_reporting/templates/table-client.html b/modules-available/statistics_reporting/templates/table-client.html
index 2fb2f574..be504cef 100644
--- a/modules-available/statistics_reporting/templates/table-client.html
+++ b/modules-available/statistics_reporting/templates/table-client.html
@@ -17,11 +17,11 @@
{{hostname}} |
{{location}} |
- {{time_s}} |
- {{medianTime_s}} |
- {{sessions}} |
+ {{totalTime_s}} |
+ {{medianSessionLength_s}} |
+ {{longSessions}} |
{{shortSessions}} |
- {{offTime_s}} |
+ {{totalOffTime_s}} |
{{lastLogout_s}} |
{{lastStart_s}} |
diff --git a/modules-available/statistics_reporting/templates/table-location.html b/modules-available/statistics_reporting/templates/table-location.html
index 9479b7af..ccac623d 100644
--- a/modules-available/statistics_reporting/templates/table-location.html
+++ b/modules-available/statistics_reporting/templates/table-location.html
@@ -13,11 +13,11 @@
{{#data}}
{{location}} |
- {{time_s}} |
- {{medianTime_s}} |
- {{sessions}} |
+ {{totalTime_s}} |
+ {{medianSessionLength_s}} |
+ {{longSessions}} |
{{shortSessions}} |
- {{offTime_s}} |
+ {{totalOffTime_s}} |
{{/data}}
diff --git a/modules-available/statistics_reporting/templates/table-total.html b/modules-available/statistics_reporting/templates/table-total.html
index e59dda25..4048a178 100644
--- a/modules-available/statistics_reporting/templates/table-total.html
+++ b/modules-available/statistics_reporting/templates/table-total.html
@@ -12,11 +12,11 @@
{{lang_total}} |
- {{data.time_s}} |
- {{data.medianTime_s}} |
- {{data.sessions}} |
+ {{data.totalTime_s}} |
+ {{data.medianSessionLength_s}} |
+ {{data.longSessions}} |
{{data.shortSessions}} |
- {{data.totalOfftime_s}} |
+ {{data.totalOffTime_s}} |
--
cgit v1.2.3-55-g7522