Fixes sorting on IP Address columns in tables.

The jQuery tablesorter plugin was choosing the digit parser
instead of the ipAddress parser for the IP Address columns.
This caused those columns to not sort correctly since only the
first 2 octects were looked at for sorting.

This patch adds an 'ip' data attribute to these columns and
updates the set_table_sorting function to set the ipAddress
sorter when this attribute is present.

Fixes bug 1108085

Change-Id: I3ca05048ce43b5bda14a4c586146c7ec9e479a79
This commit is contained in:
James Slagle 2013-04-18 19:26:01 -04:00
parent e4541a6175
commit ae2a456a34
5 changed files with 15 additions and 4 deletions

View File

@ -254,6 +254,10 @@ $(parent).find("table.datatable").each(function () {
// set as [i-1] as there is one more <th> in <thead>
// than <td>'s in <tbody>
header_options[i-1] = {sorter: 'sizeSorter'};
} else if ($th.data('type') == 'ip'){
// set as [i-1] as there is one more <th> in <thead>
// than <td>'s in <tbody>
header_options[i-1] = {sorter: 'ipAddress'};
}
});
$table.tablesorter({

View File

@ -89,7 +89,9 @@ class AdminInstancesTable(tables.DataTable):
name = tables.Column("name",
link=("horizon:admin:instances:detail"),
verbose_name=_("Name"))
ip = tables.Column(get_ips, verbose_name=_("IP Address"))
ip = tables.Column(get_ips,
verbose_name=_("IP Address"),
attrs={'data-type': "ip"})
size = tables.Column(get_size,
verbose_name=_("Size"),
classes=('nowrap-col',),

View File

@ -111,7 +111,9 @@ def get_instance_link(datum):
class FloatingIPsTable(tables.DataTable):
ip = tables.Column("ip", verbose_name=_("IP Address"))
ip = tables.Column("ip",
verbose_name=_("IP Address"),
attrs={'data-type': "ip"})
instance = tables.Column(get_instance_info,
link=get_instance_link,
verbose_name=_("Instance"),

View File

@ -454,7 +454,9 @@ class InstancesTable(tables.DataTable):
name = tables.Column("name",
link=("horizon:project:instances:detail"),
verbose_name=_("Instance Name"))
ip = tables.Column(get_ips, verbose_name=_("IP Address"))
ip = tables.Column(get_ips,
verbose_name=_("IP Address"),
attrs={'data-type': "ip"})
size = tables.Column(get_size,
verbose_name=_("Size"),
attrs={'data-type': 'size'})

View File

@ -136,7 +136,8 @@ def get_member_link(member):
class MembersTable(tables.DataTable):
address = tables.Column('address',
verbose_name=_("IP Address"),
link=get_member_link)
link=get_member_link,
attrs={'data-type': "ip"})
protocol_port = tables.Column('protocol_port',
verbose_name=_("Protocol Port"))
pool_name = tables.Column("pool_name",