@bnsights/bbsf-utilities 1.0.26 → 1.0.28
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 +10 -0
- package/bnsights-bbsf-utilities-1.0.28.tgz +0 -0
- package/bnsights-bbsf-utilities.metadata.json +1 -1
- package/bundles/bnsights-bbsf-utilities.umd.js +648 -572
- package/bundles/bnsights-bbsf-utilities.umd.js.map +1 -1
- package/esm2015/lib/shared/authentication/auth.service.js +88 -38
- package/esm2015/lib/shared/services/configuration.service.js +4 -5
- package/esm2015/lib/shared/services/environment.service.js +13 -1
- package/esm2015/lib/shared/services/masterlayout.service.js +27 -18
- package/esm2015/lib/shared/services/requesthandler.service.js +8 -4
- package/fesm2015/bnsights-bbsf-utilities.js +431 -360
- package/fesm2015/bnsights-bbsf-utilities.js.map +1 -1
- package/lib/shared/authentication/auth.service.d.ts +7 -3
- package/lib/shared/services/configuration.service.d.ts +1 -1
- package/lib/shared/services/environment.service.d.ts +3 -0
- package/lib/shared/services/masterlayout.service.d.ts +9 -6
- package/package.json +1 -1
- package/bnsights-bbsf-utilities-1.0.26.tgz +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), 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('oidc-client'), require('rxjs'), require('rxjs/operators'), require('class-transformer')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define('@bnsights/bbsf-utilities', ['exports', '@angular/common', '@angular/core', '@angular/router', '@ngx-translate/core', 'ng-block-ui', 'ngx-toastr', '@angular/http', '@angular/common/http', 'oidc-client', 'rxjs', 'rxjs/operators', 'class-transformer'], factory) :
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.bnsights = global.bnsights || {}, global.bnsights["bbsf-utilities"] = {}), global.ng.common, global.ng.core, global.ng.router, global.i1, global.ngBlockUi, global.ngxToastr, global.ng.http, global.ng.common.http, global.oidcClient, global.rxjs, global.rxjs.operators, global.classTransformer));
|
|
5
|
-
})(this, (function (exports, i1$
|
|
5
|
+
})(this, (function (exports, i1$3, i0, i1$2, i1, ngBlockUi, ngxToastr, http, i1$1, oidcClient, rxjs, operators, classTransformer) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopNamespace(e) {
|
|
8
8
|
if (e && e.__esModule) return e;
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
return Object.freeze(n);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
var i1__namespace$
|
|
25
|
+
var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1$3);
|
|
26
26
|
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
27
|
-
var
|
|
27
|
+
var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$2);
|
|
28
28
|
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
|
29
|
-
var i1__namespace$
|
|
29
|
+
var i1__namespace$3 = /*#__PURE__*/_interopNamespace(i1$1);
|
|
30
30
|
|
|
31
31
|
/*! *****************************************************************************
|
|
32
32
|
Copyright (c) Microsoft Corporation.
|
|
@@ -384,6 +384,18 @@
|
|
|
384
384
|
var Url = environment["BBSF_IdentityServerUrl"];
|
|
385
385
|
return Url;
|
|
386
386
|
};
|
|
387
|
+
EnvironmentService.prototype.getIsIdentityServerExternal = function () {
|
|
388
|
+
var Mode = environment["BBSF_IsExternalIdentityServer"];
|
|
389
|
+
return Mode;
|
|
390
|
+
};
|
|
391
|
+
EnvironmentService.prototype.getIsIdentityServerClientId = function () {
|
|
392
|
+
var Mode = environment["BBSF_IdentityServer_Client_Id"];
|
|
393
|
+
return Mode;
|
|
394
|
+
};
|
|
395
|
+
EnvironmentService.prototype.getIsIdentityServerClientSecret = function () {
|
|
396
|
+
var Mode = environment["BBSF_IdentityServer_Client_Secret"];
|
|
397
|
+
return Mode;
|
|
398
|
+
};
|
|
387
399
|
return EnvironmentService;
|
|
388
400
|
}());
|
|
389
401
|
EnvironmentService.AreaList = [];
|
|
@@ -408,577 +420,719 @@
|
|
|
408
420
|
},] }
|
|
409
421
|
];
|
|
410
422
|
|
|
411
|
-
var
|
|
412
|
-
function
|
|
423
|
+
var RequestOptionsModel = /** @class */ (function () {
|
|
424
|
+
function RequestOptionsModel() {
|
|
425
|
+
this.disableSuccessNotification = false;
|
|
426
|
+
this.disableBlockUI = false;
|
|
427
|
+
this.disableErrorHandler = false;
|
|
428
|
+
this.responseType = "";
|
|
429
|
+
this.formGroup = null;
|
|
430
|
+
this.castResponsetoClass = true;
|
|
431
|
+
}
|
|
432
|
+
return RequestOptionsModel;
|
|
433
|
+
}());
|
|
434
|
+
|
|
435
|
+
var RequestHandlerService = /** @class */ (function () {
|
|
436
|
+
function RequestHandlerService(http, authService, environmentService, utilityService, bbsfTranslateService, router) {
|
|
413
437
|
var _this = this;
|
|
438
|
+
//using localStorage to avoid call getCurrentLanguage() because it is not all to use async in constructor
|
|
414
439
|
this.http = http;
|
|
440
|
+
this.authService = authService;
|
|
415
441
|
this.environmentService = environmentService;
|
|
416
|
-
this.
|
|
442
|
+
this.utilityService = utilityService;
|
|
443
|
+
this.bbsfTranslateService = bbsfTranslateService;
|
|
417
444
|
this.router = router;
|
|
418
|
-
|
|
419
|
-
this.
|
|
420
|
-
|
|
421
|
-
this.
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
this.manager = new oidcClient.UserManager({
|
|
426
|
-
authority: this.environmentService.getIdentityServerUrl(),
|
|
427
|
-
client_id: 'angular_spa',
|
|
428
|
-
redirect_uri: this.environmentService.getIdentityServerUrl() + '/Admin/authentication/auth-callback',
|
|
429
|
-
post_logout_redirect_uri: this.environmentService.getBaseUrl(),
|
|
430
|
-
response_type: "id_token token",
|
|
431
|
-
scope: "openid profile email IdentityServerApi",
|
|
432
|
-
filterProtocolClaims: true,
|
|
433
|
-
loadUserInfo: true,
|
|
434
|
-
automaticSilentRenew: true,
|
|
435
|
-
silent_redirect_uri: this.environmentService.getIdentityServerUrl() + '/assets/silent-callback.html',
|
|
436
|
-
userStore: new oidcClient.WebStorageStateStore({ store: window.localStorage })
|
|
437
|
-
});
|
|
438
|
-
this.redirectUrl = "";
|
|
439
|
-
this.manager.getUser().then(function (user) { return __awaiter(_this, void 0, void 0, function () {
|
|
440
|
-
var _a, _b;
|
|
441
|
-
return __generator(this, function (_c) {
|
|
442
|
-
switch (_c.label) {
|
|
443
|
-
case 0:
|
|
444
|
-
this.manager.storeUser(user);
|
|
445
|
-
AuthService.user = user;
|
|
446
|
-
this.user = user;
|
|
447
|
-
_b = (_a = this._authNavStatusSource).next;
|
|
448
|
-
return [4 /*yield*/, this.isAuthenticated()];
|
|
449
|
-
case 1:
|
|
450
|
-
_b.apply(_a, [_c.sent()]);
|
|
451
|
-
return [2 /*return*/];
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
}); });
|
|
455
|
-
this.manager.events.addAccessTokenExpired(function (_) {
|
|
456
|
-
_this._authNavStatusSource.next(false);
|
|
445
|
+
this.requestOptions = new RequestOptionsModel();
|
|
446
|
+
this.currentLanguage = "";
|
|
447
|
+
this.onDestroy$ = new rxjs.Subject();
|
|
448
|
+
this.bbsfTranslateService.onLangChange.subscribe(function (event) {
|
|
449
|
+
if (_this.currentLanguage != event.lang) {
|
|
450
|
+
_this.currentLanguage = event.lang;
|
|
451
|
+
}
|
|
457
452
|
});
|
|
458
453
|
}
|
|
459
|
-
|
|
460
|
-
return
|
|
454
|
+
RequestHandlerService.prototype.getLuckyNumber = function () {
|
|
455
|
+
return rxjs.Observable.create(function (subject) {
|
|
456
|
+
setInterval(function () {
|
|
457
|
+
var number = Math.floor(Math.random() * 10);
|
|
458
|
+
console.log(number);
|
|
459
|
+
subject.next(number);
|
|
460
|
+
}, 1000);
|
|
461
|
+
}).pipe(operators.takeUntil(this.onDestroy$));
|
|
461
462
|
};
|
|
462
|
-
|
|
463
|
+
RequestHandlerService.prototype.get = function (Url, params, responseType, requestOptions) {
|
|
463
464
|
var _this = this;
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
465
|
+
if (requestOptions)
|
|
466
|
+
this.requestOptions = requestOptions;
|
|
467
|
+
var headers = this.getHeaders();
|
|
468
|
+
if (!this.requestOptions.disableBlockUI)
|
|
469
|
+
this.utilityService.startBlockUI();
|
|
470
|
+
var object;
|
|
471
|
+
return this.http.get(this.environmentService.getApiUrl() + Url, { headers: headers, params: params }).pipe(operators.takeUntil(this.onDestroy$), operators.tap(function (result) {
|
|
472
|
+
if (!_this.requestOptions.disableBlockUI)
|
|
473
|
+
_this.utilityService.stopBlockUI();
|
|
474
|
+
}, function (error) {
|
|
475
|
+
if (!_this.requestOptions.disableErrorHandler)
|
|
476
|
+
_this.handleError(error);
|
|
477
|
+
}), operators.map(function (data) {
|
|
478
|
+
if (_this.requestOptions.castResponsetoClass)
|
|
479
|
+
return classTransformer.plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
480
|
+
else
|
|
481
|
+
return data;
|
|
482
|
+
}));
|
|
480
483
|
};
|
|
481
|
-
|
|
482
|
-
this
|
|
484
|
+
RequestHandlerService.prototype.post = function (Url, model, responseType, params, requestOptions) {
|
|
485
|
+
var _this = this;
|
|
486
|
+
if (requestOptions)
|
|
487
|
+
this.requestOptions = requestOptions;
|
|
488
|
+
var headers = this.getHeaders();
|
|
489
|
+
if (!this.requestOptions.disableBlockUI)
|
|
490
|
+
this.utilityService.startBlockUI();
|
|
491
|
+
return this.http.post(this.environmentService.getApiUrl() + Url, model, { headers: headers, params: params, responseType: this.requestOptions.responseType }).pipe(operators.takeUntil(this.onDestroy$), operators.tap(function (result) {
|
|
492
|
+
if (!_this.requestOptions.disableBlockUI)
|
|
493
|
+
_this.utilityService.stopBlockUI();
|
|
494
|
+
}, function (error) {
|
|
495
|
+
if (!_this.requestOptions.disableErrorHandler)
|
|
496
|
+
_this.handleError(error);
|
|
497
|
+
}), operators.map(function (data) {
|
|
498
|
+
if (_this.requestOptions.castResponsetoClass)
|
|
499
|
+
return classTransformer.plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
500
|
+
else
|
|
501
|
+
return data;
|
|
502
|
+
}));
|
|
483
503
|
};
|
|
484
|
-
|
|
485
|
-
this
|
|
504
|
+
RequestHandlerService.prototype.delete = function (Url, deletedId, requestOptions, responseType, params) {
|
|
505
|
+
var _this = this;
|
|
506
|
+
if (requestOptions)
|
|
507
|
+
this.requestOptions = requestOptions;
|
|
508
|
+
var headers = this.getHeaders();
|
|
509
|
+
if (!this.requestOptions.disableBlockUI)
|
|
510
|
+
this.utilityService.startBlockUI();
|
|
511
|
+
return this.http.delete(this.environmentService.getApiUrl() + Url + ("/" + deletedId), { headers: headers, params: params }).pipe(operators.takeUntil(this.onDestroy$), operators.tap(function (result) {
|
|
512
|
+
if (!_this.requestOptions.disableBlockUI)
|
|
513
|
+
_this.utilityService.stopBlockUI();
|
|
514
|
+
}, function (error) {
|
|
515
|
+
if (!_this.requestOptions.disableErrorHandler)
|
|
516
|
+
_this.handleError(error);
|
|
517
|
+
}), operators.map(function (data) {
|
|
518
|
+
if (_this.requestOptions.castResponsetoClass)
|
|
519
|
+
return classTransformer.plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
520
|
+
else
|
|
521
|
+
return data;
|
|
522
|
+
}));
|
|
486
523
|
};
|
|
487
|
-
|
|
488
|
-
var
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
524
|
+
RequestHandlerService.prototype.put = function (Url, model, params, responseType, requestOptions) {
|
|
525
|
+
var _this = this;
|
|
526
|
+
if (requestOptions)
|
|
527
|
+
this.requestOptions = requestOptions;
|
|
528
|
+
var headers = this.getHeaders();
|
|
529
|
+
if (!this.requestOptions.disableBlockUI)
|
|
530
|
+
this.utilityService.startBlockUI();
|
|
531
|
+
return this.http.put(this.environmentService.getApiUrl() + Url, model, { headers: headers, params: params, responseType: this.requestOptions.responseType }).pipe(operators.takeUntil(this.onDestroy$), operators.tap(function (result) {
|
|
532
|
+
if (!_this.requestOptions.disableBlockUI)
|
|
533
|
+
_this.utilityService.stopBlockUI();
|
|
534
|
+
}, function (error) {
|
|
535
|
+
if (!_this.requestOptions.disableErrorHandler)
|
|
536
|
+
_this.handleError(error);
|
|
537
|
+
}), operators.map(function (data) {
|
|
538
|
+
if (_this.requestOptions.castResponsetoClass)
|
|
539
|
+
return classTransformer.plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
540
|
+
else
|
|
541
|
+
return data;
|
|
542
|
+
}));
|
|
492
543
|
};
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
return [4 /*yield*/, this.manager.signinRedirectCallback()];
|
|
501
|
-
case 1:
|
|
502
|
-
_a.user = _d.sent();
|
|
503
|
-
AuthService.user = this.user;
|
|
504
|
-
if (!localStorage.getItem("language") || localStorage.getItem("language") == this.user.profile.locale)
|
|
505
|
-
localStorage.setItem("language", this.user.profile.locale);
|
|
506
|
-
if (!(this.translateService.currentLang != localStorage.getItem("language"))) return [3 /*break*/, 3];
|
|
507
|
-
this.translateService.resetLang(this.translateService.currentLang);
|
|
508
|
-
return [4 /*yield*/, this.translateService.reloadLang(localStorage.getItem("language")).subscribe(function (res) {
|
|
509
|
-
console.log(res);
|
|
510
|
-
})];
|
|
511
|
-
case 2:
|
|
512
|
-
_d.sent();
|
|
513
|
-
_d.label = 3;
|
|
514
|
-
case 3:
|
|
515
|
-
this._userSource.next(AuthService.user);
|
|
516
|
-
_c = (_b = this._authNavStatusSource).next;
|
|
517
|
-
return [4 /*yield*/, this.isAuthenticated()];
|
|
518
|
-
case 4:
|
|
519
|
-
_c.apply(_b, [_d.sent()]);
|
|
520
|
-
return [2 /*return*/];
|
|
521
|
-
}
|
|
522
|
-
});
|
|
544
|
+
RequestHandlerService.prototype.patch = function (Url, model, responseType, params, requestOptions) {
|
|
545
|
+
var _this = this;
|
|
546
|
+
if (requestOptions)
|
|
547
|
+
this.requestOptions = requestOptions;
|
|
548
|
+
var headers = new i1$1.HttpHeaders({
|
|
549
|
+
'Content-Type': 'application/json',
|
|
550
|
+
'Authorization': this.authService.authorizationHeaderValue(),
|
|
523
551
|
});
|
|
552
|
+
this.currentLanguage = localStorage.getItem('language');
|
|
553
|
+
headers = headers.set('Accept-Language', this.currentLanguage.toString());
|
|
554
|
+
headers = headers.set('ignore-cookies', 'true');
|
|
555
|
+
if (!this.requestOptions.disableBlockUI)
|
|
556
|
+
this.utilityService.startBlockUI();
|
|
557
|
+
return this.http.patch(this.environmentService.getApiUrl() + Url, model, { headers: headers, params: params, responseType: this.requestOptions.responseType }).pipe(operators.takeUntil(this.onDestroy$), operators.tap(function (result) {
|
|
558
|
+
if (!_this.requestOptions.disableBlockUI)
|
|
559
|
+
_this.utilityService.stopBlockUI();
|
|
560
|
+
}, function (error) {
|
|
561
|
+
if (!_this.requestOptions.disableErrorHandler)
|
|
562
|
+
_this.handleError(error);
|
|
563
|
+
}), operators.map(function (data) {
|
|
564
|
+
if (_this.requestOptions.castResponsetoClass)
|
|
565
|
+
return classTransformer.plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
566
|
+
else
|
|
567
|
+
return data;
|
|
568
|
+
}));
|
|
524
569
|
};
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
return [4 /*yield*/, this.http.post(this.environmentService.getIdentityServerUrl() + "/users/refresh-token", httpOptions, { withCredentials: true }).subscribe(function (user) {
|
|
540
|
-
_this._userSource.next(user);
|
|
541
|
-
AuthService.user = user;
|
|
542
|
-
_this.user = user;
|
|
543
|
-
})];
|
|
544
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
});
|
|
570
|
+
RequestHandlerService.prototype.download = function (Url, params, requestOptions) {
|
|
571
|
+
var _this = this;
|
|
572
|
+
if (requestOptions)
|
|
573
|
+
this.requestOptions = requestOptions;
|
|
574
|
+
var headers = this.getHeaders();
|
|
575
|
+
if (!this.requestOptions.disableBlockUI)
|
|
576
|
+
this.utilityService.startBlockUI();
|
|
577
|
+
return this.http.get(this.environmentService.getApiUrl() + Url, { headers: headers, params: params, responseType: this.requestOptions.responseType }).pipe(operators.takeUntil(this.onDestroy$), operators.tap(function (result) {
|
|
578
|
+
if (!_this.requestOptions.disableBlockUI)
|
|
579
|
+
_this.utilityService.stopBlockUI();
|
|
580
|
+
}, function (error) {
|
|
581
|
+
if (!_this.requestOptions.disableErrorHandler)
|
|
582
|
+
_this.handleError(error);
|
|
583
|
+
}));
|
|
548
584
|
};
|
|
549
|
-
|
|
550
|
-
|
|
585
|
+
RequestHandlerService.prototype.destroyHandler = function () {
|
|
586
|
+
this.onDestroy$.next();
|
|
551
587
|
};
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
return __generator(this, function (_a) {
|
|
556
|
-
switch (_a.label) {
|
|
557
|
-
case 0: return [4 /*yield*/, this.manager.getUser().then(function (user) {
|
|
558
|
-
return user;
|
|
559
|
-
})];
|
|
560
|
-
case 1:
|
|
561
|
-
user = _a.sent();
|
|
562
|
-
return [2 /*return*/, this.user != null && !this.user.expired];
|
|
563
|
-
}
|
|
564
|
-
});
|
|
565
|
-
});
|
|
566
|
-
};
|
|
567
|
-
AuthService.prototype.isUserInRole = function (allowedPermission) {
|
|
568
|
-
var selectedPermissionSetID = Number.parseInt(this.user.profile["selectedpermissionsetid"]);
|
|
569
|
-
return allowedPermission.includes(selectedPermissionSetID);
|
|
570
|
-
};
|
|
571
|
-
AuthService.prototype.authorizationHeaderValue = function () {
|
|
572
|
-
return AuthService.user ? AuthService.user.token_type + " " + AuthService.user.access_token : "";
|
|
588
|
+
RequestHandlerService.prototype.ngOnDestroy = function () {
|
|
589
|
+
console.log("clearInterval");
|
|
590
|
+
this.destroyHandler();
|
|
573
591
|
};
|
|
574
|
-
|
|
575
|
-
|
|
592
|
+
RequestHandlerService.prototype.handleError = function (err) {
|
|
593
|
+
var isEnglish = this.utilityService.getCurrentLanguage() == "en";
|
|
594
|
+
if (err.error instanceof ErrorEvent) {
|
|
595
|
+
this.utilityService.notifyErrorMessage();
|
|
596
|
+
}
|
|
597
|
+
else {
|
|
598
|
+
if (err.status == 400)
|
|
599
|
+
rxjs.throwError(err); //error 400 is thrown to be catch by the Form component to handle Fluent validation errors
|
|
600
|
+
else if (err.status == 401)
|
|
601
|
+
this.router.navigate(["/Admin/account/login"]);
|
|
602
|
+
else if (err.status == 403)
|
|
603
|
+
this.utilityService.notifyErrorMessage(isEnglish ? "Sorry, You're not authorized to access this action" : "عذرا ليس لديك الصلاحيه لهذا الطلب");
|
|
604
|
+
else if (err.status == 510)
|
|
605
|
+
this.utilityService.notifyErrorMessage(isEnglish ? "Can not delete this item as it is related to others" : "لا يمكن حذف هذا العنصر لأنه مرتبط بعناصر أخرى");
|
|
606
|
+
else if (err.status == 515)
|
|
607
|
+
this.utilityService.notifyErrorMessage((err.error ? err.error.Message : err.message));
|
|
608
|
+
else {
|
|
609
|
+
console.log("error message is: " + (err.error ? err.error.Message : err.message));
|
|
610
|
+
this.utilityService.notifyErrorMessage(this.utilityService.getResourceValue("ErrorMassage"));
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
this.utilityService.stopBlockUI();
|
|
576
614
|
};
|
|
577
|
-
|
|
578
|
-
|
|
615
|
+
RequestHandlerService.prototype.getHeaders = function () {
|
|
616
|
+
return new i1$1.HttpHeaders({
|
|
617
|
+
'Content-Type': 'application/json',
|
|
618
|
+
'Authorization': this.authService.authorizationHeaderValue(),
|
|
619
|
+
'Client-Local-Time-Zone': Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
620
|
+
'Accept-Language': localStorage.getItem('language'),
|
|
621
|
+
'ignore-cookies': 'true'
|
|
622
|
+
});
|
|
579
623
|
};
|
|
580
|
-
|
|
581
|
-
|
|
624
|
+
return RequestHandlerService;
|
|
625
|
+
}());
|
|
626
|
+
RequestHandlerService.decorators = [
|
|
627
|
+
{ type: i0.Injectable }
|
|
628
|
+
];
|
|
629
|
+
RequestHandlerService.ctorParameters = function () { return [
|
|
630
|
+
{ type: i1$1.HttpClient },
|
|
631
|
+
{ type: AuthService },
|
|
632
|
+
{ type: EnvironmentService },
|
|
633
|
+
{ type: UtilityService },
|
|
634
|
+
{ type: BBSFTranslateService },
|
|
635
|
+
{ type: i1$2.Router }
|
|
636
|
+
]; };
|
|
637
|
+
|
|
638
|
+
var StylesBundleService = /** @class */ (function () {
|
|
639
|
+
function StylesBundleService(document, translateService) {
|
|
640
|
+
this.document = document;
|
|
641
|
+
this.translateService = translateService;
|
|
642
|
+
}
|
|
643
|
+
StylesBundleService.prototype.loadThemes = function (lang, bundleEnglishName, bundleArabicName) {
|
|
644
|
+
if (lang == "ar") {
|
|
645
|
+
this.loadStyleBundle(bundleArabicName.toString());
|
|
646
|
+
document.querySelector('html').setAttribute("b-lang", "ar"); //use b-lang instead of lang to fix firefox number inputs in Arabic locale
|
|
647
|
+
document.querySelector('html').setAttribute("dir", "rtl");
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
this.loadStyleBundle(bundleEnglishName.toString());
|
|
651
|
+
document.querySelector('html').setAttribute("b-lang", "en");
|
|
652
|
+
document.querySelector('html').setAttribute("dir", "ltr");
|
|
653
|
+
}
|
|
582
654
|
};
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
case 0: return [4 /*yield*/, this.manager.signinSilentCallback()];
|
|
589
|
-
case 1:
|
|
590
|
-
user = _a.sent();
|
|
591
|
-
//await this.manager.storeUser(user);
|
|
592
|
-
AuthService.user = user;
|
|
593
|
-
console.log("Token from signinSilentCallback :" + AuthService.user);
|
|
594
|
-
this.user = user;
|
|
595
|
-
return [2 /*return*/];
|
|
596
|
-
}
|
|
597
|
-
});
|
|
598
|
-
});
|
|
655
|
+
StylesBundleService.prototype.loadThemesColor = function (theme, bundleDarkName, bundleLightName) {
|
|
656
|
+
if (theme == "Light")
|
|
657
|
+
this.loadStyleBundle(bundleLightName.toString());
|
|
658
|
+
else
|
|
659
|
+
this.loadStyleBundle(bundleDarkName.toString());
|
|
599
660
|
};
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
});
|
|
615
|
-
});
|
|
661
|
+
StylesBundleService.prototype.loadStyleBundle = function (styleName) {
|
|
662
|
+
var head = this.document.getElementsByTagName('head')[0];
|
|
663
|
+
var themeLink = this.document.getElementById('client-theme');
|
|
664
|
+
if (themeLink && themeLink.href.includes(styleName)) {
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
else if (themeLink && !themeLink.href.includes(styleName)) {
|
|
668
|
+
themeLink.remove();
|
|
669
|
+
}
|
|
670
|
+
var style = this.document.createElement('link');
|
|
671
|
+
style.id = 'client-theme';
|
|
672
|
+
style.rel = 'stylesheet';
|
|
673
|
+
style.href = "" + styleName;
|
|
674
|
+
head.appendChild(style);
|
|
616
675
|
};
|
|
617
|
-
return
|
|
676
|
+
return StylesBundleService;
|
|
618
677
|
}());
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
AuthService.decorators = [
|
|
678
|
+
StylesBundleService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function StylesBundleService_Factory() { return new StylesBundleService(i0__namespace.ɵɵinject(i1__namespace$1.DOCUMENT), i0__namespace.ɵɵinject(BBSFTranslateService)); }, token: StylesBundleService, providedIn: "root" });
|
|
679
|
+
StylesBundleService.decorators = [
|
|
622
680
|
{ type: i0.Injectable, args: [{
|
|
623
681
|
providedIn: 'root'
|
|
624
682
|
},] }
|
|
625
683
|
];
|
|
626
|
-
|
|
627
|
-
{ type: i1$
|
|
628
|
-
{ type:
|
|
629
|
-
{ type: BBSFTranslateService },
|
|
630
|
-
{ type: i4.Router }
|
|
684
|
+
StylesBundleService.ctorParameters = function () { return [
|
|
685
|
+
{ type: Document, decorators: [{ type: i0.Inject, args: [i1$3.DOCUMENT,] }] },
|
|
686
|
+
{ type: BBSFTranslateService }
|
|
631
687
|
]; };
|
|
632
688
|
|
|
633
|
-
var
|
|
634
|
-
function
|
|
635
|
-
this.
|
|
689
|
+
var MasterLayoutService = /** @class */ (function () {
|
|
690
|
+
function MasterLayoutService(router, http, authService, stylesBundleService, translate, environmentService) {
|
|
691
|
+
this.router = router;
|
|
692
|
+
this.http = http;
|
|
636
693
|
this.authService = authService;
|
|
694
|
+
this.stylesBundleService = stylesBundleService;
|
|
695
|
+
this.translate = translate;
|
|
637
696
|
this.environmentService = environmentService;
|
|
638
|
-
this.
|
|
697
|
+
this.ApiUrl = '/api/Home/';
|
|
639
698
|
}
|
|
640
|
-
|
|
641
|
-
var
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
699
|
+
MasterLayoutService.prototype.switchLang = function (lang, bundleEnglishName, bundleArabicName) {
|
|
700
|
+
var _this = this;
|
|
701
|
+
this.changeLanguage(lang).subscribe(function (result) {
|
|
702
|
+
_this.updateUserInfo().subscribe(function (Value) {
|
|
703
|
+
var UserInfoObject = Value;
|
|
704
|
+
_this.authService.getUser();
|
|
705
|
+
_this.authService.user.profile = Object.assign(_this.authService.user.profile, UserInfoObject);
|
|
706
|
+
_this.authService.storUser(_this.authService.user);
|
|
707
|
+
_this.stylesBundleService.loadThemes(lang, bundleEnglishName, bundleArabicName);
|
|
708
|
+
localStorage.setItem('language', lang);
|
|
709
|
+
_this.translate.use(lang);
|
|
710
|
+
});
|
|
711
|
+
});
|
|
652
712
|
};
|
|
653
|
-
|
|
654
|
-
|
|
713
|
+
MasterLayoutService.prototype.reloadComponent = function () {
|
|
714
|
+
var currentUrl = this.router.url;
|
|
715
|
+
this.router.routeReuseStrategy.shouldReuseRoute = function () { return false; };
|
|
716
|
+
this.router.onSameUrlNavigation = 'reload';
|
|
717
|
+
this.router.navigate([currentUrl]);
|
|
655
718
|
};
|
|
656
|
-
|
|
657
|
-
|
|
719
|
+
MasterLayoutService.prototype.changeLanguage = function (key) {
|
|
720
|
+
var params = new i1$1.HttpParams();
|
|
721
|
+
params = params.append('UserId', this.authService.user.profile.id);
|
|
722
|
+
params = params.append('LanguageKey', key);
|
|
723
|
+
return this.http.post(this.ApiUrl + 'UpdateLanguage', null, null, params);
|
|
658
724
|
};
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
var MessageTemplate = this.getResourceValue("SuccessMessage");
|
|
662
|
-
var titleTemplate;
|
|
663
|
-
if (Message) {
|
|
664
|
-
MessageTemplate = Message;
|
|
665
|
-
}
|
|
666
|
-
if (title) {
|
|
667
|
-
titleTemplate = title;
|
|
668
|
-
}
|
|
669
|
-
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
670
|
-
showHeader ? toaster.success(MessageTemplate, titleTemplate) : toaster.success(MessageTemplate);
|
|
725
|
+
MasterLayoutService.prototype.getUserClaims = function () {
|
|
726
|
+
return this.http.get(this.ApiUrl + 'GetUserClaims', null, null);
|
|
671
727
|
};
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
if (Message) {
|
|
677
|
-
MessageTemplate = Message;
|
|
678
|
-
}
|
|
679
|
-
if (title) {
|
|
680
|
-
titleTemplate = title;
|
|
681
|
-
}
|
|
682
|
-
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
683
|
-
showHeader ? toaster.error(MessageTemplate, titleTemplate) : toaster.error(MessageTemplate);
|
|
728
|
+
MasterLayoutService.prototype.logError = function (error) {
|
|
729
|
+
var params = new i1$1.HttpParams();
|
|
730
|
+
params = params.append('error', error);
|
|
731
|
+
return this.http.post(this.ApiUrl + 'LogError', null, null, params);
|
|
684
732
|
};
|
|
685
|
-
|
|
686
|
-
if (
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
if (Message) {
|
|
690
|
-
MessageTemplate = Message;
|
|
691
|
-
}
|
|
692
|
-
if (title) {
|
|
693
|
-
titleTemplate = title;
|
|
694
|
-
}
|
|
695
|
-
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
696
|
-
showHeader ? toaster.warning(MessageTemplate, titleTemplate) : toaster.warning(MessageTemplate);
|
|
733
|
+
MasterLayoutService.prototype.updateUserInfo = function () {
|
|
734
|
+
if (this.environmentService.getIsIdentityServerExternal())
|
|
735
|
+
return this.getUserClaims();
|
|
736
|
+
return this.http.get('/connect/userinfo');
|
|
697
737
|
};
|
|
698
|
-
|
|
699
|
-
this
|
|
738
|
+
MasterLayoutService.prototype.switchRole = function (permissionSetID) {
|
|
739
|
+
var _this = this;
|
|
740
|
+
this.updateRole(permissionSetID).subscribe(function (result) {
|
|
741
|
+
_this.updateUserInfo().subscribe(function (Value) {
|
|
742
|
+
var UserInfoObject = Value;
|
|
743
|
+
_this.authService.getUser();
|
|
744
|
+
_this.authService.user.profile = Object.assign(_this.authService.user.profile, UserInfoObject);
|
|
745
|
+
_this.authService.storUser(_this.authService.user);
|
|
746
|
+
});
|
|
747
|
+
});
|
|
700
748
|
};
|
|
701
|
-
|
|
702
|
-
|
|
749
|
+
MasterLayoutService.prototype.updateRole = function (permissionSetID) {
|
|
750
|
+
var params = new i1$1.HttpParams();
|
|
751
|
+
params = params.append('UserId', this.authService.user.profile.id);
|
|
752
|
+
params = params.append('RoleID', permissionSetID);
|
|
753
|
+
return this.http.post(this.ApiUrl + 'SwitchRole', null, null, params);
|
|
703
754
|
};
|
|
704
|
-
return
|
|
755
|
+
return MasterLayoutService;
|
|
705
756
|
}());
|
|
706
|
-
|
|
707
|
-
|
|
757
|
+
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" });
|
|
758
|
+
MasterLayoutService.decorators = [
|
|
708
759
|
{ type: i0.Injectable, args: [{
|
|
709
|
-
providedIn: 'root'
|
|
760
|
+
providedIn: 'root',
|
|
710
761
|
},] }
|
|
711
762
|
];
|
|
712
|
-
|
|
713
|
-
{ type:
|
|
763
|
+
MasterLayoutService.ctorParameters = function () { return [
|
|
764
|
+
{ type: i1$2.Router },
|
|
765
|
+
{ type: RequestHandlerService },
|
|
714
766
|
{ type: AuthService },
|
|
767
|
+
{ type: StylesBundleService },
|
|
768
|
+
{ type: i1.TranslateService },
|
|
715
769
|
{ type: EnvironmentService }
|
|
716
|
-
]; };
|
|
717
|
-
__decorate([
|
|
718
|
-
ngBlockUi.BlockUI()
|
|
719
|
-
], UtilityService.prototype, "blockUI", void 0);
|
|
770
|
+
]; };
|
|
720
771
|
|
|
721
|
-
var
|
|
722
|
-
function
|
|
723
|
-
this.disableSuccessNotification = false;
|
|
724
|
-
this.disableBlockUI = false;
|
|
725
|
-
this.disableErrorHandler = false;
|
|
726
|
-
this.responseType = "";
|
|
727
|
-
this.formGroup = null;
|
|
728
|
-
this.castResponsetoClass = true;
|
|
729
|
-
}
|
|
730
|
-
return RequestOptionsModel;
|
|
731
|
-
}());
|
|
732
|
-
|
|
733
|
-
var RequestHandlerService = /** @class */ (function () {
|
|
734
|
-
function RequestHandlerService(http, authService, environmentService, utilityService, bbsfTranslateService, router) {
|
|
772
|
+
var AuthService = /** @class */ (function () {
|
|
773
|
+
function AuthService(injector, http, environmentService, translateService, router) {
|
|
735
774
|
var _this = this;
|
|
736
|
-
|
|
775
|
+
this.injector = injector;
|
|
737
776
|
this.http = http;
|
|
738
|
-
this.authService = authService;
|
|
739
777
|
this.environmentService = environmentService;
|
|
740
|
-
this.
|
|
741
|
-
this.bbsfTranslateService = bbsfTranslateService;
|
|
778
|
+
this.translateService = translateService;
|
|
742
779
|
this.router = router;
|
|
743
|
-
|
|
744
|
-
this.
|
|
745
|
-
|
|
746
|
-
this.
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
780
|
+
// Observable navItem source
|
|
781
|
+
this._authNavStatusSource = new rxjs.BehaviorSubject(false);
|
|
782
|
+
// Observable navItem stream
|
|
783
|
+
this.authNavStatus$ = this._authNavStatusSource.asObservable();
|
|
784
|
+
// Observable navItem source
|
|
785
|
+
this._userSource = new rxjs.Subject();
|
|
786
|
+
this.UserStatus$ = this._userSource.asObservable();
|
|
787
|
+
this.manager = this.getUserManager();
|
|
788
|
+
this.redirectUrl = '';
|
|
789
|
+
this.manager.getUser().then(function (user) { return __awaiter(_this, void 0, void 0, function () {
|
|
790
|
+
var _a, _b;
|
|
791
|
+
return __generator(this, function (_c) {
|
|
792
|
+
switch (_c.label) {
|
|
793
|
+
case 0:
|
|
794
|
+
this.manager.storeUser(user);
|
|
795
|
+
AuthService.user = user;
|
|
796
|
+
this.user = user;
|
|
797
|
+
_b = (_a = this._authNavStatusSource).next;
|
|
798
|
+
return [4 /*yield*/, this.isAuthenticated()];
|
|
799
|
+
case 1:
|
|
800
|
+
_b.apply(_a, [_c.sent()]);
|
|
801
|
+
return [2 /*return*/];
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
}); });
|
|
805
|
+
this.manager.events.addAccessTokenExpired(function (_) {
|
|
806
|
+
_this._authNavStatusSource.next(false);
|
|
750
807
|
});
|
|
751
808
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
809
|
+
AuthService.prototype.getUserManager = function () {
|
|
810
|
+
var user = null;
|
|
811
|
+
var isExternal = this.environmentService.getIsIdentityServerExternal().toLowerCase() == "true";
|
|
812
|
+
if (isExternal) {
|
|
813
|
+
user = new oidcClient.UserManager({
|
|
814
|
+
authority: this.environmentService.getIdentityServerUrl(),
|
|
815
|
+
client_id: this.environmentService.getIsIdentityServerClientId(),
|
|
816
|
+
client_secret: this.environmentService.getIsIdentityServerClientSecret(),
|
|
817
|
+
redirect_uri: this.environmentService.getBaseUrl() +
|
|
818
|
+
'/Admin/authentication/auth-callback',
|
|
819
|
+
post_logout_redirect_uri: this.environmentService.getBaseUrl(),
|
|
820
|
+
response_type: 'code',
|
|
821
|
+
scope: 'openid profile email',
|
|
822
|
+
filterProtocolClaims: true,
|
|
823
|
+
loadUserInfo: true,
|
|
824
|
+
automaticSilentRenew: true,
|
|
825
|
+
silent_redirect_uri: this.environmentService.getBaseUrl() + '/assets/silent-callback.html',
|
|
826
|
+
userStore: new oidcClient.WebStorageStateStore({ store: window.localStorage }),
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
else {
|
|
830
|
+
user = new oidcClient.UserManager({
|
|
831
|
+
authority: this.environmentService.getIdentityServerUrl(),
|
|
832
|
+
client_id: 'angular_spa',
|
|
833
|
+
redirect_uri: this.environmentService.getBaseUrl() +
|
|
834
|
+
'/Admin/authentication/auth-callback',
|
|
835
|
+
post_logout_redirect_uri: this.environmentService.getBaseUrl(),
|
|
836
|
+
response_type: 'id_token token',
|
|
837
|
+
scope: 'openid profile email IdentityServerApi',
|
|
838
|
+
filterProtocolClaims: true,
|
|
839
|
+
loadUserInfo: true,
|
|
840
|
+
automaticSilentRenew: true,
|
|
841
|
+
silent_redirect_uri: this.environmentService.getBaseUrl() + '/assets/silent-callback.html',
|
|
842
|
+
userStore: new oidcClient.WebStorageStateStore({ store: window.localStorage }),
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
return user;
|
|
760
846
|
};
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
if (requestOptions)
|
|
764
|
-
this.requestOptions = requestOptions;
|
|
765
|
-
var headers = this.getHeaders();
|
|
766
|
-
if (!this.requestOptions.disableBlockUI)
|
|
767
|
-
this.utilityService.startBlockUI();
|
|
768
|
-
var object;
|
|
769
|
-
return this.http.get(this.environmentService.getApiUrl() + Url, { headers: headers, params: params }).pipe(operators.takeUntil(this.onDestroy$), operators.tap(function (result) {
|
|
770
|
-
if (!_this.requestOptions.disableBlockUI)
|
|
771
|
-
_this.utilityService.stopBlockUI();
|
|
772
|
-
}, function (error) {
|
|
773
|
-
if (!_this.requestOptions.disableErrorHandler)
|
|
774
|
-
_this.handleError(error);
|
|
775
|
-
}), operators.map(function (data) {
|
|
776
|
-
if (_this.requestOptions.castResponsetoClass)
|
|
777
|
-
return classTransformer.plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
778
|
-
else
|
|
779
|
-
return data;
|
|
780
|
-
}));
|
|
847
|
+
AuthService.prototype.login = function () {
|
|
848
|
+
return this.manager.signinRedirect();
|
|
781
849
|
};
|
|
782
|
-
|
|
850
|
+
AuthService.prototype.getUser = function () {
|
|
783
851
|
var _this = this;
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
return data;
|
|
800
|
-
}));
|
|
852
|
+
this.manager.getUser().then(function (user) { return __awaiter(_this, void 0, void 0, function () {
|
|
853
|
+
var _a, _b;
|
|
854
|
+
return __generator(this, function (_c) {
|
|
855
|
+
switch (_c.label) {
|
|
856
|
+
case 0:
|
|
857
|
+
AuthService.user = user;
|
|
858
|
+
this.user = user;
|
|
859
|
+
_b = (_a = this._authNavStatusSource).next;
|
|
860
|
+
return [4 /*yield*/, this.isAuthenticated()];
|
|
861
|
+
case 1:
|
|
862
|
+
_b.apply(_a, [_c.sent()]);
|
|
863
|
+
return [2 /*return*/];
|
|
864
|
+
}
|
|
865
|
+
});
|
|
866
|
+
}); });
|
|
801
867
|
};
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
if (requestOptions)
|
|
805
|
-
this.requestOptions = requestOptions;
|
|
806
|
-
var headers = this.getHeaders();
|
|
807
|
-
if (!this.requestOptions.disableBlockUI)
|
|
808
|
-
this.utilityService.startBlockUI();
|
|
809
|
-
return this.http.delete(this.environmentService.getApiUrl() + Url + ("/" + deletedId), { headers: headers, params: params }).pipe(operators.takeUntil(this.onDestroy$), operators.tap(function (result) {
|
|
810
|
-
if (!_this.requestOptions.disableBlockUI)
|
|
811
|
-
_this.utilityService.stopBlockUI();
|
|
812
|
-
}, function (error) {
|
|
813
|
-
if (!_this.requestOptions.disableErrorHandler)
|
|
814
|
-
_this.handleError(error);
|
|
815
|
-
}), operators.map(function (data) {
|
|
816
|
-
if (_this.requestOptions.castResponsetoClass)
|
|
817
|
-
return classTransformer.plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
818
|
-
else
|
|
819
|
-
return data;
|
|
820
|
-
}));
|
|
868
|
+
AuthService.prototype.storUser = function (User) {
|
|
869
|
+
this.manager.storeUser(User);
|
|
821
870
|
};
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
if (requestOptions)
|
|
825
|
-
this.requestOptions = requestOptions;
|
|
826
|
-
var headers = this.getHeaders();
|
|
827
|
-
if (!this.requestOptions.disableBlockUI)
|
|
828
|
-
this.utilityService.startBlockUI();
|
|
829
|
-
return this.http.put(this.environmentService.getApiUrl() + Url, model, { headers: headers, params: params, responseType: this.requestOptions.responseType }).pipe(operators.takeUntil(this.onDestroy$), operators.tap(function (result) {
|
|
830
|
-
if (!_this.requestOptions.disableBlockUI)
|
|
831
|
-
_this.utilityService.stopBlockUI();
|
|
832
|
-
}, function (error) {
|
|
833
|
-
if (!_this.requestOptions.disableErrorHandler)
|
|
834
|
-
_this.handleError(error);
|
|
835
|
-
}), operators.map(function (data) {
|
|
836
|
-
if (_this.requestOptions.castResponsetoClass)
|
|
837
|
-
return classTransformer.plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
838
|
-
else
|
|
839
|
-
return data;
|
|
840
|
-
}));
|
|
871
|
+
AuthService.prototype.revokeAccessToken = function () {
|
|
872
|
+
this.manager.revokeAccessToken();
|
|
841
873
|
};
|
|
842
|
-
|
|
843
|
-
var
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
var headers = new i1$1.HttpHeaders({
|
|
847
|
-
'Content-Type': 'application/json',
|
|
848
|
-
'Authorization': this.authService.authorizationHeaderValue(),
|
|
874
|
+
AuthService.prototype.signinSilent = function () {
|
|
875
|
+
var x = this.manager.signinSilentCallback();
|
|
876
|
+
x.then(function (s) {
|
|
877
|
+
//console.log(s)
|
|
849
878
|
});
|
|
850
|
-
this.currentLanguage = localStorage.getItem('language');
|
|
851
|
-
headers = headers.set('Accept-Language', this.currentLanguage.toString());
|
|
852
|
-
headers = headers.set('ignore-cookies', 'true');
|
|
853
|
-
if (!this.requestOptions.disableBlockUI)
|
|
854
|
-
this.utilityService.startBlockUI();
|
|
855
|
-
return this.http.patch(this.environmentService.getApiUrl() + Url, model, { headers: headers, params: params, responseType: this.requestOptions.responseType }).pipe(operators.takeUntil(this.onDestroy$), operators.tap(function (result) {
|
|
856
|
-
if (!_this.requestOptions.disableBlockUI)
|
|
857
|
-
_this.utilityService.stopBlockUI();
|
|
858
|
-
}, function (error) {
|
|
859
|
-
if (!_this.requestOptions.disableErrorHandler)
|
|
860
|
-
_this.handleError(error);
|
|
861
|
-
}), operators.map(function (data) {
|
|
862
|
-
if (_this.requestOptions.castResponsetoClass)
|
|
863
|
-
return classTransformer.plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
864
|
-
else
|
|
865
|
-
return data;
|
|
866
|
-
}));
|
|
867
879
|
};
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
this
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
880
|
+
AuthService.prototype.completeAuthentication = function () {
|
|
881
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
882
|
+
var _a, _b, _c, isExternal, masterLayoutService, userClaims, _d, _e;
|
|
883
|
+
return __generator(this, function (_f) {
|
|
884
|
+
switch (_f.label) {
|
|
885
|
+
case 0:
|
|
886
|
+
_a = this;
|
|
887
|
+
return [4 /*yield*/, this.manager.signinRedirectCallback()];
|
|
888
|
+
case 1:
|
|
889
|
+
_a.user = _f.sent();
|
|
890
|
+
AuthService.user = this.user;
|
|
891
|
+
this._userSource.next(AuthService.user);
|
|
892
|
+
_c = (_b = this._authNavStatusSource).next;
|
|
893
|
+
return [4 /*yield*/, this.isAuthenticated()];
|
|
894
|
+
case 2:
|
|
895
|
+
_c.apply(_b, [_f.sent()]);
|
|
896
|
+
isExternal = this.environmentService.getIsIdentityServerExternal().toLowerCase() == "true";
|
|
897
|
+
if (!isExternal) return [3 /*break*/, 4];
|
|
898
|
+
masterLayoutService = this.injector.get(MasterLayoutService);
|
|
899
|
+
return [4 /*yield*/, masterLayoutService
|
|
900
|
+
.getUserClaims()
|
|
901
|
+
.toPromise()
|
|
902
|
+
.then(function (e) {
|
|
903
|
+
AuthService.UserClaims = e;
|
|
904
|
+
})];
|
|
905
|
+
case 3:
|
|
906
|
+
userClaims = _f.sent();
|
|
907
|
+
AuthService.user.profile = Object.assign(AuthService.user.profile, AuthService.UserClaims);
|
|
908
|
+
_f.label = 4;
|
|
909
|
+
case 4:
|
|
910
|
+
this.storUser(AuthService.user);
|
|
911
|
+
if (!localStorage.getItem('language') ||
|
|
912
|
+
localStorage.getItem('language') == this.user.profile.locale)
|
|
913
|
+
localStorage.setItem('language', this.user.profile.locale);
|
|
914
|
+
if (!(this.translateService.currentLang != localStorage.getItem('language'))) return [3 /*break*/, 6];
|
|
915
|
+
this.translateService.resetLang(this.translateService.currentLang);
|
|
916
|
+
return [4 /*yield*/, this.translateService
|
|
917
|
+
.reloadLang(localStorage.getItem('language'))
|
|
918
|
+
.subscribe(function (res) {
|
|
919
|
+
console.log(res);
|
|
920
|
+
})];
|
|
921
|
+
case 5:
|
|
922
|
+
_f.sent();
|
|
923
|
+
_f.label = 6;
|
|
924
|
+
case 6:
|
|
925
|
+
this._userSource.next(AuthService.user);
|
|
926
|
+
_e = (_d = this._authNavStatusSource).next;
|
|
927
|
+
return [4 /*yield*/, this.isAuthenticated()];
|
|
928
|
+
case 7:
|
|
929
|
+
_e.apply(_d, [_f.sent()]);
|
|
930
|
+
this.user = AuthService.user;
|
|
931
|
+
return [2 /*return*/];
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
});
|
|
935
|
+
};
|
|
936
|
+
AuthService.prototype.refreshToken = function (token) {
|
|
937
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
938
|
+
var httpOptions;
|
|
939
|
+
var _this = this;
|
|
940
|
+
return __generator(this, function (_a) {
|
|
941
|
+
switch (_a.label) {
|
|
942
|
+
case 0:
|
|
943
|
+
httpOptions = {
|
|
944
|
+
headers: new i1$1.HttpHeaders({
|
|
945
|
+
'Content-Type': 'application/json',
|
|
946
|
+
Authorization: token,
|
|
947
|
+
}),
|
|
948
|
+
};
|
|
949
|
+
this.manager.revokeAccessToken();
|
|
950
|
+
return [4 /*yield*/, this.http
|
|
951
|
+
.post(this.environmentService.getIdentityServerUrl() + "/users/refresh-token", httpOptions, { withCredentials: true })
|
|
952
|
+
.subscribe(function (user) {
|
|
953
|
+
_this._userSource.next(user);
|
|
954
|
+
AuthService.user = user;
|
|
955
|
+
_this.user = user;
|
|
956
|
+
})];
|
|
957
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
958
|
+
}
|
|
959
|
+
});
|
|
960
|
+
});
|
|
961
|
+
};
|
|
962
|
+
AuthService.prototype.getCurrentUser = function () {
|
|
963
|
+
return this.manager.getUser();
|
|
964
|
+
};
|
|
965
|
+
AuthService.prototype.isAuthenticated = function () {
|
|
966
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
967
|
+
var user;
|
|
968
|
+
return __generator(this, function (_a) {
|
|
969
|
+
switch (_a.label) {
|
|
970
|
+
case 0: return [4 /*yield*/, this.manager.getUser().then(function (user) {
|
|
971
|
+
return user;
|
|
972
|
+
})];
|
|
973
|
+
case 1:
|
|
974
|
+
user = _a.sent();
|
|
975
|
+
return [2 /*return*/, this.user != null && !this.user.expired];
|
|
976
|
+
}
|
|
977
|
+
});
|
|
978
|
+
});
|
|
882
979
|
};
|
|
883
|
-
|
|
884
|
-
this.
|
|
980
|
+
AuthService.prototype.isUserInRole = function (allowedPermission) {
|
|
981
|
+
var selectedPermissionSetID = Number.parseInt(this.user.profile['selectedpermissionsetid']);
|
|
982
|
+
return allowedPermission.includes(selectedPermissionSetID);
|
|
885
983
|
};
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
984
|
+
AuthService.prototype.authorizationHeaderValue = function () {
|
|
985
|
+
return AuthService.user
|
|
986
|
+
? AuthService.user.token_type + " " + AuthService.user.access_token
|
|
987
|
+
: '';
|
|
889
988
|
};
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
if (err.error instanceof ErrorEvent) {
|
|
893
|
-
this.utilityService.notifyErrorMessage();
|
|
894
|
-
}
|
|
895
|
-
else {
|
|
896
|
-
if (err.status == 400)
|
|
897
|
-
rxjs.throwError(err); //error 400 is thrown to be catch by the Form component to handle Fluent validation errors
|
|
898
|
-
else if (err.status == 401)
|
|
899
|
-
this.router.navigate(["/Admin/account/login"]);
|
|
900
|
-
else if (err.status == 403)
|
|
901
|
-
this.utilityService.notifyErrorMessage(isEnglish ? "Sorry, You're not authorized to access this action" : "عذرا ليس لديك الصلاحيه لهذا الطلب");
|
|
902
|
-
else if (err.status == 510)
|
|
903
|
-
this.utilityService.notifyErrorMessage(isEnglish ? "Can not delete this item as it is related to others" : "لا يمكن حذف هذا العنصر لأنه مرتبط بعناصر أخرى");
|
|
904
|
-
else
|
|
905
|
-
this.utilityService.notifyErrorMessage("error message is: " + (err.error ? err.error.Message : err.message));
|
|
906
|
-
}
|
|
907
|
-
this.utilityService.stopBlockUI();
|
|
989
|
+
AuthService.prototype.name = function () {
|
|
990
|
+
return AuthService.user != null ? AuthService.user.profile.given_name : '';
|
|
908
991
|
};
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
992
|
+
AuthService.prototype.setUrl = function (url) {
|
|
993
|
+
localStorage.setItem('redirectUrl', url);
|
|
994
|
+
};
|
|
995
|
+
AuthService.prototype.getUrl = function () {
|
|
996
|
+
return localStorage.getItem('redirectUrl');
|
|
997
|
+
};
|
|
998
|
+
AuthService.prototype.signinSilentCallback = function () {
|
|
999
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1000
|
+
var user;
|
|
1001
|
+
return __generator(this, function (_a) {
|
|
1002
|
+
switch (_a.label) {
|
|
1003
|
+
case 0: return [4 /*yield*/, this.manager.signinSilentCallback()];
|
|
1004
|
+
case 1:
|
|
1005
|
+
user = _a.sent();
|
|
1006
|
+
//await this.manager.storeUser(user);
|
|
1007
|
+
AuthService.user = user;
|
|
1008
|
+
console.log('Token from signinSilentCallback :' + AuthService.user);
|
|
1009
|
+
this.user = user;
|
|
1010
|
+
return [2 /*return*/];
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
916
1013
|
});
|
|
917
1014
|
};
|
|
918
|
-
|
|
1015
|
+
AuthService.prototype.signout = function () {
|
|
1016
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1017
|
+
return __generator(this, function (_a) {
|
|
1018
|
+
switch (_a.label) {
|
|
1019
|
+
case 0: return [4 /*yield*/, !this.isAuthenticated()];
|
|
1020
|
+
case 1:
|
|
1021
|
+
if (_a.sent())
|
|
1022
|
+
this.router.navigate(['/Admin/account/login']), localStorage.clear();
|
|
1023
|
+
return [4 /*yield*/, this.manager.signoutRedirect()];
|
|
1024
|
+
case 2:
|
|
1025
|
+
_a.sent();
|
|
1026
|
+
return [2 /*return*/];
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
1029
|
+
});
|
|
1030
|
+
};
|
|
1031
|
+
return AuthService;
|
|
919
1032
|
}());
|
|
920
|
-
|
|
921
|
-
|
|
1033
|
+
AuthService.user = null;
|
|
1034
|
+
AuthService.UserClaims = null;
|
|
1035
|
+
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" });
|
|
1036
|
+
AuthService.decorators = [
|
|
1037
|
+
{ type: i0.Injectable, args: [{
|
|
1038
|
+
providedIn: 'root',
|
|
1039
|
+
},] }
|
|
922
1040
|
];
|
|
923
|
-
|
|
1041
|
+
AuthService.ctorParameters = function () { return [
|
|
1042
|
+
{ type: i0.Injector },
|
|
924
1043
|
{ type: i1$1.HttpClient },
|
|
925
|
-
{ type: AuthService },
|
|
926
1044
|
{ type: EnvironmentService },
|
|
927
|
-
{ type: UtilityService },
|
|
928
1045
|
{ type: BBSFTranslateService },
|
|
929
|
-
{ type:
|
|
1046
|
+
{ type: i1$2.Router }
|
|
930
1047
|
]; };
|
|
931
1048
|
|
|
932
|
-
var
|
|
933
|
-
function
|
|
934
|
-
this.
|
|
935
|
-
this.
|
|
1049
|
+
var UtilityService = /** @class */ (function () {
|
|
1050
|
+
function UtilityService(translator, authService, environmentService) {
|
|
1051
|
+
this.translator = translator;
|
|
1052
|
+
this.authService = authService;
|
|
1053
|
+
this.environmentService = environmentService;
|
|
1054
|
+
this.isCreatedBefore = false;
|
|
936
1055
|
}
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1056
|
+
UtilityService.prototype.getResourceValue = function (Key) {
|
|
1057
|
+
var ResourceValue = this.translator.instant(Key);
|
|
1058
|
+
return ResourceValue;
|
|
1059
|
+
};
|
|
1060
|
+
UtilityService.prototype.getCurrentLanguage = function () {
|
|
1061
|
+
var currentLanguage = this.environmentService.getDefaultLanguage();
|
|
1062
|
+
var lang = localStorage.getItem('language');
|
|
1063
|
+
if (lang)
|
|
1064
|
+
currentLanguage = lang;
|
|
1065
|
+
else
|
|
1066
|
+
localStorage.setItem('language', currentLanguage);
|
|
1067
|
+
return currentLanguage;
|
|
1068
|
+
};
|
|
1069
|
+
UtilityService.prototype.isCurrentLanguageEnglish = function () {
|
|
1070
|
+
return this.getCurrentLanguage() == "en";
|
|
1071
|
+
};
|
|
1072
|
+
UtilityService.prototype.isCurrentLanguageArabic = function () {
|
|
1073
|
+
return this.getCurrentLanguage() == "ar";
|
|
1074
|
+
};
|
|
1075
|
+
UtilityService.prototype.notifySuccessMessage = function (Message, title, time, showHeader) {
|
|
1076
|
+
if (showHeader === void 0) { showHeader = true; }
|
|
1077
|
+
var MessageTemplate = this.getResourceValue("SuccessMessage");
|
|
1078
|
+
var titleTemplate;
|
|
1079
|
+
if (Message) {
|
|
1080
|
+
MessageTemplate = Message;
|
|
942
1081
|
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
document.querySelector('html').setAttribute("b-lang", "en");
|
|
946
|
-
document.querySelector('html').setAttribute("dir", "ltr");
|
|
1082
|
+
if (title) {
|
|
1083
|
+
titleTemplate = title;
|
|
947
1084
|
}
|
|
1085
|
+
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
1086
|
+
showHeader ? toaster.success(MessageTemplate, titleTemplate) : toaster.success(MessageTemplate);
|
|
948
1087
|
};
|
|
949
|
-
|
|
950
|
-
if (
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
1088
|
+
UtilityService.prototype.notifyErrorMessage = function (Message, title, time, showHeader) {
|
|
1089
|
+
if (showHeader === void 0) { showHeader = true; }
|
|
1090
|
+
var MessageTemplate = this.getResourceValue("ErrorMessage");
|
|
1091
|
+
var titleTemplate = this.getResourceValue("Error");
|
|
1092
|
+
if (Message) {
|
|
1093
|
+
MessageTemplate = Message;
|
|
1094
|
+
}
|
|
1095
|
+
if (title) {
|
|
1096
|
+
titleTemplate = title;
|
|
1097
|
+
}
|
|
1098
|
+
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
1099
|
+
showHeader ? toaster.error(MessageTemplate, titleTemplate) : toaster.error(MessageTemplate);
|
|
954
1100
|
};
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
var
|
|
958
|
-
|
|
959
|
-
|
|
1101
|
+
UtilityService.prototype.notifyWarningMessage = function (Message, title, time, showHeader) {
|
|
1102
|
+
if (showHeader === void 0) { showHeader = true; }
|
|
1103
|
+
var MessageTemplate = this.getResourceValue("WarningMessage");
|
|
1104
|
+
var titleTemplate = this.getResourceValue("Warning");
|
|
1105
|
+
if (Message) {
|
|
1106
|
+
MessageTemplate = Message;
|
|
960
1107
|
}
|
|
961
|
-
|
|
962
|
-
|
|
1108
|
+
if (title) {
|
|
1109
|
+
titleTemplate = title;
|
|
963
1110
|
}
|
|
964
|
-
var
|
|
965
|
-
|
|
966
|
-
style.rel = 'stylesheet';
|
|
967
|
-
style.href = "" + styleName;
|
|
968
|
-
head.appendChild(style);
|
|
1111
|
+
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
1112
|
+
showHeader ? toaster.warning(MessageTemplate, titleTemplate) : toaster.warning(MessageTemplate);
|
|
969
1113
|
};
|
|
970
|
-
|
|
1114
|
+
UtilityService.prototype.startBlockUI = function () {
|
|
1115
|
+
this.blockUI.start();
|
|
1116
|
+
};
|
|
1117
|
+
UtilityService.prototype.stopBlockUI = function () {
|
|
1118
|
+
this.blockUI.stop();
|
|
1119
|
+
};
|
|
1120
|
+
return UtilityService;
|
|
971
1121
|
}());
|
|
972
|
-
|
|
973
|
-
|
|
1122
|
+
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" });
|
|
1123
|
+
UtilityService.decorators = [
|
|
974
1124
|
{ type: i0.Injectable, args: [{
|
|
975
1125
|
providedIn: 'root'
|
|
976
1126
|
},] }
|
|
977
1127
|
];
|
|
978
|
-
|
|
979
|
-
{ type:
|
|
980
|
-
{ type:
|
|
981
|
-
|
|
1128
|
+
UtilityService.ctorParameters = function () { return [
|
|
1129
|
+
{ type: BBSFTranslateService },
|
|
1130
|
+
{ type: AuthService },
|
|
1131
|
+
{ type: EnvironmentService }
|
|
1132
|
+
]; };
|
|
1133
|
+
__decorate([
|
|
1134
|
+
ngBlockUi.BlockUI()
|
|
1135
|
+
], UtilityService.prototype, "blockUI", void 0);
|
|
982
1136
|
|
|
983
1137
|
var ControlValidationService = /** @class */ (function () {
|
|
984
1138
|
function ControlValidationService(utilityService) {
|
|
@@ -1165,98 +1319,20 @@
|
|
|
1165
1319
|
ngBlockUi.BlockUI()
|
|
1166
1320
|
], ControlValidationService.prototype, "blockUI", void 0);
|
|
1167
1321
|
|
|
1168
|
-
var MasterLayoutService = /** @class */ (function () {
|
|
1169
|
-
function MasterLayoutService(router, http, authService, stylesBundleService, translate) {
|
|
1170
|
-
this.router = router;
|
|
1171
|
-
this.http = http;
|
|
1172
|
-
this.authService = authService;
|
|
1173
|
-
this.stylesBundleService = stylesBundleService;
|
|
1174
|
-
this.translate = translate;
|
|
1175
|
-
this.ApiUrl = "/api/Home/";
|
|
1176
|
-
}
|
|
1177
|
-
MasterLayoutService.prototype.switchLang = function (lang, bundleEnglishName, bundleArabicName) {
|
|
1178
|
-
var _this = this;
|
|
1179
|
-
this.changeLanguage(lang).subscribe(function (result) {
|
|
1180
|
-
_this.updateUserInfo().subscribe(function (Value) {
|
|
1181
|
-
var UserInfoObject = Value;
|
|
1182
|
-
_this.authService.getUser();
|
|
1183
|
-
_this.authService.user.profile = Object.assign(_this.authService.user.profile, UserInfoObject);
|
|
1184
|
-
_this.authService.storUser(_this.authService.user);
|
|
1185
|
-
_this.stylesBundleService.loadThemes(lang, bundleEnglishName, bundleArabicName);
|
|
1186
|
-
localStorage.setItem('language', lang);
|
|
1187
|
-
_this.translate.use(lang);
|
|
1188
|
-
});
|
|
1189
|
-
});
|
|
1190
|
-
};
|
|
1191
|
-
MasterLayoutService.prototype.reloadComponent = function () {
|
|
1192
|
-
var currentUrl = this.router.url;
|
|
1193
|
-
this.router.routeReuseStrategy.shouldReuseRoute = function () { return false; };
|
|
1194
|
-
this.router.onSameUrlNavigation = 'reload';
|
|
1195
|
-
this.router.navigate([currentUrl]);
|
|
1196
|
-
};
|
|
1197
|
-
MasterLayoutService.prototype.changeLanguage = function (key) {
|
|
1198
|
-
var params = new i1$1.HttpParams();
|
|
1199
|
-
params = params.append("UserId", this.authService.user.profile.id);
|
|
1200
|
-
params = params.append("LanguageKey", key);
|
|
1201
|
-
return this.http.post(this.ApiUrl + 'UpdateLanguage', null, null, params);
|
|
1202
|
-
};
|
|
1203
|
-
MasterLayoutService.prototype.logError = function (error) {
|
|
1204
|
-
var params = new i1$1.HttpParams();
|
|
1205
|
-
params = params.append("error", error);
|
|
1206
|
-
return this.http.post(this.ApiUrl + 'LogError', null, null, params);
|
|
1207
|
-
};
|
|
1208
|
-
MasterLayoutService.prototype.updateUserInfo = function () {
|
|
1209
|
-
return this.http.get('/connect/userinfo');
|
|
1210
|
-
};
|
|
1211
|
-
MasterLayoutService.prototype.switchRole = function (permissionSetID) {
|
|
1212
|
-
var _this = this;
|
|
1213
|
-
this.updateRole(permissionSetID).subscribe(function (result) {
|
|
1214
|
-
_this.updateUserInfo().subscribe(function (Value) {
|
|
1215
|
-
var UserInfoObject = Value;
|
|
1216
|
-
_this.authService.getUser();
|
|
1217
|
-
_this.authService.user.profile = Object.assign(_this.authService.user.profile, UserInfoObject);
|
|
1218
|
-
_this.authService.storUser(_this.authService.user);
|
|
1219
|
-
});
|
|
1220
|
-
});
|
|
1221
|
-
};
|
|
1222
|
-
MasterLayoutService.prototype.updateRole = function (permissionSetID) {
|
|
1223
|
-
var params = new i1$1.HttpParams();
|
|
1224
|
-
params = params.append("UserId", this.authService.user.profile.id);
|
|
1225
|
-
params = params.append("RoleID", permissionSetID);
|
|
1226
|
-
return this.http.post(this.ApiUrl + 'SwitchRole', null, null, params);
|
|
1227
|
-
};
|
|
1228
|
-
return MasterLayoutService;
|
|
1229
|
-
}());
|
|
1230
|
-
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)); }, token: MasterLayoutService, providedIn: "root" });
|
|
1231
|
-
MasterLayoutService.decorators = [
|
|
1232
|
-
{ type: i0.Injectable, args: [{
|
|
1233
|
-
providedIn: 'root'
|
|
1234
|
-
},] }
|
|
1235
|
-
];
|
|
1236
|
-
MasterLayoutService.ctorParameters = function () { return [
|
|
1237
|
-
{ type: i4.Router },
|
|
1238
|
-
{ type: RequestHandlerService },
|
|
1239
|
-
{ type: AuthService },
|
|
1240
|
-
{ type: StylesBundleService },
|
|
1241
|
-
{ type: i1.TranslateService }
|
|
1242
|
-
]; };
|
|
1243
|
-
|
|
1244
1322
|
var ConfigurationService = /** @class */ (function () {
|
|
1245
1323
|
function ConfigurationService(httpClient) {
|
|
1246
|
-
var _this = this;
|
|
1247
1324
|
this.httpClient = httpClient;
|
|
1248
|
-
this.jsonData = [];
|
|
1249
1325
|
this.httpClient.get("./assets/config/configurations.json").subscribe(function (data) {
|
|
1250
|
-
|
|
1251
|
-
_this.jsonData = data;
|
|
1326
|
+
ConfigurationService.JsonData = data;
|
|
1252
1327
|
});
|
|
1253
1328
|
}
|
|
1254
1329
|
ConfigurationService.prototype.getConfigurationValue = function (key) {
|
|
1255
|
-
return
|
|
1330
|
+
return ConfigurationService.JsonData[key];
|
|
1256
1331
|
};
|
|
1257
1332
|
return ConfigurationService;
|
|
1258
1333
|
}());
|
|
1259
|
-
ConfigurationService
|
|
1334
|
+
ConfigurationService.JsonData = [];
|
|
1335
|
+
ConfigurationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ConfigurationService_Factory() { return new ConfigurationService(i0__namespace.ɵɵinject(i1__namespace$3.HttpClient)); }, token: ConfigurationService, providedIn: "root" });
|
|
1260
1336
|
ConfigurationService.decorators = [
|
|
1261
1337
|
{ type: i0.Injectable, args: [{
|
|
1262
1338
|
providedIn: 'root'
|
|
@@ -1278,10 +1354,10 @@
|
|
|
1278
1354
|
{ type: i0.NgModule, args: [{
|
|
1279
1355
|
declarations: [],
|
|
1280
1356
|
imports: [
|
|
1281
|
-
i1$
|
|
1357
|
+
i1$3.CommonModule,
|
|
1282
1358
|
ngBlockUi.BlockUIModule.forRoot(),
|
|
1283
1359
|
http.HttpModule,
|
|
1284
|
-
|
|
1360
|
+
i1$2.RouterModule,
|
|
1285
1361
|
ngxToastr.ToastrModule.forRoot(),
|
|
1286
1362
|
],
|
|
1287
1363
|
exports: [],
|