@bnsights/bbsf-utilities 1.0.37 → 1.0.39
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 +6 -2
- package/bnsights-bbsf-utilities-1.0.39.tgz +0 -0
- package/bnsights-bbsf-utilities.metadata.json +1 -1
- package/bundles/bnsights-bbsf-utilities.umd.js +403 -500
- 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 +122 -157
- package/esm2015/lib/shared/models/UserModel.js +3 -0
- package/esm2015/lib/shared/services/masterlayout.service.js +4 -11
- package/esm2015/lib/shared/services/utility.service.js +4 -8
- package/fesm2015/bnsights-bbsf-utilities.js +362 -404
- package/fesm2015/bnsights-bbsf-utilities.js.map +1 -1
- package/lib/shared/authentication/auth.service.d.ts +25 -17
- package/lib/shared/models/UserModel.d.ts +6 -0
- package/lib/shared/services/utility.service.d.ts +1 -3
- 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);
|
|
@@ -359,6 +360,20 @@
|
|
|
359
360
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
360
361
|
}
|
|
361
362
|
|
|
363
|
+
var BBSFTranslateService = /** @class */ (function (_super) {
|
|
364
|
+
__extends(BBSFTranslateService, _super);
|
|
365
|
+
function BBSFTranslateService() {
|
|
366
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
367
|
+
}
|
|
368
|
+
return BBSFTranslateService;
|
|
369
|
+
}(i1.TranslateService));
|
|
370
|
+
BBSFTranslateService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function BBSFTranslateService_Factory() { return new BBSFTranslateService(i0__namespace.ɵɵinject(i1__namespace.TranslateStore), i0__namespace.ɵɵinject(i1__namespace.TranslateLoader), i0__namespace.ɵɵinject(i1__namespace.TranslateCompiler), i0__namespace.ɵɵinject(i1__namespace.TranslateParser), i0__namespace.ɵɵinject(i1__namespace.MissingTranslationHandler), i0__namespace.ɵɵinject(i1__namespace.USE_DEFAULT_LANG), i0__namespace.ɵɵinject(i1__namespace.USE_STORE), i0__namespace.ɵɵinject(i1__namespace.USE_EXTEND), i0__namespace.ɵɵinject(i1__namespace.DEFAULT_LANGUAGE)); }, token: BBSFTranslateService, providedIn: "root" });
|
|
371
|
+
BBSFTranslateService.decorators = [
|
|
372
|
+
{ type: i0.Injectable, args: [{
|
|
373
|
+
providedIn: 'root'
|
|
374
|
+
},] }
|
|
375
|
+
];
|
|
376
|
+
|
|
362
377
|
// This file can be replaced during build by using the `fileReplacements` array.
|
|
363
378
|
// `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`.
|
|
364
379
|
// The list of file replacements can be found in `angular.json`.
|
|
@@ -419,19 +434,301 @@
|
|
|
419
434
|
},] }
|
|
420
435
|
];
|
|
421
436
|
|
|
422
|
-
var
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
437
|
+
var UtilityService = /** @class */ (function () {
|
|
438
|
+
function UtilityService(translator, environmentService) {
|
|
439
|
+
this.translator = translator;
|
|
440
|
+
this.environmentService = environmentService;
|
|
441
|
+
this.isCreatedBefore = false;
|
|
426
442
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
443
|
+
UtilityService.prototype.getResourceValue = function (Key) {
|
|
444
|
+
var ResourceValue = this.translator.instant(Key);
|
|
445
|
+
return ResourceValue;
|
|
446
|
+
};
|
|
447
|
+
UtilityService.prototype.getCurrentLanguage = function () {
|
|
448
|
+
var currentLanguage = this.environmentService.getDefaultLanguage();
|
|
449
|
+
var lang = localStorage.getItem('language');
|
|
450
|
+
if (lang)
|
|
451
|
+
currentLanguage = lang;
|
|
452
|
+
else
|
|
453
|
+
localStorage.setItem('language', currentLanguage);
|
|
454
|
+
return currentLanguage;
|
|
455
|
+
};
|
|
456
|
+
UtilityService.prototype.isCurrentLanguageEnglish = function () {
|
|
457
|
+
return this.getCurrentLanguage() == "en";
|
|
458
|
+
};
|
|
459
|
+
UtilityService.prototype.isCurrentLanguageArabic = function () {
|
|
460
|
+
return this.getCurrentLanguage() == "ar";
|
|
461
|
+
};
|
|
462
|
+
UtilityService.prototype.notifySuccessMessage = function (Message, title, time, showHeader) {
|
|
463
|
+
if (showHeader === void 0) { showHeader = true; }
|
|
464
|
+
var MessageTemplate = this.getResourceValue("SuccessMessage");
|
|
465
|
+
var titleTemplate;
|
|
466
|
+
if (Message) {
|
|
467
|
+
MessageTemplate = Message;
|
|
468
|
+
}
|
|
469
|
+
if (title) {
|
|
470
|
+
titleTemplate = title;
|
|
471
|
+
}
|
|
472
|
+
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
473
|
+
showHeader ? toaster.success(MessageTemplate, titleTemplate) : toaster.success(MessageTemplate);
|
|
474
|
+
};
|
|
475
|
+
UtilityService.prototype.notifyErrorMessage = function (Message, title, time, showHeader) {
|
|
476
|
+
if (showHeader === void 0) { showHeader = true; }
|
|
477
|
+
var MessageTemplate = this.getResourceValue("ErrorMessage");
|
|
478
|
+
var titleTemplate = this.getResourceValue("Error");
|
|
479
|
+
if (Message) {
|
|
480
|
+
MessageTemplate = Message;
|
|
481
|
+
}
|
|
482
|
+
if (title) {
|
|
483
|
+
titleTemplate = title;
|
|
484
|
+
}
|
|
485
|
+
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
486
|
+
showHeader ? toaster.error(MessageTemplate, titleTemplate) : toaster.error(MessageTemplate);
|
|
487
|
+
};
|
|
488
|
+
UtilityService.prototype.notifyWarningMessage = function (Message, title, time, showHeader) {
|
|
489
|
+
if (showHeader === void 0) { showHeader = true; }
|
|
490
|
+
var MessageTemplate = this.getResourceValue("WarningMessage");
|
|
491
|
+
var titleTemplate = this.getResourceValue("Warning");
|
|
492
|
+
if (Message) {
|
|
493
|
+
MessageTemplate = Message;
|
|
494
|
+
}
|
|
495
|
+
if (title) {
|
|
496
|
+
titleTemplate = title;
|
|
497
|
+
}
|
|
498
|
+
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
499
|
+
showHeader ? toaster.warning(MessageTemplate, titleTemplate) : toaster.warning(MessageTemplate);
|
|
500
|
+
};
|
|
501
|
+
UtilityService.prototype.startBlockUI = function () {
|
|
502
|
+
this.blockUI.start();
|
|
503
|
+
};
|
|
504
|
+
UtilityService.prototype.stopBlockUI = function () {
|
|
505
|
+
this.blockUI.stop();
|
|
506
|
+
};
|
|
507
|
+
return UtilityService;
|
|
508
|
+
}());
|
|
509
|
+
UtilityService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function UtilityService_Factory() { return new UtilityService(i0__namespace.ɵɵinject(BBSFTranslateService), i0__namespace.ɵɵinject(EnvironmentService)); }, token: UtilityService, providedIn: "root" });
|
|
510
|
+
UtilityService.decorators = [
|
|
431
511
|
{ type: i0.Injectable, args: [{
|
|
432
512
|
providedIn: 'root'
|
|
433
513
|
},] }
|
|
434
|
-
];
|
|
514
|
+
];
|
|
515
|
+
UtilityService.ctorParameters = function () { return [
|
|
516
|
+
{ type: BBSFTranslateService },
|
|
517
|
+
{ type: EnvironmentService }
|
|
518
|
+
]; };
|
|
519
|
+
__decorate([
|
|
520
|
+
ngBlockUi.BlockUI()
|
|
521
|
+
], UtilityService.prototype, "blockUI", void 0);
|
|
522
|
+
|
|
523
|
+
var User = /** @class */ (function () {
|
|
524
|
+
function User() {
|
|
525
|
+
}
|
|
526
|
+
return User;
|
|
527
|
+
}());
|
|
528
|
+
|
|
529
|
+
var TOKEN_KEY = 'access_token';
|
|
530
|
+
var AuthService = /** @class */ (function () {
|
|
531
|
+
function AuthService(injector, http, environmentService, translateService, router, cookieService, utilityService) {
|
|
532
|
+
this.injector = injector;
|
|
533
|
+
this.http = http;
|
|
534
|
+
this.environmentService = environmentService;
|
|
535
|
+
this.translateService = translateService;
|
|
536
|
+
this.router = router;
|
|
537
|
+
this.cookieService = cookieService;
|
|
538
|
+
this.utilityService = utilityService;
|
|
539
|
+
this.redirectUrl = '';
|
|
540
|
+
this.jwtHelper = new angularJwt.JwtHelperService();
|
|
541
|
+
this.isAuthenticatedSubject = new rxjs.BehaviorSubject(this.hasToken());
|
|
542
|
+
this.isAuthenticate$ = this.isAuthenticatedSubject.asObservable();
|
|
543
|
+
this.user = this.getUserManager();
|
|
544
|
+
}
|
|
545
|
+
AuthService.prototype.hasToken = function () {
|
|
546
|
+
var token = this.cookieService.get(TOKEN_KEY);
|
|
547
|
+
return token && !this.jwtHelper.isTokenExpired(token);
|
|
548
|
+
};
|
|
549
|
+
AuthService.prototype.getUserManager = function () {
|
|
550
|
+
var token = this.cookieService.get(TOKEN_KEY);
|
|
551
|
+
if (token)
|
|
552
|
+
this.handleAccessTokenWithoutLanguage(token);
|
|
553
|
+
return AuthService.user;
|
|
554
|
+
};
|
|
555
|
+
AuthService.prototype.getUser = function () {
|
|
556
|
+
this.user = AuthService.user;
|
|
557
|
+
};
|
|
558
|
+
AuthService.prototype.storUser = function (User) {
|
|
559
|
+
AuthService.user = this.user = this.user;
|
|
560
|
+
};
|
|
561
|
+
AuthService.prototype.getCurrentUser = function () {
|
|
562
|
+
return AuthService.user;
|
|
563
|
+
};
|
|
564
|
+
AuthService.prototype.isAuthenticated = function () {
|
|
565
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
566
|
+
return __generator(this, function (_b) {
|
|
567
|
+
return [2 /*return*/, AuthService.user != null && !this.jwtHelper.isTokenExpired(AuthService.user.access_token)];
|
|
568
|
+
});
|
|
569
|
+
});
|
|
570
|
+
};
|
|
571
|
+
AuthService.prototype.isUserInRole = function (allowedPermission) {
|
|
572
|
+
var selectedPermissionSetID = Number.parseInt(this.user.profile['selectedpermissionsetid']);
|
|
573
|
+
return allowedPermission.includes(selectedPermissionSetID);
|
|
574
|
+
};
|
|
575
|
+
AuthService.prototype.authorizationHeaderValue = function () {
|
|
576
|
+
return AuthService.user
|
|
577
|
+
? AuthService.user.token_type + " " + AuthService.user.access_token
|
|
578
|
+
: '';
|
|
579
|
+
};
|
|
580
|
+
AuthService.prototype.name = function () {
|
|
581
|
+
return AuthService.user != null ? AuthService.user.profile.given_name : '';
|
|
582
|
+
};
|
|
583
|
+
AuthService.prototype.setUrl = function (url) {
|
|
584
|
+
localStorage.setItem('redirectUrl', url);
|
|
585
|
+
};
|
|
586
|
+
AuthService.prototype.getUrl = function () {
|
|
587
|
+
var _a;
|
|
588
|
+
return (_a = localStorage.getItem('redirectUrl')) !== null && _a !== void 0 ? _a : "/";
|
|
589
|
+
};
|
|
590
|
+
AuthService.prototype.signout = function () {
|
|
591
|
+
var _this = this;
|
|
592
|
+
AuthService.timers.map(function (t) { return clearInterval(t); });
|
|
593
|
+
AuthService.timers = [];
|
|
594
|
+
if (!this.isAuthenticated()) {
|
|
595
|
+
this.cookieService.delete(TOKEN_KEY);
|
|
596
|
+
this.router.navigate(['/Admin/account/login']);
|
|
597
|
+
}
|
|
598
|
+
this.logout().subscribe(function (res) {
|
|
599
|
+
_this.cookieService.delete(TOKEN_KEY);
|
|
600
|
+
_this.router.navigate(['/Admin/account/login']);
|
|
601
|
+
});
|
|
602
|
+
};
|
|
603
|
+
AuthService.prototype.logout = function () {
|
|
604
|
+
var httpOptions = {
|
|
605
|
+
headers: new i1$1.HttpHeaders({
|
|
606
|
+
'Content-Type': 'application/json',
|
|
607
|
+
}),
|
|
608
|
+
};
|
|
609
|
+
var ApiUrl = '/Account/';
|
|
610
|
+
return this.http.get(this.environmentService.getApiUrl() + ApiUrl + 'Logout', httpOptions);
|
|
611
|
+
};
|
|
612
|
+
AuthService.prototype.clearUserSessionClaims = function () {
|
|
613
|
+
var httpOptions = {
|
|
614
|
+
headers: new i1$1.HttpHeaders({
|
|
615
|
+
'Content-Type': 'application/json',
|
|
616
|
+
}),
|
|
617
|
+
};
|
|
618
|
+
var ApiUrl = '/api/Home/';
|
|
619
|
+
return this.http.get(this.environmentService.getBaseUrl() + ApiUrl + 'ClearCurrentUserSession', httpOptions);
|
|
620
|
+
};
|
|
621
|
+
AuthService.prototype.handleAccessToken = function (response) {
|
|
622
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
623
|
+
var token;
|
|
624
|
+
return __generator(this, function (_b) {
|
|
625
|
+
switch (_b.label) {
|
|
626
|
+
case 0:
|
|
627
|
+
token = response;
|
|
628
|
+
AuthService.user = new User();
|
|
629
|
+
AuthService.user.token_type = "Bearer";
|
|
630
|
+
AuthService.user.access_token = token;
|
|
631
|
+
AuthService.user.profile = this.jwtHelper.decodeToken(token);
|
|
632
|
+
AuthService.user.expires_at = this.jwtHelper.getTokenExpirationDate(token);
|
|
633
|
+
AuthService.timers.map(function (t) { return clearInterval(t); });
|
|
634
|
+
AuthService.timers = [];
|
|
635
|
+
this.setTokenSeconds();
|
|
636
|
+
AuthService.timers.push(this.checkRefreshToken());
|
|
637
|
+
this.user = AuthService.user;
|
|
638
|
+
return [4 /*yield*/, this.updateLanguage()];
|
|
639
|
+
case 1:
|
|
640
|
+
_b.sent();
|
|
641
|
+
this.cookieService.set(TOKEN_KEY, token, null, null, null, true, 'Strict');
|
|
642
|
+
this.isAuthenticatedSubject.next(true);
|
|
643
|
+
return [2 /*return*/];
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
});
|
|
647
|
+
};
|
|
648
|
+
AuthService.prototype.handleAccessTokenWithoutLanguage = function (response) {
|
|
649
|
+
var token = response;
|
|
650
|
+
AuthService.user = new User();
|
|
651
|
+
AuthService.user.token_type = "Bearer";
|
|
652
|
+
AuthService.user.access_token = token;
|
|
653
|
+
AuthService.user.profile = this.jwtHelper.decodeToken(token);
|
|
654
|
+
AuthService.user.expires_at = this.jwtHelper.getTokenExpirationDate(token);
|
|
655
|
+
this.setTokenSeconds();
|
|
656
|
+
this.user = AuthService.user;
|
|
657
|
+
this.cookieService.set(TOKEN_KEY, token, null, null, null, true, 'Strict');
|
|
658
|
+
this.isAuthenticatedSubject.next(true);
|
|
659
|
+
};
|
|
660
|
+
AuthService.prototype.updateLanguage = function () {
|
|
661
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
662
|
+
return __generator(this, function (_b) {
|
|
663
|
+
switch (_b.label) {
|
|
664
|
+
case 0:
|
|
665
|
+
if (!localStorage.getItem('language') ||
|
|
666
|
+
localStorage.getItem('language') == this.user.profile.locale)
|
|
667
|
+
localStorage.setItem('language', this.user.profile.locale);
|
|
668
|
+
if (!(this.translateService.currentLang != localStorage.getItem('language'))) return [3 /*break*/, 2];
|
|
669
|
+
this.translateService.resetLang(this.translateService.currentLang);
|
|
670
|
+
return [4 /*yield*/, this.translateService
|
|
671
|
+
.reloadLang(localStorage.getItem('language'))
|
|
672
|
+
.subscribe(function (res) {
|
|
673
|
+
console.log(res);
|
|
674
|
+
})];
|
|
675
|
+
case 1:
|
|
676
|
+
_b.sent();
|
|
677
|
+
_b.label = 2;
|
|
678
|
+
case 2: return [2 /*return*/];
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
});
|
|
682
|
+
};
|
|
683
|
+
AuthService.prototype.checkRefreshToken = function () {
|
|
684
|
+
var _this = this;
|
|
685
|
+
var date = new Date();
|
|
686
|
+
return setInterval(function () {
|
|
687
|
+
if (Math.floor(AuthService.seconds) < 120 && _this.isAuthenticated())
|
|
688
|
+
_this.refresh();
|
|
689
|
+
AuthService.seconds--;
|
|
690
|
+
}, 1000);
|
|
691
|
+
};
|
|
692
|
+
AuthService.prototype.setTokenSeconds = function () {
|
|
693
|
+
var date = new Date();
|
|
694
|
+
AuthService.seconds = (AuthService.user.expires_at - date) / 1000;
|
|
695
|
+
};
|
|
696
|
+
AuthService.prototype.refresh = function () {
|
|
697
|
+
var _this = this;
|
|
698
|
+
var httpOptions = {
|
|
699
|
+
headers: new i1$1.HttpHeaders({
|
|
700
|
+
'Content-Type': 'application/json',
|
|
701
|
+
'Authorization': this.authorizationHeaderValue(),
|
|
702
|
+
}),
|
|
703
|
+
};
|
|
704
|
+
var ApiUrl = '/api/Home/';
|
|
705
|
+
this.http.get(this.environmentService.getApiUrl() + ApiUrl + 'RefreshAccessToken', httpOptions).subscribe(function (res) {
|
|
706
|
+
_this.cookieService.delete(TOKEN_KEY);
|
|
707
|
+
_this.handleAccessTokenWithoutLanguage(res.val);
|
|
708
|
+
});
|
|
709
|
+
};
|
|
710
|
+
return AuthService;
|
|
711
|
+
}());
|
|
712
|
+
AuthService.user = null;
|
|
713
|
+
AuthService.UserClaims = null;
|
|
714
|
+
//refresh
|
|
715
|
+
AuthService.timers = [];
|
|
716
|
+
AuthService.seconds = 0;
|
|
717
|
+
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), i0__namespace.ɵɵinject(UtilityService)); }, token: AuthService, providedIn: "root" });
|
|
718
|
+
AuthService.decorators = [
|
|
719
|
+
{ type: i0.Injectable, args: [{
|
|
720
|
+
providedIn: 'root',
|
|
721
|
+
},] }
|
|
722
|
+
];
|
|
723
|
+
AuthService.ctorParameters = function () { return [
|
|
724
|
+
{ type: i0.Injector },
|
|
725
|
+
{ type: i1$1.HttpClient },
|
|
726
|
+
{ type: EnvironmentService },
|
|
727
|
+
{ type: BBSFTranslateService },
|
|
728
|
+
{ type: i4.Router },
|
|
729
|
+
{ type: i5.CookieService },
|
|
730
|
+
{ type: UtilityService }
|
|
731
|
+
]; };
|
|
435
732
|
|
|
436
733
|
var RequestOptionsModel = /** @class */ (function () {
|
|
437
734
|
function RequestOptionsModel() {
|
|
@@ -645,7 +942,7 @@
|
|
|
645
942
|
{ type: EnvironmentService },
|
|
646
943
|
{ type: UtilityService },
|
|
647
944
|
{ type: BBSFTranslateService },
|
|
648
|
-
{ type:
|
|
945
|
+
{ type: i4.Router }
|
|
649
946
|
]; };
|
|
650
947
|
|
|
651
948
|
var StylesBundleService = /** @class */ (function () {
|
|
@@ -688,494 +985,22 @@
|
|
|
688
985
|
};
|
|
689
986
|
return StylesBundleService;
|
|
690
987
|
}());
|
|
691
|
-
StylesBundleService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function StylesBundleService_Factory() { return new StylesBundleService(i0__namespace.ɵɵinject(i1__namespace$
|
|
988
|
+
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
989
|
StylesBundleService.decorators = [
|
|
693
990
|
{ type: i0.Injectable, args: [{
|
|
694
991
|
providedIn: 'root'
|
|
695
992
|
},] }
|
|
696
993
|
];
|
|
697
994
|
StylesBundleService.ctorParameters = function () { return [
|
|
698
|
-
{ type: Document, decorators: [{ type: i0.Inject, args: [i1$
|
|
995
|
+
{ type: Document, decorators: [{ type: i0.Inject, args: [i1$2.DOCUMENT,] }] },
|
|
699
996
|
{ type: BBSFTranslateService }
|
|
700
997
|
]; };
|
|
701
998
|
|
|
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;
|
|
999
|
+
var ControlValidationService = /** @class */ (function () {
|
|
1000
|
+
function ControlValidationService(utilityService) {
|
|
1001
|
+
this.utilityService = utilityService;
|
|
1002
|
+
this.requestOptions = new RequestOptionsModel();
|
|
1003
|
+
this.isCreatedBefor = false;
|
|
1179
1004
|
}
|
|
1180
1005
|
ControlValidationService.prototype.showGlobalError = function (errorMessage, formId, deleteOld) {
|
|
1181
1006
|
var e_1, _a;
|
|
@@ -1363,6 +1188,83 @@
|
|
|
1363
1188
|
ngBlockUi.BlockUI()
|
|
1364
1189
|
], ControlValidationService.prototype, "blockUI", void 0);
|
|
1365
1190
|
|
|
1191
|
+
var MasterLayoutService = /** @class */ (function () {
|
|
1192
|
+
function MasterLayoutService(router, http, authService, stylesBundleService, translate, environmentService) {
|
|
1193
|
+
this.router = router;
|
|
1194
|
+
this.http = http;
|
|
1195
|
+
this.authService = authService;
|
|
1196
|
+
this.stylesBundleService = stylesBundleService;
|
|
1197
|
+
this.translate = translate;
|
|
1198
|
+
this.environmentService = environmentService;
|
|
1199
|
+
this.ApiUrl = '/api/Home/';
|
|
1200
|
+
}
|
|
1201
|
+
MasterLayoutService.prototype.switchLang = function (lang, bundleEnglishName, bundleArabicName) {
|
|
1202
|
+
var _this = this;
|
|
1203
|
+
this.changeLanguage(lang).subscribe(function (result) {
|
|
1204
|
+
_this.updateUserInfo().subscribe(function (Value) {
|
|
1205
|
+
var UserInfoObject = Value;
|
|
1206
|
+
_this.authService.handleAccessToken(UserInfoObject.token);
|
|
1207
|
+
_this.stylesBundleService.loadThemes(lang, bundleEnglishName, bundleArabicName);
|
|
1208
|
+
localStorage.setItem('language', lang);
|
|
1209
|
+
_this.translate.use(lang);
|
|
1210
|
+
});
|
|
1211
|
+
});
|
|
1212
|
+
};
|
|
1213
|
+
MasterLayoutService.prototype.reloadComponent = function () {
|
|
1214
|
+
var currentUrl = this.router.url;
|
|
1215
|
+
this.router.routeReuseStrategy.shouldReuseRoute = function () { return false; };
|
|
1216
|
+
this.router.onSameUrlNavigation = 'reload';
|
|
1217
|
+
this.router.navigate([currentUrl]);
|
|
1218
|
+
};
|
|
1219
|
+
MasterLayoutService.prototype.changeLanguage = function (key) {
|
|
1220
|
+
var params = new i1$1.HttpParams();
|
|
1221
|
+
params = params.append('UserId', this.authService.user.profile.id);
|
|
1222
|
+
params = params.append('LanguageKey', key);
|
|
1223
|
+
return this.http.post(this.ApiUrl + 'UpdateLanguage', null, null, params);
|
|
1224
|
+
};
|
|
1225
|
+
MasterLayoutService.prototype.getUserClaims = function () {
|
|
1226
|
+
return this.http.get(this.ApiUrl + 'GetUserClaims', null, null);
|
|
1227
|
+
};
|
|
1228
|
+
MasterLayoutService.prototype.logError = function (error) {
|
|
1229
|
+
var params = new i1$1.HttpParams();
|
|
1230
|
+
params = params.append('error', error);
|
|
1231
|
+
return this.http.post(this.ApiUrl + 'LogError', null, null, params);
|
|
1232
|
+
};
|
|
1233
|
+
MasterLayoutService.prototype.updateUserInfo = function () {
|
|
1234
|
+
return this.http.get(this.ApiUrl + 'UpdateUserInfo', null, null);
|
|
1235
|
+
};
|
|
1236
|
+
MasterLayoutService.prototype.switchRole = function (permissionSetID) {
|
|
1237
|
+
var _this = this;
|
|
1238
|
+
this.updateRole(permissionSetID).subscribe(function (result) {
|
|
1239
|
+
_this.updateUserInfo().subscribe(function (Value) {
|
|
1240
|
+
var UserInfoObject = Value;
|
|
1241
|
+
_this.authService.handleAccessToken(UserInfoObject.token);
|
|
1242
|
+
});
|
|
1243
|
+
});
|
|
1244
|
+
};
|
|
1245
|
+
MasterLayoutService.prototype.updateRole = function (permissionSetID) {
|
|
1246
|
+
var params = new i1$1.HttpParams();
|
|
1247
|
+
params = params.append('UserId', this.authService.user.profile.id);
|
|
1248
|
+
params = params.append('RoleID', permissionSetID);
|
|
1249
|
+
return this.http.post(this.ApiUrl + 'SwitchRole', null, null, params);
|
|
1250
|
+
};
|
|
1251
|
+
return MasterLayoutService;
|
|
1252
|
+
}());
|
|
1253
|
+
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" });
|
|
1254
|
+
MasterLayoutService.decorators = [
|
|
1255
|
+
{ type: i0.Injectable, args: [{
|
|
1256
|
+
providedIn: 'root',
|
|
1257
|
+
},] }
|
|
1258
|
+
];
|
|
1259
|
+
MasterLayoutService.ctorParameters = function () { return [
|
|
1260
|
+
{ type: i4.Router },
|
|
1261
|
+
{ type: RequestHandlerService },
|
|
1262
|
+
{ type: AuthService },
|
|
1263
|
+
{ type: StylesBundleService },
|
|
1264
|
+
{ type: i1.TranslateService },
|
|
1265
|
+
{ type: EnvironmentService }
|
|
1266
|
+
]; };
|
|
1267
|
+
|
|
1366
1268
|
var ConfigurationService = /** @class */ (function () {
|
|
1367
1269
|
function ConfigurationService(httpClient) {
|
|
1368
1270
|
this.httpClient = httpClient;
|
|
@@ -1376,7 +1278,7 @@
|
|
|
1376
1278
|
return ConfigurationService;
|
|
1377
1279
|
}());
|
|
1378
1280
|
ConfigurationService.JsonData = [];
|
|
1379
|
-
ConfigurationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ConfigurationService_Factory() { return new ConfigurationService(i0__namespace.ɵɵinject(i1__namespace$
|
|
1281
|
+
ConfigurationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ConfigurationService_Factory() { return new ConfigurationService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient)); }, token: ConfigurationService, providedIn: "root" });
|
|
1380
1282
|
ConfigurationService.decorators = [
|
|
1381
1283
|
{ type: i0.Injectable, args: [{
|
|
1382
1284
|
providedIn: 'root'
|
|
@@ -1398,10 +1300,10 @@
|
|
|
1398
1300
|
{ type: i0.NgModule, args: [{
|
|
1399
1301
|
declarations: [],
|
|
1400
1302
|
imports: [
|
|
1401
|
-
i1$
|
|
1303
|
+
i1$2.CommonModule,
|
|
1402
1304
|
ngBlockUi.BlockUIModule.forRoot(),
|
|
1403
1305
|
http.HttpModule,
|
|
1404
|
-
|
|
1306
|
+
i4.RouterModule,
|
|
1405
1307
|
ngxToastr.ToastrModule.forRoot(),
|
|
1406
1308
|
],
|
|
1407
1309
|
exports: [],
|
|
@@ -1415,7 +1317,8 @@
|
|
|
1415
1317
|
BBSFTranslateService,
|
|
1416
1318
|
ControlValidationService,
|
|
1417
1319
|
MasterLayoutService,
|
|
1418
|
-
ConfigurationService
|
|
1320
|
+
ConfigurationService,
|
|
1321
|
+
i5.CookieService
|
|
1419
1322
|
]
|
|
1420
1323
|
},] }
|
|
1421
1324
|
];
|