feat: Automatische Aktualisierung nach Update und Fehlerbehandlung bei fehlgeschlagenen Updates
- Automatische Aktualisierung nach Update-Vorgängen implementiert. - Fehlermeldungen für fehlgeschlagene Updates hinzugefügt.
This commit is contained in:
parent
3ed5ca0f00
commit
08b9035083
@ -23,7 +23,7 @@ export class AppComponent {
|
||||
@HostListener('window:keydown.control.s', ['$event'])
|
||||
protected handleCtrlS(event: KeyboardEvent) {
|
||||
event.preventDefault();
|
||||
this.updateService.executeAll();
|
||||
this.updateService.executeAllAsync().then(() => this.refreshService.executeAll());
|
||||
}
|
||||
|
||||
@HostListener('window:keydown.control.r', ['$event'])
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
<button *ngIf="isLogedIn()" class="btn" (click)="this.updateService.toggleEditability()" [ngStyle]="{ 'visibility': updateService.isVisible ? 'visible' : 'hidden' }" matTooltip="strg + L" matTooltipPosition="below" [matTooltipDisabled]="!updateService.isVisible">
|
||||
<mat-icon class="scale-pulse">{{ updateService.isEditable ? 'lock_open' : 'lock' }}</mat-icon>
|
||||
</button>
|
||||
<button *ngIf="isLogedIn()" class="btn" (click)="updateService.executeAll()" [ngStyle]="{ 'visibility': updateService.isVisible ? 'visible' : 'hidden' }" matTooltip="strg + S" matTooltipPosition="below" matTooltipClass="pt-3" [matTooltipDisabled]="!updateService.isVisible">
|
||||
<button *ngIf="isLogedIn()" class="btn" (click)="saveAsync()" [ngStyle]="{ 'visibility': updateService.isVisible ? 'visible' : 'hidden' }" matTooltip="strg + S" matTooltipPosition="below" matTooltipClass="pt-3" [matTooltipDisabled]="!updateService.isVisible">
|
||||
<mat-icon class="scale-pulse" [matBadge]="updateActCount === 0 ? '' : updateActCount">save</mat-icon>
|
||||
</button>
|
||||
<button *ngIf="isLogedIn()" class="btn" (click)="transferService.executeAll()" [ngStyle]="{ 'visibility': transferService.isVisible ? 'visible' : 'hidden' }" matTooltip="strg + ␣" matTooltipPosition="below" [matTooltipDisabled]="!transferService.isVisible">
|
||||
|
||||
@ -90,4 +90,8 @@ export class NavMenuComponent {
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
|
||||
async saveAsync() {
|
||||
await this.updateService.executeAllAsync().then(() => this.refreshService.executeAll())
|
||||
}
|
||||
}
|
||||
@ -26,7 +26,7 @@ export class BasePageComponent {
|
||||
this.refreshService.removeAll()
|
||||
this.creationService.disposeComponent();
|
||||
if (this.updateService.any) {
|
||||
this.updateService.executeAll().then()
|
||||
this.updateService.executeAllAsync().then()
|
||||
}
|
||||
if(this.transferService.any)
|
||||
this.transferService.removeAll()
|
||||
|
||||
@ -72,7 +72,7 @@ export class GroupComponent extends BasePageComponent implements AfterViewInit {
|
||||
const deleteRequests = sRows.map(sRow => this.groupTable.service.delete(sRow.source.id!));
|
||||
forkJoin(deleteRequests).subscribe({
|
||||
next: () => {
|
||||
this.updateService.executeAll().then(() => {
|
||||
this.updateService.executeAllAsync().then(() => {
|
||||
this.refreshService.executeAll();
|
||||
})
|
||||
|
||||
|
||||
@ -81,7 +81,7 @@ export class UserComponent extends BasePageComponent implements AfterViewInit {
|
||||
const deleteRequests = sRows.map(sRow => this.userTable.service.delete(sRow.source.id!));
|
||||
forkJoin(deleteRequests).subscribe({
|
||||
next: () => {
|
||||
this.updateService.executeAll().then(() => {
|
||||
this.updateService.executeAllAsync().then(() => {
|
||||
this.refreshService.executeAll();
|
||||
})
|
||||
Swal.fire({
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { BaseButtonService } from './base-button.service';
|
||||
import Swal from 'sweetalert2';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -48,8 +49,17 @@ export class UpdateService extends BaseButtonService {
|
||||
}
|
||||
}
|
||||
|
||||
async executeAll(): Promise<void> {
|
||||
await Promise.all(Object.values(this.async_actions).map(action => action()));
|
||||
async executeAllAsync(): Promise<void> {
|
||||
const count = { err: 0, succ: 0, get all() { return this.err + this.succ } }
|
||||
await Promise.all(Object.values(this.async_actions).map(action => action().then(() => count.succ += 1).catch(() => count.err += 1)))
|
||||
.then(() => {
|
||||
if (count.err > 0)
|
||||
Swal.fire({
|
||||
icon: "info",
|
||||
title: "Verarbeitungsfehler",
|
||||
text: `Von ${count.all} Aktualisierungen wurden ${count.succ} erfolgreich durchgeführt, ${count.err} jedoch nicht. Der Fehler könnte durch den Versuch entstanden sein, persönliche Daten zu aktualisieren. Bitte überprüfen Sie dies.`,
|
||||
})
|
||||
});
|
||||
Object.values(this.actions).forEach(action => action());
|
||||
this.removeAll();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user