Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

user infrastructure #1090

Closed
wants to merge 15 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,15 @@ public class MemberResource {
*
* @param member the member to create.
* @return the {@link ResponseEntity} with status {@code 201 (Created)} and
* with body the new member, or with status
* {@code 400 (Bad Request)} if the member has already an ID.
* with body the new member, or with status
* {@code 400 (Bad Request)} if the member has already an ID.
* @throws URISyntaxException if the Location URI syntax is incorrect.
* @throws JSONException
*/
@PostMapping("/members")
@PreAuthorize("hasRole(\"ROLE_ADMIN\")")
public ResponseEntity<Member> createMember(@Valid @RequestBody Member member) throws URISyntaxException, JSONException {
public ResponseEntity<Member> createMember(@Valid @RequestBody Member member)
throws URISyntaxException, JSONException {
LOG.debug("REST request to save Member : {}", member);
Member created = memberService.createMember(member);
return ResponseEntity.created(new URI("/api/member/" + created.getId())).body(created);
Expand All @@ -107,13 +108,14 @@ public ResponseEntity<Member> createMember(@Valid @RequestBody Member member) th
*
* @param member the member to validate.
* @return the {@link ResponseEntity} with status {@code 200 (Ok)} and with
* a MemberValidation object in the body.
* a MemberValidation object in the body.
* @throws URISyntaxException if the Location URI syntax is incorrect.
* @throws JSONException
*/
@PostMapping("/members/validate")
@PreAuthorize("hasRole(\"ROLE_ADMIN\")")
public ResponseEntity<MemberValidation> validateMember(@Valid @RequestBody Member member) throws URISyntaxException, JSONException {
public ResponseEntity<MemberValidation> validateMember(@Valid @RequestBody Member member)
throws URISyntaxException, JSONException {
MemberValidation validation = memberService.validateMember(member);
return ResponseEntity.ok(validation);
}
Expand All @@ -123,8 +125,8 @@ public ResponseEntity<MemberValidation> validateMember(@Valid @RequestBody Membe
*
* @param file: file containing the member to create.
* @return the {@link ResponseEntity} with status {@code 201 (Created)} and
* with a map indicating if each user was created or not, or with
* status {@code 400 (Bad Request)} if the file cannot be parsed.
* with a map indicating if each user was created or not, or with
* status {@code 400 (Bad Request)} if the file cannot be parsed.
* @throws Throwable
*/
@PostMapping("/members/upload")
Expand All @@ -140,16 +142,17 @@ public ResponseEntity<String> uploadMember(@RequestParam("file") MultipartFile f
*
* @param member the member to update.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with
* body the updated member, or with status {@code 400 (Bad Request)}
* if the member is not valid, or with status
* {@code 500 (Internal Server Error)} if the member couldn't be
* updated.
* body the updated member, or with status {@code 400 (Bad Request)}
* if the member is not valid, or with status
* {@code 500 (Internal Server Error)} if the member couldn't be
* updated.
* @throws URISyntaxException if the Location URI syntax is incorrect.
* @throws JSONException
*/
@PutMapping("/members")
@PreAuthorize("hasRole(\"ROLE_ADMIN\")")
public ResponseEntity<Member> updateMember(@Valid @RequestBody Member member) throws URISyntaxException, JSONException {
public ResponseEntity<Member> updateMember(@Valid @RequestBody Member member)
throws URISyntaxException, JSONException {
LOG.debug("REST request to update Member : {}", member);
Optional<Member> existentMember = memberService.getMember(member.getId());
if (!existentMember.isPresent()) {
Expand All @@ -159,20 +162,21 @@ public ResponseEntity<Member> updateMember(@Valid @RequestBody Member member) th
return ResponseEntity.ok().body(member);
}


/**
* {@code POST /members/:id/language/:language } : Updates an existing member's default language.
* {@code POST /members/:id/language/:language } : Updates an existing member's
* default language.
*
* @param salesforceId - the salesforceId of the member to update
* @param language - the language of the member to update
* @return the {@link ResponseEntity} with status {@code 200 (OK)},
* or with status {@code 400 (Bad Request)}
* if the member is not valid, or with status
* {@code 500 (Internal Server Error)} if the member couldn't be
* updated.
* or with status {@code 400 (Bad Request)}
* if the member is not valid, or with status
* {@code 500 (Internal Server Error)} if the member couldn't be
* updated.
*/
@PostMapping("/members/{salesforceId}/language/{language}")
public ResponseEntity<Void> updateMemberDefaultLanguage(@PathVariable String salesforceId, @PathVariable String language) {
public ResponseEntity<Void> updateMemberDefaultLanguage(@PathVariable String salesforceId,
@PathVariable String language) {
LOG.info("REST request to update default language for member : {}", salesforceId);
try {
memberService.updateMemberDefaultLanguage(salesforceId, language);
Expand All @@ -182,14 +186,15 @@ public ResponseEntity<Void> updateMemberDefaultLanguage(@PathVariable String sal
return ResponseEntity.ok().build();
}


/**
* {@code PUT /members/{salesforceId}/member-details} : update details of member specified by salesforceID
* {@code PUT /members/{salesforceId}/member-details} : update details of member
* specified by salesforceID
*
* @return the {@link MemberUpdateData}
*/
@PutMapping("/members/{salesforceId}/member-details")
public ResponseEntity<Boolean> updatePublicMemberDetails(@RequestBody MemberUpdateData memberUpdateData, @PathVariable String salesforceId) {
public ResponseEntity<Boolean> updatePublicMemberDetails(@RequestBody MemberUpdateData memberUpdateData,
@PathVariable String salesforceId) {
LOG.info("REST request to update member public details for salesforce id {}", salesforceId);
if (StringUtils.isBlank(memberUpdateData.getPublicName())) {
LOG.info("Null name in request to update public details");
Expand All @@ -204,7 +209,8 @@ public ResponseEntity<Boolean> updatePublicMemberDetails(@RequestBody MemberUpda
}

/**
* {@code GET /members/{salesforceId}/member-details} : get details of member specified by salesforceId param
* {@code GET /members/{salesforceId}/member-details} : get details of member
* specified by salesforceId param
*
* @return the {@link MemberDetails}
*/
Expand All @@ -226,9 +232,9 @@ public ResponseEntity<List<Country>> getSalesforceCountries() {
return ResponseEntity.ok(countries);
}


/**
* {@code GET /members/{salesforceId}/member-contacts} : get contacts of member specified by salesforceId param
* {@code GET /members/{salesforceId}/member-contacts} : get contacts of member
* specified by salesforceId param
*
* @return the {@link MemberDetails}
*/
Expand All @@ -244,7 +250,8 @@ public ResponseEntity<MemberContacts> getMemberContacts(@PathVariable String sal
}

/**
* {@code GET /members/{salesforceId}/member-org-ids} : get org ids of member specified by salesforceId param
* {@code GET /members/{salesforceId}/member-org-ids} : get org ids of member
* specified by salesforceId param
*
* @return the {@link MemberDetails}
*/
Expand All @@ -264,11 +271,12 @@ public ResponseEntity<MemberOrgIds> getMemberOrgIds(@PathVariable String salesfo
*
* @param pageable the pagination information.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and the
* list of member in body.
* list of member in body.
*/
@GetMapping("/members")
@PreAuthorize("hasRole(\"ROLE_ADMIN\")")
public ResponseEntity<List<Member>> getAllMembers(@RequestParam(required = false, name = "filter") String filter, Pageable pageable) {
public ResponseEntity<List<Member>> getAllMembers(@RequestParam(required = false, name = "filter") String filter,
Pageable pageable) {
LOG.debug("REST request to get a page of Member");
Page<Member> page = null;
if (StringUtils.isBlank(filter)) {
Expand All @@ -283,15 +291,16 @@ public ResponseEntity<List<Member>> getAllMembers(@RequestParam(required = false
}
page = memberService.getMembers(pageable, decodedFilter);
}
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page);
HttpHeaders headers = PaginationUtil
.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page);
return ResponseEntity.ok().headers(headers).body(page.getContent());
}

/**
* {@code GET /member} : get all the member.
*
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and the
* list of member in body.
* list of member in body.
*/
@GetMapping("/members/list/all")
@PreAuthorize("hasRole(\"ROLE_ADMIN\")")
Expand All @@ -306,24 +315,28 @@ public ResponseEntity<List<Member>> getMembersList() {
*
* @param id - the id or salesforce id of the member to retrieve.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with
* body the member, or with status {@code 404 (Not Found)}.
* body the member, or with status {@code 404 (Not Found)}.
*/
@GetMapping("/members/{id}")
public ResponseEntity<Member> getMember(@PathVariable String id) {
LOG.debug("REST request to get Member : {}", id);
Optional<Member> member = memberService.getMember(id);
if (!member.isPresent()) {
LOG.warn("Can't find member with id {}", id);
}
return ResponseUtil.wrapOrNotFound(member);
}

/**
* {@code GET /members/authorized/:encryptedEmail} : get the authorized
* member details for the specified encrypted email.
*
* @param encryptedEmail - the encrypted email of the user that has authorized the
* @param encryptedEmail - the encrypted email of the user that has authorized
* the
* member
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with
* the member details in the body, or status
* {@code 404 (Not Found)}.
* the member details in the body, or status
* {@code 404 (Not Found)}.
*/
@GetMapping("/members/authorized/{encryptedEmail}")
public ResponseEntity<Member> getAuthorizedMember(@PathVariable String encryptedEmail) {
Expand All @@ -347,8 +360,9 @@ public ResponseEntity<Void> deleteMember(@PathVariable String id) {
}

@PostMapping("/members/{salesforceId}/contact-update")
public ResponseEntity<MemberContactUpdateResponse> processMemberContactUpdate(@RequestBody MemberContactUpdate memberContactUpdate,
@PathVariable String salesforceId) {
public ResponseEntity<MemberContactUpdateResponse> processMemberContactUpdate(
@RequestBody MemberContactUpdate memberContactUpdate,
@PathVariable String salesforceId) {
LOG.debug("REST request to create new member contact update for member {}", salesforceId);
try {
memberService.processMemberContact(memberContactUpdate, salesforceId);
Expand All @@ -368,7 +382,8 @@ public ResponseEntity<Void> requestNewConsortiumMember(@RequestBody AddConsortiu

@PreAuthorize("hasRole(\"ROLE_CONSORTIUM_LEAD\")")
@PostMapping("/members/remove-consortium-member")
public ResponseEntity<Void> requestRemoveConsortiumMember(@RequestBody RemoveConsortiumMember removeConsortiumMember) {
public ResponseEntity<Void> requestRemoveConsortiumMember(
@RequestBody RemoveConsortiumMember removeConsortiumMember) {
LOG.debug("REST request to request remove consortium member");
memberService.requestRemoveConsortiumMember(removeConsortiumMember);
return ResponseEntity.ok().build();
Expand Down
10 changes: 8 additions & 2 deletions ui/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { NgModule } from '@angular/core'
import { RouterModule, Routes } from '@angular/router'
import { ActivatedRouteSnapshot, Resolve, Route, RouterModule, RouterStateSnapshot, Routes } from '@angular/router'
import { navbarRoute } from './layout/navbar/navbar.route'
import { errorRoutes } from './error/error.route'
import { AuthGuard } from './account/auth.guard'
import { UsersComponent } from './user/users.component'

const routes: Routes = [
{
Expand All @@ -12,10 +14,14 @@ const routes: Routes = [
path: '',
loadChildren: () => import('./home/home.module').then((m) => m.HomeModule),
},
{
path: 'users',
loadChildren: () => import('./user/user.module').then((m) => m.UserModule),
},
]

@NgModule({
imports: [RouterModule.forRoot([...routes, ...errorRoutes, navbarRoute])],
imports: [RouterModule.forRoot([...routes, navbarRoute, ...errorRoutes])],
exports: [RouterModule],
})
export class AppRoutingModule {}
12 changes: 11 additions & 1 deletion ui/src/app/app.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@ export enum EventType {
LOG_IN_SUCCESS = 'LOG_IN_SUCCESS',
AFFILIATION_CREATED = 'AFFILIATION_CREATED',
AFFILIATION_UPDATED = 'AFFILIATION_UPDATED',
// add as we go
USER_LIST_MODIFIED = 'USER_LIST_MODIFIED',
}

export enum AlertType {
SEND_ACTIVATION_SUCCESS = 'Invite sent.',
SEND_ACTIVATION_FAILURE = 'Invite email couldn`t be sent.',
}

export const EMAIL_NOT_FOUND_TYPE = 'https://www.jhipster.tech/problem/email-not-found'

export const DATE_FORMAT = 'YYYY-MM-DD'
export const DATE_TIME_FORMAT = 'YYYY-MM-DDTHH:mm'

export const ITEMS_PER_PAGE = 20
13 changes: 7 additions & 6 deletions ui/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,27 @@ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'
import { NavbarComponent } from './layout/navbar/navbar.component'
import { CommonModule } from '@angular/common'
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
import { HasAnyAuthorityDirective } from './shared/directive/has-any-authority.directive'
import { HomeModule } from './home/home.module'
import { FooterComponent } from './layout/footer/footer.component'
import { SharedModule } from './shared/shared.module'
import { HeaderInterceptor } from './shared/interceptor/header.interceptor'
import { ErrorService } from './error/service/error.service';
import { ErrorService } from './error/service/error.service'
import { ErrorComponent } from './error/error.component'
import { FormsModule } from '@angular/forms'
import { UserModule } from './user/user.module'

@NgModule({
declarations: [AppComponent, NavbarComponent, HasAnyAuthorityDirective, FooterComponent, ErrorComponent],
declarations: [AppComponent, NavbarComponent, FooterComponent, ErrorComponent],
imports: [
FontAwesomeModule,
BrowserModule,
UserModule,
AccountModule,
HomeModule,
BrowserModule,
HttpClientModule,
AppRoutingModule,
NgxWebstorageModule.forRoot(),
CommonModule,
NgbModule,
FormsModule,
SharedModule.forRoot(),
],
providers: [
Expand Down
3 changes: 1 addition & 2 deletions ui/src/app/error/model/error.model.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
export class AppError {
constructor(
public statusCode: number,
public message: string,
public i18nKey: string | null
public message: string
) {}
}

Expand Down
7 changes: 1 addition & 6 deletions ui/src/app/error/service/error.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ export class ErrorService implements ErrorHandler {

handleError(error: any) {
if (error instanceof HttpErrorResponse) {
if (error.headers.has('errmmmmm')) {
const i18nKey: string | null = error.headers.get('errmmmmm')
this.errors.next(new AppError(error.status, error.message, i18nKey))
} else {
this.errors.next(new AppError(error.status, error.message, null))
}
this.errors.next(new AppError(error.status, error.message))
} else {
console.error('Unknown error occurred', error)
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/layout/navbar/navbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
<li>
<a
class="dropdown-item"
routerLink="user"
routerLink="/users"
routerLinkActive="active"
[routerLinkActiveOptions]="{ exact: true }"
(click)="collapseNavbar()"
Expand Down
18 changes: 18 additions & 0 deletions ui/src/app/shared/alert/alert.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="alerts" role="alert">
<div *ngFor="let alert of alerts">
<ngb-alert *ngIf="alert && alert.type && alert.msg" [type]="alert.type" [dismissible]="false">
<div class="d-flex">
<div class="font-size-16">{{ alert.msg | localize }}</div>
<a (click)="close(alert)" (keyup)="closeOldestAlert()" tabindex="0">
<svg width="12" height="12" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M16 1.61143L14.3886 0L8 6.38857L1.61143 0L0 1.61143L6.38857 8L0 14.3886L1.61143 16L8 9.61143L14.3886 16L16 14.3886L9.61143 8L16 1.61143Z"
fill="black"
fill-opacity="0.9"
/>
</svg>
</a>
</div>
</ngb-alert>
</div>
</div>
Empty file.
21 changes: 21 additions & 0 deletions ui/src/app/shared/alert/alert.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { AlertComponent } from './alert.component';

describe('AlertComponent', () => {
let component: AlertComponent;
let fixture: ComponentFixture<AlertComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [AlertComponent]
});
fixture = TestBed.createComponent(AlertComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Loading