From 898b45a41161502df9adf1e815adaa81c8ce592e Mon Sep 17 00:00:00 2001 From: "surendar.m@watermelon.us" Date: Mon, 17 Apr 2023 13:13:07 +0530 Subject: [PATCH] business and user image validation --- .../dialog-box/dialog-box.component.scss | 2 +- .../add-business/add-business.component.html | 4 +- .../add-business/add-business.component.ts | 55 +++++++++++-------- .../user/add-user/add-user.component.html | 4 +- .../user/add-user/add-user.component.ts | 10 +++- .../customer-info.component.html | 3 +- ng-seed/src/environments/environment.ts | 2 +- 7 files changed, 47 insertions(+), 33 deletions(-) diff --git a/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.scss b/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.scss index 254055f..e615dde 100644 --- a/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.scss +++ b/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.scss @@ -165,7 +165,7 @@ $tem-color : #217e69; border: 1px solid #e8edef; width: 89%; background-color: #227f6e21; - box-shadow: 0 2px 0 rgb(0 0 0 / 3%) + box-shadow: 0 2px 0 #00000008 } .hoverButton{ background: $white; diff --git a/ng-seed/src/app/appoinment/business/add-business/add-business.component.html b/ng-seed/src/app/appoinment/business/add-business/add-business.component.html index 24b4c91..fcf431f 100644 --- a/ng-seed/src/app/appoinment/business/add-business/add-business.component.html +++ b/ng-seed/src/app/appoinment/business/add-business/add-business.component.html @@ -23,7 +23,7 @@ - + Contact No is required Invalid Contact No Contact No must be at least 10 characters @@ -54,7 +54,7 @@

- Upload Below 2MB + Upload Below 2MB
Supported File (jpg,jpeg anf png)
Add Admin diff --git a/ng-seed/src/app/appoinment/business/add-business/add-business.component.ts b/ng-seed/src/app/appoinment/business/add-business/add-business.component.ts index 9f9ba0c..19cd671 100644 --- a/ng-seed/src/app/appoinment/business/add-business/add-business.component.ts +++ b/ng-seed/src/app/appoinment/business/add-business/add-business.component.ts @@ -51,26 +51,33 @@ export class AddBusinessComponent implements OnInit { onSelectFile(event) { console.log(event) console.log(event.target.files[0]) - if(event.target.files[0].size > 2097152){ - this.notifierService.notify('warning', 'Image size is too Larger'); - }else { - const file = event.target.files[0]; - if(event != null){ - this.imageViewStatus = true - } - this.form['value'].logo = [event.target.files[0]] - if (event.target.files && event.target.files[0]) { - var reader = new FileReader(); - reader.readAsDataURL(event.target.files[0]); - reader.onload = (event) => { - this.url = event.target.result; - console.log(this.url) + let fileType = event.target.files[0] + if(fileType.type == 'image/png' || fileType.type == 'image/jpg' || fileType.type == 'image/jpeg'){ + if(event.target.files[0].size > 2097152){ + this.notifierService.notify('warning', 'Image size is too Larger'); + }else { + const file = event.target.files[0]; + if(event != null){ + this.imageViewStatus = true + } + this.form['value'].logo = [event.target.files[0]] + if (event.target.files && event.target.files[0]) { + var reader = new FileReader(); + reader.readAsDataURL(event.target.files[0]); + reader.onload = (event) => { + this.url = event.target.result; + console.log(this.url) + } } + // this.formData=[]; + this.formData.append('image', file, file.name); + console.log(this.currentFileUpload) } - // this.formData=[]; - this.formData.append('image', file, file.name); - console.log(this.currentFileUpload) - } + } else { + this.notifierService.notify('warning', 'Invalid File)'); + this.notifierService.notify('warning', 'Upload Supported File Like (png,jpg and jpeg)'); + } + // this.formData.append('file', file, file.name); } @@ -83,14 +90,14 @@ export class AddBusinessComponent implements OnInit { admin_checked: new FormControl('',null), logo: new FormControl('', null), - busName: new FormControl('', [Validators.required, Validators.maxLength(20)]), - address: new FormControl('', [Validators.required, Validators.maxLength(50)]), - city: new FormControl('', [Validators.required, Validators.maxLength(10)]), - state: new FormControl('', [Validators.required, Validators.maxLength(10)]), + busName: new FormControl('', [Validators.required]), + address: new FormControl('', [Validators.required, Validators.maxLength(100)]), + city: new FormControl('', [Validators.required]), + state: new FormControl('', [Validators.required]), email: new FormControl('', [Validators.required, Validators.email,Validators.pattern( '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,63}$', ),]), - contactNo: new FormControl('', [Validators.required, Validators.minLength(10),Validators.maxLength(10), Validators.pattern('^[0-9]{10}$')]), + contactNo: new FormControl('', [Validators.required, Validators.minLength(10),Validators.maxLength(10),Validators.pattern('^[0-9]{10}$')]), createdBy:new FormControl(userrole,[Validators.required]), }); @@ -100,7 +107,7 @@ export class AddBusinessComponent implements OnInit { public myError = (controlName: string, errorName: string) =>{ return this.form.controls[controlName].hasError(errorName); } - + submit(){ let tmp = this.form.value tmp.id = this.local_data.id diff --git a/ng-seed/src/app/appoinment/user/add-user/add-user.component.html b/ng-seed/src/app/appoinment/user/add-user/add-user.component.html index 7f115d7..88b6e17 100644 --- a/ng-seed/src/app/appoinment/user/add-user/add-user.component.html +++ b/ng-seed/src/app/appoinment/user/add-user/add-user.component.html @@ -52,7 +52,7 @@ Phone No - + Contact No is required Invalid Contact No Contact No must be at least 10 characters @@ -68,7 +68,7 @@

- Upload Below 2MB + Upload Below 2MB
Supported File (jpg,jpeg anf png)