validasi device

This commit is contained in:
Fuzi_fauzia 2024-08-21 10:20:59 +07:00
parent f81dc7bf66
commit 04972e33b1
4 changed files with 67 additions and 49 deletions

View File

@ -13,7 +13,7 @@
href="https://allbestsistem.com/"
target="_blank"
style="background-color: #ffffff !important;"
>Smart Building Management Systems (V@2024-08-20.2)
>Smart Building Management Systems (V@2024-08-21.2)
</a></span
>
</p>

View File

@ -69,7 +69,7 @@
<div class="input-group">
<select
id="categoryId"
class="form-control"
class="form-control custom-select"
formControlName="categoryId"
[ngClass]="{
'is-invalid': submitted && f.categoryId.errors
@ -83,15 +83,17 @@
</option>
</select>
</div>
<small
class="form-text text-muted danger"
*ngIf="submitted && f.categoryId.errors"
class="invalid-feedback"
<div
*ngIf="
projectInfo.get('categoryId').invalid &&
projectInfo.get('categoryId').touched
"
class="text-danger"
>
<div *ngIf="f.categoryId.errors.required">
Category is required
</div>
</small>
<small class="text-danger"
>Category is required.</small
>
</div>
</div>
</div>
<div class="col-md-6">
@ -116,15 +118,17 @@
</option>
</select>
</div>
<small
class="form-text text-muted danger"
*ngIf="submitted && f.voltageId.errors"
class="invalid-feedback"
<div
*ngIf="
projectInfo.get('voltageId').invalid &&
projectInfo.get('voltageId').touched
"
class="text-danger"
>
<div *ngIf="f.voltageId.errors.required">
Voltage is required
</div>
</small>
<small class="text-danger"
>Voltage is required.</small
>
</div>
</div>
</div>
<div class="col-md-6">
@ -270,12 +274,12 @@
class="btn btn-primary"
style="
color: #ffffff !important;
background-color: #37A647 !important;
background-color: #37a647 !important;
"
(click)="saveEdit()"
*ngIf="mode === 'edit'"
>
<i class="la la-check"></i> Save
<i class="la la-check"></i> Save
</button>
</div>
</form>

View File

@ -253,36 +253,50 @@ export class AddEditDeviceComponent implements OnInit {
}
saveEdit() {
if (this.projectInfo.get("roomBuildingId").value) {
this.monitoringApiService
.putDevice(this.projectInfo.value, this.deviceId)
.subscribe((data) => {
this.router.navigate(["/device"]);
});
} else {
Swal.fire({
title: "Apakah kamu yakin?",
text: "Data lokasi device tidak dapat diubah!",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Yes, save it!",
}).then((result) => {
if (result.isConfirmed) {
this.monitoringApiService
.putDevice(this.projectInfo.value, this.deviceId)
.subscribe((data) => {
this.router.navigate(["/device"]);
});
Swal.fire({
title: "Saved!",
text: "Data berhasil disimpan.",
icon: "success",
if (this.projectInfo.valid) {
if (this.projectInfo.get("roomBuildingId").value) {
this.monitoringApiService
.putDevice(this.projectInfo.value, this.deviceId)
.subscribe((data) => {
this.router.navigate(["/device"]);
});
}
});
} else {
Swal.fire({
title: "Apakah kamu yakin?",
text: "Data lokasi device tidak dapat diubah!",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Yes, save it!",
}).then((result) => {
if (result.isConfirmed) {
this.monitoringApiService
.putDevice(this.projectInfo.value, this.deviceId)
.subscribe((data) => {
this.router.navigate(["/device"]);
});
Swal.fire({
title: "Saved!",
text: "Data berhasil disimpan.",
icon: "success",
});
}
});
}
} else {
this.markFormGroupTouched(this.projectInfo)
}
}
markFormGroupTouched(formGroup: FormGroup) {
(Object as any).values(formGroup.controls).forEach((control) => {
control.markAsTouched();
if (control.controls) {
this.markFormGroupTouched(control);
}
});
}
cancel() {

View File

@ -138,7 +138,7 @@
<p
class="card-subtitle line-on-side text-muted text-center font-small-3 mx-2 my-1"
>
<span>(v@2024.08.20.2)</span>
<span>(v@2024.08.21.2)</span>
</p>
<!-- <div class="card-body">
<a