ng-ipa-library 1.4.6 → 1.4.9

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.
@@ -108,7 +108,7 @@ class IPAFormService {
108
108
  static validHijriDate(control) {
109
109
  const date = control.value;
110
110
  const isValid = IPAFormService.checkHijriDateValid(date);
111
- return isValid
111
+ return isValid || !date
112
112
  ? null
113
113
  : {
114
114
  ngbDate: {
@@ -1140,13 +1140,15 @@ class ShareButtonComponent {
1140
1140
  }
1141
1141
  ngAfterViewInit() {
1142
1142
  const elements = document.getElementsByClassName('sb-show-icon');
1143
- elements[0].setAttribute('type', 'button');
1144
- elements[0].setAttribute('id', 'IPAShareBtn');
1145
- const label = document.createElement('label');
1146
- label.innerHTML = this.btnLabel;
1147
- label.classList.add('sm-share-title');
1148
- label.classList.add('me-1');
1149
- elements[0].before(label);
1143
+ if (!elements[0].getAttribute('id')) {
1144
+ elements[0].setAttribute('type', 'button');
1145
+ elements[0].setAttribute('id', 'IPAShareBtn');
1146
+ const label = document.createElement('label');
1147
+ label.innerHTML = this.btnLabel;
1148
+ label.classList.add('sm-share-title');
1149
+ label.classList.add('me-1');
1150
+ elements[0].before(label);
1151
+ }
1150
1152
  }
1151
1153
  }
1152
1154
  ShareButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ShareButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
@@ -1346,8 +1348,81 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImpor
1346
1348
  type: Injectable
1347
1349
  }], ctorParameters: function () { return [{ type: LoaderService }]; } });
1348
1350
 
1351
+ class CommonService {
1352
+ constructor(toastrService) {
1353
+ this.toastrService = toastrService;
1354
+ }
1355
+ copyToClipboard(message) {
1356
+ navigator.clipboard.writeText(message);
1357
+ this.toastrService.success('تم نسخ الرسالة إلى الحافظة', '', {
1358
+ positionClass: 'toast-bottom-right',
1359
+ });
1360
+ }
1361
+ print(element, title, classes) {
1362
+ const styles = this.getElementTag('style');
1363
+ const links = this.getElementTag('link');
1364
+ const scripts = this.getElementTag('script');
1365
+ const printContents = document.getElementById(element)?.innerHTML;
1366
+ const popupWin = window.open('', '', 'top=0,left=0,height=100%,width=auto');
1367
+ const data = `
1368
+ <!DOCTYPE html>
1369
+ <head>
1370
+ <title> ${title} </title>
1371
+ <meta charset="utf-8">
1372
+ ${links}
1373
+ ${styles}
1374
+ <style>
1375
+ @media print {
1376
+ .noPrint{
1377
+ display: none !important;
1378
+ }
1379
+ body {
1380
+ direction: rtl;
1381
+ }
1382
+ }
1383
+ </style>
1384
+ </head>
1385
+ <body class="${classes}">
1386
+ ${printContents}
1387
+ ${scripts}
1388
+ </body>
1389
+
1390
+ </html>`;
1391
+ popupWin?.document.open();
1392
+ popupWin?.document.write(data);
1393
+ popupWin?.document.close();
1394
+ popupWin?.focus();
1395
+ popupWin?.addEventListener('focus', () => {
1396
+ setTimeout(() => {
1397
+ if (popupWin.document.hasFocus()) {
1398
+ popupWin.print();
1399
+ popupWin.close();
1400
+ }
1401
+ }, 1000);
1402
+ });
1403
+ }
1404
+ getElementTag(tag) {
1405
+ const html = [];
1406
+ const elements = document.getElementsByTagName(tag);
1407
+ for (let index = 0; index < elements.length; index++) {
1408
+ html.push(elements[index].outerHTML);
1409
+ }
1410
+ return html.join('\r\n');
1411
+ }
1412
+ }
1413
+ CommonService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CommonService, deps: [{ token: i1.ToastrService }], target: i0.ɵɵFactoryTarget.Injectable });
1414
+ CommonService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CommonService, providedIn: 'root' });
1415
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CommonService, decorators: [{
1416
+ type: Injectable,
1417
+ args: [{
1418
+ providedIn: 'root',
1419
+ }]
1420
+ }], ctorParameters: function () { return [{ type: i1.ToastrService }]; } });
1421
+
1349
1422
  class ErrorService {
1350
- constructor() {
1423
+ constructor(toastrService, commonService) {
1424
+ this.toastrService = toastrService;
1425
+ this.commonService = commonService;
1351
1426
  this.urls = [];
1352
1427
  }
1353
1428
  setExceptionUrls(urls) {
@@ -1356,20 +1431,48 @@ class ErrorService {
1356
1431
  addExceptionUrl(url) {
1357
1432
  this.urls.push(url);
1358
1433
  }
1434
+ showErrorMsg(response, toastrConfig) {
1435
+ if (response.errors && response.errors.length > 0) {
1436
+ toastrConfig.enableHtml = true;
1437
+ let msg = '';
1438
+ response.errors.forEach((error) => {
1439
+ msg += `<li>${error}</li>`;
1440
+ });
1441
+ this.toastrService.error(`<ul>${msg}</ul>`, response.message, toastrConfig);
1442
+ }
1443
+ else {
1444
+ this.toastrService.error('', response.message, toastrConfig);
1445
+ }
1446
+ }
1447
+ show500ErrorMsg(response, toastrConfig) {
1448
+ const msg = response.innerException + ' ' + (response.stackTrace ?? '');
1449
+ const toastr = this.toastrService.error(msg, response.message, toastrConfig);
1450
+ toastr.onShown.subscribe(() => {
1451
+ this.addCopyButton(response.message + '\n' + msg);
1452
+ });
1453
+ }
1454
+ addCopyButton(message) {
1455
+ const messageToast = document.getElementsByClassName('toast-message')[0];
1456
+ const icon = document.createElement('i');
1457
+ icon.classList.add('ms-2', 'fas', 'fa-copy');
1458
+ icon.addEventListener('click', () => {
1459
+ this.commonService.copyToClipboard(message);
1460
+ });
1461
+ messageToast.appendChild(icon);
1462
+ }
1359
1463
  }
1360
- ErrorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ErrorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1464
+ ErrorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ErrorService, deps: [{ token: i1.ToastrService }, { token: CommonService }], target: i0.ɵɵFactoryTarget.Injectable });
1361
1465
  ErrorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ErrorService, providedIn: 'root' });
1362
1466
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ErrorService, decorators: [{
1363
1467
  type: Injectable,
1364
1468
  args: [{
1365
- providedIn: 'root'
1469
+ providedIn: 'root',
1366
1470
  }]
1367
- }], ctorParameters: function () { return []; } });
1471
+ }], ctorParameters: function () { return [{ type: i1.ToastrService }, { type: CommonService }]; } });
1368
1472
 
1369
1473
  class ErrorInterceptor {
1370
- constructor(errorService, toastrService) {
1474
+ constructor(errorService) {
1371
1475
  this.errorService = errorService;
1372
- this.toastrService = toastrService;
1373
1476
  }
1374
1477
  intercept(req, next) {
1375
1478
  if (this.isException(req)) {
@@ -1384,10 +1487,10 @@ class ErrorInterceptor {
1384
1487
  };
1385
1488
  switch (response.statusCode) {
1386
1489
  case 500:
1387
- this.show500ErrorMsg(response, toastrConfig);
1490
+ this.errorService.show500ErrorMsg(response, toastrConfig);
1388
1491
  break;
1389
1492
  default:
1390
- this.showErrorMsg(response, toastrConfig);
1493
+ this.errorService.showErrorMsg(response, toastrConfig);
1391
1494
  break;
1392
1495
  }
1393
1496
  return throwError(() => error);
@@ -1401,47 +1504,12 @@ class ErrorInterceptor {
1401
1504
  }
1402
1505
  return false;
1403
1506
  }
1404
- showErrorMsg(response, toastrConfig) {
1405
- if (response.errors && response.errors.length > 0) {
1406
- toastrConfig.enableHtml = true;
1407
- let msg = '';
1408
- response.errors.forEach((error) => {
1409
- msg += `<li>${error}</li>`;
1410
- });
1411
- this.toastrService.error(`<ul>${msg}</ul>`, response.message, toastrConfig);
1412
- }
1413
- else {
1414
- this.toastrService.error('', response.message, toastrConfig);
1415
- }
1416
- }
1417
- show500ErrorMsg(response, toastrConfig) {
1418
- const msg = response.innerException + ' ' + (response.stackTrace ?? '');
1419
- const toastr = this.toastrService.error(msg, response.message, toastrConfig);
1420
- toastr.onShown.subscribe(() => {
1421
- this.addCopyButton(response.message + '\n' + msg);
1422
- });
1423
- }
1424
- addCopyButton(message) {
1425
- const messageToast = document.getElementsByClassName('toast-message')[0];
1426
- const icon = document.createElement('i');
1427
- icon.classList.add('ms-2', 'fas', 'fa-copy');
1428
- icon.addEventListener('click', () => {
1429
- this.copyToClipboard(message);
1430
- });
1431
- messageToast.appendChild(icon);
1432
- }
1433
- copyToClipboard(message) {
1434
- navigator.clipboard.writeText(message);
1435
- this.toastrService.success('تم نسخ الرسالة إلى الحافظة', '', {
1436
- positionClass: 'toast-bottom-right',
1437
- });
1438
- }
1439
1507
  }
1440
- 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 });
1508
+ ErrorInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ErrorInterceptor, deps: [{ token: ErrorService }], target: i0.ɵɵFactoryTarget.Injectable });
1441
1509
  ErrorInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ErrorInterceptor });
1442
1510
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ErrorInterceptor, decorators: [{
1443
1511
  type: Injectable
1444
- }], ctorParameters: function () { return [{ type: ErrorService }, { type: i1.ToastrService }]; } });
1512
+ }], ctorParameters: function () { return [{ type: ErrorService }]; } });
1445
1513
 
1446
1514
  class AuthService {
1447
1515
  constructor() {
@@ -1766,69 +1834,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImpor
1766
1834
  }]
1767
1835
  }], ctorParameters: function () { return []; } });
1768
1836
 
1769
- class CommonService {
1770
- constructor() { }
1771
- print(element, title, classes) {
1772
- const styles = this.getElementTag('style');
1773
- const linkes = this.getElementTag('link');
1774
- const scripts = this.getElementTag('script');
1775
- const printContents = document.getElementById(element)?.innerHTML;
1776
- const popupWin = window.open('', '', 'top=0,left=0,height=100%,width=auto');
1777
- const data = `
1778
- <!DOCTYPE html>
1779
- <head>
1780
- <title> ${title} </title>
1781
- <meta charset="utf-8">
1782
- ${linkes}
1783
- ${styles}
1784
- <style>
1785
- @media print {
1786
- .noPrint{
1787
- display: none !important;
1788
- }
1789
- body {
1790
- direction: rtl;
1791
- }
1792
- }
1793
- </style>
1794
- </head>
1795
- <body class="${classes}">
1796
- ${printContents}
1797
- ${scripts}
1798
- </body>
1799
-
1800
- </html>`;
1801
- popupWin?.document.open();
1802
- popupWin?.document.write(data);
1803
- popupWin?.document.close();
1804
- popupWin?.focus();
1805
- popupWin?.addEventListener('focus', () => {
1806
- setTimeout(() => {
1807
- if (popupWin.document.hasFocus()) {
1808
- popupWin.print();
1809
- popupWin.close();
1810
- }
1811
- }, 1000);
1812
- });
1813
- }
1814
- getElementTag(tag) {
1815
- const html = [];
1816
- const elements = document.getElementsByTagName(tag);
1817
- for (let index = 0; index < elements.length; index++) {
1818
- html.push(elements[index].outerHTML);
1819
- }
1820
- return html.join('\r\n');
1821
- }
1822
- }
1823
- CommonService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CommonService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1824
- CommonService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CommonService, providedIn: 'root' });
1825
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CommonService, decorators: [{
1826
- type: Injectable,
1827
- args: [{
1828
- providedIn: 'root',
1829
- }]
1830
- }], ctorParameters: function () { return []; } });
1831
-
1832
1837
  /*
1833
1838
  * Public API Surface of ipa-library
1834
1839
  */