@bnsights/bbsf-utilities 1.0.37 → 1.0.38
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/README.md +2 -2
- package/bnsights-bbsf-utilities-1.0.38.tgz +0 -0
- package/bnsights-bbsf-utilities.metadata.json +1 -1
- package/bundles/bnsights-bbsf-utilities.umd.js +403 -491
- package/bundles/bnsights-bbsf-utilities.umd.js.map +1 -1
- package/esm2015/lib/bbsf-utilities.module.js +5 -3
- package/esm2015/lib/shared/authentication/auth.service.js +127 -157
- package/esm2015/lib/shared/models/UserModel.js +3 -0
- package/esm2015/lib/shared/services/masterlayout.service.js +4 -11
- package/fesm2015/bnsights-bbsf-utilities.js +367 -400
- package/fesm2015/bnsights-bbsf-utilities.js.map +1 -1
- package/lib/shared/authentication/auth.service.d.ts +22 -16
- package/lib/shared/models/UserModel.d.ts +6 -0
- package/package.json +5 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@bnsights/bbsf-utilities', ['exports', '@angular/
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.bnsights = global.bnsights || {}, global.bnsights["bbsf-utilities"] = {}), global.ng.
|
|
5
|
-
})(this, (function (exports,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/router'), require('@ngx-translate/core'), require('ng-block-ui'), require('ngx-toastr'), require('@angular/http'), require('@angular/common/http'), require('rxjs'), require('@auth0/angular-jwt'), require('ngx-cookie-service'), require('rxjs/operators'), require('class-transformer'), require('@angular/common'), require('jszip'), require('xmlbuilder2'), require('virtual-dom/vnode/vnode'), require('virtual-dom/vnode/vtext'), require('html-to-vdom'), require('lodash'), require('nanoid'), require('virtual-dom/vnode/is-vnode'), require('virtual-dom/vnode/is-vtext'), require('escape-html'), require('image-size'), require('image-to-base64'), require('mime-types'), require('color-name')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@bnsights/bbsf-utilities', ['exports', '@angular/core', '@angular/router', '@ngx-translate/core', 'ng-block-ui', 'ngx-toastr', '@angular/http', '@angular/common/http', 'rxjs', '@auth0/angular-jwt', 'ngx-cookie-service', 'rxjs/operators', 'class-transformer', '@angular/common', 'jszip', 'xmlbuilder2', 'virtual-dom/vnode/vnode', 'virtual-dom/vnode/vtext', 'html-to-vdom', 'lodash', 'nanoid', 'virtual-dom/vnode/is-vnode', 'virtual-dom/vnode/is-vtext', 'escape-html', 'image-size', 'image-to-base64', 'mime-types', 'color-name'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.bnsights = global.bnsights || {}, global.bnsights["bbsf-utilities"] = {}), global.ng.core, global.ng.router, global.i1, global.ngBlockUi, global.ngxToastr, global.ng.http, global.ng.common.http, global.rxjs, global.angularJwt, global.i5, global.rxjs.operators, global.classTransformer, global.ng.common, global.JSZip, global.xmlbuilder2, global.VNode, global.VText, global.HTMLToVDOM, global.lodash, global.nanoid, global.isVNode, global.isVText, global.escape, global.sizeOf, global.imageToBase64, global.mimeTypes, global.colorNames));
|
|
5
|
+
})(this, (function (exports, i0, i4, i1, ngBlockUi, ngxToastr, http, i1$1, rxjs, angularJwt, i5, operators, classTransformer, i1$2, JSZip, xmlbuilder2, VNode, VText, HTMLToVDOM, lodash, nanoid, isVNode, isVText, escape, sizeOf, imageToBase64, mimeTypes, colorNames) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -24,11 +24,12 @@
|
|
|
24
24
|
return Object.freeze(n);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1$3);
|
|
28
27
|
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
29
|
-
var
|
|
28
|
+
var i4__namespace = /*#__PURE__*/_interopNamespace(i4);
|
|
30
29
|
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
|
31
|
-
var i1__namespace$
|
|
30
|
+
var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1$1);
|
|
31
|
+
var i5__namespace = /*#__PURE__*/_interopNamespace(i5);
|
|
32
|
+
var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$2);
|
|
32
33
|
var JSZip__default = /*#__PURE__*/_interopDefaultLegacy(JSZip);
|
|
33
34
|
var VNode__default = /*#__PURE__*/_interopDefaultLegacy(VNode);
|
|
34
35
|
var VText__default = /*#__PURE__*/_interopDefaultLegacy(VText);
|
|
@@ -433,6 +434,311 @@
|
|
|
433
434
|
},] }
|
|
434
435
|
];
|
|
435
436
|
|
|
437
|
+
var User = /** @class */ (function () {
|
|
438
|
+
function User() {
|
|
439
|
+
}
|
|
440
|
+
return User;
|
|
441
|
+
}());
|
|
442
|
+
|
|
443
|
+
var TOKEN_KEY = 'access_token';
|
|
444
|
+
var AuthService = /** @class */ (function () {
|
|
445
|
+
function AuthService(injector, http, environmentService, translateService, router, cookieService) {
|
|
446
|
+
this.injector = injector;
|
|
447
|
+
this.http = http;
|
|
448
|
+
this.environmentService = environmentService;
|
|
449
|
+
this.translateService = translateService;
|
|
450
|
+
this.router = router;
|
|
451
|
+
this.cookieService = cookieService;
|
|
452
|
+
this.redirectUrl = '';
|
|
453
|
+
this.jwtHelper = new angularJwt.JwtHelperService();
|
|
454
|
+
this.isAuthenticatedSubject = new rxjs.BehaviorSubject(this.hasToken());
|
|
455
|
+
this.isAuthenticate$ = this.isAuthenticatedSubject.asObservable();
|
|
456
|
+
this.user = this.getUserManager();
|
|
457
|
+
}
|
|
458
|
+
AuthService.prototype.hasToken = function () {
|
|
459
|
+
var token = this.cookieService.get(TOKEN_KEY);
|
|
460
|
+
return token && !this.jwtHelper.isTokenExpired(token);
|
|
461
|
+
};
|
|
462
|
+
AuthService.prototype.getUserManager = function () {
|
|
463
|
+
var token = this.cookieService.get(TOKEN_KEY);
|
|
464
|
+
if (token)
|
|
465
|
+
this.handleAccessTokenWithoutLanguage(token);
|
|
466
|
+
return AuthService.user;
|
|
467
|
+
};
|
|
468
|
+
AuthService.prototype.getUser = function () {
|
|
469
|
+
this.user = AuthService.user;
|
|
470
|
+
};
|
|
471
|
+
AuthService.prototype.storUser = function (User) {
|
|
472
|
+
AuthService.user = this.user = this.user;
|
|
473
|
+
};
|
|
474
|
+
AuthService.prototype.getCurrentUser = function () {
|
|
475
|
+
return AuthService.user;
|
|
476
|
+
};
|
|
477
|
+
AuthService.prototype.isAuthenticated = function () {
|
|
478
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
479
|
+
return __generator(this, function (_b) {
|
|
480
|
+
return [2 /*return*/, AuthService.user != null && !this.jwtHelper.isTokenExpired(AuthService.user.access_token)];
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
};
|
|
484
|
+
AuthService.prototype.isUserInRole = function (allowedPermission) {
|
|
485
|
+
var selectedPermissionSetID = Number.parseInt(this.user.profile['selectedpermissionsetid']);
|
|
486
|
+
return allowedPermission.includes(selectedPermissionSetID);
|
|
487
|
+
};
|
|
488
|
+
AuthService.prototype.authorizationHeaderValue = function () {
|
|
489
|
+
return AuthService.user
|
|
490
|
+
? AuthService.user.token_type + " " + AuthService.user.access_token
|
|
491
|
+
: '';
|
|
492
|
+
};
|
|
493
|
+
AuthService.prototype.name = function () {
|
|
494
|
+
return AuthService.user != null ? AuthService.user.profile.given_name : '';
|
|
495
|
+
};
|
|
496
|
+
AuthService.prototype.setUrl = function (url) {
|
|
497
|
+
localStorage.setItem('redirectUrl', url);
|
|
498
|
+
};
|
|
499
|
+
AuthService.prototype.getUrl = function () {
|
|
500
|
+
var _a;
|
|
501
|
+
return (_a = localStorage.getItem('redirectUrl')) !== null && _a !== void 0 ? _a : "/";
|
|
502
|
+
};
|
|
503
|
+
AuthService.prototype.signout = function () {
|
|
504
|
+
var _this = this;
|
|
505
|
+
AuthService.timers.map(function (t) { return clearInterval(t); });
|
|
506
|
+
AuthService.timers = [];
|
|
507
|
+
if (!this.isAuthenticated()) {
|
|
508
|
+
this.cookieService.delete(TOKEN_KEY);
|
|
509
|
+
this.router.navigate(['/Admin/account/login']);
|
|
510
|
+
}
|
|
511
|
+
this.logout().subscribe(function (res) {
|
|
512
|
+
_this.cookieService.delete(TOKEN_KEY);
|
|
513
|
+
_this.router.navigate(['/Admin/account/login']);
|
|
514
|
+
});
|
|
515
|
+
};
|
|
516
|
+
AuthService.prototype.logout = function () {
|
|
517
|
+
var httpOptions = {
|
|
518
|
+
headers: new i1$1.HttpHeaders({
|
|
519
|
+
'Content-Type': 'application/json',
|
|
520
|
+
}),
|
|
521
|
+
};
|
|
522
|
+
var ApiUrl = '/Account/';
|
|
523
|
+
return this.http.get(this.environmentService.getApiUrl() + ApiUrl + 'Logout', httpOptions);
|
|
524
|
+
};
|
|
525
|
+
AuthService.prototype.clearUserSessionClaims = function () {
|
|
526
|
+
var httpOptions = {
|
|
527
|
+
headers: new i1$1.HttpHeaders({
|
|
528
|
+
'Content-Type': 'application/json',
|
|
529
|
+
}),
|
|
530
|
+
};
|
|
531
|
+
var ApiUrl = '/api/Home/';
|
|
532
|
+
return this.http.get(this.environmentService.getBaseUrl() + ApiUrl + 'ClearCurrentUserSession', httpOptions);
|
|
533
|
+
};
|
|
534
|
+
AuthService.prototype.loginForm = function (model) {
|
|
535
|
+
var httpOptions = {
|
|
536
|
+
headers: new i1$1.HttpHeaders({
|
|
537
|
+
'Content-Type': 'application/json',
|
|
538
|
+
}),
|
|
539
|
+
};
|
|
540
|
+
var ApiUrl = '/Account/';
|
|
541
|
+
return this.http.post(this.environmentService.getApiUrl() + ApiUrl + 'Authenticate', model, httpOptions);
|
|
542
|
+
};
|
|
543
|
+
AuthService.prototype.handleAccessToken = function (response) {
|
|
544
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
545
|
+
var token;
|
|
546
|
+
return __generator(this, function (_b) {
|
|
547
|
+
switch (_b.label) {
|
|
548
|
+
case 0:
|
|
549
|
+
token = response;
|
|
550
|
+
AuthService.user = new User();
|
|
551
|
+
AuthService.user.token_type = "Bearer";
|
|
552
|
+
AuthService.user.access_token = token;
|
|
553
|
+
AuthService.user.profile = this.jwtHelper.decodeToken(token);
|
|
554
|
+
AuthService.user.expires_at = this.jwtHelper.getTokenExpirationDate(token);
|
|
555
|
+
AuthService.timers.map(function (t) { return clearInterval(t); });
|
|
556
|
+
AuthService.timers = [];
|
|
557
|
+
this.setTokenSeconds();
|
|
558
|
+
AuthService.timers.push(this.checkRefreshToken());
|
|
559
|
+
this.user = AuthService.user;
|
|
560
|
+
return [4 /*yield*/, this.updateLanguage()];
|
|
561
|
+
case 1:
|
|
562
|
+
_b.sent();
|
|
563
|
+
this.cookieService.set(TOKEN_KEY, token, null, null, null, true, 'Strict');
|
|
564
|
+
this.isAuthenticatedSubject.next(true);
|
|
565
|
+
return [2 /*return*/];
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
});
|
|
569
|
+
};
|
|
570
|
+
AuthService.prototype.handleAccessTokenWithoutLanguage = function (response) {
|
|
571
|
+
var token = response;
|
|
572
|
+
AuthService.user = new User();
|
|
573
|
+
AuthService.user.token_type = "Bearer";
|
|
574
|
+
AuthService.user.access_token = token;
|
|
575
|
+
AuthService.user.profile = this.jwtHelper.decodeToken(token);
|
|
576
|
+
AuthService.user.expires_at = this.jwtHelper.getTokenExpirationDate(token);
|
|
577
|
+
this.setTokenSeconds();
|
|
578
|
+
this.user = AuthService.user;
|
|
579
|
+
this.cookieService.set(TOKEN_KEY, token, null, null, null, true, 'Strict');
|
|
580
|
+
this.isAuthenticatedSubject.next(true);
|
|
581
|
+
};
|
|
582
|
+
AuthService.prototype.updateLanguage = function () {
|
|
583
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
584
|
+
return __generator(this, function (_b) {
|
|
585
|
+
switch (_b.label) {
|
|
586
|
+
case 0:
|
|
587
|
+
if (!localStorage.getItem('language') ||
|
|
588
|
+
localStorage.getItem('language') == this.user.profile.locale)
|
|
589
|
+
localStorage.setItem('language', this.user.profile.locale);
|
|
590
|
+
if (!(this.translateService.currentLang != localStorage.getItem('language'))) return [3 /*break*/, 2];
|
|
591
|
+
this.translateService.resetLang(this.translateService.currentLang);
|
|
592
|
+
return [4 /*yield*/, this.translateService
|
|
593
|
+
.reloadLang(localStorage.getItem('language'))
|
|
594
|
+
.subscribe(function (res) {
|
|
595
|
+
console.log(res);
|
|
596
|
+
})];
|
|
597
|
+
case 1:
|
|
598
|
+
_b.sent();
|
|
599
|
+
_b.label = 2;
|
|
600
|
+
case 2: return [2 /*return*/];
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
});
|
|
604
|
+
};
|
|
605
|
+
AuthService.prototype.checkRefreshToken = function () {
|
|
606
|
+
var _this = this;
|
|
607
|
+
var date = new Date();
|
|
608
|
+
return setInterval(function () {
|
|
609
|
+
if (Math.floor(AuthService.seconds) < 120 && _this.isAuthenticated())
|
|
610
|
+
_this.refresh();
|
|
611
|
+
AuthService.seconds--;
|
|
612
|
+
}, 1000);
|
|
613
|
+
};
|
|
614
|
+
AuthService.prototype.setTokenSeconds = function () {
|
|
615
|
+
var date = new Date();
|
|
616
|
+
AuthService.seconds = (AuthService.user.expires_at - date) / 1000;
|
|
617
|
+
};
|
|
618
|
+
AuthService.prototype.refresh = function () {
|
|
619
|
+
var _this = this;
|
|
620
|
+
var httpOptions = {
|
|
621
|
+
headers: new i1$1.HttpHeaders({
|
|
622
|
+
'Content-Type': 'application/json',
|
|
623
|
+
'Authorization': this.authorizationHeaderValue(),
|
|
624
|
+
}),
|
|
625
|
+
};
|
|
626
|
+
var ApiUrl = '/api/Home/';
|
|
627
|
+
this.http.get(this.environmentService.getApiUrl() + ApiUrl + 'RefreshAccessToken', httpOptions).subscribe(function (res) {
|
|
628
|
+
_this.cookieService.delete(TOKEN_KEY);
|
|
629
|
+
_this.handleAccessTokenWithoutLanguage(res);
|
|
630
|
+
});
|
|
631
|
+
};
|
|
632
|
+
return AuthService;
|
|
633
|
+
}());
|
|
634
|
+
AuthService.user = null;
|
|
635
|
+
AuthService.UserClaims = null;
|
|
636
|
+
//refresh
|
|
637
|
+
AuthService.timers = [];
|
|
638
|
+
AuthService.seconds = 0;
|
|
639
|
+
AuthService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function AuthService_Factory() { return new AuthService(i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(EnvironmentService), i0__namespace.ɵɵinject(BBSFTranslateService), i0__namespace.ɵɵinject(i4__namespace.Router), i0__namespace.ɵɵinject(i5__namespace.CookieService)); }, token: AuthService, providedIn: "root" });
|
|
640
|
+
AuthService.decorators = [
|
|
641
|
+
{ type: i0.Injectable, args: [{
|
|
642
|
+
providedIn: 'root',
|
|
643
|
+
},] }
|
|
644
|
+
];
|
|
645
|
+
AuthService.ctorParameters = function () { return [
|
|
646
|
+
{ type: i0.Injector },
|
|
647
|
+
{ type: i1$1.HttpClient },
|
|
648
|
+
{ type: EnvironmentService },
|
|
649
|
+
{ type: BBSFTranslateService },
|
|
650
|
+
{ type: i4.Router },
|
|
651
|
+
{ type: i5.CookieService }
|
|
652
|
+
]; };
|
|
653
|
+
|
|
654
|
+
var UtilityService = /** @class */ (function () {
|
|
655
|
+
function UtilityService(translator, authService, environmentService) {
|
|
656
|
+
this.translator = translator;
|
|
657
|
+
this.authService = authService;
|
|
658
|
+
this.environmentService = environmentService;
|
|
659
|
+
this.isCreatedBefore = false;
|
|
660
|
+
}
|
|
661
|
+
UtilityService.prototype.getResourceValue = function (Key) {
|
|
662
|
+
var ResourceValue = this.translator.instant(Key);
|
|
663
|
+
return ResourceValue;
|
|
664
|
+
};
|
|
665
|
+
UtilityService.prototype.getCurrentLanguage = function () {
|
|
666
|
+
var currentLanguage = this.environmentService.getDefaultLanguage();
|
|
667
|
+
var lang = localStorage.getItem('language');
|
|
668
|
+
if (lang)
|
|
669
|
+
currentLanguage = lang;
|
|
670
|
+
else
|
|
671
|
+
localStorage.setItem('language', currentLanguage);
|
|
672
|
+
return currentLanguage;
|
|
673
|
+
};
|
|
674
|
+
UtilityService.prototype.isCurrentLanguageEnglish = function () {
|
|
675
|
+
return this.getCurrentLanguage() == "en";
|
|
676
|
+
};
|
|
677
|
+
UtilityService.prototype.isCurrentLanguageArabic = function () {
|
|
678
|
+
return this.getCurrentLanguage() == "ar";
|
|
679
|
+
};
|
|
680
|
+
UtilityService.prototype.notifySuccessMessage = function (Message, title, time, showHeader) {
|
|
681
|
+
if (showHeader === void 0) { showHeader = true; }
|
|
682
|
+
var MessageTemplate = this.getResourceValue("SuccessMessage");
|
|
683
|
+
var titleTemplate;
|
|
684
|
+
if (Message) {
|
|
685
|
+
MessageTemplate = Message;
|
|
686
|
+
}
|
|
687
|
+
if (title) {
|
|
688
|
+
titleTemplate = title;
|
|
689
|
+
}
|
|
690
|
+
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
691
|
+
showHeader ? toaster.success(MessageTemplate, titleTemplate) : toaster.success(MessageTemplate);
|
|
692
|
+
};
|
|
693
|
+
UtilityService.prototype.notifyErrorMessage = function (Message, title, time, showHeader) {
|
|
694
|
+
if (showHeader === void 0) { showHeader = true; }
|
|
695
|
+
var MessageTemplate = this.getResourceValue("ErrorMessage");
|
|
696
|
+
var titleTemplate = this.getResourceValue("Error");
|
|
697
|
+
if (Message) {
|
|
698
|
+
MessageTemplate = Message;
|
|
699
|
+
}
|
|
700
|
+
if (title) {
|
|
701
|
+
titleTemplate = title;
|
|
702
|
+
}
|
|
703
|
+
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
704
|
+
showHeader ? toaster.error(MessageTemplate, titleTemplate) : toaster.error(MessageTemplate);
|
|
705
|
+
};
|
|
706
|
+
UtilityService.prototype.notifyWarningMessage = function (Message, title, time, showHeader) {
|
|
707
|
+
if (showHeader === void 0) { showHeader = true; }
|
|
708
|
+
var MessageTemplate = this.getResourceValue("WarningMessage");
|
|
709
|
+
var titleTemplate = this.getResourceValue("Warning");
|
|
710
|
+
if (Message) {
|
|
711
|
+
MessageTemplate = Message;
|
|
712
|
+
}
|
|
713
|
+
if (title) {
|
|
714
|
+
titleTemplate = title;
|
|
715
|
+
}
|
|
716
|
+
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
717
|
+
showHeader ? toaster.warning(MessageTemplate, titleTemplate) : toaster.warning(MessageTemplate);
|
|
718
|
+
};
|
|
719
|
+
UtilityService.prototype.startBlockUI = function () {
|
|
720
|
+
this.blockUI.start();
|
|
721
|
+
};
|
|
722
|
+
UtilityService.prototype.stopBlockUI = function () {
|
|
723
|
+
this.blockUI.stop();
|
|
724
|
+
};
|
|
725
|
+
return UtilityService;
|
|
726
|
+
}());
|
|
727
|
+
UtilityService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function UtilityService_Factory() { return new UtilityService(i0__namespace.ɵɵinject(BBSFTranslateService), i0__namespace.ɵɵinject(AuthService), i0__namespace.ɵɵinject(EnvironmentService)); }, token: UtilityService, providedIn: "root" });
|
|
728
|
+
UtilityService.decorators = [
|
|
729
|
+
{ type: i0.Injectable, args: [{
|
|
730
|
+
providedIn: 'root'
|
|
731
|
+
},] }
|
|
732
|
+
];
|
|
733
|
+
UtilityService.ctorParameters = function () { return [
|
|
734
|
+
{ type: BBSFTranslateService },
|
|
735
|
+
{ type: AuthService },
|
|
736
|
+
{ type: EnvironmentService }
|
|
737
|
+
]; };
|
|
738
|
+
__decorate([
|
|
739
|
+
ngBlockUi.BlockUI()
|
|
740
|
+
], UtilityService.prototype, "blockUI", void 0);
|
|
741
|
+
|
|
436
742
|
var RequestOptionsModel = /** @class */ (function () {
|
|
437
743
|
function RequestOptionsModel() {
|
|
438
744
|
this.disableSuccessNotification = false;
|
|
@@ -645,7 +951,7 @@
|
|
|
645
951
|
{ type: EnvironmentService },
|
|
646
952
|
{ type: UtilityService },
|
|
647
953
|
{ type: BBSFTranslateService },
|
|
648
|
-
{ type:
|
|
954
|
+
{ type: i4.Router }
|
|
649
955
|
]; };
|
|
650
956
|
|
|
651
957
|
var StylesBundleService = /** @class */ (function () {
|
|
@@ -688,494 +994,22 @@
|
|
|
688
994
|
};
|
|
689
995
|
return StylesBundleService;
|
|
690
996
|
}());
|
|
691
|
-
StylesBundleService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function StylesBundleService_Factory() { return new StylesBundleService(i0__namespace.ɵɵinject(i1__namespace$
|
|
997
|
+
StylesBundleService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function StylesBundleService_Factory() { return new StylesBundleService(i0__namespace.ɵɵinject(i1__namespace$2.DOCUMENT), i0__namespace.ɵɵinject(BBSFTranslateService)); }, token: StylesBundleService, providedIn: "root" });
|
|
692
998
|
StylesBundleService.decorators = [
|
|
693
999
|
{ type: i0.Injectable, args: [{
|
|
694
1000
|
providedIn: 'root'
|
|
695
1001
|
},] }
|
|
696
1002
|
];
|
|
697
1003
|
StylesBundleService.ctorParameters = function () { return [
|
|
698
|
-
{ type: Document, decorators: [{ type: i0.Inject, args: [i1$
|
|
1004
|
+
{ type: Document, decorators: [{ type: i0.Inject, args: [i1$2.DOCUMENT,] }] },
|
|
699
1005
|
{ type: BBSFTranslateService }
|
|
700
1006
|
]; };
|
|
701
1007
|
|
|
702
|
-
var
|
|
703
|
-
function
|
|
704
|
-
this.
|
|
705
|
-
this.
|
|
706
|
-
this.
|
|
707
|
-
this.stylesBundleService = stylesBundleService;
|
|
708
|
-
this.translate = translate;
|
|
709
|
-
this.environmentService = environmentService;
|
|
710
|
-
this.ApiUrl = '/api/Home/';
|
|
711
|
-
}
|
|
712
|
-
MasterLayoutService.prototype.switchLang = function (lang, bundleEnglishName, bundleArabicName) {
|
|
713
|
-
var _this = this;
|
|
714
|
-
this.changeLanguage(lang).subscribe(function (result) {
|
|
715
|
-
_this.updateUserInfo().subscribe(function (Value) {
|
|
716
|
-
var UserInfoObject = Value;
|
|
717
|
-
_this.authService.getUser();
|
|
718
|
-
_this.authService.user.profile = Object.assign(_this.authService.user.profile, UserInfoObject);
|
|
719
|
-
_this.authService.storUser(_this.authService.user);
|
|
720
|
-
_this.stylesBundleService.loadThemes(lang, bundleEnglishName, bundleArabicName);
|
|
721
|
-
localStorage.setItem('language', lang);
|
|
722
|
-
_this.translate.use(lang);
|
|
723
|
-
});
|
|
724
|
-
});
|
|
725
|
-
};
|
|
726
|
-
MasterLayoutService.prototype.reloadComponent = function () {
|
|
727
|
-
var currentUrl = this.router.url;
|
|
728
|
-
this.router.routeReuseStrategy.shouldReuseRoute = function () { return false; };
|
|
729
|
-
this.router.onSameUrlNavigation = 'reload';
|
|
730
|
-
this.router.navigate([currentUrl]);
|
|
731
|
-
};
|
|
732
|
-
MasterLayoutService.prototype.changeLanguage = function (key) {
|
|
733
|
-
var params = new i1$1.HttpParams();
|
|
734
|
-
params = params.append('UserId', this.authService.user.profile.id);
|
|
735
|
-
params = params.append('LanguageKey', key);
|
|
736
|
-
return this.http.post(this.ApiUrl + 'UpdateLanguage', null, null, params);
|
|
737
|
-
};
|
|
738
|
-
MasterLayoutService.prototype.getUserClaims = function () {
|
|
739
|
-
return this.http.get(this.ApiUrl + 'GetUserClaims', null, null);
|
|
740
|
-
};
|
|
741
|
-
MasterLayoutService.prototype.logError = function (error) {
|
|
742
|
-
var params = new i1$1.HttpParams();
|
|
743
|
-
params = params.append('error', error);
|
|
744
|
-
return this.http.post(this.ApiUrl + 'LogError', null, null, params);
|
|
745
|
-
};
|
|
746
|
-
MasterLayoutService.prototype.updateUserInfo = function () {
|
|
747
|
-
var isExternal = this.environmentService.getIsIdentityServerExternal().toLowerCase() == 'true';
|
|
748
|
-
if (isExternal)
|
|
749
|
-
return this.getUserClaims();
|
|
750
|
-
return this.http.get('/connect/userinfo');
|
|
751
|
-
};
|
|
752
|
-
MasterLayoutService.prototype.switchRole = function (permissionSetID) {
|
|
753
|
-
var _this = this;
|
|
754
|
-
this.updateRole(permissionSetID).subscribe(function (result) {
|
|
755
|
-
_this.updateUserInfo().subscribe(function (Value) {
|
|
756
|
-
var UserInfoObject = Value;
|
|
757
|
-
_this.authService.getUser();
|
|
758
|
-
_this.authService.user.profile = Object.assign(_this.authService.user.profile, UserInfoObject);
|
|
759
|
-
_this.authService.storUser(_this.authService.user);
|
|
760
|
-
});
|
|
761
|
-
});
|
|
762
|
-
};
|
|
763
|
-
MasterLayoutService.prototype.updateRole = function (permissionSetID) {
|
|
764
|
-
var params = new i1$1.HttpParams();
|
|
765
|
-
params = params.append('UserId', this.authService.user.profile.id);
|
|
766
|
-
params = params.append('RoleID', permissionSetID);
|
|
767
|
-
return this.http.post(this.ApiUrl + 'SwitchRole', null, null, params);
|
|
768
|
-
};
|
|
769
|
-
return MasterLayoutService;
|
|
770
|
-
}());
|
|
771
|
-
MasterLayoutService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function MasterLayoutService_Factory() { return new MasterLayoutService(i0__namespace.ɵɵinject(i1__namespace$2.Router), i0__namespace.ɵɵinject(RequestHandlerService), i0__namespace.ɵɵinject(AuthService), i0__namespace.ɵɵinject(StylesBundleService), i0__namespace.ɵɵinject(i1__namespace.TranslateService), i0__namespace.ɵɵinject(EnvironmentService)); }, token: MasterLayoutService, providedIn: "root" });
|
|
772
|
-
MasterLayoutService.decorators = [
|
|
773
|
-
{ type: i0.Injectable, args: [{
|
|
774
|
-
providedIn: 'root',
|
|
775
|
-
},] }
|
|
776
|
-
];
|
|
777
|
-
MasterLayoutService.ctorParameters = function () { return [
|
|
778
|
-
{ type: i1$2.Router },
|
|
779
|
-
{ type: RequestHandlerService },
|
|
780
|
-
{ type: AuthService },
|
|
781
|
-
{ type: StylesBundleService },
|
|
782
|
-
{ type: i1.TranslateService },
|
|
783
|
-
{ type: EnvironmentService }
|
|
784
|
-
]; };
|
|
785
|
-
|
|
786
|
-
var AuthService = /** @class */ (function () {
|
|
787
|
-
function AuthService(injector, http, environmentService, translateService, router) {
|
|
788
|
-
var _this = this;
|
|
789
|
-
this.injector = injector;
|
|
790
|
-
this.http = http;
|
|
791
|
-
this.environmentService = environmentService;
|
|
792
|
-
this.translateService = translateService;
|
|
793
|
-
this.router = router;
|
|
794
|
-
// Observable navItem source
|
|
795
|
-
this._authNavStatusSource = new rxjs.BehaviorSubject(false);
|
|
796
|
-
// Observable navItem stream
|
|
797
|
-
this.authNavStatus$ = this._authNavStatusSource.asObservable();
|
|
798
|
-
// Observable navItem source
|
|
799
|
-
this._userSource = new rxjs.Subject();
|
|
800
|
-
this.UserStatus$ = this._userSource.asObservable();
|
|
801
|
-
this.manager = this.getUserManager();
|
|
802
|
-
this.redirectUrl = '';
|
|
803
|
-
this.manager.getUser().then(function (user) { return __awaiter(_this, void 0, void 0, function () {
|
|
804
|
-
var _a, _b;
|
|
805
|
-
return __generator(this, function (_c) {
|
|
806
|
-
switch (_c.label) {
|
|
807
|
-
case 0:
|
|
808
|
-
this.manager.storeUser(user);
|
|
809
|
-
AuthService.user = user;
|
|
810
|
-
this.user = user;
|
|
811
|
-
_b = (_a = this._authNavStatusSource).next;
|
|
812
|
-
return [4 /*yield*/, this.isAuthenticated()];
|
|
813
|
-
case 1:
|
|
814
|
-
_b.apply(_a, [_c.sent()]);
|
|
815
|
-
return [2 /*return*/];
|
|
816
|
-
}
|
|
817
|
-
});
|
|
818
|
-
}); });
|
|
819
|
-
this.manager.events.addAccessTokenExpired(function (_) {
|
|
820
|
-
_this._authNavStatusSource.next(false);
|
|
821
|
-
});
|
|
822
|
-
}
|
|
823
|
-
AuthService.prototype.getUserManager = function () {
|
|
824
|
-
var user = null;
|
|
825
|
-
var isExternal = this.environmentService.getIsIdentityServerExternal().toLowerCase() ==
|
|
826
|
-
'true';
|
|
827
|
-
if (isExternal) {
|
|
828
|
-
user = new oidcClient.UserManager({
|
|
829
|
-
authority: this.environmentService.getIdentityServerUrl(),
|
|
830
|
-
client_id: this.environmentService.getIsIdentityServerClientId(),
|
|
831
|
-
client_secret: this.environmentService.getIsIdentityServerClientSecret(),
|
|
832
|
-
redirect_uri: this.environmentService.getBaseUrl() +
|
|
833
|
-
'/Admin/authentication/auth-callback',
|
|
834
|
-
post_logout_redirect_uri: this.environmentService.getBaseUrl(),
|
|
835
|
-
response_type: 'code',
|
|
836
|
-
scope: 'openid profile email',
|
|
837
|
-
filterProtocolClaims: true,
|
|
838
|
-
loadUserInfo: true,
|
|
839
|
-
automaticSilentRenew: true,
|
|
840
|
-
silent_redirect_uri: this.environmentService.getBaseUrl() + '/assets/silent-callback.html',
|
|
841
|
-
userStore: new oidcClient.WebStorageStateStore({ store: window.localStorage }),
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
else {
|
|
845
|
-
user = new oidcClient.UserManager({
|
|
846
|
-
authority: this.environmentService.getIdentityServerUrl(),
|
|
847
|
-
client_id: 'angular_spa',
|
|
848
|
-
redirect_uri: this.environmentService.getBaseUrl() +
|
|
849
|
-
'/Admin/authentication/auth-callback',
|
|
850
|
-
post_logout_redirect_uri: this.environmentService.getBaseUrl(),
|
|
851
|
-
response_type: 'id_token token',
|
|
852
|
-
scope: 'openid profile email IdentityServerApi',
|
|
853
|
-
filterProtocolClaims: true,
|
|
854
|
-
loadUserInfo: true,
|
|
855
|
-
automaticSilentRenew: true,
|
|
856
|
-
silent_redirect_uri: this.environmentService.getBaseUrl() + '/assets/silent-callback.html',
|
|
857
|
-
userStore: new oidcClient.WebStorageStateStore({ store: window.localStorage }),
|
|
858
|
-
});
|
|
859
|
-
}
|
|
860
|
-
return user;
|
|
861
|
-
};
|
|
862
|
-
AuthService.prototype.login = function () {
|
|
863
|
-
return this.manager.signinRedirect();
|
|
864
|
-
};
|
|
865
|
-
AuthService.prototype.getUser = function () {
|
|
866
|
-
var _this = this;
|
|
867
|
-
this.manager.getUser().then(function (user) { return __awaiter(_this, void 0, void 0, function () {
|
|
868
|
-
var _a, _b;
|
|
869
|
-
return __generator(this, function (_c) {
|
|
870
|
-
switch (_c.label) {
|
|
871
|
-
case 0:
|
|
872
|
-
AuthService.user = user;
|
|
873
|
-
this.user = user;
|
|
874
|
-
_b = (_a = this._authNavStatusSource).next;
|
|
875
|
-
return [4 /*yield*/, this.isAuthenticated()];
|
|
876
|
-
case 1:
|
|
877
|
-
_b.apply(_a, [_c.sent()]);
|
|
878
|
-
return [2 /*return*/];
|
|
879
|
-
}
|
|
880
|
-
});
|
|
881
|
-
}); });
|
|
882
|
-
};
|
|
883
|
-
AuthService.prototype.storUser = function (User) {
|
|
884
|
-
this.manager.storeUser(User);
|
|
885
|
-
};
|
|
886
|
-
AuthService.prototype.revokeAccessToken = function () {
|
|
887
|
-
this.manager.revokeAccessToken();
|
|
888
|
-
};
|
|
889
|
-
AuthService.prototype.signinSilent = function () {
|
|
890
|
-
var x = this.manager.signinSilentCallback();
|
|
891
|
-
x.then(function (s) {
|
|
892
|
-
//console.log(s)
|
|
893
|
-
});
|
|
894
|
-
};
|
|
895
|
-
AuthService.prototype.completeAuthentication = function () {
|
|
896
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
897
|
-
var _a, _b, _c, isExternal, masterLayoutService, userClaims, _d, _e;
|
|
898
|
-
return __generator(this, function (_f) {
|
|
899
|
-
switch (_f.label) {
|
|
900
|
-
case 0:
|
|
901
|
-
_a = this;
|
|
902
|
-
return [4 /*yield*/, this.manager.signinRedirectCallback()];
|
|
903
|
-
case 1:
|
|
904
|
-
_a.user = _f.sent();
|
|
905
|
-
AuthService.user = this.user;
|
|
906
|
-
this._userSource.next(AuthService.user);
|
|
907
|
-
_c = (_b = this._authNavStatusSource).next;
|
|
908
|
-
return [4 /*yield*/, this.isAuthenticated()];
|
|
909
|
-
case 2:
|
|
910
|
-
_c.apply(_b, [_f.sent()]);
|
|
911
|
-
isExternal = this.environmentService.getIsIdentityServerExternal().toLowerCase() ==
|
|
912
|
-
'true';
|
|
913
|
-
if (!isExternal) return [3 /*break*/, 4];
|
|
914
|
-
masterLayoutService = this.injector.get(MasterLayoutService);
|
|
915
|
-
return [4 /*yield*/, masterLayoutService.getUserClaims().toPromise()
|
|
916
|
-
.then(function (e) {
|
|
917
|
-
AuthService.UserClaims = e;
|
|
918
|
-
}, function (error) {
|
|
919
|
-
console.log(error);
|
|
920
|
-
})];
|
|
921
|
-
case 3:
|
|
922
|
-
userClaims = _f.sent();
|
|
923
|
-
AuthService.user.profile = Object.assign(AuthService.user.profile, AuthService.UserClaims);
|
|
924
|
-
_f.label = 4;
|
|
925
|
-
case 4:
|
|
926
|
-
this.storUser(AuthService.user);
|
|
927
|
-
if (!localStorage.getItem('language') ||
|
|
928
|
-
localStorage.getItem('language') == this.user.profile.locale)
|
|
929
|
-
localStorage.setItem('language', this.user.profile.locale);
|
|
930
|
-
if (!(this.translateService.currentLang != localStorage.getItem('language'))) return [3 /*break*/, 6];
|
|
931
|
-
this.translateService.resetLang(this.translateService.currentLang);
|
|
932
|
-
return [4 /*yield*/, this.translateService
|
|
933
|
-
.reloadLang(localStorage.getItem('language'))
|
|
934
|
-
.subscribe(function (res) {
|
|
935
|
-
console.log(res);
|
|
936
|
-
})];
|
|
937
|
-
case 5:
|
|
938
|
-
_f.sent();
|
|
939
|
-
_f.label = 6;
|
|
940
|
-
case 6:
|
|
941
|
-
this._userSource.next(AuthService.user);
|
|
942
|
-
_e = (_d = this._authNavStatusSource).next;
|
|
943
|
-
return [4 /*yield*/, this.isAuthenticated()];
|
|
944
|
-
case 7:
|
|
945
|
-
_e.apply(_d, [_f.sent()]);
|
|
946
|
-
this.user = AuthService.user;
|
|
947
|
-
return [2 /*return*/];
|
|
948
|
-
}
|
|
949
|
-
});
|
|
950
|
-
});
|
|
951
|
-
};
|
|
952
|
-
AuthService.prototype.refreshToken = function (token) {
|
|
953
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
954
|
-
var httpOptions;
|
|
955
|
-
var _this = this;
|
|
956
|
-
return __generator(this, function (_a) {
|
|
957
|
-
switch (_a.label) {
|
|
958
|
-
case 0:
|
|
959
|
-
httpOptions = {
|
|
960
|
-
headers: new i1$1.HttpHeaders({
|
|
961
|
-
'Content-Type': 'application/json',
|
|
962
|
-
Authorization: token,
|
|
963
|
-
}),
|
|
964
|
-
};
|
|
965
|
-
this.manager.revokeAccessToken();
|
|
966
|
-
return [4 /*yield*/, this.http
|
|
967
|
-
.post(this.environmentService.getIdentityServerUrl() + "/users/refresh-token", httpOptions, { withCredentials: true })
|
|
968
|
-
.subscribe(function (user) {
|
|
969
|
-
_this._userSource.next(user);
|
|
970
|
-
AuthService.user = user;
|
|
971
|
-
_this.user = user;
|
|
972
|
-
})];
|
|
973
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
974
|
-
}
|
|
975
|
-
});
|
|
976
|
-
});
|
|
977
|
-
};
|
|
978
|
-
AuthService.prototype.getCurrentUser = function () {
|
|
979
|
-
return this.manager.getUser();
|
|
980
|
-
};
|
|
981
|
-
AuthService.prototype.isAuthenticated = function () {
|
|
982
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
983
|
-
var user;
|
|
984
|
-
return __generator(this, function (_a) {
|
|
985
|
-
switch (_a.label) {
|
|
986
|
-
case 0: return [4 /*yield*/, this.manager.getUser().then(function (user) {
|
|
987
|
-
return user;
|
|
988
|
-
})];
|
|
989
|
-
case 1:
|
|
990
|
-
user = _a.sent();
|
|
991
|
-
return [2 /*return*/, this.user != null && !this.user.expired];
|
|
992
|
-
}
|
|
993
|
-
});
|
|
994
|
-
});
|
|
995
|
-
};
|
|
996
|
-
AuthService.prototype.isUserInRole = function (allowedPermission) {
|
|
997
|
-
var selectedPermissionSetID = Number.parseInt(this.user.profile['selectedpermissionsetid']);
|
|
998
|
-
return allowedPermission.includes(selectedPermissionSetID);
|
|
999
|
-
};
|
|
1000
|
-
AuthService.prototype.authorizationHeaderValue = function () {
|
|
1001
|
-
return AuthService.user
|
|
1002
|
-
? AuthService.user.token_type + " " + AuthService.user.access_token
|
|
1003
|
-
: '';
|
|
1004
|
-
};
|
|
1005
|
-
AuthService.prototype.name = function () {
|
|
1006
|
-
return AuthService.user != null ? AuthService.user.profile.given_name : '';
|
|
1007
|
-
};
|
|
1008
|
-
AuthService.prototype.setUrl = function (url) {
|
|
1009
|
-
localStorage.setItem('redirectUrl', url);
|
|
1010
|
-
};
|
|
1011
|
-
AuthService.prototype.getUrl = function () {
|
|
1012
|
-
return localStorage.getItem('redirectUrl');
|
|
1013
|
-
};
|
|
1014
|
-
AuthService.prototype.signinSilentCallback = function () {
|
|
1015
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1016
|
-
var user;
|
|
1017
|
-
return __generator(this, function (_a) {
|
|
1018
|
-
switch (_a.label) {
|
|
1019
|
-
case 0: return [4 /*yield*/, this.manager.signinSilentCallback()];
|
|
1020
|
-
case 1:
|
|
1021
|
-
user = _a.sent();
|
|
1022
|
-
//await this.manager.storeUser(user);
|
|
1023
|
-
AuthService.user = user;
|
|
1024
|
-
console.log('Token from signinSilentCallback :' + AuthService.user);
|
|
1025
|
-
this.user = user;
|
|
1026
|
-
return [2 /*return*/];
|
|
1027
|
-
}
|
|
1028
|
-
});
|
|
1029
|
-
});
|
|
1030
|
-
};
|
|
1031
|
-
AuthService.prototype.signout = function () {
|
|
1032
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1033
|
-
var isExternal;
|
|
1034
|
-
return __generator(this, function (_a) {
|
|
1035
|
-
switch (_a.label) {
|
|
1036
|
-
case 0: return [4 /*yield*/, !this.isAuthenticated()];
|
|
1037
|
-
case 1:
|
|
1038
|
-
if (_a.sent())
|
|
1039
|
-
this.router.navigate(['/Admin/account/login']), localStorage.clear();
|
|
1040
|
-
isExternal = this.environmentService.getIsIdentityServerExternal().toLowerCase() ==
|
|
1041
|
-
'true';
|
|
1042
|
-
if (!isExternal) return [3 /*break*/, 3];
|
|
1043
|
-
return [4 /*yield*/, this.clearUserSessionClaims()
|
|
1044
|
-
.toPromise()
|
|
1045
|
-
.then(function (res) {
|
|
1046
|
-
var result = res;
|
|
1047
|
-
})];
|
|
1048
|
-
case 2:
|
|
1049
|
-
_a.sent();
|
|
1050
|
-
_a.label = 3;
|
|
1051
|
-
case 3: return [4 /*yield*/, this.manager.signoutRedirect()];
|
|
1052
|
-
case 4:
|
|
1053
|
-
_a.sent();
|
|
1054
|
-
return [2 /*return*/];
|
|
1055
|
-
}
|
|
1056
|
-
});
|
|
1057
|
-
});
|
|
1058
|
-
};
|
|
1059
|
-
AuthService.prototype.clearUserSessionClaims = function () {
|
|
1060
|
-
var httpOptions = {
|
|
1061
|
-
headers: new i1$1.HttpHeaders({
|
|
1062
|
-
'Content-Type': 'application/json',
|
|
1063
|
-
}),
|
|
1064
|
-
};
|
|
1065
|
-
var ApiUrl = '/api/Home/';
|
|
1066
|
-
return this.http.get(this.environmentService.getBaseUrl() + ApiUrl + 'ClearCurrentUserSession', httpOptions);
|
|
1067
|
-
};
|
|
1068
|
-
return AuthService;
|
|
1069
|
-
}());
|
|
1070
|
-
AuthService.user = null;
|
|
1071
|
-
AuthService.UserClaims = null;
|
|
1072
|
-
AuthService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function AuthService_Factory() { return new AuthService(i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(i1__namespace$3.HttpClient), i0__namespace.ɵɵinject(EnvironmentService), i0__namespace.ɵɵinject(BBSFTranslateService), i0__namespace.ɵɵinject(i1__namespace$2.Router)); }, token: AuthService, providedIn: "root" });
|
|
1073
|
-
AuthService.decorators = [
|
|
1074
|
-
{ type: i0.Injectable, args: [{
|
|
1075
|
-
providedIn: 'root',
|
|
1076
|
-
},] }
|
|
1077
|
-
];
|
|
1078
|
-
AuthService.ctorParameters = function () { return [
|
|
1079
|
-
{ type: i0.Injector },
|
|
1080
|
-
{ type: i1$1.HttpClient },
|
|
1081
|
-
{ type: EnvironmentService },
|
|
1082
|
-
{ type: BBSFTranslateService },
|
|
1083
|
-
{ type: i1$2.Router }
|
|
1084
|
-
]; };
|
|
1085
|
-
|
|
1086
|
-
var UtilityService = /** @class */ (function () {
|
|
1087
|
-
function UtilityService(translator, authService, environmentService) {
|
|
1088
|
-
this.translator = translator;
|
|
1089
|
-
this.authService = authService;
|
|
1090
|
-
this.environmentService = environmentService;
|
|
1091
|
-
this.isCreatedBefore = false;
|
|
1092
|
-
}
|
|
1093
|
-
UtilityService.prototype.getResourceValue = function (Key) {
|
|
1094
|
-
var ResourceValue = this.translator.instant(Key);
|
|
1095
|
-
return ResourceValue;
|
|
1096
|
-
};
|
|
1097
|
-
UtilityService.prototype.getCurrentLanguage = function () {
|
|
1098
|
-
var currentLanguage = this.environmentService.getDefaultLanguage();
|
|
1099
|
-
var lang = localStorage.getItem('language');
|
|
1100
|
-
if (lang)
|
|
1101
|
-
currentLanguage = lang;
|
|
1102
|
-
else
|
|
1103
|
-
localStorage.setItem('language', currentLanguage);
|
|
1104
|
-
return currentLanguage;
|
|
1105
|
-
};
|
|
1106
|
-
UtilityService.prototype.isCurrentLanguageEnglish = function () {
|
|
1107
|
-
return this.getCurrentLanguage() == "en";
|
|
1108
|
-
};
|
|
1109
|
-
UtilityService.prototype.isCurrentLanguageArabic = function () {
|
|
1110
|
-
return this.getCurrentLanguage() == "ar";
|
|
1111
|
-
};
|
|
1112
|
-
UtilityService.prototype.notifySuccessMessage = function (Message, title, time, showHeader) {
|
|
1113
|
-
if (showHeader === void 0) { showHeader = true; }
|
|
1114
|
-
var MessageTemplate = this.getResourceValue("SuccessMessage");
|
|
1115
|
-
var titleTemplate;
|
|
1116
|
-
if (Message) {
|
|
1117
|
-
MessageTemplate = Message;
|
|
1118
|
-
}
|
|
1119
|
-
if (title) {
|
|
1120
|
-
titleTemplate = title;
|
|
1121
|
-
}
|
|
1122
|
-
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
1123
|
-
showHeader ? toaster.success(MessageTemplate, titleTemplate) : toaster.success(MessageTemplate);
|
|
1124
|
-
};
|
|
1125
|
-
UtilityService.prototype.notifyErrorMessage = function (Message, title, time, showHeader) {
|
|
1126
|
-
if (showHeader === void 0) { showHeader = true; }
|
|
1127
|
-
var MessageTemplate = this.getResourceValue("ErrorMessage");
|
|
1128
|
-
var titleTemplate = this.getResourceValue("Error");
|
|
1129
|
-
if (Message) {
|
|
1130
|
-
MessageTemplate = Message;
|
|
1131
|
-
}
|
|
1132
|
-
if (title) {
|
|
1133
|
-
titleTemplate = title;
|
|
1134
|
-
}
|
|
1135
|
-
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
1136
|
-
showHeader ? toaster.error(MessageTemplate, titleTemplate) : toaster.error(MessageTemplate);
|
|
1137
|
-
};
|
|
1138
|
-
UtilityService.prototype.notifyWarningMessage = function (Message, title, time, showHeader) {
|
|
1139
|
-
if (showHeader === void 0) { showHeader = true; }
|
|
1140
|
-
var MessageTemplate = this.getResourceValue("WarningMessage");
|
|
1141
|
-
var titleTemplate = this.getResourceValue("Warning");
|
|
1142
|
-
if (Message) {
|
|
1143
|
-
MessageTemplate = Message;
|
|
1144
|
-
}
|
|
1145
|
-
if (title) {
|
|
1146
|
-
titleTemplate = title;
|
|
1147
|
-
}
|
|
1148
|
-
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
1149
|
-
showHeader ? toaster.warning(MessageTemplate, titleTemplate) : toaster.warning(MessageTemplate);
|
|
1150
|
-
};
|
|
1151
|
-
UtilityService.prototype.startBlockUI = function () {
|
|
1152
|
-
this.blockUI.start();
|
|
1153
|
-
};
|
|
1154
|
-
UtilityService.prototype.stopBlockUI = function () {
|
|
1155
|
-
this.blockUI.stop();
|
|
1156
|
-
};
|
|
1157
|
-
return UtilityService;
|
|
1158
|
-
}());
|
|
1159
|
-
UtilityService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function UtilityService_Factory() { return new UtilityService(i0__namespace.ɵɵinject(BBSFTranslateService), i0__namespace.ɵɵinject(AuthService), i0__namespace.ɵɵinject(EnvironmentService)); }, token: UtilityService, providedIn: "root" });
|
|
1160
|
-
UtilityService.decorators = [
|
|
1161
|
-
{ type: i0.Injectable, args: [{
|
|
1162
|
-
providedIn: 'root'
|
|
1163
|
-
},] }
|
|
1164
|
-
];
|
|
1165
|
-
UtilityService.ctorParameters = function () { return [
|
|
1166
|
-
{ type: BBSFTranslateService },
|
|
1167
|
-
{ type: AuthService },
|
|
1168
|
-
{ type: EnvironmentService }
|
|
1169
|
-
]; };
|
|
1170
|
-
__decorate([
|
|
1171
|
-
ngBlockUi.BlockUI()
|
|
1172
|
-
], UtilityService.prototype, "blockUI", void 0);
|
|
1173
|
-
|
|
1174
|
-
var ControlValidationService = /** @class */ (function () {
|
|
1175
|
-
function ControlValidationService(utilityService) {
|
|
1176
|
-
this.utilityService = utilityService;
|
|
1177
|
-
this.requestOptions = new RequestOptionsModel();
|
|
1178
|
-
this.isCreatedBefor = false;
|
|
1008
|
+
var ControlValidationService = /** @class */ (function () {
|
|
1009
|
+
function ControlValidationService(utilityService) {
|
|
1010
|
+
this.utilityService = utilityService;
|
|
1011
|
+
this.requestOptions = new RequestOptionsModel();
|
|
1012
|
+
this.isCreatedBefor = false;
|
|
1179
1013
|
}
|
|
1180
1014
|
ControlValidationService.prototype.showGlobalError = function (errorMessage, formId, deleteOld) {
|
|
1181
1015
|
var e_1, _a;
|
|
@@ -1363,6 +1197,83 @@
|
|
|
1363
1197
|
ngBlockUi.BlockUI()
|
|
1364
1198
|
], ControlValidationService.prototype, "blockUI", void 0);
|
|
1365
1199
|
|
|
1200
|
+
var MasterLayoutService = /** @class */ (function () {
|
|
1201
|
+
function MasterLayoutService(router, http, authService, stylesBundleService, translate, environmentService) {
|
|
1202
|
+
this.router = router;
|
|
1203
|
+
this.http = http;
|
|
1204
|
+
this.authService = authService;
|
|
1205
|
+
this.stylesBundleService = stylesBundleService;
|
|
1206
|
+
this.translate = translate;
|
|
1207
|
+
this.environmentService = environmentService;
|
|
1208
|
+
this.ApiUrl = '/api/Home/';
|
|
1209
|
+
}
|
|
1210
|
+
MasterLayoutService.prototype.switchLang = function (lang, bundleEnglishName, bundleArabicName) {
|
|
1211
|
+
var _this = this;
|
|
1212
|
+
this.changeLanguage(lang).subscribe(function (result) {
|
|
1213
|
+
_this.updateUserInfo().subscribe(function (Value) {
|
|
1214
|
+
var UserInfoObject = Value;
|
|
1215
|
+
_this.authService.handleAccessToken(UserInfoObject.token);
|
|
1216
|
+
_this.stylesBundleService.loadThemes(lang, bundleEnglishName, bundleArabicName);
|
|
1217
|
+
localStorage.setItem('language', lang);
|
|
1218
|
+
_this.translate.use(lang);
|
|
1219
|
+
});
|
|
1220
|
+
});
|
|
1221
|
+
};
|
|
1222
|
+
MasterLayoutService.prototype.reloadComponent = function () {
|
|
1223
|
+
var currentUrl = this.router.url;
|
|
1224
|
+
this.router.routeReuseStrategy.shouldReuseRoute = function () { return false; };
|
|
1225
|
+
this.router.onSameUrlNavigation = 'reload';
|
|
1226
|
+
this.router.navigate([currentUrl]);
|
|
1227
|
+
};
|
|
1228
|
+
MasterLayoutService.prototype.changeLanguage = function (key) {
|
|
1229
|
+
var params = new i1$1.HttpParams();
|
|
1230
|
+
params = params.append('UserId', this.authService.user.profile.id);
|
|
1231
|
+
params = params.append('LanguageKey', key);
|
|
1232
|
+
return this.http.post(this.ApiUrl + 'UpdateLanguage', null, null, params);
|
|
1233
|
+
};
|
|
1234
|
+
MasterLayoutService.prototype.getUserClaims = function () {
|
|
1235
|
+
return this.http.get(this.ApiUrl + 'GetUserClaims', null, null);
|
|
1236
|
+
};
|
|
1237
|
+
MasterLayoutService.prototype.logError = function (error) {
|
|
1238
|
+
var params = new i1$1.HttpParams();
|
|
1239
|
+
params = params.append('error', error);
|
|
1240
|
+
return this.http.post(this.ApiUrl + 'LogError', null, null, params);
|
|
1241
|
+
};
|
|
1242
|
+
MasterLayoutService.prototype.updateUserInfo = function () {
|
|
1243
|
+
return this.http.get(this.ApiUrl + 'UpdateUserInfo', null, null);
|
|
1244
|
+
};
|
|
1245
|
+
MasterLayoutService.prototype.switchRole = function (permissionSetID) {
|
|
1246
|
+
var _this = this;
|
|
1247
|
+
this.updateRole(permissionSetID).subscribe(function (result) {
|
|
1248
|
+
_this.updateUserInfo().subscribe(function (Value) {
|
|
1249
|
+
var UserInfoObject = Value;
|
|
1250
|
+
_this.authService.handleAccessToken(UserInfoObject.token);
|
|
1251
|
+
});
|
|
1252
|
+
});
|
|
1253
|
+
};
|
|
1254
|
+
MasterLayoutService.prototype.updateRole = function (permissionSetID) {
|
|
1255
|
+
var params = new i1$1.HttpParams();
|
|
1256
|
+
params = params.append('UserId', this.authService.user.profile.id);
|
|
1257
|
+
params = params.append('RoleID', permissionSetID);
|
|
1258
|
+
return this.http.post(this.ApiUrl + 'SwitchRole', null, null, params);
|
|
1259
|
+
};
|
|
1260
|
+
return MasterLayoutService;
|
|
1261
|
+
}());
|
|
1262
|
+
MasterLayoutService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function MasterLayoutService_Factory() { return new MasterLayoutService(i0__namespace.ɵɵinject(i4__namespace.Router), i0__namespace.ɵɵinject(RequestHandlerService), i0__namespace.ɵɵinject(AuthService), i0__namespace.ɵɵinject(StylesBundleService), i0__namespace.ɵɵinject(i1__namespace.TranslateService), i0__namespace.ɵɵinject(EnvironmentService)); }, token: MasterLayoutService, providedIn: "root" });
|
|
1263
|
+
MasterLayoutService.decorators = [
|
|
1264
|
+
{ type: i0.Injectable, args: [{
|
|
1265
|
+
providedIn: 'root',
|
|
1266
|
+
},] }
|
|
1267
|
+
];
|
|
1268
|
+
MasterLayoutService.ctorParameters = function () { return [
|
|
1269
|
+
{ type: i4.Router },
|
|
1270
|
+
{ type: RequestHandlerService },
|
|
1271
|
+
{ type: AuthService },
|
|
1272
|
+
{ type: StylesBundleService },
|
|
1273
|
+
{ type: i1.TranslateService },
|
|
1274
|
+
{ type: EnvironmentService }
|
|
1275
|
+
]; };
|
|
1276
|
+
|
|
1366
1277
|
var ConfigurationService = /** @class */ (function () {
|
|
1367
1278
|
function ConfigurationService(httpClient) {
|
|
1368
1279
|
this.httpClient = httpClient;
|
|
@@ -1376,7 +1287,7 @@
|
|
|
1376
1287
|
return ConfigurationService;
|
|
1377
1288
|
}());
|
|
1378
1289
|
ConfigurationService.JsonData = [];
|
|
1379
|
-
ConfigurationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ConfigurationService_Factory() { return new ConfigurationService(i0__namespace.ɵɵinject(i1__namespace$
|
|
1290
|
+
ConfigurationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ConfigurationService_Factory() { return new ConfigurationService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient)); }, token: ConfigurationService, providedIn: "root" });
|
|
1380
1291
|
ConfigurationService.decorators = [
|
|
1381
1292
|
{ type: i0.Injectable, args: [{
|
|
1382
1293
|
providedIn: 'root'
|
|
@@ -1398,10 +1309,10 @@
|
|
|
1398
1309
|
{ type: i0.NgModule, args: [{
|
|
1399
1310
|
declarations: [],
|
|
1400
1311
|
imports: [
|
|
1401
|
-
i1$
|
|
1312
|
+
i1$2.CommonModule,
|
|
1402
1313
|
ngBlockUi.BlockUIModule.forRoot(),
|
|
1403
1314
|
http.HttpModule,
|
|
1404
|
-
|
|
1315
|
+
i4.RouterModule,
|
|
1405
1316
|
ngxToastr.ToastrModule.forRoot(),
|
|
1406
1317
|
],
|
|
1407
1318
|
exports: [],
|
|
@@ -1415,7 +1326,8 @@
|
|
|
1415
1326
|
BBSFTranslateService,
|
|
1416
1327
|
ControlValidationService,
|
|
1417
1328
|
MasterLayoutService,
|
|
1418
|
-
ConfigurationService
|
|
1329
|
+
ConfigurationService,
|
|
1330
|
+
i5.CookieService
|
|
1419
1331
|
]
|
|
1420
1332
|
},] }
|
|
1421
1333
|
];
|