xxx
This commit is contained in:
@@ -0,0 +1 @@
|
||||
<p>ag-base-component works!</p>
|
||||
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AgBaseComponentComponent } from './ag-base-component.component';
|
||||
|
||||
describe('AgBaseComponentComponent', () => {
|
||||
let component: AgBaseComponentComponent;
|
||||
let fixture: ComponentFixture<AgBaseComponentComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [AgBaseComponentComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(AgBaseComponentComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
||||
import { HotToastService } from '@ngxpert/hot-toast';
|
||||
import { ApiService } from '../../../api.service';
|
||||
import { ICellRendererAngularComp } from 'ag-grid-angular';
|
||||
import { ICellRendererParams } from 'ag-grid-community';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [MatDialogModule, MatTooltipModule],
|
||||
templateUrl: './ag-base-component.component.html',
|
||||
styleUrl: './ag-base-component.component.scss'
|
||||
})
|
||||
export class AgBaseComponentComponent implements ICellRendererAngularComp {
|
||||
protected api: ApiService = inject(ApiService);
|
||||
protected dialog: MatDialog = inject(MatDialog);
|
||||
protected toast = inject(HotToastService);
|
||||
params!: ICellRendererParams<any, any, any>;
|
||||
|
||||
agInit(params: ICellRendererParams<any, any, any>): void {
|
||||
this.params = params;
|
||||
}
|
||||
refresh(params: ICellRendererParams<any, any, any>): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<div class="delete icon-btn-sm" (click)="delete()" matTooltip="Löschen" [matTooltipShowDelay]="600"></div>
|
||||
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AgDeleteCylinderComponent } from './ag-delete-cylinder.component';
|
||||
|
||||
describe('AgDeleteCylinderComponent', () => {
|
||||
let component: AgDeleteCylinderComponent;
|
||||
let fixture: ComponentFixture<AgDeleteCylinderComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [AgDeleteCylinderComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(AgDeleteCylinderComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,47 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { AgBaseComponentComponent } from '../ag-base-component/ag-base-component.component';
|
||||
import { DeleteCylinderComponent } from '../../../../modules/cylinder/components/delete-cylinder/delete-cylinder.component';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
|
||||
@Component({
|
||||
selector: 'app-ag-delete-cylinder',
|
||||
standalone: true,
|
||||
imports: [MatTooltipModule],
|
||||
templateUrl: './ag-delete-cylinder.component.html',
|
||||
styleUrl: './ag-delete-cylinder.component.scss'
|
||||
})
|
||||
export class AgDeleteCylinderComponent extends AgBaseComponentComponent {
|
||||
|
||||
|
||||
delete() {
|
||||
const ref = this.dialog.open(DeleteCylinderComponent, {
|
||||
data: this.params.data,
|
||||
autoFocus: false
|
||||
})
|
||||
|
||||
ref.afterClosed().subscribe({
|
||||
next: n => {
|
||||
if (n) {
|
||||
this.deleteThisCylinder();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
deleteThisCylinder() {
|
||||
this.api.deleteCylinder(this.params.data)
|
||||
.pipe(
|
||||
this.toast.observe({
|
||||
loading: 'Löschen...',
|
||||
success: 'Gelöscht!',
|
||||
error: 'Konnte nicht gelöscht werden'
|
||||
})
|
||||
).subscribe({
|
||||
next: () => {
|
||||
const rows = this.params.api.getGridOption("rowData")?.filter(r => r.id != this.params.data.id);
|
||||
this.params.api.setGridOption("rowData", rows);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { inject, Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { IUser } from '../model/interface/user.interface';
|
||||
import { IKey } from '../model/interface/key.interface';
|
||||
import { ICylinder } from '../model/interface/cylinder.interface';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -37,8 +38,12 @@ export class ApiService {
|
||||
return this.http.post<IKey>('api/key', key);
|
||||
}
|
||||
|
||||
postKeySystem(keySystem: any) {
|
||||
return this.http.post('api/key/system', keySystem);
|
||||
createSystem(keySystem: any) {
|
||||
return this.http.post('api/system', keySystem);
|
||||
}
|
||||
|
||||
getSystems(): Observable<any[]> {
|
||||
return this.http.get<any[]>('api/system');
|
||||
}
|
||||
|
||||
handoverKey(data: any) {
|
||||
@@ -69,7 +74,11 @@ export class ApiService {
|
||||
return this.http.put(`api/key/${id}/restore`, null);
|
||||
}
|
||||
|
||||
getCylinders(): Observable<any[]> {
|
||||
return this.http.get<any[]>('api/cylinder');
|
||||
getCylinders(): Observable<ICylinder[]> {
|
||||
return this.http.get<ICylinder[]>('api/cylinder');
|
||||
}
|
||||
|
||||
deleteCylinder(cylinder: ICylinder): Observable<any> {
|
||||
return this.http.delete(`api/cylinder/${cylinder.id}`)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user