summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics_reporting
diff options
context:
space:
mode:
authorUdo Walter2017-01-16 18:59:46 +0100
committerUdo Walter2017-01-16 18:59:46 +0100
commit9cd078d34d5f3172e8e770fce3c3ec7d6445a460 (patch)
treeeb549108705ae18d9c7000a5116ef8a8e0bd420f /modules-available/statistics_reporting
parent[statistics_reporting] improved anonymization (diff)
downloadslx-admin-9cd078d34d5f3172e8e770fce3c3ec7d6445a460.tar.gz
slx-admin-9cd078d34d5f3172e8e770fce3c3ec7d6445a460.tar.xz
slx-admin-9cd078d34d5f3172e8e770fce3c3ec7d6445a460.zip
[statistics_reporting] added ui to disable the reporting
Diffstat (limited to 'modules-available/statistics_reporting')
-rw-r--r--modules-available/statistics_reporting/lang/de/template-tags.json4
-rw-r--r--modules-available/statistics_reporting/lang/en/template-tags.json4
-rw-r--r--modules-available/statistics_reporting/page.inc.php45
-rw-r--r--modules-available/statistics_reporting/style.css4
-rw-r--r--modules-available/statistics_reporting/templates/columnChooser.html46
5 files changed, 85 insertions, 18 deletions
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 @@
<div id="upper-handle" class="ui-slider-handle"></div>
</div>
<button id="applybound" type="button" class="btn btn-sm btn-primary" onclick="reloadPage()">{{lang_apply}}</button>
+ <button id="button-settings" type="button" class="pull-right btn btn-default" data-toggle="modal" data-target="#modal-settings" onclick="loadSettings()"><span class="glyphicon glyphicon-cog"></span></button>
</div>
<div class="col-md-12 buttonbar">
<button id="button-location" type="button" class="column-toggle btn btn-primary" onclick="toggleButton('location')">{{lang_location}}</button>
@@ -37,6 +38,30 @@
</div>
</div>
+
+<div id="modal-settings" class="modal fade" role="dialog">
+ <div class="modal-dialog">
+
+ <!-- Modal content-->
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal">&times;</button>
+ <h4 class="modal-title"><b>Settings</b></h4>
+ </div>
+ <div class="modal-body">
+ <label class="checkbox-inline" style="padding-left: 40px">
+ <input id="checkbox-reporting" type="checkbox" value="" style="margin-top: 0; margin-left: -30px">
+ {{lang_reportingDescription}}
+ </label>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="saveSettings()">{{lang_save}}</button>
+ </div>
+ </div>
+
+ </div>
+</div>
+
<script type="application/javascript">
document.addEventListener("DOMContentLoaded", function () {
var lowerHandle = $("#lower-handle");
@@ -87,7 +112,7 @@
$("tr").removeAttr('style');
$("[id^=table-]").hide();
$('#table-'+v).show();
- $("[id^=button-]").hide();
+ $('.buttonbar').find("[id^=button-]").hide();
var re = /column-(\w+)/g;
var match;
while (match = re.exec($('thead', '#table-'+v).html())) {
@@ -149,4 +174,23 @@
}
return(false);
}
+
+ function loadSettings() {
+ $.ajax({
+ url: '?do=statistics_reporting',
+ type: 'GET',
+ data: { action: "getReporting"},
+ success: function(value) {
+ $("#checkbox-reporting").prop("checked", value == "on");
+ }
+ });
+ }
+
+ function saveSettings() {
+ $.ajax({
+ url: '?do=statistics_reporting',
+ type: 'GET',
+ data: { action: "setReporting", reporting: $("#checkbox-reporting").is(":checked") ? "on" : "off" }
+ });
+ }
</script> \ No newline at end of file