@ieeesa-npm/tenants 0.4.4 → 0.5.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.
Files changed (142) hide show
  1. package/esm2022/ieeesa-npm-tenants.mjs +5 -0
  2. package/esm2022/lib/assets/constants.json +454 -0
  3. package/esm2022/lib/assets/tenant-validations.mjs +17 -0
  4. package/esm2022/lib/components/create-modify-group-type/create-modify-group-type.component.mjs +476 -0
  5. package/esm2022/lib/components/create-modify-role/create-modify-role.component.mjs +279 -0
  6. package/esm2022/lib/components/create-tenant-application/create-tenant-application.component.mjs +512 -0
  7. package/esm2022/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.mjs +391 -0
  8. package/esm2022/lib/components/tenant-basic-details/tenant-basic-details.component.mjs +94 -0
  9. package/esm2022/lib/components/view-tenant-details/view-tenant-details.component.mjs +733 -0
  10. package/esm2022/lib/components/view-tenant-group-types/view-tenant-group-types.component.mjs +194 -0
  11. package/esm2022/lib/components/view-tenants-list/view-tenants-list.component.mjs +335 -0
  12. package/esm2022/lib/models/app-type-config.model.mjs +2 -0
  13. package/esm2022/lib/models/app-type.model.mjs +7 -0
  14. package/esm2022/lib/models/create-group-type-config.model.mjs +22 -0
  15. package/esm2022/lib/models/create-group-type.model.mjs +2 -0
  16. package/esm2022/lib/models/feature-permission-id.model.mjs +8 -0
  17. package/esm2022/lib/models/features.model.mjs +2 -0
  18. package/esm2022/lib/models/permission-type.model.mjs +12 -0
  19. package/esm2022/lib/models/role-menu-action.model.mjs +7 -0
  20. package/esm2022/lib/models/role-type.model.mjs +2 -0
  21. package/esm2022/lib/models/roles-and-permissions-table-type.model.mjs +7 -0
  22. package/esm2022/lib/models/roles-and-permissions.model.mjs +2 -0
  23. package/esm2022/lib/models/route-config.model.mjs +2 -0
  24. package/esm2022/lib/models/table-column-schema-view-tenant-list.model.mjs +16 -0
  25. package/esm2022/lib/models/tenant-function-type.model.mjs +12 -0
  26. package/esm2022/lib/models/tenant.model.mjs +2 -0
  27. package/esm2022/lib/models/tenants-permission.model.mjs +2 -0
  28. package/esm2022/lib/models/update-tenant-status.model.mjs +2 -0
  29. package/esm2022/lib/models/view-tenant-group-types.model.mjs +11 -0
  30. package/esm2022/lib/services/tenant-applications.service.mjs +618 -0
  31. package/esm2022/lib/services/tenant-permissions-map.service.mjs +36 -0
  32. package/esm2022/lib/services/tenant-permissions.service.mjs +38 -0
  33. package/esm2022/lib/tenant-applications.component.mjs +14 -0
  34. package/esm2022/lib/tenant-applications.module.mjs +16 -0
  35. package/esm2022/public-api.mjs +36 -0
  36. package/fesm2022/ieeesa-npm-tenants.mjs +4233 -0
  37. package/fesm2022/ieeesa-npm-tenants.mjs.map +1 -0
  38. package/index.d.ts +5 -0
  39. package/lib/assets/tenant-validations.d.ts +15 -0
  40. package/lib/components/create-modify-group-type/create-modify-group-type.component.d.ts +129 -0
  41. package/lib/components/create-modify-role/create-modify-role.component.d.ts +103 -0
  42. package/lib/components/create-tenant-application/create-tenant-application.component.d.ts +128 -0
  43. package/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.d.ts +106 -0
  44. package/lib/components/tenant-basic-details/tenant-basic-details.component.d.ts +471 -0
  45. package/lib/components/view-tenant-details/view-tenant-details.component.d.ts +223 -0
  46. package/lib/components/view-tenant-group-types/view-tenant-group-types.component.d.ts +63 -0
  47. package/lib/components/view-tenants-list/view-tenants-list.component.d.ts +134 -0
  48. package/lib/models/app-type-config.model.d.ts +14 -0
  49. package/lib/models/app-type.model.d.ts +4 -0
  50. package/lib/models/create-group-type-config.model.d.ts +16 -0
  51. package/lib/models/create-group-type.model.d.ts +49 -0
  52. package/lib/models/feature-permission-id.model.d.ts +4 -0
  53. package/lib/models/features.model.d.ts +15 -0
  54. package/lib/models/permission-type.model.d.ts +8 -0
  55. package/lib/models/role-menu-action.model.d.ts +4 -0
  56. package/lib/models/role-type.model.d.ts +27 -0
  57. package/lib/models/roles-and-permissions-table-type.model.d.ts +4 -0
  58. package/lib/models/roles-and-permissions.model.d.ts +119 -0
  59. package/lib/models/route-config.model.d.ts +4 -0
  60. package/lib/models/table-column-schema-view-tenant-list.model.d.ts +20 -0
  61. package/lib/models/tenant-function-type.model.d.ts +9 -0
  62. package/lib/models/tenant.model.d.ts +51 -0
  63. package/lib/models/tenants-permission.model.d.ts +9 -0
  64. package/lib/models/update-tenant-status.model.d.ts +14 -0
  65. package/lib/models/view-tenant-group-types.model.d.ts +29 -0
  66. package/lib/services/tenant-applications.service.d.ts +399 -0
  67. package/lib/services/tenant-permissions-map.service.d.ts +13 -0
  68. package/lib/services/tenant-permissions.service.d.ts +22 -0
  69. package/lib/tenant-applications.component.d.ts +5 -0
  70. package/lib/tenant-applications.module.d.ts +6 -0
  71. package/package.json +25 -12
  72. package/{src/public-api.ts → public-api.d.ts} +32 -40
  73. package/.eslintrc.json +0 -31
  74. package/ng-package.json +0 -8
  75. package/src/lib/assets/constants.json +0 -454
  76. package/src/lib/assets/tenant-validations.ts +0 -18
  77. package/src/lib/assets/tenants-mock.ts +0 -1240
  78. package/src/lib/components/create-modify-group-type/create-modify-group-type.component.html +0 -15
  79. package/src/lib/components/create-modify-group-type/create-modify-group-type.component.scss +0 -44
  80. package/src/lib/components/create-modify-group-type/create-modify-group-type.component.spec.ts +0 -574
  81. package/src/lib/components/create-modify-group-type/create-modify-group-type.component.ts +0 -602
  82. package/src/lib/components/create-modify-role/create-modify-role.component.html +0 -15
  83. package/src/lib/components/create-modify-role/create-modify-role.component.scss +0 -83
  84. package/src/lib/components/create-modify-role/create-modify-role.component.spec.ts +0 -346
  85. package/src/lib/components/create-modify-role/create-modify-role.component.ts +0 -321
  86. package/src/lib/components/create-tenant-application/create-tenant-application.component.html +0 -18
  87. package/src/lib/components/create-tenant-application/create-tenant-application.component.scss +0 -73
  88. package/src/lib/components/create-tenant-application/create-tenant-application.component.spec.ts +0 -775
  89. package/src/lib/components/create-tenant-application/create-tenant-application.component.ts +0 -638
  90. package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.html +0 -22
  91. package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.scss +0 -79
  92. package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.spec.ts +0 -716
  93. package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.ts +0 -504
  94. package/src/lib/components/tenant-basic-details/tenant-basic-details.component.html +0 -44
  95. package/src/lib/components/tenant-basic-details/tenant-basic-details.component.scss +0 -16
  96. package/src/lib/components/tenant-basic-details/tenant-basic-details.component.spec.ts +0 -115
  97. package/src/lib/components/tenant-basic-details/tenant-basic-details.component.ts +0 -109
  98. package/src/lib/components/view-tenant-details/view-tenant-details.component.html +0 -195
  99. package/src/lib/components/view-tenant-details/view-tenant-details.component.scss +0 -163
  100. package/src/lib/components/view-tenant-details/view-tenant-details.component.spec.ts +0 -1221
  101. package/src/lib/components/view-tenant-details/view-tenant-details.component.ts +0 -876
  102. package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.html +0 -10
  103. package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.scss +0 -44
  104. package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.spec.ts +0 -410
  105. package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.ts +0 -219
  106. package/src/lib/components/view-tenants-list/view-tenants-list.component.html +0 -32
  107. package/src/lib/components/view-tenants-list/view-tenants-list.component.scss +0 -35
  108. package/src/lib/components/view-tenants-list/view-tenants-list.component.spec.ts +0 -464
  109. package/src/lib/components/view-tenants-list/view-tenants-list.component.ts +0 -388
  110. package/src/lib/models/app-type-config.model.ts +0 -14
  111. package/src/lib/models/app-type.model.ts +0 -5
  112. package/src/lib/models/create-group-type-config.model.ts +0 -18
  113. package/src/lib/models/create-group-type.model.ts +0 -46
  114. package/src/lib/models/feature-permission-id.model.ts +0 -6
  115. package/src/lib/models/features.model.ts +0 -15
  116. package/src/lib/models/form-status.model.ts +0 -5
  117. package/src/lib/models/permission-type.model.ts +0 -9
  118. package/src/lib/models/role-menu-action.model.ts +0 -5
  119. package/src/lib/models/role-type.model.ts +0 -34
  120. package/src/lib/models/roles-and-permissions-table-type.model.ts +0 -5
  121. package/src/lib/models/roles-and-permissions.model.ts +0 -113
  122. package/src/lib/models/route-config.model.ts +0 -4
  123. package/src/lib/models/table-column-schema-view-tenant-list.model.ts +0 -21
  124. package/src/lib/models/tenant-function-type.model.ts +0 -10
  125. package/src/lib/models/tenant.model.ts +0 -47
  126. package/src/lib/models/tenants-permission.model.ts +0 -9
  127. package/src/lib/models/update-tenant-status.model.ts +0 -12
  128. package/src/lib/models/view-tenant-group-types.model.ts +0 -34
  129. package/src/lib/services/tenant-applications.service.spec.ts +0 -1245
  130. package/src/lib/services/tenant-applications.service.ts +0 -798
  131. package/src/lib/services/tenant-permissions-map.service.spec.ts +0 -25
  132. package/src/lib/services/tenant-permissions-map.service.ts +0 -28
  133. package/src/lib/services/tenant-permissions.service.spec.ts +0 -62
  134. package/src/lib/services/tenant-permissions.service.ts +0 -49
  135. package/src/lib/tenant-applications.component.html +0 -0
  136. package/src/lib/tenant-applications.component.scss +0 -0
  137. package/src/lib/tenant-applications.component.spec.ts +0 -28
  138. package/src/lib/tenant-applications.component.ts +0 -12
  139. package/src/lib/tenant-applications.module.ts +0 -8
  140. package/tsconfig.lib.json +0 -14
  141. package/tsconfig.lib.prod.json +0 -10
  142. package/tsconfig.spec.json +0 -14
@@ -1,638 +0,0 @@
1
- import {
2
- Component,
3
- EventEmitter,
4
- OnDestroy,
5
- OnInit,
6
- Output,
7
- ViewChild,
8
- ViewEncapsulation,
9
- } from '@angular/core';
10
- import {
11
- AlignType,
12
- CheckboxOption,
13
- FormGrid,
14
- FormControlType,
15
- AllowedFileTypes,
16
- FileUploadPresignedUrl,
17
- RadioOption,
18
- DynamicFormComponent,
19
- FormModel,
20
- FileUploadService,
21
- } from '@ieeesa-npm/presentation';
22
- import { Subject, takeUntil } from 'rxjs';
23
- import * as screenTexts from '../../assets/constants.json';
24
- import { FormArray, FormGroup, Validators } from '@angular/forms';
25
- import { TenantsValidationPatterns } from '../../assets/tenant-validations';
26
- import { CommonModule } from '@angular/common';
27
- import { FormStatus } from '../../models/form-status.model';
28
- import { validColorValidator } from 'ngx-colors';
29
- import { Features, GetFeaturesResponse } from '../../models/features.model';
30
- import { TenantApplicationsService } from '../../services/tenant-applications.service';
31
- import {
32
- AppTypeConfig,
33
- GetAppTypesResponse,
34
- } from '../../models/app-type-config.model';
35
- import {
36
- CreateTenantRequestPayload,
37
- CreateTenantResponse,
38
- NewTenantInfo,
39
- TenantBasicInfo,
40
- } from '../../models/tenant.model';
41
- import { SharedService } from '@ieeesa-npm/shared';
42
- import { TenantFunctionType } from '../../models/tenant-function-type.model';
43
-
44
- @Component({
45
- selector: 'ieeesa-create-tenant-application',
46
- standalone: true,
47
- imports: [CommonModule, DynamicFormComponent],
48
- templateUrl: './create-tenant-application.component.html',
49
- styleUrls: ['./create-tenant-application.component.scss'],
50
- encapsulation: ViewEncapsulation.None,
51
- })
52
- export class CreateTenantApplicationComponent implements OnInit, OnDestroy {
53
- destroy$ = new Subject<boolean>();
54
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
- constants: any = screenTexts;
56
- createTenantTexts = this.constants?.createTenant;
57
- leftButtonLabel = this.createTenantTexts?.label?.leftButtonLabel;
58
- rightButtonLabel = this.createTenantTexts?.label?.rightButtonLabel;
59
- colWidth: FormGrid = { xs: 12, xl: 12, sm: 12, md: 12, lg: 12 };
60
- createTenantFormGroup!: FormModel;
61
- actionButtonAlign = AlignType.LEFT;
62
- createTenantFormGroupRef!: FormGroup;
63
- @ViewChild(DynamicFormComponent)
64
- dynamicFormComponent!: DynamicFormComponent;
65
- @Output() submitFormResponse = new EventEmitter();
66
- @Output() formCancel = new EventEmitter();
67
- featuresOptions!: CheckboxOption[];
68
- appTypeOptions!: RadioOption[];
69
- createTenantPayload!: CreateTenantRequestPayload;
70
- fileUploadPresignedUrl!: string;
71
- fileDownloadPresignedUrl!: string;
72
- file!: File | FileList;
73
- allowedFileTypes = [
74
- AllowedFileTypes.JPG,
75
- AllowedFileTypes.PNG,
76
- AllowedFileTypes.SVG,
77
- ];
78
- selectedColor!: string;
79
- selectedAppTypeOption!: RadioOption;
80
- tenantFunctionType!: TenantFunctionType;
81
- selectedTenantInfo!: TenantBasicInfo | undefined;
82
- isAppLogoModified = false;
83
- updatedTenantBasicInfo!: NewTenantInfo;
84
- constructor(
85
- // eslint-disable-next-line no-unused-vars
86
- public fileUploadService: FileUploadService,
87
- // eslint-disable-next-line no-unused-vars
88
- private tenantAppService: TenantApplicationsService,
89
- // eslint-disable-next-line no-unused-vars
90
- private sharedService: SharedService // eslint-disable-next-line no-empty-function
91
- ) {}
92
- ngOnInit(): void {
93
- this.tenantFunctionType = this.tenantAppService?.getTenantFunctionType();
94
- this.selectedTenantInfo =
95
- this.tenantAppService?.getSelectedTenantInformation();
96
- this.fileUploadService.setApiBaseUrl(this.tenantAppService?.apiBaseUrl);
97
- this.getFeatures();
98
- }
99
- /**
100
- * Gets the list of features and updates the form control.
101
- * @memberof CreateTenantApplicationComponent
102
- */
103
- getFeatures(): void {
104
- this.tenantAppService
105
- .getFeatures()
106
- .pipe(takeUntil(this.destroy$))
107
- .subscribe({
108
- next: (response: GetFeaturesResponse) => {
109
- if (response?.status) {
110
- this.featuresOptions = this.tenantAppService.getFeatureOptions(
111
- response?.body as Features[]
112
- );
113
- if (this.tenantFunctionType === TenantFunctionType.EDIT)
114
- this.featuresOptions?.forEach((option: CheckboxOption) => {
115
- if (
116
- this.selectedTenantInfo?.features?.some(
117
- (feature: Features) => feature?.featureId === option?.id
118
- )
119
- ) {
120
- option.checked = true;
121
- }
122
- });
123
- this.getApplicationTypes();
124
- }
125
- },
126
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
127
- error: (error: any) => {
128
- this.sharedService.handleErrors(
129
- error,
130
- this.createTenantTexts?.errors
131
- );
132
- },
133
- });
134
- }
135
- /**
136
- * Gets the application/tenant types and updates the form control.
137
- * @memberof CreateTenantApplicationComponent
138
- */
139
- getApplicationTypes(): void {
140
- this.tenantAppService
141
- .getApplicationTypes()
142
- .pipe(takeUntil(this.destroy$))
143
- .subscribe({
144
- next: (response: GetAppTypesResponse) => {
145
- if (response?.status) {
146
- this.appTypeOptions =
147
- this.tenantAppService.getApplicationTypeOptions(
148
- response?.body as AppTypeConfig[]
149
- );
150
- if (this.tenantFunctionType === TenantFunctionType.EDIT) {
151
- this.appTypeOptions?.forEach((radioOption: RadioOption) => {
152
- if (radioOption?.id === this.selectedTenantInfo?.appType) {
153
- radioOption.checked = true;
154
- this.selectedAppTypeOption = radioOption;
155
- } else {
156
- radioOption.checked = false;
157
- }
158
- });
159
- }
160
- this.initializeCreateTenantFormGroup();
161
- }
162
- },
163
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
164
- error: (error: any) => {
165
- this.sharedService.handleErrors(
166
- error,
167
- this.createTenantTexts?.errors
168
- );
169
- },
170
- });
171
- }
172
- /**
173
- * Initialize the create tenant form group array.
174
- * @memberof CreateTenantApplicationComponent
175
- */
176
- initializeCreateTenantFormGroup(): void {
177
- this.createTenantFormGroup = {
178
- formGroup: [
179
- {
180
- legend: '',
181
- controls: [
182
- {
183
- type: FormControlType.INPUT,
184
- label: this.createTenantTexts?.label?.appTitle + '*',
185
- controlName: 'appTitle',
186
- value:
187
- this.tenantFunctionType === TenantFunctionType.EDIT
188
- ? this.selectedTenantInfo?.appTitle
189
- : '',
190
- validation: [
191
- Validators.required,
192
- Validators.maxLength(
193
- TenantsValidationPatterns.appTitleMaxLength
194
- ),
195
- ],
196
- supportMessage: this.createTenantTexts?.supportText?.appTitle,
197
- requiredErrorMessage:
198
- this.createTenantTexts?.message?.error?.required,
199
- maxErrorMessage:
200
- this.createTenantTexts?.message?.error?.limit?.appTitleMaxChars,
201
- ariaLabel: this.createTenantTexts?.label?.ariaLabel?.appTitle,
202
- ariaDescribedById:
203
- this.createTenantTexts?.label?.ariaDescribedById?.appTitle,
204
- },
205
- {
206
- type: FormControlType.INPUT,
207
- label: `${this.createTenantTexts?.label?.appId}${
208
- this.tenantFunctionType === TenantFunctionType.EDIT ? '' : '*'
209
- }`,
210
- controlName: 'appId',
211
- value:
212
- this.tenantFunctionType === TenantFunctionType.EDIT
213
- ? this.selectedTenantInfo?.appId
214
- : '',
215
- validation: [
216
- Validators.required,
217
- Validators.maxLength(TenantsValidationPatterns.appIdMaxLength),
218
- Validators.pattern(TenantsValidationPatterns.alphaNumeric),
219
- ],
220
- disabled: this.tenantFunctionType === TenantFunctionType.EDIT,
221
- supportMessage:
222
- this.tenantFunctionType === TenantFunctionType.EDIT
223
- ? ''
224
- : this.createTenantTexts?.supportText?.appId,
225
- requiredErrorMessage:
226
- this.createTenantTexts?.message?.error?.required,
227
- maxErrorMessage:
228
- this.createTenantTexts?.message?.error?.limit?.appIdMaxChars,
229
- patternErrorMessage:
230
- this.createTenantTexts?.message?.error?.pattern?.appId,
231
- ariaLabel: this.createTenantTexts?.label?.ariaLabel?.appId,
232
- ariaDescribedById:
233
- this.createTenantTexts?.label?.ariaDescribedById?.appId,
234
- },
235
- {
236
- type: FormControlType?.FILE_UPLOAD,
237
- label: this.createTenantTexts?.label?.appLogo + '*',
238
- controlName: 'appLogo',
239
- requiredErrorMessage:
240
- this.createTenantTexts?.message?.error?.required,
241
- value:
242
- this.tenantFunctionType === TenantFunctionType.EDIT
243
- ? this.selectedTenantInfo?.appLogo
244
- : '',
245
- placeholder: '',
246
- isFileSelected:
247
- this.tenantFunctionType === TenantFunctionType.EDIT,
248
- supportMessage: this.createTenantTexts?.supportText?.appLogo,
249
- validation: [Validators.required],
250
- ariaLabel: this.createTenantTexts?.label?.ariaLabel?.appLogo,
251
- ariaDescribedById:
252
- this.createTenantTexts?.label?.ariaDescribedById?.appLogo,
253
- isMultiFileUpload: false,
254
- maxUploadFileSize: 2,
255
- maxFileSizeErrorMessage:
256
- this.createTenantTexts?.message?.error?.limit?.appLogoMaxSize,
257
- allowedFileTypeErrorMessage:
258
- this.createTenantTexts?.message?.error?.invalidFile,
259
- allowedFileTypes: this.allowedFileTypes,
260
- },
261
- {
262
- type: FormControlType.INPUT,
263
- label: this.createTenantTexts?.label?.appHeading + '*',
264
- controlName: 'appHeading',
265
- value:
266
- this.tenantFunctionType === TenantFunctionType.EDIT
267
- ? this.selectedTenantInfo?.appHeading
268
- : '',
269
- validation: [
270
- Validators.required,
271
- Validators.maxLength(
272
- TenantsValidationPatterns.appHeadingMaxLength
273
- ),
274
- ],
275
- supportMessage: this.createTenantTexts?.supportText?.appHeading,
276
- requiredErrorMessage:
277
- this.createTenantTexts?.message?.error?.required,
278
- maxErrorMessage:
279
- this.createTenantTexts?.message?.error?.limit
280
- ?.appHeadingMaxChars,
281
- patternErrorMessage:
282
- this.createTenantTexts?.message?.error?.pattern?.email,
283
- ariaLabel: this.createTenantTexts?.label?.ariaLabel?.appHeading,
284
- ariaDescribedById:
285
- this.createTenantTexts?.label?.ariaDescribedById?.appHeading,
286
- },
287
- {
288
- type: FormControlType.TEXT_AREA,
289
- label: this.createTenantTexts?.label?.appDescription + '*',
290
- controlName: 'appDescription',
291
- value:
292
- this.tenantFunctionType === TenantFunctionType.EDIT
293
- ? this.selectedTenantInfo?.appDescription
294
- : '',
295
- validation: [
296
- Validators.required,
297
- Validators.maxLength(
298
- TenantsValidationPatterns.appDescriptionMaxLength
299
- ),
300
- ],
301
- supportMessage:
302
- this.createTenantTexts?.supportText?.appDescription,
303
- requiredErrorMessage:
304
- this.createTenantTexts?.message?.error?.required,
305
- maxErrorMessage:
306
- this.createTenantTexts?.message?.error?.limit
307
- ?.appDescriptionMaxChars,
308
- maxCharCount: TenantsValidationPatterns.appDescriptionMaxLength,
309
- ariaLabel:
310
- this.createTenantTexts?.label?.ariaLabel?.appDescription,
311
- ariaDescribedById:
312
- this.createTenantTexts?.label?.ariaDescribedById
313
- ?.appDescription,
314
- ariaMultiline: true,
315
- isResize: true,
316
- },
317
- {
318
- type: FormControlType.COLOR_PICKER,
319
- label: this.createTenantTexts?.label?.appBgColor + '*',
320
- controlName: 'backgroundColor',
321
- value: '',
322
- defaultColor:
323
- this.tenantFunctionType === TenantFunctionType.EDIT
324
- ? this.selectedTenantInfo?.backgroundColor
325
- : '',
326
- placeholder: '',
327
- supportMessage: this.createTenantTexts?.supportText?.appBgColor,
328
- validation: [Validators.required, validColorValidator()],
329
- requiredErrorMessage:
330
- this.createTenantTexts?.message?.error?.required,
331
- invalidColorErrorMessage:
332
- this.createTenantTexts?.message?.error?.invalidColor,
333
- ariaLabel: this.createTenantTexts?.supportText?.appBgColor,
334
- ariaDescribedById:
335
- this.createTenantTexts?.supportText?.appBgColor,
336
- },
337
- {
338
- type: FormControlType.INPUT,
339
- label: this.createTenantTexts?.label?.appHelpLink + '*',
340
- controlName: 'appHelpLink',
341
- value:
342
- this.tenantFunctionType === TenantFunctionType.EDIT
343
- ? this.selectedTenantInfo?.appHelpLink
344
- : '',
345
- validation: [
346
- Validators.required,
347
- Validators.pattern(TenantsValidationPatterns.url),
348
- ],
349
- supportMessage: this.createTenantTexts?.supportText?.appHelpLink,
350
- requiredErrorMessage:
351
- this.createTenantTexts?.message?.error?.required,
352
- patternErrorMessage:
353
- this.createTenantTexts?.message?.error?.pattern?.appHelpLink,
354
- ariaLabel: this.createTenantTexts?.label?.ariaLabel?.appHelpLink,
355
- ariaDescribedById:
356
- this.createTenantTexts?.label?.ariaDescribedById?.appHelpLink,
357
- },
358
- {
359
- type: FormControlType.CHECKBOX,
360
- label: this.createTenantTexts?.label?.featuresList + '*',
361
- controlName: 'features',
362
- checkboxOptions: this.featuresOptions,
363
- minSelectionRequired: 1,
364
- ariaLabel: this.createTenantTexts?.label?.ariaLabel?.featuresList,
365
- ariaDescribedById:
366
- this.createTenantTexts?.label?.ariaDescribedById?.featuresList,
367
- supportMessage: this.createTenantTexts?.supportText?.featuresList,
368
- requiredErrorMessage:
369
- this.createTenantTexts?.message?.error?.required,
370
- validation: [Validators.required],
371
- },
372
- {
373
- type: FormControlType.INPUT,
374
- label: this.createTenantTexts?.label?.domainURL + '*',
375
- controlName: 'appDomainUrl',
376
- value:
377
- this.tenantFunctionType === TenantFunctionType.EDIT
378
- ? this.selectedTenantInfo?.appDomainUrl
379
- : '',
380
- validation: [
381
- Validators.required,
382
- Validators.pattern(TenantsValidationPatterns.url),
383
- ],
384
- supportMessage: this.createTenantTexts?.supportText?.domainURL,
385
- requiredErrorMessage:
386
- this.createTenantTexts?.message?.error?.required,
387
- patternErrorMessage:
388
- this.createTenantTexts?.message?.error?.pattern?.appDomainUrl,
389
- ariaLabel: this.createTenantTexts?.label?.ariaLabel?.domainURL,
390
- ariaDescribedById:
391
- this.createTenantTexts?.label?.ariaDescribedById?.domainURL,
392
- },
393
- {
394
- type: FormControlType.RADIO,
395
- label: `${this.createTenantTexts?.label?.appType}${
396
- this.tenantFunctionType === TenantFunctionType.EDIT ? '' : '*'
397
- }`,
398
- controlName: 'appType',
399
- value:
400
- this.tenantFunctionType === TenantFunctionType.EDIT
401
- ? this.selectedTenantInfo?.appType
402
- : '',
403
- disabled: this.tenantFunctionType === TenantFunctionType.EDIT,
404
- radioOptions: this.appTypeOptions,
405
- validation: [Validators.required],
406
- requiredErrorMessage:
407
- this.createTenantTexts?.message?.error?.required,
408
- ariaLabel: this.createTenantTexts?.label?.ariaLabel?.appType,
409
- ariaDescribedById:
410
- this.createTenantTexts?.label?.ariaDescribedById?.appType,
411
- },
412
- ],
413
- },
414
- ],
415
- };
416
- }
417
-
418
- /**
419
- * Creates Payload and gets presigned url for file upload on form submission.
420
- * @param {FormGroup[]} form
421
- * @memberof CreateTenantApplicationComponent
422
- */
423
- onCreateTenantFormSubmit(form: FormGroup[]): void {
424
- form[0]?.markAllAsTouched();
425
- if (form[0].status === FormStatus.VALID) {
426
- this.createTenantPayload = this.getCreateTenantPayload(
427
- form[0].getRawValue()
428
- );
429
- if (
430
- this.tenantFunctionType === TenantFunctionType.EDIT &&
431
- (!this.isAppLogoModified || !this.file)
432
- ) {
433
- this.editTenant();
434
- } else if (this.file) {
435
- this.getFileUploadPresignedUrl(
436
- this.file,
437
- form[0]?.controls['appId']?.value
438
- );
439
- } else {
440
- this.createTenant();
441
- }
442
- }
443
- }
444
-
445
- /**
446
- * Creates a new tenant on form submission.
447
- * @memberof CreateTenantApplicationComponent
448
- */
449
- createTenant(): void {
450
- this.tenantAppService
451
- .createTenant(this.createTenantPayload)
452
- .pipe(takeUntil(this.destroy$))
453
- .subscribe({
454
- next: (response: CreateTenantResponse) => {
455
- if (response.status) {
456
- this.tenantAppService.setNewTenantInfo(
457
- this.createTenantPayload?.payload
458
- );
459
- this.submitFormResponse.emit(response);
460
- }
461
- },
462
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
463
- error: (error: any) => {
464
- this.sharedService.handleErrors(
465
- error,
466
- this.createTenantTexts?.errors
467
- );
468
- },
469
- });
470
- }
471
- /**
472
- * Updates the modified tenant information on form submission.
473
- * @memberof CreateTenantApplicationComponent
474
- */
475
- editTenant(): void {
476
- this.tenantAppService
477
- .editTenant(this.createTenantPayload)
478
- .pipe(takeUntil(this.destroy$))
479
- .subscribe({
480
- next: (response: CreateTenantResponse) => {
481
- if (response?.status) {
482
- this.updatedTenantBasicInfo = this.createTenantPayload?.payload;
483
- this.updatedTenantBasicInfo.features =
484
- this.tenantAppService.getFeaturesList(this.featuresOptions);
485
- this.tenantAppService.setSelectedTenantInformation(
486
- this.updatedTenantBasicInfo as TenantBasicInfo
487
- );
488
- this.submitFormResponse.emit(response);
489
- }
490
- },
491
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
492
- error: (error: any) => {
493
- this.sharedService.handleErrors(
494
- error,
495
- this.createTenantTexts?.errors
496
- );
497
- },
498
- });
499
- }
500
- /**
501
- * Constructs create tenant payload from the form data and returns.
502
- * @param {*} formData
503
- * @return {CreateTenantRequestPayload}
504
- * @memberof CreateTenantApplicationComponent
505
- */
506
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
507
- getCreateTenantPayload(formData: any): CreateTenantRequestPayload {
508
- const payload: CreateTenantRequestPayload = {
509
- payload: {
510
- appTitle: formData?.appTitle,
511
- appId: formData?.appId,
512
- appHeading: formData?.appHeading,
513
- appDescription: formData?.appDescription,
514
- backgroundColor: formData?.backgroundColor,
515
- appLogo: formData?.appLogo,
516
- appDomainUrl: formData?.appDomainUrl,
517
- appHelpLink: formData?.appHelpLink,
518
- appType: this.selectedAppTypeOption?.id as string,
519
- features: this.tenantAppService.getFeatureIds(this.featuresOptions),
520
- },
521
- };
522
- return payload;
523
- }
524
-
525
- /**
526
- * Gets create tenant form group reference and disables default features.
527
- * @param {FormGroup[]} form
528
- * @memberof CreateTenantApplicationComponent
529
- */
530
- getCreateTenantFormGroupRef(form: FormGroup[]): void {
531
- this.createTenantFormGroupRef = form[0];
532
- const featuresFormArray = this.createTenantFormGroupRef?.controls[
533
- 'features'
534
- ] as FormArray;
535
- this.featuresOptions?.forEach((option: CheckboxOption, index: number) => {
536
- if (option?.disabled) {
537
- featuresFormArray?.at(index).disable();
538
- }
539
- });
540
- }
541
- /**
542
- * Updates createTenantFormGroupRef on add or edit tenant form change event.
543
- * @param {FormGroup[]} form
544
- * @memberof CreateTenantApplicationComponent
545
- */
546
- onCreateTenantFormChange(form: FormGroup[]): void {
547
- this.createTenantFormGroupRef = form[0];
548
- this.isAppLogoModified =
549
- this.createTenantFormGroupRef?.controls['appLogo']?.dirty &&
550
- this.tenantFunctionType === TenantFunctionType.EDIT;
551
- }
552
- /**
553
- * Emits form cancel event.
554
- * @memberof CreateTenantApplicationComponent
555
- */
556
- onFormCancel(): void {
557
- this.formCancel.emit();
558
- }
559
-
560
- /**
561
- * Gets the selected file when the file is browsed and on formFileUpload event is triggered.
562
- * @param {File | FileList} file
563
- */
564
- onFormFileUpload(file: File | FileList): void {
565
- this.file = file;
566
- }
567
- /**
568
- * Gets pre-signed URL to upload the selected file to AWS S3 bucket.
569
- * @param {File | FileList} file
570
- */
571
- getFileUploadPresignedUrl(file: File | FileList, appId: string): void {
572
- this.fileUploadService
573
- .getFileUploadPresignedUrl(file, appId)
574
- .pipe(takeUntil(this.destroy$))
575
- .subscribe({
576
- next: (response: FileUploadPresignedUrl) => {
577
- this.fileUploadPresignedUrl = response?.body;
578
- if (this.fileUploadPresignedUrl) this.uploadFileToS3(file);
579
- },
580
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function, no-empty-function
581
- error: (error: any) => {
582
- this.sharedService.handleErrors(
583
- error,
584
- this.createTenantTexts?.errors
585
- );
586
- },
587
- });
588
- }
589
- /**
590
- * Uploads the file to AWS S3 bucket and submit the form data to API to create new tenant.
591
- * @param {File | FileList} file
592
- */
593
- uploadFileToS3(file: File | FileList): void {
594
- this.fileUploadService
595
- .uploadFileToS3(this.fileUploadPresignedUrl, file)
596
- .pipe(takeUntil(this.destroy$))
597
- .subscribe({
598
- // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
599
- next: (response: any) => {
600
- this.fileUploadService.setFileUploadStatus(true);
601
- // eslint-disable-next-line no-unused-expressions
602
- this.tenantFunctionType === TenantFunctionType.EDIT
603
- ? this.editTenant()
604
- : this.createTenant();
605
- },
606
- // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
607
- error: (error: any) => {
608
- this.fileUploadService.setFileUploadStatus(false);
609
- this.sharedService.handleErrors(
610
- error,
611
- this.createTenantTexts?.errors
612
- );
613
- },
614
- });
615
- }
616
- /**
617
- * Triggers when the color picker values has been changed.
618
- * @param {string} color
619
- */
620
- onColorPickerChange(color: string): void {
621
- this.selectedColor = color;
622
- }
623
- /**
624
- * Triggers when the radio option has been changed.
625
- * @param {RadioOption} radioOption
626
- */
627
- onRadioOptionSelected(radioOption: RadioOption): void {
628
- this.selectedAppTypeOption = radioOption;
629
- }
630
- /**
631
- * Implementation of ngOnDestroy lifecycle hook method to unsubscribe the open observable subscriptions.
632
- * @memberof CreateTenantApplicationComponent
633
- */
634
- ngOnDestroy(): void {
635
- this.destroy$.next(true);
636
- this.destroy$.unsubscribe();
637
- }
638
- }
@@ -1,22 +0,0 @@
1
- <ieeesa-dynamic-form
2
- [formGroups]="formGroup"
3
- [colWidth]="colWidth"
4
- [isSubmitButtonDisabled]="true"
5
- [isLegendVisible]="true"
6
- [leftButtonLabel]="leftButtonLabel"
7
- [rightButtonLabel]="rightButtonLabel"
8
- [isLeftButtonNeeded]="true"
9
- [actionButtonAlign]="actionButtonAlign"
10
- (dropdownChange)="onRoleOrPermissionSelected($event)"
11
- (formSubmit)="onMapAndPermissionsFormSubmit()"
12
- (formLeftButtonClicked)="onMapAndPermissionsFormCancel()"
13
- >
14
- <ieeesa-data-table
15
- component
16
- *ngIf="tableData.length"
17
- [columnSchemaInfo]="tableColumnSchema"
18
- [tableColumnsHeaderText]="tableHeading"
19
- [tableDataInfo]="tableData"
20
- (rowSlideToggle)="roleOrPermissionStatusChange($event)"
21
- ></ieeesa-data-table>
22
- </ieeesa-dynamic-form>