Skip to content

Commit

Permalink
Merge pull request #1099 from ORCID/userList
Browse files Browse the repository at this point in the history
User list
  • Loading branch information
bobcaprice authored Jan 25, 2024
2 parents ef6dff5 + 8324265 commit 7efe5d2
Show file tree
Hide file tree
Showing 11 changed files with 512 additions and 97 deletions.
6 changes: 4 additions & 2 deletions ui/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<router-outlet name="navbar"></router-outlet>
<router-outlet></router-outlet>
<router-outlet name="navbar"></router-outlet>
<div class="container-fluid">
<router-outlet></router-outlet>
</div>
<app-footer></app-footer>
4 changes: 0 additions & 4 deletions ui/src/app/layout/navbar/navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
Navbar
========================================================================== */

fa-icon {
margin-right: 0.5rem;
}

.bg-dark {
background-color: #202428 !important;
}
Expand Down
14 changes: 3 additions & 11 deletions ui/src/app/shared/alert/alert.component.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
<div class="alerts" role="alert">
<div *ngFor="let alert of alerts">
<ngb-alert *ngIf="alert && alert.type && alert.msg" [type]="alert.type" [dismissible]="false">
<ngb-alert *ngIf="alert && alert.type && alert.msg" [type]="alert.type" [dismissible]="false" class="alert-success">
<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 class="font-size-16 flex-grow-1">{{ alert.msg | localize }}</div>
<a (click)="close(alert)" (keyup)="closeOldestAlert()" tabindex="0" class="close">×</a>
</div>
</ngb-alert>
</div>
Expand Down
1 change: 0 additions & 1 deletion ui/src/app/shared/request-util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { HttpParams } from '@angular/common/http'

export const createRequestOption = (req?: any): HttpParams => {
console.log('creating pagination request')
let options: HttpParams = new HttpParams()
if (req) {
Object.keys(req).forEach((key) => {
Expand Down
131 changes: 131 additions & 0 deletions ui/src/app/user/service/user.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/* tslint:disable max-line-length */
import { TestBed, getTestBed } from '@angular/core/testing'
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'
import { take, map } from 'rxjs/operators'
import * as moment from 'moment'
import { DATE_TIME_FORMAT } from '../../app.constants'

import { IUser, User } from '../model/user.model'
import { UserService } from './user.service'
import { HttpHeaders } from '@angular/common/http'

describe('Service Tests', () => {
describe('Member service users service', () => {
let injector: TestBed
let service: UserService
let httpMock: HttpTestingController
let elemDefault: User
let result: any | null = null
let currentDate: moment.Moment
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
})
result = {}
injector = getTestBed()
service = injector.get(UserService)
httpMock = injector.get(HttpTestingController)
currentDate = moment()

elemDefault = new User(
'ID',
'AAAAAAA',
'AAAAAAA',
'AAAAAAA',
false,
'AAAAAAA',
'AAAAAAA',
'AAAAAAA',
'Member name',
currentDate,
'AAAAAAA',
false,
false,
currentDate
)
})

describe('Service methods', () => {
it('should create a user', async () => {
const returnedFromService = Object.assign(
{
id: 'ID',
createdDate: currentDate.format(DATE_TIME_FORMAT),
lastModifiedDate: currentDate.format(DATE_TIME_FORMAT),
},
elemDefault
)
const expected = Object.assign(
{
createdDate: currentDate,
lastModifiedDate: currentDate,
},
returnedFromService
)
service
.create(new User(undefined))
.pipe(take(1))
.subscribe((resp) => (result = resp))
const req = httpMock.expectOne({ method: 'POST' })
req.flush(returnedFromService)
expect(result).toEqual(expected)
})

it('should update a user', async () => {
const returnedFromService = Object.assign(
{
login: 'BBBBBB',
email: 'BBBBBB',
password: 'BBBBBB',
firstName: 'BBBBBB',
lastName: 'BBBBBB',
mainContact: true,
salesforceId: 'BBBBBB',
parentSalesforceId: 'BBBBBB',
activated: false,
createdBy: 'BBBBBB',
createdDate: currentDate.format(DATE_TIME_FORMAT),
lastModifiedBy: 'BBBBBB',
lastModifiedDate: currentDate.format(DATE_TIME_FORMAT),
},
elemDefault
)

const expected = Object.assign(
{
createdDate: currentDate,
lastModifiedDate: currentDate,
},
returnedFromService
)
service
.update(expected)
.pipe(take(1))
.subscribe((resp) => (result = resp))
const req = httpMock.expectOne({ method: 'PUT' })
req.flush(returnedFromService)
expect(result).toEqual(expected)
})

it('should return a list of users', async () => {
service
.query({ sort: ['name,desc', 'id'] })
.pipe(take(1))
.subscribe((body) => (result = body))

const req = httpMock.expectOne({ method: 'GET' })
const responseHeaders = new HttpHeaders().append('X-Total-Count', '100')
req.flush([new User('123')], { headers: responseHeaders })
httpMock.verify()
expect(result).toBeTruthy()
expect(result.users).toBeTruthy()
expect(result.users.length).toEqual(1)
expect(result.totalItems).toEqual(100)
})
})

afterEach(() => {
httpMock.verify()
})
})
})
1 change: 0 additions & 1 deletion ui/src/app/user/service/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ export class UserService {
}
})
const totalCount: string | null = res.headers.get('X-Total-Count')

if (totalCount) {
const userPage = new UserPage(res.body, parseInt(totalCount, 10))
return userPage
Expand Down
Loading

0 comments on commit 7efe5d2

Please sign in to comment.