This commit is contained in:
Bastian Wagner
2024-10-25 12:32:26 +02:00
parent d4f1fbbf39
commit b4e264eda9
40 changed files with 538 additions and 66 deletions

View File

@@ -70,7 +70,6 @@ export class AllUsersComponent {
next: n => {
this.gridApi.setGridOption("rowData", n)
this.gridApi.setGridOption("loading", false);
n.filter(u => u.username == 'mail@bastian-wagner.de').map((u: any) => { console.log(u['lastLogin'])})
}
})
}
@@ -98,7 +97,6 @@ export class AllUsersComponent {
const self = this;
this.gridApi.addEventListener("cellEditingStopped", evt => this.cellEditEnd(evt, self))
this.loadUsers();
console.log(params)
}
}

View File

@@ -0,0 +1,9 @@
<h2 mat-dialog-title>Zylinder <u>{{key.name}}</u> löschen?</h2>
<mat-dialog-content>
<p>Soll der Zylinder wirklich gelöscht werden? Alle {{ key.keyCount | number:'0.0-0'}} enthaltenen Schlüssel werden mit entfernt!</p>
</mat-dialog-content>
<mat-dialog-actions>
<button mat-button [mat-dialog-close]="false" >Abbrechen</button>
<button mat-button [mat-dialog-close]="true" color="warn">Ja, löschen</button>
</mat-dialog-actions>

View File

@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DeleteCylinderComponent } from './delete-cylinder.component';
describe('DeleteCylinderComponent', () => {
let component: DeleteCylinderComponent;
let fixture: ComponentFixture<DeleteCylinderComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [DeleteCylinderComponent]
})
.compileComponents();
fixture = TestBed.createComponent(DeleteCylinderComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,18 @@
import { CommonModule } from '@angular/common';
import { Component, inject, LOCALE_ID } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
@Component({
selector: 'app-delete-cylinder',
standalone: true,
imports: [MatDialogModule, MatButtonModule, CommonModule],
providers: [{ provide: LOCALE_ID, useValue: 'de-DE' },],
templateUrl: './delete-cylinder.component.html',
styleUrl: './delete-cylinder.component.scss'
})
export class DeleteCylinderComponent {
readonly dialogRef = inject(MatDialogRef<DeleteCylinderComponent>);
readonly key = inject<any>(MAT_DIALOG_DATA);
}

View File

@@ -4,6 +4,7 @@ import { GridApi, GridOptions, GridReadyEvent } from 'ag-grid-community';
import { AgGridAngular } from 'ag-grid-angular';
import { ApiService } from '../../shared/api.service';
import { DatePipe } from '@angular/common';
import { AgDeleteCylinderComponent } from '../../shared/ag-grid/components/ag-delete-cylinder/ag-delete-cylinder.component';
@Component({
selector: 'app-cylinder',
@@ -30,6 +31,12 @@ export class CylinderComponent {
{ field: 'keyCount', headerName: 'Anzahl Schlüssel', flex: 0, type: 'number' },
{ field: 'createdAt', headerName: 'Angelegt', cellRenderer: (data: any) => data.value ? this.datePipe.transform(new Date(data.value)) : '-' },
{ field: 'updatedAt', headerName: 'Upgedated', cellRenderer: (data: any) => data.value ? this.datePipe.transform(new Date(data.value)) : '-' },
{
colId: 'actions'
, headerName: 'Aktionen'
, width: 120
, cellRenderer: AgDeleteCylinderComponent
}
]
}

View File

@@ -83,9 +83,7 @@ export class KeysComponent {
}
deleteKey(id: string) {
this.api.deleteKey(id).subscribe({
next: n => console.log(n)
})
this.api.deleteKey(id).subscribe()
}
ngOnInit(): void {

View File

@@ -1 +0,0 @@
<p>start works!</p>

View File

@@ -1,19 +0,0 @@
import { HttpClient } from '@angular/common/http';
import { Component, inject } from '@angular/core';
@Component({
selector: 'app-start',
standalone: true,
imports: [],
templateUrl: './start.component.html',
styleUrl: './start.component.scss'
})
export class StartComponent {
private http: HttpClient = inject(HttpClient);
ngOnInit(): void {
this.http.get('/api/').subscribe(res => {
console.log(res)
})
}
}

View File

@@ -0,0 +1,5 @@
<ag-grid-angular
style="width: 100%; height: 100%;"
(gridReady)="onGridReady($event)"
[gridOptions]="gridOptions!"
/>

View File

@@ -1,18 +1,18 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { StartComponent } from './start.component';
import { SystemComponent } from './system.component';
describe('StartComponent', () => {
let component: StartComponent;
let fixture: ComponentFixture<StartComponent>;
describe('SystemComponent', () => {
let component: SystemComponent;
let fixture: ComponentFixture<SystemComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [StartComponent]
imports: [SystemComponent]
})
.compileComponents();
fixture = TestBed.createComponent(StartComponent);
fixture = TestBed.createComponent(SystemComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

View File

@@ -0,0 +1,47 @@
import { DatePipe } from '@angular/common';
import { Component, inject } from '@angular/core';
import { AgGridAngular } from 'ag-grid-angular';
import { GridApi, GridOptions, GridReadyEvent } from 'ag-grid-community';
import { ApiService } from '../../shared/api.service';
import { HELPER } from '../../shared/helper.service';
@Component({
selector: 'app-system',
standalone: true,
imports: [AgGridAngular],
providers: [DatePipe],
templateUrl: './system.component.html',
styleUrl: './system.component.scss'
})
export class SystemComponent {
private api: ApiService = inject(ApiService);
private datePipe = inject(DatePipe);
gridApi!: GridApi;
gridOptions: GridOptions = HELPER.getGridOptions();
constructor() {
this.gridOptions.columnDefs = [
{ colId: 'name', field: 'name', headerName: 'Name', sort: 'asc', flex: 1},
{ field: 'createdAt', headerName: 'Angelegt', cellRenderer: (data: any) => data.value ? this.datePipe.transform(new Date(data.value)) : '-' },
{ field: 'updatedAt', headerName: 'Upgedated', cellRenderer: (data: any) => data.value ? this.datePipe.transform(new Date(data.value)) : '-' },
]
}
loadSystems() {
this.api.getSystems().subscribe({
next: n => {
this.gridApi.setGridOption("rowData", n);
this.gridApi.setGridOption("loading", false);
}
})
}
onGridReady(params: GridReadyEvent) {
this.gridApi = params.api;
this.loadSystems();
}
}