Api umgebaut
This commit is contained in:
@@ -35,7 +35,7 @@ export class KeysComponent {
|
||||
private dialog: MatDialog = inject(MatDialog);
|
||||
private route: ActivatedRoute = inject(ActivatedRoute)
|
||||
|
||||
cylinders: any[] = [];
|
||||
// cylinders: any[] = [];
|
||||
|
||||
gridApi!: GridApi;
|
||||
|
||||
@@ -93,7 +93,6 @@ export class KeysComponent {
|
||||
, width: 140
|
||||
, cellRenderer: AgKeyActionsComponent
|
||||
, sortable: false
|
||||
// , onCellClicked: (event) => { this.deleteKey(event.data.id)}
|
||||
,valueFormatter: (data: any) => { return data; },
|
||||
}
|
||||
],
|
||||
@@ -103,30 +102,15 @@ export class KeysComponent {
|
||||
pagination: true,
|
||||
}
|
||||
|
||||
|
||||
deleteKey(id: string) {
|
||||
this.api.deleteKey(id).subscribe()
|
||||
}
|
||||
|
||||
editKey(id: string) {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.api.getCylinders().subscribe({
|
||||
next: n => {
|
||||
this.cylinders = n;
|
||||
|
||||
this.setFilterToParams();
|
||||
},
|
||||
error: () => {
|
||||
this.cylinders = [];
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
private setFilterToParams() {
|
||||
console.log(this.route.snapshot.queryParams);
|
||||
const params = this.route.snapshot.queryParams;
|
||||
|
||||
if (Object.keys(params).includes('handedOut')) {
|
||||
@@ -143,23 +127,21 @@ export class KeysComponent {
|
||||
|
||||
loadKeys() {
|
||||
this.gridApi.setGridOption("loading", true);
|
||||
this.api.getKeys().subscribe({
|
||||
next: n => {
|
||||
this.gridApi.setGridOption("rowData", n);
|
||||
this.gridApi.setGridOption("loading", false);
|
||||
},
|
||||
error: () => {
|
||||
this.gridApi.setGridOption("loading", false);
|
||||
// set error in grid
|
||||
this.toast.error('Fehler beim Laden der Schlüssel')
|
||||
}
|
||||
})
|
||||
this.api.refreshKeys();
|
||||
}
|
||||
|
||||
onGridReady(params: GridReadyEvent) {
|
||||
this.gridApi = params.api;
|
||||
this.gridApi.addEventListener("cellEditingStopped", evt => this.cellEditEnd(evt))
|
||||
this.gridApi.addEventListener("cellEditingStopped", evt => this.cellEditEnd(evt));
|
||||
this.api.keys.asObservable().subscribe({
|
||||
next: keys => {
|
||||
console.log(keys)
|
||||
this.gridApi.setGridOption("rowData", keys);
|
||||
this.gridApi.setGridOption("loading", false);
|
||||
}
|
||||
})
|
||||
this.loadKeys();
|
||||
this.setFilterToParams();
|
||||
}
|
||||
|
||||
cellEditEnd(event: CellEditingStoppedEvent) {
|
||||
|
||||
Reference in New Issue
Block a user