-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(simulator-ui): visual improvements
* configurable page-size per table * refresh button on results (landing page) * possibility to reset test-results (landing page)
- Loading branch information
Showing
55 changed files
with
609 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
simulator-ui/src/main/webapp/app/core/config/user-preference.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { ITEMS_PER_PAGE } from 'app/config/pagination.constants'; | ||
|
||
import { UserPreferenceService } from './user-preference.service'; | ||
|
||
type Mock = jest.Mock; | ||
|
||
describe('UserPreferenceService', () => { | ||
let service: UserPreferenceService; | ||
let mockLocalStorage: Partial<Storage> & { | ||
setItem: Mock; | ||
getItem: Mock; | ||
removeItem: Mock; | ||
}; | ||
|
||
beforeEach(() => { | ||
mockLocalStorage = { | ||
setItem: jest.fn(), | ||
getItem: jest.fn(), | ||
removeItem: jest.fn(), | ||
}; | ||
|
||
Object.defineProperty(window, 'localStorage', { value: mockLocalStorage, writable: true }); | ||
|
||
TestBed.configureTestingModule({ | ||
providers: [UserPreferenceService], | ||
}); | ||
|
||
service = TestBed.inject(UserPreferenceService); | ||
}); | ||
|
||
describe('setPreferredPageSize', () => { | ||
it('should return known item from localStorage', () => { | ||
mockLocalStorage.getItem.mockReturnValueOnce('1234'); | ||
|
||
const preferredPageSize = service.getPreferredPageSize('key'); | ||
|
||
expect(preferredPageSize).toEqual(1234); | ||
expect(mockLocalStorage.getItem).toHaveBeenCalledWith('psize-key'); | ||
}); | ||
|
||
it('should return default page size if item is not in localStorage', () => { | ||
mockLocalStorage.getItem.mockReturnValueOnce(null); | ||
|
||
const preferredPageSize = service.getPreferredPageSize('key'); | ||
|
||
expect(preferredPageSize).toEqual(ITEMS_PER_PAGE); | ||
expect(mockLocalStorage.getItem).toHaveBeenCalledWith('psize-key'); | ||
}); | ||
}); | ||
|
||
describe('setPreferredPageSize', () => { | ||
it('should save item in localStorage', () => { | ||
service.setPreferredPageSize('key', 1234); | ||
|
||
expect(mockLocalStorage.setItem).toHaveBeenCalledWith('psize-key', '1234'); | ||
}); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
simulator-ui/src/main/webapp/app/core/config/user-preference.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Injectable } from '@angular/core'; | ||
|
||
import { ITEMS_PER_PAGE } from 'app/config/pagination.constants'; | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
export class UserPreferenceService { | ||
private paginationPrefix = 'psize'; | ||
|
||
public getPreferredPageSize(key: string): number { | ||
return Number(localStorage.getItem(this.paginationId(key)) ?? ITEMS_PER_PAGE); | ||
} | ||
|
||
public setPreferredPageSize(key: string, size: number): void { | ||
localStorage.setItem(this.paginationId(key), size.toString()); | ||
} | ||
|
||
private paginationId(key: string): string { | ||
return `${this.paginationPrefix}-${key}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.