From e53b40f8af860c0c9d1cd94503373ac85a15dda2 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Wed, 24 Apr 2024 13:14:37 +0300 Subject: [PATCH 1/3] UI: Revert blur in json-content.component --- .../shared/components/json-content.component.ts | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/ui-ngx/src/app/shared/components/json-content.component.ts b/ui-ngx/src/app/shared/components/json-content.component.ts index dfcfcfbf3f..d79feacfbc 100644 --- a/ui-ngx/src/app/shared/components/json-content.component.ts +++ b/ui-ngx/src/app/shared/components/json-content.component.ts @@ -18,13 +18,11 @@ import { ChangeDetectorRef, Component, ElementRef, - EventEmitter, forwardRef, Input, OnChanges, OnDestroy, OnInit, - Output, SimpleChanges, ViewChild, ViewEncapsulation @@ -104,9 +102,6 @@ export class JsonContentComponent implements OnInit, ControlValueAccessor, Valid @coerceBoolean() required: boolean; - @Output() - blur: EventEmitter = new EventEmitter(); - fullscreen = false; contentBody: string; @@ -116,7 +111,6 @@ export class JsonContentComponent implements OnInit, ControlValueAccessor, Valid errorShowed = false; private propagateChange = null; - private onTouched = () => {}; constructor(public elementRef: ElementRef, protected store: Store, @@ -156,14 +150,12 @@ export class JsonContentComponent implements OnInit, ControlValueAccessor, Valid this.updateView(); } }); - this.jsonEditor.on('blur', () => { - if (this.validateContent) { + if (this.validateContent) { + this.jsonEditor.on('blur', () => { this.contentValid = this.doValidate(true); this.cd.markForCheck(); - } - this.onTouched(); - this.blur.next(); - }); + }); + } if (this.tbPlaceholder && this.tbPlaceholder.length) { this.createPlaceholder(); @@ -251,7 +243,6 @@ export class JsonContentComponent implements OnInit, ControlValueAccessor, Valid } registerOnTouched(fn: any): void { - this.onTouched = fn; } setDisabledState(isDisabled: boolean): void { From 87cb4c41fd09dab6e91c3f0f78b6cb1cd7f36e53 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Wed, 24 Apr 2024 13:15:25 +0300 Subject: [PATCH 2/3] UI: Improved detect auth user in load --- ui-ngx/src/app/app.component.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ui-ngx/src/app/app.component.ts b/ui-ngx/src/app/app.component.ts index cf53929e54..ed289d6e67 100644 --- a/ui-ngx/src/app/app.component.ts +++ b/ui-ngx/src/app/app.component.ts @@ -28,10 +28,9 @@ import { DomSanitizer } from '@angular/platform-browser'; import { MatIconRegistry } from '@angular/material/icon'; import { combineLatest } from 'rxjs'; import { getCurrentAuthState, selectIsAuthenticated, selectIsUserLoaded } from '@core/auth/auth.selectors'; -import { distinctUntilChanged, filter, map, skip, tap } from 'rxjs/operators'; +import { debounceTime, filter, map, skip, tap } from 'rxjs/operators'; import { AuthService } from '@core/auth/auth.service'; import { svgIcons, svgIconsUrl } from '@shared/models/icon.models'; -import { isEqual } from '@core/utils'; import { ActionSettingsChangeLanguage } from '@core/settings/settings.actions'; import { SETTINGS_KEY } from '@core/settings/settings.effects'; @@ -94,9 +93,9 @@ export class AppComponent implements OnInit { this.store.pipe(select(selectIsAuthenticated)), this.store.pipe(select(selectIsUserLoaded))] ).pipe( + debounceTime(1), map(results => ({isAuthenticated: results[0], isUserLoaded: results[1]})), filter((data) => data.isUserLoaded), - distinctUntilChanged((a, b) => isEqual(a, b)), tap((data) => { let userLang = getCurrentAuthState(this.store).userDetails?.additionalInfo?.lang ?? null; if (!userLang && !data.isAuthenticated) { From fe493335fbc61e56c9f8a654f76eee1d22a67132 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Wed, 24 Apr 2024 16:27:28 +0300 Subject: [PATCH 3/3] UI: Added new selector userReady and change order updated auth state --- ui-ngx/src/app/app.component.ts | 14 ++++---------- ui-ngx/src/app/core/auth/auth.selectors.ts | 6 ++++++ ui-ngx/src/app/core/auth/auth.service.ts | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ui-ngx/src/app/app.component.ts b/ui-ngx/src/app/app.component.ts index ed289d6e67..9ac5bc79a1 100644 --- a/ui-ngx/src/app/app.component.ts +++ b/ui-ngx/src/app/app.component.ts @@ -21,14 +21,13 @@ import { Component, OnInit } from '@angular/core'; import { environment as env } from '@env/environment'; import { TranslateService } from '@ngx-translate/core'; -import { select, Store } from '@ngrx/store'; +import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; import { LocalStorageService } from '@core/local-storage/local-storage.service'; import { DomSanitizer } from '@angular/platform-browser'; import { MatIconRegistry } from '@angular/material/icon'; -import { combineLatest } from 'rxjs'; -import { getCurrentAuthState, selectIsAuthenticated, selectIsUserLoaded } from '@core/auth/auth.selectors'; -import { debounceTime, filter, map, skip, tap } from 'rxjs/operators'; +import { getCurrentAuthState, selectUserReady } from '@core/auth/auth.selectors'; +import { filter, skip, tap } from 'rxjs/operators'; import { AuthService } from '@core/auth/auth.service'; import { svgIcons, svgIconsUrl } from '@shared/models/icon.models'; import { ActionSettingsChangeLanguage } from '@core/settings/settings.actions'; @@ -89,12 +88,7 @@ export class AppComponent implements OnInit { } setupAuth() { - combineLatest([ - this.store.pipe(select(selectIsAuthenticated)), - this.store.pipe(select(selectIsUserLoaded))] - ).pipe( - debounceTime(1), - map(results => ({isAuthenticated: results[0], isUserLoaded: results[1]})), + this.store.select(selectUserReady).pipe( filter((data) => data.isUserLoaded), tap((data) => { let userLang = getCurrentAuthState(this.store).userDetails?.additionalInfo?.lang ?? null; diff --git a/ui-ngx/src/app/core/auth/auth.selectors.ts b/ui-ngx/src/app/core/auth/auth.selectors.ts index fc8fdc18b0..0cb13c9865 100644 --- a/ui-ngx/src/app/core/auth/auth.selectors.ts +++ b/ui-ngx/src/app/core/auth/auth.selectors.ts @@ -42,6 +42,12 @@ export const selectIsUserLoaded = createSelector( (state: AuthState) => state.isUserLoaded ); +export const selectUserReady = createSelector( + selectIsAuthenticated, + selectIsUserLoaded, + (isAuthenticated, isUserLoaded) => ({isAuthenticated, isUserLoaded}) +); + export const selectAuthUser = createSelector( selectAuthState, (state: AuthState) => state.authUser diff --git a/ui-ngx/src/app/core/auth/auth.service.ts b/ui-ngx/src/app/core/auth/auth.service.ts index ea3dfb4143..48018e9317 100644 --- a/ui-ngx/src/app/core/auth/auth.service.ts +++ b/ui-ngx/src/app/core/auth/auth.service.ts @@ -546,14 +546,14 @@ export class AuthService { this.notifyUserLoaded(false); this.loadUser(false).subscribe( (authPayload) => { - this.notifyUserLoaded(true); this.notifyAuthenticated(authPayload); + this.notifyUserLoaded(true); authenticatedSubject.next(true); authenticatedSubject.complete(); }, () => { - this.notifyUserLoaded(true); this.notifyUnauthenticated(); + this.notifyUserLoaded(true); authenticatedSubject.next(false); authenticatedSubject.complete(); }