@smartbit4all/ng-client 1.1.20 → 1.1.21

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.
@@ -679,7 +679,7 @@ class SmartSessionService {
679
679
  this.headerParams = new Array();
680
680
  this.headersUpdated = new Subject();
681
681
  // Locale
682
- this.localStorageLocaleName = "locale";
682
+ this.localStorageLocaleName = 'locale';
683
683
  this.localeChanged = new Subject();
684
684
  this.sessionExpiracyChanged = new Subject();
685
685
  }
@@ -706,16 +706,24 @@ class SmartSessionService {
706
706
  });
707
707
  }
708
708
  addHeaderParam(headerParam) {
709
- this.headerParams.push(headerParam);
709
+ console.log('addHeaderParam called ');
710
+ console.log(headerParam);
711
+ if (this.headerParams.find((h) => h.headerName === headerParam.headerName)) {
712
+ let index = this.headerParams.findIndex((h) => h.headerName === headerParam.headerName);
713
+ this.headerParams[index].value = headerParam.value;
714
+ }
715
+ else {
716
+ this.headerParams.push(headerParam);
717
+ }
710
718
  this.headersUpdated.next();
711
719
  }
712
720
  setUpTokenForSessionService() {
713
- if (this.headerParams.find((header) => header.headerName === "Authorization")) {
714
- let index = this.headerParams.findIndex((header) => header.headerName === "Authorization");
721
+ if (this.headerParams.find((header) => header.headerName === 'Authorization')) {
722
+ let index = this.headerParams.findIndex((header) => header.headerName === 'Authorization');
715
723
  this.headerParams[index].value = `Bearer ${this.token}`;
716
724
  }
717
725
  else {
718
- this.addHeaderParam({ headerName: "Authorization", value: `Bearer ${this.token}` });
726
+ this.addHeaderParam({ headerName: 'Authorization', value: `Bearer ${this.token}` });
719
727
  }
720
728
  }
721
729
  setUrl(url) {
@@ -723,7 +731,7 @@ class SmartSessionService {
723
731
  }
724
732
  getBasePath() {
725
733
  if (!this.basePath) {
726
- throw new Error("BasePath has not been set in SmartSessionService!");
734
+ throw new Error('BasePath has not been set in SmartSessionService!');
727
735
  }
728
736
  return this.basePath;
729
737
  }
@@ -732,10 +740,10 @@ class SmartSessionService {
732
740
  }
733
741
  saveTokenToLocalStorage() {
734
742
  if (this.sessionInfoData && this.cookieName) {
735
- localStorage.setItem("token", this.sessionInfoData.sid);
743
+ localStorage.setItem('token', this.sessionInfoData.sid);
736
744
  if (this.sessionInfoData.refreshToken &&
737
- this.sessionInfoData.refreshToken !== localStorage.getItem("refreshToken")) {
738
- localStorage.setItem("refreshToken", this.sessionInfoData.refreshToken);
745
+ this.sessionInfoData.refreshToken !== localStorage.getItem('refreshToken')) {
746
+ localStorage.setItem('refreshToken', this.sessionInfoData.refreshToken);
739
747
  }
740
748
  this.cookieService.set(this.cookieName, this.token);
741
749
  }
@@ -748,20 +756,18 @@ class SmartSessionService {
748
756
  }
749
757
  checkStatements() {
750
758
  if (!this.basePath) {
751
- throw new Error("The url of the backend api has not been set!");
759
+ throw new Error('The url of the backend api has not been set!');
752
760
  }
753
761
  else if (!this.cookieName) {
754
- throw new Error("The name of the cookie required by the backend has not been set!");
762
+ throw new Error('The name of the cookie required by the backend has not been set!');
755
763
  }
756
764
  }
757
765
  initialize() {
758
766
  return __awaiter(this, void 0, void 0, function* () {
759
767
  this.checkStatements();
760
- let tokenFromLocalStorage = localStorage.getItem("token");
768
+ let tokenFromLocalStorage = localStorage.getItem('token');
761
769
  let tokenFromCookies = this.cookieService.get(this.cookieName);
762
- if (tokenFromLocalStorage &&
763
- tokenFromCookies &&
764
- tokenFromLocalStorage === tokenFromCookies) {
770
+ if (tokenFromLocalStorage && tokenFromCookies && tokenFromLocalStorage === tokenFromCookies) {
765
771
  this.token = tokenFromLocalStorage;
766
772
  this.setUpTokenForSessionService();
767
773
  try {
@@ -807,7 +813,7 @@ class SmartSessionService {
807
813
  }
808
814
  refreshSession() {
809
815
  return __awaiter(this, void 0, void 0, function* () {
810
- let refreshToken = localStorage.getItem("refreshToken");
816
+ let refreshToken = localStorage.getItem('refreshToken');
811
817
  if (!refreshToken) {
812
818
  return yield this.startSession();
813
819
  }
@@ -819,7 +825,7 @@ class SmartSessionService {
819
825
  .catch((error) => __awaiter(this, void 0, void 0, function* () {
820
826
  if (error.error &&
821
827
  error.error.code &&
822
- error.error.code === "session.refreshtoken.invalid") {
828
+ error.error.code === 'session.refreshtoken.invalid') {
823
829
  yield this.startSession();
824
830
  }
825
831
  }));
@@ -867,7 +873,7 @@ class SmartSessionService {
867
873
  }
868
874
  return this.sessionInfoData.locale;
869
875
  }
870
- throw new Error("There is no SessionInfoData or locale is undefined.");
876
+ throw new Error('There is no SessionInfoData or locale is undefined.');
871
877
  }
872
878
  changeLocale(locale) {
873
879
  return __awaiter(this, void 0, void 0, function* () {
@@ -880,11 +886,11 @@ class SmartSessionService {
880
886
  }
881
887
  }
882
888
  SmartSessionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionService, deps: [{ token: SessionService }, { token: SmartCookieService }], target: i0.ɵɵFactoryTarget.Injectable });
883
- SmartSessionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionService, providedIn: "root" });
889
+ SmartSessionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionService, providedIn: 'root' });
884
890
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionService, decorators: [{
885
891
  type: Injectable,
886
892
  args: [{
887
- providedIn: "root",
893
+ providedIn: 'root',
888
894
  }]
889
895
  }], ctorParameters: function () { return [{ type: SessionService }, { type: SmartCookieService }]; } });
890
896
 
@@ -2108,6 +2114,7 @@ class SmartViewContextService {
2108
2114
  sessionStorage.clear();
2109
2115
  }
2110
2116
  setTabId(tabId) {
2117
+ console.log('setTabId ' + tabId);
2111
2118
  sessionStorage.setItem(this.tabIdName, tabId);
2112
2119
  this.session.addHeaderParam({
2113
2120
  headerName: this.tabIdhttpHeaderName,
@@ -2116,6 +2123,7 @@ class SmartViewContextService {
2116
2123
  }
2117
2124
  startViewContext() {
2118
2125
  return __awaiter(this, void 0, void 0, function* () {
2126
+ console.log('startViewContext');
2119
2127
  this.clearSessionStorage();
2120
2128
  let newViewContext = yield this.view
2121
2129
  .createViewContext()
@@ -2124,6 +2132,7 @@ class SmartViewContextService {
2124
2132
  throw new Error('No ViewContext was created');
2125
2133
  }
2126
2134
  this.viewContext = newViewContext;
2135
+ console.log(this.viewContext);
2127
2136
  this.setTabId(newViewContext.uuid);
2128
2137
  return this.viewContext;
2129
2138
  });
@@ -2136,6 +2145,8 @@ class SmartViewContextService {
2136
2145
  if (!this.messageDialogname) {
2137
2146
  throw new Error('The messageDialogName provided by the backend has not been set.');
2138
2147
  }
2148
+ console.log('init viewContext');
2149
+ console.log(uuid);
2139
2150
  if (uuid) {
2140
2151
  let subscription = this.session.headersUpdated.subscribe(() => __awaiter(this, void 0, void 0, function* () {
2141
2152
  subscription.unsubscribe();
@@ -2161,6 +2172,7 @@ class SmartViewContextService {
2161
2172
  if (!viewHandler) {
2162
2173
  throw new Error(`SmartViewHandlerModel was not found by view name: ${view.viewName}`);
2163
2174
  }
2175
+ console.log(view);
2164
2176
  sessionStorage.setItem(view.viewName, view.uuid);
2165
2177
  if (view.type === ViewType.Dialog) {
2166
2178
  if (!viewHandler.component) {
@@ -2243,6 +2255,7 @@ class SmartViewContextService {
2243
2255
  }
2244
2256
  restoreViews(uuid) {
2245
2257
  return __awaiter(this, void 0, void 0, function* () {
2258
+ console.log('restoreViews');
2246
2259
  if (!this.viewContext) {
2247
2260
  yield this.getViewContext(uuid);
2248
2261
  }