queryparams aus url

This commit is contained in:
Bastian Wagner
2026-02-17 15:38:38 +01:00
parent a292b29cb1
commit 40e3ac187e
4 changed files with 33 additions and 13 deletions

View File

@@ -4,6 +4,7 @@
"scripts": {
"ng": "ng",
"start": "ng serve",
"start:remote": "ng serve --configuration remote",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "jest",

View File

@@ -1,11 +1,8 @@
{
"/api": {
"target": "http://keyvaultpro.de:3701",
"secure": false,
"logLevel": "debug",
"target": "https://keyvaultpro.de",
"secure": true,
"changeOrigin": true,
"pathRewrite": {
"^/api": ""
}
"logLevel": "debug"
}
}

View File

@@ -59,7 +59,7 @@
<p>Derzeit ausgegebene Schlüssel</p>
</mat-card-content>
<mat-card-actions>
<button matButton routerLink="/keys">Verwalten</button>
<button matButton routerLink="/keys" [queryParams]="{handedOut: true }">Verwalten</button>
</mat-card-actions>
</mat-card>
</div>

View File

@@ -1,7 +1,7 @@
import { Component, inject } from '@angular/core';
import { AG_GRID_LOCALE_DE } from '@ag-grid-community/locale';
import { AgGridAngular } from 'ag-grid-angular';
import { GridOptions,GridApi, GridReadyEvent, CellEditingStoppedEvent, ICellEditorParams } from 'ag-grid-community';
import { GridOptions,GridApi, GridReadyEvent, CellEditingStoppedEvent, ICellEditorParams, FilterActionParams, FilterAction } from 'ag-grid-community';
import { DatePipe } from '@angular/common';
import { ApiService } from '../../shared/api.service';
import { IKey } from '../../model/interface/key.interface';
@@ -18,11 +18,13 @@ import { ICylinder } from '../../model/interface/cylinder.interface';
import { LostKeysComponent } from './components/lost-keys/lost-keys.component';
import { MatTooltipModule } from '@angular/material/tooltip';
import { SelectKeyCylinderComponent } from './create/select-key-cylinder/select-key-cylinder.component';
import { ActivatedRoute, Route } from '@angular/router';
import { ModuleRegistry } from 'ag-grid-community';
@Component({
selector: 'app-keys',
imports: [AgGridAngular, MatButtonModule, MatDialogModule, MatIconModule, MatTooltipModule],
providers: [DatePipe],
providers: [DatePipe, ModuleRegistry],
templateUrl: './keys.component.html',
styleUrl: './keys.component.scss'
})
@@ -31,6 +33,7 @@ export class KeysComponent {
private datePipe = inject(DatePipe);
private toast: HotToastService = inject(HotToastService);
private dialog: MatDialog = inject(MatDialog);
private route: ActivatedRoute = inject(ActivatedRoute)
cylinders: any[] = [];
@@ -83,7 +86,7 @@ export class KeysComponent {
, cellRenderer: (data: any) => data.value ? this.datePipe.transform(new Date(data.value)) : '-'
, tooltipValueGetter: (data: any) => this.datePipe.transform(new Date(data.value), 'medium')
},
{ colId: 'handedOut', field: 'handedOut' , headerName: 'Ausgegeben', width: 100, editable: false, filter: false, headerTooltip: 'Ausgegeben' },
{ colId: 'handedOut', field: 'handedOut' , headerName: 'Ausgegeben', width: 100, editable: false, filter: true, headerTooltip: 'Ausgegeben' },
{
colId: 'actions'
, headerName: 'Aktionen'
@@ -100,6 +103,7 @@ export class KeysComponent {
pagination: true,
}
deleteKey(id: string) {
this.api.deleteKey(id).subscribe()
}
@@ -112,6 +116,8 @@ export class KeysComponent {
this.api.getCylinders().subscribe({
next: n => {
this.cylinders = n;
this.setFilterToParams();
},
error: () => {
this.cylinders = [];
@@ -119,6 +125,22 @@ export class KeysComponent {
})
}
private setFilterToParams() {
console.log(this.route.snapshot.queryParams);
const params = this.route.snapshot.queryParams;
if (Object.keys(params).includes('handedOut')) {
this.gridApi.setFilterModel({
handedOut: {
filterType: 'text',
type: params['handedOut']
}
})
}
}
loadKeys() {
this.gridApi.setGridOption("loading", true);
this.api.getKeys().subscribe({