integrasi master floor dan master voltage
This commit is contained in:
parent
258d4f9cdb
commit
ca9b129494
|
@ -69,12 +69,12 @@ export const MenuSettingsConfig: MenuConfig = {
|
||||||
page: '/master/master-category'
|
page: '/master/master-category'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Master Location',
|
title: 'Master Voltage',
|
||||||
page: '/master/master-location'
|
page: '/master/master-voltage'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Master Location Room',
|
title: 'Master Floor',
|
||||||
page: '/master/master-location-room'
|
page: '/master/master-floor'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Master Type',
|
title: 'Master Type',
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
>
|
>
|
||||||
<m-card>
|
<m-card>
|
||||||
<ng-container mCardHeaderTitle>
|
<ng-container mCardHeaderTitle>
|
||||||
Master Location Table
|
Master Floor Table
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container mCardBody>
|
<ng-container mCardBody>
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
|
@ -29,6 +29,7 @@
|
||||||
<div class="col-md-6 text-right">
|
<div class="col-md-6 text-right">
|
||||||
<button
|
<button
|
||||||
class="btn btn-secondary"
|
class="btn btn-secondary"
|
||||||
|
(click)="openAddMasterModal()"
|
||||||
>
|
>
|
||||||
<i class="feather ft-plus"></i> Add new master
|
<i class="feather ft-plus"></i> Add new master
|
||||||
</button>
|
</button>
|
||||||
|
@ -37,7 +38,7 @@
|
||||||
<div class="card-dashboard">
|
<div class="card-dashboard">
|
||||||
<ngx-datatable
|
<ngx-datatable
|
||||||
class="bootstrap table-bordered"
|
class="bootstrap table-bordered"
|
||||||
[limit]="10"
|
[limit]="5"
|
||||||
[rows]="filteredRows"
|
[rows]="filteredRows"
|
||||||
[columnMode]="'force'"
|
[columnMode]="'force'"
|
||||||
[headerHeight]="50"
|
[headerHeight]="50"
|
||||||
|
@ -74,7 +75,7 @@
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</ngx-datatable-column>
|
</ngx-datatable-column>
|
||||||
<ngx-datatable-column
|
<ngx-datatable-column
|
||||||
name="Salary"
|
name="Status"
|
||||||
[flexGrow]="1"
|
[flexGrow]="1"
|
||||||
[minWidth]="90"
|
[minWidth]="90"
|
||||||
>
|
>
|
||||||
|
@ -85,7 +86,7 @@
|
||||||
ngx-datatable-cell-template
|
ngx-datatable-cell-template
|
||||||
let-value="value"
|
let-value="value"
|
||||||
>
|
>
|
||||||
{{ value }}
|
{{ value === '1' ? 'Aktif' : 'Tidak Aktif'}}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</ngx-datatable-column>
|
</ngx-datatable-column>
|
||||||
<ngx-datatable-column
|
<ngx-datatable-column
|
||||||
|
@ -98,20 +99,16 @@
|
||||||
let-rowIndex="rowIndex"
|
let-rowIndex="rowIndex"
|
||||||
let-row="row"
|
let-row="row"
|
||||||
>
|
>
|
||||||
<button
|
|
||||||
class="btn btn-sm btn-info mr-1"
|
|
||||||
|
|
||||||
>
|
|
||||||
<i class="ficon feather ft-eye"></i>
|
|
||||||
</button>
|
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm btn-warning mr-1"
|
class="btn btn-sm btn-warning mr-1"
|
||||||
|
(click)="editRow(row)"
|
||||||
|
|
||||||
>
|
>
|
||||||
<i class="ficon feather ft-edit"></i>
|
<i class="ficon feather ft-edit"></i>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm btn-danger"
|
class="btn btn-sm btn-danger"
|
||||||
|
(click)="deleteRow(row)"
|
||||||
|
|
||||||
>
|
>
|
||||||
<i class="ficon feather ft-trash-2"></i>
|
<i class="ficon feather ft-trash-2"></i>
|
|
@ -1,18 +1,18 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { MasterLocationComponent } from './master-location.component';
|
import { MasterFloorComponent } from './master-floor.component';
|
||||||
|
|
||||||
describe('MasterLocationComponent', () => {
|
describe('MasterFloorComponent', () => {
|
||||||
let component: MasterLocationComponent;
|
let component: MasterFloorComponent;
|
||||||
let fixture: ComponentFixture<MasterLocationComponent>;
|
let fixture: ComponentFixture<MasterFloorComponent>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [ MasterLocationComponent ]
|
declarations: [ MasterFloorComponent ]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(MasterLocationComponent);
|
fixture = TestBed.createComponent(MasterFloorComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
|
@ -0,0 +1,137 @@
|
||||||
|
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';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-master-floor',
|
||||||
|
templateUrl: './master-floor.component.html',
|
||||||
|
styleUrls: ['./master-floor.component.css']
|
||||||
|
})
|
||||||
|
export class MasterFloorComponent {
|
||||||
|
data: any;
|
||||||
|
filteredRows: any[];
|
||||||
|
searchTerm: string = "";
|
||||||
|
rows: any = [];
|
||||||
|
public breadcrumb: any;
|
||||||
|
dataMasterCategori: any;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private tableApiservice: TableApiService,
|
||||||
|
private modalService: NgbModal,
|
||||||
|
private router: Router,
|
||||||
|
private monitoringApiService: BuildingService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.breadcrumb = {
|
||||||
|
mainlabel: "Master Floor",
|
||||||
|
links: [
|
||||||
|
{
|
||||||
|
name: "Home",
|
||||||
|
isLink: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Master Floor",
|
||||||
|
isLink: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
this.fetchData();
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchData() {
|
||||||
|
this.monitoringApiService.getMasterData().subscribe((res) => {
|
||||||
|
this.data = res.results.data;
|
||||||
|
this.dataMasterCategori = res.results.data.find(
|
||||||
|
(item) => item.name === "master_floor"
|
||||||
|
);
|
||||||
|
this.filteredRows = this.dataMasterCategori.headerDetailParam;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
filterRows() {
|
||||||
|
if (!this.searchTerm) {
|
||||||
|
this.filteredRows = [
|
||||||
|
...this.data.find((item) => item.name === "master_floor")
|
||||||
|
.headerDetailParam,
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
this.filteredRows = this.data
|
||||||
|
.find((item) => item.name === "master_floor")
|
||||||
|
.headerDetailParam.filter((row) => this.rowContainsSearchTerm(row));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rowContainsSearchTerm(row: any): boolean {
|
||||||
|
const searchTermLC = this.searchTerm.toLowerCase();
|
||||||
|
return Object.values(row).some(
|
||||||
|
(value) =>
|
||||||
|
value !== null && value.toString().toLowerCase().includes(searchTermLC)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
openAddMasterModal() {
|
||||||
|
const modalRef = this.modalService.open(AddEditMasterComponent, {
|
||||||
|
size: "lg",
|
||||||
|
});
|
||||||
|
|
||||||
|
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
|
||||||
|
modalRef.componentInstance.mode = "add";
|
||||||
|
modalRef.result.then(
|
||||||
|
(result) => {
|
||||||
|
console.log(result);
|
||||||
|
if (result) {
|
||||||
|
this.monitoringApiService
|
||||||
|
.postHeaderDetailParam(result)
|
||||||
|
.subscribe((res) => {
|
||||||
|
console.log(res);
|
||||||
|
this.fetchData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(reason) => {
|
||||||
|
console.log(`Dismissed: ${reason}`);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
editRow(row) {
|
||||||
|
const modalRef = this.modalService.open(AddEditMasterComponent, {
|
||||||
|
size: "lg",
|
||||||
|
});
|
||||||
|
|
||||||
|
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
|
||||||
|
modalRef.componentInstance.dataRow = row;
|
||||||
|
modalRef.componentInstance.mode = "edit";
|
||||||
|
modalRef.result.then(
|
||||||
|
(result) => {
|
||||||
|
console.log(result);
|
||||||
|
if (result) {
|
||||||
|
this.monitoringApiService
|
||||||
|
.putHeaderDetailParam(result, row.id)
|
||||||
|
.subscribe((res) => {
|
||||||
|
console.log(res);
|
||||||
|
this.fetchData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(reason) => {
|
||||||
|
console.log(`Dismissed: ${reason}`);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteRow(row) {
|
||||||
|
const confirmDelete = confirm("Are you sure you want to delete this item?");
|
||||||
|
if (confirmDelete) {
|
||||||
|
this.monitoringApiService
|
||||||
|
.deleteHeaderDetailParam(row.id)
|
||||||
|
.subscribe((res) => {
|
||||||
|
this.fetchData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,23 +0,0 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { MasterLocationRoomComponent } from './master-location-room.component';
|
|
||||||
|
|
||||||
describe('MasterLocationRoomComponent', () => {
|
|
||||||
let component: MasterLocationRoomComponent;
|
|
||||||
let fixture: ComponentFixture<MasterLocationRoomComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ MasterLocationRoomComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
|
|
||||||
fixture = TestBed.createComponent(MasterLocationRoomComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,83 +0,0 @@
|
||||||
import { Component } from '@angular/core';
|
|
||||||
import { Router } from '@angular/router';
|
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
|
||||||
import { BlockUI, NgBlockUI } from 'ng-block-ui';
|
|
||||||
import { TableApiService } from 'src/app/_services/table-api.service';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-master-location-room',
|
|
||||||
templateUrl: './master-location-room.component.html',
|
|
||||||
styleUrls: ['./master-location-room.component.css']
|
|
||||||
})
|
|
||||||
export class MasterLocationRoomComponent {
|
|
||||||
data: any;
|
|
||||||
filteredRows: any[];
|
|
||||||
searchTerm: string = "";
|
|
||||||
rows: any = [];
|
|
||||||
public breadcrumb: any;
|
|
||||||
|
|
||||||
@BlockUI("zeroConfiguration") blockUIZeroConfiguration: NgBlockUI;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private tableApiservice: TableApiService,
|
|
||||||
private modalService: NgbModal,
|
|
||||||
private router: Router
|
|
||||||
) {}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.breadcrumb = {
|
|
||||||
mainlabel: "Master Location Room",
|
|
||||||
links: [
|
|
||||||
{
|
|
||||||
name: "Home",
|
|
||||||
isLink: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Master Location Room",
|
|
||||||
isLink: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
this.fetchData();
|
|
||||||
}
|
|
||||||
|
|
||||||
fetchData() {
|
|
||||||
this.tableApiservice.getTableInitialisationData().subscribe((response) => {
|
|
||||||
this.data = response;
|
|
||||||
this.filteredRows = this.data.rows;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
filterRows() {
|
|
||||||
if (!this.searchTerm) {
|
|
||||||
this.filteredRows = [...this.data.rows];
|
|
||||||
} else {
|
|
||||||
this.filteredRows = this.data.rows.filter((row) =>
|
|
||||||
this.rowContainsSearchTerm(row)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rowContainsSearchTerm(row: any): boolean {
|
|
||||||
const searchTermLC = this.searchTerm.toLowerCase();
|
|
||||||
return Object.values(row).some(
|
|
||||||
(value) =>
|
|
||||||
value !== null &&
|
|
||||||
value.toString().toLowerCase().includes(searchTermLC)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
viewRow(row) {
|
|
||||||
console.log("View row:", row);
|
|
||||||
this.router.navigate(["/device/view", row.name]);
|
|
||||||
}
|
|
||||||
|
|
||||||
editRow(row) {
|
|
||||||
console.log("Edit row:", row);
|
|
||||||
this.router.navigate(["/device/edit", row.name]);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteRow(row) {
|
|
||||||
console.log("Delete row:", row);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,83 +0,0 @@
|
||||||
import { Component } from '@angular/core';
|
|
||||||
import { Router } from '@angular/router';
|
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
|
||||||
import { BlockUI, NgBlockUI } from 'ng-block-ui';
|
|
||||||
import { TableApiService } from 'src/app/_services/table-api.service';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-master-location',
|
|
||||||
templateUrl: './master-location.component.html',
|
|
||||||
styleUrls: ['./master-location.component.css']
|
|
||||||
})
|
|
||||||
export class MasterLocationComponent {
|
|
||||||
data: any;
|
|
||||||
filteredRows: any[];
|
|
||||||
searchTerm: string = "";
|
|
||||||
rows: any = [];
|
|
||||||
public breadcrumb: any;
|
|
||||||
|
|
||||||
@BlockUI("zeroConfiguration") blockUIZeroConfiguration: NgBlockUI;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private tableApiservice: TableApiService,
|
|
||||||
private modalService: NgbModal,
|
|
||||||
private router: Router
|
|
||||||
) {}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.breadcrumb = {
|
|
||||||
mainlabel: "Master Location",
|
|
||||||
links: [
|
|
||||||
{
|
|
||||||
name: "Home",
|
|
||||||
isLink: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Master Location",
|
|
||||||
isLink: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
this.fetchData();
|
|
||||||
}
|
|
||||||
|
|
||||||
fetchData() {
|
|
||||||
this.tableApiservice.getTableInitialisationData().subscribe((response) => {
|
|
||||||
this.data = response;
|
|
||||||
this.filteredRows = this.data.rows;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
filterRows() {
|
|
||||||
if (!this.searchTerm) {
|
|
||||||
this.filteredRows = [...this.data.rows];
|
|
||||||
} else {
|
|
||||||
this.filteredRows = this.data.rows.filter((row) =>
|
|
||||||
this.rowContainsSearchTerm(row)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rowContainsSearchTerm(row: any): boolean {
|
|
||||||
const searchTermLC = this.searchTerm.toLowerCase();
|
|
||||||
return Object.values(row).some(
|
|
||||||
(value) =>
|
|
||||||
value !== null &&
|
|
||||||
value.toString().toLowerCase().includes(searchTermLC)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
viewRow(row) {
|
|
||||||
console.log("View row:", row);
|
|
||||||
this.router.navigate(["/device/view", row.name]);
|
|
||||||
}
|
|
||||||
|
|
||||||
editRow(row) {
|
|
||||||
console.log("Edit row:", row);
|
|
||||||
this.router.navigate(["/device/edit", row.name]);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteRow(row) {
|
|
||||||
console.log("Delete row:", row);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -12,7 +12,7 @@
|
||||||
>
|
>
|
||||||
<m-card>
|
<m-card>
|
||||||
<ng-container mCardHeaderTitle>
|
<ng-container mCardHeaderTitle>
|
||||||
Master Location Room Table
|
Master Voltage Table
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container mCardBody>
|
<ng-container mCardBody>
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
|
@ -29,6 +29,7 @@
|
||||||
<div class="col-md-6 text-right">
|
<div class="col-md-6 text-right">
|
||||||
<button
|
<button
|
||||||
class="btn btn-secondary"
|
class="btn btn-secondary"
|
||||||
|
(click)="openAddMasterModal()"
|
||||||
>
|
>
|
||||||
<i class="feather ft-plus"></i> Add new master
|
<i class="feather ft-plus"></i> Add new master
|
||||||
</button>
|
</button>
|
||||||
|
@ -37,7 +38,7 @@
|
||||||
<div class="card-dashboard">
|
<div class="card-dashboard">
|
||||||
<ngx-datatable
|
<ngx-datatable
|
||||||
class="bootstrap table-bordered"
|
class="bootstrap table-bordered"
|
||||||
[limit]="10"
|
[limit]="5"
|
||||||
[rows]="filteredRows"
|
[rows]="filteredRows"
|
||||||
[columnMode]="'force'"
|
[columnMode]="'force'"
|
||||||
[headerHeight]="50"
|
[headerHeight]="50"
|
||||||
|
@ -74,7 +75,7 @@
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</ngx-datatable-column>
|
</ngx-datatable-column>
|
||||||
<ngx-datatable-column
|
<ngx-datatable-column
|
||||||
name="Salary"
|
name="Status"
|
||||||
[flexGrow]="1"
|
[flexGrow]="1"
|
||||||
[minWidth]="90"
|
[minWidth]="90"
|
||||||
>
|
>
|
||||||
|
@ -85,7 +86,7 @@
|
||||||
ngx-datatable-cell-template
|
ngx-datatable-cell-template
|
||||||
let-value="value"
|
let-value="value"
|
||||||
>
|
>
|
||||||
{{ value }}
|
{{ value === '1' ? 'Aktif' : 'Tidak Aktif'}}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</ngx-datatable-column>
|
</ngx-datatable-column>
|
||||||
<ngx-datatable-column
|
<ngx-datatable-column
|
||||||
|
@ -98,20 +99,16 @@
|
||||||
let-rowIndex="rowIndex"
|
let-rowIndex="rowIndex"
|
||||||
let-row="row"
|
let-row="row"
|
||||||
>
|
>
|
||||||
<button
|
|
||||||
class="btn btn-sm btn-info mr-1"
|
|
||||||
|
|
||||||
>
|
|
||||||
<i class="ficon feather ft-eye"></i>
|
|
||||||
</button>
|
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm btn-warning mr-1"
|
class="btn btn-sm btn-warning mr-1"
|
||||||
|
(click)="editRow(row)"
|
||||||
|
|
||||||
>
|
>
|
||||||
<i class="ficon feather ft-edit"></i>
|
<i class="ficon feather ft-edit"></i>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm btn-danger"
|
class="btn btn-sm btn-danger"
|
||||||
|
(click)="deleteRow(row)"
|
||||||
|
|
||||||
>
|
>
|
||||||
<i class="ficon feather ft-trash-2"></i>
|
<i class="ficon feather ft-trash-2"></i>
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { MasterVoltageComponent } from './master-voltage.component';
|
||||||
|
|
||||||
|
describe('MasterVoltageComponent', () => {
|
||||||
|
let component: MasterVoltageComponent;
|
||||||
|
let fixture: ComponentFixture<MasterVoltageComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ MasterVoltageComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(MasterVoltageComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,137 @@
|
||||||
|
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';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-master-voltage',
|
||||||
|
templateUrl: './master-voltage.component.html',
|
||||||
|
styleUrls: ['./master-voltage.component.css']
|
||||||
|
})
|
||||||
|
export class MasterVoltageComponent {
|
||||||
|
data: any;
|
||||||
|
filteredRows: any[];
|
||||||
|
searchTerm: string = "";
|
||||||
|
rows: any = [];
|
||||||
|
public breadcrumb: any;
|
||||||
|
dataMasterCategori: any;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private tableApiservice: TableApiService,
|
||||||
|
private modalService: NgbModal,
|
||||||
|
private router: Router,
|
||||||
|
private monitoringApiService: BuildingService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.breadcrumb = {
|
||||||
|
mainlabel: "Master Voltage",
|
||||||
|
links: [
|
||||||
|
{
|
||||||
|
name: "Home",
|
||||||
|
isLink: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Master Voltage",
|
||||||
|
isLink: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
this.fetchData();
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchData() {
|
||||||
|
this.monitoringApiService.getMasterData().subscribe((res) => {
|
||||||
|
this.data = res.results.data;
|
||||||
|
this.dataMasterCategori = res.results.data.find(
|
||||||
|
(item) => item.name === "master_voltage"
|
||||||
|
);
|
||||||
|
this.filteredRows = this.dataMasterCategori.headerDetailParam;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
filterRows() {
|
||||||
|
if (!this.searchTerm) {
|
||||||
|
this.filteredRows = [
|
||||||
|
...this.data.find((item) => item.name === "master_voltage")
|
||||||
|
.headerDetailParam,
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
this.filteredRows = this.data
|
||||||
|
.find((item) => item.name === "master_voltage")
|
||||||
|
.headerDetailParam.filter((row) => this.rowContainsSearchTerm(row));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rowContainsSearchTerm(row: any): boolean {
|
||||||
|
const searchTermLC = this.searchTerm.toLowerCase();
|
||||||
|
return Object.values(row).some(
|
||||||
|
(value) =>
|
||||||
|
value !== null && value.toString().toLowerCase().includes(searchTermLC)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
openAddMasterModal() {
|
||||||
|
const modalRef = this.modalService.open(AddEditMasterComponent, {
|
||||||
|
size: "lg",
|
||||||
|
});
|
||||||
|
|
||||||
|
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
|
||||||
|
modalRef.componentInstance.mode = "add";
|
||||||
|
modalRef.result.then(
|
||||||
|
(result) => {
|
||||||
|
console.log(result);
|
||||||
|
if (result) {
|
||||||
|
this.monitoringApiService
|
||||||
|
.postHeaderDetailParam(result)
|
||||||
|
.subscribe((res) => {
|
||||||
|
console.log(res);
|
||||||
|
this.fetchData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(reason) => {
|
||||||
|
console.log(`Dismissed: ${reason}`);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
editRow(row) {
|
||||||
|
const modalRef = this.modalService.open(AddEditMasterComponent, {
|
||||||
|
size: "lg",
|
||||||
|
});
|
||||||
|
|
||||||
|
modalRef.componentInstance.headerId = this.dataMasterCategori.id;
|
||||||
|
modalRef.componentInstance.dataRow = row;
|
||||||
|
modalRef.componentInstance.mode = "edit";
|
||||||
|
modalRef.result.then(
|
||||||
|
(result) => {
|
||||||
|
console.log(result);
|
||||||
|
if (result) {
|
||||||
|
this.monitoringApiService
|
||||||
|
.putHeaderDetailParam(result, row.id)
|
||||||
|
.subscribe((res) => {
|
||||||
|
console.log(res);
|
||||||
|
this.fetchData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(reason) => {
|
||||||
|
console.log(`Dismissed: ${reason}`);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteRow(row) {
|
||||||
|
const confirmDelete = confirm("Are you sure you want to delete this item?");
|
||||||
|
if (confirmDelete) {
|
||||||
|
this.monitoringApiService
|
||||||
|
.deleteHeaderDetailParam(row.id)
|
||||||
|
.subscribe((res) => {
|
||||||
|
this.fetchData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,6 @@
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { MasterCategoryComponent } from './master-category/master-category.component';
|
import { MasterCategoryComponent } from './master-category/master-category.component';
|
||||||
import { MasterLocationComponent } from './master-location/master-location.component';
|
|
||||||
import { MasterLocationRoomComponent } from './master-location-room/master-location-room.component';
|
|
||||||
import { MasterTypeComponent } from './master-type/master-type.component';
|
import { MasterTypeComponent } from './master-type/master-type.component';
|
||||||
|
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
|
@ -22,20 +20,22 @@ import { MasterDurationUseComponent } from './master-duration-use/master-duratio
|
||||||
import { MasterUserComponent } from './master-user/master-user.component';
|
import { MasterUserComponent } from './master-user/master-user.component';
|
||||||
import { MasterRoleComponent } from './master-role/master-role.component';
|
import { MasterRoleComponent } from './master-role/master-role.component';
|
||||||
import { AddEditMasterComponent } from './add-edit-master/add-edit-master.component';
|
import { AddEditMasterComponent } from './add-edit-master/add-edit-master.component';
|
||||||
|
import { MasterVoltageComponent } from './master-voltage/master-voltage.component';
|
||||||
|
import { MasterFloorComponent } from './master-floor/master-floor.component';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
MasterCategoryComponent,
|
MasterCategoryComponent,
|
||||||
MasterLocationComponent,
|
|
||||||
MasterLocationRoomComponent,
|
|
||||||
MasterTypeComponent,
|
MasterTypeComponent,
|
||||||
MasterStatusComponent,
|
MasterStatusComponent,
|
||||||
MasterDurationUseComponent,
|
MasterDurationUseComponent,
|
||||||
MasterUserComponent,
|
MasterUserComponent,
|
||||||
MasterRoleComponent,
|
MasterRoleComponent,
|
||||||
AddEditMasterComponent
|
AddEditMasterComponent,
|
||||||
|
MasterVoltageComponent,
|
||||||
|
MasterFloorComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
|
@ -58,12 +58,12 @@ import { AddEditMasterComponent } from './add-edit-master/add-edit-master.compon
|
||||||
component: MasterCategoryComponent
|
component: MasterCategoryComponent
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'master-location',
|
path: 'master-floor',
|
||||||
component: MasterLocationComponent
|
component: MasterFloorComponent
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'master-location-room',
|
path: 'master-voltage',
|
||||||
component: MasterLocationRoomComponent
|
component: MasterVoltageComponent
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'master-type',
|
path: 'master-type',
|
||||||
|
|
Loading…
Reference in New Issue