diff options
author | Simon Rettberg | 2016-08-15 16:31:54 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-08-15 16:31:54 +0200 |
commit | fce78a63a56f42920ac40bbf76e67412933c8376 (patch) | |
tree | 2baaff59dbce85d56f07da6f617058cbe0e6750f /modules-available/statistics/templates/clientlist.html | |
parent | Update translations (diff) | |
download | slx-admin-fce78a63a56f42920ac40bbf76e67412933c8376.tar.gz slx-admin-fce78a63a56f42920ac40bbf76e67412933c8376.tar.xz slx-admin-fce78a63a56f42920ac40bbf76e67412933c8376.zip |
[statistics] Fix list view and sorting
Broken when moving JS snippets around
Diffstat (limited to 'modules-available/statistics/templates/clientlist.html')
-rw-r--r-- | modules-available/statistics/templates/clientlist.html | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/modules-available/statistics/templates/clientlist.html b/modules-available/statistics/templates/clientlist.html index f2a6ba03..3a1b52ac 100644 --- a/modules-available/statistics/templates/clientlist.html +++ b/modules-available/statistics/templates/clientlist.html @@ -87,3 +87,40 @@ </tr> {{/rows}} </table> + +<script type="application/javascript"><!-- +document.addEventListener("DOMContentLoaded", function () { + ['gbram', 'hddgb', 'realcores', 'kvmstate', 'lastseen', 'clientip'].forEach(function (v) { + var $sortBtn = $('#sortButton-' + v); + var order = 'up'; /* default */ + if ($('#sortColumn').val() == v) { + $sortBtn.addClass('btn-success'); + order = $('#sortDirection').val() == 'ASC' ? 'up' : 'down'; + } + $sortBtn.html('<span class="glyphicon glyphicon-arrow-' + order + '"></span>'); + $sortBtn.attr('onclick', 'toggleButton(\'' + v + '\');'); + }); +}); + +function toggleButton(v) { + var $sortBtn = $('#sortButton-' + v); + var $col = $('#sortColumn'); + var $dir = $('#sortDirection'); + if ($col.val() == v) { + /* toggle direction */ + var newDir = $dir.val() == 'ASC' ? 'DESC' : 'ASC'; + $dir.val(newDir); + /* update button */ + var order = newDir == 'ASC' ? 'up' : 'down'; + $sortBtn.html('<span class="glyphicon glyphicon-arrow-' + order + '"></span>'); + } else { + /* remove "btn-success" from current sorting */ + $('#sortButton-'+v).removeClass('btn-success'); + $sortBtn.addClass('btn-success'); + $col.val(v); + $dir = 'ASC'; + } + $queryForm.submit(); +} + +//--></script>
\ No newline at end of file |