src/app/side-nav/side-nav.component.ts
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.
selector | app-side-nav |
styleUrls | ./side-nav.component.scss |
templateUrl | ./side-nav.component.html |
Properties |
|
constructor(ss: StateService, router: Router, notify: UserNotifyService)
|
||||||||||||
Defined in src/app/side-nav/side-nav.component.ts:22
|
||||||||||||
Parameters :
|
Readonly defaultMenuTitle |
Type : string
|
Default value : 'Menu'
|
Defined in src/app/side-nav/side-nav.component.ts:17
|
graphLink |
Type : []
|
Default value : ['/']
|
Defined in src/app/side-nav/side-nav.component.ts:20
|
issuesLink |
Type : []
|
Default value : ['/']
|
Defined in src/app/side-nav/side-nav.component.ts:21
|
membersLink |
Type : []
|
Default value : ['/']
|
Defined in src/app/side-nav/side-nav.component.ts:22
|
Public menuTitle |
Default value : this.defaultMenuTitle
|
Defined in src/app/side-nav/side-nav.component.ts:18
|
Public notify |
Type : UserNotifyService
|
Defined in src/app/side-nav/side-nav.component.ts:24
|
overviewLink |
Type : []
|
Default value : ['/']
|
Defined in src/app/side-nav/side-nav.component.ts:19
|
Public router |
Type : Router
|
Defined in src/app/side-nav/side-nav.component.ts:24
|
Public ss |
Type : StateService
|
Defined in src/app/side-nav/side-nav.component.ts:24
|
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;
}