Skip to content

Commit

Permalink
Add a version to the footer #14
Browse files Browse the repository at this point in the history
  • Loading branch information
3ll3d00d committed Jan 22, 2021
1 parent efac362 commit 5eaa385
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/create-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
uses: battila7/get-version-action@v2
- name: Set version
run: |
echo ${{ steps.get_version.outputs.version-without-v }} > VERSION
echo ${{ steps.get_version.outputs.version-without-v }} > ezbeq/VERSION
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
uses: battila7/get-version-action@v2
- name: Set version
run: |
echo ${{ steps.get_version.outputs.version-without-v }} > VERSION
echo ${{ steps.get_version.outputs.version-without-v }} > ezbeq/VERSION
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,4 @@ ui/.eslintcache
ezbeq/ui

.idea
VERSION
ezbeq/VERSION
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include LICENSE
graft ezbeq/ui
include ezbeq/VERSION
2 changes: 1 addition & 1 deletion ezbeq.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get_data_args():
'''
return [
('icons/icon.ico', '.'),
('VERSION', '.'),
('ezbeq/VERSION', '.'),
('ui/build', 'ui')
]

Expand Down
4 changes: 3 additions & 1 deletion ezbeq/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from flask_restful import Api

from ezbeq.catalogue import CatalogueProvider, Authors, Years, AudioTypes, CatalogueSearch, CatalogueMeta
from ezbeq.config import Config
from ezbeq.config import Config, Version
from ezbeq.minidsp import MinidspSender, MinidspBridge, Minidsps, MinidspState

API_PREFIX = '/api/1'
Expand Down Expand Up @@ -42,6 +42,8 @@
api.add_resource(CatalogueSearch, f"{API_PREFIX}/search", resource_class_kwargs=resource_args)
# GET: catalogue meta
api.add_resource(CatalogueMeta, f"{API_PREFIX}/meta", resource_class_kwargs=resource_args)
# GET: app meta
api.add_resource(Version, f"{API_PREFIX}/version", resource_class_kwargs=resource_args)


def main(args=None):
Expand Down
20 changes: 20 additions & 0 deletions ezbeq/config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import logging
import os
import sys
from logging import handlers
from os import environ
from os import path

import yaml
from flask_restful import Resource


class Config:
Expand Down Expand Up @@ -156,3 +158,21 @@ def configure_logger(self):
logger.addHandler(fh)
logger.addHandler(ch)
return logger


class Version(Resource):

def __init__(self, **kwargs):
if getattr(sys, 'frozen', False):
# pyinstaller lets you copy files to arbitrary locations under the _MEIPASS root dir
root = os.path.join(sys._MEIPASS, 'ui')
else:
root = os.path.dirname(__file__)
v_name = os.path.join(root, 'VERSION')
self.__v = 'UNKNOWN'
if os.path.exists(v_name):
with open(v_name, 'r') as f:
self.__v = f.read()

def get(self):
return {'version': self.__v}
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
with open('README.md') as f:
readme = f.read()

if os.path.exists('VERSION'):
with open('VERSION', 'r') as f:
if os.path.exists('ezbeq/VERSION'):
with open('ezbeq/VERSION', 'r') as f:
version = f.read()
else:
version = '0.0.1-alpha.1+dirty'
Expand Down
18 changes: 14 additions & 4 deletions ui/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const App = () => {
const [years, setYears] = useState([]);
const [audioTypes, setAudioTypes] = useState([]);
const [meta, setMeta] = useState({});
const [version, setVersion] = useState({});
// filtered catalogue data
const [filteredEntries, setFilteredEntries] = useState([]);
const [filteredYears, setFilteredYears] = useState([]);
Expand Down Expand Up @@ -136,6 +137,10 @@ const App = () => {
pushData(setMeta, ezbeq.getMeta);
}, []);

useEffect(() => {
pushData(setVersion, ezbeq.getVersion);
}, []);

const combineMinidspState = state => {
setMinidspConfigSlots(state.slots.map(s => Object.assign(s, {active: state.active !== null && state.active === s.id})));
};
Expand Down Expand Up @@ -370,12 +375,17 @@ const App = () => {
: null
}
{
meta
meta || version
?
<Grid container justify="center" className={classes.noLeft}>
<Grid container justify="space-around" className={classes.noLeft}>
<Grid item>
<Typography variant={'caption'} color={'textSecondary'}>
{meta ? `BEQCatalogue: ${formatSeconds(meta.created)}` : ''}
</Typography>
</Grid>
<Grid item>
<Typography align={'center'} variant={'caption'} color={'textSecondary'}>
BEQCatalogue: {formatSeconds(meta.created)}
<Typography variant={'caption'} color={'textSecondary'}>
{version.version !== 'UNKNOWN' ? `v${version.version}` : version.version}
</Typography>
</Grid>
</Grid>
Expand Down
4 changes: 4 additions & 0 deletions ui/src/services/ezbeq.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class EzBeqService {
return this.doGet('meta');
}

getVersion = () => {
return this.doGet('version');
}

doGet = async (payload) => {
const response = await fetch(`${API_PREFIX}/${payload}`, {
method: 'GET'
Expand Down

0 comments on commit 5eaa385

Please sign in to comment.