@nettyapps/ntybase 21.1.3 → 21.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -383,26 +383,17 @@ class AlertService {
|
|
|
383
383
|
});
|
|
384
384
|
}
|
|
385
385
|
// For error notifications
|
|
386
|
-
showError(error, duration = 5000) {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
}
|
|
391
|
-
else if (error.message) {
|
|
392
|
-
errorMessage = error.message;
|
|
393
|
-
}
|
|
394
|
-
else if (error.error && typeof error.error === 'string') {
|
|
395
|
-
errorMessage = error.error;
|
|
396
|
-
}
|
|
397
|
-
else {
|
|
398
|
-
errorMessage = JSON.stringify(error);
|
|
399
|
-
}
|
|
386
|
+
showError(error, customComponent = ErrorAlert, duration = 5000, width = 'auto', height = 'auto') {
|
|
387
|
+
const dialogData = (typeof error === 'object' && error.errors)
|
|
388
|
+
? error
|
|
389
|
+
: { message: this.getErrorMessage(error) };
|
|
400
390
|
return new Promise((resolve) => {
|
|
401
|
-
const dialogRef = this.dialog.open(
|
|
402
|
-
width:
|
|
403
|
-
height:
|
|
391
|
+
const dialogRef = this.dialog.open(customComponent, {
|
|
392
|
+
width: width,
|
|
393
|
+
height: height,
|
|
394
|
+
maxWidth: '95vw',
|
|
404
395
|
data: {
|
|
405
|
-
|
|
396
|
+
...dialogData,
|
|
406
397
|
title: this.translate.instant('@errorOccurred'),
|
|
407
398
|
},
|
|
408
399
|
});
|
|
@@ -411,6 +402,15 @@ class AlertService {
|
|
|
411
402
|
});
|
|
412
403
|
});
|
|
413
404
|
}
|
|
405
|
+
getErrorMessage(error) {
|
|
406
|
+
if (typeof error === 'string')
|
|
407
|
+
return error;
|
|
408
|
+
if (error.error && typeof error.error === 'string')
|
|
409
|
+
return error.error;
|
|
410
|
+
if (error.message)
|
|
411
|
+
return error.message;
|
|
412
|
+
return JSON.stringify(error);
|
|
413
|
+
}
|
|
414
414
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: AlertService, deps: [{ token: i1$2.MatSnackBar }, { token: i1.MatDialog }, { token: i1$1.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
415
415
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: AlertService, providedIn: 'root' });
|
|
416
416
|
}
|