summaryrefslogtreecommitdiff
path: root/openstack_dashboard/dashboards/project/instances/views.py
diff options
context:
space:
mode:
authorFerenc Cserepkei <ferenc.cserepkei@ericsson.com>2017-08-25 19:53:42 +0200
committerAkihiro Motoki <amotoki@gmail.com>2018-12-28 20:46:11 +0900
commit467669417979ec7443d5195d4b4635d5596cdc08 (patch)
tree7b4782a1e8fa55d3df239743f2619041337cfcb0 /openstack_dashboard/dashboards/project/instances/views.py
parent87e2cf67fa6f71b77e70915539b93f4b86382eab (diff)
downloadhorizon-467669417979ec7443d5195d4b4635d5596cdc08.tar.gz
Add "prev" link to instance page list pagination
Currently there is no link to previous page at paginated instances table. This patch resolves that issue by re-using the pagination code for flavors. It also supports Ying Zuo's scenario: After I set only 1 item per page and deleted the instance on the first page, the expected behavior is showing the next instance in the table after one is deleted. xxxIndexView uses PagedTableMixin's _get_marker() from now instead of GET()- ing the markers Closes-Bug: #1274427 Co-Authored-By: Dmitry Ratushnyy <dratushn@cisco.com> Co-Authored-By: Akihiro Motoki <amotoki@gmail.com> Change-Id: Id8eaae6bf1b5d6f42291291655e14b8715c08bc8 Signed-off-by: Ferenc Cserepkei <ferenc.cserepkei@ericsson.com>
Diffstat (limited to 'openstack_dashboard/dashboards/project/instances/views.py')
-rw-r--r--openstack_dashboard/dashboards/project/instances/views.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/openstack_dashboard/dashboards/project/instances/views.py b/openstack_dashboard/dashboards/project/instances/views.py
index fa2e833b7..f17da0412 100644
--- a/openstack_dashboard/dashboards/project/instances/views.py
+++ b/openstack_dashboard/dashboards/project/instances/views.py
@@ -59,10 +59,13 @@ from openstack_dashboard.views import get_url_with_pagination
LOG = logging.getLogger(__name__)
-class IndexView(tables.DataTableView):
+class IndexView(tables.PagedTableMixin, tables.DataTableView):
table_class = project_tables.InstancesTable
page_title = _("Instances")
+ def has_prev_data(self, table):
+ return getattr(self, "_prev", False)
+
def has_more_data(self, table):
return self._more
@@ -85,13 +88,14 @@ class IndexView(tables.DataTableView):
exceptions.handle(self.request, ignore=True)
return {}
- def _get_instances(self, search_opts):
+ def _get_instances(self, search_opts, sort_dir):
try:
- instances, self._more = api.nova.server_list(
+ instances, self._more, self._prev = api.nova.server_list_paged(
self.request,
- search_opts=search_opts)
+ search_opts=search_opts,
+ sort_dir=sort_dir)
except Exception:
- self._more = False
+ self._more = self._prev = False
instances = []
exceptions.handle(self.request,
_('Unable to retrieve instances.'))
@@ -122,8 +126,7 @@ class IndexView(tables.DataTableView):
return instances
def get_data(self):
- marker = self.request.GET.get(
- project_tables.InstancesTable._meta.pagination_param, None)
+ marker, sort_dir = self._get_marker()
search_opts = self.get_filters({'marker': marker, 'paginate': True})
image_dict, flavor_dict = futurist_utils.call_functions_parallel(
@@ -137,7 +140,7 @@ class IndexView(tables.DataTableView):
self._more = False
return []
- instances = self._get_instances(search_opts)
+ instances = self._get_instances(search_opts, sort_dir)
# Loop through instances to get flavor info.
for instance in instances: