summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/statistics')
-rw-r--r--modules-available/statistics/inc/filter.inc.php13
-rw-r--r--modules-available/statistics/lang/de/messages.json1
-rw-r--r--modules-available/statistics/lang/de/template-tags.json1
-rw-r--r--modules-available/statistics/lang/en/messages.json1
-rw-r--r--modules-available/statistics/lang/en/template-tags.json1
-rw-r--r--modules-available/statistics/page.inc.php37
-rw-r--r--modules-available/statistics/templates/clientlist.html47
-rw-r--r--modules-available/statistics/templates/filterbox.html1
-rw-r--r--modules-available/statistics/templates/machine-main.html2
9 files changed, 93 insertions, 11 deletions
diff --git a/modules-available/statistics/inc/filter.inc.php b/modules-available/statistics/inc/filter.inc.php
index 6e437a71..be6df752 100644
--- a/modules-available/statistics/inc/filter.inc.php
+++ b/modules-available/statistics/inc/filter.inc.php
@@ -208,15 +208,22 @@ class LocationFilter extends Filter
public function whereClause(&$args, &$joins)
{
+ $recursive = (substr($this->operator, -1) === '~');
+ $this->operator = str_replace('~', '=', $this->operator);
+
settype($this->argument, 'int');
+ $neg = $this->operator === '=' ? '' : 'NOT';
if ($this->argument === 0) {
- $neg = $this->operator === '=' ? '' : 'NOT';
return "machine.locationid IS $neg NULL";
} else {
global $unique_key;
$key = $this->column . '_arg' . ($unique_key++);
- $args[$key] = $this->argument;
- return "machine.locationid {$this->operator} :$key";
+ if ($recursive) {
+ $args[$key] = array_keys(Location::getRecursiveFlat($this->argument));
+ } else {
+ $args[$key] = $this->argument;
+ }
+ return "machine.locationid $neg IN (:$key)";
}
}
}
diff --git a/modules-available/statistics/lang/de/messages.json b/modules-available/statistics/lang/de/messages.json
index e3dff61c..c9667f7b 100644
--- a/modules-available/statistics/lang/de/messages.json
+++ b/modules-available/statistics/lang/de/messages.json
@@ -1,4 +1,5 @@
{
+ "deleted-n-machines": "{{0}} Clients gel\u00f6scht",
"invalid-filter-argument": "Das Argument {{1}} ist nicht g\u00fcltig f\u00fcr den Filter {{0}}",
"invalid-filter-key": "{{0}} ist kein g\u00fcltiges Filterkriterium",
"notes-saved": "Anmerkungen gespeichert",
diff --git a/modules-available/statistics/lang/de/template-tags.json b/modules-available/statistics/lang/de/template-tags.json
index 56cf55d7..3cdde813 100644
--- a/modules-available/statistics/lang/de/template-tags.json
+++ b/modules-available/statistics/lang/de/template-tags.json
@@ -74,6 +74,7 @@
"lang_showVisualization": "Visualisierung",
"lang_sockets": "Sockel",
"lang_subnet": "Subnetz",
+ "lang_sureDeletePermanent": "M\u00f6chten Sie diese(n) Rechner wirklich unwiderruflich aus der Datenbank entfernen?\r\n\r\nWichtig: L\u00f6schen verhindert nicht, dass ein Rechner nach erneutem Starten von bwLehrpool wieder in die Datenbank aufgenommen wird.",
"lang_tempPart": "Temp. Partition",
"lang_tempPartStats": "Tempor\u00e4re Partition",
"lang_thoseAreProjectors": "Diese Modellnamen werden als Beamer behandelt, auch wenn die EDID-Informationen des Ger\u00e4tes anderes berichten.",
diff --git a/modules-available/statistics/lang/en/messages.json b/modules-available/statistics/lang/en/messages.json
index ae6c47af..3471c472 100644
--- a/modules-available/statistics/lang/en/messages.json
+++ b/modules-available/statistics/lang/en/messages.json
@@ -1,4 +1,5 @@
{
+ "deleted-n-machines": "Deleted {{0}} clients",
"invalid-filter-argument": "{{1}} is not a vald argument for filter {{0}}",
"invalid-filter-key": "{{0}} is not a valid filter",
"notes-saved": "Notes have been saved",
diff --git a/modules-available/statistics/lang/en/template-tags.json b/modules-available/statistics/lang/en/template-tags.json
index ab7a7d0a..35c4e68a 100644
--- a/modules-available/statistics/lang/en/template-tags.json
+++ b/modules-available/statistics/lang/en/template-tags.json
@@ -74,6 +74,7 @@
"lang_showVisualization": "Visualization",
"lang_sockets": "Sockets",
"lang_subnet": "Subnet",
+ "lang_sureDeletePermanent": "Are your sure you want to delete the selected machine(s) from the database? This cannot be undone.\r\n\r\nNote: Deleting machines from the database does not prevent booting up bwLehrpool again, which would recreate their respective database entries.",
"lang_tempPart": "Temp. partition",
"lang_tempPartStats": "Temporary partition",
"lang_thoseAreProjectors": "These model names will always be treated as beamers, even if the device's EDID data says otherwise.",
diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php
index fafa7cd2..c3ecf52b 100644
--- a/modules-available/statistics/page.inc.php
+++ b/modules-available/statistics/page.inc.php
@@ -111,12 +111,12 @@ class Page_Statistics extends Page
'op' => Page_Statistics::$op_nominal,
'type' => 'enum',
'column' => true,
- 'values' => ['occupied', 'on']
+ 'values' => ['occupied', 'on', 'off', 'idle', 'standby']
]
];
if (Module::isAvailable('locations')) {
Page_Statistics::$columns['location'] = [
- 'op' => Page_Statistics::$op_nominal,
+ 'op' => Page_Statistics::$op_stringcmp,
'type' => 'enum',
'column' => false,
'values' => array_keys(Location::getLocationsAssoc()),
@@ -195,6 +195,35 @@ class Page_Statistics extends Page
Util::redirect('?do=Statistics&uuid=' . $uuid);
} elseif ($action === 'addprojector' || $action === 'delprojector') {
$this->handleProjector($action);
+ } elseif ($action === 'delmachines') {
+ $this->deleteMachines();
+ Util::redirect('?do=statistics', true);
+ }
+ }
+
+ private function deleteMachines()
+ {
+ $ids = Request::post('uuid', [], 'array');
+ $ids = array_values($ids);
+ if (empty($ids)) {
+ Message::addError('main.parameter-empty', 'uuid');
+ return;
+ }
+ $res = Database::simpleQuery('SELECT machineuuid, locationid FROM machine WHERE machineuuid IN (:ids)', compact('ids'));
+ $ids = array_flip($ids);
+ $delete = [];
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ // TODO: Check locationid permissions
+ unset($ids[$row['machineuuid']]);
+ $delete[] = $row['machineuuid'];
+ }
+ if (!empty($delete)) {
+ Database::exec('DELETE FROM machine WHERE machineuuid IN (:delete)', compact('delete'));
+ Message::addSuccess('deleted-n-machines', count($delete));
+ }
+ if (!empty($ids)) {
+ // TODO: Warn permissions
+ Message::addWarning('unknown-machine', implode(', ', array_keys($ids)));
}
}
@@ -575,6 +604,7 @@ class Page_Statistics extends Page
*/
private function showMachineList($filterSet)
{
+ Module::isAvailable('js_stupidtable');
$filterSet->makeFragments($where, $join, $sort, $args);
$xtra = '';
@@ -638,7 +668,8 @@ class Page_Statistics extends Page
'sortColumn' => $filterSet->getSortColumn(),
'columns' => json_encode(Page_Statistics::$columns),
'showList' => 1,
- 'show' => 'list'
+ 'show' => 'list',
+ 'redirect' => $_SERVER['QUERY_STRING']
));
}
diff --git a/modules-available/statistics/templates/clientlist.html b/modules-available/statistics/templates/clientlist.html
index 01ca82f1..13e148fa 100644
--- a/modules-available/statistics/templates/clientlist.html
+++ b/modules-available/statistics/templates/clientlist.html
@@ -1,6 +1,10 @@
+<h2>{{lang_clientList}} ({{rowCount}})</h2>
-<table class="stupidtable table table-condensed table-striped">
+<form method="post" action="?do=statistics">
+<input type="hidden" name="token" value="{{token}}">
+<input type="hidden" name="redirect" value="?{{redirect}}">
+<table class="stupidtable table table-condensed table-striped">
<thead>
<tr>
<td></td>
@@ -45,6 +49,10 @@
{{#rows}}
<tr>
<td data-sort-value="{{hostname}}" class="text-nowrap">
+ <div class="checkbox checkbox-inline">
+ <input type="checkbox" name="uuid[]" value="{{machineuuid}}">
+ <label></label>
+ </div>
{{#hasnotes}}<span class="glyphicon glyphicon-exclamation-sign pull-right"></span>{{/hasnotes}}
{{#state_OFFLINE}}
<span class="glyphicon glyphicon-off" title="{{lang_machineOff}}"></span>
@@ -68,10 +76,10 @@
<td data-sort-value="{{gbram}}" class="text-right {{ramclass}}">{{gbram}}&thinsp;GiB</td>
<td data-sort-value="{{gbtmp}}" class="text-right {{hddclass}}">
{{gbtmp}}&thinsp;GiB
- {{#badsectors}}<div>
- <span class="glyphicon glyphicon-exclamation-sign" data-toggle="tooltip" title="{{lang_reallocatedSectors}}" data-placement="left"></span>
+ {{#badsectors}}<div><span data-toggle="tooltip" title="{{lang_reallocatedSectors}}" data-placement="left">
+ <span class="glyphicon glyphicon-exclamation-sign"></span>
{{badsectors}}
- </div>{{/badsectors}}
+ </span></div>{{/badsectors}}
{{#nohdd}}<div>
<span class="glyphicon glyphicon-hdd red"></span>
</div>{{/nohdd}}
@@ -81,6 +89,37 @@
{{/rows}}
</tbody>
</table>
+ <div class="text-right buttonbar">
+ <button type="reset" class="btn btn-default">
+ <span class="glyphicon glyphicon-remove"></span>
+ {{lang_reset}}
+ </button>
+ <button type="button" class="btn btn-danger" onclick="$('#del-confirm').modal()">
+ <span class="glyphicon glyphicon-trash"></span>
+ {{lang_delete}}
+ </button>
+ </div>
+ <div class="modal fade" id="del-confirm" tabindex="-1" role="dialog">
+ <div class="modal-dialog" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal">&times;</button>
+ <b>{{lang_delete}}</b>
+ </div>
+ <div class="modal-body">
+ {{lang_sureDeletePermanent}}
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default" data-dismiss="modal">{{lang_cancel}}</button>
+ <button type="submit" class="btn btn-danger" name="action" value="delmachines">
+ <span class="glyphicon glyphicon-trash"></span>
+ {{lang_delete}}
+ </button>
+ </div>
+ </div>
+ </div>
+ </div>
+</form>
<script type="application/javascript"><!--
document.addEventListener("DOMContentLoaded", function () {
diff --git a/modules-available/statistics/templates/filterbox.html b/modules-available/statistics/templates/filterbox.html
index c2630ed9..31daabc6 100644
--- a/modules-available/statistics/templates/filterbox.html
+++ b/modules-available/statistics/templates/filterbox.html
@@ -170,6 +170,7 @@ document.addEventListener("DOMContentLoaded", function () {
$('#argumentInput').datepicker({format : 'yyyy-mm-dd'});
$('#argumentSelect').hide();
} else if(columns[col]['type'] == 'enum') {
+ $('#argumentSelect').empty();
$('#argumentInput').hide();
$('#argumentSelect').show();
columns[col]['values'].forEach(function (v) {
diff --git a/modules-available/statistics/templates/machine-main.html b/modules-available/statistics/templates/machine-main.html
index 14d388d3..19deb8b3 100644
--- a/modules-available/statistics/templates/machine-main.html
+++ b/modules-available/statistics/templates/machine-main.html
@@ -84,7 +84,7 @@
<tr>
<td class="text-nowrap">{{lang_runMode}}</td>
<td>
- <a href="?do={{modeid}}">{{moduleName}}</a> – {{modeName}}
+ <a href="?do=runmode&amp;module={{module}}">{{moduleName}}</a> – {{modeName}}
</td>
</tr>
{{/modeid}}