edk12564 commented on code in PR #32: URL: https://github.com/apache/fineract-consumer-facing/pull/32#discussion_r3502348101
########## frontend/src/app/layout/shell.component.ts: ########## @@ -0,0 +1,140 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { ChangeDetectionStrategy, Component, DestroyRef, inject, signal } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { + NavigationCancel, + NavigationEnd, + NavigationError, + NavigationStart, + Router, + RouterLink, + RouterLinkActive, + RouterOutlet, +} from '@angular/router'; +import { MatButtonModule } from '@angular/material/button'; +import { MatIconModule } from '@angular/material/icon'; +import { MatListModule } from '@angular/material/list'; +import { MatProgressBarModule } from '@angular/material/progress-bar'; +import { MatSidenavModule } from '@angular/material/sidenav'; +import { MatToolbarModule } from '@angular/material/toolbar'; +import { AuthService } from '../core/auth/auth.service'; + +@Component({ + selector: 'app-shell', + changeDetection: ChangeDetectionStrategy.OnPush, + imports: [ + RouterLink, + RouterLinkActive, + RouterOutlet, + MatButtonModule, + MatIconModule, + MatListModule, + MatProgressBarModule, + MatSidenavModule, + MatToolbarModule, + ], + template: ` + @if (loading()) { + <mat-progress-bar mode="indeterminate" /> + } + + <mat-toolbar> + <mat-icon class="brand-icon">account_balance</mat-icon> + <span>Fineract Consumer</span> + <span class="spacer"></span> + <button mat-icon-button aria-label="Logout" (click)="logout()"> + <mat-icon>logout</mat-icon> + </button> + </mat-toolbar> + + <mat-sidenav-container> + <mat-sidenav mode="side" opened> + <mat-nav-list> + <a mat-list-item routerLink="/summary" routerLinkActive="active-link"> + <mat-icon matListItemIcon>dashboard</mat-icon>Summary + </a> + <a mat-list-item routerLink="/savings" routerLinkActive="active-link"> + <mat-icon matListItemIcon>savings</mat-icon>Savings + </a> + <a mat-list-item routerLink="/loans" routerLinkActive="active-link"> + <mat-icon matListItemIcon>request_quote</mat-icon>Loans + </a> + <a mat-list-item routerLink="/transfers" routerLinkActive="active-link"> + <mat-icon matListItemIcon>swap_horiz</mat-icon>Transfers + </a> + </mat-nav-list> + </mat-sidenav> + <mat-sidenav-content> + <main> + <router-outlet /> + </main> + </mat-sidenav-content> + </mat-sidenav-container> + `, + styles: ` + .brand-icon { + margin-right: 0.5rem; + } + .spacer { + flex: 1 1 auto; + } + mat-sidenav-container { + height: calc(100vh - 64px); + } + mat-sidenav { + width: 15rem; + } + main { + padding: 2rem; + } Review Comment: Thanks for the comments Aman. I learned a lot here. But I think I account for this one in the Angular 16+ way with "this.router.events.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event)", which should unsubscribe from the observable when the component is destroyed. I think this is the modern equivalent of the ngOnDestroy + unsubscribe() pattern. Other than that, I just pushed a change to use APPLICATION_JSON constant and a new translation layer and UI element for the frontend, along with a CI check. Please take a look! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
