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