diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index ea6649b..27fc937 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -23,7 +23,8 @@ import {MatCardModule} from '@angular/material/card';
import {MatGridListModule} from '@angular/material/grid-list';
import {MatTooltipModule} from '@angular/material/tooltip';
import {MatSelectModule} from '@angular/material/select';
-
+import { MatPaginatorModule } from '@angular/material/paginator';
+import { MatSortModule } from '@angular/material/sort';
import { AppRoutingModule } from './app-routing.module';
@@ -76,6 +77,8 @@ import { NavService }from './components/menu-list-item/nav.service';
DragDropModule,
MatTooltipModule,
MatSelectModule,
+ MatPaginatorModule,
+ MatSortModule
],
providers: [NavService],
bootstrap: [AppComponent],
diff --git a/src/app/pages/tables/bikes/bikes.component.html b/src/app/pages/tables/bikes/bikes.component.html
index d9c2787..cf30a16 100644
--- a/src/app/pages/tables/bikes/bikes.component.html
+++ b/src/app/pages/tables/bikes/bikes.component.html
@@ -13,6 +13,19 @@
>
sync
+
+ Filter
+
+
+
= new MatTableDataSource() ;
+ data: MatTableDataSource = new MatTableDataSource();
selection = new SelectionModel(true, []);
reloadingTable = false;
@@ -108,15 +112,15 @@ export class BikesComponent {
constructor(
private bikesService: BikesService,
- private schemaService: SchemaService,
- //private cdr: ChangeDetectorRef
+ private schemaService: SchemaService
) {}
ngAfterViewInit() {
- //this.cdr.detach();
-
this.addTypesToColumnInfo();
this.addReadOnlyPropertiesToColumnInfo();
+ this.data.paginator = this.paginator;
+ this.data.sort = this.sort;
+
this.columnInfo.forEach((column) =>
this.displayedColumns.push(column.name)
);
@@ -128,10 +132,8 @@ export class BikesComponent {
});
this.bikesService.bikes.subscribe((newTableDataSource) => {
- console.time("newBikes");
this.reloadingTable = false;
const tempDataSource = [];
- console.time("overwriteCheck");
for (const row of newTableDataSource) {
const oldRow = this.getRowById(row.id);
/** make sure to not overwrite a row that is being edited */
@@ -143,13 +145,7 @@ export class BikesComponent {
tempDataSource.push(oldRow);
}
}
- console.timeEnd("overwriteCheck");
- console.time("assignData");
this.data.data = tempDataSource;
- console.timeEnd("assignData");
-
- console.timeEnd("newBikes");
-
});
this.bikesService.loadBikes();
@@ -190,7 +186,6 @@ export class BikesComponent {
}
getType(propertyName: string) {
- // console.log(propertyName, this.schemaService.getPropertyTypeFromSchema("CargoBike", propertyName))
return this.schemaService.getPropertyTypeFromSchema(
'CargoBike',
propertyName
@@ -261,4 +256,9 @@ export class BikesComponent {
? this.selection.clear()
: this.data.data.forEach((row) => this.selection.select(row));
}
+
+ applyFilter(event: Event) {
+ const filterValue = (event.target as HTMLInputElement).value;
+ this.data.filter = filterValue.trim().toLowerCase();
+ }
}
diff --git a/src/app/services/bikes.service.ts b/src/app/services/bikes.service.ts
index 598cd5c..20efacb 100644
--- a/src/app/services/bikes.service.ts
+++ b/src/app/services/bikes.service.ts
@@ -52,13 +52,12 @@ export class BikesService {
loadBikes() {
this.getCargoBikesGQL.fetch().subscribe((result) => {
- console.time("addMoreBikes");
- for (let i = 1; i <= 500; i++) {
+ // comment in for performance testing
+ /*for (let i = 1; i <= 500; i++) {
const newBike = deepCopy(result.data.cargoBikes[0]);
newBike.id = (i + 100).toString();
result.data.cargoBikes.push(newBike);
- }
- console.timeEnd("addMoreBikes");
+ }*/
this.bikes.next(result.data.cargoBikes);
});