@ieeesa-npm/groups 0.14.5 → 0.15.0

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.
package/README.md CHANGED
@@ -19,6 +19,211 @@ After building your library with `ng build groups`, go to the dist folder `cd di
19
19
 
20
20
  Run `ng test groups` to execute the unit tests via [Karma](https://karma-runner.github.io).
21
21
 
22
+ # Groups NPM Package Usage Guide
23
+
24
+ ## 1. Angular versions
25
+ Groups npm package is developed using Angular 16. To use the groups npm package in Angular application, application should be developed with Angular 16 and above version.
26
+
27
+ ## 2. Install groups NPM Package
28
+ You can use the following command to install groups NPM package.
29
+ npm install @ieeesa-npm/groups or npm install @ieeesa-npm/groups@latest or npm install @ieeesa-npm/groups@0.11.4 (in case of particular version)
30
+
31
+ ## 3. Install groups peer dependency NPM Packages
32
+ Following npm packages are dependency for groups module and you can use below commands to install those NPM packages.
33
+
34
+ * npm install @ieeesa-npm/presentation
35
+ * npm install @ieeesa-npm/shared-styles
36
+ * npm install @ieeesa-npm/feature
37
+ * npm install @ieeesa-npm/utility
38
+
39
+ ## 4. Import GroupsComponent from installed node_modules
40
+ Import the GroupsComponent to your application component where you want to integrate the GroupsComponent. Refer below snippet to import the groups component. Group Component to be imported from @ieeesa-npm/groups and provided it in the imports array of component decorator.
41
+
42
+ ```typescript
43
+ import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
44
+ import { CommonModule } from '@angular/common';
45
+ import { GroupsComponent } from '@ieeesa-npm/groups';
46
+ import { HttpClientModule } from '@angular/common/http';
47
+ import { UserPermissions } from '@core/models/user-permissions.model';
48
+ import { Subject, distinctUntilChanged, takeUntil } from 'rxjs';
49
+ import { BreadcrumbComponent } from '@ieeesa-npm/presentation';
50
+ import { UserInfo } from '@core/models/user-info.model';
51
+
52
+ @Component({
53
+ selector: 'committees',
54
+ standalone: true,
55
+ imports: [
56
+ CommonModule,
57
+ GroupsComponent,
58
+ HttpClientModule,
59
+ BreadcrumbComponent,
60
+ ],
61
+ templateUrl: './committees.component.html',
62
+ styleUrls: ['./committees.component.scss'],
63
+ encapsulation: ViewEncapsulation.None,
64
+ ```
65
+ Next, you can integrate the groups component in the html template using groups component selector <ieeesa-groups> </ieeesa-groups>.
66
+
67
+ ```html
68
+ <div class="committees">
69
+ <div class="committees__breadcrumb px-4 pt-3">
70
+ <ieeesa-breadcrumb
71
+ [breadcrumbInitialRoute]="breadCrumbInitialRoute"
72
+ [breadcrumbInitialRouteLabel]="breadcrumbInitialRouteLabel"
73
+ ></ieeesa-breadcrumb>
74
+ </div>
75
+ <ieeesa-groups
76
+ [apiBaseURL]="apiBaseURL"
77
+ [userPermissions]="userPermissions"
78
+ [userInfo]="userInfo"
79
+ ></ieeesa-groups>
80
+ </div>
81
+ ```
82
+ Next, pass the necessary metadata as an input property to the groups component such as,
83
+ * apiBaseURL
84
+ * userPermissions
85
+ * userInfo
86
+
87
+ ```html
88
+ <div class="committees">
89
+ <div class="committees__breadcrumb px-4 pt-3">
90
+ <ieeesa-breadcrumb
91
+ [breadcrumbInitialRoute]="breadCrumbInitialRoute"
92
+ [breadcrumbInitialRouteLabel]="breadcrumbInitialRouteLabel"
93
+ ></ieeesa-breadcrumb>
94
+ </div>
95
+ <ieeesa-groups
96
+ [apiBaseURL]="apiBaseURL"
97
+ [userPermissions]="userPermissions"
98
+ [userInfo]="userInfo"
99
+ ></ieeesa-groups>
100
+ </div>
101
+ ```
102
+ ## 4.1 apiBaseURL
103
+ API base URL to be passed to the component based on the environment such as dev/qa/uat/prod to get the groups data from server.
104
+
105
+ * DEV: https://saappsapidev.ieee.org/v1
106
+ * QA: https://saappsapiqa.ieee.org/v1
107
+ * UAT: https://saappsapiuat.ieee.org/v1
108
+ * PROD: https://saappsapi.ieee.org/v1
109
+
110
+ ## 4.2 userInfo
111
+ You can get the logged user information by calling the API https://saappsapiqa.ieee.org/v1/userauth/public/jwt/verify along with passing the JWT token as a bearer token that was generated by the API https://saappsapiqa.ieee.org/v1/configurations/public/saml2/authenticate/QASAAPPSIEEE. This API will verify the validity of the token and respond the following user information when the token verification is successful.
112
+ ```typescript
113
+ {
114
+ "userId": "User_0511a78f",
115
+ "appId": "SAAPPS",
116
+ "firstName": "",
117
+ "lastName": "",
118
+ "email": "",
119
+ "token": null,
120
+ "roles": null
121
+ }
122
+ ```
123
+ Logged in user info to be passed to the groups component to identify whether the logged in user is assigned with admin role. Based on the passed user info, groups component does not allow the admin to edit or delete his/her role by himself/herself when the logged in user is admin. Refer to below UserInfo model.
124
+ ```typescript
125
+ export interface UserInfo {
126
+ appId: string;
127
+ userId: string;
128
+ ssoId: string;
129
+ firstName: string;
130
+ lastName: string;
131
+ email: string;
132
+ }
133
+ ```
134
+
135
+ ## 4.3 userPermissions
136
+ Logged userInfo will be used to get the user roles and permissions. You can get the logged user roles and permissions by calling the API
137
+ https://saappsapiqa.ieee.org/v1/groups/userPermissions/User_a25979e3-96c5-489c-aed7-7a6948c0fa66 along with passing the JWT token as a bearer token. The userId (User_a25979e3-96c5-489c-aed7-7a6948c0fa66) to be passed as a path parameter to the API.
138
+
139
+ API will validate the bearer token and userId, and then respond to the API request with following roles and permission information when the token is not expired, and token & userId is valid.
140
+ ```json
141
+ {
142
+ "status": true,
143
+ "message": "SUCCESS",
144
+ "body": {
145
+ "roles": [
146
+ {
147
+ "roleId": "ROLE_edaf1dcc",
148
+ "roleName": "Admin",
149
+ "permissions": [
150
+ {
151
+ "permissionId": "PERM_eebde105",
152
+ "permissionName": "Manage All Group Details"
153
+ },
154
+ {
155
+ "permissionId": "PERM_fc522748",
156
+ "permissionName": "Create Parent Group"
157
+ },
158
+ {
159
+ "permissionId": "PERM_741d7504",
160
+ "permissionName": "View All Group Details"
161
+ },
162
+ {
163
+ "permissionId": "PERM_9ddd51db",
164
+ "permissionName": "Manage Group Officers"
165
+ },
166
+ {
167
+ "permissionId": "PERM_b322c647",
168
+ "permissionName": "View Group details"
169
+ },
170
+ {
171
+ "permissionId": "PERM_5a8edb91",
172
+ "permissionName": "View Group Members"
173
+ },
174
+ {
175
+ "permissionId": "PERM_f80ac8a3",
176
+ "permissionName": "View Group Officers"
177
+ },
178
+ {
179
+ "permissionId": "PERM_1969fecb",
180
+ "permissionName": "Manage Group Member"
181
+ },
182
+ {
183
+ "permissionId": "PERM_008229bf",
184
+ "permissionName": "Delete Group"
185
+ },
186
+ {
187
+ "permissionId": "PERM_8f8a203e",
188
+ "permissionName": "Create Subgroup"
189
+ },
190
+ {
191
+ "permissionId": "PERM_d64e1f09",
192
+ "permissionName": "Edit Group Details"
193
+ },
194
+ {
195
+ "permissionId": "PERM_d2c103e9",
196
+ "permissionName": "Manage System Users"
197
+ },
198
+ {
199
+ "permissionId": "PERM_c05ff592",
200
+ "permissionName": "View Groups"
201
+ }
202
+ ]
203
+ }
204
+ ]
205
+ }
206
+ }
207
+ ```
208
+ API returns more than one role and associated permissions based on the roles assigned to the user and permissions mapped to each role. You can consolidate all the roles permissions of an user and pass the filtered permissions to the “userPermissions” input property of the groups component.
209
+
210
+ Logged in user list of permissions to be passed to the component to authorize the user to perform or provide the access appropriate functions such as View Groups, Add Group, Add Subgroup, Edit Group, Delete Group, View/Manage Roster, Manage SUG (System User Group), Manage Group Members/Officers.
211
+
212
+ The groups component is mapped with associated permissionId and provides access based on the permissionId’s passed to the component. Refer to the UserPermissions model in below.
213
+
214
+ ```typescript
215
+ export interface UserPermissions {
216
+ permissionId: string;
217
+ permissionName: string;
218
+ }
219
+ ```
220
+
221
+ ## 5. Send the JWT Token as Bearer Token to every API Request for Authentication & Authorization
222
+ API requires the JWT token of the logged in user as bearer token to authenticate the user for every API request. You can implement Angular Interceptor to pass the bearer token for every API request or reuse the token.interceptor available from @ieeesa-npm/utility NPM package.
223
+
224
+ ## 6. Use constants.json to update the screen texts, labels and error messages
225
+ You can find the screen texts, labels, aria labels, and error messages at **projects/groups/src/lib/assets/constants.json** to update it. You have to publish the packages and integrate the latest version of NPM package to reflect the updates to your application.
226
+
22
227
  ## Further help
23
228
 
24
229
  To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.