mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-18 13:10:08 -07:00
Add debug views of parts/sets
This commit is contained in:
parent
979985759b
commit
ebe636a324
@ -14,9 +14,9 @@ ModelViewer = function() {
|
||||
scene = new THREE.Scene();
|
||||
scene.fog = new THREE.FogExp2(0x000000, 0.001);
|
||||
|
||||
var grid = new THREE.GridHelper( 30, 70 );
|
||||
// grid.position.set(30/70,-0.5,30/70);
|
||||
scene.add( grid );
|
||||
// var grid = new THREE.GridHelper( 30, 70 );
|
||||
// // grid.position.set(30/70,-0.5,30/70);
|
||||
// scene.add( grid );
|
||||
|
||||
// Lights
|
||||
|
||||
|
@ -12,6 +12,12 @@
|
||||
{{ knp_menu_render('AppBundle:Builder:mainMenu') }}
|
||||
{% block body %}{% endblock %}
|
||||
{% block javascripts %}
|
||||
|
||||
<script type="text/javascript" src="{{ asset('resources/js/three.js') }}"></script>
|
||||
|
||||
<script type="text/javascript" src="{{ asset('resources/js/OrbitControls.js') }}"></script>
|
||||
|
||||
|
||||
<script src="{{ asset('resources/js/main.js') }}"></script>
|
||||
{% endblock %}
|
||||
</body>
|
||||
|
@ -3,26 +3,84 @@
|
||||
{% block body %}
|
||||
|
||||
{{ dump(part) }}
|
||||
{{ dump(rbPart) }}
|
||||
|
||||
<div id="model" style="height: 300px; width: 300px; padding: 5px; display: inline-block"></div>
|
||||
|
||||
<div style="display: flex; flex-wrap: wrap">
|
||||
{% if part is not null %}
|
||||
<div id="model" style="height: 300px; width: 300px; padding: 5px; display: inline-block"></div>
|
||||
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block">
|
||||
<img src="{{ url('part_image', {id:part.id}) }}" style="max-height: 90%; max-width: 100%">
|
||||
</div>
|
||||
|
||||
<h2 style="width: 100%">alias of</h2>
|
||||
{% if part.aliasOf is not null %}
|
||||
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block;">
|
||||
<img src="{{ url('part_image', {id:part.aliasOf.id}) }}" style="max-height: 90%; max-width: 100%;">
|
||||
<p><a href="{{ url('part_detail', {id:part.aliasOf.id}) }}">{{ part.aliasOf.id }}</a></p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<h2 style="width: 100%">aliases</h2>
|
||||
{% for alias in part.aliases %}
|
||||
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block;">
|
||||
<img src="{{ url('part_image', {id:alias.id}) }}" style="max-height: 90%; max-width: 100%;">
|
||||
<p><a href="{{ url('part_detail', {id:alias.id}) }}">{{ alias.id }}</a></p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<h2 style="width: 100%">subparts</h2>
|
||||
{% for subpart in part.subparts %}
|
||||
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block;">
|
||||
<img src="{{ url('part_image', {id:subpart.id}) }}" style="max-height: 90%; max-width: 100%;">
|
||||
<p><a href="{{ url('part_detail', {id:subpart.id}) }}">{{ subpart.id }}</a></p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<h2 style="width: 100%">subpart of</h2>
|
||||
{% for subpart in part.subpartOf %}
|
||||
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block;">
|
||||
<img src="{{ url('part_image', {id:subpart.id}) }}" style="max-height: 90%; max-width: 100%;">
|
||||
<p><a href="{{ url('part_detail', {id:subpart.id}) }}">{{ subpart.id }}</a></p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% if part.printOf is not null %}
|
||||
<h2 style="width: 100%">print of</h2>
|
||||
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block;">
|
||||
<img src="{{ url('part_image', {id:part.printOf.id}) }}" style="max-height: 90%; max-width: 100%;">
|
||||
<p><a href="{{ url('part_detail', {id:part.printOf.id}) }}">{{ part.printOf.id }}</a></p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if part.prints is not empty %}
|
||||
<h2 style="width: 100%">prints</h2>
|
||||
{% for print in part.prints %}
|
||||
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block;">
|
||||
<img src="{{ url('part_image', {id:print.id}) }}" style="max-height: 90%; max-width: 100%;">
|
||||
<p><a href="{{ url('part_detail', {id:print.id}) }}">{{ print.id }}</a></p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
<h2 style="width: 100%">in sets</h2>
|
||||
{% for inventory in inventories %}
|
||||
<span style="margin: 5px"><a href="{{ url('set_detail', {id:inventory.set.number}) }}">{{ inventory.set.number }}</a></span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block javascripts %}
|
||||
{{ parent() }}
|
||||
|
||||
<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/ModelViewer.js') }}"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
window.onload = function() {
|
||||
modelView = new ModelViewer();
|
||||
var scene = modelView.initScene($('#model'));
|
||||
{% if part.model is not null %}
|
||||
modelView.loadStl('{{ path('download_model', {'id' : part.model.id })}}');
|
||||
{% if part is not null and part.model is not null %}
|
||||
modelView.loadStl('{{ path('model_stl', {'id' : part.model.id })}}');
|
||||
{% endif %}
|
||||
modelView.render();
|
||||
};
|
||||
|
@ -2,19 +2,29 @@
|
||||
|
||||
|
||||
{% block body %}
|
||||
|
||||
|
||||
<div style="display: flex; flex-wrap: wrap;">
|
||||
{% for part in parts %}
|
||||
<div style="display: inline-block; width: 160px; margin: 5px; padding: 5px; border: solid 1px gray">
|
||||
<h4><a href="{{ url('part_detail', {id:part.id}) }}">{{ part.id }}</a></h4>
|
||||
<p>{{ part.name }}</p>
|
||||
<h2 style="width: 100%; text-align: center">
|
||||
total parts {{ parts.TotalItemCount }}
|
||||
<div class="navigation text-center">
|
||||
{{ knp_pagination_render(parts) }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</h2>
|
||||
|
||||
|
||||
<div style="display: flex; flex-wrap: wrap;">
|
||||
{% for part in parts %}
|
||||
<div style="display: inline-block; width: 160px; margin: 5px; padding: 5px; border: solid 1px gray;{% if part.sub is defined and not part.sub %}background:red{% endif %}">
|
||||
<img src="{{ url('part_image', {id:part.id}) }}" style="max-height: 100px; max-width: 100%">
|
||||
<h4><a href="{{ url('part_detail', {id:part.id}) }}">{{ part.id }}</a></h4>
|
||||
<p>{{ part.name }}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<h2 style="width: 100%; text-align: center">
|
||||
<div class="navigation text-center">
|
||||
{{ knp_pagination_render(parts) }}
|
||||
</div>
|
||||
</h2>
|
||||
|
||||
|
||||
<div class="navigation text-center">
|
||||
{{ knp_pagination_render(parts) }}
|
||||
</div>
|
||||
{% endblock %}
|
@ -12,7 +12,7 @@
|
||||
|
||||
<ul>
|
||||
{% for set in sets %}
|
||||
<li><a href="{{ url('set_detail', {'id': set.setID, 'name' : set.name|escape('url') }) }}">{{ set.LegoSetID }} - {{ set.name }}</a></li>
|
||||
<li><a href="{{ url('set_detail', {'id': set.number~'-'~set.numberVariant, 'name' : set.name|escape('url') }) }}">{{ set.LegoSetID }} - {{ set.name }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
@ -3,5 +3,25 @@
|
||||
{% block body %}
|
||||
|
||||
{{ dump(set) }}
|
||||
{{ dump(brset) }}
|
||||
|
||||
<h1>{{ brset.name }}</h1>
|
||||
<img src="{{ brset.imageURL }}">
|
||||
|
||||
{% if set is not null %}
|
||||
{% for inventory in set.inventories %}
|
||||
<h2>Parts</h2>
|
||||
<div style="display: flex; flex-wrap: wrap">
|
||||
{% for inventoryPart in inventory.inventoryParts %}
|
||||
<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%">
|
||||
<p><a style="color: #{{ inventoryPart.color.rgb }}" href="{{ url('part_detail', {id:inventoryPart.part.id}) }}"><strong>{{ inventoryPart.part.id }}</strong> {{ inventoryPart.quantity }}</a></p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div>
|
||||
{% else %}
|
||||
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
@ -40,4 +40,11 @@ class BricksetManager
|
||||
{
|
||||
return $this->bricksetClient->getSet($id);
|
||||
}
|
||||
|
||||
public function getSetByNumber($number)
|
||||
{
|
||||
$sets = $this->bricksetClient->getSets(['setNumber' => $number]);
|
||||
|
||||
return isset($sets[0]) ? $sets[0] : null;
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,13 @@
|
||||
namespace AppBundle\Controller;
|
||||
|
||||
use AppBundle\Entity\LDraw\Part;
|
||||
use AppBundle\Entity\Rebrickable\Inventory;
|
||||
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
||||
use Doctrine\DBAL\Query\QueryBuilder;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* @Route("/parts")
|
||||
@ -18,10 +19,25 @@ class PartController extends Controller
|
||||
/**
|
||||
* @Route("/detail/{id}", name="part_detail")
|
||||
*/
|
||||
public function showAction(Request $request, Part $part)
|
||||
public function showAction(Request $request, $id)
|
||||
{
|
||||
$em = $this->get('doctrine.orm.default_entity_manager');
|
||||
|
||||
$part = $em->getRepository(Part::class)->find($id);
|
||||
$rbPart = $em->getRepository(\AppBundle\Entity\Rebrickable\Part::class)->find($id);
|
||||
|
||||
$qb = $em->getRepository('AppBundle:Rebrickable\Inventory')->createQueryBuilder('i');
|
||||
|
||||
$qb->innerJoin(Inventory_Part::class, 'ip', Join::WITH, 'i.id = ip.inventory')
|
||||
->where('ip.part = :part')
|
||||
->setParameter('part', $id)->distinct(true);
|
||||
|
||||
$inventries = $qb->getQuery()->getResult();
|
||||
|
||||
return $this->render('part/detail.html.twig', [
|
||||
'part' => $part,
|
||||
'rbPart' => $rbPart,
|
||||
'inventories' => $inventries,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -35,21 +51,20 @@ class PartController extends Controller
|
||||
$queryBuilder = $em->getRepository(Part::class)->createQueryBuilder('p');
|
||||
|
||||
/** @var QueryBuilder $queryBuilder */
|
||||
$queryBuilder->where('p.model is not null');
|
||||
// $queryBuilder->where('p.model is not null');
|
||||
|
||||
$query = $queryBuilder->getQuery();
|
||||
|
||||
$paginator = $this->get('knp_paginator');
|
||||
$paginator = $this->get('knp_paginator');
|
||||
|
||||
$parts = $paginator->paginate(
|
||||
$query,
|
||||
$request->query->getInt('page', 1)/*page number*/,
|
||||
$request->query->getInt('limit', 30)/*limit per page*/
|
||||
$request->query->getInt('limit', 100)/*limit per page*/
|
||||
);
|
||||
|
||||
return $this->render('part/index.html.twig', [
|
||||
'parts' => $parts,
|
||||
'part' => null
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,14 @@
|
||||
|
||||
namespace AppBundle\Controller;
|
||||
|
||||
use AppBundle\Entity\Rebrickable\Set;
|
||||
use AppBundle\Form\FilterSetType;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* @Route("/brickset/set")
|
||||
* @Route("/sets")
|
||||
*/
|
||||
class SetController extends Controller
|
||||
{
|
||||
@ -39,14 +40,17 @@ class SetController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{id}_{name}", name="set_detail")
|
||||
* @Route("/detail/{id}_{name}", name="set_detail")
|
||||
*/
|
||||
public function detailAction(Request $request, $id, $name = null)
|
||||
{
|
||||
$set = $this->get('manager.brickset')->getSetById($id);
|
||||
$brset = $this->get('manager.brickset')->getSetByNumber($id);
|
||||
|
||||
$set = $this->get('doctrine.orm.default_entity_manager')->getRepository(Set::class)->find($id);
|
||||
|
||||
return $this->render('set/detail.html.twig', [
|
||||
'set' => $set,
|
||||
'brset' => $brset,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user