diff --git a/src/app/content/hemat-app/device/add-edit-device/add-edit-device.component.ts b/src/app/content/hemat-app/device/add-edit-device/add-edit-device.component.ts index bfa2996..5ea7750 100644 --- a/src/app/content/hemat-app/device/add-edit-device/add-edit-device.component.ts +++ b/src/app/content/hemat-app/device/add-edit-device/add-edit-device.component.ts @@ -271,6 +271,7 @@ export class AddEditDeviceComponent implements OnInit { confirmButtonColor: "#37a647", cancelButtonColor: "#d33", confirmButtonText: "Yes, save it!", + allowOutsideClick: false, }).then((result) => { if (result.isConfirmed) { this.monitoringApiService diff --git a/src/app/content/hemat-app/device/control-scheduler/control-scheduler.component.ts b/src/app/content/hemat-app/device/control-scheduler/control-scheduler.component.ts index 373b37a..b01e434 100644 --- a/src/app/content/hemat-app/device/control-scheduler/control-scheduler.component.ts +++ b/src/app/content/hemat-app/device/control-scheduler/control-scheduler.component.ts @@ -94,7 +94,7 @@ export class ControlSchedulerComponent { // Collect selected days' labels const selectedDays = this.daysOfWeek .filter((day) => formValues[day.value]) - .map((day) => day.label); + .map((day) => day.value); // Construct the final output const result = { diff --git a/src/app/content/hemat-app/device/scheduler-list/scheduler-list.component.html b/src/app/content/hemat-app/device/scheduler-list/scheduler-list.component.html index d9d90bc..ea16e0e 100644 --- a/src/app/content/hemat-app/device/scheduler-list/scheduler-list.component.html +++ b/src/app/content/hemat-app/device/scheduler-list/scheduler-list.component.html @@ -55,7 +55,7 @@ background-color: transparent !important; border-color: #37a647 !important; " - (click)="openEditModal(schedule)" + (click)="editSchedule(schedule)" > { + if (result) { + this.deviceService.putDeviceScheduler(result, data.id).subscribe((res) => { + this.dataListScheduler(this.deviceId); + }); + } + }, + (reason) => { + console.log(`Dismissed: ${reason}`); + } + ); + } + deleteSchedule(id) { Swal.fire({ title: "Apakah kamu yakin ingin menghapus jadwal ini?", @@ -103,6 +129,7 @@ export class SchedulerListComponent { cancelButtonColor: "#d33", confirmButtonText: "Ya, hapus!", cancelButtonText: "Batal", + allowOutsideClick: false, }).then((result) => { if (result.isConfirmed) { this.deviceService.deleteDeviceScheduler(id).subscribe((data) => { diff --git a/src/app/content/hemat-app/service/device.service.ts b/src/app/content/hemat-app/service/device.service.ts index e15c24c..6f94925 100644 --- a/src/app/content/hemat-app/service/device.service.ts +++ b/src/app/content/hemat-app/service/device.service.ts @@ -136,6 +136,16 @@ export class DeviceService { return this.http.post(url, data, { headers }); } + putDeviceScheduler(data, id): Observable { + const endpoint = `/device-scheduler/${id}`; + const url = `${BASE_URL}${endpoint}`; + const headers = new HttpHeaders({ + "Content-Type": "application/json", + "x-api-key": "j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT", + }); + return this.http.put(url, data, { headers }); + } + deleteDeviceScheduler(id): Observable { const endpoint = `/device-scheduler/${id}`; const url = `${BASE_URL}${endpoint}`;