fp-ng-components
v2.2.0
Published
This project is the shared components and helpers that are being using for most fast-pack apps
Downloads
9
Maintainers
Keywords
Readme
fast-pack-app-components
Available modules
- FpAutoFocusModule
- FpAlertModule
- FpLoadingModule
- FpProductNumberModule
- FpAuthModule - use forRoot
- FpEventModule - use forRoot
- FpLocalStorageModule - use forRoot
- FpNewRelicModule - use forRoot
The forRoot functions take the following variables:
FpLocalStorageModule.forRoot(prefix: string)
FpAuthModule.forRoot({
userServiceAPI: string,
parentURL: string,
serviceName: string
})
FpEventModule.forRoot({
eventServiceAPI: string,
warehouseCode: string
})
FpNewRelicModule.forRoot({
serviceName: string,
appVersion: string
})
Inter Module Dependencies
The following modules use the modules in the 'Includes' column optionally. | Module | Includes | |--|--| |FpAuthModule| FpNewRelicModule, FpLoadingModule, FpAlertModule | |FpLoadingModeule | FpAlertModule |
Available Services
- FpAlertService
- FpAuthService
- FpEventService
- FpLoadingService
- FpLocalStorageService
- FpNewRelicService
Others
- FpAuthGuard
- fpAutoFocus
- fpProductNumber
- FpUserModel
- FpRoleModel
Notes
To use the FpAlertService
you have to add "../node_modules/ngx-toastr/toastr.css"
to the styles section of angular-cli.json
FpAlertService
|Function| Input |Explination| |-|-|-| |success| message: string, options?: IndividualConfig| Display success message. | |error| message: string, options?: IndividualConfig| Display error message. | |info| message: string, options?: IndividualConfig| Display info message. | |warn| message: string, options?: IndividualConfig| Display warning message. | |handleError | error: HttpErrorResponse | TimeoutError | any | This is for handling most common errors that would get thrown from angular HttpErrors, and thrown errors.| | clear| N/A | Clears all notifications from page.| |IndividualConfig| Interface|See https://github.com/scttcper/ngx-toastr/blob/master/src/lib/toastr/toastr-config.ts for documentation. |
FpAuthGuard
Only implements the canActivate
function.
In order to use the FpAuthGuard data.allowedRoles
must exist in the Router module.
FpAuthService
|Function| Input |Explination|
|-|-|-|
|isAuthenticated| N/A| Calls the user service to check the bearer token saved inside the cookie. |
|hasRequiredRole| requiredRoles: string | string[]| Checks the user for the roles passed in. |
This has a user
. That user is UserModel, and is the currently logged in user. If you need to get anything about the currently logged in user use this attribuite.
The authInterceptor that will be added automatically and add the bearer token to all API calls.
fpAutoFocus
Make any input auto focus by adding the fpAutoFocus
attribute to the input tag.
To not let people click outside of the input field do the following:
<input [fpAutoFocus]="true">
FpEventService
|Function| Input |Explination| |-|-|-| |createEvent| name: string, eventData?: any | This will send any data to the event service. |
FpLoadingService
|Function| Input |Explination|
|-|-|-|
|startLoading | timeoutDuration: number = 30 * 1000| Overlay the loading screen. timeoutDuration
is in seconds. |
|stopLoading | N/A | Remove the overlay. |
|isLoading | N/A | Test whether the overlay is set. |
|loadingHeartbeat | timeoutDuration: number = 10 * 1000| Keep the overlay running and place new timer. timeoutDuration
is in seconds. |
FpLocalStorageService
|Function| Input |Explination| |-|-|-| |get | key: string, defaultItem: any = null) | Returns a JSON object from the localStorage. Default is what is returned when there is nothing in localStorage. | |set | key: string, value: any | Set localStorage value. | |remove | key: string | Remove the key from localStorage. | |clear | | Remove everything from localStorage set by this service. |
FpNewRelicService
|Function| Input |Explination| |-|-|-| | setUserUuid |uuid: string| Set the user uuid before doing anything. This makes sure that New Relic will have the user for every error reported. |
- By including the FpNewRelicModule it will overwrite the standard Angular error handler with the new Relic error handler. Errors will be sent to New Relic.
FpVersionCheckerService
|Function| Input |Explination| |-|-|-| | checkAppVersion |config: object| Start listening for version change by checking package.json file by polling the file remotely. |
fpProductNumber
Name of the pipe fpProductNumber
This pipe will take a upc and turn it into a more recognizable string by removing the check digit and showing only the last few characters. It aslo will handle a bad UPC or no UPC.
FpUserModel
|Attribute| Type |Explanation| |-|-|-| |uuid| string| The users database id. | |roles| FpRoleModel[]| The roles owned by the user. | |email| string| Users email. | |firstName| string|Users first name. | |lastName| string|Users last name. | |username| string|Users username. | |barcodeLogin| boolean| Whether the user is allowed to log into the system with a barcode or not. | |password| string| Users Password. | |createdAt| Date|Date role was created. | |updatedAt| Date|Last update time. | |hasRole|(roleSlug: string)=>{boolean}| Pass in the role you want to check the user for. It will return true if the user has the role. |
FpRoleModel
|Attribute| Type |Explanation| |-|-|-| |slug| string| The name of the role.| |roleName| string| The human readable role name.| |createdAt| Date| Date role was created.| |updatedAt| Date| Last update time.| |updatedBy| string| Who updated the role last.|