refactoring

This commit is contained in:
Bastian Wagner
2025-01-03 11:00:02 +01:00
parent a47bbe29fe
commit c8c2ee18cb
35 changed files with 285 additions and 167 deletions

View File

@@ -1,9 +1,21 @@
<h2 mat-dialog-title>Zylinder <u>{{key.name}}</u> löschen?</h2>
<h2 mat-dialog-title>Zylinder <u>{{cylinder.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>
<div class="warning-message">
<mat-icon color="warn">warning</mat-icon>
<p>
<b>{{cylinder.name}}</b> wirklich entfernen?
Alle Schlüssel die nur diesen Zylinder haben werden ebenfalls entfernt.
</p>
<p class="additional-info">
<!-- Additional information -->
<small>Diese Aktion kann nicht rückgängig gemacht werden.</small>
</p>
</div>
</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 align="end">
<button mat-button [mat-dialog-close]="false">Abbrechen</button>
<button mat-raised-button color="warn" [mat-dialog-close]="true">
<mat-icon>delete</mat-icon>
Entfernen
</button>
</mat-dialog-actions>

View File

@@ -2,17 +2,19 @@ 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';
import { MatIconModule } from '@angular/material/icon';
import { ICylinder } from '../../../../model/interface/cylinder.interface';
@Component({
selector: 'app-delete-cylinder',
standalone: true,
imports: [MatDialogModule, MatButtonModule, CommonModule],
imports: [MatDialogModule, MatButtonModule, CommonModule, MatIconModule],
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);
readonly cylinder = inject<ICylinder>(MAT_DIALOG_DATA);
}

View File

@@ -1,9 +1,9 @@
<div class="dashboard-container">
<!-- Welcome Section -->
<div class="welcome-section">
<!-- <div class="welcome-section">
<h1>Willkommen bei Keyvault Pro</h1>
<p>Verwalte deine Schlüssel und Systeme</p>
</div>
</div> -->
<!-- Quick Stats Cards -->
<div class="stats-grid">
@@ -38,22 +38,36 @@
<mat-card class="stat-card">
<mat-card-header>
<mat-icon>admin_panel_settings</mat-icon>
<mat-card-title>Systeme</mat-card-title>
<mat-card-title>Schließanlagen</mat-card-title>
</mat-card-header>
<mat-card-content>
<span class="stat-number">{{ systemCount }}</span>
<p>Aktive Systeme</p>
<p>Aktive Schließanlagen</p>
</mat-card-content>
<mat-card-actions>
<button mat-button routerLink="/systems">Verwalten</button>
</mat-card-actions>
</mat-card>
<mat-card class="stat-card">
<mat-card-header>
<mat-icon>passkey</mat-icon>
<mat-card-title>Ausgegebene Schlüssel</mat-card-title>
</mat-card-header>
<mat-card-content>
<span class="stat-number">{{ handedOut }}</span>
<p>Derzeit ausgegebene Schlüssel</p>
</mat-card-content>
<mat-card-actions>
<button mat-button routerLink="/keys">Verwalten</button>
</mat-card-actions>
</mat-card>
</div>
<!-- Recent Activity Section -->
<div class="recent-activity">
<h2>Letzte Aktivitäten</h2>
<mat-card>
<mat-card style="background: white">
<mat-card-content>
<ag-grid-angular
style="width: 100%; height: 100%;"

View File

@@ -1,6 +1,6 @@
.dashboard-container {
padding: 24px;
height: calc(100% - 48px);
height: 100%;
display: flex;
flex-direction: column;
gap: 24px;

View File

@@ -8,11 +8,12 @@ import {MatCardModule} from '@angular/material/card';
import { RouterModule } from '@angular/router';
import { AgLoadingComponent } from '../../shared/ag-grid/components/ag-loading/ag-loading.component';
import { AG_GRID_LOCALE_DE } from '@ag-grid-community/locale';
import { MatButtonModule } from '@angular/material/button';
@Component({
selector: 'app-dashboard',
standalone: true,
imports: [AgGridAngular, MatIconModule, AgGridAngular, MatCardModule, RouterModule],
imports: [AgGridAngular, MatIconModule, AgGridAngular, MatCardModule, RouterModule, MatButtonModule],
providers: [DatePipe],
templateUrl: './dashboard.component.html',
styleUrl: './dashboard.component.scss'
@@ -40,6 +41,7 @@ export class DashboardComponent {
keyCount = 0;
cylinderCount = 0;
systemCount = 0;
handedOut = 0;
ngOnInit() {
this.loadStats();
@@ -50,6 +52,7 @@ export class DashboardComponent {
this.keyCount = stats.keys;
this.cylinderCount = stats.cylinders;
this.systemCount = stats.systems;
this.handedOut = stats.handedOut;
});
}

View File

@@ -1,9 +1,20 @@
<h2 mat-dialog-title>Schlüssel {{key.name}} löschen?</h2>
<h2 mat-dialog-title>Schlüssel <u>{{key.name}}</u> löschen?</h2>
<mat-dialog-content>
<p>Soll der Schlüssel wirklich gelöscht werden?</p>
<div class="warning-message">
<mat-icon color="warn">warning</mat-icon>
<p>
<b>{{key.name}}</b> wirklich entfernen?
</p>
<p class="additional-info">
<!-- Additional information -->
<small>Gelöschte Schlüssel können über das Archiv wiederhergestellt werden.</small>
</p>
</div>
</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 align="end">
<button mat-button [mat-dialog-close]="false">Abbrechen</button>
<button mat-raised-button color="warn" [mat-dialog-close]="true">
<mat-icon>delete</mat-icon>
Entfernen
</button>
</mat-dialog-actions>

View File

@@ -2,11 +2,12 @@ import { Component, inject } from '@angular/core';
import { IKey } from '../../../../model/interface/key.interface';
import { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
@Component({
selector: 'app-delete-key',
standalone: true,
imports: [MatDialogModule, MatButtonModule],
imports: [MatDialogModule, MatButtonModule, MatIconModule],
templateUrl: './delete-key.component.html',
styleUrl: './delete-key.component.scss'
})

View File

@@ -43,8 +43,8 @@
</form>
</mat-dialog-content>
<mat-dialog-actions>
<button mat-button (click)="save()" [disabled]="handoverForm.invalid">Speichern</button>
<button mat-button mat-dialog-close color="warn" >Schließen</button>
<button mat-button (click)="save()" [disabled]="handoverForm.invalid">Speichern</button>
</mat-dialog-actions>
</mat-tab>

View File

@@ -187,10 +187,17 @@ export class HandoverDialogComponent {
createCustomer(name: string): Promise<any> {
this.isLoading = true;
return new Promise((resolve, reject) => {
this.api.createCustomer({ name, system: this.data.cylinder.system}).subscribe({
this.api.createCustomer({ name, system: this.data.cylinder[0].system}).subscribe({
next: n => {
this.isLoading = false;
resolve(n);
},
error: e => {
this.isLoading = false;
const field = e.error.field;
const message = field ? e.error.message : 'Ein Fehler ist aufgetreten. Bitte versuche es später erneut';
this.toast.error(message);
reject(e);
}
})
})

View File

@@ -5,7 +5,7 @@
<mat-icon color="warn">warning</mat-icon>
<p>
<b>{{ manager.firstName }} {{ manager.lastName }}</b> wirklich entfernen?
Der Benutzer hat dann keinen Zugriff mehr auf das System mit allen seinen Daten.
Der Benutzer hat dann keinen Zugriff mehr auf diese Schließanlage mit allen ihren Daten.
</p>
<p class="additional-info">
<!-- Additional information -->

View File

@@ -1,19 +0,0 @@
.warning-message {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
padding: 1rem;
mat-icon {
font-size: 48px;
height: 48px;
width: 48px;
margin-bottom: 1rem;
}
.additional-info {
margin-top: 1rem;
color: rgba(0, 0, 0, 0.6);
}
}

View File

@@ -1,4 +1,4 @@
<h2 mat-dialog-title>Neuen Schlüssel anlegen</h2>
<h2 mat-dialog-title>Neue Schließanlage anlegen</h2>
<mat-dialog-content>
<form [formGroup]="createForm" class="flex flex-col gap-3">
@@ -8,7 +8,7 @@
@if ((createForm.controls.name.value || '').length > 20) {
<mat-hint>{{ (createForm.controls.name.value || '').length }} / 100 Zeichen</mat-hint>
} @else {
<mat-hint>Wie soll der Schlüssel heißen?</mat-hint>
<mat-hint>Wie soll die Anlage heißen?</mat-hint>
}
</mat-form-field>
</form>

View File

@@ -5,5 +5,5 @@
/>
<div class="floating-btn-container">
<button mat-flat-button class="btn-create mat-elevation-z8" (click)="openCreateSystem()" color="accent" >System anlegen</button>
<button mat-flat-button class="btn-create mat-elevation-z8" (click)="openCreateSystem()" color="accent" >Schließanlage anlegen</button>
</div>