diff --git a/src/app/_layout/footer/footer.component.html b/src/app/_layout/footer/footer.component.html
index 18a5731..d3a7438 100644
--- a/src/app/_layout/footer/footer.component.html
+++ b/src/app/_layout/footer/footer.component.html
@@ -13,7 +13,7 @@
href="https://allbestsistem.com/"
target="_blank"
style="background-color: #000000 !important;"
- >Smart Building Management Systems (V@2024-07-1.01)
+ >Smart Building Management Systems (V@2024-07-2.02)
diff --git a/src/app/content/hemat-app/component/select-icon/select-icon.component.ts b/src/app/content/hemat-app/component/select-icon/select-icon.component.ts
index f6980ad..4d5d779 100644
--- a/src/app/content/hemat-app/component/select-icon/select-icon.component.ts
+++ b/src/app/content/hemat-app/component/select-icon/select-icon.component.ts
@@ -12,17 +12,20 @@ interface Icon {
export class SelectIconComponent {
// @Output() iconSelected: EventEmitter = new EventEmitter();
@Output() iconSelected = new EventEmitter();
- @Input() selectedIcon: string;
+ @Input() selectedIcon = undefined;
icons: any[] = [];
constructor(private masterService: MasterService) {}
ngOnInit(): void {
this.masterService.getIconData().subscribe((res) => {
this.icons = res.rows;
});
+ if (!this.selectedIcon) {
+ this.selectedIcon = undefined;
+ }
+
}
onSelect(icon: Icon): void {
- console.log(icon);
if (icon) {
this.iconSelected.emit(icon.icon);
} else {
diff --git a/src/app/content/hemat-app/master/add-edit-master/add-edit-master.component.html b/src/app/content/hemat-app/master/add-edit-master/add-edit-master.component.html
index 7842f52..083f69e 100644
--- a/src/app/content/hemat-app/master/add-edit-master/add-edit-master.component.html
+++ b/src/app/content/hemat-app/master/add-edit-master/add-edit-master.component.html
@@ -1,6 +1,6 @@
@@ -16,13 +16,17 @@
formControlName="name"
maxlength="50"
/>
+
+ Name is required.
+
-
@@ -53,6 +60,6 @@
class="btn btn-primary"
(click)="addRow()"
>
- Save Changes
+ Save
diff --git a/src/app/content/hemat-app/master/add-edit-master/add-edit-master.component.ts b/src/app/content/hemat-app/master/add-edit-master/add-edit-master.component.ts
index b6ba8aa..9782328 100644
--- a/src/app/content/hemat-app/master/add-edit-master/add-edit-master.component.ts
+++ b/src/app/content/hemat-app/master/add-edit-master/add-edit-master.component.ts
@@ -16,6 +16,7 @@ export class AddEditMasterComponent implements OnInit {
myForm: FormGroup;
dataMasterStatus: any;
selectedIcon: string = '';
+ labelModal: string = '';
constructor(
public activeModal: NgbActiveModal,
@@ -26,7 +27,11 @@ export class AddEditMasterComponent implements OnInit {
ngOnInit() {
this.createForm();
this.dataListMaster();
- console.log(this.dataRow);
+ if (this.mode === "add") {
+ this.labelModal = "Add Row"
+ } else {
+ this.labelModal = "Edit Row"
+ }
if (this.dataRow) {
this.editForm();
@@ -36,7 +41,7 @@ export class AddEditMasterComponent implements OnInit {
createForm() {
const formControls = {
name: ["", Validators.required],
- status: [2, Validators.required],
+ status: ["", Validators.required],
headerId: this.headerId
};
@@ -50,14 +55,14 @@ export class AddEditMasterComponent implements OnInit {
editForm() {
const formControls = {
id: this.dataRow.id,
- name: this.dataRow.name,
- status: this.dataRow.status,
+ name: [this.dataRow.name, Validators.required],
+ status: [this.dataRow.status, Validators.required],
headerId: this.dataRow.headerId,
};
if (this.category) {
- formControls['icon'] = this.dataRow.icon || "";
- this.selectedIcon = this.dataRow.icon || "";
+ formControls['icon'] = [this.dataRow.icon || undefined , Validators.required];
+ this.selectedIcon = this.dataRow.icon || undefined;
}
this.myForm = this.fb.group(formControls);
@@ -75,9 +80,20 @@ export class AddEditMasterComponent implements OnInit {
addRow() {
if (this.myForm.valid) {
this.activeModal.close(this.myForm.value);
+ } else {
+ this.markFormGroupTouched(this.myForm)
}
}
+ markFormGroupTouched(formGroup: FormGroup) {
+ (Object as any).values(formGroup.controls).forEach((control) => {
+ control.markAsTouched();
+ if (control.controls) {
+ this.markFormGroupTouched(control);
+ }
+ });
+ }
+
addDepartment() {
let newDept = prompt("Enter new department name:");
if (newDept) {
diff --git a/src/app/content/hemat-app/master/master-building/add-edit-master-building/add-edit-master-building.component.ts b/src/app/content/hemat-app/master/master-building/add-edit-master-building/add-edit-master-building.component.ts
index 0dcede8..932352d 100644
--- a/src/app/content/hemat-app/master/master-building/add-edit-master-building/add-edit-master-building.component.ts
+++ b/src/app/content/hemat-app/master/master-building/add-edit-master-building/add-edit-master-building.component.ts
@@ -36,7 +36,7 @@ export class AddEditMasterBuildingComponent {
createForm() {
this.myForm = this.fb.group({
name: ["", Validators.required],
- statusId: [0, Validators.required],
+ statusId: ["", Validators.required],
email: ["", [Validators.required, Validators.email]],
owner: ["", Validators.required],
address: ["", Validators.required],
@@ -48,13 +48,16 @@ export class AddEditMasterBuildingComponent {
editForm() {
this.myForm = this.fb.group({
id: this.dataRow.id,
- name: this.dataRow.name,
- statusId: this.dataRow.statusId,
+ name: [this.dataRow.name, Validators.required],
+ statusId: [this.dataRow.statusId, Validators.required],
email: [this.dataRow.email, [Validators.required, Validators.email]],
- owner: this.dataRow.owner,
- address: this.dataRow.address,
- phone: [this.dataRow.phone, [Validators.required, Validators.pattern("^[0-9]*$")]],
- kwh: this.dataRow.kwh,
+ owner: [this.dataRow.owner, Validators.required],
+ address: [this.dataRow.address, Validators.required],
+ phone: [
+ this.dataRow.phone,
+ [Validators.required, Validators.pattern("^[0-9]*$")],
+ ],
+ kwh: [this.dataRow.kwh, Validators.required],
});
}
@@ -66,7 +69,7 @@ export class AddEditMasterBuildingComponent {
);
this.dataStatus = this.dataMasterStatus.headerDetailParam;
console.log(this.dataStatus);
-
+
this.filteredDataStatus = this.dataStatus.filter(
(item) => item.status === "2"
);
@@ -76,9 +79,20 @@ export class AddEditMasterBuildingComponent {
addRow() {
if (this.myForm.valid) {
this.activeModal.close(this.myForm.value);
+ } else {
+ this.markFormGroupTouched(this.myForm);
}
}
+ markFormGroupTouched(formGroup: FormGroup) {
+ (Object as any).values(formGroup.controls).forEach((control) => {
+ control.markAsTouched();
+ if (control.controls) {
+ this.markFormGroupTouched(control);
+ }
+ });
+ }
+
addDepartment() {
let newDept = prompt("Enter new department name:");
if (newDept) {
diff --git a/src/app/content/hemat-app/master/master-category/master-category.component.ts b/src/app/content/hemat-app/master/master-category/master-category.component.ts
index 662ea79..0079df0 100644
--- a/src/app/content/hemat-app/master/master-category/master-category.component.ts
+++ b/src/app/content/hemat-app/master/master-category/master-category.component.ts
@@ -83,6 +83,8 @@ export class MasterCategoryComponent implements OnInit {
openAddMasterModal() {
const modalRef = this.modalService.open(AddEditMasterComponent, {
size: "lg",
+ backdrop: 'static', // Add this line
+ keyboard: false // Add this line
});
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
@@ -119,6 +121,8 @@ export class MasterCategoryComponent implements OnInit {
editRow(row) {
const modalRef = this.modalService.open(AddEditMasterComponent, {
size: "lg",
+ backdrop: 'static', // Add this line
+ keyboard: false // Add this line
});
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
diff --git a/src/app/content/hemat-app/master/master-duration-use/master-duration-use.component.ts b/src/app/content/hemat-app/master/master-duration-use/master-duration-use.component.ts
index ace25e0..15094de 100644
--- a/src/app/content/hemat-app/master/master-duration-use/master-duration-use.component.ts
+++ b/src/app/content/hemat-app/master/master-duration-use/master-duration-use.component.ts
@@ -76,6 +76,8 @@ export class MasterDurationUseComponent {
openAddMasterModal() {
const modalRef = this.modalService.open(AddEditMasterComponent, {
size: "lg",
+ backdrop: 'static', // Add this line
+ keyboard: false // Add this line
});
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
@@ -101,6 +103,8 @@ export class MasterDurationUseComponent {
editRow(row) {
const modalRef = this.modalService.open(AddEditMasterComponent, {
size: "lg",
+ backdrop: 'static', // Add this line
+ keyboard: false // Add this line
});
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
diff --git a/src/app/content/hemat-app/master/master-floor/master-floor.component.ts b/src/app/content/hemat-app/master/master-floor/master-floor.component.ts
index 913bd2d..787d044 100644
--- a/src/app/content/hemat-app/master/master-floor/master-floor.component.ts
+++ b/src/app/content/hemat-app/master/master-floor/master-floor.component.ts
@@ -76,6 +76,8 @@ export class MasterFloorComponent {
openAddMasterModal() {
const modalRef = this.modalService.open(AddEditMasterComponent, {
size: "lg",
+ backdrop: 'static', // Add this line
+ keyboard: false // Add this line
});
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
@@ -101,6 +103,8 @@ export class MasterFloorComponent {
editRow(row) {
const modalRef = this.modalService.open(AddEditMasterComponent, {
size: "lg",
+ backdrop: 'static', // Add this line
+ keyboard: false // Add this line
});
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
diff --git a/src/app/content/hemat-app/master/master-role/master-role.component.ts b/src/app/content/hemat-app/master/master-role/master-role.component.ts
index 0ed5e01..844d0ca 100644
--- a/src/app/content/hemat-app/master/master-role/master-role.component.ts
+++ b/src/app/content/hemat-app/master/master-role/master-role.component.ts
@@ -76,6 +76,8 @@ export class MasterRoleComponent {
openAddMasterModal() {
const modalRef = this.modalService.open(AddEditMasterComponent, {
size: "lg",
+ backdrop: 'static', // Add this line
+ keyboard: false // Add this line
});
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
@@ -101,6 +103,8 @@ export class MasterRoleComponent {
editRow(row) {
const modalRef = this.modalService.open(AddEditMasterComponent, {
size: "lg",
+ backdrop: 'static', // Add this line
+ keyboard: false // Add this line
});
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
diff --git a/src/app/content/hemat-app/master/master-room/add-edit-master-room/add-edit-master-room.component.html b/src/app/content/hemat-app/master/master-room/add-edit-master-room/add-edit-master-room.component.html
index 02b92d0..7f4c26b 100644
--- a/src/app/content/hemat-app/master/master-room/add-edit-master-room/add-edit-master-room.component.html
+++ b/src/app/content/hemat-app/master/master-room/add-edit-master-room/add-edit-master-room.component.html
@@ -1,6 +1,6 @@
@@ -16,6 +16,12 @@
formControlName="name"
maxlength="50"
/>
+
+ Name is required.
+
@@ -73,6 +93,6 @@
style="color: #000000 !important; background-color: #c3f164 !important"
(click)="addRow()"
>
- Save Changes
+ Save
diff --git a/src/app/content/hemat-app/master/master-room/add-edit-master-room/add-edit-master-room.component.ts b/src/app/content/hemat-app/master/master-room/add-edit-master-room/add-edit-master-room.component.ts
index 2ace44e..662c0ac 100644
--- a/src/app/content/hemat-app/master/master-room/add-edit-master-room/add-edit-master-room.component.ts
+++ b/src/app/content/hemat-app/master/master-room/add-edit-master-room/add-edit-master-room.component.ts
@@ -1,12 +1,12 @@
-import { Component, Input } from '@angular/core';
-import { FormBuilder, FormGroup, Validators } from '@angular/forms';
-import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
-import { BuildingService } from '../../../service/monitoring-api.service';
+import { Component, Input } from "@angular/core";
+import { FormBuilder, FormGroup, Validators } from "@angular/forms";
+import { NgbActiveModal } from "@ng-bootstrap/ng-bootstrap";
+import { BuildingService } from "../../../service/monitoring-api.service";
@Component({
- selector: 'app-add-edit-master-room',
- templateUrl: './add-edit-master-room.component.html',
- styleUrls: ['./add-edit-master-room.component.css']
+ selector: "app-add-edit-master-room",
+ templateUrl: "./add-edit-master-room.component.html",
+ styleUrls: ["./add-edit-master-room.component.css"],
})
export class AddEditMasterRoomComponent {
@Input() dataRow: any;
@@ -19,6 +19,7 @@ export class AddEditMasterRoomComponent {
filteredDataStatus: any[];
filteredDataBuilding: any[];
dataMasterStatus: any;
+ labelRoom: string = "";
constructor(
public activeModal: NgbActiveModal,
@@ -30,7 +31,12 @@ export class AddEditMasterRoomComponent {
this.createForm();
this.listDataStatus();
this.listDataBuilding();
-
+ console.log(this.mode);
+ if (this.mode) {
+ this.labelRoom = "Add New Row"
+ } else {
+ this.labelRoom = "Add New Row"
+ }
if (this.dataRow) {
this.editForm();
}
@@ -39,8 +45,8 @@ export class AddEditMasterRoomComponent {
createForm() {
this.myForm = this.fb.group({
name: ["", Validators.required],
- statusId: [0, Validators.required],
- buildingId: [0, Validators.required],
+ statusId: ["", Validators.required],
+ buildingId: ["", Validators.required],
description: ["", Validators.required],
});
}
@@ -48,10 +54,10 @@ export class AddEditMasterRoomComponent {
editForm() {
this.myForm = this.fb.group({
id: this.dataRow.id,
- name: this.dataRow.name,
- statusId: this.dataRow.statusId,
- buildingId: this.dataRow.buildingId,
- description: this.dataRow.description,
+ name: [this.dataRow.name, Validators.required],
+ statusId: [this.dataRow.statusId, Validators.required],
+ buildingId: [this.dataRow.buildingId, Validators.required],
+ description: [this.dataRow.description, Validators.required],
});
}
@@ -65,23 +71,32 @@ export class AddEditMasterRoomComponent {
this.filteredDataStatus = this.dataStatus.filter(
(item) => item.status === "2"
);
-
});
}
- listDataBuilding(){
+ listDataBuilding() {
this.monitoringApiService.getMasterBuildingData().subscribe((res) => {
this.dataBuilding = res.results.data;
this.filteredDataBuilding = this.dataBuilding.filter(
(item) => item.statusId === 2
);
-
});
}
addRow() {
if (this.myForm.valid) {
this.activeModal.close(this.myForm.value);
+ } else {
+ this.markFormGroupTouched(this.myForm);
}
}
+
+ markFormGroupTouched(formGroup: FormGroup) {
+ (Object as any).values(formGroup.controls).forEach((control) => {
+ control.markAsTouched();
+ if (control.controls) {
+ this.markFormGroupTouched(control);
+ }
+ });
+ }
}
diff --git a/src/app/content/hemat-app/master/master-room/master-room.component.ts b/src/app/content/hemat-app/master/master-room/master-room.component.ts
index d056392..8fba965 100644
--- a/src/app/content/hemat-app/master/master-room/master-room.component.ts
+++ b/src/app/content/hemat-app/master/master-room/master-room.component.ts
@@ -43,14 +43,16 @@ export class MasterRoomComponent {
this.monitoringApiService.getBuildingRoomList().subscribe((res) => {
this.data = res;
this.filteredRows = this.data.results.data;
+ console.log(this.filteredRows);
+
});
}
filterRows() {
if (!this.searchTerm) {
- this.filteredRows = [...this.data];
+ this.filteredRows = [...this.data.results.data];
} else {
- this.filteredRows = this.data.filter((row) =>
+ this.filteredRows = this.data.results.data.filter((row) =>
this.rowContainsSearchTerm(row)
);
}
@@ -67,6 +69,8 @@ export class MasterRoomComponent {
openAddMasterModal() {
const modalRef = this.modalService.open(AddEditMasterRoomComponent, {
size: "lg",
+ backdrop: 'static', // Add this line
+ keyboard: false // Add this line
});
modalRef.componentInstance.mode = "add";
@@ -102,6 +106,8 @@ export class MasterRoomComponent {
editRow(row) {
const modalRef = this.modalService.open(AddEditMasterRoomComponent, {
size: "lg",
+ backdrop: 'static', // Add this line
+ keyboard: false // Add this line
});
modalRef.componentInstance.dataRow = row;
diff --git a/src/app/content/hemat-app/master/master-status/master-status.component.ts b/src/app/content/hemat-app/master/master-status/master-status.component.ts
index bc2920d..0aba3be 100644
--- a/src/app/content/hemat-app/master/master-status/master-status.component.ts
+++ b/src/app/content/hemat-app/master/master-status/master-status.component.ts
@@ -76,6 +76,8 @@ export class MasterStatusComponent {
openAddMasterModal() {
const modalRef = this.modalService.open(AddEditMasterComponent, {
size: "lg",
+ backdrop: 'static', // Add this line
+ keyboard: false // Add this line
});
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
@@ -101,6 +103,8 @@ export class MasterStatusComponent {
editRow(row) {
const modalRef = this.modalService.open(AddEditMasterComponent, {
size: "lg",
+ backdrop: 'static', // Add this line
+ keyboard: false // Add this line
});
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
diff --git a/src/app/content/hemat-app/master/master-type/master-type.component.ts b/src/app/content/hemat-app/master/master-type/master-type.component.ts
index 7f36be3..17b1f99 100644
--- a/src/app/content/hemat-app/master/master-type/master-type.component.ts
+++ b/src/app/content/hemat-app/master/master-type/master-type.component.ts
@@ -76,6 +76,8 @@ export class MasterTypeComponent {
openAddMasterModal() {
const modalRef = this.modalService.open(AddEditMasterComponent, {
size: "lg",
+ backdrop: 'static', // Add this line
+ keyboard: false // Add this line
});
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
@@ -101,6 +103,8 @@ export class MasterTypeComponent {
editRow(row) {
const modalRef = this.modalService.open(AddEditMasterComponent, {
size: "lg",
+ backdrop: 'static', // Add this line
+ keyboard: false // Add this line
});
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
diff --git a/src/app/content/hemat-app/master/master-voltage/master-voltage.component.ts b/src/app/content/hemat-app/master/master-voltage/master-voltage.component.ts
index 3e48360..f4546fc 100644
--- a/src/app/content/hemat-app/master/master-voltage/master-voltage.component.ts
+++ b/src/app/content/hemat-app/master/master-voltage/master-voltage.component.ts
@@ -76,6 +76,8 @@ export class MasterVoltageComponent {
openAddMasterModal() {
const modalRef = this.modalService.open(AddEditMasterComponent, {
size: "lg",
+ backdrop: 'static', // Add this line
+ keyboard: false // Add this line
});
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
@@ -101,6 +103,8 @@ export class MasterVoltageComponent {
editRow(row) {
const modalRef = this.modalService.open(AddEditMasterComponent, {
size: "lg",
+ backdrop: 'static', // Add this line
+ keyboard: false // Add this line
});
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
diff --git a/src/app/content/hemat-app/service/monitoring-api.service.ts b/src/app/content/hemat-app/service/monitoring-api.service.ts
index ac45db3..90f84eb 100644
--- a/src/app/content/hemat-app/service/monitoring-api.service.ts
+++ b/src/app/content/hemat-app/service/monitoring-api.service.ts
@@ -198,7 +198,7 @@ export class BuildingService {
return this.http.post(url, data, { headers });
}
- getBuildingRoomList(page: number = 1, limit: number = 100): Observable {
+ getBuildingRoomList(page: number = 1, limit: number = 1000): Observable {
const url = `https://kapi.absys.ninja/hemat/room-building?page=${page}&limit=${limit}`;
const headers = new HttpHeaders({
"Content-Type": "application/json",
diff --git a/src/app/login/login.component.html b/src/app/login/login.component.html
index 7cbe230..a03c586 100644
--- a/src/app/login/login.component.html
+++ b/src/app/login/login.component.html
@@ -138,7 +138,7 @@
- (v@2024.07.1.01)
+ (v@2024.07.2.02)