Skip to content

Commit b8880c4

Browse files
Merge pull request #311 from AndreWohnsland/dev
bump dashboard dependencies
2 parents dd24202 + 7b765c6 commit b8880c4

File tree

17 files changed

+684
-2696
lines changed

17 files changed

+684
-2696
lines changed

.github/workflows/manual-docker-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
with:
4444
context: ${{ contains(github.event.inputs.service, 'service') && './microservice' || contains(github.event.inputs.service, 'backend') && './dashboard/backend' || './dashboard/frontend' }}
4545
file: ${{ contains(github.event.inputs.service, 'service') && './microservice/Dockerfile' || contains(github.event.inputs.service, 'backend') && './dashboard/backend/Dockerfile' || './dashboard/frontend/Dockerfile' }}
46-
platforms: linux/amd64,linux/arm64,linux/arm/v7
46+
platforms: linux/amd64,linux/arm64
4747
push: true
4848
tags: ${{ contains(github.event.inputs.service, 'service') && 'andrewo92/cocktailberry-microservice' || contains(github.event.inputs.service, 'backend') && 'andrewo92/cocktailberry-dashboard-be' || 'andrewo92/cocktailberry-dashboard-fe' }}:latest,${{ contains(github.event.inputs.service, 'service') && 'andrewo92/cocktailberry-microservice' || contains(github.event.inputs.service, 'backend') && 'andrewo92/cocktailberry-dashboard-be' || 'andrewo92/cocktailberry-dashboard-fe' }}:${{ github.event.inputs.version }}
4949
no-cache: true

.github/workflows/release-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
with:
106106
context: ${{ matrix.context }}
107107
file: ${{ matrix.dockerfile }}
108-
platforms: linux/amd64,linux/arm64,linux/arm/v7
108+
platforms: linux/amd64,linux/arm64
109109
push: true
110110
tags: ${{ steps.meta.outputs.tags }}
111111
labels: ${{ steps.meta.outputs.labels }}

dashboard/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# CocktailBerry Dashboard
2+
3+
This is the source code for the CocktailBerry dashboard, which is an optional service of CocktailBerry.
4+
The dashboard provides a web interface and server for the Teams option.
5+
6+
## Getting Started
7+
8+
Use uv to install the dependencies:
9+
10+
```bash
11+
uv sync
12+
```
13+
14+
Then, go in the frontend or backend folder and run the following command:
15+
16+
```bash
17+
uv run index.py # frontend
18+
uv run main.py # backend
19+
```

dashboard/backend/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from typing import Optional
22

33
import uvicorn
4+
from db_controller import DBController
45
from fastapi import FastAPI
56

6-
from db_controller import DBController
77
from models import TeamInfo
88

99
app = FastAPI()

dashboard/backend/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from pydantic import BaseModel
21
from typing import Optional
32

3+
from pydantic import BaseModel
4+
45

56
class TeamInfo(BaseModel):
67
team: str

dashboard/backend/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
fastapi==0.111.0
2-
uvicorn==0.29.0
3-
uvloop==0.20.0
1+
fastapi==0.115.12
2+
uvicorn==0.34.0
3+
uvloop==0.21.0

dashboard/frontend/app.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import dash # type: ignore
1+
import dash
22

33
# meta_tags are required for the app layout to be mobile responsive
4-
app = dash.Dash(__name__, suppress_callback_exceptions=True,
5-
meta_tags=[{'name': 'viewport',
6-
'content': 'width=device-width, initial-scale=1.0'}]
7-
)
4+
app = dash.Dash(
5+
__name__,
6+
suppress_callback_exceptions=True,
7+
meta_tags=[{"name": "viewport", "content": "width=device-width, initial-scale=1.0"}],
8+
)
89
app.title = "Cocktail Dashboard"

dashboard/frontend/callbacks.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1-
import dash
2-
from dash.dependencies import Input, Output # type: ignore
31
import datetime
42

5-
from treemap import generate_treemap, get_plot_data
3+
import dash
64
from app import app
5+
from dash.dependencies import Input, Output
76
from store import store
7+
from treemap import generate_treemap, get_plot_data
88

99

10-
@app.callback(Output('treemap', 'figure'),
11-
Output('timeclock', "children"),
12-
Input('interval-component', 'n_intervals'),
13-
Input('url', 'pathname'))
10+
@app.callback(
11+
Output("treemap", "figure"),
12+
Output("timeclock", "children"),
13+
Input("interval-component", "n_intervals"),
14+
Input("url", "pathname"),
15+
)
1416
def update_plot(n, pathname):
1517
routes = {
1618
"/n_today": 1,
1719
"/vol_today": 2,
1820
"/n_all": 3,
1921
"/vol_all": 4,
2022
}
21-
graphtype = routes.get(pathname, 1)
22-
store.current_graph_type = graphtype
23+
graph_type = routes.get(pathname, 1)
24+
store.current_graph_type = graph_type
2325
df = get_plot_data(store.current_graph_type)
24-
now_time = datetime.datetime.now().strftime('%H:%M')
26+
now_time = datetime.datetime.now().strftime("%H:%M")
2527
trigger_id = dash.callback_context.triggered[0]["prop_id"]
2628
triggered_by_time = trigger_id == "interval-component.n_intervals"
2729
if df.equals(store.last_data) and triggered_by_time:

dashboard/frontend/index.py

Lines changed: 47 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,56 @@
11
# pylint: disable=unused-import
2-
import dash # type: ignore
3-
from dash import dcc # type: ignore
4-
from dash import html # type: ignore
5-
6-
from language import language
7-
import callbacks
2+
import callbacks # noqa: F401
3+
import dash # noqa: F401
84
from app import app
9-
5+
from dash import (
6+
dcc,
7+
html,
8+
)
9+
from language import language
1010

1111
server = app.server
1212
# Connect to your app pages
13-
app.layout = html.Div([
14-
dcc.Location(id='url', refresh=False),
15-
html.Div(
16-
html.Div([
17-
html.Ul(
18-
[html.Li(dcc.Link(language.AMOUNT_TODAY, href='/n_today')),
19-
html.Li(dcc.Link(language.VOLUME_TODAY, href='/vol_today')),
20-
html.Li(dcc.Link(language.AMOUNT_ALL, href='/n_all')),
21-
html.Li(dcc.Link(language.VOLUME_ALL, href='/vol_all'))]
22-
),
23-
html.Div("00:00", id="timeclock", className="clock")
24-
], className="container"), className="navbar"),
25-
html.Div(id='page-content', children=[
26-
html.Div([
27-
dcc.Interval(
28-
id='interval-component',
29-
interval=15 * 1000, # in milliseconds
30-
n_intervals=0
13+
app.layout = html.Div(
14+
[
15+
dcc.Location(id="url", refresh=False),
16+
html.Div(
17+
html.Div(
18+
[
19+
html.Ul(
20+
[
21+
html.Li(dcc.Link(language.AMOUNT_TODAY, href="/n_today")),
22+
html.Li(dcc.Link(language.VOLUME_TODAY, href="/vol_today")),
23+
html.Li(dcc.Link(language.AMOUNT_ALL, href="/n_all")),
24+
html.Li(dcc.Link(language.VOLUME_ALL, href="/vol_all")),
25+
]
26+
),
27+
html.Div("00:00", id="timeclock", className="clock"),
28+
],
29+
className="container",
3130
),
32-
dcc.Graph(figure={}, className="treemap", config={"displayModeBar": False}, id="treemap")
33-
], style={"textAlign": "center"})
34-
])
35-
], className="App")
31+
className="navbar",
32+
),
33+
html.Div(
34+
id="page-content",
35+
children=[
36+
html.Div(
37+
[
38+
dcc.Interval(
39+
id="interval-component",
40+
interval=15 * 1000, # in milliseconds
41+
n_intervals=0,
42+
),
43+
dcc.Graph(figure={}, className="treemap", config={"displayModeBar": False}, id="treemap"),
44+
],
45+
style={"textAlign": "center"},
46+
)
47+
],
48+
),
49+
],
50+
className="App",
51+
)
3652

3753

38-
if __name__ == '__main__':
39-
# app.run_server(debug=True)
54+
if __name__ == "__main__":
4055
print("access the server on http://127.0.0.1:8050/ http://127.0.0.1 or your defined address")
41-
app.run_server(host="0.0.0.0", debug=False, port="8050")
56+
app.run(host="0.0.0.0", debug=False, port="8050")

dashboard/frontend/language.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
from pathlib import Path
3-
from typing import Dict, List, Union
3+
from typing import Union
44

55
import yaml
66
from dotenv import load_dotenv
@@ -11,7 +11,7 @@
1111
# Getting the language file as dict
1212
LANGUAGE_FILE = DIRPATH / "language.yaml"
1313
with open(LANGUAGE_FILE, encoding="UTF-8") as stream:
14-
LANGUAGE_DATA: Dict = yaml.safe_load(stream)
14+
LANGUAGE_DATA: dict = yaml.safe_load(stream)
1515

1616

1717
class Language:
@@ -24,7 +24,7 @@ def __init__(self):
2424
self.AMOUNT_ALL = self._choose_language(LANGUAGE_DATA["amount_all"])
2525
self.VOLUME_ALL = self._choose_language(LANGUAGE_DATA["volume_all"])
2626

27-
def _choose_language(self, element: dict, **kwargs) -> Union[str, List[str]]:
27+
def _choose_language(self, element: dict, **kwargs) -> Union[str, list[str]]:
2828
"""Choose either the given language if exists, or english if not piping additional info into template."""
2929
language = os.getenv("UI_LANGUAGE")
3030
tmpl = element.get(language, element["en"])

0 commit comments

Comments
 (0)