Feature: Made the title configurable
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
<mat-toolbar class="fixed-to-top">
|
||||
<span class="mr-5"><a routerLink="/">HnG / TGB</a></span>
|
||||
<span class="mr-5"
|
||||
><a routerLink="/">{{ title }}</a></span
|
||||
>
|
||||
<mat-menu #voucherMenu="matMenu">
|
||||
<a mat-menu-item routerLink="/journal">Journal</a>
|
||||
<a mat-menu-item routerLink="/purchase">Purchase</a>
|
||||
|
||||
@ -1,18 +1,30 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { AuthService } from '../../auth/auth.service';
|
||||
import { TitleService } from '../title.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-nav-bar',
|
||||
templateUrl: './nav-bar.component.html',
|
||||
styleUrls: ['./nav-bar.component.css'],
|
||||
})
|
||||
export class NavBarComponent {
|
||||
export class NavBarComponent implements OnInit {
|
||||
title: string;
|
||||
constructor(
|
||||
private router: Router,
|
||||
public auth: AuthService,
|
||||
) {}
|
||||
public titleService: TitleService,
|
||||
) {
|
||||
this.title = environment.title;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.titleService.get().subscribe((value) => {
|
||||
this.title = value;
|
||||
});
|
||||
}
|
||||
|
||||
logout() {
|
||||
this.auth.logout();
|
||||
|
||||
25
overlord/src/app/core/title.service.ts
Normal file
25
overlord/src/app/core/title.service.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from './error-logger.service';
|
||||
|
||||
const url = '/api/title';
|
||||
const serviceName = 'VoucherService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class TitleService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private log: ErrorLoggerService,
|
||||
) {}
|
||||
|
||||
get(): Observable<string> {
|
||||
return this.http
|
||||
.get<string>(url)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'Get Title'))) as Observable<string>;
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,7 @@ export const environment = {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry
|
||||
version: '11.3.1',
|
||||
title: 'HnG / TGB',
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user