1
0
mirror of https://github.com/ToxicCrack/PrintABrick.git synced 2025-05-19 05:30:08 -07:00

Update controllers

This commit is contained in:
David Hübner 2017-03-27 18:33:17 +02:00
parent a6a8f9cd8c
commit 3bd04a3b94
12 changed files with 64 additions and 35 deletions

View File

@ -0,0 +1,5 @@
$(document).ready(function () {
$('.ui.dropdown')
.dropdown()
;
});

View File

@ -0,0 +1,3 @@
.ui.fixed + .ui.main {
margin-top: 5em;
}

View File

@ -0,0 +1,4 @@
@import "variables";
@import "main";

View File

@ -1,6 +1,6 @@
{% extends 'base.html.twig' %} {% extends 'base.html.twig' %}
{% block body %} {% block content %}
{% endblock %} {% endblock %}

View File

@ -1,20 +1,31 @@
{% extends 'base.html.twig' %} {% extends 'base.html.twig' %}
{% block body %} {% block content %}
{{ form_start(form) }} {{ form_start(form) }}
<div class="three fields"> <div class="four fields">
{{ form_row(form.theme) }} {{ form_row(form.theme) }}
{{ form_row(form.subtheme) }} {{ form_row(form.subtheme) }}
{{ form_row(form.years) }} {{ form_row(form.years) }}
<div class="field">
<label>submit</label>
<input type="submit" class="ui button">
</div>
</div> </div>
{{ form_end(form) }} {{ form_end(form) }}
<ul> <div class="ui seven column grid">
{% for set in sets %} <div class="row">
<li><a href="{{ url('set_detail', {'id': set.number~'-'~set.numberVariant, 'name' : set.name|escape('url') }) }}">{{ set.LegoSetID }} - {{ set.name }}</a></li> {% for set in sets %}
{% endfor %} <div class="column">
</ul> <a href="{{ url('set_detail', {'number': set.number~'-'~set.numberVariant, 'name' : set.name|escape('url') }) }}">
<img style="width: 100%" src="{{ set.largeThumbnailURL }}">
<p>{{ set.LegoSetID }} - {{ set.name }}</p>
</a>
</div>
{% endfor %}
</div>
</div>
{% endblock %} {% endblock %}
{% block javascripts %} {% block javascripts %}

View File

@ -1,27 +1,27 @@
{% extends 'base.html.twig' %} {% extends 'base.html.twig' %}
{% block body %} {% block content %}
{{ dump(set) }} {{ dump(set) }}
{{ dump(brset) }} {{ dump(brset) }}
<h1>{{ brset.name }}</h1> <h1>{{brset ? brset.name }}</h1>
<img src="{{ brset.imageURL }}"> <img src="{{brset ? brset.imageURL }}">
{% if set is not null %} {% if set is not null %}
{% for inventory in set.inventories %} {#{% for inventory in set.inventories %}#}
<h2>Parts</h2> <h2>Parts</h2>
<div style="display: flex; flex-wrap: wrap"> <div style="display: flex; flex-wrap: wrap">
{% for inventoryPart in inventory.inventoryParts %} {% for inventoryPart in inventoryParts %}
<div style="height: 150px; width: 150px; padding: 5px; display: inline-block"> <div style="height: 150px; width: 150px; padding: 5px; display: inline-block">
<img src="https://rebrickable.com/media/parts/ldraw/{{ inventoryPart.color.id }}/{{ inventoryPart.part.id }}.png" style="max-height: 90%; max-width: 100%"> <img src="https://rebrickable.com/media/parts/ldraw/{{inventoryPart ? inventoryPart.color.id }}/{{ inventoryPart.part.number }}.png" style="max-height: 90%; max-width: 100%">
<p><a style="color: #{{ inventoryPart.color.rgb }}" href="{{ url('part_detail', {id:inventoryPart.part.id}) }}"><strong>{{ inventoryPart.part.id }}</strong> {{ inventoryPart.quantity }}</a></p> <p><a style="color: #{{ inventoryPart.color.rgb }}" href="{{ url('ldraw_part_show', {number:inventoryPart.part.number}) }}"><strong>{{ inventoryPart.part.number }}</strong> {{ inventoryPart.quantity }}</a></p>
</div> </div>
{% endfor %} {% endfor %}
<div> <div>
{% else %} {#{% else %}#}
{% endfor %} {#{% endfor %}#}
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View File

@ -73,12 +73,9 @@ swiftmailer:
spool: { type: memory } spool: { type: memory }
knp_menu: knp_menu:
# use "twig: false" to disable the Twig extension and the TwigRenderer
twig: twig:
template: KnpMenuBundle::menu.html.twig template: menu/knp_menu.html.twig
# if true, enables the helper for PHP templates
templating: false templating: false
# the renderer to use, list is also available by default
default_renderer: twig default_renderer: twig
knp_paginator: knp_paginator:
@ -89,7 +86,7 @@ knp_paginator:
sort_direction_name: direction # sort direction query parameter name sort_direction_name: direction # sort direction query parameter name
distinct: true # ensure distinct results, useful when ORM queries are using GROUP BY statements distinct: true # ensure distinct results, useful when ORM queries are using GROUP BY statements
template: template:
pagination: KnpPaginatorBundle:Pagination:sliding.html.twig # sliding pagination controls template pagination: KnpPaginatorBundle:Pagination:semantic_ui_pagination.html.twig # sliding pagination controls template
sortable: KnpPaginatorBundle:Pagination:sortable_link.html.twig # sort link template sortable: KnpPaginatorBundle:Pagination:sortable_link.html.twig # sort link template
oneup_flysystem: oneup_flysystem:

View File

@ -32,7 +32,7 @@ class MediaController extends Controller
// Create the disposition of the file // Create the disposition of the file
$disposition = $response->headers->makeDisposition( $disposition = $response->headers->makeDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT, ResponseHeaderBag::DISPOSITION_ATTACHMENT,
$model->getId().'.stl' $model->getNumber().'.stl'
); );
$response->headers->set('Content-Disposition', $disposition); $response->headers->set('Content-Disposition', $disposition);
@ -43,7 +43,7 @@ class MediaController extends Controller
} }
/** /**
* @Route("/part/{id}", name="part_image") * @Route("/part/{number}", name="part_image")
* *
* @return Response * @return Response
*/ */
@ -51,20 +51,20 @@ class MediaController extends Controller
{ {
$mediaFilesystem = $this->get('oneup_flysystem.media_filesystem'); $mediaFilesystem = $this->get('oneup_flysystem.media_filesystem');
if ($mediaFilesystem->has('ldraw'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$part->getId().'.png')) { if ($mediaFilesystem->has('ldraw'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$part->getNumber().'.png')) {
$response = new BinaryFileResponse($mediaFilesystem->getAdapter()->getPathPrefix().DIRECTORY_SEPARATOR.'ldraw'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$part->getId().'.png'); $response = new BinaryFileResponse($mediaFilesystem->getAdapter()->getPathPrefix().DIRECTORY_SEPARATOR.'ldraw'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$part->getNumber().'.png');
$response->headers->set('Content-Type', 'image/png'); $response->headers->set('Content-Type', 'image/png');
// Create the disposition of the file // Create the disposition of the file
$disposition = $response->headers->makeDisposition( $disposition = $response->headers->makeDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT, ResponseHeaderBag::DISPOSITION_ATTACHMENT,
$part->getId().'png' $part->getNumber().'png'
); );
$response->headers->set('Content-Disposition', $disposition); $response->headers->set('Content-Disposition', $disposition);
return $response; return $response;
} }
throw new FileNotFoundException($part->getId().'png'); throw new FileNotFoundException($part->getNumber().'png');
} }
} }

View File

@ -2,7 +2,11 @@
namespace AppBundle\Controller; namespace AppBundle\Controller;
use AppBundle\Entity\Rebrickable\Color;
use AppBundle\Entity\Rebrickable\Inventory_Part;
use AppBundle\Entity\Rebrickable\Part;
use AppBundle\Entity\Rebrickable\Set; use AppBundle\Entity\Rebrickable\Set;
use AppBundle\Entity\Rebrickable\Theme;
use AppBundle\Form\FilterSetType; use AppBundle\Form\FilterSetType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
@ -40,17 +44,25 @@ class SetController extends Controller
} }
/** /**
* @Route("/detail/{id}_{name}", name="set_detail") * @Route("/detail/{number}_{name}", name="set_detail")
*/ */
public function detailAction(Request $request, $id, $name = null) public function detailAction(Request $request, $number, $name = null)
{ {
$brset = $this->get('manager.brickset')->getSetByNumber($id); $brset = $this->get('manager.brickset')->getSetByNumber($number);
$set = $this->get('doctrine.orm.default_entity_manager')->getRepository(Set::class)->find($id); $set = $this->get('doctrine.orm.default_entity_manager')->getRepository(Set::class)->find($number);
$em = $this->getDoctrine()->getManager();
$em->getRepository(Color::class)->findAll();
$em->getRepository(Theme::class)->findAll();
return $this->render('set/detail.html.twig', [ return $this->render('set/detail.html.twig', [
'set' => $set, 'set' => $set,
'brset' => $brset, 'brset' => $brset,
'parts' => $em->getRepository(Part::class)->findAllBySetNumber($number),
'inventoryParts' => $em->getRepository(Inventory_Part::class)->findAllBySetNumber($number),
]); ]);
} }
} }

View File

@ -8,7 +8,6 @@ use AppBundle\Api\Client\Brickset\Entity\Year;
use AppBundle\Api\Manager\BricksetManager; use AppBundle\Api\Manager\BricksetManager;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Form; use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvent;
@ -74,7 +73,5 @@ class FilterSetType extends AbstractType
$formModifier($event->getForm()->getParent(), $theme); $formModifier($event->getForm()->getParent(), $theme);
} }
); );
$builder->add('submit', SubmitType::class);
} }
} }