integrasi master building dan penyasuaian UI dashboard monitoring building
This commit is contained in:
parent
bb10d57139
commit
608c53ab66
|
@ -95,6 +95,14 @@ export const MenuSettingsConfig: MenuConfig = {
|
|||
{
|
||||
title: 'Master Role',
|
||||
page: '/master/master-role'
|
||||
},
|
||||
{
|
||||
title: 'Master Room',
|
||||
page: '/master/master-room'
|
||||
},
|
||||
{
|
||||
title: 'Master Building',
|
||||
page: '/master/master-building'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -17,6 +17,9 @@ export class AddEditMasterComponent implements OnInit{
|
|||
|
||||
ngOnInit() {
|
||||
this.createForm();
|
||||
console.log(this.dataRow);
|
||||
console.log(this.headerId);
|
||||
console.log(this.mode);
|
||||
if (this.dataRow) {
|
||||
this.editForm();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/* modal-add-edit.component.css */
|
||||
::ng-deep .modal-backdrop.show {
|
||||
z-index: auto !important;
|
||||
}
|
||||
|
||||
::ng-deep .input-group-append .btn {
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
border-radius: 0;
|
||||
border-left: 0;
|
||||
flex-grow: 0;
|
||||
border-left: 1px solid #ced4da;
|
||||
padding: 0.375rem 0.75rem;
|
||||
}
|
||||
|
||||
::ng-deep .input-group {
|
||||
display: flex;
|
||||
flex-wrap: nowrap; /* Prevents wrapping of the items */
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
::ng-deep .form-control {
|
||||
flex-grow: 1; /* Ensures select takes up available space */
|
||||
padding-right: 0.5rem;
|
||||
}
|
||||
|
||||
::ng-deep .input-group select,
|
||||
::ng-deep .input-group .input-group-append .btn {
|
||||
padding-right: 5px; /* Adjust padding if necessary */
|
||||
}
|
||||
|
||||
::ng-deep .input-group .form-control {
|
||||
margin-right: 2px; /* Adjust margin to make space */
|
||||
}
|
||||
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.form-control {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: calc(1.5em + 0.75rem + 2px);
|
||||
padding: 0.375rem 0.75rem;
|
||||
font-size: 1rem;
|
||||
font-weight: 400;
|
||||
line-height: 1.5;
|
||||
color: #495057;
|
||||
background-color: #fff;
|
||||
background-clip: padding-box;
|
||||
border: 1px solid #ced4da;
|
||||
border-radius: 0.25rem;
|
||||
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
<div class="modal-header">
|
||||
<h4 class="modal-title">Add New Row</h4>
|
||||
<button type="button" class="close" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form [formGroup]="myForm">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="name">Name Building:</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="name"
|
||||
formControlName="name"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="name">Email:</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="email"
|
||||
formControlName="email"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="phone">Phone:</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="phone"
|
||||
formControlName="phone"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="owner">Owner:</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="owner"
|
||||
formControlName="owner"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="address">Address:</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="address"
|
||||
formControlName="address"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="statusId">Status:</label>
|
||||
<!-- <select
|
||||
id="projectinput5"
|
||||
class="form-control"
|
||||
formControlName="statusId"
|
||||
>
|
||||
<option value="1">Aktif</option>
|
||||
<option value="0">Tidak Aktif</option>
|
||||
</select> -->
|
||||
|
||||
<select
|
||||
id="projectinput5"
|
||||
class="form-control"
|
||||
formControlName="statusId"
|
||||
>
|
||||
<option *ngFor="let data of filteredDataStatus" [value]="data.id">
|
||||
{{ data.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-secondary"
|
||||
(click)="activeModal.dismiss('Cross click')"
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary" (click)="addRow()">
|
||||
Save Changes
|
||||
</button>
|
||||
</div>
|
|
@ -0,0 +1,23 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AddEditMasterBuildingComponent } from './add-edit-master-building.component';
|
||||
|
||||
describe('AddEditMasterBuildingComponent', () => {
|
||||
let component: AddEditMasterBuildingComponent;
|
||||
let fixture: ComponentFixture<AddEditMasterBuildingComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ AddEditMasterBuildingComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(AddEditMasterBuildingComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,84 @@
|
|||
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-building",
|
||||
templateUrl: "./add-edit-master-building.component.html",
|
||||
styleUrls: ["./add-edit-master-building.component.css"],
|
||||
})
|
||||
export class AddEditMasterBuildingComponent {
|
||||
@Input() dataRow: any;
|
||||
@Input() mode: any;
|
||||
myForm: FormGroup;
|
||||
|
||||
data: any;
|
||||
dataStatus: any[];
|
||||
filteredDataStatus: any[];
|
||||
dataMasterStatus: any;
|
||||
|
||||
constructor(
|
||||
public activeModal: NgbActiveModal,
|
||||
private fb: FormBuilder,
|
||||
private monitoringApiService: BuildingService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.createForm();
|
||||
this.listDataStatus();
|
||||
|
||||
if (this.dataRow) {
|
||||
this.editForm();
|
||||
}
|
||||
}
|
||||
|
||||
createForm() {
|
||||
this.myForm = this.fb.group({
|
||||
name: ["", Validators.required],
|
||||
statusId: [0, Validators.required],
|
||||
email: ["", Validators.required],
|
||||
owner: ["", Validators.required],
|
||||
address: ["", Validators.required],
|
||||
phone: ["", Validators.required],
|
||||
});
|
||||
}
|
||||
|
||||
editForm() {
|
||||
this.myForm = this.fb.group({
|
||||
id: this.dataRow.id,
|
||||
name: this.dataRow.name,
|
||||
statusId: this.dataRow.statusId,
|
||||
email: this.dataRow.email,
|
||||
owner: this.dataRow.owner,
|
||||
address: this.dataRow.address,
|
||||
phone: this.dataRow.phone,
|
||||
});
|
||||
}
|
||||
|
||||
listDataStatus() {
|
||||
this.monitoringApiService.getMasterData().subscribe((res) => {
|
||||
this.data = res.results.data;
|
||||
this.dataMasterStatus = res.results.data.find(
|
||||
(item) => item.name === "master_status"
|
||||
);
|
||||
this.dataStatus = this.dataMasterStatus.headerDetailParam;
|
||||
this.filteredDataStatus = this.dataStatus.filter(
|
||||
(item) => item.status === "1"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
addRow() {
|
||||
if (this.myForm.valid) {
|
||||
this.activeModal.close(this.myForm.value);
|
||||
}
|
||||
}
|
||||
|
||||
addDepartment() {
|
||||
let newDept = prompt("Enter new department name:");
|
||||
if (newDept) {
|
||||
alert(`Department ${newDept} added! (simulated)`);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,190 @@
|
|||
:host ::ng-deep .ngx-datatable.bootstrap .datatable-header .datatable-header-cell .datatable-header-cell-label {
|
||||
font-family: inherit;
|
||||
font-size: medium;
|
||||
font-weight: bold;
|
||||
color: #6B6F82;
|
||||
}
|
||||
:host ::ng-deep .ngx-datatable .datatable-row-center, .ngx-datatable .datatable-row-group, .ngx-datatable .datatable-row-right {
|
||||
position: relative;
|
||||
height: 50px !important;
|
||||
}
|
||||
|
||||
:host ::ng-deep .datatable-icon-right:before {
|
||||
font-family: 'icofont';
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
:host ::ng-deep .datatable-icon-skip:before {
|
||||
font-family: 'icofont';
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
:host ::ng-deep .datatable-icon-left:before {
|
||||
font-family: 'icofont';
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
:host ::ng-deep .datatable-icon-left:before {
|
||||
content: "\2039";
|
||||
font-size: x-large;
|
||||
}
|
||||
|
||||
:host ::ng-deep .datatable-icon-prev:before {
|
||||
content: "\00AB";
|
||||
font-size: x-large;
|
||||
}
|
||||
|
||||
:host ::ng-deep .datatable-icon-right:before {
|
||||
content: "\203A";
|
||||
font-size: x-large;
|
||||
}
|
||||
|
||||
:host ::ng-deep .datatable-icon-skip:before {
|
||||
content: "\00BB";
|
||||
font-size: x-large;
|
||||
}
|
||||
|
||||
:host ::ng-deep .ngx-datatable.bootstrap .datatable-footer .datatable-pager .datatable-icon-left,
|
||||
.ngx-datatable.bootstrap .datatable-footer .datatable-pager .datatable-icon-right,
|
||||
.ngx-datatable.bootstrap .datatable-footer .datatable-pager .datatable-icon-prev {
|
||||
font-size: 16px;
|
||||
line-height: 22px;
|
||||
padding: 0px 09px;
|
||||
background-color: #d4d2e7;
|
||||
}
|
||||
|
||||
:host ::ng-deep .ngx-datatable.bootstrap .datatable-footer .datatable-pager .datatable-icon-right,
|
||||
.ngx-datatable.bootstrap .datatable-footer .datatable-pager .datatable-icon-right {
|
||||
font-size: 16px;
|
||||
line-height: 22px;
|
||||
padding: 0px 09px;
|
||||
background-color: #d4d2e7;
|
||||
}
|
||||
|
||||
:host ::ng-deep .ngx-datatable.bootstrap .datatable-footer .datatable-pager .datatable-icon-skip {
|
||||
font-size: 16px;
|
||||
line-height: 22px;
|
||||
padding: 0px 09px;
|
||||
background-color: #d4d2e7;
|
||||
}
|
||||
|
||||
:host ::ng-deep .ngx-datatable.bootstrap .datatable-footer .datatable-pager .datatable-icon-prev {
|
||||
font-size: 16px;
|
||||
line-height: 22px;
|
||||
padding: 0px 09px;
|
||||
background-color: #d4d2e7;
|
||||
}
|
||||
|
||||
:host ::ng-deep .datatable-footer .datatable-pager ul li:not(.disabled).active a,
|
||||
.ngx-datatable.bootstrap[_ngcontent-c11] .datatable-footer[_ngcontent-c11] .datatable-pager[_ngcontent-c11] ul[_ngcontent-c11] li[_ngcontent-c11]:not(.disabled):hover a[_ngcontent-c11] {
|
||||
background-color: #d4d2e7;
|
||||
font-weight: bold;
|
||||
font-size: larger;
|
||||
}
|
||||
|
||||
:host ::ng-deep .ngx-datatable.bootstrap .datatable-footer .datatable-pager a {
|
||||
height: 32px;
|
||||
min-width: 34px;
|
||||
line-height: 22px;
|
||||
padding: 0;
|
||||
border-radius: 3px;
|
||||
margin: 0 3px;
|
||||
text-align: center;
|
||||
vertical-align: top;
|
||||
padding-top: 3px;
|
||||
text-decoration: none;
|
||||
vertical-align: bottom;
|
||||
color: #7c8091;
|
||||
}
|
||||
|
||||
:host ::ng-deep .ngx-datatable.bootstrap .datatable-footer .datatable-pager .datatable-icon-left,
|
||||
.ngx-datatable.bootstrap[_ngcontent-c11] .datatable-footer[_ngcontent-c11] .datatable-pager[_ngcontent-c11] .datatable-icon-right[_ngcontent-c11],
|
||||
.ngx-datatable.bootstrap[_ngcontent-c11] .datatable-footer[_ngcontent-c11] .datatable-pager[_ngcontent-c11] .datatable-icon-prev[_ngcontent-c11] {
|
||||
font-size: 14px;
|
||||
line-height: 9px;
|
||||
padding: 0px 08px;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
:host ::ng-deep .ngx-datatable.bootstrap .datatable-footer .datatable-pager .datatable-icon-left,
|
||||
.ngx-datatable.bootstrap[_ngcontent-c11] .datatable-footer[_ngcontent-c11] .datatable-pager[_ngcontent-c11] .datatable-icon-right[_ngcontent-c11],
|
||||
.ngx-datatable.bootstrap[_ngcontent-c11] .datatable-footer[_ngcontent-c11] .datatable-pager[_ngcontent-c11] .datatable-icon-prev[_ngcontent-c11] {
|
||||
font-size: 0px;
|
||||
line-height: 22px;
|
||||
padding: 0px 09px;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
:host ::ng-deep .ngx-datatable.bootstrap .datatable-footer .datatable-pager .datatable-icon-right,
|
||||
.ngx-datatable.bootstrap[_ngcontent-c11] .datatable-footer[_ngcontent-c11] .datatable-pager[_ngcontent-c11] .datatable-icon-right[_ngcontent-c11],
|
||||
.ngx-datatable.bootstrap[_ngcontent-c11] .datatable-footer[_ngcontent-c11] .datatable-pager[_ngcontent-c11] .datatable-icon-prev[_ngcontent-c11] {
|
||||
font-size: 0px;
|
||||
line-height: 22px;
|
||||
padding: 0px 09px;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
:host ::ng-deep .ngx-datatable.bootstrap .datatable-footer .datatable-pager .datatable-icon-skip,
|
||||
.ngx-datatable.bootstrap[_ngcontent-c11] .datatable-footer[_ngcontent-c11] .datatable-pager[_ngcontent-c11] .datatable-icon-right[_ngcontent-c11],
|
||||
.ngx-datatable.bootstrap[_ngcontent-c11] .datatable-footer[_ngcontent-c11] .datatable-pager[_ngcontent-c11] .datatable-icon-prev[_ngcontent-c11] {
|
||||
font-size: 0px;
|
||||
line-height: 22px;
|
||||
padding: 0px 09px;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
:host ::ng-deep .ngx-datatable.bootstrap .datatable-footer .datatable-pager .datatable-icon-prev,
|
||||
.ngx-datatable.bootstrap[_ngcontent-c11] .datatable-footer[_ngcontent-c11] .datatable-pager[_ngcontent-c11] .datatable-icon-right[_ngcontent-c11],
|
||||
.ngx-datatable.bootstrap[_ngcontent-c11] .datatable-footer[_ngcontent-c11] .datatable-pager[_ngcontent-c11] .datatable-icon-prev[_ngcontent-c11] {
|
||||
font-size: 0px;
|
||||
line-height: 22px;
|
||||
padding: 0px 09px;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
:host ::ng-deep .ngx-datatable.bootstrap .datatable-footer .datatable-pager ul li:not(.disabled):hover a {
|
||||
background-color: #545454;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
|
||||
}
|
||||
|
||||
:host ::ng-deep .ngx-datatable.bootstrap .datatable-footer .datatable-pager ul li:not(.disabled).active a,
|
||||
.ngx-datatable.bootstrap .datatable-footer .datatable-pager ul li:not(.disabled):hover a {
|
||||
background-color: #545454;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
}
|
||||
|
||||
:host ::ng-deep .ngx-datatable.bootstrap .datatable-footer {
|
||||
background: #727e8e;
|
||||
color: #ededed;
|
||||
margin-top: -1px;
|
||||
overflow: inherit;
|
||||
}
|
||||
|
||||
:host ::ng-deep .ngx-datatable.bootstrap .datatable-header {
|
||||
font-weight: bold;
|
||||
height: unset !important;
|
||||
overflow: inherit
|
||||
}
|
||||
|
||||
:host ::ng-deep .ngx-datatable .datatable-footer .datatable-pager {
|
||||
flex: 0 0 0%;
|
||||
}
|
||||
|
||||
:host ::ng-deep .ngx-datatable .datatable-footer .datatable-pager .pager {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
:host ::ng-deep .block-ui-wrapper {
|
||||
background: rgba(255, 249, 249, 0.5) !important;
|
||||
}
|
||||
:host ::ng-deep .ngx-datatable .datatable-footer .selected-count .datatable-pager {
|
||||
flex: 0 0 0%;
|
||||
}
|
||||
|
||||
:host ::ng-deep .ngx-datatable {
|
||||
display: -webkit-box;
|
||||
}
|
||||
|
|
@ -0,0 +1,188 @@
|
|||
<div class="app-content content">
|
||||
<div class="content-wrapper">
|
||||
<div class="content-header row mb-1">
|
||||
<app-breadcrumb class="col-12" [breadcrumb]="breadcrumb"></app-breadcrumb>
|
||||
</div>
|
||||
<div class="content-body">
|
||||
<section id="configuration">
|
||||
<div class="row">
|
||||
<div
|
||||
class="col-12"
|
||||
*blockUI="'zeroConfiguration'; message: 'Loading'"
|
||||
>
|
||||
<m-card>
|
||||
<ng-container mCardHeaderTitle>
|
||||
Master Building Table
|
||||
</ng-container>
|
||||
<ng-container mCardBody>
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-6">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
placeholder="Search..."
|
||||
[(ngModel)]="searchTerm"
|
||||
(input)="filterRows()"
|
||||
(touchstart)="onTouchStart($event)"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-md-6 text-right">
|
||||
<button
|
||||
class="btn btn-secondary"
|
||||
(click)="openAddMasterModal()"
|
||||
>
|
||||
<i class="feather ft-plus"></i> Add new master
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-dashboard">
|
||||
<ngx-datatable
|
||||
class="bootstrap table-bordered"
|
||||
[limit]="5"
|
||||
[rows]="filteredRows"
|
||||
[columnMode]="'force'"
|
||||
[headerHeight]="50"
|
||||
[footerHeight]="50"
|
||||
[rowHeight]="50"
|
||||
fxFlex="auto"
|
||||
[scrollbarH]="true"
|
||||
>
|
||||
<ngx-datatable-column
|
||||
name="#"
|
||||
[flexGrow]="1"
|
||||
[minWidth]="10"
|
||||
>
|
||||
<ng-template
|
||||
ngx-datatable-cell-template
|
||||
let-rowIndex="rowIndex"
|
||||
>
|
||||
{{ rowIndex + 1 }}
|
||||
</ng-template>
|
||||
</ngx-datatable-column>
|
||||
<ngx-datatable-column
|
||||
name="Name"
|
||||
[flexGrow]="1"
|
||||
[minWidth]="90"
|
||||
>
|
||||
<ng-template ngx-datatable-header-template>
|
||||
<span>Building Name</span>
|
||||
</ng-template>
|
||||
<ng-template
|
||||
let-value="value"
|
||||
ngx-datatable-cell-template
|
||||
>
|
||||
{{ value }}
|
||||
</ng-template>
|
||||
</ngx-datatable-column>
|
||||
<ngx-datatable-column
|
||||
name="email"
|
||||
[flexGrow]="1"
|
||||
[minWidth]="90"
|
||||
>
|
||||
<ng-template ngx-datatable-header-template>
|
||||
<span>Email</span>
|
||||
</ng-template>
|
||||
<ng-template
|
||||
let-value="value"
|
||||
ngx-datatable-cell-template
|
||||
>
|
||||
{{ value }}
|
||||
</ng-template>
|
||||
</ngx-datatable-column>
|
||||
<ngx-datatable-column
|
||||
name="phone"
|
||||
[flexGrow]="1"
|
||||
[minWidth]="90"
|
||||
>
|
||||
<ng-template ngx-datatable-header-template>
|
||||
<span>Phone</span>
|
||||
</ng-template>
|
||||
<ng-template
|
||||
let-value="value"
|
||||
ngx-datatable-cell-template
|
||||
>
|
||||
{{ value }}
|
||||
</ng-template>
|
||||
</ngx-datatable-column>
|
||||
<ngx-datatable-column
|
||||
name="owner"
|
||||
[flexGrow]="1"
|
||||
[minWidth]="90"
|
||||
>
|
||||
<ng-template ngx-datatable-header-template>
|
||||
<span>Owner</span>
|
||||
</ng-template>
|
||||
<ng-template
|
||||
let-value="value"
|
||||
ngx-datatable-cell-template
|
||||
>
|
||||
{{ value }}
|
||||
</ng-template>
|
||||
</ngx-datatable-column>
|
||||
<ngx-datatable-column
|
||||
name="address"
|
||||
[flexGrow]="1"
|
||||
[minWidth]="90"
|
||||
>
|
||||
<ng-template ngx-datatable-header-template>
|
||||
<span>Address</span>
|
||||
</ng-template>
|
||||
<ng-template
|
||||
let-value="value"
|
||||
ngx-datatable-cell-template
|
||||
>
|
||||
{{ value }}
|
||||
</ng-template>
|
||||
</ngx-datatable-column>
|
||||
<ngx-datatable-column
|
||||
name="statusId"
|
||||
[flexGrow]="1"
|
||||
[minWidth]="90"
|
||||
>
|
||||
<ng-template ngx-datatable-header-template>
|
||||
<span>Status</span>
|
||||
</ng-template>
|
||||
<ng-template
|
||||
ngx-datatable-cell-template
|
||||
let-value="value"
|
||||
>
|
||||
{{ value === 2 ? 'Aktif' : 'Tidak Aktif'}}
|
||||
</ng-template>
|
||||
</ngx-datatable-column>
|
||||
<ngx-datatable-column
|
||||
name="Actions"
|
||||
[flexGrow]="1"
|
||||
[minWidth]="150"
|
||||
>
|
||||
<ng-template
|
||||
ngx-datatable-cell-template
|
||||
let-rowIndex="rowIndex"
|
||||
let-row="row"
|
||||
>
|
||||
<button
|
||||
class="btn btn-sm btn-warning mr-1"
|
||||
(click)="editRow(row)"
|
||||
|
||||
>
|
||||
<i class="ficon feather ft-edit"></i>
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-sm btn-danger"
|
||||
(click)="deleteRow(row)"
|
||||
|
||||
>
|
||||
<i class="ficon feather ft-trash-2"></i>
|
||||
</button>
|
||||
</ng-template>
|
||||
</ngx-datatable-column>
|
||||
</ngx-datatable>
|
||||
</div>
|
||||
</ng-container>
|
||||
</m-card>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { MasterBuildingComponent } from './master-building.component';
|
||||
|
||||
describe('MasterBuildingComponent', () => {
|
||||
let component: MasterBuildingComponent;
|
||||
let fixture: ComponentFixture<MasterBuildingComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ MasterBuildingComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(MasterBuildingComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,125 @@
|
|||
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';
|
||||
|
||||
@Component({
|
||||
selector: 'app-master-building',
|
||||
templateUrl: './master-building.component.html',
|
||||
styleUrls: ['./master-building.component.css']
|
||||
})
|
||||
export class MasterBuildingComponent {
|
||||
data: any;
|
||||
filteredRows: any[];
|
||||
searchTerm: string = "";
|
||||
rows: any = [];
|
||||
public breadcrumb: any;
|
||||
|
||||
constructor(
|
||||
private tableApiservice: TableApiService,
|
||||
private modalService: NgbModal,
|
||||
private router: Router,
|
||||
private monitoringApiService: BuildingService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.breadcrumb = {
|
||||
mainlabel: "Master Building",
|
||||
links: [
|
||||
{
|
||||
name: "Home",
|
||||
isLink: false,
|
||||
},
|
||||
{
|
||||
name: "Master Building",
|
||||
isLink: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
this.fetchData();
|
||||
}
|
||||
|
||||
fetchData() {
|
||||
this.monitoringApiService.getMasterBuildingData().subscribe((res) => {
|
||||
this.data = res.results.data;
|
||||
this.filteredRows = this.data;
|
||||
});
|
||||
}
|
||||
|
||||
filterRows() {
|
||||
if (!this.searchTerm) {
|
||||
this.filteredRows = [...this.data];
|
||||
} else {
|
||||
this.filteredRows = this.data.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(AddEditMasterBuildingComponent, {
|
||||
size: "lg",
|
||||
});
|
||||
|
||||
modalRef.componentInstance.mode = "add";
|
||||
modalRef.result.then(
|
||||
(result) => {
|
||||
if (result) {
|
||||
this.monitoringApiService
|
||||
.postMasterBuildingParam(result)
|
||||
.subscribe((res) => {
|
||||
this.fetchData();
|
||||
});
|
||||
}
|
||||
},
|
||||
(reason) => {
|
||||
console.log(`Dismissed: ${reason}`);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
editRow(row) {
|
||||
const modalRef = this.modalService.open(AddEditMasterBuildingComponent, {
|
||||
size: "lg",
|
||||
});
|
||||
|
||||
modalRef.componentInstance.dataRow = row;
|
||||
modalRef.componentInstance.mode = "edit";
|
||||
modalRef.result.then(
|
||||
(result) => {
|
||||
if (result) {
|
||||
this.monitoringApiService
|
||||
.putMasterBuildingParam(result, row.id)
|
||||
.subscribe((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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
<p>master-room works!</p>
|
|
@ -0,0 +1,23 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { MasterRoomComponent } from './master-room.component';
|
||||
|
||||
describe('MasterRoomComponent', () => {
|
||||
let component: MasterRoomComponent;
|
||||
let fixture: ComponentFixture<MasterRoomComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ MasterRoomComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(MasterRoomComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,10 @@
|
|||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-master-room',
|
||||
templateUrl: './master-room.component.html',
|
||||
styleUrls: ['./master-room.component.css']
|
||||
})
|
||||
export class MasterRoomComponent {
|
||||
|
||||
}
|
|
@ -22,6 +22,9 @@ import { MasterRoleComponent } from './master-role/master-role.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';
|
||||
import { MasterRoomComponent } from './master-room/master-room.component';
|
||||
import { MasterBuildingComponent } from './master-building/master-building.component';
|
||||
import { AddEditMasterBuildingComponent } from './master-building/add-edit-master-building/add-edit-master-building.component';
|
||||
|
||||
|
||||
|
||||
|
@ -35,7 +38,10 @@ import { MasterFloorComponent } from './master-floor/master-floor.component';
|
|||
MasterRoleComponent,
|
||||
AddEditMasterComponent,
|
||||
MasterVoltageComponent,
|
||||
MasterFloorComponent
|
||||
MasterFloorComponent,
|
||||
MasterRoomComponent,
|
||||
MasterBuildingComponent,
|
||||
AddEditMasterBuildingComponent
|
||||
],
|
||||
imports: [
|
||||
CommonModule,
|
||||
|
@ -84,6 +90,14 @@ import { MasterFloorComponent } from './master-floor/master-floor.component';
|
|||
{
|
||||
path: 'master-role',
|
||||
component: MasterRoleComponent
|
||||
},
|
||||
{
|
||||
path: 'master-room',
|
||||
component: MasterRoomComponent
|
||||
},
|
||||
{
|
||||
path: 'master-building',
|
||||
component: MasterBuildingComponent
|
||||
}
|
||||
])
|
||||
]
|
||||
|
|
|
@ -106,7 +106,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group text-center">
|
||||
<!-- <div class="form-group text-center">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-float btn-square btn-outline-secondary"
|
||||
|
@ -116,6 +116,7 @@
|
|||
>
|
||||
<i class="feather ft-edit"></i>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="gap_fl_btn btn btn-float btn-square btn-float-lg btn-outline-primary"
|
||||
|
@ -134,6 +135,23 @@
|
|||
>
|
||||
<i class="feather ft-log-in"></i>
|
||||
</button>
|
||||
</div> -->
|
||||
<div class="form-group text-center">
|
||||
<!-- Social Icons Outline Buttons -->
|
||||
<button [routerLink]="" class="btn btn-social-icon mr-1 mb-1 btn-outline-adn"><span
|
||||
class="la la-adn"></span></button>
|
||||
<button [routerLink]="" class="btn btn-social-icon mr-1 mb-1 btn-outline-bitbucket"><span
|
||||
class="la la-bitbucket font-medium-4"></span></button>
|
||||
<button [routerLink]="" class="btn btn-social-icon mr-1 mb-1 btn-outline-dropbox"><span
|
||||
class="la la-dropbox font-medium-4"></span></button>
|
||||
<button [routerLink]="" class="btn btn-social-icon mr-1 mb-1 btn-outline-facebook"><span
|
||||
class="la la-facebook"></span></button>
|
||||
<button [routerLink]="" n class="btn btn-social-icon mr-1 mb-1 btn-outline-flickr"><span
|
||||
class="la la-flickr font-medium-4"></span></button>
|
||||
<button [routerLink]="" class="btn btn-social-icon mr-1 mb-1 btn-outline-foursquare"><span
|
||||
class="la la-foursquare font-medium-4"></span></button>
|
||||
<button [routerLink]="" class="btn btn-social-icon mr-1 mb-1 btn-outline-github"><span
|
||||
class="la la-github font-medium-4"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -54,6 +54,15 @@ export class BuildingService {
|
|||
return this.http.get<any>(url, { headers });
|
||||
}
|
||||
|
||||
getMasterBuildingData(page: number = 1, limit: number = 100): Observable<any> {
|
||||
const url = `https://kapi.absys.ninja/hemat/building?page=${page}&limit=${limit}`;
|
||||
const headers = new HttpHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT'
|
||||
});
|
||||
return this.http.get<any>(url, { headers });
|
||||
}
|
||||
|
||||
postHeaderDetailParam(data: any): Observable<any> {
|
||||
const url = `https://kapi.absys.ninja/hemat/header-detail-param`;
|
||||
const headers = new HttpHeaders({
|
||||
|
@ -79,4 +88,21 @@ export class BuildingService {
|
|||
});
|
||||
return this.http.delete<any>(url, { headers });
|
||||
}
|
||||
|
||||
postMasterBuildingParam(data: any): Observable<any> {
|
||||
const url = `https://kapi.absys.ninja/hemat/building`;
|
||||
const headers = new HttpHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT'
|
||||
});
|
||||
return this.http.post<any>(url, data, { headers });
|
||||
}
|
||||
putMasterBuildingParam(data: any, 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.put<any>(url, data, { headers });
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue