error dialog introduced
This commit is contained in:
parent
272500df8c
commit
0e1e03f1a9
@ -5,6 +5,7 @@ import { MatExpansionPanel } from '@angular/material/expansion';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { AccountEntryCategoryService, AccountEntryService, AccountService } from '../data-object-service';
|
||||
import { Account, AccountEntry, AccountEntryCategory, NULL_AccountEntry } from '../data-objects';
|
||||
import { ErrorDialogService } from '../error-dialog.service';
|
||||
import { ExtApiService } from '../ext-data-object-service';
|
||||
import { Saldo } from '../ext-data-objects';
|
||||
import { MessageService } from '../message.service';
|
||||
@ -46,7 +47,8 @@ export class AccountComponent implements OnInit {
|
||||
private accountEntryService: AccountEntryService,
|
||||
private extApiService: ExtApiService,
|
||||
private accountEntryCategoryService: AccountEntryCategoryService,
|
||||
private messageService: MessageService
|
||||
private messageService: MessageService,
|
||||
private errorDialogService: ErrorDialogService
|
||||
) { }
|
||||
|
||||
|
||||
@ -111,11 +113,12 @@ export class AccountComponent implements OnInit {
|
||||
newAccountEntry = await this.accountEntryService.postAccountEntry(newAccountEntry)
|
||||
this.messageService.add(`New accountEntry created: ${newAccountEntry.id}`)
|
||||
|
||||
formData.reset()
|
||||
this.getAccountEntries()
|
||||
} catch (err) {
|
||||
this.messageService.add(`Error in addAccountEntry: ${JSON.stringify(err, undefined, 4)}`)
|
||||
this.errorDialogService.openDialog('AccountComponent', 'addAccountEntry', JSON.stringify(err, undefined, 4))
|
||||
} finally {
|
||||
formData.reset()
|
||||
this.addAccountEntryButton.disabled = false
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,8 @@ import { NoteComponent } from './note/note.component'
|
||||
import { MatMomentDateModule, MAT_MOMENT_DATE_ADAPTER_OPTIONS } from '@angular/material-moment-adapter';
|
||||
import { EnterPaymentComponent } from './enter-payment/enter-payment.component';
|
||||
import { HomeComponent } from './home/home.component';
|
||||
import { LedgerComponent } from './ledger/ledger.component'
|
||||
import { LedgerComponent } from './ledger/ledger.component';
|
||||
import { ErrorDialogComponent } from './error-dialog/error-dialog.component'
|
||||
|
||||
registerLocaleData(localeDe)
|
||||
|
||||
@ -78,7 +79,8 @@ registerLocaleData(localeDe)
|
||||
NoteComponent,
|
||||
EnterPaymentComponent,
|
||||
HomeComponent,
|
||||
LedgerComponent
|
||||
LedgerComponent,
|
||||
ErrorDialogComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
6
ui/hv2-ui/src/app/error-dialog-data.ts
Normal file
6
ui/hv2-ui/src/app/error-dialog-data.ts
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
export interface ErrorDialogData {
|
||||
module: string,
|
||||
func: string,
|
||||
msg: string
|
||||
}
|
16
ui/hv2-ui/src/app/error-dialog.service.spec.ts
Normal file
16
ui/hv2-ui/src/app/error-dialog.service.spec.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ErrorDialogService } from './error-dialog.service';
|
||||
|
||||
describe('ErrorDialogService', () => {
|
||||
let service: ErrorDialogService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(ErrorDialogService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
18
ui/hv2-ui/src/app/error-dialog.service.ts
Normal file
18
ui/hv2-ui/src/app/error-dialog.service.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ErrorDialogComponent } from './error-dialog/error-dialog.component';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ErrorDialogService {
|
||||
|
||||
constructor(public dialog: MatDialog) { }
|
||||
|
||||
openDialog(module: string, func: string, msg: string): void {
|
||||
const dialogRef = this.dialog.open(ErrorDialogComponent, {
|
||||
width: '450px',
|
||||
data: { module: module, func: func, msg: msg }
|
||||
})
|
||||
}
|
||||
}
|
11
ui/hv2-ui/src/app/error-dialog/error-dialog.component.html
Normal file
11
ui/hv2-ui/src/app/error-dialog/error-dialog.component.html
Normal file
@ -0,0 +1,11 @@
|
||||
<h1>Fehler</h1>
|
||||
|
||||
<h2>Module</h2>
|
||||
<p>{{data.module}}</p>
|
||||
|
||||
<h2>Function</h2>
|
||||
<p>{{data.func}}</p>
|
||||
|
||||
<h2>Message</h2>
|
||||
<p>{{data.msg}}</p>
|
||||
|
@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ErrorDialogComponent } from './error-dialog.component';
|
||||
|
||||
describe('ErrorDialogComponent', () => {
|
||||
let component: ErrorDialogComponent;
|
||||
let fixture: ComponentFixture<ErrorDialogComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ ErrorDialogComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ErrorDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
24
ui/hv2-ui/src/app/error-dialog/error-dialog.component.ts
Normal file
24
ui/hv2-ui/src/app/error-dialog/error-dialog.component.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { ErrorDialogData } from '../error-dialog-data';
|
||||
|
||||
@Component({
|
||||
selector: 'app-error-dialog',
|
||||
templateUrl: './error-dialog.component.html',
|
||||
styleUrls: ['./error-dialog.component.css']
|
||||
})
|
||||
export class ErrorDialogComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<ErrorDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: ErrorDialogData
|
||||
) { }
|
||||
|
||||
onNoClick(): void {
|
||||
this.dialogRef.close()
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user