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

Update Controllers

This commit is contained in:
David Hübner 2017-04-07 19:07:15 +02:00
parent 61caac6f55
commit 2976f6b801
11 changed files with 98 additions and 83 deletions

1
.gitignore vendored
View File

@ -18,4 +18,5 @@
/node_modules/ /node_modules/
/app/Resources/libs/semantic/dist /app/Resources/libs/semantic/dist
/web/resources/ /web/resources/
/web/media/
.php_cs.cache .php_cs.cache

View File

@ -2,39 +2,56 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<title>{% block title %}Welcome!{% endblock %}</title> <title>{% block title %}PrintABrick{% endblock %}</title>
{% block stylesheets %} {% block stylesheets %}
<link rel="stylesheet" href="{{ asset('resources/css/main.css') }}"> <link rel="stylesheet" href="{{ asset('resources/css/main.css') }}">
{% endblock %} {% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" /> <link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
</head> </head>
<body> <body>
{% block body %} {% block body %}
<div class="ui fixed inverted menu"> <div class="ui fixed inverted menu">
{{ knp_menu_render('mainMenu') }} {{ knp_menu_render('mainMenu') }}
</div>
<div class="ui main container">
<div class="ui masthead vertical segment">
<div class="introduction">
<div class="ui small breadcrumb">
{% for breadcrumb_item in knp_menu_get_breadcrumbs_array(knp_menu_get_current_item('mainMenu')) %}
{% if not loop.last %}
<a class="section" href="{{ breadcrumb_item.uri }}">{{ breadcrumb_item.label }}</a>
<i class="right chevron icon divider"></i>
{% else %}
<a class="active section">{{ breadcrumb_item.label }}</a>
{% endif %}
{% endfor %}
</div>
<h1 class="ui header">{% block header %}{% endblock %}</h1>
</div> </div>
<div class="ui main container"> </div>
{% for label, flashes in app.session.flashbag.all %}
{% for flash in flashes %} {% for label, flashes in app.session.flashbag.all %}
{{ elements.flash(label,flash) }} {% for flash in flashes %}
{% endfor %} {{ elements.flash(label,flash) }}
{% endfor %} {% endfor %}
{% block content %} {% endfor %}
{% block content %}
{% endblock %}
</div>
{% endblock %} {% endblock %}
</div>
{% endblock %}
{% block javascripts %} {% block javascripts %}
<script type="text/javascript" src="{{ asset('resources/js/three.js') }}"></script> <script type="text/javascript" src="{{ asset('resources/js/three.js') }}"></script>
<script type="text/javascript" src="{{ asset('resources/js/OrbitControls.js') }}"></script> <script type="text/javascript" src="{{ asset('resources/js/OrbitControls.js') }}"></script>
<script src="{{ asset('resources/js/main.js') }}"></script>
<script src="{{ asset('resources/js/main.js') }}"></script> {% endblock %}
{% endblock %} </body>
</body>
</html> </html>

View File

@ -1,7 +1,11 @@
{% macro part(model) %} {% macro part(model) %}
<div style="height: 100px; width: 100px; padding: 5px; display: inline-block;"> <div class="column">
<img src="{{ url('media_file', {'path': 'ldraw/images/'~model.number~'.png'}) }}" style="max-height: 90%; max-width: 100%"> <div class="ui bordered fluid image">
<p><a href="{{ url('model_detail', {'number': model.number}) }}">{{ model.number }}</a></p> <a href="{{ url('model_detail', {'number': model.number})}}">
<img src="{{ asset('/ldraw/images/'~model.number~'.png') | imagine_filter('model') }}">
<div class="ui bottom attached label">{{ model.number }}</div>
</a>
</div>
</div> </div>
{% endmacro %} {% endmacro %}

View File

@ -2,8 +2,11 @@
{% import 'macros/elements.html.twig' as elements %} {% import 'macros/elements.html.twig' as elements %}
{% block title %}{{ model.name }}{% endblock %}
{% block header %}{{ model.name }}{% endblock %}
{% block content %} {% block content %}
{% if model %}
<dl> <dl>
<dt>number:</dt><dd>{{ model.number }}</dd> <dt>number:</dt><dd>{{ model.number }}</dd>
<dt>name:</dt><dd>{{ model.name }}</dd> <dt>name:</dt><dd>{{ model.name }}</dd>
@ -34,12 +37,10 @@
</div> </div>
</p> </p>
</dd> </dd>
</dl> </dl>
{% endif %}
<div style="display: flex; flex-wrap: wrap"> <div style="display: flex; flex-wrap: wrap">
<div id="model" style="height: 300px; width: 300px; padding: 5px; display: inline-block"></div> <div id="model" style="height: 200px; width: 300px; padding: 5px; display: inline-block"></div>
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block"> <div style="height: 300px; width: 300px; padding: 5px; display: inline-block">
<img src="{{ url('media_file', {'path': 'ldraw/images/'~model.number~'.png'}) }}" style="max-height: 90%; max-width: 100%"> <img src="{{ url('media_file', {'path': 'ldraw/images/'~model.number~'.png'}) }}" style="max-height: 90%; max-width: 100%">
</div> </div>
@ -75,10 +76,8 @@
<script type="text/javascript"> <script type="text/javascript">
window.onload = function() { window.onload = function() {
modelView = new ModelViewer(); modelView = new ModelViewer($('#model'));
var scene = modelView.initScene($('#model'));
modelView.loadStl('{{ url('media_file', {'path': model.path }) }}'); modelView.loadStl('{{ url('media_file', {'path': model.path }) }}');
modelView.render();
}; };
</script> </script>
{% endblock %} {% endblock %}

View File

@ -3,7 +3,7 @@
{% import 'macros/elements.html.twig' as elements %} {% import 'macros/elements.html.twig' as elements %}
{% block content %} {% block content %}
<form method="get" action="." class="ui form"> <form method="get" action="" class="ui form">
{{ form_start(form) }} {{ form_start(form) }}
{{ form_row(form.search) }} {{ form_row(form.search) }}
@ -19,14 +19,10 @@
<p>{{ models.getTotalItemCount }}</p> <p>{{ models.getTotalItemCount }}</p>
<div class="ui ten column grid"> <div class="ui eight column grid">
<div class="row"> {% for model in models %}
{% for model in models %} {{ elements.part(model) }}
<div class="column"> {% endfor %}
{{ elements.part(model) }}
</div>
{% endfor %}
</div>
</div> </div>
{{ knp_pagination_render(models) }} {{ knp_pagination_render(models) }}

View File

@ -15,9 +15,6 @@
<img src="{{ apiPart.imgUrl }}" style="max-height: 90%; max-width: 100%"> <img src="{{ apiPart.imgUrl }}" style="max-height: 90%; max-width: 100%">
</div> </div>
{% endif %} {% endif %}
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block">
<img src="{{ url('model_image', {number:part.number}) }}" style="max-height: 90%; max-width: 100%">
</div>
{% if part.model %} {% if part.model %}
{{ elements.part(part.model) }} {{ elements.part(part.model) }}
@ -28,9 +25,19 @@
<i class="puzzle icon"></i> Sets <i class="puzzle icon"></i> Sets
</h4> </h4>
<div class="ui eight column grid">
{% for set in sets %} {% for set in sets %}
<span style="margin: 5px"><a href="{{ url('set_detail', {number:set.number}) }}">{{ set.number }}</a></span> <div class="column">
<div class="ui fluid bordered image">
<a href="{{ url('set_detail', {number:set.number}) }}">
<img class="ui bordered image" src="{{ set|setImage|imagine_filter('rebrickable_set_min') }}">
<div class="ui bottom attached label">{{ set.number }}<br></div>
</a>
</div>
</div>
{% endfor %} {% endfor %}
<div>
{{ dump(apiPart) }} {{ dump(apiPart) }}

View File

@ -10,8 +10,9 @@
<dt>count of parts:</dt><dd>{{ set.partCount }}</dd> <dt>count of parts:</dt><dd>{{ set.partCount }}</dd>
</dl> </dl>
<img class="ui bordered image medium" src="{{ rbset ? rbset.imgUrl }}"> <img class="ui bordered image medium" src="{{ set|setImage|imagine_filter('rebrickable_set_mid') }}">
{{ dump(rbset.imgUrl) }}
<h4 class="ui horizontal divider header"> <h4 class="ui horizontal divider header">
<i class="cubes icon"></i> Parts {{ inventoryParts|length }} <i class="cubes icon"></i> Parts {{ inventoryParts|length }}
@ -20,36 +21,18 @@
<div class="ui eight column grid"> <div class="ui eight column grid">
{% for inventoryPart in inventoryParts %} {% for inventoryPart in inventoryParts %}
<div class="column"> <div class="column">
<div class="ui fluid image {{ inventoryPart.part.model == null ? 'active dimmer'}}" style="height: 150px;"> <div class="ui fluid bordered image">
<a class="ui right red circular label">{{ inventoryPart.quantity }}</a> <a class="ui right {{ inventoryPart.part.model == null ? 'black' : 'red'}} circular label">{{ inventoryPart.quantity }}</a>
<a href="{{ path('rebrickable_part_show', {number: inventoryPart.part.number}) }}"> <a href="{{ path('rebrickable_part_show', {number: inventoryPart.part.number}) }}">
<img src="https://rebrickable.com/media/parts/ldraw/{{inventoryPart.color ? inventoryPart.color.id }}/{{ inventoryPart.part.number }}.png"> <img src="{{ inventoryPart.part|partImage(inventoryPart.color)| imagine_filter('rebrickable_part_min') }}">
<div style="border-bottom: #{{ inventoryPart.color.rgb }} 5px solid" class="ui bottom attached label">{{ inventoryPart.part.number }}<br>{{ inventoryPart.isSpare ? 'Spare' : 'Regular' }}</div> <div style="border-bottom: #{{ inventoryPart.color.rgb }} 5px solid" class="ui bottom attached label">{{ inventoryPart.part.number }}<br>{{ inventoryPart.isSpare ? 'Spare' : 'Regular' }}</div>
</a> </a>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
<div> <div>
<h4 class="ui horizontal divider header">
<i class="cubes icon"></i> Models {{ parts|length }}
</h4>
<div class="ui eight column grid">
{% for part in parts %}
<div class="column">
<div class="ui bordered fluid image">
<a href="{{ path('model_detail', {number: part.number}) }}">
<img src="https://rebrickable.com/media/parts/ldraw/-1/{{ part.number }}.png">
<div class="ui bottom attached label">{{ part.number }} </div>
</a>
</div>
</div>
{% endfor %}
<div>
{% endif %} {% endif %}
{{ brset ? dump(brset) }} {{ brset ? dump(brset) }}

View File

@ -12,7 +12,7 @@ use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
/** /**
* @Route("/media") * @Route("/files")
*/ */
class MediaController extends Controller class MediaController extends Controller
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace AppBundle\Controller\LDraw; namespace AppBundle\Controller;
use AppBundle\Entity\LDraw\Model; use AppBundle\Entity\LDraw\Model;
use AppBundle\Entity\Rebrickable\Part; use AppBundle\Entity\Rebrickable\Part;
@ -14,14 +14,14 @@ use Symfony\Component\HttpFoundation\Request;
/** /**
* Part controller. * Part controller.
* *
* @Route("ldraw") * @Route("models")
*/ */
class ModelController extends Controller class ModelController extends Controller
{ {
/** /**
* Lists all part entities. * Lists all part entities.
* *
* @Route("/models/", name="ldraw_model_index") * @Route("/", name="model_index")
* @Method("GET") * @Method("GET")
*/ */
public function indexAction(Request $request) public function indexAction(Request $request)
@ -45,10 +45,10 @@ class ModelController extends Controller
$models = $paginator->paginate( $models = $paginator->paginate(
$filterBuilder->getQuery(), $filterBuilder->getQuery(),
$request->query->getInt('page', 1)/*page number*/, $request->query->getInt('page', 1)/*page number*/,
$request->query->getInt('limit', 100)/*limit per page*/ $request->query->getInt('limit', 40)/*limit per page*/
); );
return $this->render('ldraw/model/index.html.twig', [ return $this->render('model/index.html.twig', [
'models' => $models, 'models' => $models,
'form' => $form->createView(), 'form' => $form->createView(),
]); ]);
@ -57,7 +57,7 @@ class ModelController extends Controller
/** /**
* Finds and displays a part entity. * Finds and displays a part entity.
* *
* @Route("/models/{number}", name="model_detail") * @Route("/{number}", name="model_detail")
* @Method("GET") * @Method("GET")
*/ */
public function detailAction($number) public function detailAction($number)
@ -65,11 +65,20 @@ class ModelController extends Controller
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
if($model = $this->get('manager.ldraw.model')->findByNumber($number)) { if($model = $this->get('manager.ldraw.model')->findByNumber($number)) {
// $bin = $this->get('imagine.data.loader.media')->find('/ldraw/images/'.$model->getNumber().'.png');
//
// $path = $this->get('imagine.cache.resolver.media')->resolve('/ldraw/images/'.$model->getNumber().'.png','model');
//
// $this->get('imagine.cache.resolver.media')->store($bin,$path,'model');
try { try {
$rbParts = $model != null ? $em->getRepository(Part::class)->findAllByModel($model) : null; $rbParts = $model != null ? $em->getRepository(Part::class)->findAllByModel($model) : null;
$sets = $model != null ? $em->getRepository(Set::class)->findAllByModel($model) : null; $sets = $model != null ? $em->getRepository(Set::class)->findAllByModel($model) : null;
return $this->render('ldraw/model/detail.html.twig', [ return $this->render('model/detail.html.twig', [
'model' => $model, 'model' => $model,
'rbParts' => $rbParts, 'rbParts' => $rbParts,
'sets' => $sets, 'sets' => $sets,

View File

@ -67,7 +67,6 @@ class SetController extends Controller
'set' => $set, 'set' => $set,
'brset' => $brset, 'brset' => $brset,
'rbset' => $rbset, 'rbset' => $rbset,
'parts' => $em->getRepository(Model::class)->findAllBySetNumber($number),
'inventoryParts' => $em->getRepository(Inventory_Part::class)->findAllBySetNumber($number), 'inventoryParts' => $em->getRepository(Inventory_Part::class)->findAllBySetNumber($number),
]); ]);
} }

View File

@ -35,7 +35,7 @@ class Builder
]); ]);
$menu->addChild('Models', [ $menu->addChild('Models', [
'route' => 'ldraw_model_index', 'route' => 'model_index',
]); ]);
$menu->addChild('Sets', [ $menu->addChild('Sets', [