perbaikan routing dan penambahan button back pada page monitoring

This commit is contained in:
Fuzi_fauzia 2024-04-26 16:36:04 +07:00
parent ee2b7e35e6
commit 5ce07dc3fd
7 changed files with 98 additions and 29 deletions

View File

@ -11,9 +11,7 @@
*blockUI="'zeroConfiguration'; message: 'Loading'" *blockUI="'zeroConfiguration'; message: 'Loading'"
> >
<m-card> <m-card>
<ng-container mCardHeaderTitle> <ng-container mCardHeaderTitle> Device Table </ng-container>
Device Table
</ng-container>
<ng-container mCardBody> <ng-container mCardBody>
<div class="row mb-2"> <div class="row mb-2">
<div class="col-md-6"> <div class="col-md-6">
@ -23,15 +21,21 @@
placeholder="Search..." placeholder="Search..."
[(ngModel)]="searchTerm" [(ngModel)]="searchTerm"
(input)="filterRows()" (input)="filterRows()"
(touchstart)="onTouchStart($event)"
/> />
</div> </div>
<div class="col-md-6 text-right"> <div class="col-md-6 text-right">
<button <button
class="btn btn-secondary" class="btn btn-secondary"
[routerLink]="['/device/add-row']" [disabled]="spinnerActive"
(click)="addDevice()"
> >
<i class="feather ft-plus"></i>&nbsp; Add new device <i
class="la la-spinner spinner"
*ngIf="spinnerActive"
></i>
<i class="feather ft-plus" *ngIf="!spinnerActive"></i
>&nbsp;
<span>Syncing Data</span>
</button> </button>
</div> </div>
</div> </div>

View File

@ -16,6 +16,7 @@ export class DeviceComponent implements OnInit {
searchTerm: string = ""; searchTerm: string = "";
rows: any = []; rows: any = [];
public breadcrumb: any; public breadcrumb: any;
spinnerActive: boolean = false;
@BlockUI("zeroConfiguration") blockUIZeroConfiguration: NgBlockUI; @BlockUI("zeroConfiguration") blockUIZeroConfiguration: NgBlockUI;
@ -108,7 +109,17 @@ export class DeviceComponent implements OnInit {
console.log("Delete row:", row); console.log("Delete row:", row);
} }
onTouchStart(event: Event) { addDevice(): void {
event.preventDefault(); // Add this if necessary // Aktifkan spinner
this.spinnerActive = true;
// Lakukan proses tambahan (misalnya, panggil API atau proses yang memakan waktu)
setTimeout(() => {
// Selesaikan proses tambahan di sini
// Nonaktifkan spinner setelah proses selesai
this.spinnerActive = false;
this.fetchData();
}, 3000); // Ganti 3000 dengan waktu yang sesuai dengan proses tambahan Anda (dalam milidetik)
} }
} }

View File

@ -1,4 +1,5 @@
import { Component } from "@angular/core"; import { Component } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { BlockUI, NgBlockUI } from "ng-block-ui"; import { BlockUI, NgBlockUI } from "ng-block-ui";
import { ChartApiService } from "src/app/_services/chart.api"; import { ChartApiService } from "src/app/_services/chart.api";
interface Sales { interface Sales {
@ -17,9 +18,14 @@ export class DetailComponent {
data: any; data: any;
chartOption: any; chartOption: any;
Sales: any; Sales: any;
mode: string;
ExpenseschartOption: any; ExpenseschartOption: any;
public breadcrumb: any; public breadcrumb: any;
constructor(private chartApiservice: ChartApiService) {} constructor(
private chartApiservice: ChartApiService,
private router: Router,
private route: ActivatedRoute
) {}
@BlockUI("totalReceivables") blockUITotalReceivables: NgBlockUI; @BlockUI("totalReceivables") blockUITotalReceivables: NgBlockUI;
@BlockUI("salesRecieptsDues") blockUISalesRecieptsDues: NgBlockUI; @BlockUI("salesRecieptsDues") blockUISalesRecieptsDues: NgBlockUI;
getInvoicechart() { getInvoicechart() {
@ -148,9 +154,13 @@ export class DetailComponent {
}; };
} }
ngOnInit() { ngOnInit() {
this.route.data.subscribe((data) => {
this.mode = data.mode;
});
if (this.mode === "room") {
this.breadcrumb = { this.breadcrumb = {
mainlabel: "Detail Monitoring", mainlabel: "Detail Monitoring",
linkBack: '/monitoring', linkBack: "/monitoring/monitoring-room",
isLinkBack: true, isLinkBack: true,
links: [ links: [
{ {
@ -162,9 +172,29 @@ export class DetailComponent {
name: "Detail Monitoring", name: "Detail Monitoring",
isLink: false, isLink: false,
link: "", link: "",
} },
], ],
}; };
} else {
this.breadcrumb = {
mainlabel: "Detail Monitoring",
linkBack: "/monitoring",
isLinkBack: true,
links: [
{
name: "Home",
isLink: false,
link: "",
},
{
name: "Detail Monitoring",
isLink: false,
link: "",
},
],
};
}
this.chartApiservice.getInvoiceData().subscribe((Response) => { this.chartApiservice.getInvoiceData().subscribe((Response) => {
this.data = Response; this.data = Response;
this.getInvoicechart(); this.getInvoicechart();

View File

@ -55,7 +55,8 @@ import { NgxEchartsModule } from 'ngx-echarts';
}, },
{ {
path: 'monitoring-room', path: 'monitoring-room',
component: RoomComponent component: RoomComponent,
data: { mode: 'room' }
}, },
{ {
path: 'add-new-room', path: 'add-new-room',
@ -77,6 +78,11 @@ import { NgxEchartsModule } from 'ngx-echarts';
component: DetailComponent, component: DetailComponent,
data: { mode: 'build' } data: { mode: 'build' }
}, },
{
path: 'view-new-room/:id',
component: DetailComponent,
data: { mode: 'room' }
},
]) ])
] ]
}) })

View File

@ -73,6 +73,7 @@
class="btn btn-icon btn-outline-primary mr-1" class="btn btn-icon btn-outline-primary mr-1"
triggers="hover:click:hover" triggers="hover:click:hover"
ngbTooltip="Edit" ngbTooltip="Edit"
(click)="editRow(data)"
> >
<i class="feather ft-edit"></i> <i class="feather ft-edit"></i>
</button> </button>
@ -81,6 +82,7 @@
class="btn btn-icon btn-outline-primary mr-1" class="btn btn-icon btn-outline-primary mr-1"
triggers="hover:click:hover" triggers="hover:click:hover"
ngbTooltip="Detail" ngbTooltip="Detail"
(click)="viewRow(data)"
> >
<i class="la la-building"></i> <i class="la la-building"></i>
</button> </button>

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from "@angular/core"; import { Component, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router"; import { ActivatedRoute, Router } from "@angular/router";
import { TableMonitoringService } from "../monitoring.service"; import { TableMonitoringService } from "../monitoring.service";
@Component({ @Component({
@ -16,7 +16,8 @@ export class RoomComponent implements OnInit {
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
private monitoringService: TableMonitoringService private monitoringService: TableMonitoringService,
private router: Router
) {} ) {}
ngOnInit() { ngOnInit() {
@ -67,4 +68,11 @@ export class RoomComponent implements OnInit {
value !== null && value.toString().toLowerCase().includes(searchTermLC) value !== null && value.toString().toLowerCase().includes(searchTermLC)
); );
} }
viewRow(row) {
this.router.navigate(["/monitoring/view-new-room", row.id]);
}
editRow(row) {
this.router.navigate(["/monitoring/edit-new-room", row.id]);
}
} }

View File

@ -1,5 +1,6 @@
[ [
{ {
"id": 1,
"type": "danger", "type": "danger",
"value": 95, "value": 95,
"product": "Ruang Meeting 1", "product": "Ruang Meeting 1",
@ -8,6 +9,7 @@
"bagde": "+8 more" "bagde": "+8 more"
}, },
{ {
"id": 2,
"type": "warning", "type": "warning",
"value": 75, "value": 75,
"product": "Ruang Meeting 2", "product": "Ruang Meeting 2",
@ -16,6 +18,7 @@
"bagde": "+5 more" "bagde": "+5 more"
}, },
{ {
"id": 3,
"type": "success", "type": "success",
"value": 65, "value": 65,
"product": "Ruang Meeting 3", "product": "Ruang Meeting 3",
@ -24,6 +27,7 @@
"bagde": "+3 more" "bagde": "+3 more"
}, },
{ {
"id": 4,
"type": "success", "type": "success",
"value": 55, "value": 55,
"product": "Dapur", "product": "Dapur",
@ -31,6 +35,7 @@
"amount": "$ 1150.00" "amount": "$ 1150.00"
}, },
{ {
"id": 5,
"type": "success", "type": "success",
"value": 45, "value": 45,
"product": "Ruang Musola", "product": "Ruang Musola",
@ -38,6 +43,7 @@
"amount": "$ 1180.00" "amount": "$ 1180.00"
}, },
{ {
"id": 6,
"type": "danger", "type": "danger",
"value": 90, "value": 90,
"product": "Ruang Server", "product": "Ruang Server",
@ -46,6 +52,7 @@
"bagde": "+8 more" "bagde": "+8 more"
}, },
{ {
"id": 7,
"type": "warning", "type": "warning",
"value": 75, "value": 75,
"product": "Ruang Kepala Bagian", "product": "Ruang Kepala Bagian",
@ -54,6 +61,7 @@
"bagde": "+5 more" "bagde": "+5 more"
}, },
{ {
"id": 8,
"type": "success", "type": "success",
"value": 65, "value": 65,
"product": "Ruang Tengah", "product": "Ruang Tengah",