filter added for snapshots and types
volume snapshots table in both admin and project, volume types table in admin page are don't have filter option. this patch is adding the filter option on the above mentioned tables. Change-Id: Ib3d5f844b1ba96b15102f33d2aed126f4a1870bb Closes-Bug: #1332074
This commit is contained in:
parent
b0093f5193
commit
bd0924dec3
|
@ -18,7 +18,7 @@
|
|||
{% elif filter.filter_type == 'query' %}
|
||||
<div class="table_search client">
|
||||
<div class="form-group has-feedback">
|
||||
<input class="form-control" value="{{ filter.filter_string|default:'' }}" type="text" name="{{ filter.get_param_name }}" />
|
||||
<input class="form-control" value="{{ filter.filter_string|default:'' }}" type="text" name="{{ filter.get_param_name }}" placeholder="{% trans "Filter" %}"/>
|
||||
<span class="fa fa-search search-icon form-control-feedback"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -67,7 +67,8 @@ class VolumeSnapshotsTable(volumes_tables.VolumesTableBase):
|
|||
class Meta:
|
||||
name = "volume_snapshots"
|
||||
verbose_name = _("Volume Snapshots")
|
||||
table_actions = (snapshots_tables.DeleteVolumeSnapshot,)
|
||||
table_actions = (snapshots_tables.VolumeSnapshotsFilterAction,
|
||||
snapshots_tables.DeleteVolumeSnapshot,)
|
||||
row_actions = (snapshots_tables.DeleteVolumeSnapshot,
|
||||
UpdateVolumeSnapshotStatus,)
|
||||
row_class = UpdateRow
|
||||
|
|
|
@ -133,6 +133,15 @@ def get_volume_type_encryption(volume_type):
|
|||
return provider
|
||||
|
||||
|
||||
class VolumeTypesFilterAction(tables.FilterAction):
|
||||
|
||||
def filter(self, table, volume_types, filter_string):
|
||||
"""Naive case-insensitive search."""
|
||||
query = filter_string.lower()
|
||||
return [volume_type for volume_type in volume_types
|
||||
if query in volume_type.name.lower()]
|
||||
|
||||
|
||||
class VolumeTypesTable(tables.DataTable):
|
||||
name = tables.Column("name", verbose_name=_("Name"))
|
||||
assoc_qos_spec = tables.Column("associated_qos_spec",
|
||||
|
@ -152,7 +161,8 @@ class VolumeTypesTable(tables.DataTable):
|
|||
name = "volume_types"
|
||||
hidden_title = False
|
||||
verbose_name = _("Volume Types")
|
||||
table_actions = (CreateVolumeType, DeleteVolumeType,)
|
||||
table_actions = (VolumeTypesFilterAction, CreateVolumeType,
|
||||
DeleteVolumeType,)
|
||||
row_actions = (CreateVolumeTypeEncryption,
|
||||
ViewVolumeTypeExtras,
|
||||
ManageQosSpecAssociation,
|
||||
|
|
|
@ -133,6 +133,15 @@ class SnapshotVolumeNameColumn(tables.Column):
|
|||
return reverse(self.link, args=(volume_id,))
|
||||
|
||||
|
||||
class VolumeSnapshotsFilterAction(tables.FilterAction):
|
||||
|
||||
def filter(self, table, snapshots, filter_string):
|
||||
"""Naive case-insensitive search."""
|
||||
query = filter_string.lower()
|
||||
return [snapshot for snapshot in snapshots
|
||||
if query in snapshot.name.lower()]
|
||||
|
||||
|
||||
class VolumeSnapshotsTable(volume_tables.VolumesTableBase):
|
||||
name = tables.Column("name",
|
||||
verbose_name=_("Name"),
|
||||
|
@ -145,7 +154,7 @@ class VolumeSnapshotsTable(volume_tables.VolumesTableBase):
|
|||
class Meta:
|
||||
name = "volume_snapshots"
|
||||
verbose_name = _("Volume Snapshots")
|
||||
table_actions = (DeleteVolumeSnapshot,)
|
||||
table_actions = (VolumeSnapshotsFilterAction, DeleteVolumeSnapshot,)
|
||||
row_actions = (CreateVolumeFromSnapshot, LaunchSnapshot,
|
||||
EditVolumeSnapshot, DeleteVolumeSnapshot)
|
||||
row_class = UpdateRow
|
||||
|
|
Loading…
Reference in New Issue