Archive
This commit is contained in:
@@ -0,0 +1 @@
|
||||
<div class="delete icon-btn-sm" (click)="delete()" ></div>
|
||||
@@ -0,0 +1,8 @@
|
||||
:host {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AgDeleteKeyComponent } from './ag-delete-key.component';
|
||||
|
||||
describe('AgDeleteKeyComponent', () => {
|
||||
let component: AgDeleteKeyComponent;
|
||||
let fixture: ComponentFixture<AgDeleteKeyComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [AgDeleteKeyComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(AgDeleteKeyComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,69 @@
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { ICellRendererAngularComp } from 'ag-grid-angular';
|
||||
import { ICellRendererParams } from 'ag-grid-community';
|
||||
import { IKey } from '../../../../model/interface/key.interface';
|
||||
import { ApiService } from '../../../api.service';
|
||||
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
||||
import { DeleteKeyComponent } from '../../../../modules/keys/components/delete-key/delete-key.component';
|
||||
import { HotToastService } from '@ngxpert/hot-toast';
|
||||
|
||||
@Component({
|
||||
selector: 'app-ag-delete-key',
|
||||
standalone: true,
|
||||
imports: [MatDialogModule],
|
||||
templateUrl: './ag-delete-key.component.html',
|
||||
styleUrl: './ag-delete-key.component.scss'
|
||||
})
|
||||
export class AgDeleteKeyComponent implements ICellRendererAngularComp {
|
||||
key!: IKey;
|
||||
params!: ICellRendererParams<any, any, any>;
|
||||
|
||||
private api: ApiService = inject(ApiService);
|
||||
private dialog: MatDialog = inject(MatDialog);
|
||||
private toast = inject(HotToastService);
|
||||
|
||||
agInit(params: ICellRendererParams<any, any, any>): void {
|
||||
this.params = params;
|
||||
this.key = params.data;
|
||||
}
|
||||
refresh(params: ICellRendererParams<any, any, any>): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
delete() {
|
||||
const ref = this.dialog.open(DeleteKeyComponent, {
|
||||
data: this.key,
|
||||
autoFocus: false
|
||||
})
|
||||
|
||||
ref.afterClosed().subscribe({
|
||||
next: n => {
|
||||
if (n) {
|
||||
this.deleteThisKey();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
deleteThisKey() {
|
||||
this.params.api.setGridOption("loading", true);
|
||||
this.api.deleteKey(this.key.id).pipe(
|
||||
this.toast.observe({
|
||||
loading: 'Lösche Schlüssel ' + this.key.name,
|
||||
success: 'Schlüssel ' + this.key.name + ' gelöscht',
|
||||
error: 'Konnte nicht gelöscht werden'
|
||||
})
|
||||
).subscribe({
|
||||
next: () => {
|
||||
let data = this.params.api.getGridOption("rowData");
|
||||
data = data?.filter(d => d.id != this.key.id);
|
||||
this.params.api.setGridOption("rowData", data);
|
||||
this.params.api.setGridOption("loading", false);
|
||||
},
|
||||
error: () => {
|
||||
this.params.api.setGridOption("loading", false);
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<mat-spinner></mat-spinner>
|
||||
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AgLoadingComponent } from './ag-loading.component';
|
||||
|
||||
describe('AgLoadingComponent', () => {
|
||||
let component: AgLoadingComponent;
|
||||
let fixture: ComponentFixture<AgLoadingComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [AgLoadingComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(AgLoadingComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { ILoadingOverlayAngularComp } from 'ag-grid-angular';
|
||||
import { ILoadingOverlayParams } from 'ag-grid-community';
|
||||
|
||||
@Component({
|
||||
selector: 'app-ag-loading',
|
||||
standalone: true,
|
||||
imports: [MatProgressSpinnerModule],
|
||||
templateUrl: './ag-loading.component.html',
|
||||
styleUrl: './ag-loading.component.scss'
|
||||
})
|
||||
export class AgLoadingComponent implements ILoadingOverlayAngularComp {
|
||||
agInit(params: ILoadingOverlayParams<any, any>): void {
|
||||
|
||||
}
|
||||
refresh?(params: ILoadingOverlayParams<any, any>): void {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user