Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added all dev pushes to master #19

Merged
merged 9 commits into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ APP_SECRET=86f8e46e16865da05c3cbe1137e8aa22
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
DATABASE_URL="mysql://root:[email protected]:3306/symfony?serverVersion=8.0.27"
DATABASE_URL="mysql://root:@127.0.0.1:3306/symfony"
#DATABASE_URL="postgresql://root:[email protected]:3306/db_name?serverVersion=13&charset=utf8"
# DATABASE_URL="mysql://root:[email protected]:3306/symfony?serverVersion=8.0.27"
#DATABASE_URL="postgresql://db_user:[email protected]:3306/db_name?serverVersion=13&charset=utf8"
###< doctrine/doctrine-bundle ###

Expand Down
Empty file removed migrations/.gitignore
Empty file.
2 changes: 1 addition & 1 deletion public/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php

use App\Kernel;

Expand Down
21 changes: 19 additions & 2 deletions public/javascript/script.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
function goBack() {
window.history.back();
var baseUrl = 'http://127.0.0.1:8000/';

function goBack(currentUrl) {

if (currentUrl.includes("/categories")) {
window.location.replace(baseUrl);
}

if (currentUrl.includes("/category/")) {
window.location.replace(baseUrl + "categories");
}

if (currentUrl.includes("/meals/")) {
window.location.replace(localStorage.getItem('categoryId'));
}

if (currentUrl.includes("/matches/")) {
window.location.replace(localStorage.getItem('mealId'));
}
}
22 changes: 21 additions & 1 deletion public/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,24 @@ button {
.imageWine {
max-width: 200px;
max-height: 200px;
}
}

/* ---------------------- price slider ----------------------------------*/

.ui-page-theme-a .ui-btn {
background-color: #d9534f!important;
color: #fff!important;
}

.ui-page-theme-a .ui-slider-track .ui-btn-active {
background-color: #b5191f!important;
border-color: #b5191f!important;
color: #fff;
text-shadow: 0 1px 0 #b5191f!important;
}

.ui-page-theme-a .ui-body-inherit::before {
content: "€"!important;
}

/* ---------------- end price slider ---------------------------------------- */
52 changes: 34 additions & 18 deletions src/Controller/MealController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,77 +7,93 @@
use App\Service\MealMatcherService;
use GuzzleHttp\Exception\GuzzleException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;


class MealController extends AbstractController
{

private $requestStack;

public function __construct(RequestStack $requestStack)
{
$this->requestStack = $requestStack;
}

/**
* @throws GuzzleException
*
* @Route("/", name="landing_page")
*/
#[Route('/', name: 'landing_page')]
public function getIndex(MealMatcherService $mealMatcherService): Response
{
return $this->render('landing/index.html.twig', ['choices' => $mealMatcherService->getIndexPage()]);
}

/**
* @throws GuzzleException
*
* @Route("/categories", name="meal_categories")
*/
#[Route('/categories', name: 'meal_categories')]
public function getMealCategories(MealMatcherService $mealMatcherService): Response
{
return $this->render('categories/index.html.twig', ['meals' => $mealMatcherService->getParentMealCategories()]);
}

/**
* @throws GuzzleException
*
* @Route("/category/{parentId}", name="meal_categories_for_parent")
*/
#[Route('/category/{parentId}', name: 'meal_categories_for_parent')]
public function getCategoriesForParent(int $parentId, MealMatcherService $mealMatcherService): Response
{
return $this->render('categories/index.html.twig', ['meals' => $mealMatcherService->getCategoriesForParent($parentId)]);
}

/**
* @throws GuzzleException
*
* @Route("/meals/{categoryId}", name="meals_for_category")
*/
#[Route('/meals/{categoryId}', name: 'meals_for_category')]
public function getMealsForCategory(int $categoryId, MealMatcherService $mealMatcherService): Response
{
return $this->render('meals/index.html.twig', ['meals' => $mealMatcherService->getMealsForCategory($categoryId)]);
}

/**
* @throws GuzzleException
*
* @Route("/matches/{mealId}", name="wines_for_meals")
*/
public function getWinesForMeals(ProductRepository $products, $mealId, MealMatcherService $mealMatcherService): Response
#[Route('matches/{mealId}', name: 'wines_for_meals')]
public function getWinesForMeals(Request $request, ProductRepository $products, $mealId, MealMatcherService $mealMatcherService): Response
{
$matches = [];
// dd($mealMatcherService->getWinesForMeal($mealId));

$session = $this->requestStack->getSession();
$session->set('mealId', array('mealId' => $mealId));

$formMinPrice = $request->query->get('price-min');
if ($formMinPrice === null) {
$formMinPrice = 0;
}
$formMaxPrice = $request->query->get('price-max');
if ($formMaxPrice === null) {
$formMaxPrice = 5000;
}


foreach ($mealMatcherService->getWinesForMeal($mealId) as $wine) {
$product = $products->findOneBy(['sku' => $wine->wine->sku]);
// $product = $products->findOneBy(['sku' => $wine->wine->sku]);
$product = $products->findBySkuAndPrice($wine->wine->sku, $formMinPrice, $formMaxPrice);
if ($product !== null) {
$score = $wine->score;
$productMatch = new ProductMatch($product, $score);
$matches[] = $productMatch;
// $score'' = $product;

//TODO: Scores toevoegen aan de wijn
}
}

return $this->render('wines/index.html.twig', [
'matches' => $matches
'matches' => $matches,
'min_price' => $formMinPrice,
'max_price' => $formMaxPrice
]);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20211102200438 extends AbstractMigration
final class Version20211104082645 extends AbstractMigration
{
public function getDescription(): string
{
Expand Down
29 changes: 16 additions & 13 deletions src/Repository/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,25 @@ public function __construct(ManagerRegistry $registry)
parent::__construct($registry, Product::class);
}

// /**
// * @return Product[] Returns an array of Product objects
// */
/*
public function findByExampleField($value)
public function findBySkuAndPrice(string $sku, float $minPrice, float $maxPrice)
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->orderBy('p.id', 'ASC')
->setMaxResults(10)
$products = $this->createQueryBuilder('p')
->andWhere('p.sku = :sku')
->andWhere('p.price >= :minPrice')
->andWhere('p.price <= :maxPrice')
->setParameter('sku', $sku)
->setParameter('minPrice', $minPrice)
->setParameter('maxPrice', $maxPrice)
// ->orderBy('p.id', 'ASC')
// ->setMaxResults(10)
->getQuery()
->getResult()
;
->getResult();
if (count($products) > 0) {
return $products[0];
}
return null;
}
*/


/*
public function findOneBySomeField($value): ?Product
Expand Down
6 changes: 5 additions & 1 deletion templates/categories/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<img src='https://www.grandcruwijnen.nl/static/version1634749600/frontend/Grandcruwijnen/default/nl_NL/images/logo.svg'
alt='logo' class="logo">
<button style="" type="button" class="btn btn-danger btn-sm" data-toggle="modal" onclick='goBack()'><i
<button style="" type="button" class="btn btn-danger btn-sm" data-toggle="modal" onclick='goBack(window.location.href)'><i
class="fa fa-arrow-left" aria-hidden="true"></i> Terug
</button>
<div class="text">
Expand All @@ -41,6 +41,10 @@
</section>

{% else %}
<script>
localStorage.removeItem('categoryId');
localStorage.setItem('categoryId',window.location.href);
</script>
<section class="grid-sub">
<a href="{{ path('meals_for_category', {categoryId: meal.categoryId}) }}" class="meal-name" style='heigth:50px;'>
{{ meal.name }}
Expand Down
6 changes: 5 additions & 1 deletion templates/meals/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{# https://mealmatcher.grandcruwijnen.nl/meals/%7B12de8bb3-8ce2-43a9-8b09-d56161365ebc%7D #}
<img src='https://www.grandcruwijnen.nl/static/version1634749600/frontend/Grandcruwijnen/default/nl_NL/images/logo.svg'
alt='logo' class="logo_landing_page">
<button type="button" class="btn btn-danger btn-sm" data-toggle="modal" onclick='goBack()'><i
<button type="button" class="btn btn-danger btn-sm" data-toggle="modal" onclick='goBack(window.location.href)'><i
class="fa fa-arrow-left" aria-hidden="true"></i> Terug
</button>
<div class="example-wrapper" style='text-align:center; padding-bottom:50px;'>
Expand All @@ -29,6 +29,10 @@
<div class="container" style='width:100%;'>
<div class="row" id="row">
{% for meal in meals %}
<script>
localStorage.removeItem('mealId');
localStorage.setItem('mealId',window.location.href);
</script>
<div class="col-sm-3" id="column">
<img src="https://mealmatcher.grandcruwijnen.nl/meals/{{ meal.id }}" alt="{{ meal.name }}"
class="mealImage">
Expand Down
Loading