From 124482d4bc226a223b4a8b6346fe1da47464c21c Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Mon, 25 Nov 2024 16:21:10 +0100 Subject: [PATCH 01/19] pagination --- .../html/pages/search/resultsByCountry.html | 3 +- .../html/pages/search/resultsByType.html | 3 +- .../html/pages/search/searchResults.html | 3 +- .../html/parts/org_results_page.html | 33 +++++---- .../html/parts/select_org.modal.html | 5 +- .../static/resources/js/organizations.js | 67 +++++++++++-------- 6 files changed, 63 insertions(+), 51 deletions(-) diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/resultsByCountry.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/resultsByCountry.html index 12373cd9..34fb4848 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/resultsByCountry.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/resultsByCountry.html @@ -1,6 +1,5 @@ diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/resultsByType.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/resultsByType.html index cd80bf1e..740ec66d 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/resultsByType.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/resultsByType.html @@ -1,6 +1,5 @@ diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/searchResults.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/searchResults.html index 9f62420f..c3d50f0c 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/searchResults.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/searchResults.html @@ -1,6 +1,5 @@ diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html index 1d98f884..7e604abe 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html @@ -1,16 +1,13 @@

- Page: {{orgs.number + 1}} / {{orgs.totalPages}}
Total elements: {{orgs.totalElements}}
{{searchMessage}}
- Page: -
Total elements: 0
{{searchMessage}}
- Page:
Total elements:
{{searchMessage}}
@@ -25,16 +22,26 @@

- +
+
+ + + + + + + + +
+

Click the organization name to add the organization (multiple selection is allowed)

diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/select_org.modal.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/select_org.modal.html index 57b78402..2c1db405 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/select_org.modal.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/select_org.modal.html @@ -10,14 +10,13 @@
- +
diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js b/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js index b7fb83a7..cd77907d 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js @@ -38,7 +38,7 @@ orgsModule.controller('menuCtrl', function ($scope, suggestionInfo) { suggestionInfo.updateInfo(null); }); -orgsModule.directive('selectOrgModal', function($http, $timeout) { +orgsModule.directive('selectOrgModal', function($http) { return { restrict: 'E', scope: { @@ -52,15 +52,19 @@ orgsModule.directive('selectOrgModal', function($http, $timeout) { scope.searchOrgs = {}; scope.searchText = ''; scope.searchValue = ''; - - scope.search = function(text, page, size) { + + scope.search = function(text) { scope.searchOrgs = {}; - - call_http_get($http, 'api/organizations/search/' + page + '/' + size + '?status='+ scope.filterStatus + '&q=' + text, function(res) { + + call_http_get($http, 'api/organizations/search/0/25?status='+ scope.filterStatus + '&q=' + text, function(res) { scope.searchValue = text; scope.searchOrgs = res.data; }); } + + scope.searchPage = function() { + return 'api/organizations/search/__PAGE__/__SIZE__?status='+ scope.filterStatus + '&q=' + scope.searchValue; + } scope.selectOrg = function() { if (scope.onSelect) { @@ -207,8 +211,7 @@ orgsModule.directive('orgResultsPage', function($http, $location, $route) { scope: { 'searchMessage' : '@', 'orgs' : '=', - 'nextFunction' : '&', - 'prevFunction' : '&', + 'pageFunction' : '&', 'onSelect' : '&', 'selectedOrg' : '=', 'mode' : '@', @@ -234,7 +237,27 @@ orgsModule.directive('orgResultsPage', function($http, $location, $route) { } } + + scope.availablePages = function() { + var input = []; + for (var i = 0; i < scope.orgs.totalPages; i++) input.push(i); + return input; + } + + scope.gotoPage = function(page, pageSize) { + var url = scope.pageFunction().replace(/__PAGE__/, page).replace(/__SIZE__/, pageSize); + + if (scope.mode == 'select-modal') { + scope.orgs = {}; + call_http_get($http, url, function(res) { + scope.orgs = res.data; + }); + } else { + $location.url(url); + } + } } + } }); @@ -448,21 +471,14 @@ orgsModule.controller('searchResultsCtrl', function ($scope, $http, $routeParams call_http_get($http, 'api/organizations/search/' + $routeParams.page + '/' + $routeParams.size + '?q=' + $scope.searchText, function(res) { $scope.orgs = res.data; }); - $scope.prev = function() { + $scope.pageSearch = function() { if ($scope.searchText) { - $location.url('/searchResults/' + ($scope.orgs.number - 1) + '/' + $scope.orgs.size + '/' + encodeURIComponent($scope.searchText)); + return '/searchResults/__PAGE__/__SIZE__/' + encodeURIComponent($scope.searchText); } else { - $location.url('/searchResults/' + ($scope.orgs.number - 1) + '/' + $scope.orgs.size + '/_'); + return '/searchResults/__PAGE__/__SIZE__/_'; } } - $scope.next = function() { - if ($scope.searchText) { - $location.url('/searchResults/' + ($scope.orgs.number + 1) + '/' + $scope.orgs.size + '/' + encodeURIComponent($scope.searchText)); - } else { - $location.url('/searchResults/' + ($scope.orgs.number + 1) + '/' + $scope.orgs.size + '/_'); - } - } }); orgsModule.controller('countriesCtrl', function ($scope, $http, $routeParams) { @@ -483,12 +499,8 @@ orgsModule.controller('byCountryCtrl', function ($scope, $http, $routeParams, $l call_http_get($http, 'api/organizations/byCountry/' + $routeParams.status + '/' + $routeParams.code + '/' + $routeParams.page + '/' + $routeParams.size, function(res) { $scope.orgs = res.data; }); - $scope.prev = function() { - $location.url('/byCountry/' + ($scope.orgs.number - 1) + '/' + $scope.orgs.size + '/' + $routeParams.status + '/' + encodeURIComponent($scope.fieldValue)); - } - - $scope.next = function() { - $location.url('/byCountry/' + ($scope.orgs.number + 1) + '/' + $scope.orgs.size + '/' + $routeParams.status + '/' + encodeURIComponent($scope.fieldValue)); + $scope.pageByCountry = function() { + return '/byCountry/__PAGE__/__SIZE__/' + $routeParams.status + '/' + encodeURIComponent($scope.fieldValue); } }); @@ -511,13 +523,10 @@ orgsModule.controller('byTypeCtrl', function ($scope, $http, $routeParams, $loca call_http_get($http, 'api/organizations/byType/' + $routeParams.status + '/' + $routeParams.type + '/' + $routeParams.page + '/' + $routeParams.size, function(res) { $scope.orgs = res.data; }); - $scope.prev = function() { - $location.url('/byType/' + ($scope.orgs.number - 1) + '/' + $scope.orgs.size + '/' + $routeParams.status + '/' + encodeURIComponent($scope.fieldValue)); - } - - $scope.next = function() { - $location.url('/byType/' + ($scope.orgs.number + 1) + '/' + $scope.orgs.size + '/' + $routeParams.status + '/' + encodeURIComponent($scope.fieldValue)); + $scope.pageByType = function() { + return '/byType/__PAGE__/__SIZE__/' + $routeParams.status + '/' + encodeURIComponent($scope.fieldValue); } + }); -- 2.17.1 From c8ad02503157dc0386c1c16b3a845886f4ec062a Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Tue, 26 Nov 2024 11:47:20 +0100 Subject: [PATCH 02/19] page size --- .../html/parts/org_results_page.html | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html index 7e604abe..d97188d2 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html @@ -24,22 +24,25 @@
- - + - - - - - + +
-- 2.17.1 From c75d8b0e3975b454a523ed28042beef09259375c Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Tue, 26 Nov 2024 12:48:58 +0100 Subject: [PATCH 03/19] single and multi select modal --- .../html/pages/advanced/conflicts.html | 2 +- .../resources/html/parts/org_conflicts.html | 2 +- .../resources/html/parts/org_duplicates.html | 2 +- .../html/parts/org_metadata.form.html | 2 +- .../html/parts/org_results_page.html | 22 ++++++++++++------- .../html/parts/select_org.modal.html | 3 +-- .../static/resources/js/organizations.js | 11 ++++++++-- 7 files changed, 28 insertions(+), 16 deletions(-) diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/advanced/conflicts.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/advanced/conflicts.html index 531b27b1..057d6ed0 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/advanced/conflicts.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/advanced/conflicts.html @@ -44,5 +44,5 @@ - + diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_conflicts.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_conflicts.html index f825aa73..4384c8ff 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_conflicts.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_conflicts.html @@ -32,4 +32,4 @@ - + diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_duplicates.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_duplicates.html index 23c22e88..9df14a67 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_duplicates.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_duplicates.html @@ -69,4 +69,4 @@
- + diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_metadata.form.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_metadata.form.html index 5e7d45a4..efd8e632 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_metadata.form.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_metadata.form.html @@ -282,7 +282,7 @@ +

Total elements: {{orgs.totalElements}}
{{searchMessage}} @@ -13,8 +13,8 @@

-

- Page: {{orgs.number + 1}} / {{orgs.totalPages}} - Total elements: {{orgs.totalElements}} +

+ Total elements: {{orgs.totalElements}} Total elements: 0

@@ -46,7 +46,8 @@
-

Click the organization name to add the organization (multiple selection is allowed)

+

Click the organization name to select the organization

+

Click the organization name to add the organization (multiple selection is allowed)

@@ -61,11 +62,16 @@ diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/select_org.modal.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/select_org.modal.html index 2c1db405..9094e387 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/select_org.modal.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/select_org.modal.html @@ -19,8 +19,7 @@ page-function="searchPage()" on-select="selectOrg()" selected-org="selectedOrg" - mode="select-modal"> - + mode="{{resultsPageMode}}"> - + -- 2.17.1 From 02655e504ab8d4a155d347393325682d8fb27513 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Wed, 27 Nov 2024 15:46:45 +0100 Subject: [PATCH 13/19] method for sorting --- .../controller/OrganizationController.java | 52 ++++++++++++++----- .../OrganizationSimpleViewRepository.java | 42 +++++++-------- 2 files changed, 59 insertions(+), 35 deletions(-) diff --git a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/OrganizationController.java b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/OrganizationController.java index 821594f8..a9331c1c 100644 --- a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/OrganizationController.java +++ b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/OrganizationController.java @@ -19,6 +19,8 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; +import org.springframework.data.domain.Sort.Order; import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -228,6 +230,8 @@ public class OrganizationController extends AbstractDnetController { @PathVariable final int size, @RequestParam final String q, @RequestParam(required = false, defaultValue = "") final String status, + @RequestParam(required = false, defaultValue = "name") final String orderBy, + @RequestParam(required = false, defaultValue = "false") final boolean reverse, final Authentication authentication) { if (SPECIAL_STATUS_FOR_CANDIDATE_DUP.equals(status)) { @@ -244,9 +248,11 @@ public class OrganizationController extends AbstractDnetController { statuses = Arrays.asList(OrganizationStatus.approved.toString(), OrganizationStatus.suggested.toString()); } + final PageRequest pageRequest = PageRequest.of(page, size, Sort.by(reverse ? Order.desc(orderBy) : Order.asc(orderBy))); + return UserInfo.isSuperAdmin(authentication) - ? organizationSimpleViewRepository.search(q, statuses, PageRequest.of(page, size)) - : organizationSimpleViewRepository.searchForUser(q, UserInfo.getEmail(authentication), statuses, PageRequest.of(page, size)); + ? organizationSimpleViewRepository.search(q, statuses, pageRequest) + : organizationSimpleViewRepository.searchForUser(q, UserInfo.getEmail(authentication), statuses, pageRequest); } @GetMapping("/byCountry/{status}/{code}/{page}/{size}") @@ -254,12 +260,18 @@ public class OrganizationController extends AbstractDnetController { @PathVariable final String code, @PathVariable final int page, @PathVariable final int size, + @RequestParam(required = false, defaultValue = "name") final String orderBy, + @RequestParam(required = false, defaultValue = "false") final boolean reverse, final Authentication authentication) { if (!UserInfo.isSuperAdmin(authentication) && !userCountryRepository.verifyAuthorizationForCountry(code, UserInfo.getEmail(authentication))) { throw new RuntimeException("User not authorized"); } - if ("all".equalsIgnoreCase(status)) { return organizationSimpleViewRepository.findByCountryOrderByName(code, PageRequest.of(page, size)); } - return organizationSimpleViewRepository.findByCountryAndStatusOrderByName(code, status, PageRequest.of(page, size)); + + final PageRequest pageRequest = PageRequest.of(page, size, Sort.by(reverse ? Order.desc(orderBy) : Order.asc(orderBy))); + + if ("all".equalsIgnoreCase(status)) { return organizationSimpleViewRepository.findByCountry(code, pageRequest); } + + return organizationSimpleViewRepository.findByCountryAndStatus(code, status, pageRequest); } @GetMapping("/byCountry/{status}/{code}") @@ -267,20 +279,30 @@ public class OrganizationController extends AbstractDnetController { @PathVariable final String code, @RequestParam(required = false, defaultValue = "0") final int page, @RequestParam(required = false, defaultValue = "${openorgs.findOrgsByStatusAndCountry.limit.default}") final int size, + @RequestParam(required = false, defaultValue = "name") final String orderBy, + @RequestParam(required = false, defaultValue = "false") final boolean reverse, final Authentication authentication) { if (!UserInfo.isSuperAdmin(authentication) && !userCountryRepository.verifyAuthorizationForCountry(code, UserInfo.getEmail(authentication))) { throw new RuntimeException("User not authorized"); } - if ("all".equalsIgnoreCase(status)) { return organizationSimpleViewRepository.findByCountryOrderByName(code, PageRequest.of(page, size)).getContent(); } - return organizationSimpleViewRepository.findByCountryAndStatusOrderByName(code, status, PageRequest.of(page, size)).getContent(); + + final PageRequest pageRequest = PageRequest.of(page, size, Sort.by(reverse ? Order.desc(orderBy) : Order.asc(orderBy))); + + if ("all".equalsIgnoreCase(status)) { return organizationSimpleViewRepository.findByCountry(code, pageRequest).getContent(); } + + return organizationSimpleViewRepository.findByCountryAndStatus(code, status, pageRequest).getContent(); } @GetMapping(value = "/byCountry/{status}/{code}/csv", produces = "text/csv") public void findOrgsByStatusAndCountryCSV(@PathVariable final String status, @PathVariable final String code, + @RequestParam(required = false, defaultValue = "name") final String orderBy, + @RequestParam(required = false, defaultValue = "false") final boolean reverse, final HttpServletResponse res, final Authentication authentication) throws IOException { - final Iterable list = findOrgsByStatusAndCountry(status, code, 0, Integer.MAX_VALUE, authentication); + + final Iterable list = findOrgsByStatusAndCountry(status, code, 0, Integer.MAX_VALUE, orderBy, reverse, authentication); + CSVConverter.writeCSV(res .getOutputStream(), list, OrganizationSimpleView.class, "id", "name", "type", "city", "country", "acronyms", "urls", "status", "nSimilarDups", "nSuggestedDups", "nDifferentDups"); } @@ -290,17 +312,21 @@ public class OrganizationController extends AbstractDnetController { @PathVariable final String type, @PathVariable final int page, @PathVariable final int size, + @RequestParam(required = false, defaultValue = "name") final String orderBy, + @RequestParam(required = false, defaultValue = "false") final boolean reverse, final Authentication authentication) { + final PageRequest pageRequest = PageRequest.of(page, size, Sort.by(reverse ? Order.desc(orderBy) : Order.asc(orderBy))); + if (UserInfo.isSuperAdmin(authentication)) { - if ("all".equalsIgnoreCase(status)) { return organizationSimpleViewRepository.findByTypeOrderByName(type, PageRequest.of(page, size)); } - return organizationSimpleViewRepository.findByTypeAndStatusOrderByName(type, status, PageRequest.of(page, size)); - } - if ("all".equalsIgnoreCase(status)) { - return organizationSimpleViewRepository.findByTypeForUser(type, UserInfo.getEmail(authentication), PageRequest.of(page, size)); + if ("all".equalsIgnoreCase(status)) { return organizationSimpleViewRepository.findByType(type, pageRequest); } + + return organizationSimpleViewRepository.findByTypeAndStatus(type, status, pageRequest); } + + if ("all".equalsIgnoreCase(status)) { return organizationSimpleViewRepository.findByTypeForUser(type, UserInfo.getEmail(authentication), pageRequest); } return organizationSimpleViewRepository - .findByTypeAndStatusForUser(type, status, UserInfo.getEmail(authentication), PageRequest.of(page, size)); + .findByTypeAndStatusForUser(type, status, UserInfo.getEmail(authentication), pageRequest); } diff --git a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/repository/readonly/OrganizationSimpleViewRepository.java b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/repository/readonly/OrganizationSimpleViewRepository.java index 7fed09e6..9da4534e 100644 --- a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/repository/readonly/OrganizationSimpleViewRepository.java +++ b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/repository/readonly/OrganizationSimpleViewRepository.java @@ -15,12 +15,12 @@ public interface OrganizationSimpleViewRepository extends ReadOnlyRepository search(@Param("text") String text, @Param("statuses") List statuses, Pageable pageable); // SEARCH FOR USER @Query(value = "SELECT\n" - + " org.id,\n" - + " org.name,\n" - + " org.type,\n" - + " org.city,\n" - + " org.country,\n" - + " org.status,\n" + + " org.id AS id,\n" + + " org.name AS name,\n" + + " org.type AS type,\n" + + " org.city AS city,\n" + + " org.country AS country,\n" + + " org.status AS status,\n" + " array_remove(array_agg(DISTINCT a.acronym), NULL) AS acronyms,\n" + " array_remove(array_agg(DISTINCT u.url), NULL) AS urls,\n" + " count(DISTINCT d1.oa_original_id) FILTER (WHERE d1.reltype = 'is_similar' ) AS n_similar_dups,\n" @@ -56,25 +55,24 @@ public interface OrganizationSimpleViewRepository extends ReadOnlyRepository searchForUser(@Param("text") String text, @Param("email") String email, @Param("statuses") List statuses, Pageable pageable); - Page findByCountryOrderByName(String country, Pageable pageable); + Page findByCountry(String country, Pageable pageable); - Page findByCountryAndStatusOrderByName(String code, String status, Pageable pageable); + Page findByCountryAndStatus(String code, String status, Pageable pageable); - Page findByTypeOrderByName(String type, Pageable pageable); + Page findByType(String type, Pageable pageable); - Page findByTypeAndStatusOrderByName(String type, String status, Pageable pageable); + Page findByTypeAndStatus(String type, String status, Pageable pageable); - @Query(value = "select o.* from organizations_simple_view o left outer join user_countries uc on (uc.country = o.country) where uc.email = ?2 and o.type = ?1 order by o.name", nativeQuery = true) + @Query(value = "select o.* from organizations_simple_view o left outer join user_countries uc on (uc.country = o.country) where uc.email = ?2 and o.type = ?1", nativeQuery = true) Page findByTypeForUser(String type, String name, Pageable pageable); - @Query(value = "select o.* from organizations_simple_view o left outer join user_countries uc on (uc.country = o.country) where o.type = ?1 and o.status = ?2 and uc.email = ?3 order by o.name", nativeQuery = true) + @Query(value = "select o.* from organizations_simple_view o left outer join user_countries uc on (uc.country = o.country) where o.type = ?1 and o.status = ?2 and uc.email = ?3", nativeQuery = true) Page findByTypeAndStatusForUser(String type, String status, String name, Pageable pageable); // SEARCH FOR VALID DUPLICATE CANDIDATES -- 2.17.1 From f25d89bc4a1486b39a565b0cd4d770d5c9d38322 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Thu, 28 Nov 2024 12:05:01 +0100 Subject: [PATCH 14/19] support of sorting in route paths --- .../resources/html/pages/search/browse.html | 8 +- .../static/resources/js/organizations.js | 126 +++++++++++++----- 2 files changed, 97 insertions(+), 37 deletions(-) diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/browse.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/browse.html index 25677167..0fb35d65 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/browse.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/browse.html @@ -23,19 +23,19 @@ diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js b/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js index c313bd7a..5a29603e 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js @@ -212,7 +212,7 @@ orgsModule.directive('orgDetails', function($http, $location, $route) { } }); -orgsModule.directive('orgResultsPage', function($http, $location, $route) { +orgsModule.directive('orgResultsPage', function($http, $location, $route, $routeParams) { return { restrict: 'E', scope: { @@ -250,9 +250,13 @@ orgsModule.directive('orgResultsPage', function($http, $location, $route) { for (var i = 0; i < scope.orgs.totalPages; i++) input.push(i); return input; } - - scope.gotoPage = function(page, pageSize) { - var url = scope.pageFunction().replace(/__PAGE__/, page).replace(/__SIZE__/, pageSize); + + scope.gotoPageAndSort = function(page, pageSize, orderBy, orderType) { + var url = scope.pageFunction() + .replace(/__PAGE__/, page) + .replace(/__SIZE__/, pageSize) + .replace(/__ORDER_BY__/, orderBy) + .replace(/__ORDER_TYPE__/, orderType); if (scope.mode == 'select-modal' || scope.mode == 'multi-select-modal') { scope.orgs = {}; @@ -263,6 +267,11 @@ orgsModule.directive('orgResultsPage', function($http, $location, $route) { $location.url(url); } } + + scope.gotoPage = function(page, pageSize) { + scope.gotoPageAndSort(page, pageSize, $routeParams.orderBy, $routeParams.orderType); + } + } } @@ -402,25 +411,24 @@ orgsModule.directive('orgJournal', function($http) { } }); - orgsModule.config(function($routeProvider) { $routeProvider - .when('/search', { templateUrl: 'resources/html/pages/search/search.html', controller: 'searchCtrl' }) - .when('/searchResults/:page/:size/:text*', { templateUrl: 'resources/html/pages/search/searchResults.html', controller: 'searchResultsCtrl' }) - .when('/countries/:mode', { templateUrl: 'resources/html/pages/search/browse.html', controller: 'countriesCtrl' }) - .when('/byCountry/:page/:size/:status/:code*', { templateUrl: 'resources/html/pages/search/resultsByCountry.html', controller: 'byCountryCtrl' }) - .when('/types/:mode', { templateUrl: 'resources/html/pages/search/browse.html', controller: 'typesCtrl' }) - .when('/byType/:page/:size/:status/:type*', { templateUrl: 'resources/html/pages/search/resultsByType.html', controller: 'byTypeCtrl' }) - .when('/edit/:msg/:id*', { templateUrl: 'resources/html/pages/edit/edit.html', controller: 'showEditCtrl' }) - .when('/new', { templateUrl: 'resources/html/pages/advanced/new.html', controller: 'newOrgCtrl' }) - .when('/pendings/:country', { templateUrl: 'resources/html/pages/advanced/pendingOrgs.html', controller: 'pendingOrgsCtrl' }) - .when('/duplicates/:country', { templateUrl: 'resources/html/pages/advanced/duplicates.html', controller: 'duplicatesCtrl' }) - .when('/conflicts/:country', { templateUrl: 'resources/html/pages/advanced/conflicts.html', controller: 'conflictsCtrl' }) - .when('/users', { templateUrl: 'resources/html/pages/admin/users.html', controller: 'usersCtrl' }) - .when('/sysconf', { templateUrl: 'resources/html/pages/admin/sysConf.html', controller: 'sysConfCtrl' }) - .when('/utils', { templateUrl: 'resources/html/pages/admin/utils.html', controller: 'utilsCtrl' }) - .when('/lastImport', { templateUrl: 'resources/html/pages/admin/lastImport.html', controller: 'lastImportCtrl' }) - .when('/persistentOrgs', { templateUrl: 'resources/html/pages/admin/persistentOrgs.html', controller: 'persistentOrgsCtrl' }) + .when('/search', { templateUrl: 'resources/html/pages/search/search.html', controller: 'searchCtrl' }) + .when('/page/:page/:size/sortBy/:orderBy/:orderType/search/:text*', { templateUrl: 'resources/html/pages/search/searchResults.html', controller: 'searchResultsCtrl' }) + .when('/countries/:mode', { templateUrl: 'resources/html/pages/search/browse.html', controller: 'countriesCtrl' }) + .when('/page/:page/:size/sortBy/:orderBy/:orderType/byCountry/:status/:code*', { templateUrl: 'resources/html/pages/search/resultsByCountry.html', controller: 'byCountryCtrl' }) + .when('/types/:mode', { templateUrl: 'resources/html/pages/search/browse.html', controller: 'typesCtrl' }) + .when('/page/:page/:size/sortBy/:orderBy/:orderType/byType/:status/:type*', { templateUrl: 'resources/html/pages/search/resultsByType.html', controller: 'byTypeCtrl' }) + .when('/edit/:msg/:id*', { templateUrl: 'resources/html/pages/edit/edit.html', controller: 'showEditCtrl' }) + .when('/new', { templateUrl: 'resources/html/pages/advanced/new.html', controller: 'newOrgCtrl' }) + .when('/pendings/:country', { templateUrl: 'resources/html/pages/advanced/pendingOrgs.html', controller: 'pendingOrgsCtrl' }) + .when('/duplicates/:country', { templateUrl: 'resources/html/pages/advanced/duplicates.html', controller: 'duplicatesCtrl' }) + .when('/conflicts/:country', { templateUrl: 'resources/html/pages/advanced/conflicts.html', controller: 'conflictsCtrl' }) + .when('/users', { templateUrl: 'resources/html/pages/admin/users.html', controller: 'usersCtrl' }) + .when('/sysconf', { templateUrl: 'resources/html/pages/admin/sysConf.html', controller: 'sysConfCtrl' }) + .when('/utils', { templateUrl: 'resources/html/pages/admin/utils.html', controller: 'utilsCtrl' }) + .when('/lastImport', { templateUrl: 'resources/html/pages/admin/lastImport.html', controller: 'lastImportCtrl' }) + .when('/persistentOrgs', { templateUrl: 'resources/html/pages/admin/persistentOrgs.html', controller: 'persistentOrgsCtrl' }) .otherwise({ redirectTo: '/search' }); }); @@ -462,9 +470,9 @@ orgsModule.controller('searchCtrl', function ($scope, $location) { $scope.searchText = ''; $scope.search = function() { if ($scope.searchText) { - $location.url('/searchResults/0/50/' + encodeURIComponent(encodeURIComponent($scope.searchText))); + $location.url('/page/0/50/sortBy/name/asc/search/' + encodeURIComponent(encodeURIComponent($scope.searchText))); } else { - $location.url('/searchResults/0/50/_'); + $location.url('/page/0/50/sortBy/name/asc/search/_'); } } }); @@ -476,13 +484,27 @@ orgsModule.controller('searchResultsCtrl', function ($scope, $http, $routeParams } $scope.orgs = {}; - call_http_get($http, 'api/organizations/search/' + $routeParams.page + '/' + $routeParams.size + '?q=' + $scope.searchText, function(res) { $scope.orgs = res.data; }); + + var url = 'api/organizations/search/' + + $routeParams.page + + '/' + + $routeParams.size + + '?q=' + + $scope.searchText + + '&orderBy=' + + encodeURIComponent($routeParams.orderBy); + + if ($routeParams.orderType == 'desc') { + url += "&reverse=true"; + } + + call_http_get($http, url, function(res) { $scope.orgs = res.data; }); $scope.pageSearch = function() { if ($scope.searchText) { - return '/searchResults/__PAGE__/__SIZE__/' + encodeURIComponent($scope.searchText); + return '/page/__PAGE__/__SIZE__/sortBy/__ORDER_BY__/__ORDER_TYPE__/search/' + encodeURIComponent($scope.searchText); } else { - return '/searchResults/__PAGE__/__SIZE__/_'; + return '/page/__PAGE__/__SIZE__/sortBy/__ORDER_BY__/__ORDER_TYPE__/search/_'; } } @@ -492,7 +514,7 @@ orgsModule.controller('countriesCtrl', function ($scope, $http, $routeParams) { $scope.title = 'Countries'; $scope.field = 'Country'; - $scope.resultsBasePath = '/byCountry' + $scope.resultsBasePath = '/page/0/50/sortBy/name/asc/byCountry'; $scope.entries = []; $scope.mode = $routeParams.mode; @@ -504,18 +526,37 @@ orgsModule.controller('byCountryCtrl', function ($scope, $http, $routeParams, $l $scope.fieldValue = decodeURIComponent($routeParams.code); $scope.orgs = {}; - call_http_get($http, 'api/organizations/byCountry/' + $routeParams.status + '/' + $routeParams.code + '/' + $routeParams.page + '/' + $routeParams.size, function(res) { $scope.orgs = res.data; }); + var url = 'api/organizations/byCountry/' + + $routeParams.status + + '/' + + $routeParams.code + + '/' + + $routeParams.page + + '/' + + $routeParams.size + + '?orderBy=' + + encodeURIComponent($routeParams.orderBy) + + if ($routeParams.orderType == 'desc') { + url += "&reverse=true"; + } + + + call_http_get($http, url, function(res) { $scope.orgs = res.data; }); $scope.pageByCountry = function() { - return '/byCountry/__PAGE__/__SIZE__/' + $routeParams.status + '/' + encodeURIComponent($scope.fieldValue); + return '/page/__PAGE__/__SIZE__/sortBy/__ORDER_BY__/__ORDER_TYPE__/byCountry/' + + $routeParams.status + + '/' + + encodeURIComponent($scope.fieldValue); } - + }); orgsModule.controller('typesCtrl', function ($scope, $http, $routeParams) { $scope.title = 'Organization types'; $scope.field = 'Organization type'; - $scope.resultsBasePath = '/byType' + $scope.resultsBasePath = '/page/0/50/sortBy/name/asc/byType'; $scope.entries = []; $scope.mode = $routeParams.mode; @@ -528,10 +569,29 @@ orgsModule.controller('byTypeCtrl', function ($scope, $http, $routeParams, $loca $scope.orgs = {}; - call_http_get($http, 'api/organizations/byType/' + $routeParams.status + '/' + $routeParams.type + '/' + $routeParams.page + '/' + $routeParams.size, function(res) { $scope.orgs = res.data; }); + var url = 'api/organizations/byType/' + + $routeParams.status + + '/' + + $routeParams.type + + '/' + + $routeParams.page + + '/' + + $routeParams.size + + '?orderBy=' + + encodeURIComponent($routeParams.orderBy) + + if ($routeParams.orderType == 'desc') { + url += "&reverse=true"; + } + + + call_http_get($http, url, function(res) { $scope.orgs = res.data; }); $scope.pageByType = function() { - return '/byType/__PAGE__/__SIZE__/' + $routeParams.status + '/' + encodeURIComponent($scope.fieldValue); + return '/page/__PAGE__/__SIZE__/sortBy/__ORDER_BY__/__ORDER_TYPE__/byType/' + + $routeParams.status + + '/' + + encodeURIComponent($scope.fieldValue); } }); -- 2.17.1 From 6d491345fe143edee5b5ae3947bdd7a6be87e39b Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Thu, 28 Nov 2024 14:20:52 +0100 Subject: [PATCH 15/19] sorting and filtering --- .../html/parts/org_results_page.html | 68 +++++++++++++------ .../static/resources/js/organizations.js | 4 ++ 2 files changed, 50 insertions(+), 22 deletions(-) diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html index 6a41abb5..f9c7f9ec 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html @@ -21,29 +21,53 @@

No results

- -
-
- -
- + diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js b/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js index 37c84725..f134a6ec 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js @@ -62,8 +62,10 @@ orgsModule.directive('selectOrgModal', function($http) { scope.search = function(text) { scope.searchOrgs = {}; - - call_http_get($http, 'api/organizations/search/0/25?status='+ scope.filterStatus + '&q=' + text, function(res) { + + var url = 'api/organizations/search/0/50?orderBy=name&status='+ scope.filterStatus + '&q=' + text; + + call_http_get($http, url, function(res) { scope.searchValue = text; scope.searchOrgs = res.data; }); @@ -227,6 +229,11 @@ orgsModule.directive('orgResultsPage', function($http, $location, $route, $route }, templateUrl: 'resources/html/parts/org_results_page.html', link: function(scope, element, attrs, ctrl) { + + scope.orderBy = $routeParams.orderBy ? $routeParams.orderBy : 'name'; + scope.orderType = $routeParams.orderType ? $routeParams.orderType : 'asc'; + scope.size = $routeParams.size ? $routeParams.size : 50; + scope.selectOrg = function(o) { o.selected = true; @@ -251,29 +258,38 @@ orgsModule.directive('orgResultsPage', function($http, $location, $route, $route return input; } - scope.gotoPageAndSort = function(page, pageSize, orderBy, orderType) { + scope.gotoPage = function(page, pageSize) { var url = scope.pageFunction() .replace(/__PAGE__/, page) .replace(/__SIZE__/, pageSize) - .replace(/__ORDER_BY__/, orderBy) - .replace(/__ORDER_TYPE__/, orderType); + .replace(/__ORDER_BY__/, scope.orderBy) + .replace(/__ORDER_TYPE__/, scope.orderType); if (scope.mode == 'select-modal' || scope.mode == 'multi-select-modal') { + url += '&orderBy=' + scope.orderBy; + if (scope.orderType == 'desc') { + url += '&reverse=true'; + } + scope.orgs = {}; call_http_get($http, url, function(res) { scope.orgs = res.data; + scope.size = res.data.size; }); } else { $location.url(url); } } - scope.changeSort = function(orderBy, orderType) { - scope.gotoPageAndSort(0, $routeParams.size, orderBy, orderType); + scope.changeSortField = function(orderBy) { + scope.orderBy = orderBy; + scope.gotoPage(0, scope.size); } - scope.gotoPage = function(page, pageSize) { - scope.gotoPageAndSort(page, pageSize, $routeParams.orderBy, $routeParams.orderType); + scope.changeSortOrder = function() { + if (scope.orderType == 'desc') { scope.orderType = 'asc'; } + else { scope.orderType = 'desc'; } + scope.gotoPage(0, scope.size); } } -- 2.17.1 From d40d9adc9c03aa94031ae180287b732d2afcfb89 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Fri, 29 Nov 2024 13:38:15 +0100 Subject: [PATCH 17/19] minor fix --- .../static/resources/html/parts/org_results_page.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html index 84e331b4..18cb7ac2 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html @@ -40,10 +40,10 @@ name country type - status - # accepted dups - # suggested dups - # rejected dups + status + # accepted dups + # suggested dups + # rejected dups -- 2.17.1 From b5f9fed5da72e28000198cb787cb23f3916dae65 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Fri, 29 Nov 2024 14:14:20 +0100 Subject: [PATCH 18/19] add multiple parent/child relations --- .../html/parts/org_metadata.form.html | 37 +++++++++---------- .../static/resources/js/organizations.js | 22 +++++++---- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_metadata.form.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_metadata.form.html index efd8e632..6b97444a 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_metadata.form.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_metadata.form.html @@ -271,25 +271,22 @@ - - - - @@ -340,5 +337,5 @@ + - diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js b/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js index f134a6ec..fa858f24 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js @@ -172,21 +172,27 @@ orgsModule.directive('orgFormMetadata', function($http, $location, $route, $rout }, templateUrl: 'resources/html/parts/org_metadata.form.html', link: function(scope, element, attrs, ctrl) { - scope.newRelation = {}; scope.newRelType = ''; - - scope.resetSelectedRelation = function() { - scope.newRelation = {}; - } + scope.newRelation = {}; - scope.addNewRelation = function() { + scope.addRelation = function() { + + for (var i = 0; i < scope.org.relations.length; i++) { + if (scope.org.relations[i].relatedOrgId == scope.newRelation.id) { + alert("The selected organization has been already added !!!"); + return; + } + } + scope.org.relations.push({ 'relatedOrgId' : scope.newRelation.id, 'relatedOrgName' : scope.newRelation.name, 'type' : scope.newRelType }); - scope.newRelation = {}; - scope.newRelType = ''; + } + + scope.setRelationType = function(relType) { + scope.newRelType = relType; } scope.save = function() { -- 2.17.1 From a0c5818181e8a8f6c211f58f170308e806b41790 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Mon, 2 Dec 2024 10:12:49 +0100 Subject: [PATCH 19/19] css --- .../resources/css/bootstrap.openorgs.css | 34 +++++++++---------- .../html/parts/org_metadata.form.html | 4 +-- .../html/parts/org_results_page.html | 6 ++-- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/css/bootstrap.openorgs.css b/apps/dnet-orgs-database-application/src/main/resources/static/resources/css/bootstrap.openorgs.css index 9c35e23a..8a8d3668 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/css/bootstrap.openorgs.css +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/css/bootstrap.openorgs.css @@ -29,7 +29,7 @@ --secondary: #e9ecef; --success: #73a839; --info: #033c73; - --warning: #dd5600; + --warning: #ff9933; --danger: #c71c22; --light: #f8f9fa; --dark: #343a40; @@ -2773,8 +2773,8 @@ a.btn.disabled, fieldset:disabled a.btn { .btn-warning { color: #fff; - background-color: #dd5600; - border-color:#dd5600 + background-color: #ff9933; + border-color:#ff9933 } .btn-warning:hover { @@ -2792,8 +2792,8 @@ a.btn.disabled, fieldset:disabled a.btn { .btn-warning.disabled, .btn-warning:disabled { color: #fff; - background-color: #dd5600; - border-color:#dd5600 + background-color: #ff9933; + border-color:#ff9933 } .btn-warning:not(:disabled):not(.disabled).active, .btn-warning:not(:disabled):not(.disabled):active, .show > .btn-warning.dropdown-toggle { @@ -3032,14 +3032,14 @@ a.btn.disabled, fieldset:disabled a.btn { } .btn-outline-warning { - color: #dd5600; - border-color:#dd5600 + color: #ff9933; + border-color:#ff9933 } .btn-outline-warning:hover { color: #fff; - background-color: #dd5600; - border-color:#dd5600 + background-color: #ff9933; + border-color:#ff9933 } .btn-outline-warning.focus, .btn-outline-warning:focus { @@ -3047,14 +3047,14 @@ a.btn.disabled, fieldset:disabled a.btn { } .btn-outline-warning.disabled, .btn-outline-warning:disabled { - color: #dd5600; + color: #ff9933; background-color:transparent } .btn-outline-warning:not(:disabled):not(.disabled).active, .btn-outline-warning:not(:disabled):not(.disabled):active, .show > .btn-outline-warning.dropdown-toggle { color: #fff; - background-color: #dd5600; - border-color:#dd5600 + background-color: #ff9933; + border-color:#ff9933 } .btn-outline-warning:not(:disabled):not(.disabled).active:focus, .btn-outline-warning:not(:disabled):not(.disabled):active:focus, .show > .btn-outline-warning.dropdown-toggle:focus { @@ -5197,7 +5197,7 @@ a.badge-info.focus, a.badge-info:focus { .badge-warning { color: #fff; - background-color:#dd5600 + background-color:#ff9933 } a.badge-warning:focus, a.badge-warning:hover { @@ -6771,7 +6771,7 @@ a.bg-info:focus, a.bg-info:hover, button.bg-info:focus, button.bg-info:hover { } .bg-warning { - background-color:#dd5600 !important + background-color:#ff9933 !important } a.bg-warning:focus, a.bg-warning:hover, button.bg-warning:focus, button.bg-warning:hover { @@ -6867,7 +6867,7 @@ a.bg-dark:focus, a.bg-dark:hover, button.bg-dark:focus, button.bg-dark:hover { } .border-warning { - border-color:#dd5600 !important + border-color:#ff9933 !important } .border-danger { @@ -10297,7 +10297,7 @@ a.text-info:focus, a.text-info:hover { } .text-warning { - color:#dd5600 !important + color:#ff9933 !important } a.text-warning:focus, a.text-warning:hover { @@ -10502,7 +10502,7 @@ a.text-dark:focus, a.text-dark:hover { } .btn-warning { - background-image: linear-gradient(#ff6707, #dd5600 60%, #c94e00); + background-image: linear-gradient(#ffaa66, #ff9933 60%, #ff6707); background-repeat:no-repeat } diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_metadata.form.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_metadata.form.html index 6b97444a..195d4489 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_metadata.form.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_metadata.form.html @@ -36,7 +36,7 @@ @@ -303,7 +303,7 @@
- +
diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html index 18cb7ac2..8b6a3a1b 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html @@ -49,7 +49,7 @@
- reverse + descending
@@ -57,7 +57,7 @@
- + - +
-- 2.17.1
- {{o.name}} - {{o.name}} (SELECTED) - {{o.name}} + {{o.name}} + {{o.name}} (SELECTED) + + {{o.name}} + + {{o.name}} + {{o.status}} -
URL: {{ourl}}
+ +
URL: {{ourl}}
{{o.city || '-'}}, {{o.country}} {{o.acronyms.join()}}
+ {{o.status}} + {{o.name}} {{o.name}} (SELECTED) @@ -69,7 +71,6 @@ {{o.name}} - {{o.status}}
URL: {{ourl}}
{{e.name}} ({{e.code}}) - {{e.values.approved}} + {{e.values.approved}} - - {{e.values.suggested}} + {{e.values.suggested}} - - {{e.values.raw}} + {{e.values.raw}} - - {{e.values.hidden}} + {{e.values.hidden}} -
{{o.status}} diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js b/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js index 5a29603e..37c84725 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/js/organizations.js @@ -268,6 +268,10 @@ orgsModule.directive('orgResultsPage', function($http, $location, $route, $route } } + scope.changeSort = function(orderBy, orderType) { + scope.gotoPageAndSort(0, $routeParams.size, orderBy, orderType); + } + scope.gotoPage = function(page, pageSize) { scope.gotoPageAndSort(page, pageSize, $routeParams.orderBy, $routeParams.orderType); } -- 2.17.1 From d36c9b7a5e0b543a36023d38ee63d56a44aed3a3 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Fri, 29 Nov 2024 12:43:50 +0100 Subject: [PATCH 16/19] page and sorting --- .../controller/OrganizationController.java | 8 +-- .../OrganizationSimpleViewRepository.java | 30 +++++----- .../html/pages/search/resultsByType.html | 2 +- .../html/parts/org_results_page.html | 59 +++++++++++-------- .../static/resources/js/organizations.js | 34 ++++++++--- 5 files changed, 80 insertions(+), 53 deletions(-) diff --git a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/OrganizationController.java b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/OrganizationController.java index a9331c1c..82037224 100644 --- a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/OrganizationController.java +++ b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/OrganizationController.java @@ -234,10 +234,12 @@ public class OrganizationController extends AbstractDnetController { @RequestParam(required = false, defaultValue = "false") final boolean reverse, final Authentication authentication) { + final PageRequest pageRequest = PageRequest.of(page, size, Sort.by(reverse ? Order.desc(orderBy) : Order.asc(orderBy))); + if (SPECIAL_STATUS_FOR_CANDIDATE_DUP.equals(status)) { return UserInfo.isSuperAdmin(authentication) - ? organizationSimpleViewRepository.searchCandidateDuplicates(q, PageRequest.of(page, size)) - : organizationSimpleViewRepository.searchCandidateDuplicatesForUser(q, UserInfo.getEmail(authentication), PageRequest.of(page, size)); + ? organizationSimpleViewRepository.searchCandidateDuplicates(q, pageRequest) + : organizationSimpleViewRepository.searchCandidateDuplicatesForUser(q, UserInfo.getEmail(authentication), pageRequest); } final List statuses; if (StringUtils.isNotBlank(status)) { @@ -248,8 +250,6 @@ public class OrganizationController extends AbstractDnetController { statuses = Arrays.asList(OrganizationStatus.approved.toString(), OrganizationStatus.suggested.toString()); } - final PageRequest pageRequest = PageRequest.of(page, size, Sort.by(reverse ? Order.desc(orderBy) : Order.asc(orderBy))); - return UserInfo.isSuperAdmin(authentication) ? organizationSimpleViewRepository.search(q, statuses, pageRequest) : organizationSimpleViewRepository.searchForUser(q, UserInfo.getEmail(authentication), statuses, pageRequest); diff --git a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/repository/readonly/OrganizationSimpleViewRepository.java b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/repository/readonly/OrganizationSimpleViewRepository.java index 9da4534e..9e95f100 100644 --- a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/repository/readonly/OrganizationSimpleViewRepository.java +++ b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/repository/readonly/OrganizationSimpleViewRepository.java @@ -77,12 +77,12 @@ public interface OrganizationSimpleViewRepository extends ReadOnlyRepository searchCandidateDuplicates(@Param("text") String text, Pageable pageable); // SEARCH FOR VALID DUPLICATE CANDIDATES FOR USER @Query(value = "SELECT\n" - + " org.id,\n" - + " org.name,\n" - + " org.type,\n" - + " org.city,\n" - + " org.country,\n" - + " org.status,\n" + + " org.id AS id,\n" + + " org.name AS name,\n" + + " org.type AS type,\n" + + " org.city AS city,\n" + + " org.country AS country,\n" + + " org.status AS status,\n" + " array_remove(array_agg(DISTINCT a.acronym), NULL) AS acronyms,\n" + " array_remove(array_agg(DISTINCT u.url), NULL) AS urls,\n" + " NULL AS n_similar_dups,\n" @@ -120,8 +119,7 @@ public interface OrganizationSimpleViewRepository extends ReadOnlyRepository searchCandidateDuplicatesForUser(@Param("text") String text, @Param("email") String email, Pageable pageable); } diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/resultsByType.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/resultsByType.html index 740ec66d..ac569edf 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/resultsByType.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/pages/search/resultsByType.html @@ -1,5 +1,5 @@ diff --git a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html index f9c7f9ec..84e331b4 100644 --- a/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html +++ b/apps/dnet-orgs-database-application/src/main/resources/static/resources/html/parts/org_results_page.html @@ -8,7 +8,7 @@ {{searchMessage}} - Total elements:
+ Total elements:
fr {{searchMessage}}

@@ -21,29 +21,41 @@

No results

-
-
{{o.city || '-'}}, {{o.country}}
This organization - - - - - - + + + +