mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
Merged PR 1233: #3093 Improved Offline Handling
#3093 Improved Offline Handling
This commit is contained in:
committed by
Andreas Schickinger
parent
dafb1d335e
commit
c529134cd2
@@ -52,8 +52,8 @@ describe('HttpErrorInterceptor', () => {
|
||||
httpErrorInterceptor.handleError(error as any);
|
||||
expect(modalMock.open).toHaveBeenCalledWith({
|
||||
content: UiMessageModalComponent,
|
||||
title: 'Die Netzwerkverbindung wurde unterbrochen',
|
||||
data: { message: 'Bitte überprüfen Sie Ihre Netzwerkverbindung.' },
|
||||
title: 'Sie sind offline, keine Verbindung zum Netzwerk',
|
||||
data: { message: 'Bereits geladene Inhalte werden angezeigt. Interaktionen sind aktuell nicht möglich.' },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,8 +16,8 @@ export class HttpErrorInterceptor implements HttpInterceptor {
|
||||
if (error.status === 0) {
|
||||
this._modal.open({
|
||||
content: UiMessageModalComponent,
|
||||
title: 'Die Netzwerkverbindung wurde unterbrochen',
|
||||
data: { message: 'Bitte überprüfen Sie Ihre Netzwerkverbindung.' },
|
||||
title: 'Sie sind offline, keine Verbindung zum Netzwerk',
|
||||
data: { message: 'Bereits geladene Inhalte werden angezeigt. Interaktionen sind aktuell nicht möglich.' },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,6 @@
|
||||
.actions {
|
||||
@apply text-center;
|
||||
button {
|
||||
@apply px-5 py-3 bg-brand text-white text-cta-l rounded-full border-none outline-none;
|
||||
@apply px-5 py-3 mt-4 bg-brand text-white text-cta-l rounded-full border-none outline-none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ import { UiModalRef } from '../defs';
|
||||
})
|
||||
export class UiErrorModalComponent implements OnInit {
|
||||
get errorMessage() {
|
||||
if (!navigator.onLine) {
|
||||
return this.getOfflineMessage();
|
||||
}
|
||||
|
||||
if (this.error instanceof HttpErrorResponse) {
|
||||
if (isResponseArgs(this.error?.error)) {
|
||||
return (
|
||||
@@ -40,6 +44,10 @@ export class UiErrorModalComponent implements OnInit {
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
getOfflineMessage() {
|
||||
return 'Bereits geladene Inhalte werden angezeigt. Interaktionen sind aktuell nicht möglich.';
|
||||
}
|
||||
|
||||
getMessageFromInvalidProperties(invalidProperties: Record<string, string>): string {
|
||||
if (!isEmpty(invalidProperties)) {
|
||||
return Object.values(invalidProperties).join('\n');
|
||||
|
||||
@@ -6,7 +6,7 @@ import { UiModalRef } from './defs';
|
||||
template: `
|
||||
<p class="message">{{ modalRef.data.message }}</p>
|
||||
<div class="actions">
|
||||
<button (click)="modalRef.close(true)">{{ modalRef?.data?.closeAction || 'Schließen' }}</button>
|
||||
<button (click)="modalRef.close(true)">{{ modalRef?.data?.closeAction || 'OK' }}</button>
|
||||
</div>
|
||||
`,
|
||||
styleUrls: ['./message-modal.component.scss'],
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<ui-icon icon="close" size="21px"></ui-icon>
|
||||
</button>
|
||||
|
||||
<h1 *ngIf="!!ref.title" class="modal-title">{{ ref.title }}</h1>
|
||||
<h1 *ngIf="!!title" class="modal-title">{{ title }}</h1>
|
||||
|
||||
<div class="modal-content scroll-bar" [class.scrollX]="ref.config.showScrollbarX" [class.scrollY]="ref.config.showScrollbarY">
|
||||
<ng-container [ngSwitch]="contentType">
|
||||
|
||||
@@ -12,6 +12,10 @@ export class UiModalComponent implements OnInit {
|
||||
content: string | TemplateRef<any> | Type<any>;
|
||||
context;
|
||||
|
||||
get title() {
|
||||
return navigator.onLine ? this.ref?.title : 'Sie sind offline, keine Verbindung zum Netzwerk';
|
||||
}
|
||||
|
||||
constructor(public ref: UiModalRef) {}
|
||||
|
||||
close(): void {
|
||||
|
||||
Reference in New Issue
Block a user