File

src/app/side-nav/side-nav.component.ts

Description

This component displays and manages the sidemenu showing the name of the current project at the top. Beneath it navigation points e.g. 'Graph' are displayed.

Metadata

selector app-side-nav
styleUrls ./side-nav.component.scss
templateUrl ./side-nav.component.html

Index

Properties

Constructor

constructor(ss: StateService, router: Router, notify: UserNotifyService)
Parameters :
Name Type Optional
ss StateService No
router Router No
notify UserNotifyService No

Properties

Readonly defaultMenuTitle
Type : string
Default value : 'Menu'
graphLink
Type : []
Default value : ['/']
issuesLink
Type : []
Default value : ['/']
membersLink
Type : []
Default value : ['/']
Public menuTitle
Default value : this.defaultMenuTitle
Public notify
Type : UserNotifyService
overviewLink
Type : []
Default value : ['/']
Public router
Type : Router
Public ss
Type : StateService
import {Component} from '@angular/core';
import {StateService} from '@app/state.service';
import {Router} from '@angular/router';
import {UserNotifyService} from '@app/user-notify/user-notify.service';

/**
 * This component displays and manages the sidemenu showing
 * the name of the current project at the top. Beneath it
 * navigation points e.g. 'Graph' are displayed.
 */
@Component({
  selector: 'app-side-nav',
  templateUrl: './side-nav.component.html',
  styleUrls: ['./side-nav.component.scss']
})
export class SideNavComponent {
  readonly defaultMenuTitle = 'Menu';
  public menuTitle = this.defaultMenuTitle;
  overviewLink = ['/'];
  graphLink = ['/'];
  issuesLink = ['/'];
  membersLink = ['/'];

  constructor(public ss: StateService, public router: Router, public notify: UserNotifyService) {
    ss.state$.subscribe((appState) => {
      if (!appState.project) {
        return;
      }

      if (appState.project.node) {
        this.menuTitle = appState.project.node.name;
        this.overviewLink = ['/projects', appState.project.node.id];
        this.graphLink = ['/projects', appState.project.node.id, 'graph'];
        this.issuesLink = ['/projects', appState.project.node.id, 'issues'];
        this.membersLink = ['/projects', appState.project.node.id, 'members'];
      } else {
        this.router.navigate(['/']);
        notify.notifyError('The specified project does not exist!');
      }
    });
  }
}
<mat-toolbar>{{ menuTitle }}</mat-toolbar>
<mat-nav-list>
  <mat-list-item [routerLink]="overviewLink" routerLinkActive="list-item-active" [routerLinkActiveOptions]="{ exact: true }">
    <mat-icon>info</mat-icon>
    <a>Overview</a>
  </mat-list-item>
  <mat-list-item [routerLink]="graphLink" routerLinkActive="list-item-active" [routerLinkActiveOptions]="{ exact: true }">
    <mat-icon>account_tree</mat-icon>
    <a>Graph</a>
  </mat-list-item>
  <mat-list-item [routerLink]="issuesLink" routerLinkActive="list-item-active" [routerLinkActiveOptions]="{ exact: true }">
    <mat-icon>bug_report</mat-icon>
    <a>Issues</a>
  </mat-list-item>
  <mat-list-item [routerLink]="membersLink" routerLinkActive="list-item-active" [routerLinkActiveOptions]="{ exact: true }">
    <mat-icon>group</mat-icon>
    <a>Members</a>
  </mat-list-item>
</mat-nav-list>

./side-nav.component.scss

@import "~@angular/material/theming";
@import "variables";

mat-icon {
  color: rgba(0, 0, 0, 0.54);
  margin-right: 20px;
  padding-left: 4px;
}

.list-item-active {
  font-weight: bold;
  background-color: mat-color($accent, 300) !important;
}

mat-nav-list {
  padding-top: 0;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""