penyesuaian scheduler
This commit is contained in:
		
							parent
							
								
									ca5f0c8c0c
								
							
						
					
					
						commit
						45e280c007
					
				@ -271,6 +271,7 @@ export class AddEditDeviceComponent implements OnInit {
 | 
				
			|||||||
          confirmButtonColor: "#37a647",
 | 
					          confirmButtonColor: "#37a647",
 | 
				
			||||||
          cancelButtonColor: "#d33",
 | 
					          cancelButtonColor: "#d33",
 | 
				
			||||||
          confirmButtonText: "Yes, save it!",
 | 
					          confirmButtonText: "Yes, save it!",
 | 
				
			||||||
 | 
					          allowOutsideClick: false,
 | 
				
			||||||
        }).then((result) => {
 | 
					        }).then((result) => {
 | 
				
			||||||
          if (result.isConfirmed) {
 | 
					          if (result.isConfirmed) {
 | 
				
			||||||
            this.monitoringApiService
 | 
					            this.monitoringApiService
 | 
				
			||||||
 | 
				
			|||||||
@ -94,7 +94,7 @@ export class ControlSchedulerComponent {
 | 
				
			|||||||
    // Collect selected days' labels
 | 
					    // Collect selected days' labels
 | 
				
			||||||
    const selectedDays = this.daysOfWeek
 | 
					    const selectedDays = this.daysOfWeek
 | 
				
			||||||
      .filter((day) => formValues[day.value])
 | 
					      .filter((day) => formValues[day.value])
 | 
				
			||||||
      .map((day) => day.label);
 | 
					      .map((day) => day.value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Construct the final output
 | 
					    // Construct the final output
 | 
				
			||||||
    const result = {
 | 
					    const result = {
 | 
				
			||||||
 | 
				
			|||||||
@ -55,7 +55,7 @@
 | 
				
			|||||||
                                    background-color: transparent !important;
 | 
					                                    background-color: transparent !important;
 | 
				
			||||||
                                    border-color: #37a647 !important;
 | 
					                                    border-color: #37a647 !important;
 | 
				
			||||||
                                  "
 | 
					                                  "
 | 
				
			||||||
                                  (click)="openEditModal(schedule)"
 | 
					                                  (click)="editSchedule(schedule)"
 | 
				
			||||||
                                >
 | 
					                                >
 | 
				
			||||||
                                  <i
 | 
					                                  <i
 | 
				
			||||||
                                    class="ficon la la-edit"
 | 
					                                    class="ficon la la-edit"
 | 
				
			||||||
 | 
				
			|||||||
@ -93,6 +93,32 @@ export class SchedulerListComponent {
 | 
				
			|||||||
    // Handle edit action
 | 
					    // 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) {
 | 
					  deleteSchedule(id) {
 | 
				
			||||||
    Swal.fire({
 | 
					    Swal.fire({
 | 
				
			||||||
      title: "Apakah kamu yakin ingin menghapus jadwal ini?",
 | 
					      title: "Apakah kamu yakin ingin menghapus jadwal ini?",
 | 
				
			||||||
@ -103,6 +129,7 @@ export class SchedulerListComponent {
 | 
				
			|||||||
      cancelButtonColor: "#d33",
 | 
					      cancelButtonColor: "#d33",
 | 
				
			||||||
      confirmButtonText: "Ya, hapus!",
 | 
					      confirmButtonText: "Ya, hapus!",
 | 
				
			||||||
      cancelButtonText: "Batal",
 | 
					      cancelButtonText: "Batal",
 | 
				
			||||||
 | 
					      allowOutsideClick: false,
 | 
				
			||||||
    }).then((result) => {
 | 
					    }).then((result) => {
 | 
				
			||||||
      if (result.isConfirmed) {
 | 
					      if (result.isConfirmed) {
 | 
				
			||||||
        this.deviceService.deleteDeviceScheduler(id).subscribe((data) => {
 | 
					        this.deviceService.deleteDeviceScheduler(id).subscribe((data) => {
 | 
				
			||||||
 | 
				
			|||||||
@ -136,6 +136,16 @@ export class DeviceService {
 | 
				
			|||||||
    return this.http.post<any>(url, data, { headers });
 | 
					    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> {
 | 
					  deleteDeviceScheduler(id): Observable<any> {
 | 
				
			||||||
    const endpoint = `/device-scheduler/${id}`;
 | 
					    const endpoint = `/device-scheduler/${id}`;
 | 
				
			||||||
    const url = `${BASE_URL}${endpoint}`;
 | 
					    const url = `${BASE_URL}${endpoint}`;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user