@bnsights/bbsf-utilities 1.0.2 → 1.0.6

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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
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')) :
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'], factory) :
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));
5
- })(this, (function (exports, i1$2, i0, i1$3, i1, ngBlockUi, ngxToastr, http, i1$1, oidcClient, rxjs, operators) { 'use strict';
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/internal/Observable'), require('rxjs/operators')) :
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/internal/Observable', 'rxjs/operators'], factory) :
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["internal/Observable"], global.rxjs.operators));
5
+ })(this, (function (exports, i1$2, i0, i1$3, i1, ngBlockUi, ngxToastr, http, i1$1, oidcClient, rxjs, Observable, operators) { 'use strict';
6
6
 
7
7
  function _interopNamespace(e) {
8
8
  if (e && e.__esModule) return e;
@@ -546,9 +546,9 @@
546
546
  AuthService.prototype.getCurrentUser = function () {
547
547
  return this.manager.getUser();
548
548
  };
549
- AuthService.prototype.isAuthenticated = function (allowedPermission) {
549
+ AuthService.prototype.isAuthenticated = function () {
550
550
  return __awaiter(this, void 0, void 0, function () {
551
- var user, isUserInRole;
551
+ var user;
552
552
  return __generator(this, function (_a) {
553
553
  switch (_a.label) {
554
554
  case 0: return [4 /*yield*/, this.manager.getUser().then(function (user) {
@@ -556,29 +556,17 @@
556
556
  })];
557
557
  case 1:
558
558
  user = _a.sent();
559
- if (allowedPermission != null && allowedPermission != undefined) {
560
- if (allowedPermission.length == 0) {
561
- return [2 /*return*/, this.user != null && !this.user.expired];
562
- }
563
- else {
564
- isUserInRole = this.isUserInRole(allowedPermission);
565
- return [2 /*return*/, this.user != null && !this.user.expired && isUserInRole];
566
- }
567
- }
568
- else
569
- return [2 /*return*/, this.user != null && !this.user.expired];
570
- return [2 /*return*/];
559
+ return [2 /*return*/, this.user != null && !this.user.expired];
571
560
  }
572
561
  });
573
562
  });
574
563
  };
575
564
  AuthService.prototype.isUserInRole = function (allowedPermission) {
576
- ;
577
- var permissionSetSID = this.user.profile["permissionSetSID"].split(templateObject_1 || (templateObject_1 = __makeTemplateObject([","], [","]))).map(function (x) { return +x; });
578
- return allowedPermission.every(function (i) { return permissionSetSID.includes(i); });
565
+ var selectedPermissionSetID = this.user.profile["selectedPermissionSetID"];
566
+ return allowedPermission.includes(selectedPermissionSetID);
579
567
  };
580
568
  AuthService.prototype.authorizationHeaderValue = function () {
581
- return AuthService.user.token_type + " " + AuthService.user.access_token;
569
+ return AuthService.user ? AuthService.user.token_type + " " + AuthService.user.access_token : "";
582
570
  };
583
571
  AuthService.prototype.name = function () {
584
572
  return AuthService.user != null ? AuthService.user.profile.given_name : '';
@@ -633,8 +621,7 @@
633
621
  { type: i1$1.HttpClient },
634
622
  { type: EnvironmentService },
635
623
  { type: BBSFTranslateService }
636
- ]; };
637
- var templateObject_1;
624
+ ]; };
638
625
 
639
626
  var UtilityService = /** @class */ (function () {
640
627
  function UtilityService(translator, authService, environmentService) {
@@ -657,10 +644,10 @@
657
644
  return currentLanguage;
658
645
  };
659
646
  UtilityService.prototype.isCurrentLanguageEnglish = function () {
660
- this.getCurrentLanguage() == "en";
647
+ return this.getCurrentLanguage() == "en";
661
648
  };
662
649
  UtilityService.prototype.isCurrentLanguageArabic = function () {
663
- this.getCurrentLanguage() == "ar";
650
+ return this.getCurrentLanguage() == "ar";
664
651
  };
665
652
  UtilityService.prototype.notifySuccessMessage = function (Message, title, time) {
666
653
  var MessageTemplate = this.getResourceValue("SuccessMessage");
@@ -731,13 +718,182 @@
731
718
  return RequestOptionsModel;
732
719
  }());
733
720
 
721
+ var RequestHandlerService = /** @class */ (function () {
722
+ function RequestHandlerService(http, authService, environmentService, utilityService, bbsfTranslateService) {
723
+ var _this = this;
724
+ //using localStorage to avoid call getCurrentLanguage() because it is not all to use async in constructor
725
+ this.http = http;
726
+ this.authService = authService;
727
+ this.environmentService = environmentService;
728
+ this.utilityService = utilityService;
729
+ this.bbsfTranslateService = bbsfTranslateService;
730
+ this.requestOptions = new RequestOptionsModel();
731
+ this.currentLanguage = "";
732
+ this.onDestroy$ = new rxjs.Subject();
733
+ this.bbsfTranslateService.onLangChange.subscribe(function (event) {
734
+ if (_this.currentLanguage != event.lang) {
735
+ _this.currentLanguage = event.lang;
736
+ }
737
+ });
738
+ }
739
+ RequestHandlerService.prototype.getLuckyNumber = function () {
740
+ return Observable.Observable.create(function (subject) {
741
+ setInterval(function () {
742
+ var number = Math.floor(Math.random() * 10);
743
+ console.log(number);
744
+ subject.next(number);
745
+ }, 1000);
746
+ }).pipe(operators.takeUntil(this.onDestroy$));
747
+ };
748
+ RequestHandlerService.prototype.get = function (Url, params, requestOptions) {
749
+ var _this = this;
750
+ if (requestOptions)
751
+ this.requestOptions = requestOptions;
752
+ var headers = new i1$1.HttpHeaders({
753
+ 'Content-Type': 'application/json',
754
+ 'Authorization': this.authService.authorizationHeaderValue(),
755
+ });
756
+ this.currentLanguage = localStorage.getItem('language');
757
+ headers = headers.set('Accept-Language', this.currentLanguage.toString());
758
+ headers = headers.set('ignore-cookies', 'true');
759
+ if (!this.requestOptions.disableBlockUI)
760
+ this.utilityService.startBlockUI();
761
+ var object;
762
+ return this.http.get(this.environmentService.getApiUrl() + Url, { headers: headers, params: params }).pipe(operators.takeUntil(this.onDestroy$), operators.tap(function (result) {
763
+ if (!_this.requestOptions.disableBlockUI)
764
+ _this.utilityService.stopBlockUI();
765
+ }), operators.map(function (data) {
766
+ var result = data;
767
+ return result;
768
+ }));
769
+ };
770
+ RequestHandlerService.prototype.post = function (Url, model, params, requestOptions) {
771
+ var _this = this;
772
+ if (requestOptions)
773
+ this.requestOptions = requestOptions;
774
+ var headers = new i1$1.HttpHeaders({
775
+ 'Content-Type': 'application/json',
776
+ 'Authorization': this.authService.authorizationHeaderValue(),
777
+ });
778
+ this.currentLanguage = localStorage.getItem('language');
779
+ headers = headers.set('Accept-Language', this.currentLanguage.toString());
780
+ headers = headers.set('ignore-cookies', 'true');
781
+ if (!this.requestOptions.disableBlockUI)
782
+ this.utilityService.startBlockUI();
783
+ 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) {
784
+ if (!_this.requestOptions.disableBlockUI)
785
+ _this.utilityService.stopBlockUI();
786
+ }));
787
+ };
788
+ RequestHandlerService.prototype.delete = function (Url, deletedId, params, requestOptions) {
789
+ var _this = this;
790
+ if (requestOptions)
791
+ this.requestOptions = requestOptions;
792
+ var headers = new i1$1.HttpHeaders({
793
+ 'Content-Type': 'application/json',
794
+ 'Authorization': this.authService.authorizationHeaderValue(),
795
+ });
796
+ this.currentLanguage = localStorage.getItem('language');
797
+ headers = headers.set('Accept-Language', this.currentLanguage.toString());
798
+ headers = headers.set('ignore-cookies', 'true');
799
+ if (!this.requestOptions.disableBlockUI)
800
+ this.utilityService.startBlockUI();
801
+ return this.http.delete(this.environmentService.getApiUrl() + Url + ("/" + deletedId), { headers: headers, params: params }).pipe(operators.takeUntil(this.onDestroy$), operators.tap(function (result) {
802
+ if (!_this.requestOptions.disableBlockUI)
803
+ _this.utilityService.stopBlockUI();
804
+ }));
805
+ };
806
+ RequestHandlerService.prototype.put = function (Url, model, params, requestOptions) {
807
+ var _this = this;
808
+ if (requestOptions)
809
+ this.requestOptions = requestOptions;
810
+ var headers = new i1$1.HttpHeaders({
811
+ 'Content-Type': 'application/json',
812
+ 'Authorization': this.authService.authorizationHeaderValue(),
813
+ });
814
+ this.currentLanguage = localStorage.getItem('language');
815
+ headers = headers.set('Accept-Language', this.currentLanguage.toString());
816
+ headers = headers.set('ignore-cookies', 'true');
817
+ if (!this.requestOptions.disableBlockUI)
818
+ this.utilityService.startBlockUI();
819
+ 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) {
820
+ if (!_this.requestOptions.disableBlockUI)
821
+ _this.utilityService.stopBlockUI();
822
+ }));
823
+ };
824
+ RequestHandlerService.prototype.destroyHandler = function () {
825
+ this.onDestroy$.next();
826
+ };
827
+ RequestHandlerService.prototype.ngOnDestroy = function () {
828
+ console.log("clearInterval");
829
+ this.destroyHandler();
830
+ };
831
+ return RequestHandlerService;
832
+ }());
833
+ RequestHandlerService.decorators = [
834
+ { type: i0.Injectable }
835
+ ];
836
+ RequestHandlerService.ctorParameters = function () { return [
837
+ { type: i1$1.HttpClient },
838
+ { type: AuthService },
839
+ { type: EnvironmentService },
840
+ { type: UtilityService },
841
+ { type: BBSFTranslateService }
842
+ ]; };
843
+
844
+ var StylesBundleService = /** @class */ (function () {
845
+ function StylesBundleService(document, translateService) {
846
+ this.document = document;
847
+ this.translateService = translateService;
848
+ }
849
+ StylesBundleService.prototype.loadThemes = function (lang, bundleEnglishName, bundleArabicName) {
850
+ if (lang == "ar") {
851
+ this.loadStyleBundle(bundleArabicName.toString());
852
+ document.querySelector('html').setAttribute("lang", "ar");
853
+ document.querySelector('html').setAttribute("dir", "rtl");
854
+ }
855
+ else {
856
+ this.loadStyleBundle(bundleEnglishName.toString());
857
+ document.querySelector('html').setAttribute("lang", "en");
858
+ document.querySelector('html').setAttribute("dir", "ltr");
859
+ }
860
+ };
861
+ StylesBundleService.prototype.loadStyleBundle = function (styleName) {
862
+ var head = this.document.getElementsByTagName('head')[0];
863
+ var themeLink = this.document.getElementById('client-theme');
864
+ if (themeLink && themeLink.href.includes(styleName)) {
865
+ return;
866
+ }
867
+ else if (themeLink && !themeLink.href.includes(styleName)) {
868
+ themeLink.remove();
869
+ }
870
+ var style = this.document.createElement('link');
871
+ style.id = 'client-theme';
872
+ style.rel = 'stylesheet';
873
+ style.href = "" + styleName;
874
+ head.appendChild(style);
875
+ };
876
+ return StylesBundleService;
877
+ }());
878
+ StylesBundleService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function StylesBundleService_Factory() { return new StylesBundleService(i0__namespace.ɵɵinject(i1__namespace$2.DOCUMENT), i0__namespace.ɵɵinject(BBSFTranslateService)); }, token: StylesBundleService, providedIn: "root" });
879
+ StylesBundleService.decorators = [
880
+ { type: i0.Injectable, args: [{
881
+ providedIn: 'root'
882
+ },] }
883
+ ];
884
+ StylesBundleService.ctorParameters = function () { return [
885
+ { type: Document, decorators: [{ type: i0.Inject, args: [i1$2.DOCUMENT,] }] },
886
+ { type: BBSFTranslateService }
887
+ ]; };
888
+
734
889
  var ControlValidationService = /** @class */ (function () {
735
890
  function ControlValidationService(utilityService) {
736
891
  this.utilityService = utilityService;
737
892
  this.requestOptions = new RequestOptionsModel();
738
893
  this.isCreatedBefor = false;
739
894
  }
740
- ControlValidationService.prototype.showGlobalError = function (errorMessage) {
895
+ ControlValidationService.prototype.showGlobalError = function (errorMessage, formId, deleteOld) {
896
+ var e_1, _a;
741
897
  var globalErorrElement = document.getElementsByClassName('alert alert-danger alert-InvalidValidation');
742
898
  if (globalErorrElement.length > 0) {
743
899
  this.removeElementsByClass('alert alert-danger alert-InvalidValidation');
@@ -746,28 +902,50 @@
746
902
  this.removeElementsByClass('alert alert-danger alert-InvalidValidation');
747
903
  }
748
904
  // tslint:disable-next-line: prefer-const
749
- var objects = document.querySelectorAll('form.ng-invalid.ng-touched');
905
+ if (!formId)
906
+ formId = "currentForm";
907
+ var object = document.getElementById(formId);
750
908
  var tagName = 'div';
751
909
  // tslint:disable-next-line: prefer-const
752
910
  var elementToAppend = document.createElement(tagName); // Your tag name here
753
911
  var message = "";
754
- if (localStorage.getItem('language') == "ar")
755
- message = errorMessage ? errorMessage : "لديك بعص الأخطاء . من فضلك قم بالمراجعه ";
756
- else
757
- message = errorMessage ? errorMessage : "You have some validation errors. Please check below";
758
- elementToAppend.innerHTML = "<ul><li>" + message + "</li></ul>";
759
- elementToAppend.className += 'alert alert-danger alert-InvalidValidation';
760
- elementToAppend.id += 'errorId';
761
- // tslint:disable-next-line: prefer-for-of
762
- for (var i = 0; i < objects.length; i++) {
763
- // const elementToAppen = elementToAppend.cloneNode(true);
764
- // objects[i].insertBefore(elementToAppen, objects[i].firstChild);
912
+ if (!errorMessage || (typeof errorMessage == "string")) {
913
+ if (localStorage.getItem('language') == "ar")
914
+ message = errorMessage ? errorMessage : "لديك بعص الأخطاء . من فضلك قم بالمراجعه ";
915
+ else
916
+ message = errorMessage ? errorMessage : "You have some validation errors. Please check below";
917
+ elementToAppend.innerHTML = "<ul><li>" + message + "</li></ul>";
918
+ elementToAppend.className += 'alert alert-danger alert-InvalidValidation';
919
+ elementToAppend.id += 'errorId';
920
+ // tslint:disable-next-line: prefer-for-of
765
921
  var elementToAppen = elementToAppend.cloneNode(true);
766
- var targetElement = objects[i].getElementsByClassName("b-control")[0];
767
- targetElement.parentNode.insertBefore(elementToAppen, targetElement);
768
- this.isCreatedBefor = true;
769
- break;
922
+ // let targetElement = object.getElementsByClassName("b-control")[0];
923
+ object.insertBefore(elementToAppen, object.firstChild);
770
924
  }
925
+ else {
926
+ elementToAppend.innerHTML = "<ul>";
927
+ try {
928
+ for (var errorMessage_1 = __values(errorMessage), errorMessage_1_1 = errorMessage_1.next(); !errorMessage_1_1.done; errorMessage_1_1 = errorMessage_1.next()) {
929
+ var iterator = errorMessage_1_1.value;
930
+ elementToAppend.innerHTML = "<li>" + iterator + "</li>";
931
+ }
932
+ }
933
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
934
+ finally {
935
+ try {
936
+ if (errorMessage_1_1 && !errorMessage_1_1.done && (_a = errorMessage_1.return)) _a.call(errorMessage_1);
937
+ }
938
+ finally { if (e_1) throw e_1.error; }
939
+ }
940
+ elementToAppend.innerHTML = "</ul>";
941
+ elementToAppend.className += 'alert alert-danger alert-InvalidValidation';
942
+ elementToAppend.id += 'errorId';
943
+ // tslint:disable-next-line: prefer-for-of
944
+ var elementToAppen = elementToAppend.cloneNode(true);
945
+ // let targetElement = object.getElementsByClassName("b-control")[0];
946
+ object.insertBefore(elementToAppen, object.firstChild);
947
+ }
948
+ this.isCreatedBefor = true;
771
949
  };
772
950
  ControlValidationService.prototype.RemoveGlobalError = function () {
773
951
  var removedList = document.getElementsByClassName('alert alert-danger alert-InvalidValidation');
@@ -779,7 +957,7 @@
779
957
  this.isCreatedBefor = false;
780
958
  };
781
959
  ControlValidationService.prototype.showInputErro = function (errors) {
782
- var e_1, _a;
960
+ var e_2, _a;
783
961
  // show error on top of form
784
962
  this.showGlobalError();
785
963
  // remove old error from server
@@ -788,7 +966,7 @@
788
966
  for (var key in errors) {
789
967
  if (errors.hasOwnProperty(key)) {
790
968
  try {
791
- for (var _b = (e_1 = void 0, __values(errors[key])), _c = _b.next(); !_c.done; _c = _b.next()) {
969
+ for (var _b = (e_2 = void 0, __values(errors[key])), _c = _b.next(); !_c.done; _c = _b.next()) {
792
970
  var iterator = _c.value;
793
971
  var input = document.querySelectorAll('[ng-reflect-name=' + key + ']')[0];
794
972
  if (input.attributes['ng-reflect-name'].value === key) {
@@ -804,12 +982,12 @@
804
982
  }
805
983
  }
806
984
  }
807
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
985
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
808
986
  finally {
809
987
  try {
810
988
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
811
989
  }
812
- finally { if (e_1) throw e_1.error; }
990
+ finally { if (e_2) throw e_2.error; }
813
991
  }
814
992
  }
815
993
  }
@@ -820,56 +998,60 @@
820
998
  elements[0].parentNode.removeChild(elements[0]);
821
999
  }
822
1000
  };
823
- ControlValidationService.prototype.renderServerErrors = function (form, err, requestOptions) {
1001
+ ControlValidationService.prototype.renderServerErrors = function (form, err, requestOptions, formId) {
824
1002
  var _this = this;
825
1003
  if (err.error == null) {
826
1004
  return;
827
1005
  }
1006
+ var errorsArray = [];
828
1007
  this.requestOptions = requestOptions;
829
1008
  err.error.validation_errors.forEach(function (element) {
830
1009
  var fieldName = element.field;
831
- var controlName = element.control_name;
1010
+ var controlName = element.controlName;
832
1011
  var message = element.message;
833
1012
  if (form == null) {
834
1013
  _this.requestOptions.customErrorMessage ? _this.utilityService.notifyErrorMessage(_this.requestOptions.customErrorMessage) : _this.utilityService.notifyErrorMessage(fieldName + ": " + message);
835
1014
  }
836
- else if (!_this.hasControlName(form, controlName)) {
837
- _this.showGlobalError(fieldName + ": " + message);
1015
+ else if (controlName && !_this.hasControlName(form, controlName)) {
1016
+ errorsArray.push(fieldName + ": " + message);
1017
+ // this.showGlobalError(`${fieldName}: ${message}`,formId )
838
1018
  }
839
1019
  else {
840
1020
  _this.setFieldError(form, controlName, fieldName, message);
841
1021
  }
842
1022
  });
1023
+ if (errorsArray.length > 0)
1024
+ this.showGlobalError(errorsArray, formId);
843
1025
  };
844
1026
  ControlValidationService.prototype.hasControlName = function (form, controlName) {
845
1027
  var control = form.get(controlName);
846
1028
  return control != null;
847
1029
  };
848
1030
  ControlValidationService.prototype.setFieldError = function (form, controlName, fieldName, message) {
849
- var _a;
850
- var control = form.get(controlName);
851
- var errors = (_a = {}, _a[message] = true, _a);
1031
+ var control = null;
1032
+ if (controlName)
1033
+ control = form.get(controlName);
1034
+ else
1035
+ control = form.get(fieldName.split('.')[0]);
1036
+ var errors = { "errorMassage": message };
852
1037
  var fieldNameArray = fieldName.split('.');
853
1038
  if (fieldNameArray.length >= 1) {
854
- switch (fieldNameArray[length - 1].toLocaleLowerCase()) {
1039
+ switch (fieldNameArray[fieldNameArray.length - 1].toLocaleLowerCase()) {
855
1040
  case "english":
856
- var englishControl = control.get("EnglishValue");
1041
+ var englishControl = control.get("English");
857
1042
  englishControl.setErrors(errors);
858
- englishControl.markAsTouched();
859
- englishControl.updateValueAndValidity();
860
1043
  break;
861
1044
  case "arabic":
862
- var arabicControl = control.get("ArabicValue");
1045
+ var arabicControl = control.get("Arabic");
863
1046
  arabicControl.setErrors(errors);
864
- arabicControl.markAsTouched();
865
- arabicControl.updateValueAndValidity();
866
1047
  break;
867
1048
  default:
868
1049
  control.setErrors(errors);
869
- control.markAsTouched();
870
- control.updateValueAndValidity();
871
1050
  }
872
1051
  }
1052
+ else if (fieldNameArray.length == 1) {
1053
+ control.setErrors(errors);
1054
+ }
873
1055
  else {
874
1056
  this.requestOptions.customErrorMessage ? this.utilityService.notifyErrorMessage(this.requestOptions.customErrorMessage) : this.utilityService.notifyErrorMessage(fieldName + ": " + message);
875
1057
  }
@@ -889,124 +1071,6 @@
889
1071
  ngBlockUi.BlockUI()
890
1072
  ], ControlValidationService.prototype, "blockUI", void 0);
891
1073
 
892
- var RequestHandlerService = /** @class */ (function () {
893
- function RequestHandlerService(http, authService, environmentService, utilityService, controlValidationService, bbsfTranslateService) {
894
- var _this = this;
895
- //using localStorage to avoid call getCurrentLanguage() because it is not all to use async in constructor
896
- this.http = http;
897
- this.authService = authService;
898
- this.environmentService = environmentService;
899
- this.utilityService = utilityService;
900
- this.controlValidationService = controlValidationService;
901
- this.bbsfTranslateService = bbsfTranslateService;
902
- this.requestOptions = new RequestOptionsModel();
903
- this.currentLanguage = "";
904
- this.onDestroy$ = new rxjs.Subject();
905
- this.bbsfTranslateService.onLangChange.subscribe(function (event) {
906
- if (_this.currentLanguage != event.lang) {
907
- _this.currentLanguage = event.lang;
908
- }
909
- });
910
- }
911
- RequestHandlerService.prototype.get = function (Url, params, requestOptions) {
912
- var _this = this;
913
- if (requestOptions)
914
- this.requestOptions = requestOptions;
915
- var headers = new i1$1.HttpHeaders({
916
- 'Content-Type': 'application/json',
917
- 'Authorization': this.authService.authorizationHeaderValue(),
918
- });
919
- this.currentLanguage = localStorage.getItem('language');
920
- headers = headers.set('Accept-Language', this.currentLanguage.toString());
921
- if (!this.requestOptions.disableBlockUI)
922
- this.utilityService.startBlockUI();
923
- return this.http.get(this.environmentService.getApiUrl() + Url, { headers: headers, params: params }).pipe(operators.takeUntil(this.onDestroy$), operators.tap(function (result) {
924
- if (!_this.requestOptions.disableBlockUI)
925
- _this.utilityService.stopBlockUI();
926
- }));
927
- };
928
- RequestHandlerService.prototype.post = function (Url, model, params, requestOptions) {
929
- var _this = this;
930
- if (requestOptions)
931
- this.requestOptions = requestOptions;
932
- var headers = new i1$1.HttpHeaders({
933
- 'Content-Type': 'application/json',
934
- 'Authorization': this.authService.authorizationHeaderValue(),
935
- });
936
- this.currentLanguage = localStorage.getItem('language');
937
- headers = headers.set('Accept-Language', this.currentLanguage.toString());
938
- if (!this.requestOptions.disableBlockUI)
939
- this.utilityService.startBlockUI();
940
- 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) {
941
- if (!_this.requestOptions.disableBlockUI)
942
- _this.utilityService.stopBlockUI();
943
- }));
944
- };
945
- RequestHandlerService.prototype.destroyHandler = function () {
946
- this.onDestroy$.next();
947
- };
948
- return RequestHandlerService;
949
- }());
950
- RequestHandlerService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function RequestHandlerService_Factory() { return new RequestHandlerService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(AuthService), i0__namespace.ɵɵinject(EnvironmentService), i0__namespace.ɵɵinject(UtilityService), i0__namespace.ɵɵinject(ControlValidationService), i0__namespace.ɵɵinject(BBSFTranslateService)); }, token: RequestHandlerService, providedIn: "root" });
951
- RequestHandlerService.decorators = [
952
- { type: i0.Injectable, args: [{
953
- providedIn: 'root'
954
- },] }
955
- ];
956
- RequestHandlerService.ctorParameters = function () { return [
957
- { type: i1$1.HttpClient },
958
- { type: AuthService },
959
- { type: EnvironmentService },
960
- { type: UtilityService },
961
- { type: ControlValidationService },
962
- { type: BBSFTranslateService }
963
- ]; };
964
-
965
- var StylesBundleService = /** @class */ (function () {
966
- function StylesBundleService(document, translateService) {
967
- this.document = document;
968
- this.translateService = translateService;
969
- }
970
- StylesBundleService.prototype.loadThemes = function (lang, bundleEnglishName, bundleArabicName) {
971
- if (lang == "ar") {
972
- this.loadStyleBundle(bundleArabicName.toString());
973
- document.querySelector('html').setAttribute("lang", "ar");
974
- document.querySelector('html').setAttribute("dir", "rtl");
975
- }
976
- else {
977
- this.loadStyleBundle(bundleEnglishName.toString());
978
- document.querySelector('html').setAttribute("lang", "en");
979
- document.querySelector('html').setAttribute("dir", "ltr");
980
- }
981
- };
982
- StylesBundleService.prototype.loadStyleBundle = function (styleName) {
983
- var head = this.document.getElementsByTagName('head')[0];
984
- var themeLink = this.document.getElementById('client-theme');
985
- if (themeLink && themeLink.href.includes(styleName)) {
986
- return;
987
- }
988
- else if (themeLink && !themeLink.href.includes(styleName)) {
989
- themeLink.remove();
990
- }
991
- var style = this.document.createElement('link');
992
- style.id = 'client-theme';
993
- style.rel = 'stylesheet';
994
- style.href = "" + styleName;
995
- head.appendChild(style);
996
- };
997
- return StylesBundleService;
998
- }());
999
- StylesBundleService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function StylesBundleService_Factory() { return new StylesBundleService(i0__namespace.ɵɵinject(i1__namespace$2.DOCUMENT), i0__namespace.ɵɵinject(BBSFTranslateService)); }, token: StylesBundleService, providedIn: "root" });
1000
- StylesBundleService.decorators = [
1001
- { type: i0.Injectable, args: [{
1002
- providedIn: 'root'
1003
- },] }
1004
- ];
1005
- StylesBundleService.ctorParameters = function () { return [
1006
- { type: Document, decorators: [{ type: i0.Inject, args: [i1$2.DOCUMENT,] }] },
1007
- { type: BBSFTranslateService }
1008
- ]; };
1009
-
1010
1074
  var MasterLayoutService = /** @class */ (function () {
1011
1075
  function MasterLayoutService(router, http, authService, stylesBundleService, translate) {
1012
1076
  this.router = router;