@ieeesa-npm/tenants 0.4.2 → 0.4.4

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 (138) hide show
  1. package/.eslintrc.json +31 -0
  2. package/ng-package.json +8 -0
  3. package/package.json +12 -25
  4. package/src/lib/assets/constants.json +454 -0
  5. package/src/lib/assets/tenant-validations.ts +18 -0
  6. package/src/lib/assets/tenants-mock.ts +1240 -0
  7. package/src/lib/components/create-modify-group-type/create-modify-group-type.component.html +15 -0
  8. package/src/lib/components/create-modify-group-type/create-modify-group-type.component.scss +44 -0
  9. package/src/lib/components/create-modify-group-type/create-modify-group-type.component.spec.ts +574 -0
  10. package/src/lib/components/create-modify-group-type/create-modify-group-type.component.ts +602 -0
  11. package/src/lib/components/create-modify-role/create-modify-role.component.html +15 -0
  12. package/src/lib/components/create-modify-role/create-modify-role.component.scss +83 -0
  13. package/src/lib/components/create-modify-role/create-modify-role.component.spec.ts +346 -0
  14. package/src/lib/components/create-modify-role/create-modify-role.component.ts +321 -0
  15. package/src/lib/components/create-tenant-application/create-tenant-application.component.html +18 -0
  16. package/src/lib/components/create-tenant-application/create-tenant-application.component.scss +73 -0
  17. package/src/lib/components/create-tenant-application/create-tenant-application.component.spec.ts +775 -0
  18. package/src/lib/components/create-tenant-application/create-tenant-application.component.ts +638 -0
  19. package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.html +22 -0
  20. package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.scss +79 -0
  21. package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.spec.ts +716 -0
  22. package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.ts +504 -0
  23. package/src/lib/components/tenant-basic-details/tenant-basic-details.component.html +44 -0
  24. package/src/lib/components/tenant-basic-details/tenant-basic-details.component.scss +16 -0
  25. package/src/lib/components/tenant-basic-details/tenant-basic-details.component.spec.ts +115 -0
  26. package/src/lib/components/tenant-basic-details/tenant-basic-details.component.ts +109 -0
  27. package/src/lib/components/view-tenant-details/view-tenant-details.component.html +195 -0
  28. package/src/lib/components/view-tenant-details/view-tenant-details.component.scss +163 -0
  29. package/src/lib/components/view-tenant-details/view-tenant-details.component.spec.ts +1221 -0
  30. package/src/lib/components/view-tenant-details/view-tenant-details.component.ts +876 -0
  31. package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.html +10 -0
  32. package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.scss +44 -0
  33. package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.spec.ts +410 -0
  34. package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.ts +219 -0
  35. package/src/lib/components/view-tenants-list/view-tenants-list.component.html +32 -0
  36. package/src/lib/components/view-tenants-list/view-tenants-list.component.scss +35 -0
  37. package/src/lib/components/view-tenants-list/view-tenants-list.component.spec.ts +464 -0
  38. package/src/lib/components/view-tenants-list/view-tenants-list.component.ts +388 -0
  39. package/src/lib/models/app-type-config.model.ts +14 -0
  40. package/src/lib/models/app-type.model.ts +5 -0
  41. package/src/lib/models/create-group-type-config.model.ts +18 -0
  42. package/src/lib/models/create-group-type.model.ts +46 -0
  43. package/src/lib/models/feature-permission-id.model.ts +6 -0
  44. package/src/lib/models/features.model.ts +15 -0
  45. package/src/lib/models/form-status.model.ts +5 -0
  46. package/src/lib/models/permission-type.model.ts +9 -0
  47. package/src/lib/models/role-menu-action.model.ts +5 -0
  48. package/src/lib/models/role-type.model.ts +34 -0
  49. package/src/lib/models/roles-and-permissions-table-type.model.ts +5 -0
  50. package/src/lib/models/roles-and-permissions.model.ts +113 -0
  51. package/src/lib/models/route-config.model.ts +4 -0
  52. package/src/lib/models/table-column-schema-view-tenant-list.model.ts +21 -0
  53. package/src/lib/models/tenant-function-type.model.ts +10 -0
  54. package/src/lib/models/tenant.model.ts +47 -0
  55. package/src/lib/models/tenants-permission.model.ts +9 -0
  56. package/src/lib/models/update-tenant-status.model.ts +12 -0
  57. package/src/lib/models/view-tenant-group-types.model.ts +34 -0
  58. package/src/lib/services/tenant-applications.service.spec.ts +1245 -0
  59. package/src/lib/services/tenant-applications.service.ts +798 -0
  60. package/src/lib/services/tenant-permissions-map.service.spec.ts +25 -0
  61. package/src/lib/services/tenant-permissions-map.service.ts +28 -0
  62. package/src/lib/services/tenant-permissions.service.spec.ts +62 -0
  63. package/src/lib/services/tenant-permissions.service.ts +49 -0
  64. package/src/lib/tenant-applications.component.html +0 -0
  65. package/src/lib/tenant-applications.component.scss +0 -0
  66. package/src/lib/tenant-applications.component.spec.ts +28 -0
  67. package/src/lib/tenant-applications.component.ts +12 -0
  68. package/src/lib/tenant-applications.module.ts +8 -0
  69. package/{public-api.d.ts → src/public-api.ts} +40 -30
  70. package/tsconfig.lib.json +14 -0
  71. package/tsconfig.lib.prod.json +10 -0
  72. package/tsconfig.spec.json +14 -0
  73. package/esm2022/ieeesa-npm-tenants.mjs +0 -5
  74. package/esm2022/lib/assets/constants.json +0 -390
  75. package/esm2022/lib/assets/tenant-validations.mjs +0 -13
  76. package/esm2022/lib/components/create-modify-role/create-modify-role.component.mjs +0 -280
  77. package/esm2022/lib/components/create-tenant-application/create-tenant-application.component.mjs +0 -512
  78. package/esm2022/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.mjs +0 -391
  79. package/esm2022/lib/components/tenant-basic-details/tenant-basic-details.component.mjs +0 -95
  80. package/esm2022/lib/components/view-tenant-details/view-tenant-details.component.mjs +0 -708
  81. package/esm2022/lib/components/view-tenant-group-types/view-tenant-group-types.component.mjs +0 -174
  82. package/esm2022/lib/components/view-tenants-list/view-tenants-list.component.mjs +0 -334
  83. package/esm2022/lib/models/app-type-config.model.mjs +0 -2
  84. package/esm2022/lib/models/app-type.model.mjs +0 -7
  85. package/esm2022/lib/models/feature-permission-id.model.mjs +0 -8
  86. package/esm2022/lib/models/features.model.mjs +0 -2
  87. package/esm2022/lib/models/form-status.model.mjs +0 -7
  88. package/esm2022/lib/models/permission-type.model.mjs +0 -12
  89. package/esm2022/lib/models/role-menu-action.model.mjs +0 -7
  90. package/esm2022/lib/models/role-type.model.mjs +0 -2
  91. package/esm2022/lib/models/roles-and-permissions-table-type.model.mjs +0 -7
  92. package/esm2022/lib/models/roles-and-permissions.model.mjs +0 -2
  93. package/esm2022/lib/models/route-config.model.mjs +0 -2
  94. package/esm2022/lib/models/table-column-schema-view-tenant-list.model.mjs +0 -16
  95. package/esm2022/lib/models/tenant-function-type.model.mjs +0 -10
  96. package/esm2022/lib/models/tenant.model.mjs +0 -2
  97. package/esm2022/lib/models/tenants-permission.model.mjs +0 -2
  98. package/esm2022/lib/models/update-tenant-status.model.mjs +0 -2
  99. package/esm2022/lib/models/view-tenant-group-types.model.mjs +0 -9
  100. package/esm2022/lib/services/tenant-applications.service.mjs +0 -542
  101. package/esm2022/lib/services/tenant-permissions-map.service.mjs +0 -36
  102. package/esm2022/lib/services/tenant-permissions.service.mjs +0 -38
  103. package/esm2022/lib/tenant-applications.component.mjs +0 -14
  104. package/esm2022/lib/tenant-applications.module.mjs +0 -16
  105. package/esm2022/public-api.mjs +0 -34
  106. package/fesm2022/ieeesa-npm-tenants.mjs +0 -3565
  107. package/fesm2022/ieeesa-npm-tenants.mjs.map +0 -1
  108. package/index.d.ts +0 -5
  109. package/lib/assets/tenant-validations.d.ts +0 -11
  110. package/lib/components/create-modify-role/create-modify-role.component.d.ts +0 -103
  111. package/lib/components/create-tenant-application/create-tenant-application.component.d.ts +0 -128
  112. package/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.d.ts +0 -106
  113. package/lib/components/tenant-basic-details/tenant-basic-details.component.d.ts +0 -408
  114. package/lib/components/view-tenant-details/view-tenant-details.component.d.ts +0 -216
  115. package/lib/components/view-tenant-group-types/view-tenant-group-types.component.d.ts +0 -58
  116. package/lib/components/view-tenants-list/view-tenants-list.component.d.ts +0 -134
  117. package/lib/models/app-type-config.model.d.ts +0 -14
  118. package/lib/models/app-type.model.d.ts +0 -4
  119. package/lib/models/feature-permission-id.model.d.ts +0 -4
  120. package/lib/models/features.model.d.ts +0 -15
  121. package/lib/models/form-status.model.d.ts +0 -4
  122. package/lib/models/permission-type.model.d.ts +0 -8
  123. package/lib/models/role-menu-action.model.d.ts +0 -4
  124. package/lib/models/role-type.model.d.ts +0 -27
  125. package/lib/models/roles-and-permissions-table-type.model.d.ts +0 -4
  126. package/lib/models/roles-and-permissions.model.d.ts +0 -119
  127. package/lib/models/route-config.model.d.ts +0 -4
  128. package/lib/models/table-column-schema-view-tenant-list.model.d.ts +0 -20
  129. package/lib/models/tenant-function-type.model.d.ts +0 -7
  130. package/lib/models/tenant.model.d.ts +0 -51
  131. package/lib/models/tenants-permission.model.d.ts +0 -9
  132. package/lib/models/update-tenant-status.model.d.ts +0 -14
  133. package/lib/models/view-tenant-group-types.model.d.ts +0 -27
  134. package/lib/services/tenant-applications.service.d.ts +0 -357
  135. package/lib/services/tenant-permissions-map.service.d.ts +0 -13
  136. package/lib/services/tenant-permissions.service.d.ts +0 -22
  137. package/lib/tenant-applications.component.d.ts +0 -5
  138. package/lib/tenant-applications.module.d.ts +0 -6
@@ -0,0 +1,798 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { HttpService } from '@ieeesa-npm/utility';
3
+ import { Observable, Subject, catchError, map } from 'rxjs';
4
+ import * as screenTexts from '../assets/constants.json';
5
+ import { GetTenantsPayload } from '../models/table-column-schema-view-tenant-list.model';
6
+ import {
7
+ TenantsPermissions,
8
+ UserPermission,
9
+ } from '../models/tenants-permission.model';
10
+ import { PermissionType } from '../models/permission-type.model';
11
+ import { TenantPermissionsMapService } from './tenant-permissions-map.service';
12
+ import {
13
+ CreateTenantRequestPayload,
14
+ CreateTenantResponse,
15
+ GetTenantsResponse,
16
+ NewTenantInfo,
17
+ TenantBasicInfo,
18
+ TenantDetailsResponse,
19
+ } from '../models/tenant.model';
20
+ import { CheckboxOption, RadioOption } from '@ieeesa-npm/presentation';
21
+ import {
22
+ FeatureId,
23
+ Features,
24
+ GetFeaturesResponse,
25
+ } from '../models/features.model';
26
+ import {
27
+ AppTypeConfig,
28
+ GetAppTypesResponse,
29
+ } from '../models/app-type-config.model';
30
+ import { TenantPermissionsService } from './tenant-permissions.service';
31
+ import { TenantFunctionType } from '../models/tenant-function-type.model';
32
+ import {
33
+ GetRolesAndPermissionsPayload,
34
+ GetRolesAndPermissionsResponse,
35
+ GetRolesResponse,
36
+ RoleInfo,
37
+ DeleteRoleRequestPayload,
38
+ DeleteRoleResponse,
39
+ Role,
40
+ GetPermissionsResponse,
41
+ RolePermissionMappingRequestPayload,
42
+ RolePermissionMappingResponse,
43
+ RolesAndPermissionsRequestPayload,
44
+ RolesAndPermissionsResponse,
45
+ RoleDetails,
46
+ CreateModifyRoleRequestPayload,
47
+ CreateModifyRoleResponse,
48
+ } from '../models/roles-and-permissions.model';
49
+ import {
50
+ UpdateTenantStatusRequestPayload,
51
+ UpdateTenantStatusResponse,
52
+ } from '../models/update-tenant-status.model';
53
+ import {
54
+ GetRoleTypesPayload,
55
+ RoleTypeConfiguration,
56
+ RoleTypeOption,
57
+ RoleTypeResponse,
58
+ } from '../models/role-type.model';
59
+ import { ViewGroupTypeResponse } from '../models/view-tenant-group-types.model';
60
+ import {
61
+ CreateGroupTypeRequestPayload,
62
+ CreateGroupTypeResponse,
63
+ CreatedOrModifiedGroupTypeInfo,
64
+ GetRosterTypeOrSettingsResponse,
65
+ } from '../models/create-group-type.model';
66
+ @Injectable({
67
+ providedIn: 'root',
68
+ })
69
+ export class TenantApplicationsService {
70
+ tenantsText = screenTexts?.viewTenants?.errors;
71
+ apiBaseUrl!: string;
72
+ userPermission!: UserPermission[];
73
+ selectedTenantInfo!: TenantBasicInfo | undefined;
74
+ userTenantsPermissions!: TenantsPermissions[];
75
+ createTenantsText = screenTexts?.createTenant?.errors;
76
+ newTenantInfo!: NewTenantInfo;
77
+ tenantFunctionType!: TenantFunctionType;
78
+ radioOptions: RadioOption[] = [];
79
+ checkBoxOptions: CheckboxOption[] = [];
80
+ appTypeInfo: RadioOption[] = [];
81
+ featureList: Features[] = [];
82
+ roleTypeOptions: RoleTypeOption[] = [];
83
+ newlyCreatedRole!: RoleInfo;
84
+ roleTypeOption!: RoleTypeOption[];
85
+ selectedRoleInfo!: RoleDetails;
86
+ roles!: Role[];
87
+ groupTypes!: ViewGroupTypeResponse;
88
+ newlyCreatedGroupType!: CreatedOrModifiedGroupTypeInfo;
89
+ isGroupTypeAddedOrModified = new Subject<boolean>();
90
+ constructor(
91
+ // eslint-disable-next-line no-unused-vars
92
+ private httpService: HttpService,
93
+ // eslint-disable-next-line no-unused-vars
94
+ private tenantPermissionsService: TenantPermissionsService,
95
+ // eslint-disable-next-line no-unused-vars
96
+ private tenantPermissionsMapService: TenantPermissionsMapService // eslint-disable-next-line no-empty-function
97
+ ) {}
98
+ setAppConfig(apiBaseUrl: string, userPermission: UserPermission[]): void {
99
+ this.apiBaseUrl = apiBaseUrl;
100
+ this.userPermission = userPermission;
101
+ }
102
+
103
+ /**
104
+ * Gets tenant details from server using HttpService
105
+ * @param {string} appId
106
+ * @return {Observable<TenantDetailsResponse>}
107
+ * @memberof TenantApplicationsService
108
+ */
109
+ getTenantDetails(appId: string): Observable<TenantDetailsResponse> {
110
+ return this.httpService
111
+ .getData(`${this.apiBaseUrl}/configurations/app/details/${appId}`)
112
+ .pipe(
113
+ map((response) => {
114
+ return response;
115
+ }),
116
+ catchError((error) => {
117
+ throw error;
118
+ })
119
+ );
120
+ }
121
+ /**
122
+ * Sets the user tenants permissions
123
+ * @param {TenantsPermissions[]} TenantsPermissions
124
+ * @memberof TenantApplicationsService
125
+ */
126
+ setUserTenantsPermissions(userTenantsPermissions: TenantsPermissions[]) {
127
+ this.userTenantsPermissions = userTenantsPermissions;
128
+ }
129
+ /**
130
+ * Returns the user tenants permissions
131
+ * @return {TenantsPermissions[]}
132
+ * @memberof TenantApplicationsService
133
+ */
134
+ getUserTenantsPermissions(): TenantsPermissions[] {
135
+ return this.userTenantsPermissions;
136
+ }
137
+
138
+ /**
139
+ * Sets the user tenants information
140
+ * @param {TenantBasicInfo} tenantInfo
141
+ * @memberof TenantApplicationsService
142
+ */
143
+ setSelectedTenantInformation(tenantInfo: TenantBasicInfo): void {
144
+ this.selectedTenantInfo = tenantInfo;
145
+ }
146
+ /**
147
+ * Returns the tenants information
148
+ * @return {TenantBasicInfo}
149
+ * @memberof TenantApplicationsService
150
+ */
151
+ getSelectedTenantInformation(): TenantBasicInfo | undefined {
152
+ return this.selectedTenantInfo;
153
+ }
154
+ /**
155
+ * Sets the roles informations
156
+ * @param {Role} roles
157
+ * @memberof TenantApplicationsService
158
+ */
159
+ setRolesInfo(roles: Role[]): void {
160
+ this.roles = roles;
161
+ }
162
+ /**
163
+ * Returns the roles information
164
+ * @return {Role}
165
+ * @memberof TenantApplicationsService
166
+ */
167
+ getRolesInfo(): Role[] | undefined {
168
+ return this.roles;
169
+ }
170
+ /**
171
+ * Sets the selected role information.
172
+ * @param {RoleDetails} roleInfo
173
+ * @memberof TenantApplicationsService
174
+ */
175
+ setSelectedRoleInformation(roleInfo: RoleDetails): void {
176
+ this.selectedRoleInfo = roleInfo;
177
+ }
178
+ /**
179
+ * Returns the selected role information.
180
+ * @return {RoleDetails}
181
+ * @memberof TenantApplicationsService
182
+ */
183
+ getSelectedRoleInformation(): RoleDetails | undefined {
184
+ return this.selectedRoleInfo;
185
+ }
186
+ /**
187
+ * Sets the tenant role type options.
188
+ * @param {RoleTypeOption} roleTypeOptions
189
+ * @memberof TenantApplicationsService
190
+ */
191
+ setRoleTypeOption(roleTypeOptions: RoleTypeOption[]): void {
192
+ this.roleTypeOption = roleTypeOptions;
193
+ }
194
+ /**
195
+ * Returns the tenant role type options.
196
+ * @return {RoleTypeOption}
197
+ * @memberof TenantApplicationsService
198
+ */
199
+ getRoleTypeOption(): RoleTypeOption[] {
200
+ return this.roleTypeOption;
201
+ }
202
+ /**
203
+ * Sets the list of application type information
204
+ * @param {RadioOption} appTypeInfo
205
+ * @memberof TenantApplicationsService
206
+ */
207
+ setApplicationType(appTypeInfo: RadioOption[]): void {
208
+ this.appTypeInfo = appTypeInfo;
209
+ }
210
+ /**
211
+ * Returns the list of application type information
212
+ * @return {RadioOption}
213
+ * @memberof TenantApplicationsService
214
+ */
215
+ getApplicationType(): RadioOption[] | undefined {
216
+ return this.appTypeInfo;
217
+ }
218
+ /**
219
+ * Filter permissions
220
+ * @param usersPermissions
221
+ * @returns @memberof TenantApplicationsService
222
+ */
223
+ filterPermission(usersPermissions: UserPermission[]): TenantsPermissions[] {
224
+ return this.tenantPermissionsService?.filterTenantsPermissions(
225
+ usersPermissions,
226
+ this.tenantPermissionsMapService?.getGlobalTenantsPermissions()
227
+ );
228
+ }
229
+ /**
230
+ * Validating access for tenants
231
+ * @param permissionType Permission Type to validate permission
232
+ * @param mappedUserPermissions Permission which are mapped with tenants
233
+ * @returns true if permission is granted
234
+ */
235
+ validateAccess(
236
+ permissionType: PermissionType,
237
+ permissions: TenantsPermissions[]
238
+ ): boolean {
239
+ return this.tenantPermissionsService.validateAccessPermission(
240
+ permissionType,
241
+ permissions
242
+ );
243
+ }
244
+ /**
245
+ * Gets the tenants.
246
+ * @param {GetTenantsPayload} payload
247
+ * @return {Observable<GetTenantsResponse>}
248
+ * @memberof TenantApplicationsService
249
+ */
250
+ getTenantsList(payload: GetTenantsPayload): Observable<GetTenantsResponse> {
251
+ return this.httpService
252
+ .postData(`${this.apiBaseUrl}/configurations/app/config`, payload)
253
+ .pipe(
254
+ map((response) => {
255
+ return response;
256
+ }),
257
+ catchError((error) => {
258
+ throw error;
259
+ })
260
+ );
261
+ }
262
+ /**
263
+ * Gets list of features from server using HttpService.
264
+ * @return {Observable<GetFeaturesResponse>}
265
+ * @memberof TenantApplicationsService
266
+ */
267
+ getFeatures(): Observable<GetFeaturesResponse> {
268
+ return this.httpService
269
+ .getData(`${this.apiBaseUrl}/configurations/app/features`)
270
+ .pipe(
271
+ map((response) => {
272
+ return response;
273
+ }),
274
+ catchError((error) => {
275
+ throw error;
276
+ })
277
+ );
278
+ }
279
+ /**
280
+ * Gets list of roles from server using HttpService.
281
+ * @param {string} appId
282
+ * @return {*} {Observable<GetRolesResponse>}
283
+ * @memberof TenantApplicationsService
284
+ */
285
+ getRoles(appId: string): Observable<GetRolesResponse> {
286
+ return this.httpService
287
+ .getData(`${this.apiBaseUrl}/groups/role/${appId}`)
288
+ .pipe(
289
+ map((response) => {
290
+ return response;
291
+ }),
292
+ catchError((error) => {
293
+ throw error;
294
+ })
295
+ );
296
+ }
297
+ /**
298
+ * Gets the list of permissions based on the appId and return the success or error response as Observable.
299
+ * @param {string} appId
300
+ * @return {Observable<GetPermissionsResponse>}
301
+ * @memberof TenantApplicationsService
302
+ */
303
+ getPermissions(appId: string): Observable<GetPermissionsResponse> {
304
+ return this.httpService
305
+ .getData(`${this.apiBaseUrl}/groups/permissions/${appId}`)
306
+ .pipe(
307
+ map((response) => {
308
+ return response;
309
+ }),
310
+ catchError((error) => {
311
+ throw error;
312
+ })
313
+ );
314
+ }
315
+ /**
316
+ * Gets the list of roles or permissions based on the roleId or permissionId in the payload and return the success or error response as Observable.
317
+ * @param {RolePermissionMappingRequestPayload} payload
318
+ * @returns {Observable<RolePermissionMappingResponse>}
319
+ * @memberof TenantApplicationsService
320
+ */
321
+ getRolePermissionMapping(
322
+ payload: RolePermissionMappingRequestPayload
323
+ ): Observable<RolePermissionMappingResponse> {
324
+ return this.httpService
325
+ .postData(
326
+ `${this.apiBaseUrl}/groups/users/rolePermissionMapping`,
327
+ payload
328
+ )
329
+ .pipe(
330
+ map((response) => {
331
+ return response;
332
+ }),
333
+ catchError((error) => {
334
+ throw error;
335
+ })
336
+ );
337
+ }
338
+ /**
339
+ * Submit the new mappings of roles to permissions to the server.
340
+ * @param {RolesAndPermissionsRequestPayload} payload
341
+ * @returns {Observable<RolesAndPermissionsResponse>}
342
+ * @memberof TenantApplicationsService
343
+ */
344
+ saveRolePermissionMapping(
345
+ payload: RolesAndPermissionsRequestPayload
346
+ ): Observable<RolesAndPermissionsResponse> {
347
+ return this.httpService
348
+ .postData(`${this.apiBaseUrl}/groups/users/rolePermission`, payload)
349
+ .pipe(
350
+ map((response) => {
351
+ return response;
352
+ }),
353
+ catchError((error) => {
354
+ throw error;
355
+ })
356
+ );
357
+ }
358
+ /**
359
+ * Gets list of roles and permissions mappings from server using HttpService.
360
+ * @param {string} appId
361
+ * @param {GetRolesAndPermissionsPayload} payload
362
+ * @return {*} {Observable<GetRolesAndPermissionsResponse>}
363
+ * @memberof TenantApplicationsService
364
+ */
365
+ getRolesAndPermissionsMappings(
366
+ appId: string,
367
+ payload: GetRolesAndPermissionsPayload
368
+ ): Observable<GetRolesAndPermissionsResponse> {
369
+ return this.httpService
370
+ .postData(
371
+ `${this.apiBaseUrl}/groups/roleBasedPermissions/${appId}`,
372
+ payload
373
+ )
374
+ .pipe(
375
+ map((response) => {
376
+ return response;
377
+ }),
378
+ catchError((error) => {
379
+ throw error;
380
+ })
381
+ );
382
+ }
383
+ /**
384
+ * Gets list of application types from server using HttpService.
385
+ * @return {Observable<GetAppTypesResponse>}
386
+ * @memberof TenantApplicationsService
387
+ */
388
+ getApplicationTypes(): Observable<GetAppTypesResponse> {
389
+ return this.httpService
390
+ .getData(`${this.apiBaseUrl}/configurations/config/app_type`)
391
+ .pipe(
392
+ map((response) => {
393
+ return response;
394
+ }),
395
+ catchError((error) => {
396
+ throw error;
397
+ })
398
+ );
399
+ }
400
+ /**
401
+ * Posts create role form data to server using HttpService to create a new role.
402
+ * @param {CreateModifyRoleRequestPayload} createModifyRolePayload
403
+ * @return {Observable<CreateModifyRoleResponse>}
404
+ * @memberof TenantApplicationsService
405
+ */
406
+ createRole(
407
+ createModifyRolePayload: CreateModifyRoleRequestPayload
408
+ ): Observable<CreateModifyRoleResponse> {
409
+ return this.httpService
410
+ .postData(`${this.apiBaseUrl}/groups/role`, createModifyRolePayload)
411
+ .pipe(
412
+ map((response) => {
413
+ return response;
414
+ }),
415
+ catchError((error) => {
416
+ throw error;
417
+ })
418
+ );
419
+ }
420
+ /**
421
+ * Posts the edited role form data to server using HttpService for updating the role information.
422
+ * @param {CreateModifyRoleRequestPayload} createModifyRolePayload
423
+ * @return {Observable<CreateModifyRoleResponse>}
424
+ * @memberof TenantApplicationsService
425
+ */
426
+ editRole(
427
+ createModifyRolePayload: CreateModifyRoleRequestPayload
428
+ ): Observable<CreateModifyRoleResponse> {
429
+ return this.httpService
430
+ .putData(`${this.apiBaseUrl}/groups/role`, createModifyRolePayload)
431
+ .pipe(
432
+ map((response) => {
433
+ return response;
434
+ }),
435
+ catchError((error) => {
436
+ throw error;
437
+ })
438
+ );
439
+ }
440
+
441
+ /**
442
+ * Gets list of role types from server using HttpService.
443
+ * @param {GetRoleTypesPayload} payload
444
+ * @return {Observable<RoleTypeResponse>}
445
+ * @memberof TenantApplicationsService
446
+ */
447
+ getRoleTypes(payload: GetRoleTypesPayload): Observable<RoleTypeResponse> {
448
+ return this.httpService
449
+ .postData(`${this.apiBaseUrl}/configurations/config/configField`, payload)
450
+ .pipe(
451
+ map((response) => {
452
+ return response;
453
+ }),
454
+ catchError((error) => {
455
+ throw error;
456
+ })
457
+ );
458
+ }
459
+ /**
460
+ * Constructs the select/dropdown options from the role types received from server.
461
+ * @param {RoleTypeConfiguration[]} roleTypeResponse
462
+ * @return {RoleTypeOption[]}
463
+ * @memberof TenantApplicationsService
464
+ */
465
+ getRoleTypeOptions(
466
+ roleTypeResponse: RoleTypeConfiguration[]
467
+ ): RoleTypeOption[] {
468
+ this.roleTypeOptions = [];
469
+ roleTypeResponse.forEach((item) => {
470
+ this.roleTypeOptions?.push({
471
+ id: item?.configFieldId,
472
+ name: item?.configFieldValue?.roleTypeName,
473
+ order: item?.configFieldValue?.viewOrder,
474
+ });
475
+ });
476
+ this.roleTypeOptions.sort((a, b) => a.order - b.order);
477
+ return this.roleTypeOptions;
478
+ }
479
+
480
+ /**
481
+ * Posts tenant application form data to server using HttpService for creating new tenant application.
482
+ * @param {CreateTenantPayload} createTenantPayload
483
+ * @return {Observable<CreateTenantResponse>}
484
+ * @memberof TenantApplicationsService
485
+ */
486
+ createTenant(
487
+ createTenantPayload: CreateTenantRequestPayload
488
+ ): Observable<CreateTenantResponse> {
489
+ return this.httpService
490
+ .postData(
491
+ `${this.apiBaseUrl}/configurations/app/createTenant`,
492
+ createTenantPayload
493
+ )
494
+ .pipe(
495
+ map((response) => {
496
+ return response;
497
+ }),
498
+ catchError((error) => {
499
+ throw error;
500
+ })
501
+ );
502
+ }
503
+
504
+ /**
505
+ * Constructs the checkbox options from features list from server.
506
+ * @param {FeaturesList[]} features
507
+ * @returns {CheckboxOption[]}
508
+ */
509
+ getFeatureOptions(features: Features[]): CheckboxOption[] {
510
+ this.checkBoxOptions = [];
511
+ features?.forEach((feature: Features) => {
512
+ this.checkBoxOptions?.push({
513
+ id: feature?.featureId,
514
+ name: feature?.featureName,
515
+ checked: feature?.isDefault,
516
+ disabled: feature?.isDefault,
517
+ });
518
+ });
519
+ return this.checkBoxOptions;
520
+ }
521
+ /**
522
+ * Constructs the radio options from application types from server.
523
+ * @param {AppTypeConfig[]} appTypeOptions
524
+ * @returns {RadioOption[]}
525
+ */
526
+ getApplicationTypeOptions(appTypeOptions: AppTypeConfig[]): RadioOption[] {
527
+ this.radioOptions = [];
528
+ appTypeOptions?.forEach((appType: AppTypeConfig) => {
529
+ this.radioOptions?.push({
530
+ id: appType?.configFieldId,
531
+ label: appType?.configFieldValue?.type,
532
+ });
533
+ });
534
+ return this.radioOptions;
535
+ }
536
+ /**
537
+ * Constructs the selected features id's.
538
+ * @param {CheckboxOption[]} featureOptions
539
+ * @returns {FeatureId[]}
540
+ */
541
+ getFeatureIds(featureOptions: CheckboxOption[]): FeatureId[] {
542
+ const featureIds: FeatureId[] = [];
543
+ featureOptions?.forEach((featureOption: CheckboxOption) => {
544
+ if (featureOption?.checked) {
545
+ featureIds.push({
546
+ featureId: featureOption.id as string,
547
+ });
548
+ }
549
+ });
550
+ return featureIds;
551
+ }
552
+ /**
553
+ * Sets the newly created tenant information.
554
+ * @param {NewTenantInfo} newTenantInfo
555
+ */
556
+ setNewTenantInfo(newTenantInfo: NewTenantInfo): void {
557
+ this.newTenantInfo = newTenantInfo;
558
+ }
559
+ /**
560
+ * Returns the newly created tenant information.
561
+ */
562
+ get getNewTenantInfo(): NewTenantInfo {
563
+ return this.newTenantInfo;
564
+ }
565
+
566
+ /**
567
+ * Sets tenant function type.
568
+ * @param {TenantFunctionType} tenantFunctionType -tenant function type.
569
+ */
570
+ setTenantFunctionType(tenantFunctionType: TenantFunctionType): void {
571
+ this.tenantFunctionType = tenantFunctionType;
572
+ }
573
+
574
+ /**
575
+ * Returns tenant function type.
576
+ * @return {TenantFunctionType} -tenant function type.
577
+ */
578
+ getTenantFunctionType(): TenantFunctionType {
579
+ return this.tenantFunctionType;
580
+ }
581
+ /**
582
+ * Stores the newly created role information.
583
+ * @param {RoleInfo} newlyCreatedRole -create role information.
584
+ */
585
+ setNewlyCreatedRoleInfo(newlyCreatedRole: RoleInfo): void {
586
+ this.newlyCreatedRole = newlyCreatedRole;
587
+ }
588
+ /**
589
+ * Returns the newly created role information.
590
+ * @return {RoleInfo} -create role information.
591
+ */
592
+ getNewlyCreatedRoleInfo(): RoleInfo {
593
+ return this.newlyCreatedRole;
594
+ }
595
+ /**
596
+ * Stores the newly created group type information.
597
+ * @param {CreatedOrModifiedGroupTypeInfo} newlyCreatedGroupType
598
+ * @memberof TenantApplicationsService
599
+ */
600
+ setNewlyCreatedGroupTypeInfo(newlyCreatedGroupType: CreatedOrModifiedGroupTypeInfo): void {
601
+ this.newlyCreatedGroupType = newlyCreatedGroupType;
602
+ }
603
+ /**
604
+ * Returns the newly created group type information.
605
+ * @return {*} {CreatedOrModifiedGroupTypeInfo}
606
+ * @memberof TenantApplicationsService
607
+ */
608
+ getNewlyCreatedGroupTypeInfo(): CreatedOrModifiedGroupTypeInfo {
609
+ return this.newlyCreatedGroupType;
610
+ }
611
+ /**
612
+ * Posts the edited tenant application form data to server using HttpService for updating the tenant information.
613
+ * @param {CreateTenantPayload} editTenantPayload
614
+ * @return {Observable<CreateTenantResponse>}
615
+ * @memberof TenantApplicationsService
616
+ */
617
+ editTenant(
618
+ editTenantPayload: CreateTenantRequestPayload
619
+ ): Observable<CreateTenantResponse> {
620
+ return this.httpService
621
+ .putData(
622
+ `${this.apiBaseUrl}/configurations/app/editTenant`,
623
+ editTenantPayload
624
+ )
625
+ .pipe(
626
+ map((response) => {
627
+ return response;
628
+ }),
629
+ catchError((error) => {
630
+ throw error;
631
+ })
632
+ );
633
+ }
634
+ /**
635
+ * Sends update request to the server to update the tenant application status to active/inactive using HttpService and returns the success or failure response.
636
+ * @param {UpdateTenantStatusRequestPayload} updateTenantStatusPayload
637
+ * @return {Observable<UpdateTenantStatusResponse>}
638
+ * @memberof TenantApplicationsService
639
+ */
640
+ updateTenantStatus(
641
+ updateTenantStatusPayload: UpdateTenantStatusRequestPayload
642
+ ): Observable<UpdateTenantStatusResponse> {
643
+ return this.httpService
644
+ .putData(
645
+ `${this.apiBaseUrl}/configurations/app/updateStatus`,
646
+ updateTenantStatusPayload
647
+ )
648
+ .pipe(
649
+ map((response) => {
650
+ return response;
651
+ }),
652
+ catchError((error) => {
653
+ throw error;
654
+ })
655
+ );
656
+ }
657
+ /**
658
+ * It generates Feature list from checkbox options generated in form array.
659
+ * @param {CheckboxOption[]} features
660
+ * @return {Features[]}
661
+ * @memberof TenantApplicationsService
662
+ */
663
+ getFeaturesList(features: CheckboxOption[]): Features[] {
664
+ this.featureList = [];
665
+ features?.forEach((feature: CheckboxOption) => {
666
+ if (feature.checked)
667
+ this.featureList?.push({
668
+ featureId: feature?.id as string,
669
+ featureName: feature?.name as string,
670
+ isDefault: feature?.checked,
671
+ });
672
+ });
673
+ return this.featureList;
674
+ }
675
+ /**
676
+ * Gets roster type from server using HttpService.
677
+ * @return {*} {Observable<GetRosterTypeOrSettingsResponse>}
678
+ * @memberof TenantApplicationsService
679
+ */
680
+ getRosterType(): Observable<GetRosterTypeOrSettingsResponse> {
681
+ return this.httpService
682
+ .getData(`${this.apiBaseUrl}/configurations/lookup/RosterType`)
683
+ .pipe(
684
+ map((response) => {
685
+ return response;
686
+ }),
687
+ catchError((error) => {
688
+ throw error;
689
+ })
690
+ );
691
+ }
692
+ /**
693
+ * Gets group type settings from server using HttpService.
694
+ * @return {*} {Observable<GetRosterTypeOrSettingsResponse>}
695
+ * @memberof TenantApplicationsService
696
+ */
697
+ getGroupTypeSettings(): Observable<GetRosterTypeOrSettingsResponse> {
698
+ return this.httpService
699
+ .getData(`${this.apiBaseUrl}/configurations/lookup/GT_Settings`)
700
+ .pipe(
701
+ map((response) => {
702
+ return response;
703
+ }),
704
+ catchError((error) => {
705
+ throw error;
706
+ })
707
+ );
708
+ }
709
+ /**
710
+ * Posts the group type details to server using HttpService to create new group type.
711
+ * @param {CreateGroupTypeRequestPayload} createGroupTypePayload
712
+ * @return {*} {Observable<CreateGroupTypeResponse>}
713
+ * @memberof TenantApplicationsService
714
+ */
715
+ createGroupType(
716
+ createGroupTypePayload: CreateGroupTypeRequestPayload
717
+ ): Observable<CreateGroupTypeResponse> {
718
+ return this.httpService
719
+ .postData(
720
+ `${this.apiBaseUrl}/configurations/config/groupType`,
721
+ createGroupTypePayload
722
+ )
723
+ .pipe(
724
+ map((response) => {
725
+ return response;
726
+ }),
727
+ catchError((error) => {
728
+ throw error;
729
+ })
730
+ );
731
+ }
732
+ /**
733
+ * Returns sorted role list data.
734
+ * @param {Role[]} roleList
735
+ * @return {Role[]}
736
+ * @memberof TenantApplicationsService
737
+ */
738
+ sortRolesByRoleType(roleList: Role[]): Role[] {
739
+ return roleList.sort((a, b) => a?.viewOrder - b?.viewOrder);
740
+ }
741
+ /**
742
+ * Posts the role details to server using HttpService for deleting the role.
743
+ * @param {DeleteRoleRequestPayload} deleteRoleRequestPayload
744
+ * @return {Observable<DeleteRoleResponse>}
745
+ * @memberof TenantApplicationsService
746
+ */
747
+ deleteRole(
748
+ deleteRolePayload: DeleteRoleRequestPayload
749
+ ): Observable<DeleteRoleResponse> {
750
+ return this.httpService
751
+ .putData(`${this.apiBaseUrl}/groups/role/deleteRole`, deleteRolePayload)
752
+ .pipe(
753
+ map((response) => {
754
+ return response;
755
+ }),
756
+ catchError((error) => {
757
+ throw error;
758
+ })
759
+ );
760
+ }
761
+ /**
762
+ * Gets group types from server using HttpService.
763
+ * @param {string} appId
764
+ * @return {Observable<ViewGroupTypeResponse>}
765
+ * @memberof TenantApplicationsService
766
+ */
767
+ getGroupTypes(appId: string): Observable<ViewGroupTypeResponse> {
768
+ return this.httpService
769
+ .getData(
770
+ `${this.apiBaseUrl}/configurations/config/appGroupTypeDetails/${appId}`
771
+ )
772
+ .pipe(
773
+ map((response) => {
774
+ return response;
775
+ }),
776
+ catchError((error) => {
777
+ throw error;
778
+ })
779
+ );
780
+ }
781
+ /**
782
+ * Sets group type details.
783
+ * @param {ViewGroupTypeResponse} groupTypes
784
+ * @memberof TenantApplicationsService
785
+ */
786
+ setGroupTypeDetails(groupTypes: ViewGroupTypeResponse): void {
787
+ this.groupTypes = groupTypes;
788
+ }
789
+
790
+ /**
791
+ * Returns group type details.
792
+ * @return {ViewGroupTypeResponse}
793
+ * @memberof TenantApplicationsService
794
+ */
795
+ getGroupTypeDetails(): ViewGroupTypeResponse {
796
+ return this.groupTypes;
797
+ }
798
+ }