@fhss-web-team/frontend-utils 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +197 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  This package is designed for use in Angular applications and includes integration with Keycloak for authentication.
6
6
 
7
- ## 📆 Installation
7
+ ## Installation
8
8
 
9
9
  Install the package and its required peer dependencies:
10
10
 
@@ -12,8 +12,199 @@ Install the package and its required peer dependencies:
12
12
  npm install @fhss-web-team/frontend-utils
13
13
  ```
14
14
 
15
- ## 🚀 Usage
16
- Refer to each directory’s `README.md` for specific exports and usage patterns:
17
- - [Components](./src/lib/components/README.md)
18
- - [Services](./src/lib/services/README.md)
19
- - [Signals](./src/lib/signals/README.md)
15
+ # Documentation
16
+ - [Components](#components)
17
+ - [Services](#services)
18
+ - [Signals](#signals)
19
+
20
+ ## Components
21
+
22
+ This directory contains reusable Angular components designed to streamline development and maintain consistency across BYU websites.
23
+
24
+ ### BYU Header
25
+ This is the header displayed on all BYU websites. It displays the BYU logo, site title, breadcrumbs, and navigation menu.
26
+
27
+ #### Features:
28
+ - **Logo**: Displays the BYU logo.
29
+ - **Title and Subtitle**: Configurable links for the site title and subtitle.
30
+ - **Breadcrumbs**: Displays a breadcrumb trail for navigation.
31
+ - **Navigation Menu**: Supports both simple links and dropdown menus.
32
+ - **Authentication**: Integrates with the [auth service](#auth) to display user information and provide sign-in/sign-out functionality.
33
+
34
+ #### Configuration:
35
+ The header is configured using a `HeaderConfig` object. Below is the structure:
36
+
37
+ ```typescript
38
+ type HeaderLink = {
39
+ text: string;
40
+ path: string;
41
+ };
42
+
43
+ type HeaderMenu = HeaderLink | {
44
+ text: string;
45
+ items: HeaderLink[];
46
+ };
47
+
48
+ export type HeaderConfig = {
49
+ title: HeaderLink;
50
+ subtitle?: HeaderLink;
51
+ breadcrumbs?: HeaderLink[];
52
+ menu?: HeaderMenu[];
53
+ };
54
+ ```
55
+
56
+ #### Usage:
57
+ Pass the `HeaderConfig` object to the `byu-header` component:
58
+
59
+ ```html
60
+ <byu-header [config]="headerConfig"></byu-header>
61
+ ```
62
+
63
+ Example `HeaderConfig`:
64
+
65
+ ```typescript
66
+ const headerConfig = {
67
+ title: { text: 'Home', path: '/' },
68
+ subtitle: { text: 'About Us', path: '/about' },
69
+ breadcrumbs: [
70
+ { text: 'Home', path: '/' },
71
+ { text: 'Section', path: '/section' }
72
+ ],
73
+ menu: [
74
+ { text: 'Services', path: '/services' },
75
+ {
76
+ text: 'More',
77
+ items: [
78
+ { text: 'Contact', path: '/contact' },
79
+ { text: 'Help', path: '/help' }
80
+ ]
81
+ }
82
+ ]
83
+ };
84
+ ```
85
+
86
+ ---
87
+
88
+ ### BYU Footer
89
+ This is the footer displayed on all BYU websites. It provides essential information and links to comply with legal and institutional requirements.
90
+
91
+ #### Features:
92
+ - **University Name**: Displays "Brigham Young University" with a link to the main BYU website.
93
+ - **Address**: Displays the university's address.
94
+ - **Copyright Notice**: Automatically updates the year to the current year.
95
+ - **Privacy Links**: Includes links to the Privacy Notice and Cookie Preferences pages.
96
+
97
+ #### Usage:
98
+ Add the `byu-footer` component to your template:
99
+
100
+ ```html
101
+ <byu-footer />
102
+ ```
103
+
104
+ The footer does not require any configuration and is ready to use out of the box.
105
+
106
+ ---
107
+
108
+ ### User Management Table
109
+ This component provides a table for managing user data, including search, filtering, sorting, and pagination functionalities. It will use the site's backend's `/api/user-management/` route.
110
+
111
+ #### Features:
112
+ - **Search**: Allows searching for users by their NetID or other attributes.
113
+ - **Filtering**: Supports filtering by account types (e.g., NonBYU, Student, Employee).
114
+ - **Sorting**: Columns can be sorted by attributes such as NetID, First Name, Last Name, Account Type, and Created Date.
115
+ - **Pagination**: Includes a paginator to navigate through large datasets.
116
+ - **Dynamic Data**: Fetches user data dynamically from the server.
117
+
118
+ #### Configuration:
119
+ The table uses the following signals for configuration:
120
+ - `search`: A string for filtering users by search terms.
121
+ - `accountTypes`: An array of account types to filter users.
122
+ - `sortBy`: The column to sort by (e.g., `netId`, `preferredFirstName`).
123
+ - `sortDirection`: The sorting direction (`asc` or `desc`).
124
+ - `pageCount`: The number of rows per page.
125
+ - `pageOffset`: The offset for pagination.
126
+ - `createdAfter` and `createdBefore`: Filtering by creationg date
127
+
128
+ #### Usage:
129
+ Add the `app-user-management` component to your template:
130
+
131
+ ```html
132
+ <app-user-management />
133
+ ```
134
+
135
+ The component automatically handles data fetching and UI updates based on user interactions.
136
+
137
+
138
+
139
+ ## Services
140
+
141
+ The services in this library provide reusable logic and utilities to simplify common tasks such as authentication, data fetching, and state management. They are designed to integrate seamlessly with Angular applications and follow best practices for dependency injection and reactive programming.
142
+
143
+ ### Auth
144
+ Wraps the `keycloak-angular` service to provide a simplified interface for authentication and authorization.
145
+
146
+ #### Features:
147
+ - **Login and Logout**: Methods to handle user login and logout.
148
+ - **Authentication Signals**: Signals to track authentication status, tokens, and user information.
149
+ - **Token Management**: Provides access to tokens (e.g., `token`, `idToken`, `refreshToken`) and their parsed forms.
150
+ - **Role and Access Management**: Signals for realm and resource roles.
151
+ - **Time Skew and Configuration**: Signals for Keycloak configuration properties like `timeSkew`, `responseMode`, and `flow`.
152
+
153
+
154
+
155
+
156
+ ## Signals
157
+
158
+ ### fetchSignal
159
+ The `fetchSignal` helper provides a reactive way to perform HTTP requests in Angular applications. It supports various HTTP methods and automatically tracks dependencies for reactivity.
160
+
161
+ #### Features:
162
+ - **Reactive Requests**: Automatically updates when input signals change.
163
+ - **Support for Multiple Methods**: Includes `GET`, `POST`, `PUT`, `PATCH`, and `DELETE`.
164
+ - **Response Parsing**: Supports JSON, text, Blob, and ArrayBuffer responses.
165
+ - **Error Handling**: Tracks errors and status codes reactively.
166
+ - **Auto-Refresh**: Automatically refreshes requests when dependencies change.
167
+
168
+ #### Usage:
169
+ ```typescript
170
+ import { fetchSignal } from '@fhss-web-team/frontend-utils';
171
+
172
+ // Example: Reactive GET request
173
+ const request = () => ({
174
+ url: '/api/data',
175
+ params: { filter: 'active' },
176
+ });
177
+ const dataSignal = fetchSignal.json(request, true);
178
+
179
+ // Access reactive properties
180
+ dataSignal.value(); // Current response value
181
+ dataSignal.isLoading(); // Loading state
182
+ dataSignal.error(); // Error details
183
+ dataSignal.refresh(); // Manually refresh the request
184
+ ```
185
+
186
+ ---
187
+
188
+ ### debounced
189
+ The `debounced` helper creates a debounced version of a signal, delaying updates until after a specified wait time.
190
+
191
+ #### Features:
192
+ - **Debounced Updates**: Reduces the frequency of updates to a signal.
193
+ - **Customizable Delay**: Specify the debounce delay in milliseconds.
194
+
195
+ #### Usage:
196
+ ```typescript
197
+ import { signal } from '@angular/core';
198
+ import { debounced } from '@fhss-web-team/frontend-utils';
199
+
200
+ // Example: Debounced search input
201
+ const searchInput = signal('');
202
+ const debouncedSearch = debounced(searchInput, 300);
203
+
204
+ // Update the input signal
205
+ searchInput.set('new search term');
206
+
207
+ // The debounced signal updates after 300ms
208
+ debouncedSearch(); // 'new search term' (after delay)
209
+ ```
210
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fhss-web-team/frontend-utils",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^19.2.0",
6
6
  "@angular/core": "^19.2.0"