From 2d6dba7772207e46dbcc6291eb468c430467aece Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Tue, 23 Jan 2024 15:27:53 +0200 Subject: [PATCH] UI: Refactoring --- .../vc/repository-settings.component.html | 2 +- .../vc/repository-settings.component.ts | 2 ++ .../vc/version-control.component.html | 2 +- ui-ngx/src/app/modules/home/home.component.ts | 10 +++++----- .../home/pages/admin/admin-routing.module.ts | 3 --- .../pages/admin/oauth2-settings.component.ts | 20 +++++++++++++++---- .../admin/security-settings.component.ts | 13 ++++++------ .../two-factor-auth-settings.component.ts | 5 ++++- .../modules/home/pages/home-pages.models.ts | 4 ++++ 9 files changed, 40 insertions(+), 21 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/vc/repository-settings.component.html b/ui-ngx/src/app/modules/home/components/vc/repository-settings.component.html index e0d33fdfd5..7ba277364d 100644 --- a/ui-ngx/src/app/modules/home/components/vc/repository-settings.component.html +++ b/ui-ngx/src/app/modules/home/components/vc/repository-settings.component.html @@ -28,7 +28,7 @@ -
+
diff --git a/ui-ngx/src/app/modules/home/components/vc/repository-settings.component.ts b/ui-ngx/src/app/modules/home/components/vc/repository-settings.component.ts index b2af171353..2cdef0dea4 100644 --- a/ui-ngx/src/app/modules/home/components/vc/repository-settings.component.ts +++ b/ui-ngx/src/app/modules/home/components/vc/repository-settings.component.ts @@ -34,6 +34,7 @@ import { selectHasRepository } from '@core/auth/auth.selectors'; import { catchError, mergeMap, take } from 'rxjs/operators'; import { of } from 'rxjs'; import { TbPopoverComponent } from '@shared/components/popover.component'; +import { coerceBoolean } from '@shared/decorators/coercion'; @Component({ selector: 'tb-repository-settings', @@ -49,6 +50,7 @@ export class RepositorySettingsComponent extends PageComponent implements OnInit popoverComponent: TbPopoverComponent; @Input() + @coerceBoolean() hideLoadingBar = false; repositorySettingsForm: UntypedFormGroup; diff --git a/ui-ngx/src/app/modules/home/components/vc/version-control.component.html b/ui-ngx/src/app/modules/home/components/vc/version-control.component.html index 566c1b149f..eb4b1d962b 100644 --- a/ui-ngx/src/app/modules/home/components/vc/version-control.component.html +++ b/ui-ngx/src/app/modules/home/components/vc/version-control.component.html @@ -17,7 +17,7 @@ --> diff --git a/ui-ngx/src/app/modules/home/home.component.ts b/ui-ngx/src/app/modules/home/home.component.ts index 3042061bb5..f88cdc9dec 100644 --- a/ui-ngx/src/app/modules/home/home.component.ts +++ b/ui-ngx/src/app/modules/home/home.component.ts @@ -15,7 +15,7 @@ /// import { AfterViewInit, Component, ElementRef, Inject, OnDestroy, OnInit, ViewChild } from '@angular/core'; -import { startWith, skip, Subject } from 'rxjs'; +import { skip, startWith, Subject } from 'rxjs'; import { Store } from '@ngrx/store'; import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators'; @@ -151,10 +151,10 @@ export class HomeComponent extends PageComponent implements AfterViewInit, OnIni this.textSearch.reset('', {emitEvent: false}); this.activeComponent = activeComponent; let showLoadingBar: boolean; - if (isDefined(this.route.children[0]?.snapshot?.data?.showLoadingBar)) { - showLoadingBar = this.route.children[0]?.snapshot?.data?.showLoadingBar; - } else if (isDefined(this.route.children[0]?.children[0]?.snapshot?.data?.showLoadingBar)) { - showLoadingBar = this.route.children[0]?.children[0]?.snapshot?.data?.showLoadingBar; + if (isDefined(this.activeComponent.activatedRoute?.data?.value?.showLoadingBar)) { + showLoadingBar = this.activeComponent.activatedRoute?.data?.value?.showLoadingBar; + } else if (isDefined(this.activeComponent?.showLoadingBar)) { + showLoadingBar = this.activeComponent.showLoadingBar; } if (activeComponent && activeComponent instanceof RouterTabsComponent) { this.hideLoadingBar = isDefinedAndNotNull(showLoadingBar) ? !showLoadingBar : true; diff --git a/ui-ngx/src/app/modules/home/pages/admin/admin-routing.module.ts b/ui-ngx/src/app/modules/home/pages/admin/admin-routing.module.ts index c91448c7d7..74c5012791 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/admin-routing.module.ts +++ b/ui-ngx/src/app/modules/home/pages/admin/admin-routing.module.ts @@ -323,7 +323,6 @@ const routes: Routes = [ canDeactivate: [ConfirmOnExitGuard], data: { auth: [Authority.SYS_ADMIN], - showLoadingBar: false, title: 'admin.general', breadcrumb: { label: 'admin.general', @@ -337,7 +336,6 @@ const routes: Routes = [ canDeactivate: [ConfirmOnExitGuard], data: { auth: [Authority.SYS_ADMIN], - showLoadingBar: false, title: 'admin.2fa.2fa', breadcrumb: { label: 'admin.2fa.2fa', @@ -351,7 +349,6 @@ const routes: Routes = [ canDeactivate: [ConfirmOnExitGuard], data: { auth: [Authority.SYS_ADMIN], - showLoadingBar: false, title: 'admin.oauth2.oauth2', breadcrumb: { label: 'admin.oauth2.oauth2', diff --git a/ui-ngx/src/app/modules/home/pages/admin/oauth2-settings.component.ts b/ui-ngx/src/app/modules/home/pages/admin/oauth2-settings.component.ts index 4b0ba741d3..798b07c461 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/oauth2-settings.component.ts +++ b/ui-ngx/src/app/modules/home/pages/admin/oauth2-settings.component.ts @@ -15,7 +15,14 @@ /// import { Component, Inject, OnDestroy, OnInit } from '@angular/core'; -import { AbstractControl, UntypedFormArray, UntypedFormBuilder, UntypedFormGroup, ValidationErrors, Validators } from '@angular/forms'; +import { + AbstractControl, + UntypedFormArray, + UntypedFormBuilder, + UntypedFormGroup, + ValidationErrors, + Validators +} from '@angular/forms'; import { ClientAuthenticationMethod, DomainSchema, @@ -26,9 +33,11 @@ import { MapperConfigType, OAuth2ClientRegistrationTemplate, OAuth2DomainInfo, - OAuth2Info, OAuth2MobileInfo, + OAuth2Info, + OAuth2MobileInfo, OAuth2ParamsInfo, - OAuth2RegistrationInfo, PlatformType, + OAuth2RegistrationInfo, + PlatformType, platformTypeTranslations, TenantNameStrategy } from '@shared/models/oauth2.models'; @@ -45,13 +54,14 @@ import { TranslateService } from '@ngx-translate/core'; import { isDefined, isDefinedAndNotNull, randomAlphanumeric } from '@core/utils'; import { OAuth2Service } from '@core/http/oauth2.service'; import { ActivatedRoute } from '@angular/router'; +import { HasShowLoading } from '@home/pages/home-pages.models'; @Component({ selector: 'tb-oauth2-settings', templateUrl: './oauth2-settings.component.html', styleUrls: ['./oauth2-settings.component.scss', './settings-card.scss'] }) -export class OAuth2SettingsComponent extends PageComponent implements OnInit, HasConfirmForm, OnDestroy { +export class OAuth2SettingsComponent extends PageComponent implements OnInit, HasConfirmForm, HasShowLoading, OnDestroy { constructor(protected store: Store, private route: ActivatedRoute, @@ -105,6 +115,8 @@ export class OAuth2SettingsComponent extends PageComponent implements OnInit, Ha templateProvider = ['Custom']; + showLoadingBar = false; + private loginProcessingUrl: string = this.route.snapshot.data.loginProcessingUrl; private static validateScope(control: AbstractControl): ValidationErrors | null { diff --git a/ui-ngx/src/app/modules/home/pages/admin/security-settings.component.ts b/ui-ngx/src/app/modules/home/pages/admin/security-settings.component.ts index e4fd483eb9..f9449eba33 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/security-settings.component.ts +++ b/ui-ngx/src/app/modules/home/pages/admin/security-settings.component.ts @@ -23,7 +23,8 @@ import { AbstractControl, UntypedFormBuilder, UntypedFormControl, - UntypedFormGroup, ValidationErrors, + UntypedFormGroup, + ValidationErrors, ValidatorFn, Validators } from '@angular/forms'; @@ -35,21 +36,21 @@ import { randomAlphanumeric } from '@core/utils'; import { AuthService } from '@core/auth/auth.service'; import { DialogService } from '@core/services/dialog.service'; import { TranslateService } from '@ngx-translate/core'; -import { forkJoin, Observable, of } from 'rxjs'; -import { MatCheckboxChange } from '@angular/material/checkbox'; -import { AlarmInfo } from '@shared/models/alarm.models'; -import { QueueProcessingStrategyTypes, QueueProcessingStrategyTypesMap } from '@shared/models/queue.models'; +import { Observable, of } from 'rxjs'; +import { HasShowLoading } from '@home/pages/home-pages.models'; @Component({ selector: 'tb-security-settings', templateUrl: './security-settings.component.html', styleUrls: ['./security-settings.component.scss', './settings-card.scss'] }) -export class SecuritySettingsComponent extends PageComponent implements HasConfirmForm { +export class SecuritySettingsComponent extends PageComponent implements HasConfirmForm, HasShowLoading { securitySettingsFormGroup: UntypedFormGroup; jwtSecuritySettingsFormGroup: UntypedFormGroup; + showLoadingBar = false; + private securitySettings: SecuritySettings; private jwtSettings: JwtSettings; diff --git a/ui-ngx/src/app/modules/home/pages/admin/two-factor-auth-settings.component.ts b/ui-ngx/src/app/modules/home/pages/admin/two-factor-auth-settings.component.ts index 5ea4776ff9..208d133e3e 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/two-factor-auth-settings.component.ts +++ b/ui-ngx/src/app/modules/home/pages/admin/two-factor-auth-settings.component.ts @@ -32,13 +32,14 @@ import { isNotEmptyStr } from '@core/utils'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { MatExpansionPanel } from '@angular/material/expansion'; +import { HasShowLoading } from '@home/pages/home-pages.models'; @Component({ selector: 'tb-2fa-settings', templateUrl: './two-factor-auth-settings.component.html', styleUrls: [ './settings-card.scss', './two-factor-auth-settings.component.scss'] }) -export class TwoFactorAuthSettingsComponent extends PageComponent implements OnInit, HasConfirmForm, OnDestroy { +export class TwoFactorAuthSettingsComponent extends PageComponent implements OnInit, HasConfirmForm, HasShowLoading, OnDestroy { private readonly destroy$ = new Subject(); private readonly posIntValidation = [Validators.required, Validators.min(1), Validators.pattern(/^\d*$/)]; @@ -47,6 +48,8 @@ export class TwoFactorAuthSettingsComponent extends PageComponent implements OnI twoFactorAuthProviderType = TwoFactorAuthProviderType; twoFactorAuthProvidersData = twoFactorAuthProvidersData; + showLoadingBar = false; + @ViewChildren(MatExpansionPanel) expansionPanel: QueryList; constructor(protected store: Store, diff --git a/ui-ngx/src/app/modules/home/pages/home-pages.models.ts b/ui-ngx/src/app/modules/home/pages/home-pages.models.ts index 20872e3c65..456bbb6999 100644 --- a/ui-ngx/src/app/modules/home/pages/home-pages.models.ts +++ b/ui-ngx/src/app/modules/home/pages/home-pages.models.ts @@ -31,3 +31,7 @@ export const entityDetailsPageBreadcrumbLabelFunction: BreadCrumbLabelFunction