Skip to content

Commit f234545

Browse files
authored
Merge pull request #106 from Sohith-code/cbrelease-4.8.20-custom-registration-sohith
Added api to upload logo and designation changes
2 parents f3e5eea + 51d69ed commit f234545

File tree

13 files changed

+114
-69
lines changed

13 files changed

+114
-69
lines changed

project/ws/app/src/lib/head/ui-admin-table/create-organisation/create-organisation.component.ts

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ import * as _ from 'lodash'
55
import { CreateMDOService } from '../../../routes/home/services/create-mdo.services'
66
import { ActivatedRoute } from '@angular/router'
77
import { LoaderService } from '../../../routes/home/services/loader.service'
8+
import { IUploadedLogoresponse } from '../interface/interfaces'
89
@Component({
910
selector: 'ws-app-create-organisation',
1011
templateUrl: './create-organisation.component.html',
1112
styleUrls: ['./create-organisation.component.scss']
1213
})
1314
export class CreateOrganisationComponent implements OnInit, OnDestroy {
1415

15-
//#region (global variables)
16-
17-
//#region (input and output)
1816
@Input() rowData: any
1917
@Input() dropdownList: {
2018
statesList: any[],
@@ -26,7 +24,6 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
2624
@Input() openMode: string = ''
2725
@Output() buttonClick = new EventEmitter()
2826
@Output() organizationCreated = new EventEmitter<any>()
29-
//#endregion
3027

3128
organisationForm!: FormGroup
3229
statesList: any = []
@@ -40,6 +37,8 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
4037
filteredStates: any[] = []
4138
filteredMinistry: any[] = []
4239
heirarchyObject: any
40+
selectedLogoFile: any
41+
uploadedLogoResponse!: IUploadedLogoresponse
4342
constructor(
4443
private formBuilder: FormBuilder,
4544
private snackBar: MatSnackBar,
@@ -51,7 +50,6 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
5150
this.addOverflowHidden()
5251
}
5352

54-
//#region (ng onint)
5553
ngOnInit(): void {
5654
this.loggedInUserId = _.get(this.activatedRoute, 'snapshot.parent.data.configService.userProfile.userId')
5755
this.initialization()
@@ -128,9 +126,6 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
128126
})
129127
}
130128
}
131-
//#endregion
132-
133-
//#region (UI interaction lick click)
134129

135130
get getCategory() {
136131
return this.organisationForm.controls.category.value
@@ -153,7 +148,7 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
153148
isTenant: true,
154149
requestedBy: this.loggedInUserId,
155150

156-
logo: this.selectedLogo,
151+
logo: this.uploadedLogoResponse?.qrcodepath || "",
157152
description: this.controls['description'].value,
158153
parentMapId: this.heirarchyObject?.parentMapId || "",
159154
sbRootOrgId: this.heirarchyObject?.sbRootOrgId || "",
@@ -173,7 +168,7 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
173168
next: (response: any) => {
174169
if (response.result) {
175170
this.organizationCreated.emit(payload)
176-
this.snackBar.open('Organization successfully created.', 'Close', { panelClass: ['success'] })
171+
this.snackBar.open('Organization successfully created.', 'X', { panelClass: ['success'] })
177172
this.closeNaveBar()
178173
this.loaderService.changeLoad.next(false)
179174
this.isLoading = false
@@ -194,15 +189,15 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
194189
// organisationSubType: this.heirarchyObject.sbOrgSubType,
195190
organisationSubType: "board",
196191
orgId: this.rowData.id,
197-
logo: request.logo,
192+
logo: this.uploadedLogoResponse?.qrcodepath || this.rowData.logo,
198193
description: request.description
199194
}
200195

201196
this.createMDOService.updateOrganization(payload).subscribe({
202197
next: (response: any) => {
203198
if (response.result) {
204199
this.organizationCreated.emit(payload)
205-
this.snackBar.open('Organization successfully updated.', 'Close', { panelClass: ['success'] })
200+
this.snackBar.open('Organization successfully updated.', 'X', { panelClass: ['success'] })
206201
this.closeNaveBar()
207202
this.loaderService.changeLoad.next(false)
208203
this.isLoading = false
@@ -219,28 +214,22 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
219214
uploadLogo(event: Event) {
220215
const input = event.target as HTMLInputElement
221216
if (input.files?.length) {
222-
const selectedFile = input.files[0]
223-
this.selectedLogoName = selectedFile.name
217+
this.selectedLogoFile = input.files[0]
218+
this.selectedLogoName = this.selectedLogoFile.name
224219
const maxFileSize = this.maxFileSize * 1024
225220

226-
if (!this.validFileTypes.includes(selectedFile.type)) {
227-
this.snackBar.open('Invalid file type', 'Close', { panelClass: ['error'] })
221+
if (!this.validFileTypes.includes(this.selectedLogoFile.type)) {
222+
this.snackBar.open('Invalid file type', 'X', { panelClass: ['error'] })
228223
return
229224
}
230225

231-
if (selectedFile.size > maxFileSize) {
232-
this.snackBar.open(`File size exceeds ${this.maxFileSize} KB. Please select a smaller file.`, 'Close', { panelClass: ['error'] })
226+
if (this.selectedLogoFile.size > maxFileSize) {
227+
this.snackBar.open(`File size exceeds ${this.maxFileSize} KB. Please select a smaller file.`, 'X', { panelClass: ['error'] })
233228
return
234229
}
235-
236-
const reader = new FileReader()
237-
reader.onload = () => {
238-
this.selectedLogo = reader.result
239-
}
240-
reader.readAsDataURL(selectedFile)
230+
this.uploadOrganizationLogo()
241231
}
242232
}
243-
//#endregion
244233

245234
addOverflowHidden() {
246235
document.body.classList.add('overflow-hidden')
@@ -268,4 +257,19 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
268257

269258
}
270259

260+
uploadOrganizationLogo() {
261+
const formData = new FormData()
262+
formData.append('file', this.selectedLogoFile)
263+
this.createMDOService.uploadOrganizationLogo(formData).subscribe({
264+
next: (response: any) => {
265+
if (response.result) {
266+
this.uploadedLogoResponse = response.result
267+
this.selectedLogo = this.uploadedLogoResponse.qrcodepath
268+
}
269+
},
270+
error: () => {
271+
this.snackBar.open(`Couldn't upload the logo, Please try again`, 'X', { panelClass: ['error'] })
272+
}
273+
})
274+
}
271275
}

project/ws/app/src/lib/head/ui-admin-table/custom-self-registration/custom-self-registration.component.html

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<mat-icon class="closeIcon" (click)="closeNaveBar()">close</mat-icon>
88
</div>
99

10-
<div class="px-5 pt-6 mb-24">
10+
<div class="px-5 pt-6 mb-24 relative">
1111
<ng-container>
1212
<form [formGroup]="selfRegistrationForm">
1313
<!-- <div class="flex items-center justify-between ">
@@ -36,7 +36,7 @@
3636
</div> -->
3737

3838
<ng-container *ngIf="!initialData.QRGenerated">
39-
<div class="flex justify-center items-center flex-column gap-6">
39+
<div class="flex justify-center items-center flex-column gap-6 center-position">
4040
<!-- <button mat-flat-button class="mat-btn-flat" [disabled]="selfRegistrationForm.invalid || isLoading"
4141
(click)="generateQRCodeLink()">Generate</button> -->
4242

@@ -47,15 +47,15 @@
4747
</ng-container>
4848

4949
<ng-container *ngIf="initialData.QRGenerated">
50-
<div class="flex justify-center items-center mb-4">
50+
<!-- <div class="flex justify-center items-center mb-4">
5151
<button mat-stroked-button class="mat-btn-outline"
5252
[disabled]="selfRegistrationForm.invalid || isLoading" (click)="generateQRCodeLink()">Publish New
5353
Link </button>
54-
</div>
55-
54+
</div> -->
55+
<!--
5656
<p class="text-xs note-text">Note: Publishing a new URL will automatically expire the old one. Please
5757
use the new URL for custom
58-
user registrations.</p>
58+
user registrations.</p> -->
5959

6060
<div class="wrapper-card p-4 rounded-lg">
6161
<div class="flex justify-between">
@@ -65,9 +65,8 @@
6565
[href]="customRegistrationLinks.registrationLink"
6666
target="_blank">{{customRegistrationLinks.registrationLink}}</a>
6767
</div>
68-
<div class="badge"
69-
[ngClass]="checkRegistrationStatus(this.initialData.endDateRegistration) ? 'active':'in-active'">
70-
{{checkRegistrationStatus(this.initialData.endDateRegistration) ?
68+
<div class="badge " [ngClass]="checkRegistrationStatus() ? 'active':'in-active'">
69+
{{checkRegistrationStatus() ?
7170
'Active': 'None'}}</div>
7271
</div>
7372

@@ -137,17 +136,11 @@
137136
</ng-container>
138137
</div>
139138

140-
<div class="right-sidenav-footer flex items-center justify-end gap-4 items-center px-5 pt-3 pb-5 bg-white">
141-
<!-- <ng-container *ngIf="!initialData.QRGenerated">
142-
<button mat-flat-button class="mat-btn-outline" (click)="closeNaveBar()">Cancel</button>
143-
<button mat-flat-button class="mat-btn-flat" [disabled]="!initialData?.QRGenerated">{{initialData?.openMode
144-
=== 'edit' ? 'Update' : 'Add'}}</button>
145-
</ng-container> -->
146-
<ng-container *ngIf="initialData.QRGenerated">
139+
<ng-container *ngIf="initialData.QRGenerated">
140+
<div class="right-sidenav-footer flex items-center justify-end gap-4 items-center px-5 pt-3 pb-5 bg-white">
147141
<button mat-flat-button class="mat-btn-flat" (click)="closeNaveBar()">Close</button>
148-
</ng-container>
149-
150-
</div>
142+
</div>
143+
</ng-container>
151144
</div>
152145
</div>
153146
</mat-sidenav-content>

project/ws/app/src/lib/head/ui-admin-table/custom-self-registration/custom-self-registration.component.scss

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
color: #1d8923;
9898
background: #1d892329;
9999
}
100+
100101
&.in-active {
101102
color: #00000099;
102103
background: #00000029;
@@ -118,9 +119,11 @@
118119
white-space: normal;
119120
}
120121

121-
// .mat-btn-outline.active-button {
122-
// background: #1b4ca1 !important;
123-
// span {
124-
// color: #fff !important;
125-
// }
126-
// }
122+
.center-position {
123+
position: absolute;
124+
top: 0;
125+
right: 0;
126+
left: 0;
127+
bottom: 0;
128+
129+
}

project/ws/app/src/lib/head/ui-admin-table/custom-self-registration/custom-self-registration.component.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ export class CustomSelfRegistrationComponent implements OnInit, OnDestroy {
6161
}
6262
}
6363

64-
checkRegistrationStatus(endDateRegistration: string): boolean {
65-
if (!endDateRegistration) return true
64+
checkRegistrationStatus(): boolean {
65+
// if (!endDateRegistration) return true
6666

67-
const endDate = new Date(endDateRegistration)
68-
const today = new Date()
69-
return today <= endDate
67+
// const endDate = new Date(endDateRegistration)
68+
// const today = new Date()
69+
// return today <= endDate
70+
return true
7071
}
7172

7273
closeNaveBar() {

project/ws/app/src/lib/head/ui-admin-table/directory-list/directory-table.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<button mat-menu-item (click)="editOrganization(row)">Edit</button>
7272
<button mat-menu-item (click)="goToRoute('users', row)">Users</button>
7373
<button mat-menu-item (click)="goToRoute('rolesandaccess', row)">Roles &
74-
Permissions</button>
74+
Access</button>
7575
<button mat-menu-item (click)="goToRoute('mentormanage', row)">Mentor
7676
Management</button>
7777
<button mat-menu-item (click)="goToRoute('designation_master', row)">Manage

project/ws/app/src/lib/head/ui-admin-table/directory-list/directory-table.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export class UIDirectoryTableComponent implements OnInit, AfterViewInit, OnChang
271271
this.dialogRef.afterClosed().subscribe((result: any) => {
272272
if (result && result.hasOwnProperty('reviewImporting') && !result.reviewImporting) {
273273
this.customSelfRegistration = true
274-
this.selfRegistrationData.title = 'Custom Self Registration_DAE'
274+
this.selfRegistrationData.title = 'Custom Self Registration'
275275
this.selfRegistrationData.QRGenerated = false
276276
this.selfRegistrationData.openMode = 'edit'
277277
this.selfRegistrationData.orgId = row.id

project/ws/app/src/lib/head/ui-admin-table/interface/interfaces.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,10 @@ export interface ITableData {
2929
export interface CustomRegistrationQRCodeResponse {
3030
registrationLink: string,
3131
qrRegistrationLink: string
32+
}
33+
34+
export interface IUploadedLogoresponse {
35+
name: string
36+
url: string
37+
qrcodepath: string
3238
}

project/ws/app/src/lib/routes/create-mdo/routes/designation/components/designations/designations.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,6 @@
9393
</ng-container>
9494

9595
<ng-container *ngIf="isImportDesignation">
96-
<ws-app-import-designation (closeComponent)="removeImportDesignationComp($event)"></ws-app-import-designation>
96+
<ws-app-import-designation (closeComponent)="removeImportDesignationComp($event)"
97+
[loader]="showLoader"></ws-app-import-designation>
9798
</ng-container>

project/ws/app/src/lib/routes/create-mdo/routes/designation/components/designations/designations.component.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class DesignationsComponent implements OnInit {
3131
designationsList: any = []
3232
filteredDesignationsList: any = []
3333
tableData!: ITableData
34-
showLoader = false
34+
showLoader = true
3535
actionMenuItem: {
3636
name: string,
3737
icon: string,
@@ -114,6 +114,9 @@ export class DesignationsComponent implements OnInit {
114114
} else {
115115
this.createFreamwork()
116116
}
117+
if (this.goToImportMaster) {
118+
this.isImportDesignation = true
119+
}
117120

118121
})
119122
// this.getFrameworkInfo('0140788510336040962_odcs')
@@ -152,9 +155,9 @@ export class DesignationsComponent implements OnInit {
152155
this.showCreateLoader = false
153156
this.frameworkDetails = _.get(res, 'result.framework')
154157
this.designationsService.setFrameWorkInfo(this.frameworkDetails)
155-
if (this.goToImportMaster) {
156-
this.isImportDesignation = true
157-
}
158+
// if (this.goToImportMaster) {
159+
// this.isImportDesignation = true
160+
// }
158161
this.getOrganisations()
159162
},
160163
error: () => {

project/ws/app/src/lib/routes/create-mdo/routes/designation/components/import-designation/import-designation.component.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,20 @@
7171
</div>
7272
</div>
7373
</ng-container>
74-
<ng-container *ngIf="igotDesignationsList.length === 0">
74+
<ng-container *ngIf="igotDesignationsList.length === 0 && !loader">
7575
<div class=" w-full flex justify-center items-center">
7676
<div class="my-8 mx-4">
7777
<p>No designations found</p>
7878
</div>
7979
</div>
8080
</ng-container>
81+
<ng-container *ngIf="loader">
82+
<div class=" w-full flex justify-center items-center">
83+
<div class="my-8 mx-4">
84+
<mat-spinner class="display-inline-block mb-5" [diameter]="50" [strokeWidth]="3"></mat-spinner>
85+
</div>
86+
</div>
87+
</ng-container>
8188
</div>
8289
<div class="flex flex-row justify-center">
8390
<mat-paginator [length]="deisgnationsCount" [pageSize]="pageSize" [pageSizeOptions]="[20,30,40]"

0 commit comments

Comments
 (0)