Schließanlagen können gelöscht werden
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<h2 mat-dialog-title>Schließanlage <u>{{key.name}}</u> löschen?</h2>
|
||||
<mat-dialog-content>
|
||||
<div class="warning-message">
|
||||
<mat-icon>warning</mat-icon>
|
||||
<p>
|
||||
<b>{{key.name}}</b> wirklich entfernen?
|
||||
</p>
|
||||
<p class="additional-info">
|
||||
<!-- Additional information -->
|
||||
<small>Gelöschte Schließanlagen können über das Archiv wiederhergestellt werden.</small>
|
||||
</p>
|
||||
</div>
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions align="end">
|
||||
<button matButton [mat-dialog-close]="false">Abbrechen</button>
|
||||
<button matButton="elevated" [mat-dialog-close]="true" class="btn-warning">
|
||||
<mat-icon>delete</mat-icon>
|
||||
Entfernen
|
||||
</button>
|
||||
</mat-dialog-actions>
|
||||
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AgDeleteSystemComponent } from './ag-delete-system.component';
|
||||
|
||||
describe('AgDeleteSystemComponent', () => {
|
||||
let component: AgDeleteSystemComponent;
|
||||
let fixture: ComponentFixture<AgDeleteSystemComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [AgDeleteSystemComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(AgDeleteSystemComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { IKey } from '../../../../model/interface/key.interface';
|
||||
|
||||
@Component({
|
||||
selector: 'app-ag-delete-system',
|
||||
imports: [MatDialogModule, MatButtonModule, MatIconModule],
|
||||
templateUrl: './ag-delete-system.component.html',
|
||||
styleUrl: './ag-delete-system.component.scss',
|
||||
})
|
||||
export class AgDeleteSystemComponent {
|
||||
readonly dialogRef = inject(MatDialogRef<AgDeleteSystemComponent>);
|
||||
readonly key = inject<any>(MAT_DIALOG_DATA);
|
||||
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
<div class="manage icon-btn-sm" (click)="openManager()" matTooltip="Manager bearbeiten" [matTooltipShowDelay]="600"></div>
|
||||
<div class="manage icon-btn-sm" (click)="openManager()" matTooltip="Manager bearbeiten" [matTooltipShowDelay]="600"></div>
|
||||
<div class="delete icon-btn-sm" (click)="delete()" matTooltip="Löschen" [matTooltipShowDelay]="400"></div>
|
||||
@@ -6,6 +6,7 @@ import { ICellRendererAngularComp } from 'ag-grid-angular';
|
||||
import { ICellRendererParams } from 'ag-grid-community';
|
||||
import { ApiService } from '../../../api.service';
|
||||
import { SystemManagerComponent } from '../../../../modules/system/components/system-manager/system-manager.component';
|
||||
import { AgDeleteSystemComponent } from '../ag-delete-system/ag-delete-system.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-ag-system-manager',
|
||||
@@ -32,15 +33,39 @@ export class AgSystemManagerComponent implements ICellRendererAngularComp {
|
||||
|
||||
|
||||
openManager() {
|
||||
const ref = this.dialog.open(SystemManagerComponent, {
|
||||
data: this.system,
|
||||
autoFocus: false,
|
||||
maxHeight: "calc(100vh - 24px)",
|
||||
maxWidth: "calc(100vw - 24px)",
|
||||
width: "50vw",
|
||||
minWidth: "300px",
|
||||
height: "70vh",
|
||||
disableClose: false
|
||||
})
|
||||
}
|
||||
const ref = this.dialog.open(SystemManagerComponent, {
|
||||
data: this.system,
|
||||
autoFocus: false,
|
||||
maxHeight: "calc(100vh - 24px)",
|
||||
maxWidth: "calc(100vw - 24px)",
|
||||
width: "50vw",
|
||||
minWidth: "300px",
|
||||
height: "70vh",
|
||||
disableClose: false
|
||||
})
|
||||
}
|
||||
|
||||
delete() {
|
||||
const ref = this.dialog.open(AgDeleteSystemComponent, {
|
||||
data: this.system,
|
||||
autoFocus: false,
|
||||
width: '500px',
|
||||
maxWidth: 'calc(100vw - 24px)',
|
||||
})
|
||||
|
||||
ref.afterClosed().subscribe({
|
||||
next: n => {
|
||||
if (n) {
|
||||
this.deleteThisKey();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async deleteThisKey() {
|
||||
this.params.api.setGridOption("loading", true);
|
||||
await this.api.deleteSystem(this.system);
|
||||
this.params.api.setGridOption("loading", false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { IKey } from '../model/interface/key.interface';
|
||||
import { ICylinder } from '../model/interface/cylinder.interface';
|
||||
import { HotToastService } from '@ngxpert/hot-toast';
|
||||
import { ICustomer } from '../model/interface/customer.interface';
|
||||
import { ISystem } from '../model/interface/keysystem.interface';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -198,7 +199,7 @@ export class ApiService {
|
||||
*/
|
||||
deleteSystem(system: any): Promise<boolean> {
|
||||
return new Promise<boolean>(resolve => {
|
||||
this.http.delete(`api/system${system.id}`).pipe(
|
||||
this.http.delete(`api/system/${system.id}`).pipe(
|
||||
this.toast.observe({
|
||||
loading: `Lösche Schließanlage ${system.name}...`,
|
||||
success: `Schließanlage ${system.name} wurde gelöscht.`,
|
||||
@@ -222,6 +223,21 @@ export class ApiService {
|
||||
return this.http.put(`api/key/${id}/restore`, null);
|
||||
}
|
||||
|
||||
restoreSystem(system: ISystem): Promise<boolean> {
|
||||
return new Promise(resolve => {
|
||||
this.http.put(`api/system/${system.id}/restore`, null).subscribe({
|
||||
next: () => {
|
||||
this.refreshSystems();
|
||||
resolve(true);
|
||||
},
|
||||
error: () => {
|
||||
this.toast.error('Schließanlage konnte nicht wiederhergestellt werden');
|
||||
resolve(false)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
private getCylinders(): Observable<ICylinder[]> {
|
||||
return this.http.get<ICylinder[]>('api/cylinder');
|
||||
}
|
||||
@@ -240,6 +256,20 @@ export class ApiService {
|
||||
})
|
||||
}
|
||||
|
||||
getSystemArchive(): Promise<any[]> {
|
||||
return new Promise<any[]>(resolve => {
|
||||
this.http.get<any[]>('api/system/archive').subscribe({
|
||||
next: val => {
|
||||
return resolve(val);
|
||||
},
|
||||
error: () => {
|
||||
this.toast.error('Gelöschte Schließanlagen konnten nicht geladen werden');
|
||||
return resolve([])
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualisiert die Zylinder im Behaviour Subject
|
||||
* cylinders
|
||||
|
||||
Reference in New Issue
Block a user