@osovitny/anatoly 3.16.50 → 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/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 +69 -81
- 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() {
|
|
@@ -3223,11 +3205,14 @@ class BuyAccessButtonComponent {
|
|
|
3223
3205
|
this.appContext = appContext;
|
|
3224
3206
|
}
|
|
3225
3207
|
ngOnInit() {
|
|
3226
|
-
this.appContext.
|
|
3227
|
-
|
|
3208
|
+
this.appContext.updated$.subscribe((context) => {
|
|
3209
|
+
if (!context) {
|
|
3210
|
+
return;
|
|
3211
|
+
}
|
|
3212
|
+
this.isUserSignedIn = context.isUserSignedIn;
|
|
3228
3213
|
if (this.isUserSignedIn) {
|
|
3229
|
-
this.currentPlan =
|
|
3230
|
-
this.currentPlanTitle =
|
|
3214
|
+
this.currentPlan = context.account.billingPlan;
|
|
3215
|
+
this.currentPlanTitle = context.account.billingPlanAsString;
|
|
3231
3216
|
}
|
|
3232
3217
|
this.contextUpdated = true;
|
|
3233
3218
|
});
|
|
@@ -3337,13 +3322,16 @@ class SubscribePlanButtonComponent {
|
|
|
3337
3322
|
this.appContext = appContext;
|
|
3338
3323
|
}
|
|
3339
3324
|
ngOnInit() {
|
|
3340
|
-
this.appContext.
|
|
3341
|
-
|
|
3325
|
+
this.appContext.updated$.subscribe((context) => {
|
|
3326
|
+
if (!context) {
|
|
3327
|
+
return;
|
|
3328
|
+
}
|
|
3329
|
+
this.isUserSignedIn = context.isUserSignedIn;
|
|
3342
3330
|
if (this.isUserSignedIn) {
|
|
3343
|
-
this.currentPlan =
|
|
3344
|
-
this.currentPlanTitle =
|
|
3345
|
-
this.requestedPlan =
|
|
3346
|
-
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;
|
|
3347
3335
|
}
|
|
3348
3336
|
this.contextUpdated = true;
|
|
3349
3337
|
});
|
|
@@ -5049,8 +5037,18 @@ class ContactUsForm extends BaseEditComponent {
|
|
|
5049
5037
|
}
|
|
5050
5038
|
ngOnInit() {
|
|
5051
5039
|
this.createFormGroup();
|
|
5052
|
-
this.appContext.
|
|
5053
|
-
|
|
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
|
+
}
|
|
5054
5052
|
});
|
|
5055
5053
|
}
|
|
5056
5054
|
createFormGroup() {
|
|
@@ -5062,16 +5060,6 @@ class ContactUsForm extends BaseEditComponent {
|
|
|
5062
5060
|
message: new FormControl('', [Validators.required])
|
|
5063
5061
|
});
|
|
5064
5062
|
}
|
|
5065
|
-
setContext(context) {
|
|
5066
|
-
this.isUserSignedIn = context.isUserSignedIn;
|
|
5067
|
-
this.reCaptchaSiteKey = context.reCaptchaSiteKeyV3;
|
|
5068
|
-
this.selectedTopic = this.topicList[3].value;
|
|
5069
|
-
this.setFormValue('topic', this.selectedTopic);
|
|
5070
|
-
if (this.isUserSignedIn) {
|
|
5071
|
-
this.setFormValue('name', context.user.displayNameOrFullName);
|
|
5072
|
-
this.setFormValue('email', context.user.email);
|
|
5073
|
-
}
|
|
5074
|
-
}
|
|
5075
5063
|
isValid() {
|
|
5076
5064
|
return this.formGroup.valid;
|
|
5077
5065
|
}
|