From 27d24478aea0e8bf7c04df87a8969e1ec1972204 Mon Sep 17 00:00:00 2001 From: Aravindh-Raju Date: Wed, 1 Jun 2022 15:01:01 +0530 Subject: [PATCH 01/41] Add pagination in group view --- modules/api/src/main/resources/reference.conf | 4 +- .../api/route/MembershipRouting.scala | 2 +- .../tests/membership/list_my_groups_test.py | 43 ++-- .../src/test/functional/vinyldns_python.py | 2 +- .../portal/app/views/groups/groups.scala.html | 135 ++++++++++++- .../portal/app/views/zones/zones.scala.html | 16 +- modules/portal/public/css/vinyldns.css | 4 +- .../lib/controllers/controller.groups.js | 184 ++++++++++++++---- .../lib/controllers/controller.groups.spec.js | 70 ++++++- .../lib/controllers/controller.zones.js | 2 +- .../lib/controllers/controller.zones.spec.js | 2 +- .../lib/services/groups/service.groups.js | 9 +- 12 files changed, 377 insertions(+), 96 deletions(-) diff --git a/modules/api/src/main/resources/reference.conf b/modules/api/src/main/resources/reference.conf index b82cb74d6..aff3f95cc 100644 --- a/modules/api/src/main/resources/reference.conf +++ b/modules/api/src/main/resources/reference.conf @@ -110,8 +110,8 @@ vinyldns { limits { batchchange-routing-max-items-limit = 100 membership-routing-default-max-items = 100 - membership-routing-max-items-limit = 1000 - membership-routing-max-groups-list-limit = 1500 + membership-routing-max-items-limit = 100 + membership-routing-max-groups-list-limit = 100 recordset-routing-default-max-items= 100 zone-routing-default-max-items = 100 zone-routing-max-items-limit = 100 diff --git a/modules/api/src/main/scala/vinyldns/api/route/MembershipRouting.scala b/modules/api/src/main/scala/vinyldns/api/route/MembershipRouting.scala index 620c6d79f..1869e0d83 100644 --- a/modules/api/src/main/scala/vinyldns/api/route/MembershipRouting.scala +++ b/modules/api/src/main/scala/vinyldns/api/route/MembershipRouting.scala @@ -79,7 +79,7 @@ class MembershipRoute( } ~ (get & monitor("Endpoint.listMyGroups")) { parameters( - "startFrom".?, + "startFrom".as[String].?, "maxItems".as[Int].?(DEFAULT_MAX_ITEMS), "groupNameFilter".?, "ignoreAccess".as[Boolean].?(false), diff --git a/modules/api/src/test/functional/tests/membership/list_my_groups_test.py b/modules/api/src/test/functional/tests/membership/list_my_groups_test.py index cfcf557e8..516cdc76a 100644 --- a/modules/api/src/test/functional/tests/membership/list_my_groups_test.py +++ b/modules/api/src/test/functional/tests/membership/list_my_groups_test.py @@ -13,20 +13,11 @@ def test_list_my_groups_no_parameters(list_my_groups_context): Test that we can get all the groups where a user is a member """ results = list_my_groups_context.client.list_my_groups(status=200) - assert_that(results, has_length(3)) # 3 fields - - # Only count the groups with the group prefix - groups = [x for x in results["groups"] if x["name"].startswith(list_my_groups_context.group_prefix)] - assert_that(groups, has_length(50)) + assert_that(results, has_length(4)) # 4 fields assert_that(results, is_not(has_key("groupNameFilter"))) assert_that(results, is_not(has_key("startFrom"))) - assert_that(results, is_not(has_key("nextId"))) - assert_that(results["maxItems"], is_(200)) - - results["groups"] = sorted(groups, key=lambda x: x["name"]) - - for i in range(0, 50): - assert_that(results["groups"][i]["name"], is_("{0}-{1:0>3}".format(list_my_groups_context.group_prefix, i))) + assert_that(results, is_(has_key("nextId"))) + assert_that(results["maxItems"], is_(100)) def test_get_my_groups_using_old_account_auth(list_my_groups_context): @@ -34,11 +25,11 @@ def test_get_my_groups_using_old_account_auth(list_my_groups_context): Test passing in an account will return an empty set """ results = list_my_groups_context.client.list_my_groups(status=200) - assert_that(results, has_length(3)) + assert_that(results, has_length(4)) assert_that(results, is_not(has_key("groupNameFilter"))) assert_that(results, is_not(has_key("startFrom"))) - assert_that(results, is_not(has_key("nextId"))) - assert_that(results["maxItems"], is_(200)) + assert_that(results, is_(has_key("nextId"))) + assert_that(results["maxItems"], is_(100)) def test_list_my_groups_max_items(list_my_groups_context): @@ -102,7 +93,7 @@ def test_list_my_groups_filter_matches(list_my_groups_context): assert_that(results["groupNameFilter"], is_(f"{list_my_groups_context.group_prefix}-01")) assert_that(results, is_not(has_key("startFrom"))) assert_that(results, is_not(has_key("nextId"))) - assert_that(results["maxItems"], is_(200)) + assert_that(results["maxItems"], is_(100)) results["groups"] = sorted(results["groups"], key=lambda x: x["name"]) @@ -133,28 +124,20 @@ def test_list_my_groups_with_ignore_access_true(list_my_groups_context): Test that we can get all the groups whether a user is a member or not """ results = list_my_groups_context.client.list_my_groups(ignore_access=True, status=200) - - # Only count the groups with the group prefix + assert_that(results, has_length(4)) # 4 fields assert_that(len(results["groups"]), greater_than(50)) - assert_that(results["maxItems"], is_(200)) + assert_that(results["maxItems"], is_(100)) assert_that(results["ignoreAccess"], is_(True)) - my_results = list_my_groups_context.client.list_my_groups(status=200) - my_groups = [x for x in my_results["groups"] if x["name"].startswith(list_my_groups_context.group_prefix)] - sorted_groups = sorted(my_groups, key=lambda x: x["name"]) - - for i in range(0, 50): - assert_that(sorted_groups[i]["name"], is_("{0}-{1:0>3}".format(list_my_groups_context.group_prefix, i))) - def test_list_my_groups_as_support_user(list_my_groups_context): """ Test that we can get all the groups as a support user, even without ignore_access """ results = list_my_groups_context.support_user_client.list_my_groups(status=200) - + assert_that(results, has_length(4)) # 4 fields assert_that(len(results["groups"]), greater_than(50)) - assert_that(results["maxItems"], is_(200)) + assert_that(results["maxItems"], is_(100)) assert_that(results["ignoreAccess"], is_(False)) @@ -163,7 +146,7 @@ def test_list_my_groups_as_support_user_with_ignore_access_true(list_my_groups_c Test that we can get all the groups as a support user """ results = list_my_groups_context.support_user_client.list_my_groups(ignore_access=True, status=200) - + assert_that(results, has_length(4)) # 4 fields assert_that(len(results["groups"]), greater_than(50)) - assert_that(results["maxItems"], is_(200)) + assert_that(results["maxItems"], is_(100)) assert_that(results["ignoreAccess"], is_(True)) diff --git a/modules/api/src/test/functional/vinyldns_python.py b/modules/api/src/test/functional/vinyldns_python.py index 63df14233..2fcfbddf3 100644 --- a/modules/api/src/test/functional/vinyldns_python.py +++ b/modules/api/src/test/functional/vinyldns_python.py @@ -220,7 +220,7 @@ class VinylDNSClient(object): return data - def list_my_groups(self, group_name_filter=None, start_from=None, max_items=200, ignore_access=False, **kwargs): + def list_my_groups(self, group_name_filter=None, start_from=None, max_items=100, ignore_access=False, **kwargs): """ Retrieves my groups :param start_from: the start key of the page diff --git a/modules/portal/app/views/groups/groups.scala.html b/modules/portal/app/views/groups/groups.scala.html index 5e4ba60da..c1b4ea7fb 100644 --- a/modules/portal/app/views/groups/groups.scala.html +++ b/modules/portal/app/views/groups/groups.scala.html @@ -26,12 +26,12 @@
-
+
@@ -66,7 +66,22 @@

Loading groups...

You don't have any groups yet.

-

No groups match the search criteria.

+

No groups match the search criteria.

+ + +
+ {{ getGroupsPageNumber("myGroups") }} + +
+ + @@ -96,6 +111,118 @@
+ +
+ {{ getGroupsPageNumber("myGroups") }} + +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+
+ + +
+ + +
+
+
+ + + + +
+
+
+ + +
+
+

Loading groups...

+

No groups match the search criteria.

+ + +
+ {{ getGroupsPageNumber("allGroups") }} + +
+ + + + + + + + + + + + + + + + + + + +
Group NameEmailDescriptionActions
+ {{group.name}} + {{group.email}}{{group.description}} +
+ + View + + Edit + +
+
+ +
+ {{ getGroupsPageNumber("allGroups") }} + +
+
diff --git a/modules/portal/app/views/zones/zones.scala.html b/modules/portal/app/views/zones/zones.scala.html index 52ab8b759..aefdad5d7 100644 --- a/modules/portal/app/views/zones/zones.scala.html +++ b/modules/portal/app/views/zones/zones.scala.html @@ -72,8 +72,8 @@

No zones match the search criteria.

-
- {{ getZonesPageNumber("myZones") }} +
+ {{ getZonesPageNumber("myZones") }}