update validator user profil
This commit is contained in:
parent
daef6aafdc
commit
978127f2c4
|
@ -13,7 +13,7 @@
|
||||||
href="https://allbestsistem.com/"
|
href="https://allbestsistem.com/"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
style="background-color: #000000 !important;"
|
style="background-color: #000000 !important;"
|
||||||
>Smart Building Management Systems (V@2024-07-4.02)
|
>Smart Building Management Systems (V@2024-07-8.01)
|
||||||
</a></span
|
</a></span
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -20,4 +20,16 @@ img {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
color: #000000 !important;
|
||||||
|
background-color: #c3f164 !important;
|
||||||
|
border-radius: 10px;
|
||||||
|
width: 145px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:disabled {
|
||||||
|
background-color: gray !important;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { Component, ViewChild } from "@angular/core";
|
||||||
import { FormBuilder, FormGroup, NgForm, Validators } from "@angular/forms";
|
import { FormBuilder, FormGroup, NgForm, Validators } from "@angular/forms";
|
||||||
import { LoginService } from "../../service/login.service";
|
import { LoginService } from "../../service/login.service";
|
||||||
import { ToastrService } from "ngx-toastr";
|
import { ToastrService } from "ngx-toastr";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-profil-information",
|
selector: "app-profil-information",
|
||||||
templateUrl: "./profil-information.component.html",
|
templateUrl: "./profil-information.component.html",
|
||||||
|
@ -14,7 +15,7 @@ export class ProfilInformationComponent {
|
||||||
activeTab: string = "profile-info2";
|
activeTab: string = "profile-info2";
|
||||||
submitted = false;
|
submitted = false;
|
||||||
storedData: any;
|
storedData: any;
|
||||||
disableButton: boolean = false
|
disableButton: boolean = false;
|
||||||
|
|
||||||
url: any = 'https://www.w3schools.com/howto/img_avatar.png';
|
url: any = 'https://www.w3schools.com/howto/img_avatar.png';
|
||||||
fileSelected: any = null;
|
fileSelected: any = null;
|
||||||
|
@ -22,7 +23,7 @@ export class ProfilInformationComponent {
|
||||||
constructor(
|
constructor(
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
private authService: LoginService,
|
private authService: LoginService,
|
||||||
private toastr: ToastrService,
|
private toastr: ToastrService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
@ -30,14 +31,17 @@ export class ProfilInformationComponent {
|
||||||
this.profilInfo = this.formBuilder.group({
|
this.profilInfo = this.formBuilder.group({
|
||||||
firstName: ["", Validators.required],
|
firstName: ["", Validators.required],
|
||||||
lastName: ["", Validators.required],
|
lastName: ["", Validators.required],
|
||||||
email: ["", Validators.required],
|
email: ["", [Validators.required, Validators.email]],
|
||||||
phone: ["", Validators.required],
|
phone: ["", [Validators.required, Validators.pattern(/^[0-9]{10,15}$/)]],
|
||||||
image: [null]
|
image: [null]
|
||||||
});
|
});
|
||||||
this.dataProfil(this.storedData.sub)
|
this.dataProfil(this.storedData.sub);
|
||||||
|
this.profilInfo.valueChanges.subscribe(() => {
|
||||||
|
this.disableButton = !this.profilInfo.valid;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
dataProfil(userId){
|
dataProfil(userId) {
|
||||||
this.authService.getDataProfil(userId).subscribe(data => {
|
this.authService.getDataProfil(userId).subscribe(data => {
|
||||||
this.profilInfo.patchValue({
|
this.profilInfo.patchValue({
|
||||||
firstName: data.data.firstname,
|
firstName: data.data.firstname,
|
||||||
|
@ -47,7 +51,7 @@ export class ProfilInformationComponent {
|
||||||
image: [null]
|
image: [null]
|
||||||
});
|
});
|
||||||
if (data.data.image_path !== "https://kapi.absys.ninja/hemat/image/null") {
|
if (data.data.image_path !== "https://kapi.absys.ninja/hemat/image/null") {
|
||||||
this.url = data.data.image_path
|
this.url = data.data.image_path;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -79,9 +83,9 @@ export class ProfilInformationComponent {
|
||||||
public deleteImage() {
|
public deleteImage() {
|
||||||
this.url = null;
|
this.url = null;
|
||||||
if (this.url === null) {
|
if (this.url === null) {
|
||||||
this.disableButton = true
|
this.disableButton = true;
|
||||||
} else{
|
} else {
|
||||||
this.disableButton = false
|
this.disableButton = false;
|
||||||
}
|
}
|
||||||
this.profilInfo.patchValue({ image: null });
|
this.profilInfo.patchValue({ image: null });
|
||||||
}
|
}
|
||||||
|
@ -97,9 +101,12 @@ export class ProfilInformationComponent {
|
||||||
onProjectInfoSubmit() {
|
onProjectInfoSubmit() {
|
||||||
this.submitted = true;
|
this.submitted = true;
|
||||||
if (this.profilInfo.invalid) {
|
if (this.profilInfo.invalid) {
|
||||||
|
this.disableButton = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.disableButton = false;
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("firstname", this.profilInfo.get("firstName").value);
|
formData.append("firstname", this.profilInfo.get("firstName").value);
|
||||||
formData.append("lastname", this.profilInfo.get("lastName").value);
|
formData.append("lastname", this.profilInfo.get("lastName").value);
|
||||||
|
@ -108,7 +115,7 @@ export class ProfilInformationComponent {
|
||||||
formData.append("statusId", "2");
|
formData.append("statusId", "2");
|
||||||
formData.append("buildingId", "4");
|
formData.append("buildingId", "4");
|
||||||
formData.append("image", this.fileSelected);
|
formData.append("image", this.fileSelected);
|
||||||
|
|
||||||
this.authService.updateProfile(formData, this.storedData.sub).subscribe(
|
this.authService.updateProfile(formData, this.storedData.sub).subscribe(
|
||||||
(response) => {
|
(response) => {
|
||||||
console.log("Profile updated successfully:", response);
|
console.log("Profile updated successfully:", response);
|
||||||
|
@ -131,6 +138,6 @@ export class ProfilInformationComponent {
|
||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
this.dataProfil(this.storedData.sub);
|
this.dataProfil(this.storedData.sub);
|
||||||
this.disableButton = false
|
this.disableButton = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@
|
||||||
<p
|
<p
|
||||||
class="card-subtitle line-on-side text-muted text-center font-small-3 mx-2 my-1"
|
class="card-subtitle line-on-side text-muted text-center font-small-3 mx-2 my-1"
|
||||||
>
|
>
|
||||||
<span>(v@2024.07.4.02)</span>
|
<span>(v@2024.07.8.01)</span>
|
||||||
</p>
|
</p>
|
||||||
<!-- <div class="card-body">
|
<!-- <div class="card-body">
|
||||||
<a
|
<a
|
||||||
|
|
Loading…
Reference in New Issue