Display frontend / backend version at the homescreen

This commit is contained in:
Amritanshu Agrawal 2020-10-11 11:13:06 +05:30
parent d677cfb1ea
commit 9ecf0b5cc9
10 changed files with 20 additions and 4 deletions

View File

@ -0,0 +1 @@
__version__ = "1.0.0"

View File

@ -15,6 +15,7 @@ from fastapi.responses import JSONResponse
from fastapi.security import OAuth2PasswordRequestForm from fastapi.security import OAuth2PasswordRequestForm
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
from .. import __version__
from ..core.security import ( from ..core.security import (
Token, Token,
authenticate_user, authenticate_user,
@ -85,6 +86,7 @@ async def login_for_access_token(
), ),
"userId": str(user.id), "userId": str(user.id),
"lockedOut": user.locked_out, "lockedOut": user.locked_out,
"ver": __version__.__version__,
}, },
expires_delta=access_token_expires, expires_delta=access_token_expires,
) )
@ -100,6 +102,7 @@ async def refresh_token(user: UserToken = Security(get_current_active_user)):
"scopes": user.permissions, "scopes": user.permissions,
"userId": str(user.id_), "userId": str(user.id_),
"lockedOut": user.locked_out, "lockedOut": user.locked_out,
"ver": __version__.__version__,
}, },
expires_delta=access_token_expires, expires_delta=access_token_expires,
) )

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "barker" name = "barker"
version = "0.1.0" version = "1.0.0"
description = "Point of Sale for a restaurant" description = "Point of Sale for a restaurant"
authors = ["tanshu <git@tanshu.com>"] authors = ["tanshu <git@tanshu.com>"]

View File

@ -1,6 +1,6 @@
{ {
"name": "bookie", "name": "bookie",
"version": "0.0.0", "version": "1.0.0",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"start": "ng serve", "start": "ng serve",

View File

@ -10,6 +10,7 @@ export class User {
isAuthenticated: boolean; isAuthenticated: boolean;
access_token?: string; access_token?: string;
exp?: number; exp?: number;
ver: string;
public constructor(init?: Partial<User>) { public constructor(init?: Partial<User>) {
Object.assign(this, init); Object.assign(this, init);

View File

@ -198,3 +198,6 @@
<h3 class="item-name">Users</h3> <h3 class="item-name">Users</h3>
</mat-card> </mat-card>
</div> </div>
<footer class="footer">
<p>Backend: v{{ auth.user.ver }} / Frontend: v{{ version }}</p>
</footer>

View File

@ -1,5 +1,6 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { environment } from '../../environments/environment';
import { AuthService } from '../auth/auth.service'; import { AuthService } from '../auth/auth.service';
@Component({ @Component({
@ -8,5 +9,9 @@ import { AuthService } from '../auth/auth.service';
styleUrls: ['./home.component.css'], styleUrls: ['./home.component.css'],
}) })
export class HomeComponent { export class HomeComponent {
constructor(public auth: AuthService) {} version: string;
constructor(public auth: AuthService) {
this.version = environment.version;
}
} }

View File

@ -22,7 +22,8 @@ export class RunningTablesComponent implements OnInit {
navigateToBill(table: Table): void { navigateToBill(table: Table): void {
const qp = { table: table.id }; const qp = { table: table.id };
if (table.voucherId) { if (table.voucherId) {
qp.voucher = table.voucherId; // eslint-disable-next-line @typescript-eslint/dot-notation
qp['voucher'] = table.voucherId;
} }
const navigationExtras: NavigationExtras = { const navigationExtras: NavigationExtras = {
queryParams: qp, queryParams: qp,

View File

@ -1,4 +1,5 @@
export const environment = { export const environment = {
production: true, production: true,
ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry
version: "1.0.0",
}; };

View File

@ -5,6 +5,7 @@
export const environment = { export const environment = {
production: false, production: false,
ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry
version: "1.0.0",
}; };
/* /*