penyesuaian scheduler
This commit is contained in:
		
							parent
							
								
									ca5f0c8c0c
								
							
						
					
					
						commit
						45e280c007
					
				@ -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
 | 
			
		||||
 | 
			
		||||
@ -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 = {
 | 
			
		||||
 | 
			
		||||
@ -55,7 +55,7 @@
 | 
			
		||||
                                    background-color: transparent !important;
 | 
			
		||||
                                    border-color: #37a647 !important;
 | 
			
		||||
                                  "
 | 
			
		||||
                                  (click)="openEditModal(schedule)"
 | 
			
		||||
                                  (click)="editSchedule(schedule)"
 | 
			
		||||
                                >
 | 
			
		||||
                                  <i
 | 
			
		||||
                                    class="ficon la la-edit"
 | 
			
		||||
 | 
			
		||||
@ -93,6 +93,32 @@ export class SchedulerListComponent {
 | 
			
		||||
    // Handle edit action
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  editSchedule(data) {
 | 
			
		||||
    console.log(data);
 | 
			
		||||
    const modalRef = this.modalService.open(ControlSchedulerComponent, {
 | 
			
		||||
      size: "md",
 | 
			
		||||
      backdrop: "static",
 | 
			
		||||
      keyboard: false,
 | 
			
		||||
      centered: true,
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    modalRef.componentInstance.deviceId = this.deviceId;
 | 
			
		||||
    modalRef.componentInstance.data = data;
 | 
			
		||||
    modalRef.componentInstance.mode = "add";
 | 
			
		||||
    modalRef.result.then(
 | 
			
		||||
      (result) => {
 | 
			
		||||
        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) => {
 | 
			
		||||
 | 
			
		||||
@ -136,6 +136,16 @@ export class DeviceService {
 | 
			
		||||
    return this.http.post<any>(url, data, { headers });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  putDeviceScheduler(data, id): Observable<any> {
 | 
			
		||||
    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<any>(url, data, { headers });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  deleteDeviceScheduler(id): Observable<any> {
 | 
			
		||||
    const endpoint = `/device-scheduler/${id}`;
 | 
			
		||||
    const url = `${BASE_URL}${endpoint}`;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user