This commit is contained in:
Bastian Wagner
2024-12-27 20:57:37 +01:00
parent 5194298fa6
commit 5363d0880f
33 changed files with 640 additions and 50 deletions

View File

@@ -0,0 +1 @@
<div class="manage icon-btn-sm" (click)="openManager()" matTooltip="Manager bearbeiten" [matTooltipShowDelay]="600"></div>

View File

@@ -0,0 +1,13 @@
:host {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
gap: 12px;
}
.manage {
background-image: url('../../../../../assets/img/manager.svg');
}

View File

@@ -0,0 +1,47 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AgSystemManagerComponent } from './ag-system-manager.component';
import { MatDialogModule } from '@angular/material/dialog';
import { AgGridAngular } from 'ag-grid-angular';
import { ApiService } from '../../../api.service';
import { of } from 'rxjs';
import { HotToastService } from '@ngxpert/hot-toast';
describe('AgSystemManagerComponent', () => {
let component: AgSystemManagerComponent;
let fixture: ComponentFixture<AgSystemManagerComponent>;
let mockApiService: MockApiService;
const mockHotToastService = {
observe: jest.fn().mockImplementation(() => ({
loading: 'speichern...',
success: 'Änderungen gespeichert',
error: 'Änderungen konnten nicht gespeichert werden!',
subscribe: jest.fn().mockReturnValue(of([]))
}))
};
beforeEach(async () => {
mockApiService = new MockApiService();
await TestBed.configureTestingModule({
imports: [AgSystemManagerComponent, AgGridAngular, MatDialogModule],
providers: [
{ provide: ApiService, useValue: mockApiService },
{ provide: HotToastService, useValue: mockHotToastService },
]
})
.compileComponents();
fixture = TestBed.createComponent(AgSystemManagerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
class MockApiService {
getSystems = jest.fn();
}

View File

@@ -0,0 +1,55 @@
import { Component, inject } from '@angular/core';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { MatTooltipModule } from '@angular/material/tooltip';
import { HotToastService } from '@ngxpert/hot-toast';
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';
@Component({
selector: 'app-ag-system-manager',
standalone: true,
imports: [MatDialogModule, MatTooltipModule],
templateUrl: './ag-system-manager.component.html',
styleUrl: './ag-system-manager.component.scss'
})
export class AgSystemManagerComponent implements ICellRendererAngularComp {
private api: ApiService = inject(ApiService);
private dialog: MatDialog = inject(MatDialog);
private toast = inject(HotToastService);
params!: ICellRendererParams<any, any, any>;
system: any;
agInit(params: ICellRendererParams<any, any, any>): void {
this.params = params;
this.system = params.data;
}
refresh(params: ICellRendererParams<any, any, any>): boolean {
return false;
}
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: true
})
// ref.afterClosed().subscribe({
// next: n => {
// if (n) {
// this.deleteThisKey();
// }
// }
// })
}
}