UI: Refactoring
This commit is contained in:
parent
82cfcaff82
commit
84c82dbc12
@ -17,8 +17,6 @@
|
|||||||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
||||||
import { MenuService } from '@core/services/menu.service';
|
import { MenuService } from '@core/services/menu.service';
|
||||||
import { MenuSection } from '@core/services/menu.models';
|
import { MenuSection } from '@core/services/menu.models';
|
||||||
import { Observable, of } from 'rxjs';
|
|
||||||
import { mergeMap, share } from 'rxjs/operators';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-side-menu',
|
selector: 'tb-side-menu',
|
||||||
@ -28,23 +26,15 @@ import { mergeMap, share } from 'rxjs/operators';
|
|||||||
})
|
})
|
||||||
export class SideMenuComponent implements OnInit {
|
export class SideMenuComponent implements OnInit {
|
||||||
|
|
||||||
menuSections$: Observable<Array<MenuSection>>;
|
menuSections$ = this.menuService.menuSections();
|
||||||
|
|
||||||
constructor(private menuService: MenuService) {
|
constructor(private menuService: MenuService) {
|
||||||
this.menuSections$ = this.menuService.menuSections().pipe(
|
|
||||||
mergeMap((sections) => this.filterSections(sections)),
|
|
||||||
share()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trackByMenuSection(index: number, section: MenuSection){
|
trackByMenuSection(index: number, section: MenuSection){
|
||||||
return section.id;
|
return section.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
private filterSections(sections: Array<MenuSection>): Observable<Array<MenuSection>> {
|
|
||||||
return of(sections.filter(section => !section.disabled));
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,28 +14,13 @@
|
|||||||
/// limitations under the License.
|
/// 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 { ConfirmOnExitGuard } from '@core/guards/confirm-on-exit.guard';
|
||||||
import { Authority } from '@shared/models/authority.enum';
|
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 { 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';
|
import { NotificationService } from '@core/http/notification.service';
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class NotificationUserSettingsResolver implements Resolve<any> {
|
|
||||||
|
|
||||||
constructor(private store: Store<AppState>,
|
|
||||||
private notificationService: NotificationService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve(): Observable<any> {
|
|
||||||
return this.notificationService.getNotificationUserSettings();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const notificationUserSettingsRoutes: Routes = [
|
export const notificationUserSettingsRoutes: Routes = [
|
||||||
{
|
{
|
||||||
path: 'notificationSettings',
|
path: 'notificationSettings',
|
||||||
@ -50,21 +35,10 @@ export const notificationUserSettingsRoutes: Routes = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
userSettings: NotificationUserSettingsResolver
|
userSettings: () => inject(NotificationService).getNotificationUserSettings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const routes: Routes = [
|
@NgModule({})
|
||||||
{
|
|
||||||
path: 'notificationSettings',
|
|
||||||
redirectTo: '/account/notificationSettings'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
@NgModule({
|
|
||||||
imports: [RouterModule.forChild(routes)],
|
|
||||||
exports: [RouterModule],
|
|
||||||
providers: [NotificationUserSettingsResolver]
|
|
||||||
})
|
|
||||||
export class NotificationSettingsRoutingModules { }
|
export class NotificationSettingsRoutingModules { }
|
||||||
|
|||||||
@ -11,7 +11,8 @@
|
|||||||
"permission-denied-text": "You don't have permission to perform this operation!"
|
"permission-denied-text": "You don't have permission to perform this operation!"
|
||||||
},
|
},
|
||||||
"account": {
|
"account": {
|
||||||
"account": "Account"
|
"account": "Account",
|
||||||
|
"notification-settings": "Notification settings"
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
"activate": "Activate",
|
"activate": "Activate",
|
||||||
@ -3221,11 +3222,6 @@
|
|||||||
"profiles": {
|
"profiles": {
|
||||||
"profiles": "Profiles"
|
"profiles": "Profiles"
|
||||||
},
|
},
|
||||||
"account": {
|
|
||||||
"account": "Account",
|
|
||||||
"personal-info": "Personal info",
|
|
||||||
"notification-settings": "Notification settings"
|
|
||||||
},
|
|
||||||
"security": {
|
"security": {
|
||||||
"security": "Security",
|
"security": "Security",
|
||||||
"general-settings": "General security settings",
|
"general-settings": "General security settings",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user