Skip to content

Commit 8c8e96d

Browse files
Merge pull request #373 from AndreWohnsland/dev
Sort available ingredients alphabetically
2 parents 8989316 + 50ab502 commit 8c8e96d

File tree

5 files changed

+52
-9
lines changed

5 files changed

+52
-9
lines changed

.vscode/launch.json

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,48 @@
1717
"justMyCode": true
1818
},
1919
{
20-
"name": "Python: Calibration program",
20+
"name": "Calibration program over CLI",
2121
"type": "debugpy",
2222
"request": "launch",
23-
"program": "${file}",
23+
"program": "${workspaceFolder}/runme.py",
2424
"console": "integratedTerminal",
2525
"justMyCode": true,
2626
"args": ["-c"]
2727
},
2828
{
29-
"name": "Python: Main program in debug mode",
29+
"name": "Main program in debug mode over CLI",
3030
"type": "debugpy",
3131
"request": "launch",
32-
"program": "${file}",
32+
"program": "${workspaceFolder}/runme.py",
3333
"console": "integratedTerminal",
3434
"justMyCode": true,
3535
"args": ["-d"]
3636
},
3737
{
38-
"name": "Debug FastApi over uvicorn",
38+
"name": "Run Backend over CLI",
39+
"type": "debugpy",
40+
"request": "launch",
41+
"program": "${workspaceFolder}/api.py",
42+
"console": "integratedTerminal",
43+
"justMyCode": true
44+
},
45+
{
46+
"name": "Debug FastApi (Backend) over uvicorn",
3947
"type": "debugpy",
4048
"request": "launch",
4149
"module": "uvicorn",
4250
"args": ["src.api.api:app", "--reload"]
4351
},
4452
{
45-
"name": "Debug FastApi over fastapi CLI",
53+
"name": "Debug FastApi (Backend) over fastapi CLI",
4654
"type": "debugpy",
4755
"request": "launch",
4856
"module": "fastapi",
4957
"cwd": "${workspaceFolder}/src/api/",
5058
"args": ["dev", "./api.py"]
5159
},
5260
{
53-
"name": "Run Frontend",
61+
"name": "Node: Run Frontend",
5462
"type": "node",
5563
"request": "launch",
5664
"cwd": "${workspaceFolder}/web_client",

src/api/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from src import __version__
1313
from src.api.api_config import DESCRIPTION, TAGS_METADATA
14+
from src.api.internal.log_config import log_config
1415
from src.api.internal.validation import ValidationError
1516
from src.api.models import ApiMessage
1617
from src.api.routers import bottles, cocktails, ingredients, options
@@ -132,4 +133,4 @@ async def root() -> ApiMessage:
132133

133134

134135
def run_api(port: int = 8000) -> None:
135-
uvicorn.run(app, host="0.0.0.0", port=port)
136+
uvicorn.run(app, host="0.0.0.0", port=port, log_config=log_config)

src/api/internal/log_config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import copy
2+
3+
from uvicorn.config import LOGGING_CONFIG
4+
5+
log_config = copy.deepcopy(LOGGING_CONFIG)
6+
log_config["formatters"]["default"]["fmt"] = "%(asctime)s %(levelprefix)s - %(message)s"
7+
log_config["formatters"]["access"]["fmt"] = (
8+
'%(asctime)s %(levelprefix)s %(client_addr)s - "%(request_line)s" %(status_code)s'
9+
)

web_client/src/components/bottle/ListView.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,17 @@ const ListView: React.FC<ListViewProps> = ({ ingredientList, setSelected, select
1212
setSelected((prev) => (prev.includes(ingredient) ? prev.filter((i) => i !== ingredient) : [...prev, ingredient]));
1313
};
1414

15+
// Sort ingredients: hand=true first, then by name alphabetically
16+
const sortedIngredients = [...ingredientList].sort((a, b) => {
17+
if (a.hand === b.hand) {
18+
return a.name.localeCompare(b.name);
19+
}
20+
return a.hand ? -1 : 1;
21+
});
22+
1523
return (
1624
<div className='h-full overflow-y-auto border-2 border-neutral rounded-md px-2 py-1'>
17-
{ingredientList.map((ingredient) => (
25+
{sortedIngredients.map((ingredient) => (
1826
<div
1927
key={ingredient.id}
2028
onClick={() => handleSelect(ingredient)}

web_client/src/index.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,20 @@ input[type='time']::-webkit-calendar-picker-indicator {
226226
overflow: hidden;
227227
padding-right: var(--scrollbar-width, 15px); /* Prevent layout shift when scrollbar disappears */
228228
}
229+
230+
/* Custom Scrollbar Styling */
231+
/* Chrome, Edge, Safari */
232+
::-webkit-scrollbar {
233+
background: var(--background-color);
234+
}
235+
::-webkit-scrollbar-thumb {
236+
background: var(--primary-color);
237+
}
238+
::-webkit-scrollbar-track {
239+
background: var(--background-color);
240+
}
241+
242+
/* Firefox */
243+
* {
244+
scrollbar-color: var(--primary-color) var(--background-color);
245+
}

0 commit comments

Comments
 (0)