Skip to content

Commit

Permalink
Merge pull request #537 from RADAR-base/release-release-0.6.2
Browse files Browse the repository at this point in the history
Release release 0.6.2
  • Loading branch information
nivemaham authored Dec 2, 2020
2 parents b49998a + a17b1b3 commit d424832
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 84 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ memory database and ManagementPortal.
The docker image can be pulled by running `docker pull radarbase/management-portal:0.6.1`.
The docker image can be pulled by running `docker pull radarbase/management-portal:0.6.2`.
## Configuration
Expand Down
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
allprojects {
group 'org.radarcns'

version '0.6.1' // project version
version '0.6.2' // project version

// The comment on the previous line is only there to identify the project version line easily
// with a sed command, to auto-update the version number with the prepare-release-branch.sh
Expand Down Expand Up @@ -195,7 +195,9 @@ dependencies {

testCompile "org.awaitility:awaitility:${awaitility_version}"
testCompile "com.jayway.jsonpath:json-path"
testCompile "org.springframework.boot:spring-boot-starter-test"
testCompile ("org.springframework.boot:spring-boot-starter-test") {
exclude group: "com.vaadin.external.google", module:"android-json"
}
testCompile "org.springframework.security:spring-security-test"
testCompile "org.springframework.boot:spring-boot-test"
testCompile "org.assertj:assertj-core:${assertj_version}"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "management-portal",
"version": "0.6.1",
"version": "0.6.2",
"description": "Description for ManagementPortal",
"private": true,
"cacheDirectories": [
Expand Down Expand Up @@ -75,7 +75,7 @@
"lodash": "4.17.13",
"map-stream": "0.0.7",
"mini-css-extract-plugin": "^0.7.0",
"node-sass": "^4.12.0",
"node-sass": "^4.13.1",
"phantomjs-prebuilt": "2.1.14",
"postcss-loader": "^2.0.0",
"protractor": "^5.4.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.radarcns.management.repository.filters;

import org.apache.commons.lang.StringUtils;
import org.radarcns.management.domain.Authority;
import org.radarcns.management.domain.Project;
import org.radarcns.management.domain.Role;
import org.radarcns.management.domain.User;
import org.radarcns.management.web.rest.util.FilterUtil;
import org.springframework.data.jpa.domain.Specification;

import javax.persistence.criteria.CriteriaBuilder;
Expand All @@ -15,44 +15,55 @@
import java.util.ArrayList;
import java.util.List;

import static org.radarcns.auth.authorization.AuthoritiesConstants.INACTIVE_PARTICIPANT;
import static org.radarcns.auth.authorization.AuthoritiesConstants.PARTICIPANT;

public class UserFilter implements Specification<User> {
private String login;
private String email;
private String projectName;
private String authority;

@Override
public Predicate toPredicate(Root<User> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
public Predicate toPredicate(Root<User> root, CriteriaQuery<?> query, CriteriaBuilder builder) {

List<Predicate> predicates = new ArrayList<>();

if (StringUtils.isNotBlank(login)) {
predicates
.add(cb.like(cb.lower(root.get("login")), "%" + login.trim().toLowerCase() + "%"));
Join<User, Role> roleJoin = root.join("roles");
Join<Role, Authority> authorityJoin = roleJoin.join("authority");
Predicate filterParticipants = builder.and(
builder.not(authorityJoin.get("name").in(PARTICIPANT, INACTIVE_PARTICIPANT)));
predicates.add(filterParticipants);

if (FilterUtil.isValid(login)) {
predicates.add(builder.like(
builder.lower(root.get("login")), "%" + login.trim().toLowerCase() + "%"));
}
if (StringUtils.isNotBlank(email)) {
predicates
.add(cb.like(cb.lower(root.get("email")), "%" + email.trim().toLowerCase() + "%"));
if (FilterUtil.isValid(email)) {
predicates.add(builder.like(
builder.lower(root.get("email")), "%" + email.trim().toLowerCase() + "%"));
}

if (StringUtils.isNotBlank(projectName)) {
Join<User, Role> roleJoin = root.join("roles");
if (FilterUtil.isValid(projectName)) {
Join<Role, Project> projectJoin = roleJoin.join("project");
predicates.add(cb.like(cb.lower(projectJoin.get("projectName")),
predicates.add(builder.like(builder.lower(projectJoin.get("projectName")),
"%" + projectName.trim().toLowerCase() + "%"));
}
if (StringUtils.isNotBlank(authority)) {
Join<User, Role> roleJoin = root.join("roles");
Join<Role, Authority> authorityJoin = roleJoin.join("authority");
predicates.add(cb.like(cb.lower(authorityJoin.get("name")),
"%" + authority.trim().toLowerCase() + "%"));
if (FilterUtil.isValid(authority)) {
Predicate filterByAuthority = builder.and(builder.like(
builder.lower(
authorityJoin.get("name")), "%" + authority.trim().toLowerCase() + "%"),
filterParticipants);
predicates.add(filterByAuthority);

} else {
predicates.add(filterParticipants);
}

if (predicates.isEmpty()) {
return null;
} else {
query.distinct(true);
return cb.and(predicates.toArray(new Predicate[0]));
return builder.and(predicates.toArray(new Predicate[0]));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.radarcns.management.web.rest.util;

import org.apache.commons.lang.StringUtils;

public class FilterUtil {
public static boolean isValid(String str) {
return StringUtils.isNotBlank(str) && !str.equals("null");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ <h4 jhiTranslate="userManagement.search.title">Filter by</h4>
<th jhiSortBy="email"><span jhiTranslate="userManagement.email">Email</span> <span class="fa fa-sort"></span></th>
<th></th>
<th jhiSortBy="langKey"> <span jhiTranslate="userManagement.langKey">Lang Key</span> <span class="fa fa-sort"></span></th>
<th jhiSortBy="roles.authorityName"><span jhiTranslate="userManagement.role.authorityName">Profiles</span><span class="fa fa-sort"></span></th>
<th jhiSortBy="lastModifiedDate"><span jhiTranslate="userManagement.role.project">Project</span> <span class="fa fa-sort"></span></th>
<th jhiSortBy="createdDate"><span jhiTranslate="userManagement.createdDate">Created Date</span> <span class="fa fa-sort"></span></th>
<th jhiSortBy="lastModifiedBy"><span jhiTranslate="userManagement.lastModifiedBy">Last Modified By</span> <span class="fa fa-sort"></span></th>
<th jhiSortBy="lastModifiedDate"><span jhiTranslate="userManagement.lastModifiedDate">Last Modified Date</span> <span class="fa fa-sort"></span></th>
<th><span jhiTranslate="userManagement.role.authorityName">Profiles</span></th>
<th><span jhiTranslate="userManagement.role.project">Project</span></th>
<th><span jhiTranslate="userManagement.createdDate">Created Date</span></th>
<th><span jhiTranslate="userManagement.lastModifiedBy">Last Modified By</span></th>
<th><span jhiTranslate="userManagement.lastModifiedDate">Last Modified Date</span></th>
<th></th>
</tr>
</thead>
Expand Down
3 changes: 2 additions & 1 deletion src/main/webapp/app/blocks/interceptor/auth.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ export class AuthInterceptor implements HttpInterceptor {
if (!!tokenString) {
const token: TokenData = JSON.parse(tokenString);
if (!!token && token.expires_at && token.expires_at > new Date().getTime()) {
request = request.clone({
const newReq = request.clone({
setHeaders: {
Authorization: 'Bearer ' + token.access_token
}
});
return next.handle(newReq);
}
}
return next.handle(request);
Expand Down
4 changes: 4 additions & 0 deletions src/main/webapp/app/shared/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ export class JhiLoginModalComponent implements AfterViewInit {

// // previousState was set in the authExpiredInterceptor before being redirected to login modal.
// // since login is succesful, go to stored previousState and clear previousState

const redirect = this.stateStorageService.getUrl();
if (redirect) {
this.stateStorageService.storeUrl(null);
this.router.navigate([redirect]);
} else {
this.router.navigate(['/']);
}
}).catch(() => {
this.authenticationError = true;
Expand Down
15 changes: 8 additions & 7 deletions src/main/webapp/app/shared/model/request.utils.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { HttpParams } from '@angular/common/http';

export const createRequestOption = (req?: RequestOptions): HttpParams => {
export const createRequestOption = (req?: any): HttpParams => {
let options: HttpParams = new HttpParams();
if (req) {
Object.keys(req).forEach((key) => {
if (Array.isArray(req[key])) {
const values: [string] = req[key] as [string];
values.forEach(value => options.append(key, value));
} else {
const value = req[key] as string;
options = options.set(key, value);
if (key !== 'sort' && req[key]) {
options = options.set(key, req[key]);
}
});
if (req.sort) {
req.sort.forEach((val) => {
options = options.append('sort', val);
});
}
}
return options;
};
Expand Down
6 changes: 3 additions & 3 deletions src/main/webapp/app/shared/subject/subject.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ <h4>
<table class="table table-striped">
<thead>
<tr jhiSort [(predicate)]="predicate" [(ascending)]="reverse" [callback]="transition.bind(this)">
<th ><span jhiTranslate="managementPortalApp.subject.subjectId">subjectId</span></th>
<th ><span jhiTranslate="managementPortalApp.subject.externalId">Enternal Id</span></th>
<th ><span jhiTranslate="managementPortalApp.subject.status.title">Status</span></th>
<th jhiSortBy="user.login" ><span jhiTranslate="managementPortalApp.subject.subjectId">subjectId</span><span class="fa fa-sort"></span></th>
<th jhiSortBy="externalId" ><span jhiTranslate="managementPortalApp.subject.externalId">Enternal Id</span><span class="fa fa-sort"></span></th>
<th jhiSortBy="user.activated"><span jhiTranslate="managementPortalApp.subject.status.title">Status</span><span class="fa fa-sort"></span></th>
<th *ngIf="!isProjectSpecific"><span jhiTranslate="managementPortalApp.subject.project">Project</span></th>
<th><span jhiTranslate="managementPortalApp.subject.sources">Sources</span></th>
<th><span jhiTranslate="managementPortalApp.subject.attributeData">Attributes</span></th>
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/i18n/en/user-management.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"firstName": "First name",
"lastName": "Last name",
"email": "Email",
"activated": "Geactiveerd",
"deactivated": "Gedeactiveerd",
"activated": "Activated",
"deactivated": "Deactivated",
"profiles": "Authorities",
"langKey": "Language",
"createdBy": "Created by",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.radarcns.auth.authorization.AuthoritiesConstants;
import org.radarcns.management.ManagementPortalTestApp;
import org.radarcns.management.config.ManagementPortalProperties;
import org.radarcns.management.domain.Authority;
import org.radarcns.management.domain.Role;
import org.radarcns.management.domain.User;
import org.radarcns.management.repository.SubjectRepository;
import org.radarcns.management.repository.UserRepository;
Expand All @@ -34,6 +36,7 @@
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import java.util.HashSet;
import java.util.Collections;
import java.util.List;
import java.util.Set;

Expand All @@ -52,6 +55,7 @@
import static org.radarcns.management.service.UserServiceIntTest.UPDATED_LOGIN;
import static org.radarcns.management.service.UserServiceIntTest.UPDATED_PASSWORD;
import static org.radarcns.management.service.UserServiceIntTest.createEntity;
import static org.radarcns.auth.authorization.AuthoritiesConstants.SYS_ADMIN;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
Expand Down Expand Up @@ -125,7 +129,6 @@ public void setUp() throws ServletException {
}



@Before
public void initTest() {
user = createEntity();
Expand All @@ -139,7 +142,7 @@ public void createUser() throws Exception {
// Create the User
Set<RoleDTO> roles = new HashSet<>();
RoleDTO role = new RoleDTO();
role.setAuthorityName(AuthoritiesConstants.SYS_ADMIN);
role.setAuthorityName(SYS_ADMIN);
roles.add(role);

ManagedUserVM managedUserVm = createDefaultUser(roles);
Expand Down Expand Up @@ -238,7 +241,21 @@ public void createUserWithExistingEmail() throws Exception {
@Transactional
public void getAllUsers() throws Exception {
// Initialize the database
userRepository.saveAndFlush(user);
Role adminRole = new Role();
adminRole.setId(1L);
adminRole.setAuthority(new Authority(SYS_ADMIN));
adminRole.setProject(null);

User userWithRole = new User();
userWithRole.setLogin(DEFAULT_LOGIN);
userWithRole.setPassword(RandomStringUtils.random(60));
userWithRole.setActivated(true);
userWithRole.setEmail(DEFAULT_EMAIL);
userWithRole.setFirstName(DEFAULT_FIRSTNAME);
userWithRole.setLastName(DEFAULT_LASTNAME);
userWithRole.setLangKey(DEFAULT_LANGKEY);
userWithRole.setRoles(Collections.singleton(adminRole));
userRepository.saveAndFlush(userWithRole);

// Get all the users
restUserMockMvc.perform(get("/api/users?sort=id,desc")
Expand Down
10 changes: 5 additions & 5 deletions src/test/javascript/e2e/entities/user-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Create, edit, and delete user', () => {
await element(by.cssContainingText('button.btn-primary', 'Save')).click();
await browser.waitForAngular();

expect((await element.all(by.css('jhi-user-mgmt tbody tr')).count())).toEqual(8);
expect((await element.all(by.css('jhi-user-mgmt tbody tr')).count())).toEqual(4);
});

it('should be able to create new system admin user', async() => {
Expand All @@ -61,7 +61,7 @@ describe('Create, edit, and delete user', () => {

await element(by.cssContainingText('button.btn-primary', 'Save')).click();
await browser.waitForAngular();
expect((await element.all(by.css('jhi-user-mgmt tbody tr')).count())).toEqual(9);
expect((await element.all(by.css('jhi-user-mgmt tbody tr')).count())).toEqual(5);
});

it('should be able to edit a user with roles', async() => {
Expand All @@ -73,7 +73,7 @@ describe('Create, edit, and delete user', () => {
await element(by.cssContainingText('button.btn-primary', 'Save')).click();

await browser.waitForAngular();
expect((await element.all(by.css('jhi-user-mgmt tbody tr')).count())).toEqual(9);
expect((await element.all(by.css('jhi-user-mgmt tbody tr')).count())).toEqual(5);
});

it('should be able to delete a user with roles', async() => {
Expand All @@ -85,7 +85,7 @@ describe('Create, edit, and delete user', () => {
.click();

await browser.waitForAngular();
expect((await element.all(by.css('jhi-user-mgmt tbody tr')).count())).toEqual(8);
expect((await element.all(by.css('jhi-user-mgmt tbody tr')).count())).toEqual(4);
});

it('should be able to delete a sys admin user', async() => {
Expand All @@ -97,6 +97,6 @@ describe('Create, edit, and delete user', () => {
.click();

await browser.waitForAngular();
expect((await element.all(by.css('jhi-user-mgmt tbody tr')).count())).toEqual(7);
expect((await element.all(by.css('jhi-user-mgmt tbody tr')).count())).toEqual(3);
});
});
Loading

0 comments on commit d424832

Please sign in to comment.