UI: Refactoring
This commit is contained in:
parent
82cfcaff82
commit
84c82dbc12
@ -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<Array<MenuSection>>;
|
||||
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<MenuSection>): Observable<Array<MenuSection>> {
|
||||
return of(sections.filter(section => !section.disabled));
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
|
||||
@ -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<any> {
|
||||
|
||||
constructor(private store: Store<AppState>,
|
||||
private notificationService: NotificationService) {
|
||||
}
|
||||
|
||||
resolve(): Observable<any> {
|
||||
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 { }
|
||||
|
||||
@ -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",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user