@smartbit4all/ng-client 1.1.20 → 1.1.22

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.
@@ -735,7 +735,7 @@ class SmartSessionService {
735
735
  this.headerParams = new Array();
736
736
  this.headersUpdated = new Subject();
737
737
  // Locale
738
- this.localStorageLocaleName = "locale";
738
+ this.localStorageLocaleName = 'locale';
739
739
  this.localeChanged = new Subject();
740
740
  this.sessionExpiracyChanged = new Subject();
741
741
  }
@@ -759,24 +759,27 @@ class SmartSessionService {
759
759
  throw new Error(`sessionHandlerService was not initialized. Error: ${sessionError.code}`);
760
760
  }
761
761
  addHeaderParam(headerParam) {
762
- this.headerParams.push(headerParam);
763
- this.headersUpdated.next();
764
- }
765
- setUpTokenForSessionService() {
766
- if (this.headerParams.find((header) => header.headerName === "Authorization")) {
767
- let index = this.headerParams.findIndex((header) => header.headerName === "Authorization");
768
- this.headerParams[index].value = `Bearer ${this.token}`;
762
+ if (this.headerParams.find((h) => h.headerName === headerParam.headerName)) {
763
+ let index = this.headerParams.findIndex((h) => h.headerName === headerParam.headerName);
764
+ this.headerParams[index].value = headerParam.value;
769
765
  }
770
766
  else {
771
- this.addHeaderParam({ headerName: "Authorization", value: `Bearer ${this.token}` });
767
+ this.headerParams.push(headerParam);
772
768
  }
769
+ this.headersUpdated.next();
770
+ }
771
+ setUpTokenForSessionService() {
772
+ this.addHeaderParam({
773
+ headerName: 'Authorization',
774
+ value: `Bearer ${this.token}`,
775
+ });
773
776
  }
774
777
  setUrl(url) {
775
778
  this.basePath = url;
776
779
  }
777
780
  getBasePath() {
778
781
  if (!this.basePath) {
779
- throw new Error("BasePath has not been set in SmartSessionService!");
782
+ throw new Error('BasePath has not been set in SmartSessionService!');
780
783
  }
781
784
  return this.basePath;
782
785
  }
@@ -785,10 +788,10 @@ class SmartSessionService {
785
788
  }
786
789
  saveTokenToLocalStorage() {
787
790
  if (this.sessionInfoData && this.cookieName) {
788
- localStorage.setItem("token", this.sessionInfoData.sid);
791
+ localStorage.setItem('token', this.sessionInfoData.sid);
789
792
  if (this.sessionInfoData.refreshToken &&
790
- this.sessionInfoData.refreshToken !== localStorage.getItem("refreshToken")) {
791
- localStorage.setItem("refreshToken", this.sessionInfoData.refreshToken);
793
+ this.sessionInfoData.refreshToken !== localStorage.getItem('refreshToken')) {
794
+ localStorage.setItem('refreshToken', this.sessionInfoData.refreshToken);
792
795
  }
793
796
  this.cookieService.set(this.cookieName, this.token);
794
797
  }
@@ -801,19 +804,17 @@ class SmartSessionService {
801
804
  }
802
805
  checkStatements() {
803
806
  if (!this.basePath) {
804
- throw new Error("The url of the backend api has not been set!");
807
+ throw new Error('The url of the backend api has not been set!');
805
808
  }
806
809
  else if (!this.cookieName) {
807
- throw new Error("The name of the cookie required by the backend has not been set!");
810
+ throw new Error('The name of the cookie required by the backend has not been set!');
808
811
  }
809
812
  }
810
813
  async initialize() {
811
814
  this.checkStatements();
812
- let tokenFromLocalStorage = localStorage.getItem("token");
815
+ let tokenFromLocalStorage = localStorage.getItem('token');
813
816
  let tokenFromCookies = this.cookieService.get(this.cookieName);
814
- if (tokenFromLocalStorage &&
815
- tokenFromCookies &&
816
- tokenFromLocalStorage === tokenFromCookies) {
817
+ if (tokenFromLocalStorage && tokenFromCookies && tokenFromLocalStorage === tokenFromCookies) {
817
818
  this.token = tokenFromLocalStorage;
818
819
  this.setUpTokenForSessionService();
819
820
  try {
@@ -853,7 +854,7 @@ class SmartSessionService {
853
854
  return this.sessionInfoData;
854
855
  }
855
856
  async refreshSession() {
856
- let refreshToken = localStorage.getItem("refreshToken");
857
+ let refreshToken = localStorage.getItem('refreshToken');
857
858
  if (!refreshToken) {
858
859
  return await this.startSession();
859
860
  }
@@ -865,7 +866,7 @@ class SmartSessionService {
865
866
  .catch(async (error) => {
866
867
  if (error.error &&
867
868
  error.error.code &&
868
- error.error.code === "session.refreshtoken.invalid") {
869
+ error.error.code === 'session.refreshtoken.invalid') {
869
870
  await this.startSession();
870
871
  }
871
872
  });
@@ -906,7 +907,7 @@ class SmartSessionService {
906
907
  }
907
908
  return this.sessionInfoData.locale;
908
909
  }
909
- throw new Error("There is no SessionInfoData or locale is undefined.");
910
+ throw new Error('There is no SessionInfoData or locale is undefined.');
910
911
  }
911
912
  async changeLocale(locale) {
912
913
  this.sessionInfoData = await this.apiService.setLocale(locale).toPromise();
@@ -917,11 +918,11 @@ class SmartSessionService {
917
918
  }
918
919
  }
919
920
  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 });
920
- SmartSessionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionService, providedIn: "root" });
921
+ SmartSessionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionService, providedIn: 'root' });
921
922
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionService, decorators: [{
922
923
  type: Injectable,
923
924
  args: [{
924
- providedIn: "root",
925
+ providedIn: 'root',
925
926
  }]
926
927
  }], ctorParameters: function () { return [{ type: SessionService }, { type: SmartCookieService }]; } });
927
928
 
@@ -2226,7 +2227,6 @@ class SmartViewContextService {
2226
2227
  if (!viewHandler) {
2227
2228
  throw new Error(`SmartViewHandlerModel was not found by view name: ${view.viewName}`);
2228
2229
  }
2229
- sessionStorage.setItem(view.viewName, view.uuid);
2230
2230
  if (view.type === ViewType.Dialog) {
2231
2231
  if (!viewHandler.component) {
2232
2232
  throw new Error(`Component is undefined in SmartViewHandlerModel with name: ${view.viewName}`);
@@ -2254,6 +2254,7 @@ class SmartViewContextService {
2254
2254
  view.state = ViewState.Opened;
2255
2255
  this.openedViewUuids.push(view.uuid);
2256
2256
  this.openedViewData.push(view);
2257
+ sessionStorage.setItem(view.viewName, view.uuid);
2257
2258
  this.uuidOfPageHasBeenChanged.next(view.viewName);
2258
2259
  this.updateViewContext({
2259
2260
  updates: [
@@ -2293,8 +2294,8 @@ class SmartViewContextService {
2293
2294
  if (index >= 0) {
2294
2295
  this.openedViewUuids.splice(index, 1);
2295
2296
  this.openedViewData.splice(index, 1);
2297
+ sessionStorage.removeItem(view.viewName);
2296
2298
  }
2297
- sessionStorage.removeItem(view.viewName);
2298
2299
  this.updateViewContext({
2299
2300
  updates: [
2300
2301
  {
@@ -2328,8 +2329,8 @@ class SmartViewContextService {
2328
2329
  .flatMap((viewData) => viewData.uuid)
2329
2330
  .includes(viewData.uuid));
2330
2331
  if (viewDataToClose?.length) {
2331
- viewDataToClose.map(async (viewData) => {
2332
- await this.closeView(viewData);
2332
+ viewDataToClose.map((viewData) => {
2333
+ this.closeView(viewData);
2333
2334
  });
2334
2335
  }
2335
2336
  this.viewContextHasBeenSynced.next();
@@ -4229,7 +4230,7 @@ let SmartComponentApiClient = class SmartComponentApiClient {
4229
4230
  }
4230
4231
  }
4231
4232
  catch (error) {
4232
- console.log(error);
4233
+ console.error(error);
4233
4234
  this.model = change.value;
4234
4235
  }
4235
4236
  if (!change.changedWidgets && !change.changes && change.value) {