@bnsights/bbsf-utilities 1.0.27 → 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 +6 -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 +651 -577
- 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/environment.service.js +13 -1
- package/esm2015/lib/shared/services/masterlayout.service.js +27 -18
- package/esm2015/lib/shared/services/requesthandler.service.js +2 -2
- package/fesm2015/bnsights-bbsf-utilities.js +425 -357
- package/fesm2015/bnsights-bbsf-utilities.js.map +1 -1
- package/lib/shared/authentication/auth.service.d.ts +7 -3
- 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.27.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,581 +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 : "";
|
|
573
|
-
};
|
|
574
|
-
AuthService.prototype.name = function () {
|
|
575
|
-
return AuthService.user != null ? AuthService.user.profile.given_name : '';
|
|
576
|
-
};
|
|
577
|
-
AuthService.prototype.setUrl = function (url) {
|
|
578
|
-
localStorage.setItem("redirectUrl", url);
|
|
579
|
-
};
|
|
580
|
-
AuthService.prototype.getUrl = function () {
|
|
581
|
-
return localStorage.getItem("redirectUrl");
|
|
588
|
+
RequestHandlerService.prototype.ngOnDestroy = function () {
|
|
589
|
+
console.log("clearInterval");
|
|
590
|
+
this.destroyHandler();
|
|
582
591
|
};
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
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();
|
|
599
614
|
};
|
|
600
|
-
|
|
601
|
-
return
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
this.router.navigate(['/Admin/account/login']),
|
|
608
|
-
localStorage.clear();
|
|
609
|
-
return [4 /*yield*/, this.manager.signoutRedirect()];
|
|
610
|
-
case 2:
|
|
611
|
-
_a.sent();
|
|
612
|
-
return [2 /*return*/];
|
|
613
|
-
}
|
|
614
|
-
});
|
|
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'
|
|
615
622
|
});
|
|
616
623
|
};
|
|
617
|
-
return
|
|
624
|
+
return RequestHandlerService;
|
|
618
625
|
}());
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
AuthService.decorators = [
|
|
622
|
-
{ type: i0.Injectable, args: [{
|
|
623
|
-
providedIn: 'root'
|
|
624
|
-
},] }
|
|
626
|
+
RequestHandlerService.decorators = [
|
|
627
|
+
{ type: i0.Injectable }
|
|
625
628
|
];
|
|
626
|
-
|
|
629
|
+
RequestHandlerService.ctorParameters = function () { return [
|
|
627
630
|
{ type: i1$1.HttpClient },
|
|
631
|
+
{ type: AuthService },
|
|
628
632
|
{ type: EnvironmentService },
|
|
633
|
+
{ type: UtilityService },
|
|
629
634
|
{ type: BBSFTranslateService },
|
|
630
|
-
{ type:
|
|
635
|
+
{ type: i1$2.Router }
|
|
631
636
|
]; };
|
|
632
637
|
|
|
633
|
-
var
|
|
634
|
-
function
|
|
635
|
-
this.
|
|
636
|
-
this.
|
|
637
|
-
this.environmentService = environmentService;
|
|
638
|
-
this.isCreatedBefore = false;
|
|
638
|
+
var StylesBundleService = /** @class */ (function () {
|
|
639
|
+
function StylesBundleService(document, translateService) {
|
|
640
|
+
this.document = document;
|
|
641
|
+
this.translateService = translateService;
|
|
639
642
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
var currentLanguage = this.environmentService.getDefaultLanguage();
|
|
646
|
-
var lang = localStorage.getItem('language');
|
|
647
|
-
if (lang)
|
|
648
|
-
currentLanguage = lang;
|
|
649
|
-
else
|
|
650
|
-
localStorage.setItem('language', currentLanguage);
|
|
651
|
-
return currentLanguage;
|
|
652
|
-
};
|
|
653
|
-
UtilityService.prototype.isCurrentLanguageEnglish = function () {
|
|
654
|
-
return this.getCurrentLanguage() == "en";
|
|
655
|
-
};
|
|
656
|
-
UtilityService.prototype.isCurrentLanguageArabic = function () {
|
|
657
|
-
return this.getCurrentLanguage() == "ar";
|
|
658
|
-
};
|
|
659
|
-
UtilityService.prototype.notifySuccessMessage = function (Message, title, time, showHeader) {
|
|
660
|
-
if (showHeader === void 0) { showHeader = true; }
|
|
661
|
-
var MessageTemplate = this.getResourceValue("SuccessMessage");
|
|
662
|
-
var titleTemplate;
|
|
663
|
-
if (Message) {
|
|
664
|
-
MessageTemplate = Message;
|
|
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");
|
|
665
648
|
}
|
|
666
|
-
|
|
667
|
-
|
|
649
|
+
else {
|
|
650
|
+
this.loadStyleBundle(bundleEnglishName.toString());
|
|
651
|
+
document.querySelector('html').setAttribute("b-lang", "en");
|
|
652
|
+
document.querySelector('html').setAttribute("dir", "ltr");
|
|
668
653
|
}
|
|
669
|
-
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
670
|
-
showHeader ? toaster.success(MessageTemplate, titleTemplate) : toaster.success(MessageTemplate);
|
|
671
654
|
};
|
|
672
|
-
|
|
673
|
-
if (
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
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);
|
|
655
|
+
StylesBundleService.prototype.loadThemesColor = function (theme, bundleDarkName, bundleLightName) {
|
|
656
|
+
if (theme == "Light")
|
|
657
|
+
this.loadStyleBundle(bundleLightName.toString());
|
|
658
|
+
else
|
|
659
|
+
this.loadStyleBundle(bundleDarkName.toString());
|
|
684
660
|
};
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
var
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
MessageTemplate = Message;
|
|
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;
|
|
691
666
|
}
|
|
692
|
-
if (
|
|
693
|
-
|
|
667
|
+
else if (themeLink && !themeLink.href.includes(styleName)) {
|
|
668
|
+
themeLink.remove();
|
|
694
669
|
}
|
|
695
|
-
var
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
};
|
|
701
|
-
UtilityService.prototype.stopBlockUI = function () {
|
|
702
|
-
this.blockUI.stop();
|
|
670
|
+
var style = this.document.createElement('link');
|
|
671
|
+
style.id = 'client-theme';
|
|
672
|
+
style.rel = 'stylesheet';
|
|
673
|
+
style.href = "" + styleName;
|
|
674
|
+
head.appendChild(style);
|
|
703
675
|
};
|
|
704
|
-
return
|
|
676
|
+
return StylesBundleService;
|
|
705
677
|
}());
|
|
706
|
-
|
|
707
|
-
|
|
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 = [
|
|
708
680
|
{ type: i0.Injectable, args: [{
|
|
709
681
|
providedIn: 'root'
|
|
710
682
|
},] }
|
|
711
683
|
];
|
|
712
|
-
|
|
713
|
-
{ type:
|
|
714
|
-
{ type:
|
|
715
|
-
|
|
716
|
-
]; };
|
|
717
|
-
__decorate([
|
|
718
|
-
ngBlockUi.BlockUI()
|
|
719
|
-
], UtilityService.prototype, "blockUI", void 0);
|
|
720
|
-
|
|
721
|
-
var RequestOptionsModel = /** @class */ (function () {
|
|
722
|
-
function RequestOptionsModel() {
|
|
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
|
-
}());
|
|
684
|
+
StylesBundleService.ctorParameters = function () { return [
|
|
685
|
+
{ type: Document, decorators: [{ type: i0.Inject, args: [i1$3.DOCUMENT,] }] },
|
|
686
|
+
{ type: BBSFTranslateService }
|
|
687
|
+
]; };
|
|
732
688
|
|
|
733
|
-
var
|
|
734
|
-
function
|
|
735
|
-
|
|
736
|
-
//using localStorage to avoid call getCurrentLanguage() because it is not all to use async in constructor
|
|
689
|
+
var MasterLayoutService = /** @class */ (function () {
|
|
690
|
+
function MasterLayoutService(router, http, authService, stylesBundleService, translate, environmentService) {
|
|
691
|
+
this.router = router;
|
|
737
692
|
this.http = http;
|
|
738
693
|
this.authService = authService;
|
|
694
|
+
this.stylesBundleService = stylesBundleService;
|
|
695
|
+
this.translate = translate;
|
|
739
696
|
this.environmentService = environmentService;
|
|
740
|
-
this.
|
|
741
|
-
this.bbsfTranslateService = bbsfTranslateService;
|
|
742
|
-
this.router = router;
|
|
743
|
-
this.requestOptions = new RequestOptionsModel();
|
|
744
|
-
this.currentLanguage = "";
|
|
745
|
-
this.onDestroy$ = new rxjs.Subject();
|
|
746
|
-
this.bbsfTranslateService.onLangChange.subscribe(function (event) {
|
|
747
|
-
if (_this.currentLanguage != event.lang) {
|
|
748
|
-
_this.currentLanguage = event.lang;
|
|
749
|
-
}
|
|
750
|
-
});
|
|
697
|
+
this.ApiUrl = '/api/Home/';
|
|
751
698
|
}
|
|
752
|
-
|
|
753
|
-
return rxjs.Observable.create(function (subject) {
|
|
754
|
-
setInterval(function () {
|
|
755
|
-
var number = Math.floor(Math.random() * 10);
|
|
756
|
-
console.log(number);
|
|
757
|
-
subject.next(number);
|
|
758
|
-
}, 1000);
|
|
759
|
-
}).pipe(operators.takeUntil(this.onDestroy$));
|
|
760
|
-
};
|
|
761
|
-
RequestHandlerService.prototype.get = function (Url, params, responseType, requestOptions) {
|
|
699
|
+
MasterLayoutService.prototype.switchLang = function (lang, bundleEnglishName, bundleArabicName) {
|
|
762
700
|
var _this = this;
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
_this.
|
|
772
|
-
|
|
773
|
-
|
|
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
|
-
}));
|
|
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
|
+
});
|
|
781
712
|
};
|
|
782
|
-
|
|
783
|
-
var
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
if (!this.requestOptions.disableBlockUI)
|
|
788
|
-
this.utilityService.startBlockUI();
|
|
789
|
-
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) {
|
|
790
|
-
if (!_this.requestOptions.disableBlockUI)
|
|
791
|
-
_this.utilityService.stopBlockUI();
|
|
792
|
-
}, function (error) {
|
|
793
|
-
if (!_this.requestOptions.disableErrorHandler)
|
|
794
|
-
_this.handleError(error);
|
|
795
|
-
}), operators.map(function (data) {
|
|
796
|
-
if (_this.requestOptions.castResponsetoClass)
|
|
797
|
-
return classTransformer.plainToClass(responseType, data, { excludeExtraneousValues: true });
|
|
798
|
-
else
|
|
799
|
-
return data;
|
|
800
|
-
}));
|
|
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]);
|
|
801
718
|
};
|
|
802
|
-
|
|
803
|
-
var
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
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
|
-
}));
|
|
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);
|
|
821
724
|
};
|
|
822
|
-
|
|
725
|
+
MasterLayoutService.prototype.getUserClaims = function () {
|
|
726
|
+
return this.http.get(this.ApiUrl + 'GetUserClaims', null, null);
|
|
727
|
+
};
|
|
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);
|
|
732
|
+
};
|
|
733
|
+
MasterLayoutService.prototype.updateUserInfo = function () {
|
|
734
|
+
if (this.environmentService.getIsIdentityServerExternal())
|
|
735
|
+
return this.getUserClaims();
|
|
736
|
+
return this.http.get('/connect/userinfo');
|
|
737
|
+
};
|
|
738
|
+
MasterLayoutService.prototype.switchRole = function (permissionSetID) {
|
|
823
739
|
var _this = this;
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
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
|
-
}));
|
|
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
|
+
});
|
|
841
748
|
};
|
|
842
|
-
|
|
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);
|
|
754
|
+
};
|
|
755
|
+
return MasterLayoutService;
|
|
756
|
+
}());
|
|
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 = [
|
|
759
|
+
{ type: i0.Injectable, args: [{
|
|
760
|
+
providedIn: 'root',
|
|
761
|
+
},] }
|
|
762
|
+
];
|
|
763
|
+
MasterLayoutService.ctorParameters = function () { return [
|
|
764
|
+
{ type: i1$2.Router },
|
|
765
|
+
{ type: RequestHandlerService },
|
|
766
|
+
{ type: AuthService },
|
|
767
|
+
{ type: StylesBundleService },
|
|
768
|
+
{ type: i1.TranslateService },
|
|
769
|
+
{ type: EnvironmentService }
|
|
770
|
+
]; };
|
|
771
|
+
|
|
772
|
+
var AuthService = /** @class */ (function () {
|
|
773
|
+
function AuthService(injector, http, environmentService, translateService, router) {
|
|
843
774
|
var _this = this;
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
775
|
+
this.injector = injector;
|
|
776
|
+
this.http = http;
|
|
777
|
+
this.environmentService = environmentService;
|
|
778
|
+
this.translateService = translateService;
|
|
779
|
+
this.router = router;
|
|
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);
|
|
849
807
|
});
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
808
|
+
}
|
|
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;
|
|
867
846
|
};
|
|
868
|
-
|
|
847
|
+
AuthService.prototype.login = function () {
|
|
848
|
+
return this.manager.signinRedirect();
|
|
849
|
+
};
|
|
850
|
+
AuthService.prototype.getUser = function () {
|
|
869
851
|
var _this = this;
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
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
|
+
}); });
|
|
867
|
+
};
|
|
868
|
+
AuthService.prototype.storUser = function (User) {
|
|
869
|
+
this.manager.storeUser(User);
|
|
870
|
+
};
|
|
871
|
+
AuthService.prototype.revokeAccessToken = function () {
|
|
872
|
+
this.manager.revokeAccessToken();
|
|
873
|
+
};
|
|
874
|
+
AuthService.prototype.signinSilent = function () {
|
|
875
|
+
var x = this.manager.signinSilentCallback();
|
|
876
|
+
x.then(function (s) {
|
|
877
|
+
//console.log(s)
|
|
878
|
+
});
|
|
879
|
+
};
|
|
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
|
+
});
|
|
979
|
+
};
|
|
980
|
+
AuthService.prototype.isUserInRole = function (allowedPermission) {
|
|
981
|
+
var selectedPermissionSetID = Number.parseInt(this.user.profile['selectedpermissionsetid']);
|
|
982
|
+
return allowedPermission.includes(selectedPermissionSetID);
|
|
882
983
|
};
|
|
883
|
-
|
|
884
|
-
|
|
984
|
+
AuthService.prototype.authorizationHeaderValue = function () {
|
|
985
|
+
return AuthService.user
|
|
986
|
+
? AuthService.user.token_type + " " + AuthService.user.access_token
|
|
987
|
+
: '';
|
|
885
988
|
};
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
this.destroyHandler();
|
|
989
|
+
AuthService.prototype.name = function () {
|
|
990
|
+
return AuthService.user != null ? AuthService.user.profile.given_name : '';
|
|
889
991
|
};
|
|
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 if (err.status == 515)
|
|
905
|
-
this.utilityService.notifyErrorMessage((err.error ? err.error.Message : err.message));
|
|
906
|
-
else {
|
|
907
|
-
console.log("error message is: " + (err.error ? err.error.Message : err.message));
|
|
908
|
-
this.utilityService.notifyErrorMessage(this.utilityService.getResourceValue("ErrorMassage"));
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
this.utilityService.stopBlockUI();
|
|
992
|
+
AuthService.prototype.setUrl = function (url) {
|
|
993
|
+
localStorage.setItem('redirectUrl', url);
|
|
912
994
|
};
|
|
913
|
-
|
|
914
|
-
return
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
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
|
+
});
|
|
920
1013
|
});
|
|
921
1014
|
};
|
|
922
|
-
|
|
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;
|
|
923
1032
|
}());
|
|
924
|
-
|
|
925
|
-
|
|
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
|
+
},] }
|
|
926
1040
|
];
|
|
927
|
-
|
|
1041
|
+
AuthService.ctorParameters = function () { return [
|
|
1042
|
+
{ type: i0.Injector },
|
|
928
1043
|
{ type: i1$1.HttpClient },
|
|
929
|
-
{ type: AuthService },
|
|
930
1044
|
{ type: EnvironmentService },
|
|
931
|
-
{ type: UtilityService },
|
|
932
1045
|
{ type: BBSFTranslateService },
|
|
933
|
-
{ type:
|
|
1046
|
+
{ type: i1$2.Router }
|
|
934
1047
|
]; };
|
|
935
1048
|
|
|
936
|
-
var
|
|
937
|
-
function
|
|
938
|
-
this.
|
|
939
|
-
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;
|
|
940
1055
|
}
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
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;
|
|
946
1081
|
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
document.querySelector('html').setAttribute("b-lang", "en");
|
|
950
|
-
document.querySelector('html').setAttribute("dir", "ltr");
|
|
1082
|
+
if (title) {
|
|
1083
|
+
titleTemplate = title;
|
|
951
1084
|
}
|
|
1085
|
+
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
1086
|
+
showHeader ? toaster.success(MessageTemplate, titleTemplate) : toaster.success(MessageTemplate);
|
|
952
1087
|
};
|
|
953
|
-
|
|
954
|
-
if (
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
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);
|
|
958
1100
|
};
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
var
|
|
962
|
-
|
|
963
|
-
|
|
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;
|
|
964
1107
|
}
|
|
965
|
-
|
|
966
|
-
|
|
1108
|
+
if (title) {
|
|
1109
|
+
titleTemplate = title;
|
|
967
1110
|
}
|
|
968
|
-
var
|
|
969
|
-
|
|
970
|
-
style.rel = 'stylesheet';
|
|
971
|
-
style.href = "" + styleName;
|
|
972
|
-
head.appendChild(style);
|
|
1111
|
+
var toaster = exports.AppInjector.get(ngxToastr.ToastrService);
|
|
1112
|
+
showHeader ? toaster.warning(MessageTemplate, titleTemplate) : toaster.warning(MessageTemplate);
|
|
973
1113
|
};
|
|
974
|
-
|
|
1114
|
+
UtilityService.prototype.startBlockUI = function () {
|
|
1115
|
+
this.blockUI.start();
|
|
1116
|
+
};
|
|
1117
|
+
UtilityService.prototype.stopBlockUI = function () {
|
|
1118
|
+
this.blockUI.stop();
|
|
1119
|
+
};
|
|
1120
|
+
return UtilityService;
|
|
975
1121
|
}());
|
|
976
|
-
|
|
977
|
-
|
|
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 = [
|
|
978
1124
|
{ type: i0.Injectable, args: [{
|
|
979
1125
|
providedIn: 'root'
|
|
980
1126
|
},] }
|
|
981
1127
|
];
|
|
982
|
-
|
|
983
|
-
{ type:
|
|
984
|
-
{ type:
|
|
985
|
-
|
|
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);
|
|
986
1136
|
|
|
987
1137
|
var ControlValidationService = /** @class */ (function () {
|
|
988
1138
|
function ControlValidationService(utilityService) {
|
|
@@ -1169,82 +1319,6 @@
|
|
|
1169
1319
|
ngBlockUi.BlockUI()
|
|
1170
1320
|
], ControlValidationService.prototype, "blockUI", void 0);
|
|
1171
1321
|
|
|
1172
|
-
var MasterLayoutService = /** @class */ (function () {
|
|
1173
|
-
function MasterLayoutService(router, http, authService, stylesBundleService, translate) {
|
|
1174
|
-
this.router = router;
|
|
1175
|
-
this.http = http;
|
|
1176
|
-
this.authService = authService;
|
|
1177
|
-
this.stylesBundleService = stylesBundleService;
|
|
1178
|
-
this.translate = translate;
|
|
1179
|
-
this.ApiUrl = "/api/Home/";
|
|
1180
|
-
}
|
|
1181
|
-
MasterLayoutService.prototype.switchLang = function (lang, bundleEnglishName, bundleArabicName) {
|
|
1182
|
-
var _this = this;
|
|
1183
|
-
this.changeLanguage(lang).subscribe(function (result) {
|
|
1184
|
-
_this.updateUserInfo().subscribe(function (Value) {
|
|
1185
|
-
var UserInfoObject = Value;
|
|
1186
|
-
_this.authService.getUser();
|
|
1187
|
-
_this.authService.user.profile = Object.assign(_this.authService.user.profile, UserInfoObject);
|
|
1188
|
-
_this.authService.storUser(_this.authService.user);
|
|
1189
|
-
_this.stylesBundleService.loadThemes(lang, bundleEnglishName, bundleArabicName);
|
|
1190
|
-
localStorage.setItem('language', lang);
|
|
1191
|
-
_this.translate.use(lang);
|
|
1192
|
-
});
|
|
1193
|
-
});
|
|
1194
|
-
};
|
|
1195
|
-
MasterLayoutService.prototype.reloadComponent = function () {
|
|
1196
|
-
var currentUrl = this.router.url;
|
|
1197
|
-
this.router.routeReuseStrategy.shouldReuseRoute = function () { return false; };
|
|
1198
|
-
this.router.onSameUrlNavigation = 'reload';
|
|
1199
|
-
this.router.navigate([currentUrl]);
|
|
1200
|
-
};
|
|
1201
|
-
MasterLayoutService.prototype.changeLanguage = function (key) {
|
|
1202
|
-
var params = new i1$1.HttpParams();
|
|
1203
|
-
params = params.append("UserId", this.authService.user.profile.id);
|
|
1204
|
-
params = params.append("LanguageKey", key);
|
|
1205
|
-
return this.http.post(this.ApiUrl + 'UpdateLanguage', null, null, params);
|
|
1206
|
-
};
|
|
1207
|
-
MasterLayoutService.prototype.logError = function (error) {
|
|
1208
|
-
var params = new i1$1.HttpParams();
|
|
1209
|
-
params = params.append("error", error);
|
|
1210
|
-
return this.http.post(this.ApiUrl + 'LogError', null, null, params);
|
|
1211
|
-
};
|
|
1212
|
-
MasterLayoutService.prototype.updateUserInfo = function () {
|
|
1213
|
-
return this.http.get('/connect/userinfo');
|
|
1214
|
-
};
|
|
1215
|
-
MasterLayoutService.prototype.switchRole = function (permissionSetID) {
|
|
1216
|
-
var _this = this;
|
|
1217
|
-
this.updateRole(permissionSetID).subscribe(function (result) {
|
|
1218
|
-
_this.updateUserInfo().subscribe(function (Value) {
|
|
1219
|
-
var UserInfoObject = Value;
|
|
1220
|
-
_this.authService.getUser();
|
|
1221
|
-
_this.authService.user.profile = Object.assign(_this.authService.user.profile, UserInfoObject);
|
|
1222
|
-
_this.authService.storUser(_this.authService.user);
|
|
1223
|
-
});
|
|
1224
|
-
});
|
|
1225
|
-
};
|
|
1226
|
-
MasterLayoutService.prototype.updateRole = function (permissionSetID) {
|
|
1227
|
-
var params = new i1$1.HttpParams();
|
|
1228
|
-
params = params.append("UserId", this.authService.user.profile.id);
|
|
1229
|
-
params = params.append("RoleID", permissionSetID);
|
|
1230
|
-
return this.http.post(this.ApiUrl + 'SwitchRole', null, null, params);
|
|
1231
|
-
};
|
|
1232
|
-
return MasterLayoutService;
|
|
1233
|
-
}());
|
|
1234
|
-
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" });
|
|
1235
|
-
MasterLayoutService.decorators = [
|
|
1236
|
-
{ type: i0.Injectable, args: [{
|
|
1237
|
-
providedIn: 'root'
|
|
1238
|
-
},] }
|
|
1239
|
-
];
|
|
1240
|
-
MasterLayoutService.ctorParameters = function () { return [
|
|
1241
|
-
{ type: i4.Router },
|
|
1242
|
-
{ type: RequestHandlerService },
|
|
1243
|
-
{ type: AuthService },
|
|
1244
|
-
{ type: StylesBundleService },
|
|
1245
|
-
{ type: i1.TranslateService }
|
|
1246
|
-
]; };
|
|
1247
|
-
|
|
1248
1322
|
var ConfigurationService = /** @class */ (function () {
|
|
1249
1323
|
function ConfigurationService(httpClient) {
|
|
1250
1324
|
this.httpClient = httpClient;
|
|
@@ -1258,7 +1332,7 @@
|
|
|
1258
1332
|
return ConfigurationService;
|
|
1259
1333
|
}());
|
|
1260
1334
|
ConfigurationService.JsonData = [];
|
|
1261
|
-
ConfigurationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ConfigurationService_Factory() { return new ConfigurationService(i0__namespace.ɵɵinject(i1__namespace$
|
|
1335
|
+
ConfigurationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ConfigurationService_Factory() { return new ConfigurationService(i0__namespace.ɵɵinject(i1__namespace$3.HttpClient)); }, token: ConfigurationService, providedIn: "root" });
|
|
1262
1336
|
ConfigurationService.decorators = [
|
|
1263
1337
|
{ type: i0.Injectable, args: [{
|
|
1264
1338
|
providedIn: 'root'
|
|
@@ -1280,10 +1354,10 @@
|
|
|
1280
1354
|
{ type: i0.NgModule, args: [{
|
|
1281
1355
|
declarations: [],
|
|
1282
1356
|
imports: [
|
|
1283
|
-
i1$
|
|
1357
|
+
i1$3.CommonModule,
|
|
1284
1358
|
ngBlockUi.BlockUIModule.forRoot(),
|
|
1285
1359
|
http.HttpModule,
|
|
1286
|
-
|
|
1360
|
+
i1$2.RouterModule,
|
|
1287
1361
|
ngxToastr.ToastrModule.forRoot(),
|
|
1288
1362
|
],
|
|
1289
1363
|
exports: [],
|