-
- {{ element.id }}
+ {{ rowIndex + 1 }}
-
-
+
+
+
+
+
+
+
diff --git a/src/app/content/hemat-app/device/device.component.ts b/src/app/content/hemat-app/device/device.component.ts
index 1927341..36300eb 100644
--- a/src/app/content/hemat-app/device/device.component.ts
+++ b/src/app/content/hemat-app/device/device.component.ts
@@ -8,6 +8,7 @@ import {
} from "ngx-perfect-scrollbar";
import { TableApiService } from "src/app/_services/table-api.service";
import { ModalAddEditComponent } from "./modal-add-edit/modal-add-edit.component";
+import { ActivatedRoute, Router } from "@angular/router";
@Component({
selector: "app-device",
@@ -16,6 +17,8 @@ import { ModalAddEditComponent } from "./modal-add-edit/modal-add-edit.component
})
export class DeviceComponent implements OnInit {
data: any;
+ filteredRows: any[];
+ searchTerm: string = '';
@BlockUI("addRows") blockUIAddRows: NgBlockUI;
@BlockUI("rowSelection") blockUIRowSelection: NgBlockUI;
@@ -43,46 +46,49 @@ export class DeviceComponent implements OnInit {
constructor(
private tableApiservice: TableApiService,
- private modalService: NgbModal
+ private modalService: NgbModal,
+ private router: Router
) {}
ngOnInit() {
- this.breadcrumb = {
- mainlabel: "Device List",
- links: [
- {
- name: "Home",
- isLink: false,
- link: "/dashboard/sales",
- },
- {
- name: "Device",
- isLink: false,
- },
- ],
- };
- this.tableApiservice.getTableApiData().subscribe((Response) => {
- console.log(Response);
+ this.fetchData();
+ }
- this.data = Response;
- this.getTabledata();
+ fetchData() {
+ this.tableApiservice.getTableApiData().subscribe((response) => {
+ this.data = response;
+ this.filteredRows = this.data.rows;
});
}
- getTabledata() {
- this.rows = this.data.rows;
- this.row = this.data.row;
+ filterRows() {
+ if (!this.searchTerm) {
+ this.filteredRows = [...this.data.rows];
+ } else {
+ this.filteredRows = this.data.rows.filter((row) =>
+ this.rowContainsSearchTerm(row)
+ );
+ }
}
- private newAttribute = {
- id: 15,
- name: "Mark",
- position: "Otto",
- office: "@mdo",
- age: "31",
- salary: "12000",
- startdate: "16/05/2017",
- };
+ rowContainsSearchTerm(row: any): boolean {
+ const searchTermLC = this.searchTerm.toLowerCase();
+ return Object.values(row).some(
+ (value) =>
+ value !== null &&
+ value.toString().toLowerCase().includes(searchTermLC)
+ );
+ }
+
+ // private newAttribute = {
+ // id: 15,
+ // name: "Mark",
+ // position: "Otto",
+ // office: "@mdo",
+ // age: "31",
+ // salary: "12000",
+ // startdate: "16/05/2017",
+ // };
// addFieldValue() {
// this.rows.push(this.newAttribute);
@@ -102,5 +108,20 @@ export class DeviceComponent implements OnInit {
console.log(`Dismissed: ${reason}`);
});
}
+
+ viewRow(row) {
+ console.log("View row:", row);
+ this.router.navigate(['/device/view', row.id]);
+ }
+
+ editRow(row) {
+ console.log("Edit row:", row);
+ this.router.navigate(['/device/edit', row.id]);
+ }
+
+ deleteRow(row) {
+ console.log("Delete row:", row);
+ }
+
}
diff --git a/src/app/content/hemat-app/device/device.module.ts b/src/app/content/hemat-app/device/device.module.ts
index bf6b54a..c0fb3e4 100644
--- a/src/app/content/hemat-app/device/device.module.ts
+++ b/src/app/content/hemat-app/device/device.module.ts
@@ -43,7 +43,18 @@ import { ModalAddEditComponent } from './modal-add-edit/modal-add-edit.component
},
{
path: 'add-row',
- component: AddEditDeviceComponent
+ component: AddEditDeviceComponent,
+ data: { mode: 'add' }
+ },
+ {
+ path: 'edit/:id',
+ component: AddEditDeviceComponent,
+ data: { mode: 'edit' }
+ },
+ {
+ path: 'view/:id',
+ component: AddEditDeviceComponent,
+ data: { mode: 'view' }
}
])
]