Always sort empty rows to the bottom of the table

Signed-off-by: Graham <gpe@openrs2.org>
Graham 2 years ago
parent 55072a5102
commit 62df015ad5
  1. 32
      archive/src/main/resources/org/openrs2/archive/static/js/openrs2.js
  2. 6
      archive/src/main/resources/org/openrs2/archive/templates/caches/index.html

@ -1,14 +1,36 @@
var buildRegex = new RegExp('>([0-9]+)(?:[.]([0-9]+))?<');
function buildSort(a, b) {
a = buildRegex.exec(a);
b = buildRegex.exec(b);
function customSort(name, order, data) {
order = order === 'asc' ? 1 : -1;
data.sort(function (a, b) {
a = a[name];
b = b[name];
if (!a) {
return -1;
} else if (!b) {
return 1;
} else if (!b) {
return -1;
}
if (name === 'builds') {
return buildSort(a, b) * order;
} else {
if (a < b) {
return -order;
} else if (a === b) {
return 0;
} else {
return order;
}
}
});
}
function buildSort(a, b) {
a = buildRegex.exec(a);
b = buildRegex.exec(b);
var aMajor = parseInt(a[1]);
var bMajor = parseInt(b[1]);
if (aMajor !== bMajor) {

@ -12,13 +12,13 @@
<main class="container">
<h1>Caches</h1>
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" data-toggle="table" data-filter-control="true" data-sticky-header="true">
<table class="table table-striped table-bordered table-hover" data-toggle="table" data-filter-control="true" data-sticky-header="true" data-custom-sort="customSort">
<thead class="table-dark">
<tr>
<th data-field="game" data-filter-control="select">Game</th>
<th data-field="environment" data-filter-control="select">Env</th>
<th data-field="language" data-filter-control="select">Lang</th>
<th data-field="builds" data-filter-control="input" data-sortable="true" data-sorter="buildSort">Build(s)</th>
<th data-field="builds" data-filter-control="input" data-sortable="true">Build(s)</th>
<th data-field="timestamp" data-sortable="true">Timestamp</th>
<th data-field="sources" data-filter-control="input">Source(s)</th>
<th>Archives</th>
@ -41,9 +41,11 @@
</span>
</td>
<td>
<span th:if="${cache.timestamp}" th:remove="tag">
<span th:text="${#temporals.format(cache.timestamp, 'yyyy-MM-dd')}"></span>
<br />
<span th:text="${#temporals.format(cache.timestamp, 'HH:mm:ss')}"></span>
</span>
</td>
<td th:text="${#strings.setJoin(cache.sources, ', ')}"></td>
<td th:classappend="${cache.stats}? (${cache.stats.allIndexesValid}? 'table-success' : 'table-danger')"

Loading…
Cancel
Save