From 84c82dbc12bac2dcdeac70345e6ab4ab650c6fc9 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Tue, 1 Aug 2023 11:56:46 +0300 Subject: [PATCH] UI: Refactoring --- .../modules/home/menu/side-menu.component.ts | 12 +------ .../notification-settings-routing.modules.ts | 34 +++---------------- .../assets/locale/locale.constant-en_US.json | 8 ++--- 3 files changed, 7 insertions(+), 47 deletions(-) diff --git a/ui-ngx/src/app/modules/home/menu/side-menu.component.ts b/ui-ngx/src/app/modules/home/menu/side-menu.component.ts index cf3e5ca4db..f6e1f30624 100644 --- a/ui-ngx/src/app/modules/home/menu/side-menu.component.ts +++ b/ui-ngx/src/app/modules/home/menu/side-menu.component.ts @@ -17,8 +17,6 @@ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { MenuService } from '@core/services/menu.service'; import { MenuSection } from '@core/services/menu.models'; -import { Observable, of } from 'rxjs'; -import { mergeMap, share } from 'rxjs/operators'; @Component({ selector: 'tb-side-menu', @@ -28,23 +26,15 @@ import { mergeMap, share } from 'rxjs/operators'; }) export class SideMenuComponent implements OnInit { - menuSections$: Observable>; + menuSections$ = this.menuService.menuSections(); constructor(private menuService: MenuService) { - this.menuSections$ = this.menuService.menuSections().pipe( - mergeMap((sections) => this.filterSections(sections)), - share() - ); } trackByMenuSection(index: number, section: MenuSection){ return section.id; } - private filterSections(sections: Array): Observable> { - return of(sections.filter(section => !section.disabled)); - } - ngOnInit() { } diff --git a/ui-ngx/src/app/modules/home/pages/notification/settings/notification-settings-routing.modules.ts b/ui-ngx/src/app/modules/home/pages/notification/settings/notification-settings-routing.modules.ts index e6aababc33..3d61e4b227 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/settings/notification-settings-routing.modules.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/settings/notification-settings-routing.modules.ts @@ -14,28 +14,13 @@ /// limitations under the License. /// -import { Resolve, RouterModule, Routes } from '@angular/router'; +import { Routes } from '@angular/router'; import { ConfirmOnExitGuard } from '@core/guards/confirm-on-exit.guard'; import { Authority } from '@shared/models/authority.enum'; -import { Injectable, NgModule } from '@angular/core'; +import { inject, NgModule } from '@angular/core'; import { NotificationSettingsComponent } from '@home/pages/notification/settings/notification-settings.component'; -import { Store } from '@ngrx/store'; -import { AppState } from '@core/core.state'; -import { Observable } from 'rxjs'; import { NotificationService } from '@core/http/notification.service'; -@Injectable() -export class NotificationUserSettingsResolver implements Resolve { - - constructor(private store: Store, - private notificationService: NotificationService) { - } - - resolve(): Observable { - return this.notificationService.getNotificationUserSettings(); - } -} - export const notificationUserSettingsRoutes: Routes = [ { path: 'notificationSettings', @@ -50,21 +35,10 @@ export const notificationUserSettingsRoutes: Routes = [ } }, resolve: { - userSettings: NotificationUserSettingsResolver + userSettings: () => inject(NotificationService).getNotificationUserSettings() } } ]; -const routes: Routes = [ - { - path: 'notificationSettings', - redirectTo: '/account/notificationSettings' - } -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule], - providers: [NotificationUserSettingsResolver] -}) +@NgModule({}) export class NotificationSettingsRoutingModules { } diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index dadc52e670..bc22dfb195 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -11,7 +11,8 @@ "permission-denied-text": "You don't have permission to perform this operation!" }, "account": { - "account": "Account" + "account": "Account", + "notification-settings": "Notification settings" }, "action": { "activate": "Activate", @@ -3221,11 +3222,6 @@ "profiles": { "profiles": "Profiles" }, - "account": { - "account": "Account", - "personal-info": "Personal info", - "notification-settings": "Notification settings" - }, "security": { "security": "Security", "general-settings": "General security settings",