summaryrefslogtreecommitdiffstats
path: root/modules-available
diff options
context:
space:
mode:
authorSimon Rettberg2016-07-13 17:55:21 +0200
committerSimon Rettberg2016-07-13 17:55:21 +0200
commit28365aa243bb84d896c2058b33893e8e501f22d3 (patch)
tree7ece9bd5d506b156e6655bf04c846a81143383c3 /modules-available
parent[statistics] Change delimiter to something more unusual, add captions for fil... (diff)
downloadslx-admin-28365aa243bb84d896c2058b33893e8e501f22d3.tar.gz
slx-admin-28365aa243bb84d896c2058b33893e8e501f22d3.tar.xz
slx-admin-28365aa243bb84d896c2058b33893e8e501f22d3.zip
[statistics] Add location to filter dropdown list
Diffstat (limited to 'modules-available')
-rw-r--r--modules-available/statistics/page.inc.php20
-rw-r--r--modules-available/statistics/templates/clientlist.html19
-rw-r--r--modules-available/statistics/templates/machine-main.html7
3 files changed, 37 insertions, 9 deletions
diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php
index 31ff280f..e4a47ca5 100644
--- a/modules-available/statistics/page.inc.php
+++ b/modules-available/statistics/page.inc.php
@@ -15,7 +15,6 @@ class Page_Statistics extends Page
/* some constants, TODO: Find a better place */
public static $op_nominal;
public static $op_ordinal;
- public static $op_element;
public static $op_stringcmp;
public static $columns;
@@ -24,7 +23,6 @@ class Page_Statistics extends Page
{
Page_Statistics::$op_nominal = ['!=', '='];
Page_Statistics::$op_ordinal = ['!=', '<=', '>=', '=', '<', '>'];
- Page_Statistics::$op_element = ['in', 'not in'];
Page_Statistics::$op_stringcmp = ['!~', '~', '=', '!='];
Page_Statistics::$columns = [
@@ -107,6 +105,14 @@ class Page_Statistics extends Page
'column' => false
]
];
+ if (Module::isAvailable('locations')) {
+ Page_Statistics::$columns['location'] = [
+ 'op' => Page_Statistics::$op_nominal,
+ 'type' => 'enum',
+ 'column' => false,
+ 'values' => array_keys(Location::getLocationsAssoc()),
+ ];
+ }
/* TODO ... */
}
@@ -539,6 +545,15 @@ class Page_Statistics extends Page
}
$rows[] = $row;
}
+ $locsFlat = array();
+ if (Module::isAvailable('locations')) {
+ foreach (Location::getLocations() as $loc) {
+ $locsFlat['L' . $loc['locationid']] = array(
+ 'pad' => $loc['locationpad'],
+ 'name' => $loc['locationname']
+ );
+ }
+ }
Render::addTemplate('clientlist', array(
'rows' => $rows,
'filter' => $filter,
@@ -548,6 +563,7 @@ class Page_Statistics extends Page
'sortColumn' => $sortColumn,
'argument' => $argument,
'columns' => json_encode(Page_Statistics::$columns),
+ 'locations' => json_encode($locsFlat),
));
}
diff --git a/modules-available/statistics/templates/clientlist.html b/modules-available/statistics/templates/clientlist.html
index 57ec7f64..664d5413 100644
--- a/modules-available/statistics/templates/clientlist.html
+++ b/modules-available/statistics/templates/clientlist.html
@@ -151,9 +151,12 @@ var slxFilterNames = {
kvmstate: '{{lang_kvmSupport}}',
badsectors: '{{lang_reallocatedSectors}}',
clientip: '{{lang_ip}}',
- state: '{{lang_usageState}}'
+ state: '{{lang_usageState}}',
+ location: '{{lang_location}}'
};
+slxLocations = {{{locations}}};
+
var slxFilterDel = '{{delimiter}}';
@@ -188,7 +191,7 @@ document.addEventListener("DOMContentLoaded", function () {
})[0].selectize;
/* add query */
var str = "{{{query}}}";
- var eExp = /^(\w+)\s*([=><!]+)\s*(.*)$/;
+ var eExp = /^(\w+)\s*([=><!~]+)\s*(.*)$/;
str.split(slxFilterDel).forEach(function(v) {
var match = eExp.exec(v);
if (match && match.length === 4) {
@@ -217,7 +220,11 @@ document.addEventListener("DOMContentLoaded", function () {
$('#argumentInput').hide();
$('#argumentSelect').show();
columns[col]['values'].forEach(function (v) {
- $('#argumentSelect').append($('<option>', { value: v, text: v }));
+ var t = v;
+ if (col === 'location' && slxLocations['L' + v]) {
+ t = slxLocations['L' + v].pad + ' ' + slxLocations['L' + v].name;
+ }
+ $('#argumentSelect').append($('<option>', { value: v, text: t }));
});
} else {
$('#argumentInput').datepicker('remove');
@@ -288,8 +295,12 @@ function addFilterFromForm() {
function addFilter(col, op, argument) {
var filterValue = col + ' ' + op + ' ' + argument;
var filterText = filterValue;
+ var displayArgument = argument;
+ if (col === 'location' && slxLocations['L' + argument]) {
+ displayArgument = slxLocations['L' + argument].name;
+ }
if (slxFilterNames[col]) {
- filterText = slxFilterNames[col] + ' ' + op + ' ' + argument;
+ filterText = slxFilterNames[col] + ' ' + op + ' ' + displayArgument;
}
filterSelectize.addOption({value: filterValue, text: filterText});
filterSelectize.addItem(filterValue);
diff --git a/modules-available/statistics/templates/machine-main.html b/modules-available/statistics/templates/machine-main.html
index daff724e..f76b5770 100644
--- a/modules-available/statistics/templates/machine-main.html
+++ b/modules-available/statistics/templates/machine-main.html
@@ -2,11 +2,12 @@
{{hostname}} {{#hostname}}–{{/hostname}} {{clientip}}
{{#notes}}<a href="#usernotes"><span class="glyphicon glyphicon-exclamation-sign"></span></a>{{/notes}}
</h1>
-<div>
+<ol class="breadcrumb">
{{#locations}}
- &raquo; <a href="?do=statistics&amp;filter=location&amp;argument={{locationid}}">{{locationname}}</a>
+ <li><a href="?do=statistics&amp;show=list&amp;filters=location={{locationid}}">{{locationname}}</a></li>
{{/locations}}
-</div>
+ <li class="active">{{hostname}} {{^hostname}} {{clientip}} {{/hostname}}</li>
+</ol>
<div class="row">
<div class="col-md-6">