@osovitny/anatoly 3.16.49 → 3.16.51
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/esm2022/lib/core/services/appcontext.service.mjs +42 -60
- package/esm2022/lib/iam/services/auth.service.mjs +6 -5
- package/esm2022/lib/ui/components/billing/buyaccess-button.component.mjs +8 -5
- package/esm2022/lib/ui/components/billing/subscribe-plan-button.component.mjs +10 -7
- package/esm2022/lib/ui/forms/contact-us/contact-us.mjs +13 -13
- package/fesm2022/osovitny-anatoly.mjs +74 -85
- package/fesm2022/osovitny-anatoly.mjs.map +1 -1
- package/lib/core/services/appcontext.service.d.ts +4 -7
- package/lib/ui/forms/contact-us/contact-us.d.ts +0 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import { NavigationEnd, NavigationStart, NavigationCancel, NavigationError, Rout
|
|
|
6
6
|
import * as i1$1 from '@angular/common/http';
|
|
7
7
|
import { HttpResponse, HttpClientModule, HttpClient, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
8
8
|
import { map, tap, mergeMap, catchError as catchError$1 } from 'rxjs/operators';
|
|
9
|
-
import { Subject, filter, takeUntil, map as map$1, catchError, of,
|
|
9
|
+
import { BehaviorSubject, Subject, filter, takeUntil, map as map$1, catchError, of, timer, merge, fromEvent, forkJoin } from 'rxjs';
|
|
10
10
|
import * as i4 from '@azure/msal-angular';
|
|
11
11
|
import { MSAL_GUARD_CONFIG, MsalGuard, MsalInterceptor, MSAL_INTERCEPTOR_CONFIG, MSAL_INSTANCE, MsalService, MsalBroadcastService, MsalModule } from '@azure/msal-angular';
|
|
12
12
|
import { BrowserUtils, EventType, InteractionStatus, InteractionType, InteractionRequiredAuthError, PromptValue, PublicClientApplication, LogLevel } from '@azure/msal-browser';
|
|
@@ -674,12 +674,10 @@ class AppContextService extends ApiServiceBase {
|
|
|
674
674
|
http;
|
|
675
675
|
localStorage;
|
|
676
676
|
sessionStorage;
|
|
677
|
-
//Consts
|
|
678
677
|
storageKeyName = 'appContext';
|
|
679
678
|
subscription = null;
|
|
680
|
-
successes = [];
|
|
681
679
|
//Private Streams
|
|
682
|
-
_updated = new
|
|
680
|
+
_updated = new BehaviorSubject(null);
|
|
683
681
|
//Public Streams
|
|
684
682
|
updated$ = this._updated.asObservable();
|
|
685
683
|
constructor(http, localStorage, sessionStorage) {
|
|
@@ -689,64 +687,36 @@ class AppContextService extends ApiServiceBase {
|
|
|
689
687
|
this.sessionStorage = sessionStorage;
|
|
690
688
|
this.baseUrl = `${ApiUrl}/appContext`;
|
|
691
689
|
}
|
|
690
|
+
fireUpdated(data) {
|
|
691
|
+
if (!data) {
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
let now = new Date();
|
|
695
|
+
console.log('AppContext has been updated at ' + now);
|
|
696
|
+
this._updated.next(data);
|
|
697
|
+
}
|
|
692
698
|
//Session
|
|
693
|
-
|
|
699
|
+
getCurrent4Session() {
|
|
694
700
|
return this.sessionStorage.getObject(this.storageKeyName);
|
|
695
701
|
}
|
|
696
|
-
|
|
702
|
+
setCurrent2Session(value) {
|
|
697
703
|
this.sessionStorage.setObject(this.storageKeyName, value);
|
|
698
704
|
}
|
|
699
|
-
updateCurrentIfExpired() {
|
|
700
|
-
let context = this.getCurrentFromSession();
|
|
701
|
-
if (!context) {
|
|
702
|
-
return;
|
|
703
|
-
}
|
|
704
|
-
let shouldBeUpdated = false;
|
|
705
|
-
let lr = context.lastRequested;
|
|
706
|
-
if (lr) {
|
|
707
|
-
let now = new Date();
|
|
708
|
-
let lastRequested = new Date(context.lastRequested);
|
|
709
|
-
let in3Mins = new Date(lastRequested.getFullYear(), lastRequested.getMonth(), lastRequested.getDate(), lastRequested.getHours(), lastRequested.getMinutes() + 3, 0, 0);
|
|
710
|
-
if (in3Mins.getTime() < now.getTime()) {
|
|
711
|
-
shouldBeUpdated = true;
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
else {
|
|
715
|
-
shouldBeUpdated = true;
|
|
716
|
-
}
|
|
717
|
-
if (shouldBeUpdated) {
|
|
718
|
-
this.updateCurrent();
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
705
|
dataReceived(data) {
|
|
722
706
|
this.current = data;
|
|
723
|
-
for (let i = 0; i < this.successes.length; i++) {
|
|
724
|
-
let success = this.successes[i];
|
|
725
|
-
if (success) {
|
|
726
|
-
success(data);
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
this.successes = [];
|
|
730
707
|
this.subscription.unsubscribe();
|
|
731
708
|
this.subscription = null;
|
|
732
|
-
if (data) {
|
|
733
|
-
let now = new Date();
|
|
734
|
-
console.log('AppContext has been updated at ' + now);
|
|
735
|
-
this._updated.next(data);
|
|
736
|
-
}
|
|
737
709
|
}
|
|
738
710
|
getCurrentPrivate(success = null, getCachedIfExist = true) {
|
|
739
711
|
if (getCachedIfExist) {
|
|
740
|
-
let context = this.
|
|
712
|
+
let context = this.getCurrent4Session();
|
|
741
713
|
if (context != null) {
|
|
742
|
-
if (success)
|
|
714
|
+
if (success) {
|
|
743
715
|
success(context);
|
|
716
|
+
}
|
|
744
717
|
return;
|
|
745
718
|
}
|
|
746
719
|
}
|
|
747
|
-
if (success) {
|
|
748
|
-
this.successes.push(success);
|
|
749
|
-
}
|
|
750
720
|
if (this.subscription != null) {
|
|
751
721
|
return;
|
|
752
722
|
}
|
|
@@ -758,23 +728,34 @@ class AppContextService extends ApiServiceBase {
|
|
|
758
728
|
}
|
|
759
729
|
});
|
|
760
730
|
}
|
|
731
|
+
updateCurrentIfExpired() {
|
|
732
|
+
let context = this.getCurrent4Session();
|
|
733
|
+
if (!context) {
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
let shouldBeUpdated = false;
|
|
737
|
+
let lr = context.lastRequested;
|
|
738
|
+
if (lr) {
|
|
739
|
+
let now = new Date();
|
|
740
|
+
let lastRequested = new Date(context.lastRequested);
|
|
741
|
+
let in3Mins = new Date(lastRequested.getFullYear(), lastRequested.getMonth(), lastRequested.getDate(), lastRequested.getHours(), lastRequested.getMinutes() + 3, 0, 0);
|
|
742
|
+
if (in3Mins.getTime() < now.getTime()) {
|
|
743
|
+
shouldBeUpdated = true;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
else {
|
|
747
|
+
shouldBeUpdated = true;
|
|
748
|
+
}
|
|
749
|
+
if (shouldBeUpdated) {
|
|
750
|
+
this.updateCurrent();
|
|
751
|
+
}
|
|
752
|
+
}
|
|
761
753
|
//Public
|
|
762
754
|
init(context) {
|
|
763
755
|
this.current = context;
|
|
764
756
|
}
|
|
765
|
-
getLatestCurrent(success = null) {
|
|
766
|
-
this.getCurrentPrivate(success, false);
|
|
767
|
-
}
|
|
768
|
-
getCurrent(success = null) {
|
|
769
|
-
this.getCurrentPrivate(success, true);
|
|
770
|
-
}
|
|
771
757
|
updateCurrent(success = null) {
|
|
772
|
-
|
|
773
|
-
//this.clearCurrent();
|
|
774
|
-
this.getLatestCurrent(success);
|
|
775
|
-
}
|
|
776
|
-
clearCurrent() {
|
|
777
|
-
this.sessionStorage.remove(this.storageKeyName);
|
|
758
|
+
this.getCurrentPrivate(success, false);
|
|
778
759
|
}
|
|
779
760
|
//Storage
|
|
780
761
|
clearLocalStorage() {
|
|
@@ -790,10 +771,11 @@ class AppContextService extends ApiServiceBase {
|
|
|
790
771
|
//current
|
|
791
772
|
get current() {
|
|
792
773
|
this.updateCurrentIfExpired();
|
|
793
|
-
return this.
|
|
774
|
+
return this.getCurrent4Session();
|
|
794
775
|
}
|
|
795
776
|
set current(value) {
|
|
796
|
-
this.
|
|
777
|
+
this.setCurrent2Session(value);
|
|
778
|
+
this.fireUpdated(value);
|
|
797
779
|
}
|
|
798
780
|
//currentUser
|
|
799
781
|
get currentUser() {
|
|
@@ -1125,15 +1107,16 @@ class AuthService extends ApiServiceBase {
|
|
|
1125
1107
|
if (!this.isUserAuthenticated()) {
|
|
1126
1108
|
return false;
|
|
1127
1109
|
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1110
|
+
if (this.appContext.current.isUserSignedIn && this.appContext.currentUser) {
|
|
1111
|
+
return true;
|
|
1112
|
+
}
|
|
1113
|
+
return false;
|
|
1130
1114
|
}
|
|
1131
1115
|
isUserAdmin() {
|
|
1132
1116
|
if (!this.isUserSignedIn()) {
|
|
1133
1117
|
return false;
|
|
1134
1118
|
}
|
|
1135
|
-
|
|
1136
|
-
return currentUser && currentUser.isUserAdmin;
|
|
1119
|
+
return this.appContext.current.isUserAdmin;
|
|
1137
1120
|
}
|
|
1138
1121
|
static ɵfac = function AuthService_Factory(t) { return new (t || AuthService)(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i1.Router), i0.ɵɵinject(AppContextService), i0.ɵɵinject(MSAL_GUARD_CONFIG), i0.ɵɵinject(i4.MsalService), i0.ɵɵinject(i4.MsalBroadcastService)); };
|
|
1139
1122
|
static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthService, factory: AuthService.ɵfac, providedIn: 'root' });
|
|
@@ -3222,11 +3205,14 @@ class BuyAccessButtonComponent {
|
|
|
3222
3205
|
this.appContext = appContext;
|
|
3223
3206
|
}
|
|
3224
3207
|
ngOnInit() {
|
|
3225
|
-
this.appContext.
|
|
3226
|
-
|
|
3208
|
+
this.appContext.updated$.subscribe((context) => {
|
|
3209
|
+
if (!context) {
|
|
3210
|
+
return;
|
|
3211
|
+
}
|
|
3212
|
+
this.isUserSignedIn = context.isUserSignedIn;
|
|
3227
3213
|
if (this.isUserSignedIn) {
|
|
3228
|
-
this.currentPlan =
|
|
3229
|
-
this.currentPlanTitle =
|
|
3214
|
+
this.currentPlan = context.account.billingPlan;
|
|
3215
|
+
this.currentPlanTitle = context.account.billingPlanAsString;
|
|
3230
3216
|
}
|
|
3231
3217
|
this.contextUpdated = true;
|
|
3232
3218
|
});
|
|
@@ -3336,13 +3322,16 @@ class SubscribePlanButtonComponent {
|
|
|
3336
3322
|
this.appContext = appContext;
|
|
3337
3323
|
}
|
|
3338
3324
|
ngOnInit() {
|
|
3339
|
-
this.appContext.
|
|
3340
|
-
|
|
3325
|
+
this.appContext.updated$.subscribe((context) => {
|
|
3326
|
+
if (!context) {
|
|
3327
|
+
return;
|
|
3328
|
+
}
|
|
3329
|
+
this.isUserSignedIn = context.isUserSignedIn;
|
|
3341
3330
|
if (this.isUserSignedIn) {
|
|
3342
|
-
this.currentPlan =
|
|
3343
|
-
this.currentPlanTitle =
|
|
3344
|
-
this.requestedPlan =
|
|
3345
|
-
this.requestedPlanTitle =
|
|
3331
|
+
this.currentPlan = context.account.billingPlan;
|
|
3332
|
+
this.currentPlanTitle = context.account.billingPlanAsString;
|
|
3333
|
+
this.requestedPlan = context.account.requestedBillingPlan;
|
|
3334
|
+
this.requestedPlanTitle = context.account.requestedBillingPlanAsString;
|
|
3346
3335
|
}
|
|
3347
3336
|
this.contextUpdated = true;
|
|
3348
3337
|
});
|
|
@@ -5048,8 +5037,18 @@ class ContactUsForm extends BaseEditComponent {
|
|
|
5048
5037
|
}
|
|
5049
5038
|
ngOnInit() {
|
|
5050
5039
|
this.createFormGroup();
|
|
5051
|
-
this.appContext.
|
|
5052
|
-
|
|
5040
|
+
this.appContext.updated$.subscribe((context) => {
|
|
5041
|
+
if (!context) {
|
|
5042
|
+
return;
|
|
5043
|
+
}
|
|
5044
|
+
this.isUserSignedIn = context.isUserSignedIn;
|
|
5045
|
+
this.reCaptchaSiteKey = context.reCaptchaSiteKeyV3;
|
|
5046
|
+
this.selectedTopic = this.topicList[3].value;
|
|
5047
|
+
this.setFormValue('topic', this.selectedTopic);
|
|
5048
|
+
if (this.isUserSignedIn) {
|
|
5049
|
+
this.setFormValue('name', context.user.displayNameOrFullName);
|
|
5050
|
+
this.setFormValue('email', context.user.email);
|
|
5051
|
+
}
|
|
5053
5052
|
});
|
|
5054
5053
|
}
|
|
5055
5054
|
createFormGroup() {
|
|
@@ -5061,16 +5060,6 @@ class ContactUsForm extends BaseEditComponent {
|
|
|
5061
5060
|
message: new FormControl('', [Validators.required])
|
|
5062
5061
|
});
|
|
5063
5062
|
}
|
|
5064
|
-
setContext(context) {
|
|
5065
|
-
this.isUserSignedIn = context.isUserSignedIn;
|
|
5066
|
-
this.reCaptchaSiteKey = context.reCaptchaSiteKeyV3;
|
|
5067
|
-
this.selectedTopic = this.topicList[3].value;
|
|
5068
|
-
this.setFormValue('topic', this.selectedTopic);
|
|
5069
|
-
if (this.isUserSignedIn) {
|
|
5070
|
-
this.setFormValue('name', context.user.displayNameOrFullName);
|
|
5071
|
-
this.setFormValue('email', context.user.email);
|
|
5072
|
-
}
|
|
5073
|
-
}
|
|
5074
5063
|
isValid() {
|
|
5075
5064
|
return this.formGroup.valid;
|
|
5076
5065
|
}
|