forked from DHBW-FN-TIT20/essensfindung
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
193 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
function change_recipe_url() { | ||
var length_int = get_length() | ||
if (length_int == 0) { | ||
var length = 900; | ||
} else if (length_int == 1) { | ||
var length = 1800; | ||
} else if (length_int == 2) { | ||
var length = 3600; | ||
} else if (length_int == 3) { | ||
var length = 7200; | ||
} else { | ||
var length = 0; | ||
} | ||
var keywords = get_keywords() | ||
document.getElementById("search_recipe").href = "/findrecipe?length=" + length + "&keywords=" + keywords; | ||
} | ||
|
||
function reload_page() { | ||
window.location.reload(true); | ||
} | ||
|
||
function get_keywords() { | ||
return "" | ||
} | ||
|
||
function get_length() { | ||
return document.getElementById('recipe_filter_length').value; | ||
} | ||
|
||
function update_recipe_modal_on_show() { | ||
update_length_text(document.getElementById('recipe_filter_length').value); | ||
} | ||
|
||
function update_length_text(val) { | ||
if (val == 0) { | ||
document.getElementById('recipe_filter_length_text').value = "höchstens 15 min"; | ||
} else if (val == 1) { | ||
document.getElementById('recipe_filter_length_text').value = "höchstens 30 min"; | ||
} else if (val == 2) { | ||
document.getElementById('recipe_filter_length_text').value = "höchstens 60 min"; | ||
} else if (val == 3) { | ||
document.getElementById('recipe_filter_length_text').value = "höchstens 120 min"; | ||
} else { | ||
document.getElementById('recipe_filter_length_text').value = "Länge irrelevant"; | ||
} | ||
} | ||
|
||
function strToArray(commaSeperatedString) { | ||
return commaSeperatedString.split(','); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!-- Modal --> | ||
<div class="modal fade modal-sm modal-lg center" id="recipeFilter" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title" id="staticBackdropLabel">Rezeptfilter</h5> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> | ||
<div class="modal-body"> | ||
<div class="p-2"> | ||
<p>Die Filter werden automatisch gespeichert.</p> | ||
</div> | ||
|
||
<!-- length range --> | ||
<div class="p-2"> | ||
<label for="recipe_filter_length" class="form-label">Länge</label> | ||
<!-- value="recp_filter.length" --> | ||
<input type="range" class="form-range" id="recipe_filter_length" name="recipe_filter_length" min="0" max="4" value="" oninput="update_length_text(this.value)"></input> | ||
<input class="form-label text-center" id="recipe_filter_length_text" value="" readonly></input> | ||
</div> | ||
|
||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">Schließen</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div class="row justify-content-center"> | ||
<div class="col-10" style="max-width: 480px;"> | ||
<nav class="navbar navbar-light bg-white justify-content-between my-2"> | ||
<a class="navbar-brand" href="/rating" style="margin-right:0rem;"> | ||
<img src="/static/img/icons8-star-96.png" width="30" height="30" alt="Bewertungen" class="drop-shadow"> | ||
</a> | ||
<img src="/static/img/essensfinder-draft.png" id="logo" width="30" height="30" alt="logo"> | ||
<a class="navbar-brand" href="/main" style="margin-right:0rem;"> | ||
<img src="/static/img/icons8-home-192.png" width="30" height="30" alt="Home" class="drop-shadow"> | ||
</a> | ||
</nav> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{% extends "shared/layout.html" %} {% block content %} {% include "recipe/recipe_navbar.html" %} | ||
<div class="row justify-content-center"> | ||
<div class="col-10 mb-2" style="max-width: 480px;"> | ||
<h1>{{recipe.name}}</h1> | ||
</div> | ||
</div> | ||
<div class="row justify-content-center"> | ||
<div class="col-10" style="max-width: 480px;"> | ||
<p>{{recipe.ingredients}}</p> | ||
<p>{{recipe.url}}</p> | ||
<p>{{recipe.cookTime}}</p> | ||
<p>{{recipe.prepTime}}</p> | ||
<p>{{recipe.image}}</p> | ||
</div> | ||
</div> | ||
<div class="row justify-content-center"> | ||
<div class="col-10 m-3 text-center" style="max-width: 480px;"> | ||
<a href="/main" class="btn btn-lg btn-dark">TODO: zum Rezept</a> | ||
</div> | ||
</div> | ||
<div class="row justify-content-center"> | ||
<div class="col-10 m-3 text-center" style="max-width: 480px;"> | ||
<img id="recipe-image" index="recipe-image" src="/static/img/glaser.JPG"></img> | ||
</div> | ||
</div> | ||
<div class="row justify-content-center"> | ||
<div class="col-10 text-center m-3" style="max-width: 480px;"> | ||
<a onclick="reload_page()" class="btn btn-dark btn-lg">Erneut suchen!</a> | ||
</div> | ||
</div> | ||
<script src="/static/js/recipe.js"></script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""Router for the Home of the Website""" | ||
from typing import Union | ||
|
||
from datetime import timedelta | ||
import fastapi | ||
from fastapi.responses import HTMLResponse | ||
from sqlalchemy.orm import Session | ||
from starlette.requests import Request | ||
from starlette.templating import Jinja2Templates | ||
|
||
from schemes import scheme_filter | ||
from services import service_rec | ||
from schemes import scheme_cuisine | ||
|
||
|
||
templates = Jinja2Templates("templates") | ||
router = fastapi.APIRouter() | ||
|
||
|
||
@router.get("/findrecipe", response_class=HTMLResponse) | ||
async def findrecipe( | ||
request: Request, | ||
length: int, | ||
keywords: Union[str, None] = None, | ||
): | ||
if length == 0: | ||
total_length = timedelta(days=100) | ||
else: | ||
total_length = timedelta(seconds=length) | ||
rec_filter = scheme_filter.FilterRecipe( | ||
cuisines = [scheme_cuisine.PydanticCuisine(name="Restaurant")], | ||
rating = 1, | ||
keyword = keywords, | ||
total_time = total_length, | ||
) | ||
recipe = service_rec.search_recipe(recipe_filter=rec_filter) | ||
|
||
# TODO: Rezept suchen/auswählen | ||
|
||
return templates.TemplateResponse( | ||
"recipe/recipe_result.html", {"request": request, "recipe": recipe} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters