From fc9947da156668b4b5e63eedfbcc36e2e269aa46 Mon Sep 17 00:00:00 2001 From: Fuzi_fauzia Date: Tue, 25 Jun 2024 18:06:20 +0700 Subject: [PATCH] penambahan button cancel device control --- .../device-control.component.html | 16 +++++++- .../device-control.component.ts | 37 ++++++++++++++----- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/app/content/hemat-app/device/device-control/device-control.component.html b/src/app/content/hemat-app/device/device-control/device-control.component.html index db7aebd..ec44513 100644 --- a/src/app/content/hemat-app/device/device-control/device-control.component.html +++ b/src/app/content/hemat-app/device/device-control/device-control.component.html @@ -61,7 +61,8 @@ (click)="doFilter()" style=" background-color: #252525 !important; - border-color: #bef264 !important; + border-color: #ffffff !important; + border-radius: 12px; " [disabled]="spinnerFilterActive" > @@ -76,6 +77,19 @@ *ngIf="spinnerFilterActive" > + diff --git a/src/app/content/hemat-app/device/device-control/device-control.component.ts b/src/app/content/hemat-app/device/device-control/device-control.component.ts index 51b39f6..b29e7b9 100644 --- a/src/app/content/hemat-app/device/device-control/device-control.component.ts +++ b/src/app/content/hemat-app/device/device-control/device-control.component.ts @@ -2,6 +2,7 @@ import { Component } from "@angular/core"; import { Router } from "@angular/router"; import { BuildingService } from "../../service/monitoring-api.service"; import { DeviceService } from "../../service/device.service"; +import { ToastrService } from "ngx-toastr"; @Component({ selector: "app-device-control", @@ -42,7 +43,8 @@ export class DeviceControlComponent { constructor( private router: Router, private deviceService: DeviceService, - private monitoringApiService: BuildingService + private monitoringApiService: BuildingService, + private toastr: ToastrService ) {} ngOnInit() { @@ -103,15 +105,30 @@ export class DeviceControlComponent { } doFilter() { - this.spinnerFilterActive = true; - this.fetchData( - this.buildingSelected, - this.categorySelected, - this.statusSelected - ); - setTimeout(() => { - this.spinnerFilterActive = false; - }, 3000); + if (!this.buildingSelected) { + this.toastr.error("Warning", "Filter Building tidak boleh kosong.", { + timeOut: 5000, + closeButton: true, + }); + } else { + this.spinnerFilterActive = true; + this.fetchData( + this.buildingSelected, + this.categorySelected, + this.statusSelected + ); + setTimeout(() => { + this.spinnerFilterActive = false; + }, 3000); + } + } + + doCancelFilter() { + this.storedData = JSON.parse(localStorage.getItem("currentUser")); + this.buildingSelected = this.storedData.buildingId; + this.categorySelected = undefined; + this.statusSelected = undefined; + this.fetchData(this.buildingSelected, 0, 0); } filterRows() {