Skip to content
Snippets Groups Projects
Commit 00b98cdb authored by Tim van Dijen's avatar Tim van Dijen
Browse files

Fix 'no data available' for Twig-template

parent 802ae561
No related branches found
No related tags found
No related merge requests found
......@@ -3,8 +3,8 @@ $this->data['header'] = 'SimpleSAMLphp Statistics';
$this->data['jquery'] = array('core' => true, 'ui' => true, 'css' => true);
$this->data['head'] = '<link rel="stylesheet" type="text/css" href="' . SimpleSAML\Module::getModuleURL("statistics/style.css") . '" />' . "\n";
$this->data['head'] .= '<script type="text/javascript" src="' . SimpleSAML\Module::getModuleURL("statistics/javascript.js") . '"></script>' . "\n";
$this->data['head'] = '<link rel="stylesheet" type="text/css" href="' . SimpleSAML\Module::getModuleURL("statistics/assets/statistics.css") . '" />' . "\n";
$this->data['head'] .= '<script type="text/javascript" src="' . SimpleSAML\Module::getModuleURL("statistics/assets/statistics.js") . '"></script>' . "\n";
$this->includeAtTemplateBase('includes/header.php');
......@@ -18,11 +18,15 @@ echo '<tr><td class="selecttime_icon"><img src="' . SimpleSAML\Utils\HTTP::getBa
// Select report
echo '<td>';
echo '<form action="#">';
echo $this->data['post_rule'];
if (!empty($this->data['available.rules'])) {
foreach ($this->data['post_rule'] as $k => $v) {
echo '<input type="hidden" name="' . $k . '" value="'. htmlspecialchars($v) . '" />' . "\n";
}
if (!empty($this->data['available_rules'])) {
echo '<select onchange="submit();" name="rule">';
foreach ($this->data['available.rules'] as $key => $rule) {
if ($key === $this->data['selected.rule']) {
foreach ($this->data['available_rules'] as $key => $rule) {
if ($key === $this->data['selected_rule']) {
echo '<option selected="selected" value="' . $key . '">' . $rule['name'] . '</option>';
} else {
echo '<option value="' . $key . '">' . $rule['name'] . '</option>';
......@@ -35,8 +39,12 @@ echo '</form></td>';
// Select delimiter
echo '<td class="td_right">';
echo '<form action="#">';
echo $this->data['post_d'];
if(!empty($this->data['availdelimiters'])) {
foreach($this->data['post_d'] as $k => $v) {
echo '<input type="hidden" name="' . $k . '" value="'. htmlspecialchars($v) . '" />' . "\n";
}
if (!empty($this->data['availdelimiters'])) {
echo '<select onchange="submit();" name="d">';
foreach ($this->data['availdelimiters'] as $key => $delim) {
$delimName = $delim;
......@@ -73,7 +81,11 @@ if (isset($this->data['available.times.prev'])) {
echo '<td class="td_right">';
echo '<form action="#">';
echo $this->data['post_res'];
foreach ($this->data['post_res'] as $k => $v) {
echo '<input type="hidden" name="' . $k . '" value="'. htmlspecialchars($v) . '" />' . "\n";
}
if (!empty($this->data['available.timeres'])) {
echo '<select onchange="submit();" name="res">';
foreach ($this->data['available.timeres'] as $key => $timeresname) {
......@@ -89,7 +101,11 @@ echo '</form></td>';
echo '<td class="td_left">';
echo '<form action="#">';
echo $this->data['post_time'];
foreach ($this->data['post_time'] as $k => $v) {
echo '<input type="hidden" name="' . $k . '" value="'. htmlspecialchars($v) . '" />' . "\n";
}
if (!empty($this->data['available.times'])) {
echo '<select onchange="submit();" name="time">';
foreach ($this->data['available.times'] as $key => $timedescr) {
......@@ -125,10 +141,14 @@ if (!empty($this->data['results'])){
echo '<form action="#">';
echo '<p class="p_right">Compare with total from this dataset ';
echo $this->data['post_rule2'];
foreach ($this->data['post_rule2'] as $k => $v) {
echo '<input type="hidden" name="' . $k . '" value="'. htmlspecialchars($v) . '" />' . "\n";
}
echo '<select onchange="submit();" name="rule2">';
echo ' <option value="_">None</option>';
foreach ($this->data['available.rules'] as $key => $rule) {
foreach ($this->data['available_rules'] as $key => $rule) {
if ($key === $this->data['selected.rule2']) {
echo '<option selected="selected" value="' . $key . '">' . $rule['name'] . '</option>';
} else {
......
......@@ -2,20 +2,11 @@
{% extends "base.twig" %}
{% block preload %}
<link href="{{ baseurlpath }}style.css" rel="stylesheet" />
<link href="{{ baseurlpath }}assets/statistics.css" rel="stylesheet" />
{% endblock %}
{% block postload %}
<script type="text/javascript">
$(document).ready(function() {
$("#tabdiv").tabs();
$('ul.tabset_tabs li').click(
function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
}
)
});
</script>
<script type="text/javascript" src="{{ baseurlpath }}assets/statistics.js"></script>
{% endblock %}
{% block content %}
......@@ -48,6 +39,7 @@
{% for key, value in post_d %}
<input type="hidden" name="{{ key|escape('html') }}" value="{{ value|escape('html') }}">
{% endfor %}
{% if availdelimiters %}
<select onchange="submit();" name="d">
{% for key, delim in availdelimiters %}
{% set delimName = delim %}
......@@ -65,6 +57,7 @@
{% endif %}
{% endfor %}
</select>
{% endif %}
</form>
</td>
</tr>
......@@ -85,6 +78,7 @@
{% for key, value in post_res %}
<input type="hidden" name="{{ key|escape('html') }}" value="{{ value|escape('html') }}">
{% endfor %}
{% if available_timeres %}
<select onchange="submit();" name="res">
{% for key, timeresname in available_timeres %}
{% if key == selected_timeres %}
......@@ -94,6 +88,7 @@
{% endif %}
{% endfor %}
</select>
{% endif %}
</form>
</td>
<td class="td_left">
......@@ -101,6 +96,7 @@
{% for key, value in post_time %}
<input type="hidden" name="{{ key|escape('html') }}" value="{{ value|escape('html') }}">
{% endfor %}
{% if available_times %}
<select onchange="submit();" name=time>
{% for key, timedescr in available_times %}
{% if key == selected_time %}
......@@ -110,6 +106,7 @@
{% endif%}
{% endfor %}
</select>
{% endif %}
</form>
</td>
{% if available_times_next %}
......@@ -121,6 +118,7 @@
</table>
<div id="tabdiv">
{% if results %}
<ul class="tabset_tabs">
<li class="tab-link current" data-tab="graph"><a href="#graph">Graph</a></li>
<li class="tab-link" data-tab="table"><a href="#table">Summary table</a></li>
......@@ -218,5 +216,9 @@
{% endfor %}
</table>
</div>
{% else %}
<h4 align="center">{{ error }}</h4>
<p align="center"><a href="showstats.php">Clear selection</a></p>
{% endif %}
</div>
{% endblock %}
$(document).ready(function() {
$("#tabdiv").tabs();
$('ul.tabset_tabs li').click(
function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
}
)
});
......@@ -46,10 +46,12 @@ $rule = $statrule->getRuleID();
$t = new \SimpleSAML\XHTML\Template($config, 'statistics:statistics.tpl.php');
$t->data['pageid'] = 'statistics';
$t->data['header'] = 'stat';
$t->data['available.rules'] = $ruleset->availableRulesNames();
$t->data['selected.rule'] = $rule;
$t->data['selected.rule2'] = $preferRule2;
$t->data['available_rules'] = $ruleset->availableRulesNames();
$t->data['selected_rule'] = $rule;
$t->data['selected_rule2'] = $preferRule2;
$t->data['post_d'] = getBaseURL($t, 'post', 'd');
try {
$dataset = $statrule->getDataset($preferTimeRes, $preferTime);
$dataset->setDelimiter($delimiter);
......@@ -67,6 +69,7 @@ try {
}
exit;
}
} catch (\Exception $e) {
$t->data['error'] = "No data available";
$t->show();
......@@ -135,18 +138,17 @@ $t->data['debugdata'] = $dataset->getDebugData();
$t->data['results'] = $dataset->getResults();
$t->data['summaryDataset'] = $dataset->getSummary();
$t->data['topdelimiters'] = $dataset->getTopDelimiters();
$t->data['availdelimiters'] = $dataset->availDelimiters();
$t->data['delimiterPresentation'] = $dataset->getDelimiterPresentation();
$t->data['post_rule'] = getBaseURL($t, 'post', 'rule');
$t->data['post_rule2'] = getBaseURL($t, 'post', 'rule2');
$t->data['post_d'] = getBaseURL($t, 'post', 'd');
$t->data['post_res'] = getBaseURL($t, 'post', 'res');
$t->data['post_time'] = getBaseURL($t, 'post', 'time');
$t->data['get_times_prev'] = getBaseURL($t, 'get', 'time', $t->data['available_times_prev']);
$t->data['get_times_next'] = getBaseURL($t, 'get', 'time', $t->data['available_times_next']);
$t->data['availdelimiters'] = $dataset->availDelimiters();
$t->data['delimiterPresentation'] = $dataset->getDelimiterPresentation();
$t->data['jquery'] = array('core' => false, 'ui' => true, 'css' => true);
$t->show();
......@@ -177,5 +179,6 @@ function getBaseURL($t, $type = 'get', $key = null, $value = null)
if ($type === 'get') {
return \SimpleSAML\Module::getModuleURL("statistics/showstats.php").'?'.http_build_query($vars, '', '&amp;');
}
return $vars;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment