@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.
- package/esm2020/lib/session/smart-session.service.mjs +29 -23
- package/esm2020/lib/view-context/smart-view-context.service.mjs +8 -1
- package/fesm2015/smartbit4all-ng-client.mjs +33 -20
- package/fesm2015/smartbit4all-ng-client.mjs.map +1 -1
- package/fesm2020/smartbit4all-ng-client.mjs +33 -20
- package/fesm2020/smartbit4all-ng-client.mjs.map +1 -1
- package/lib/session/smart-session.service.d.ts +4 -4
- package/package.json +1 -1
- package/smartbit4all-ng-client-1.1.21.tgz +0 -0
- package/smartbit4all-ng-client-1.1.20.tgz +0 -0
|
@@ -735,7 +735,7 @@ class SmartSessionService {
|
|
|
735
735
|
this.headerParams = new Array();
|
|
736
736
|
this.headersUpdated = new Subject();
|
|
737
737
|
// Locale
|
|
738
|
-
this.localStorageLocaleName =
|
|
738
|
+
this.localStorageLocaleName = 'locale';
|
|
739
739
|
this.localeChanged = new Subject();
|
|
740
740
|
this.sessionExpiracyChanged = new Subject();
|
|
741
741
|
}
|
|
@@ -759,16 +759,24 @@ class SmartSessionService {
|
|
|
759
759
|
throw new Error(`sessionHandlerService was not initialized. Error: ${sessionError.code}`);
|
|
760
760
|
}
|
|
761
761
|
addHeaderParam(headerParam) {
|
|
762
|
-
|
|
762
|
+
console.log('addHeaderParam called ');
|
|
763
|
+
console.log(headerParam);
|
|
764
|
+
if (this.headerParams.find((h) => h.headerName === headerParam.headerName)) {
|
|
765
|
+
let index = this.headerParams.findIndex((h) => h.headerName === headerParam.headerName);
|
|
766
|
+
this.headerParams[index].value = headerParam.value;
|
|
767
|
+
}
|
|
768
|
+
else {
|
|
769
|
+
this.headerParams.push(headerParam);
|
|
770
|
+
}
|
|
763
771
|
this.headersUpdated.next();
|
|
764
772
|
}
|
|
765
773
|
setUpTokenForSessionService() {
|
|
766
|
-
if (this.headerParams.find((header) => header.headerName ===
|
|
767
|
-
let index = this.headerParams.findIndex((header) => header.headerName ===
|
|
774
|
+
if (this.headerParams.find((header) => header.headerName === 'Authorization')) {
|
|
775
|
+
let index = this.headerParams.findIndex((header) => header.headerName === 'Authorization');
|
|
768
776
|
this.headerParams[index].value = `Bearer ${this.token}`;
|
|
769
777
|
}
|
|
770
778
|
else {
|
|
771
|
-
this.addHeaderParam({ headerName:
|
|
779
|
+
this.addHeaderParam({ headerName: 'Authorization', value: `Bearer ${this.token}` });
|
|
772
780
|
}
|
|
773
781
|
}
|
|
774
782
|
setUrl(url) {
|
|
@@ -776,7 +784,7 @@ class SmartSessionService {
|
|
|
776
784
|
}
|
|
777
785
|
getBasePath() {
|
|
778
786
|
if (!this.basePath) {
|
|
779
|
-
throw new Error(
|
|
787
|
+
throw new Error('BasePath has not been set in SmartSessionService!');
|
|
780
788
|
}
|
|
781
789
|
return this.basePath;
|
|
782
790
|
}
|
|
@@ -785,10 +793,10 @@ class SmartSessionService {
|
|
|
785
793
|
}
|
|
786
794
|
saveTokenToLocalStorage() {
|
|
787
795
|
if (this.sessionInfoData && this.cookieName) {
|
|
788
|
-
localStorage.setItem(
|
|
796
|
+
localStorage.setItem('token', this.sessionInfoData.sid);
|
|
789
797
|
if (this.sessionInfoData.refreshToken &&
|
|
790
|
-
this.sessionInfoData.refreshToken !== localStorage.getItem(
|
|
791
|
-
localStorage.setItem(
|
|
798
|
+
this.sessionInfoData.refreshToken !== localStorage.getItem('refreshToken')) {
|
|
799
|
+
localStorage.setItem('refreshToken', this.sessionInfoData.refreshToken);
|
|
792
800
|
}
|
|
793
801
|
this.cookieService.set(this.cookieName, this.token);
|
|
794
802
|
}
|
|
@@ -801,19 +809,17 @@ class SmartSessionService {
|
|
|
801
809
|
}
|
|
802
810
|
checkStatements() {
|
|
803
811
|
if (!this.basePath) {
|
|
804
|
-
throw new Error(
|
|
812
|
+
throw new Error('The url of the backend api has not been set!');
|
|
805
813
|
}
|
|
806
814
|
else if (!this.cookieName) {
|
|
807
|
-
throw new Error(
|
|
815
|
+
throw new Error('The name of the cookie required by the backend has not been set!');
|
|
808
816
|
}
|
|
809
817
|
}
|
|
810
818
|
async initialize() {
|
|
811
819
|
this.checkStatements();
|
|
812
|
-
let tokenFromLocalStorage = localStorage.getItem(
|
|
820
|
+
let tokenFromLocalStorage = localStorage.getItem('token');
|
|
813
821
|
let tokenFromCookies = this.cookieService.get(this.cookieName);
|
|
814
|
-
if (tokenFromLocalStorage &&
|
|
815
|
-
tokenFromCookies &&
|
|
816
|
-
tokenFromLocalStorage === tokenFromCookies) {
|
|
822
|
+
if (tokenFromLocalStorage && tokenFromCookies && tokenFromLocalStorage === tokenFromCookies) {
|
|
817
823
|
this.token = tokenFromLocalStorage;
|
|
818
824
|
this.setUpTokenForSessionService();
|
|
819
825
|
try {
|
|
@@ -853,7 +859,7 @@ class SmartSessionService {
|
|
|
853
859
|
return this.sessionInfoData;
|
|
854
860
|
}
|
|
855
861
|
async refreshSession() {
|
|
856
|
-
let refreshToken = localStorage.getItem(
|
|
862
|
+
let refreshToken = localStorage.getItem('refreshToken');
|
|
857
863
|
if (!refreshToken) {
|
|
858
864
|
return await this.startSession();
|
|
859
865
|
}
|
|
@@ -865,7 +871,7 @@ class SmartSessionService {
|
|
|
865
871
|
.catch(async (error) => {
|
|
866
872
|
if (error.error &&
|
|
867
873
|
error.error.code &&
|
|
868
|
-
error.error.code ===
|
|
874
|
+
error.error.code === 'session.refreshtoken.invalid') {
|
|
869
875
|
await this.startSession();
|
|
870
876
|
}
|
|
871
877
|
});
|
|
@@ -906,7 +912,7 @@ class SmartSessionService {
|
|
|
906
912
|
}
|
|
907
913
|
return this.sessionInfoData.locale;
|
|
908
914
|
}
|
|
909
|
-
throw new Error(
|
|
915
|
+
throw new Error('There is no SessionInfoData or locale is undefined.');
|
|
910
916
|
}
|
|
911
917
|
async changeLocale(locale) {
|
|
912
918
|
this.sessionInfoData = await this.apiService.setLocale(locale).toPromise();
|
|
@@ -917,11 +923,11 @@ class SmartSessionService {
|
|
|
917
923
|
}
|
|
918
924
|
}
|
|
919
925
|
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:
|
|
926
|
+
SmartSessionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionService, providedIn: 'root' });
|
|
921
927
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartSessionService, decorators: [{
|
|
922
928
|
type: Injectable,
|
|
923
929
|
args: [{
|
|
924
|
-
providedIn:
|
|
930
|
+
providedIn: 'root',
|
|
925
931
|
}]
|
|
926
932
|
}], ctorParameters: function () { return [{ type: SessionService }, { type: SmartCookieService }]; } });
|
|
927
933
|
|
|
@@ -2178,6 +2184,7 @@ class SmartViewContextService {
|
|
|
2178
2184
|
sessionStorage.clear();
|
|
2179
2185
|
}
|
|
2180
2186
|
setTabId(tabId) {
|
|
2187
|
+
console.log('setTabId ' + tabId);
|
|
2181
2188
|
sessionStorage.setItem(this.tabIdName, tabId);
|
|
2182
2189
|
this.session.addHeaderParam({
|
|
2183
2190
|
headerName: this.tabIdhttpHeaderName,
|
|
@@ -2185,6 +2192,7 @@ class SmartViewContextService {
|
|
|
2185
2192
|
});
|
|
2186
2193
|
}
|
|
2187
2194
|
async startViewContext() {
|
|
2195
|
+
console.log('startViewContext');
|
|
2188
2196
|
this.clearSessionStorage();
|
|
2189
2197
|
let newViewContext = await this.view
|
|
2190
2198
|
.createViewContext()
|
|
@@ -2193,6 +2201,7 @@ class SmartViewContextService {
|
|
|
2193
2201
|
throw new Error('No ViewContext was created');
|
|
2194
2202
|
}
|
|
2195
2203
|
this.viewContext = newViewContext;
|
|
2204
|
+
console.log(this.viewContext);
|
|
2196
2205
|
this.setTabId(newViewContext.uuid);
|
|
2197
2206
|
return this.viewContext;
|
|
2198
2207
|
}
|
|
@@ -2203,6 +2212,8 @@ class SmartViewContextService {
|
|
|
2203
2212
|
if (!this.messageDialogname) {
|
|
2204
2213
|
throw new Error('The messageDialogName provided by the backend has not been set.');
|
|
2205
2214
|
}
|
|
2215
|
+
console.log('init viewContext');
|
|
2216
|
+
console.log(uuid);
|
|
2206
2217
|
if (uuid) {
|
|
2207
2218
|
let subscription = this.session.headersUpdated.subscribe(async () => {
|
|
2208
2219
|
subscription.unsubscribe();
|
|
@@ -2226,6 +2237,7 @@ class SmartViewContextService {
|
|
|
2226
2237
|
if (!viewHandler) {
|
|
2227
2238
|
throw new Error(`SmartViewHandlerModel was not found by view name: ${view.viewName}`);
|
|
2228
2239
|
}
|
|
2240
|
+
console.log(view);
|
|
2229
2241
|
sessionStorage.setItem(view.viewName, view.uuid);
|
|
2230
2242
|
if (view.type === ViewType.Dialog) {
|
|
2231
2243
|
if (!viewHandler.component) {
|
|
@@ -2306,6 +2318,7 @@ class SmartViewContextService {
|
|
|
2306
2318
|
});
|
|
2307
2319
|
}
|
|
2308
2320
|
async restoreViews(uuid) {
|
|
2321
|
+
console.log('restoreViews');
|
|
2309
2322
|
if (!this.viewContext) {
|
|
2310
2323
|
await this.getViewContext(uuid);
|
|
2311
2324
|
}
|