ng-ipa-library 1.3.12 → 1.4.2

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.
@@ -1337,13 +1337,19 @@ class ErrorInterceptor {
1337
1337
  const response = error.error;
1338
1338
  const toastrConfig = {
1339
1339
  disableTimeOut: true,
1340
+ closeButton: true,
1341
+ tapToDismiss: false,
1340
1342
  };
1341
1343
  switch (response.statusCode) {
1342
1344
  case 500:
1343
- this.toastrService.error(response?.innerException + ' ' + response?.stackTrace, response.message, toastrConfig);
1345
+ const msg = response.innerException + ' ' + (response.stackTrace ?? '');
1346
+ const toastr = this.toastrService.error(msg, response.message, toastrConfig);
1347
+ toastr.onShown.subscribe(() => {
1348
+ this.addCopyButton(response.message + '\n' + msg);
1349
+ });
1344
1350
  break;
1345
1351
  default:
1346
- this.toastrService.error(response.message, '', toastrConfig);
1352
+ this.toastrService.error('', response.message, toastrConfig);
1347
1353
  break;
1348
1354
  }
1349
1355
  return throwError(error);
@@ -1357,6 +1363,21 @@ class ErrorInterceptor {
1357
1363
  }
1358
1364
  return false;
1359
1365
  }
1366
+ addCopyButton(message) {
1367
+ const messageToast = document.getElementsByClassName('toast-message')[0];
1368
+ const icon = document.createElement('i');
1369
+ icon.classList.add('ms-2', 'fas', 'fa-copy');
1370
+ icon.addEventListener('click', () => {
1371
+ this.copyToClipboard(message);
1372
+ });
1373
+ messageToast.appendChild(icon);
1374
+ }
1375
+ copyToClipboard(message) {
1376
+ navigator.clipboard.writeText(message);
1377
+ this.toastrService.success('تم نسخ الرسالة إلى الحافظة', '', {
1378
+ positionClass: 'toast-bottom-right',
1379
+ });
1380
+ }
1360
1381
  }
1361
1382
  ErrorInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ErrorInterceptor, deps: [{ token: ErrorService }, { token: i1.ToastrService }], target: i0.ɵɵFactoryTarget.Injectable });
1362
1383
  ErrorInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ErrorInterceptor });
@@ -1423,16 +1444,41 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImpor
1423
1444
  }]
1424
1445
  }], ctorParameters: function () { return []; } });
1425
1446
 
1447
+ class TokenService {
1448
+ constructor() {
1449
+ this.urls = [];
1450
+ }
1451
+ setExceptionUrls(urls) {
1452
+ this.urls = urls;
1453
+ }
1454
+ addExceptionUrl(url) {
1455
+ this.urls.push(url);
1456
+ }
1457
+ }
1458
+ TokenService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: TokenService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1459
+ TokenService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: TokenService, providedIn: 'root' });
1460
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: TokenService, decorators: [{
1461
+ type: Injectable,
1462
+ args: [{
1463
+ providedIn: 'root',
1464
+ }]
1465
+ }], ctorParameters: function () { return []; } });
1466
+
1426
1467
  class TokenInterceptor {
1427
- constructor(authService, http, loaderService) {
1468
+ constructor(authService, http, loaderService, tokenService) {
1428
1469
  this.authService = authService;
1429
1470
  this.http = http;
1430
1471
  this.loaderService = loaderService;
1472
+ this.tokenService = tokenService;
1431
1473
  this.refresh = true;
1432
1474
  this.loaderService.addExceptionUrl({
1433
1475
  path: '/api/users?refresh',
1434
1476
  method: 'GET',
1435
1477
  });
1478
+ this.tokenService.addExceptionUrl({
1479
+ path: '/api/users?refresh',
1480
+ method: 'GET',
1481
+ });
1436
1482
  }
1437
1483
  intercept(request, next) {
1438
1484
  if (this.isException(request)) {
@@ -1478,19 +1524,20 @@ class TokenInterceptor {
1478
1524
  }
1479
1525
  }
1480
1526
  }
1481
- isException(request) {
1482
- if (request.url.includes('/api/users?refresh') &&
1483
- request.method === 'GET') {
1484
- return true;
1527
+ isException(req) {
1528
+ for (const url of this.tokenService.urls) {
1529
+ if (req.url.includes(url.path) && req.method === url.method) {
1530
+ return true;
1531
+ }
1485
1532
  }
1486
1533
  return false;
1487
1534
  }
1488
1535
  }
1489
- TokenInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: TokenInterceptor, deps: [{ token: AuthService }, { token: i2$4.HttpClient }, { token: LoaderService }], target: i0.ɵɵFactoryTarget.Injectable });
1536
+ TokenInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: TokenInterceptor, deps: [{ token: AuthService }, { token: i2$4.HttpClient }, { token: LoaderService }, { token: TokenService }], target: i0.ɵɵFactoryTarget.Injectable });
1490
1537
  TokenInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: TokenInterceptor });
1491
1538
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: TokenInterceptor, decorators: [{
1492
1539
  type: Injectable
1493
- }], ctorParameters: function () { return [{ type: AuthService }, { type: i2$4.HttpClient }, { type: LoaderService }]; } });
1540
+ }], ctorParameters: function () { return [{ type: AuthService }, { type: i2$4.HttpClient }, { type: LoaderService }, { type: TokenService }]; } });
1494
1541
 
1495
1542
  class myIPATokenInterceptor {
1496
1543
  constructor(authService) {
@@ -1732,5 +1779,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImpor
1732
1779
  * Generated bundle index. Do not edit.
1733
1780
  */
1734
1781
 
1735
- export { AuthService, BreadcrumbsService, CommonService, DropdownInputComponent, ErrorInterceptor, ErrorService, FileUploadComponent, GenerateFormComponent, GregorianDatepickerComponent, HijriDatePipe, HijriDatepickerComponent, IPAFormService, LoaderComponent, LoaderService, LoadingInterceptor, NgIPALibraryModule, PipesModule, RecaptchaComponent, ShareButtonComponent, ShareButtonModule, TextInputComponent, TextareaInputComponent, TokenInterceptor, myIPATokenInterceptor };
1782
+ export { AuthService, BreadcrumbsService, CommonService, DropdownInputComponent, ErrorInterceptor, ErrorService, FileUploadComponent, GenerateFormComponent, GregorianDatepickerComponent, HijriDatePipe, HijriDatepickerComponent, IPAFormService, LoaderComponent, LoaderService, LoadingInterceptor, NgIPALibraryModule, PipesModule, RecaptchaComponent, ShareButtonComponent, ShareButtonModule, TextInputComponent, TextareaInputComponent, TokenInterceptor, TokenService, myIPATokenInterceptor };
1736
1783
  //# sourceMappingURL=ng-ipa-library.mjs.map