Stop using naturalSort in hypervisors table
In some situations, JS's naturalSort sorts hypervisor_hostname in
an unusual order. For example, this is a usually ordered list:
east-01, east-02, west-01, west-02
while the result made by naturalSort is:
east-01, west-01, east-02, west-02
Also, this is inconsistent with the other tables as they are using
datatable's default sort. Actually, the default sort does natural
ordering to numbers in text. So we can use the default sort instead
of naturalSort without a problem.
As the hypervisor table is the only user of naturalSort, all stuff
for naturalSort were removed.
Closes-Bug: #1480563
(cherry picked from commit 3067584f71
)
Change-Id: I8df3ff72a33d194a5b6bc1692aac7878a611ae44
This commit is contained in:
parent
b45fb04264
commit
437b59794c
|
@ -305,28 +305,6 @@ $.tablesorter.addParser({
|
|||
type: "numeric"
|
||||
});
|
||||
|
||||
$.tablesorter.addParser({
|
||||
id: 'naturalSort',
|
||||
is: function(s) {
|
||||
return false;
|
||||
},
|
||||
// compare int values, non-integers use the ordinal value of the first byte
|
||||
format: function(s) {
|
||||
result = parseInt(s);
|
||||
if (isNaN(result)) {
|
||||
m = s.match(/\d+/);
|
||||
if (m && m.length) {
|
||||
return parseInt(m[0]);
|
||||
} else {
|
||||
return s.charCodeAt(0);
|
||||
}
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
},
|
||||
type: 'numeric'
|
||||
});
|
||||
|
||||
$.tablesorter.addParser({
|
||||
id: 'IPv4Address',
|
||||
is: function(s, table, cell) {
|
||||
|
@ -466,8 +444,6 @@ horizon.datatables.set_table_sorting = function (parent) {
|
|||
header_options[i] = {sorter: 'timesinceSorter'};
|
||||
} else if ($th.data('type') === 'timestamp'){
|
||||
header_options[i] = {sorter: 'timestampSorter'};
|
||||
} else if ($th.data('type') == 'naturalSort'){
|
||||
header_options[i] = {sorter: 'naturalSort'};
|
||||
} else if ($th.data('type') == 'uuid'){
|
||||
header_options[i] = {sorter: 'uuid'};
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ from horizon.templatetags import sizeformat
|
|||
class AdminHypervisorsTable(tables.DataTable):
|
||||
hostname = tables.Column("hypervisor_hostname",
|
||||
link="horizon:admin:hypervisors:detail",
|
||||
attrs={'data-type': 'naturalSort'},
|
||||
verbose_name=_("Hostname"))
|
||||
|
||||
hypervisor_type = tables.Column("hypervisor_type",
|
||||
|
|
Loading…
Reference in New Issue