From 89203b99845041512e9b5ee30a4c70a46ebb013f Mon Sep 17 00:00:00 2001 From: Fuzi_fauzia Date: Tue, 25 Jun 2024 21:54:12 +0700 Subject: [PATCH] penambahan icon pada master category --- .../select-icon/select-icon.component.html | 1 + .../select-icon/select-icon.component.ts | 14 ++++-- .../add-edit-master.component.html | 5 ++- .../add-edit-master.component.ts | 30 ++++++++++--- .../master-category.component.html | 15 +++++++ .../master-category.component.ts | 4 ++ .../add-edit-master-room.component.html | 18 ++++++-- .../add-edit-master-room.component.ts | 29 ++++++++----- .../master-room/master-room.component.html | 42 +++++++++++++++--- .../master-room/master-room.component.ts | 43 ++++++++++++------- src/assets/data/hemat/remixicons.json | 8 ++++ 11 files changed, 164 insertions(+), 45 deletions(-) diff --git a/src/app/content/hemat-app/component/select-icon/select-icon.component.html b/src/app/content/hemat-app/component/select-icon/select-icon.component.html index aa758b8..c7d0e26 100644 --- a/src/app/content/hemat-app/component/select-icon/select-icon.component.html +++ b/src/app/content/hemat-app/component/select-icon/select-icon.component.html @@ -2,6 +2,7 @@ [items]="icons" bindLabel="name" (change)="onSelect($event)" + [(ngModel)]="selectedIcon" bindValue="icon" placeholder="Select an icon" > 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 0ec2297..f6980ad 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 @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Output } from "@angular/core"; +import { Component, EventEmitter, Input, Output } from "@angular/core"; import { MasterService } from "../../service/master-api.service"; interface Icon { name: string; @@ -10,7 +10,9 @@ interface Icon { styleUrls: ["./select-icon.component.css"], }) export class SelectIconComponent { - @Output() iconSelected: EventEmitter = new EventEmitter(); + // @Output() iconSelected: EventEmitter = new EventEmitter(); + @Output() iconSelected = new EventEmitter(); + @Input() selectedIcon: string; icons: any[] = []; constructor(private masterService: MasterService) {} ngOnInit(): void { @@ -20,6 +22,12 @@ export class SelectIconComponent { } onSelect(icon: Icon): void { - this.iconSelected.emit(icon.icon); + console.log(icon); + if (icon) { + this.iconSelected.emit(icon.icon); + } else { + this.iconSelected.emit(undefined); + } + } } 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 9d959a0..7610773 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 @@ -16,9 +16,10 @@ formControlName="name" /> -
+
- + +
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 4bb34b6..b6ba8aa 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 @@ -12,6 +12,7 @@ export class AddEditMasterComponent implements OnInit { @Input() headerId: number; @Input() dataRow: any; @Input() mode: any; + @Input() category: boolean = false; myForm: FormGroup; dataMasterStatus: any; selectedIcon: string = ''; @@ -25,26 +26,41 @@ export class AddEditMasterComponent implements OnInit { ngOnInit() { this.createForm(); this.dataListMaster(); + console.log(this.dataRow); + if (this.dataRow) { this.editForm(); } } createForm() { - this.myForm = this.fb.group({ + const formControls = { name: ["", Validators.required], status: [2, Validators.required], - headerId: this.headerId, - }); + headerId: this.headerId + }; + + if (this.category) { + formControls['icon'] = [undefined, Validators.required]; + } + + this.myForm = this.fb.group(formControls); } editForm() { - this.myForm = this.fb.group({ + const formControls = { id: this.dataRow.id, name: this.dataRow.name, status: this.dataRow.status, headerId: this.dataRow.headerId, - }); + }; + + if (this.category) { + formControls['icon'] = this.dataRow.icon || ""; + this.selectedIcon = this.dataRow.icon || ""; + } + + this.myForm = this.fb.group(formControls); } dataListMaster() { @@ -70,7 +86,9 @@ export class AddEditMasterComponent implements OnInit { } onIconSelected(icon: string): void { + console.log(icon); + this.selectedIcon = icon; - this.myForm.get('selectedIcon').setValue(icon); // Set nilai selectedIcon ke dalam form + this.myForm.get('icon').setValue(icon); // Set nilai icon ke dalam form } } diff --git a/src/app/content/hemat-app/master/master-category/master-category.component.html b/src/app/content/hemat-app/master/master-category/master-category.component.html index 2decda7..030697e 100644 --- a/src/app/content/hemat-app/master/master-category/master-category.component.html +++ b/src/app/content/hemat-app/master/master-category/master-category.component.html @@ -78,6 +78,21 @@

{{ value }}

+ + + Icon + + +

{{ value }}

+
+
item.name === "master_category" ); this.filteredRows = this.dataMasterCategori.headerDetailParam; + console.log(this.filteredRows); + }); } @@ -85,6 +87,7 @@ export class MasterCategoryComponent implements OnInit { modalRef.componentInstance.headerId = this.dataMasterCategori.id; modalRef.componentInstance.mode = "add"; + modalRef.componentInstance.category = true; modalRef.result.then( (result) => { console.log(result); @@ -121,6 +124,7 @@ export class MasterCategoryComponent implements OnInit { modalRef.componentInstance.headerId = this.dataMasterCategori.id; modalRef.componentInstance.dataRow = row; modalRef.componentInstance.mode = "edit"; + modalRef.componentInstance.category = true; modalRef.result.then( (result) => { console.log(result); 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 d028ad3..4f22560 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 @@ -16,6 +16,18 @@ formControlName="name" />
+
+ + +
- +
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 7876901..2ace44e 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 @@ -15,7 +15,9 @@ export class AddEditMasterRoomComponent { data: any; dataStatus: any[]; + dataBuilding: any[]; filteredDataStatus: any[]; + filteredDataBuilding: any[]; dataMasterStatus: any; constructor( @@ -27,6 +29,7 @@ export class AddEditMasterRoomComponent { ngOnInit() { this.createForm(); this.listDataStatus(); + this.listDataBuilding(); if (this.dataRow) { this.editForm(); @@ -36,7 +39,8 @@ export class AddEditMasterRoomComponent { createForm() { this.myForm = this.fb.group({ name: ["", Validators.required], - // statusId: [0, Validators.required], + statusId: [0, Validators.required], + buildingId: [0, Validators.required], description: ["", Validators.required], }); } @@ -45,7 +49,8 @@ export class AddEditMasterRoomComponent { this.myForm = this.fb.group({ id: this.dataRow.id, name: this.dataRow.name, - // statusId: this.dataRow.statusId, + statusId: this.dataRow.statusId, + buildingId: this.dataRow.buildingId, description: this.dataRow.description, }); } @@ -58,8 +63,19 @@ export class AddEditMasterRoomComponent { ); this.dataStatus = this.dataMasterStatus.headerDetailParam; this.filteredDataStatus = this.dataStatus.filter( - (item) => item.status === "1" + (item) => item.status === "2" ); + + }); + } + + listDataBuilding(){ + this.monitoringApiService.getMasterBuildingData().subscribe((res) => { + this.dataBuilding = res.results.data; + this.filteredDataBuilding = this.dataBuilding.filter( + (item) => item.statusId === 2 + ); + }); } @@ -68,11 +84,4 @@ export class AddEditMasterRoomComponent { this.activeModal.close(this.myForm.value); } } - - addDepartment() { - let newDept = prompt("Enter new department name:"); - if (newDept) { - alert(`Department ${newDept} added! (simulated)`); - } - } } diff --git a/src/app/content/hemat-app/master/master-room/master-room.component.html b/src/app/content/hemat-app/master/master-room/master-room.component.html index 2bfdb19..2e74cb7 100644 --- a/src/app/content/hemat-app/master/master-room/master-room.component.html +++ b/src/app/content/hemat-app/master/master-room/master-room.component.html @@ -64,23 +64,55 @@ - Room Name + Room -

{{ value }}

+

{{ value.name }}

+ + Building + + +

{{ value.name }}

+
+
+ + + + Description + + +

{{ value.description }}

+
+
+ + @@ -91,7 +123,7 @@ ngx-datatable-cell-template let-value="value" > -

{{ value === 2 ? "Aktif" : "Tidak Aktif" }}

+

{{ value.name }}

{ - this.data = res.results.data; - this.filteredRows = this.data; + this.monitoringApiService.getBuildingRoomList().subscribe((res) => { + this.data = res; + this.filteredRows = this.data.results.data; }); } @@ -75,10 +73,23 @@ export class MasterRoomComponent { modalRef.result.then( (result) => { if (result) { + const filteredData = { + name: result.name, + description: result.description, + }; this.monitoringApiService - .postMasterRoomParam(result) + .postMasterRoomParam(filteredData) .subscribe((res) => { - this.fetchData(); + const transformedData = { + buildingId: result.buildingId, + roomId: res.data.id, + statusId: result.statusId, + }; + this.monitoringApiService + .postBatchBuilding(transformedData) + .subscribe((res) => { + this.fetchData(); + }); }); } }, diff --git a/src/assets/data/hemat/remixicons.json b/src/assets/data/hemat/remixicons.json index ec6d8ed..963c06e 100644 --- a/src/assets/data/hemat/remixicons.json +++ b/src/assets/data/hemat/remixicons.json @@ -16,6 +16,14 @@ "name": "Plug Line", "icon": "ri-plug-2-line" }, + { + "name": "Camera Line", + "icon": "ri-dv-line" + }, + { + "name": "Camera Fill", + "icon": "ri-dv-fill" + }, { "name": "Airplay Fill", "icon": "ri-airplay-fill"