penambahan room list
This commit is contained in:
parent
6a9451c2b5
commit
b2c1020c22
|
@ -52,6 +52,15 @@
|
||||||
formControlName="address"
|
formControlName="address"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="address">KWH:</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
class="form-control"
|
||||||
|
id="kwh"
|
||||||
|
formControlName="kwh"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="statusId">Status:</label>
|
<label for="statusId">Status:</label>
|
||||||
<!-- <select
|
<!-- <select
|
||||||
|
|
|
@ -41,6 +41,7 @@ export class AddEditMasterBuildingComponent {
|
||||||
owner: ["", Validators.required],
|
owner: ["", Validators.required],
|
||||||
address: ["", Validators.required],
|
address: ["", Validators.required],
|
||||||
phone: ["", Validators.required],
|
phone: ["", Validators.required],
|
||||||
|
kwh: ["", Validators.required],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +54,7 @@ export class AddEditMasterBuildingComponent {
|
||||||
owner: this.dataRow.owner,
|
owner: this.dataRow.owner,
|
||||||
address: this.dataRow.address,
|
address: this.dataRow.address,
|
||||||
phone: this.dataRow.phone,
|
phone: this.dataRow.phone,
|
||||||
|
kwh: this.dataRow.phone,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ export class MasterBuildingComponent {
|
||||||
const confirmDelete = confirm("Are you sure you want to delete this item?");
|
const confirmDelete = confirm("Are you sure you want to delete this item?");
|
||||||
if (confirmDelete) {
|
if (confirmDelete) {
|
||||||
this.monitoringApiService
|
this.monitoringApiService
|
||||||
.deleteHeaderDetailParam(row.id)
|
.deleteMasterBuildingParam(row.id)
|
||||||
.subscribe((res) => {
|
.subscribe((res) => {
|
||||||
this.fetchData();
|
this.fetchData();
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form [formGroup]="userProfileForm" class="row">
|
<form [formGroup]="userProfileForm" class="row">
|
||||||
<div class="form-group col-md-6 mb-2">
|
<div class="form-group col-md-6 mb-2">
|
||||||
<label for="name">Building Name *</label>
|
<label for="name">Building*</label>
|
||||||
<select
|
<select
|
||||||
id="buildingId"
|
id="buildingId"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
|
@ -27,32 +27,32 @@
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<option
|
<option
|
||||||
*ngFor="let interest of interestedIn"
|
*ngFor="let list of listBuildingMaster"
|
||||||
[value]="interest"
|
[value]="list.id"
|
||||||
>
|
>
|
||||||
{{ interest }}
|
{{ list.name }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-6 mb-2">
|
<div class="form-group col-md-6 mb-2">
|
||||||
<label for="name">Floor*</label>
|
<label for="statusId">Status*</label>
|
||||||
<select
|
<select
|
||||||
id="floorId"
|
id="statusId"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
formControlName="floorId"
|
formControlName="statusId"
|
||||||
[ngClass]="{
|
[ngClass]="{
|
||||||
'is-invalid': submitted && f.interestedIn.errors
|
'is-invalid': submitted && f.interestedIn.errors
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<option
|
<option
|
||||||
*ngFor="let interest of interestedIn"
|
*ngFor="let list of dataMasterstatus"
|
||||||
[value]="interest"
|
[value]="list.id"
|
||||||
>
|
>
|
||||||
{{ interest }}
|
{{ list.name }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-12 mb-2">
|
<!-- <div class="form-group col-12 mb-2">
|
||||||
<label for="name">Status*</label>
|
<label for="name">Status*</label>
|
||||||
<select
|
<select
|
||||||
id="statusId"
|
id="statusId"
|
||||||
|
@ -63,13 +63,13 @@
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<option
|
<option
|
||||||
*ngFor="let interest of interestedIn"
|
*ngFor="let list of dataMasterstatus"
|
||||||
[value]="interest"
|
[value]="list.id"
|
||||||
>
|
>
|
||||||
{{ interest }}
|
{{ list.name }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div> -->
|
||||||
<div class="form-group col-12 mb-2 contact-repeater">
|
<div class="form-group col-12 mb-2 contact-repeater">
|
||||||
<div class="" formArrayName="userArray">
|
<div class="" formArrayName="userArray">
|
||||||
<div
|
<div
|
||||||
|
@ -91,10 +91,10 @@
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<option
|
<option
|
||||||
*ngFor="let interest of interestedIn"
|
*ngFor="let list of listRoomMaster"
|
||||||
[value]="interest"
|
[value]="list.id"
|
||||||
>
|
>
|
||||||
{{ interest }}
|
{{ list.name }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<button
|
<button
|
||||||
|
@ -133,10 +133,11 @@
|
||||||
type="button"
|
type="button"
|
||||||
uiSref="work"
|
uiSref="work"
|
||||||
class="btn btn-info btn-raised"
|
class="btn btn-info btn-raised"
|
||||||
|
(click)="save()"
|
||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
<span style="margin-left: 10px">
|
<span style="margin-left: 10px">
|
||||||
<i class="feather ft-chevron-right"></i>
|
<!-- <i class="feather ft-chevron-right"></i> -->
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { Component, OnInit } from "@angular/core";
|
||||||
import { FormArray, FormBuilder, FormGroup, Validators } from "@angular/forms";
|
import { FormArray, FormBuilder, FormGroup, Validators } from "@angular/forms";
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, Router } from "@angular/router";
|
||||||
import { BlockUI, NgBlockUI } from "ng-block-ui";
|
import { BlockUI, NgBlockUI } from "ng-block-ui";
|
||||||
|
import { BuildingService } from "../../service/monitoring-api.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-add-new-building-room",
|
selector: "app-add-new-building-room",
|
||||||
|
@ -10,6 +11,9 @@ import { BlockUI, NgBlockUI } from "ng-block-ui";
|
||||||
})
|
})
|
||||||
export class AddNewBuildingRoomComponent implements OnInit {
|
export class AddNewBuildingRoomComponent implements OnInit {
|
||||||
public breadcrumb: any;
|
public breadcrumb: any;
|
||||||
|
dataMasterstatus: any;
|
||||||
|
listRoomMaster: any;
|
||||||
|
listBuildingMaster: any;
|
||||||
mode: string;
|
mode: string;
|
||||||
userProfileForm: FormGroup;
|
userProfileForm: FormGroup;
|
||||||
public userList: FormArray;
|
public userList: FormArray;
|
||||||
|
@ -21,7 +25,8 @@ export class AddNewBuildingRoomComponent implements OnInit {
|
||||||
constructor(
|
constructor(
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private route: ActivatedRoute
|
private route: ActivatedRoute,
|
||||||
|
private monitoringApiService: BuildingService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -36,22 +41,72 @@ export class AddNewBuildingRoomComponent implements OnInit {
|
||||||
};
|
};
|
||||||
this.userProfileForm = this.formBuilder.group({
|
this.userProfileForm = this.formBuilder.group({
|
||||||
buildingId: ['', Validators.required],
|
buildingId: ['', Validators.required],
|
||||||
roomId: ['', Validators.required],
|
roomId: [''],
|
||||||
floorId: ['', Validators.required],
|
statusId: ['', Validators.required],
|
||||||
userArray: this.formBuilder.array([this.createPhone()]),
|
userArray: this.formBuilder.array([this.createRoom()]),
|
||||||
});
|
});
|
||||||
|
|
||||||
this.userList = this.userProfileForm.get('userArray') as FormArray;
|
this.userList = this.userProfileForm.get('userArray') as FormArray;
|
||||||
|
this.listMaster();
|
||||||
|
this.listRoom();
|
||||||
|
this.listBuilding();
|
||||||
}
|
}
|
||||||
|
|
||||||
createPhone(): FormGroup {
|
createRoom(): FormGroup {
|
||||||
return this.formBuilder.group({
|
return this.formBuilder.group({
|
||||||
roomId: ['', Validators.required]
|
roomId: ['', Validators.required]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
listMaster() {
|
||||||
|
this.monitoringApiService.getMasterData().subscribe((res) => {
|
||||||
|
this.dataMasterstatus = res.results.data.find(
|
||||||
|
(item) => item.name === "master_status"
|
||||||
|
).headerDetailParam;
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
listRoom() {
|
||||||
|
this.monitoringApiService.getListRoomData().subscribe((res) => {
|
||||||
|
this.listRoomMaster = res.results;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
listBuilding(){
|
||||||
|
this.monitoringApiService.getMasterBuildingData().subscribe((res) => {
|
||||||
|
this.listBuildingMaster = res.results.data;
|
||||||
|
console.log(this.listBuildingMaster);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
save(){
|
||||||
|
console.log(this.userProfileForm);
|
||||||
|
console.log(this.userProfileForm.valid);
|
||||||
|
this.submitted = true;
|
||||||
|
|
||||||
|
if (this.userProfileForm.invalid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = this.userProfileForm.value;
|
||||||
|
const transformedData = {
|
||||||
|
buildingId: formData.buildingId,
|
||||||
|
roomId: formData.userArray.map(room => room.roomId),
|
||||||
|
statusId: formData.statusId
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log(transformedData);
|
||||||
|
|
||||||
|
this.monitoringApiService.postBatchBuilding(transformedData).subscribe((res) => {
|
||||||
|
console.log(res);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
addPhone() {
|
addPhone() {
|
||||||
this.userList.push(this.createPhone());
|
this.userList.push(this.createRoom());
|
||||||
}
|
}
|
||||||
|
|
||||||
removePhone(index) {
|
removePhone(index) {
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div
|
<div
|
||||||
class="col-xl-6 col-md-6 col-12"
|
class="col-xl-6 col-md-6 col-12"
|
||||||
*ngFor="let top of data.topUse; let i = index"
|
*ngFor="let top of data.topUse | filterTopUse; let i = index"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<span class="mb-1 text-muted cardtext d-block"
|
<span class="mb-1 text-muted cardtext d-block"
|
||||||
|
|
|
@ -14,7 +14,7 @@ export class BuildingComponent {
|
||||||
feedbacksdonutChart: any;
|
feedbacksdonutChart: any;
|
||||||
donutChart1: any;
|
donutChart1: any;
|
||||||
filteredRows: any[];
|
filteredRows: any[];
|
||||||
dataTop: any;
|
topUseData: any;
|
||||||
searchTerm: string = "";
|
searchTerm: string = "";
|
||||||
colorChart: string = "";
|
colorChart: string = "";
|
||||||
|
|
||||||
|
@ -52,17 +52,16 @@ export class BuildingComponent {
|
||||||
|
|
||||||
listBuilding() {
|
listBuilding() {
|
||||||
this.monitoringApiService.listBuilding().subscribe((res) => {
|
this.monitoringApiService.listBuilding().subscribe((res) => {
|
||||||
console.log(res.data);
|
|
||||||
this.data = res.data;
|
this.data = res.data;
|
||||||
this.filteredRows = res.data;
|
this.filteredRows = res.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
buildingData() {
|
// buildingData() {
|
||||||
this.monitoringApiService.getBuildingData().subscribe((res) => {
|
// this.monitoringApiService.getBuildingData().subscribe((res) => {
|
||||||
console.log(res);
|
// console.log(res);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
filterRows() {
|
filterRows() {
|
||||||
if (!this.searchTerm) {
|
if (!this.searchTerm) {
|
||||||
|
|
|
@ -23,6 +23,7 @@ import { NgxPhotoswipeModule } from '@fnxone/ngx-photoswipe';
|
||||||
import { NgxMasonryModule } from 'ngx-masonry';
|
import { NgxMasonryModule } from 'ngx-masonry';
|
||||||
import { UiSwitchModule } from 'ngx-ui-switch';
|
import { UiSwitchModule } from 'ngx-ui-switch';
|
||||||
import { DetailRoomComponent } from './detail-room/detail-room.component';
|
import { DetailRoomComponent } from './detail-room/detail-room.component';
|
||||||
|
import { FilterTopUsePipe } from './monitoring.pipe';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
|
@ -30,7 +31,8 @@ import { DetailRoomComponent } from './detail-room/detail-room.component';
|
||||||
RoomComponent,
|
RoomComponent,
|
||||||
AddNewBuildingRoomComponent,
|
AddNewBuildingRoomComponent,
|
||||||
DetailComponent,
|
DetailComponent,
|
||||||
DetailRoomComponent
|
DetailRoomComponent,
|
||||||
|
FilterTopUsePipe
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
// create a new file named filter-top-use.pipe.ts
|
||||||
|
import { Pipe, PipeTransform } from '@angular/core';
|
||||||
|
|
||||||
|
@Pipe({
|
||||||
|
name: 'filterTopUse'
|
||||||
|
})
|
||||||
|
export class FilterTopUsePipe implements PipeTransform {
|
||||||
|
|
||||||
|
transform(items: any[]): any[] {
|
||||||
|
if (!items) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return items.filter(item => item.label !== null && item.value !== null);
|
||||||
|
}
|
||||||
|
}
|
|
@ -81,7 +81,7 @@ export class BuildingService {
|
||||||
return this.http.get<any>(url, { headers });
|
return this.http.get<any>(url, { headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
getMasterData(page: number = 1, limit: number = 10): Observable<any> {
|
getMasterData(page: number = 1, limit: number = 100): Observable<any> {
|
||||||
const url = `https://kapi.absys.ninja/hemat/header-param?page=${page}&limit=${limit}`;
|
const url = `https://kapi.absys.ninja/hemat/header-param?page=${page}&limit=${limit}`;
|
||||||
const headers = new HttpHeaders({
|
const headers = new HttpHeaders({
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -99,6 +99,15 @@ export class BuildingService {
|
||||||
return this.http.get<any>(url, { headers });
|
return this.http.get<any>(url, { headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getListRoomData(): Observable<any> {
|
||||||
|
const url = `https://kapi.absys.ninja/hemat/room/list`;
|
||||||
|
const headers = new HttpHeaders({
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT'
|
||||||
|
});
|
||||||
|
return this.http.get<any>(url, { headers });
|
||||||
|
}
|
||||||
|
|
||||||
getMasterRoomData(page: number = 1, limit: number = 100): Observable<any> {
|
getMasterRoomData(page: number = 1, limit: number = 100): Observable<any> {
|
||||||
const url = `https://kapi.absys.ninja/hemat/room?page=${page}&limit=${limit}`;
|
const url = `https://kapi.absys.ninja/hemat/room?page=${page}&limit=${limit}`;
|
||||||
const headers = new HttpHeaders({
|
const headers = new HttpHeaders({
|
||||||
|
@ -151,6 +160,15 @@ export class BuildingService {
|
||||||
return this.http.put<any>(url, data, { headers });
|
return this.http.put<any>(url, data, { headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteMasterBuildingParam(id: any): Observable<any> {
|
||||||
|
const url = `https://kapi.absys.ninja/hemat/building/${id}`;
|
||||||
|
const headers = new HttpHeaders({
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT'
|
||||||
|
});
|
||||||
|
return this.http.delete<any>(url, { headers });
|
||||||
|
}
|
||||||
|
|
||||||
postMasterRoomParam(data: any): Observable<any> {
|
postMasterRoomParam(data: any): Observable<any> {
|
||||||
const url = `https://kapi.absys.ninja/hemat/room`;
|
const url = `https://kapi.absys.ninja/hemat/room`;
|
||||||
const headers = new HttpHeaders({
|
const headers = new HttpHeaders({
|
||||||
|
@ -167,4 +185,13 @@ export class BuildingService {
|
||||||
});
|
});
|
||||||
return this.http.put<any>(url, data, { headers });
|
return this.http.put<any>(url, data, { headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
postBatchBuilding(data: any): Observable<any> {
|
||||||
|
const url = `https://kapi.absys.ninja/hemat/room-building/post-batch/room`;
|
||||||
|
const headers = new HttpHeaders({
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT'
|
||||||
|
});
|
||||||
|
return this.http.post<any>(url, data, { headers });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue