perbaikan master
This commit is contained in:
@@ -48,7 +48,7 @@ export class AddEditMasterBuildingComponent {
|
||||
owner: ["", Validators.required],
|
||||
address: ["", Validators.required],
|
||||
phone: ["", [Validators.required, Validators.pattern(/^[0-9]{10,15}$/)]],
|
||||
kwh: ["", [Validators.required, Validators.maxLength(15), Validators.pattern(/^[0-9]{10,15}$/)]],
|
||||
kwh: ["", [Validators.required, Validators.maxLength(15), Validators.pattern(/^[0-9]{2,15}$/)]],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ export class AddEditMasterBuildingComponent {
|
||||
address: [this.dataRow.address, Validators.required],
|
||||
phone: [this.dataRow.phone, [Validators.required, Validators.pattern(/^[0-9]{10,15}$/)]],
|
||||
owner: [this.dataRow.owner,Validators.required],
|
||||
kwh: [this.dataRow.kwh, [Validators.required, Validators.maxLength(15), Validators.pattern(/^[0-9]{10,15}$/)]],
|
||||
kwh: [this.dataRow.kwh, [Validators.required, Validators.maxLength(15), Validators.pattern(/^[0-9]{2,15}$/)]],
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { AddEditMasterComponent } from '../add-edit-master/add-edit-master.component';
|
||||
import { TableApiService } from 'src/app/_services/table-api.service';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { Router } from '@angular/router';
|
||||
import { BuildingService } from '../../service/monitoring-api.service';
|
||||
import { AddEditMasterBuildingComponent } from './add-edit-master-building/add-edit-master-building.component';
|
||||
import { LoginService } from '../../service/login.service';
|
||||
import { Component } from "@angular/core";
|
||||
import { AddEditMasterComponent } from "../add-edit-master/add-edit-master.component";
|
||||
import { TableApiService } from "src/app/_services/table-api.service";
|
||||
import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
|
||||
import { Router } from "@angular/router";
|
||||
import { BuildingService } from "../../service/monitoring-api.service";
|
||||
import { AddEditMasterBuildingComponent } from "./add-edit-master-building/add-edit-master-building.component";
|
||||
import { LoginService } from "../../service/login.service";
|
||||
import { ToastrService } from "ngx-toastr";
|
||||
|
||||
@Component({
|
||||
selector: 'app-master-building',
|
||||
templateUrl: './master-building.component.html',
|
||||
styleUrls: ['./master-building.component.css']
|
||||
selector: "app-master-building",
|
||||
templateUrl: "./master-building.component.html",
|
||||
styleUrls: ["./master-building.component.css"],
|
||||
})
|
||||
export class MasterBuildingComponent {
|
||||
data: any;
|
||||
@@ -24,7 +25,8 @@ export class MasterBuildingComponent {
|
||||
private modalService: NgbModal,
|
||||
private router: Router,
|
||||
private monitoringApiService: BuildingService,
|
||||
private authService: LoginService
|
||||
private authService: LoginService,
|
||||
private toastr: ToastrService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -74,20 +76,38 @@ export class MasterBuildingComponent {
|
||||
openAddMasterModal() {
|
||||
const modalRef = this.modalService.open(AddEditMasterBuildingComponent, {
|
||||
size: "lg",
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
backdrop: "static",
|
||||
keyboard: false,
|
||||
});
|
||||
|
||||
modalRef.componentInstance.mode = "add";
|
||||
modalRef.result.then(
|
||||
(result) => {
|
||||
if (result) {
|
||||
this.monitoringApiService
|
||||
.postMasterBuildingParam(result)
|
||||
.subscribe((res) => {
|
||||
this.fetchData();
|
||||
if (
|
||||
this.filteredRows.some(
|
||||
(value) => value.name.toLowerCase() === result.name.toLowerCase()
|
||||
)
|
||||
) {
|
||||
this.toastr.error("Warning", "Data yang anda masukan double.", {
|
||||
timeOut: 5000,
|
||||
closeButton: true,
|
||||
});
|
||||
} else {
|
||||
this.monitoringApiService
|
||||
.postMasterBuildingParam(result)
|
||||
.subscribe((res) => {
|
||||
this.fetchData();
|
||||
});
|
||||
}
|
||||
}
|
||||
// if (result) {
|
||||
// this.monitoringApiService
|
||||
// .postMasterBuildingParam(result)
|
||||
// .subscribe((res) => {
|
||||
// this.fetchData();
|
||||
// });
|
||||
// }
|
||||
},
|
||||
(reason) => {
|
||||
console.log(`Dismissed: ${reason}`);
|
||||
@@ -98,8 +118,8 @@ export class MasterBuildingComponent {
|
||||
editRow(row) {
|
||||
const modalRef = this.modalService.open(AddEditMasterBuildingComponent, {
|
||||
size: "lg",
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
backdrop: "static",
|
||||
keyboard: false,
|
||||
});
|
||||
|
||||
modalRef.componentInstance.dataRow = row;
|
||||
@@ -107,12 +127,27 @@ export class MasterBuildingComponent {
|
||||
modalRef.result.then(
|
||||
(result) => {
|
||||
if (result) {
|
||||
this.monitoringApiService
|
||||
if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase())) {
|
||||
this.toastr.error("Warning", "Data yang anda masukan double.", {
|
||||
timeOut: 5000,
|
||||
closeButton: true,
|
||||
});
|
||||
} else {
|
||||
this.monitoringApiService
|
||||
.putMasterBuildingParam(result, row.id)
|
||||
.subscribe((res) => {
|
||||
this.fetchData();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// if (result) {
|
||||
// this.monitoringApiService
|
||||
// .putMasterBuildingParam(result, row.id)
|
||||
// .subscribe((res) => {
|
||||
// this.fetchData();
|
||||
// });
|
||||
// }
|
||||
},
|
||||
(reason) => {
|
||||
console.log(`Dismissed: ${reason}`);
|
||||
|
||||
Reference in New Issue
Block a user