Feature: Made the title configurable

This commit is contained in:
Amritanshu Agrawal 2023-08-23 11:38:59 +05:30
parent b1ca758e9d
commit 56da6b0a82
14 changed files with 66 additions and 4 deletions

1
.env
View File

@ -1,3 +1,4 @@
TITLE="Brewman"
HOST=0.0.0.0
PORT=80
LOG_LEVEL=WARN

View File

@ -7,6 +7,7 @@ from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
# openssl rand -hex 32
TITLE: str = ""
SECRET_KEY: str = secrets.token_urlsafe(32)
MIDDLEWARE_SECRET_KEY: str = secrets.token_urlsafe(5)
ALGORITHM: str = "HS256"

View File

@ -40,6 +40,7 @@ from .routers import (
recipe,
recipe_template,
role,
title,
user,
voucher,
voucher_types,
@ -130,6 +131,7 @@ app.include_router(maintenance.router, prefix="/api/maintenance", tags=["setting
app.include_router(db_integrity.router, prefix="/api/db-integrity", tags=["management"])
app.include_router(rebase.router, prefix="/api/rebase", tags=["management"])
app.include_router(title.router, prefix="/api/title")
def init() -> None:

View File

@ -0,0 +1,11 @@
from fastapi import APIRouter
from ..core.config import settings
router = APIRouter()
@router.get("", response_model=str)
async def get_version() -> str:
return settings.TITLE

View File

@ -1,3 +1,4 @@
TITLE="{{ title }}"
HOST=0.0.0.0
PORT=80
LOG_LEVEL=WARN

View File

@ -1,5 +1,6 @@
---
name: acc
title: "The Great Bear"
http_host: "acc.hopsngrains.com"
http_conf: "acc.hopsngrains.com.conf"

View File

@ -1,5 +1,6 @@
---
name: exp
title: Tanshu
http_host: "exp.tanshu.com"
http_conf: "exp.tanshu.com.conf"

View File

@ -1,5 +1,6 @@
---
name: hinchco
title: Mozimo
http_host: "acc.hinchco.in"
http_conf: "acc.hinchco.in.conf"

View File

@ -1,5 +1,7 @@
---
name: hops
title: "HnG Panchkula"
http_host: "hops.hopsngrains.com"
http_conf: "hops.hopsngrains.com.conf"

View File

@ -1,5 +1,6 @@
---
name: mhl
title: "HnG Mohali"
http_host: "mhl.hopsngrains.com"
http_conf: "mhl.hopsngrains.com.conf"

View File

@ -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>

View File

@ -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();

View 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>;
}
}

View File

@ -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',
};
/*