mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-29 10:10:25 -07:00
Update templates
This commit is contained in:
parent
9e9bcfe928
commit
8ddf1a7263
@ -2,4 +2,27 @@ $(document).ready(function () {
|
||||
$('.ui.dropdown')
|
||||
.dropdown()
|
||||
;
|
||||
|
||||
$('.image.load img')
|
||||
.visibility({
|
||||
type : 'image',
|
||||
transition : 'fade in',
|
||||
duration : 1000
|
||||
})
|
||||
;
|
||||
|
||||
$('.ui.rating')
|
||||
.rating("disable")
|
||||
;
|
||||
|
||||
$('.tabular.menu .item').tab();
|
||||
|
||||
$('.message .close')
|
||||
.on('click', function() {
|
||||
$(this)
|
||||
.closest('.message')
|
||||
.transition('fade')
|
||||
;
|
||||
})
|
||||
;
|
||||
});
|
@ -1,3 +1,4 @@
|
||||
.ui.fixed + .ui.main {
|
||||
margin-top: 5em;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
{{ knp_menu_render('mainMenu') }}
|
||||
</div>
|
||||
<div class="ui main container">
|
||||
|
||||
<div class="ui masthead vertical segment">
|
||||
<div class="introduction">
|
||||
<div class="ui small breadcrumb">
|
||||
@ -43,6 +42,12 @@
|
||||
|
||||
{% endblock %}
|
||||
</div>
|
||||
|
||||
<div class="ui black inverted vertical footer segment stripe">
|
||||
<div class="ui center aligned container">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block javascripts %}
|
||||
|
@ -2,8 +2,10 @@
|
||||
<div class="column">
|
||||
<div class="ui bordered fluid image">
|
||||
<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>
|
||||
<div class="image">
|
||||
<img src="{{ asset('/ldraw/images/'~model.number~'.png') | imagine_filter('model_min') }}" data-src="{{ asset('/ldraw/images/'~model.number~'.png') | imagine_filter('model_min') }}" class="transition visible">
|
||||
</div>
|
||||
<div class="ui bottom attached label {% if model.parts|length == 0 %}black{% endif %}">{{ model.number }}</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -7,9 +7,9 @@
|
||||
{% block header %}{{ model.name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="model-container">
|
||||
|
||||
<div id="model-viewer" class="model-container">
|
||||
<img src="{{ asset('ldraw/images/'~model.number~'.png') | imagine_filter('model_large')}}">
|
||||
<div id="model-viewer"></div>
|
||||
</div>
|
||||
|
||||
<dl>
|
||||
@ -18,6 +18,7 @@
|
||||
<dt>category:</dt><dd>{{ model.category ? model.category.name }}</dd>
|
||||
<dt>model:</dt><dd>{{ model.path }}</dd>
|
||||
<dt>author:</dt><dd>{{ model.author }}</dd>
|
||||
<dt>modified:</dt><dd>{{ model.modified ? model.modified|date('Y-m-d') }}</dd>
|
||||
<dt>keywords:</dt>
|
||||
<dd>
|
||||
{% for keyword in model.keywords %}
|
||||
@ -49,17 +50,25 @@
|
||||
<i class="puzzle icon"></i> Subparts of this model
|
||||
</h4>
|
||||
|
||||
<div class="ui eight cards">
|
||||
{% for subpart in model.subparts %}
|
||||
<div class="column">
|
||||
{{ elements.part(subpart.subpart) }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<h4 class="ui horizontal divider header">
|
||||
<i class="cube icon"></i> Model is subpart of
|
||||
</h4>
|
||||
|
||||
<div class="ui eight cards">
|
||||
{% for subpart in model.parents %}
|
||||
<div class="column">
|
||||
{{ elements.part(subpart.parent) }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<h4 class="ui horizontal divider header">
|
||||
<i class="cubes icon"></i> Sets ({{ sets|length }})
|
||||
@ -73,11 +82,9 @@
|
||||
|
||||
{% block javascripts %}
|
||||
{{ parent() }}
|
||||
|
||||
<script type="text/javascript">
|
||||
window.onload = function() {
|
||||
modelView = new ModelViewer($('#model-viewer'));
|
||||
modelView.loadStl('{{ url('media_file', {'path': model.path }) }}');
|
||||
modelView = new ModelViewer($('#model-viewer'), '{{ url('media_file', {'path': model.path }) }}');
|
||||
};
|
||||
</script>
|
||||
{% endblock %}
|
@ -9,23 +9,21 @@
|
||||
<dt>category:</dt><dd>{{ part.category ? part.category.name }}</dd>
|
||||
</dl>
|
||||
|
||||
<div style="display: flex; flex-wrap: wrap">
|
||||
|
||||
{% if apiPart is not null %}
|
||||
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block">
|
||||
<img src="{{ apiPart.imgUrl }}" style="max-height: 90%; max-width: 100%">
|
||||
</div>
|
||||
<a href="{{ apiPart.url }}">Rebrickable</a>
|
||||
|
||||
<img class="image ui middle" src="{{ apiPart.imgUrl }}" style="max-height: 90%; max-width: 100%">
|
||||
{% endif %}
|
||||
|
||||
{% if part.model %}
|
||||
{{ elements.part(part.model) }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<h4 class="ui horizontal divider header">
|
||||
<i class="puzzle icon"></i> Sets
|
||||
</h4>
|
||||
|
||||
|
||||
<div class="ui eight column grid">
|
||||
{% for set in sets %}
|
||||
<div class="column">
|
||||
|
@ -1,41 +0,0 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
{% if set is not null %}
|
||||
<dl>
|
||||
<dt>number:</dt><dd>{{ set.number }}</dd>
|
||||
<dt>year:</dt><dd>{{ set.year }}</dd>
|
||||
<dt>name:</dt><dd>{{ set.name }}</dd>
|
||||
<dt>theme:</dt><dd>{{ set.theme.name }}</dd>
|
||||
<dt>count of parts:</dt><dd>{{ set.partCount }}</dd>
|
||||
</dl>
|
||||
|
||||
<img class="ui bordered image medium" src="{{ set|setImage|imagine_filter('rebrickable_set_mid') }}">
|
||||
|
||||
{{ dump(rbset.imgUrl) }}
|
||||
|
||||
<h4 class="ui horizontal divider header">
|
||||
<i class="cubes icon"></i> Parts {{ inventoryParts|length }}
|
||||
</h4>
|
||||
|
||||
<div class="ui eight column grid">
|
||||
{% for inventoryPart in inventoryParts %}
|
||||
<div class="column">
|
||||
<div class="ui fluid bordered image">
|
||||
<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}) }}">
|
||||
<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>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div>
|
||||
|
||||
{% endif %}
|
||||
|
||||
{{ brset ? dump(brset) }}
|
||||
|
||||
|
||||
{% endblock %}
|
17
app/Resources/views/rebrickable/set/inventory_sets.html.twig
Normal file
17
app/Resources/views/rebrickable/set/inventory_sets.html.twig
Normal file
@ -0,0 +1,17 @@
|
||||
<h4 class="ui horizontal divider header">
|
||||
Sets
|
||||
</h4>
|
||||
<div class="ui eight column grid">
|
||||
{% for inventorySet in inventorySets %}
|
||||
<div class="column">
|
||||
<div class="ui fluid bordered image">
|
||||
<a href="{{ path('rebrickable_set_detail', {number: inventorySet.set}) }}">
|
||||
<div class="image load">
|
||||
<img src="{{ inventorySet.set|setImage| imagine_filter('rebrickable_set_min') }}" data-src="{{ inventorySet.set|setImage| imagine_filter('rebrickable_set_min') }}" class="transition visible">
|
||||
</div>
|
||||
<div class="ui bottom attached label">{{ inventorySet.set.number }}<br>{{ inventorySet.quantity }}</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
48
app/Resources/views/rebrickable/set/parts.html.twig
Normal file
48
app/Resources/views/rebrickable/set/parts.html.twig
Normal file
@ -0,0 +1,48 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h4 class="ui horizontal divider header">
|
||||
Regular parts
|
||||
</h4>
|
||||
|
||||
<div class="ui eight column grid">
|
||||
{% for inventoryPart in regularParts %}
|
||||
{% if inventoryPart.part is defined %}
|
||||
<div class="column">
|
||||
<div class="ui fluid bordered image">
|
||||
<a class="ui right {{ inventoryPart.part.model == null ? 'black' : 'red'}} circular label">{{ inventoryPart.quantity }}</a>
|
||||
<a href="{{ path('reb_part_detail', {number: inventoryPart.part.number}) }}">
|
||||
<div class="image load">
|
||||
<img src="{{ inventoryPart.part|partImage(inventoryPart.color)| imagine_filter('rebrickable_part_min') }}" data-src="{{ inventoryPart.part|partImage(inventoryPart.color)| imagine_filter('rebrickable_part_min') }}" class="transition visible">
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<h4 class="ui horizontal divider header">
|
||||
Spare parts
|
||||
</h4>
|
||||
<div class="ui eight column grid">
|
||||
{% for inventoryPart in spareParts %}
|
||||
{% if inventoryPart.part is defined %}
|
||||
<div class="column">
|
||||
<div class="ui fluid bordered image">
|
||||
<a class="ui right {{ inventoryPart.part.model == null ? 'black' : 'red'}} circular label">{{ inventoryPart.quantity }}</a>
|
||||
<a href="{{ path('reb_part_detail', {number: inventoryPart.part.number}) }}">
|
||||
<div class="image load">
|
||||
<img src="{{ inventoryPart.part|partImage(inventoryPart.color)| imagine_filter('rebrickable_part_min') }}" data-src="{{ inventoryPart.part|partImage(inventoryPart.color)| imagine_filter('rebrickable_part_min') }}" class="transition visible">
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
76
app/Resources/views/set/detail.html.twig
Normal file
76
app/Resources/views/set/detail.html.twig
Normal file
@ -0,0 +1,76 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}{{ rbset ? rbset.number }} {{ rbset ? rbset.name }}{% endblock %}
|
||||
|
||||
{% block header %}{{ rbset ? rbset.number }} {{ rbset ? rbset.name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if brset %}
|
||||
<a href="{{ brset.bricksetURL }}"><img class="image ui mini" src="http://brickset.com/assets/images/logo/bricks.jpg"> Brickset</a>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if rbset is not null %}
|
||||
<a href="http://rebrickable.com/sets/{{ rbset ? rbset.number }}"><img class="image ui mini" src="https://s.rebrickable.com/static/img/robo3ta.png"> Rebrickable</a>
|
||||
<dl>
|
||||
<dt>number:</dt><dd>{{ rbset.number }}</dd>
|
||||
<dt>year:</dt><dd>{{ rbset.year }}</dd>
|
||||
<dt>name:</dt><dd>{{ rbset.name }}</dd>
|
||||
<dt>theme:</dt><dd>{{ rbset.theme.name }}</dd>
|
||||
{% if rbset.theme.parent %}
|
||||
<dt>themeparent:</dt><dd>{{ rbset.theme.parent.name }}</dd>
|
||||
{% if rbset.theme.parent.parent %}
|
||||
<dt>themeparent:</dt><dd>{{ rbset.theme.parent.parent.name }}</dd>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<dt>count of parts:</dt><dd>{{ rbset.partCount }}</dd>
|
||||
</dl>
|
||||
{% endif %}
|
||||
|
||||
{% if brset is not null %}
|
||||
<dl>
|
||||
<dt>year:</dt><dd>{{ brset.year }}</dd>
|
||||
<dt>name:</dt><dd>{{ brset.name }}</dd>
|
||||
<dt>themegroup:</dt><dd>{{ brset.themeGroup }}</dd>
|
||||
<dt>theme:</dt><dd>{{ brset.theme }}</dd>
|
||||
<dt>subtheme:</dt><dd>{{ brset.subtheme }}</dd>
|
||||
<dt>count of parts:</dt><dd>{{ brset.pieces }}</dd>
|
||||
<dt>lego id:</dt><dd>{{ brset.legoSetID }}</dd>
|
||||
<dt>minifigs:</dt><dd>{{ brset.minifigs }}</dd>
|
||||
<dt>description:</dt><dd>{{ brset.description }}</dd>
|
||||
</dl>
|
||||
{% endif %}
|
||||
|
||||
{% if brset %}
|
||||
<img class="ui bordered image medium" src="{{ brset.imageURL }}">
|
||||
{% elseif rbset %}
|
||||
<img class="ui bordered image medium" src="{{ rbset|setImage|imagine_filter('rebrickable') }}">
|
||||
{% endif %}
|
||||
|
||||
{#{{ brset ? dump(brset) }}#}
|
||||
|
||||
<div class="ui tabular menu">
|
||||
<a class="item active" data-tab="parts"><i class="cubes icon"></i> Parts ({{ rbset ? rbset.partCount : 0}})</a>
|
||||
{% if brset %}
|
||||
<a class="item" data-tab="images"> <i class="image icon"></i> Images ({{ brset.additionalImageCount }})</a>
|
||||
<a class="item" data-tab="instructions"> <i class="file pdf outline icon"></i> Instructions ({{ brset.instructionsCount }})</a>
|
||||
<a class="item" data-tab="reviews"><i class="write icon"></i> Reviews ({{ brset.reviewCount }})</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="ui tab active" data-tab="parts">
|
||||
{% if rbset %}
|
||||
{#{{ render(controller('AppBundle:Rebrickable/Set:parts', { 'number': rbset.number })) }}#}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if brset %}
|
||||
<div class="ui tab" data-tab="images">
|
||||
{{ render(controller('AppBundle:Brickset/Set:images', { 'id': brset.setID })) }}
|
||||
</div>
|
||||
<div class="ui tab" data-tab="instructions">
|
||||
{{ render(controller('AppBundle:Brickset/Set:instructions', { 'id': brset.setID })) }}
|
||||
</div>
|
||||
<div class="ui tab" data-tab="reviews">
|
||||
{{ render(controller('AppBundle:Brickset/Set:reviews', { 'id': brset.setID })) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
@ -6,8 +6,7 @@
|
||||
{% for set in sets %}
|
||||
<div class="column">
|
||||
<a href="{{ url('set_detail', {'number': set.number, 'name' : set.name|escape('url') }) }}">
|
||||
|
||||
{#<img style="width: 100%" src="{{ set }}">#}
|
||||
<img class="ui bordered image medium" src="{{ set|setImage|imagine_filter('rebrickable_set_min') }}">
|
||||
<p>{{ set.number }} - {{ set.name }}</p>
|
||||
</a>
|
||||
</div>
|
@ -99,17 +99,18 @@ liip_imagine:
|
||||
filesystem_service: oneup_flysystem.media_filesystem
|
||||
rebrickable:
|
||||
stream:
|
||||
wrapper: 'http://rebrickable.com/media/'
|
||||
wrapper: 'http://m.rebrickable.com/media/'
|
||||
|
||||
resolvers:
|
||||
default:
|
||||
web_path: ~
|
||||
|
||||
filter_sets:
|
||||
model:
|
||||
model_min:
|
||||
data_loader: media
|
||||
cache: ~
|
||||
quality: 80
|
||||
default_image: '/resources/images/unknown_image_min.png'
|
||||
filters:
|
||||
thumbnail: { size: [200, 200], mode: inset }
|
||||
background: { size: [250, 250], position: center, color: '#FFFFFF' }
|
||||
@ -118,27 +119,24 @@ liip_imagine:
|
||||
cache: ~
|
||||
quality: 92
|
||||
filters:
|
||||
thumbnail: { size: [400, 300], mode: inset }
|
||||
background: { size: [600, 400], position: center, color: '#FFFFFF' }
|
||||
thumbnail: { size: [800, 600], mode: inset }
|
||||
background: { size: [1100, 800], position: center, color: '#FFFFFF' }
|
||||
rebrickable:
|
||||
data_loader: rebrickable
|
||||
rebrickable_part_min:
|
||||
quality: 80
|
||||
data_loader: rebrickable
|
||||
cache: ~
|
||||
default_image: '/resources/images/unknown_image_min.png'
|
||||
filters:
|
||||
thumbnail: { size: [200, 200], mode: inset }
|
||||
rebrickable_set_mid:
|
||||
quality: 80
|
||||
data_loader: rebrickable
|
||||
cache: ~
|
||||
filters:
|
||||
thumbnail: { size: [600, 600], mode: inset }
|
||||
thumbnail: { size: [250, 250], mode: inset }
|
||||
rebrickable_set_min:
|
||||
quality: 80
|
||||
data_loader: rebrickable
|
||||
default_image: '/resources/images/unknown_image_min.png'
|
||||
cache: ~
|
||||
filters:
|
||||
thumbnail: { size: [300, 300], mode: inset }
|
||||
|
||||
thumbnail: { size: [250, 250], mode: inset }
|
||||
oneup_flysystem:
|
||||
adapters:
|
||||
media:
|
||||
|
@ -65,15 +65,6 @@ class ModelController extends Controller
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
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 {
|
||||
$rbParts = $model != null ? $em->getRepository(Part::class)->findAllByModel($model) : null;
|
||||
$sets = $model != null ? $em->getRepository(Set::class)->findAllByModel($model) : null;
|
||||
|
37
src/AppBundle/Controller/Rebrickable/InventoryController.php
Normal file
37
src/AppBundle/Controller/Rebrickable/InventoryController.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Controller\Rebrickable;
|
||||
|
||||
use AppBundle\Api\Exception\EmptyResponseException;
|
||||
use AppBundle\Entity\LDraw\Model;
|
||||
use AppBundle\Entity\Rebrickable\Color;
|
||||
use AppBundle\Entity\Rebrickable\Inventory;
|
||||
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
||||
use AppBundle\Entity\Rebrickable\Inventory_Set;
|
||||
use AppBundle\Entity\Rebrickable\Part;
|
||||
use AppBundle\Entity\Rebrickable\Set;
|
||||
use AppBundle\Entity\Rebrickable\Theme;
|
||||
use AppBundle\Form\FilterSetType;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* @Route("/rebrickable/inventory")
|
||||
*/
|
||||
class InventoryController extends Controller
|
||||
{
|
||||
/**
|
||||
* @Route("/{number}/inventory_sets", name="rebrickable_inventory_sets")
|
||||
*/
|
||||
public function inventoryAction(Inventory $inventory) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$inventorySets = $em->getRepository(Set::class)->findAllByInventory($inventory);
|
||||
|
||||
return $this->render('rebrickable/set/inventory_sets.html.twig', [
|
||||
'inventorySets' => $inventorySets,
|
||||
]);
|
||||
}
|
||||
}
|
@ -19,10 +19,10 @@ class PartController extends Controller
|
||||
/**
|
||||
* Finds and displays a part entity.
|
||||
*
|
||||
* @Route("/{number}", name="rebrickable_part_show")
|
||||
* @Route("/{number}", name="reb_part_detail")
|
||||
* @Method("GET")
|
||||
*/
|
||||
public function showAction(Part $part = null)
|
||||
public function detailAction(Part $part)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
|
@ -6,6 +6,7 @@ use AppBundle\Api\Exception\EmptyResponseException;
|
||||
use AppBundle\Entity\LDraw\Model;
|
||||
use AppBundle\Entity\Rebrickable\Color;
|
||||
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
||||
use AppBundle\Entity\Rebrickable\Inventory_Set;
|
||||
use AppBundle\Entity\Rebrickable\Part;
|
||||
use AppBundle\Entity\Rebrickable\Set;
|
||||
use AppBundle\Entity\Rebrickable\Theme;
|
||||
@ -21,87 +22,55 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
class SetController extends Controller
|
||||
{
|
||||
/**
|
||||
* @Route("/", name="set_index")
|
||||
* @Route("/{number}/parts", name="rebrickable_set_parts")
|
||||
*/
|
||||
public function indexAction(Request $request)
|
||||
{
|
||||
public function partsAction(Set $set) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$qb = $em->getRepository(Set::class)->createQueryBuilder('s');
|
||||
|
||||
$paginator = $this->get('knp_paginator');
|
||||
$sets = $paginator->paginate(
|
||||
$qb->getQuery(),
|
||||
$request->query->getInt('page', 1)/*page number*/,
|
||||
$request->query->getInt('limit', 30)/*limit per page*/
|
||||
);
|
||||
|
||||
return $this->render('rebrickable/set/index.html.twig', [
|
||||
'sets' => $sets,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/detail/{number}_{name}", name="set_detail")
|
||||
*/
|
||||
public function detailAction(Request $request, $number, $name = null)
|
||||
{
|
||||
$brset = null;
|
||||
try {
|
||||
$brset = $this->get('api.manager.brickset')->getSetByNumber($number);
|
||||
} catch (EmptyResponseException $e) {
|
||||
$this->addFlash('warning', 'Set not found in Brickset database');
|
||||
} catch (\Exception $e) {
|
||||
$this->addFlash('error', $e->getMessage());
|
||||
}
|
||||
|
||||
$set = $this->getDoctrine()->getManager()->getRepository(Set::class)->find($number);
|
||||
|
||||
$rbset = $this->get('api.manager.rebrickable')->getSet($number);
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->getRepository(Color::class)->findAll();
|
||||
$em->getRepository(Theme::class)->findAll();
|
||||
$em->getRepository(Part::class)->findAllBySetNumber($set->getNumber());
|
||||
|
||||
return $this->render('rebrickable/set/detail.html.twig', [
|
||||
'set' => $set,
|
||||
'brset' => $brset,
|
||||
'rbset' => $rbset,
|
||||
'inventoryParts' => $em->getRepository(Inventory_Part::class)->findAllBySetNumber($number),
|
||||
$regularParts = $em->getRepository(Inventory_Part::class)->findAllRegularBySetNumber($set->getNumber());
|
||||
$spareParts = $em->getRepository(Inventory_Part::class)->findAllSpareBySetNumber($set->getNumber());
|
||||
|
||||
return $this->render('rebrickable/set/parts.html.twig', [
|
||||
'regularParts' => $regularParts,
|
||||
'spareParts' => $spareParts,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/download/{number}", name="set_download")
|
||||
*/
|
||||
public function downloadZipAction(Request $request, $number) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
// /**
|
||||
// * @Route("/download/{number}", name="set_download")
|
||||
// */
|
||||
// public function downloadZipAction(Request $request, $number) {
|
||||
// $em = $this->getDoctrine()->getManager();
|
||||
//
|
||||
// $inventoryParts = $em->getRepository(Inventory_Part::class)->findAllBySetNumber($number);
|
||||
//
|
||||
// $zip = new \ZipArchive();
|
||||
// $zipName = 'set_'.$number.'.zip';
|
||||
// $zip->open($zipName, \ZipArchive::CREATE);
|
||||
// /** @var Inventory_Part $part */
|
||||
// foreach ($inventoryParts as $part) {
|
||||
// $filename = $part->getPart()->getNumber().'_('.$part->getColor()->getName().'_'.$part->getQuantity().'x).stl';
|
||||
//
|
||||
// try {
|
||||
// if($part->getPart()->getModel()) {
|
||||
// $zip->addFromString($filename, $this->get('oneup_flysystem.media_filesystem')->read($part->getPart()->getModel()->getPath()));
|
||||
// }
|
||||
// } catch (\Exception $e) {
|
||||
// dump($e);
|
||||
// }
|
||||
// }
|
||||
// $zip->close();
|
||||
//
|
||||
// $response = new Response(file_get_contents($zipName));
|
||||
// $response->headers->set('Content-Type', 'application/zip');
|
||||
// $response->headers->set('Content-Disposition', 'attachment;filename="' . $zipName . '"');
|
||||
// $response->headers->set('Content-length', filesize($zipName));
|
||||
//
|
||||
// return $response;
|
||||
// }
|
||||
|
||||
$inventoryParts = $em->getRepository(Inventory_Part::class)->findAllBySetNumber($number);
|
||||
|
||||
$zip = new \ZipArchive();
|
||||
$zipName = 'set_'.$number.'.zip';
|
||||
$zip->open($zipName, \ZipArchive::CREATE);
|
||||
/** @var Inventory_Part $part */
|
||||
foreach ($inventoryParts as $part) {
|
||||
$filename = $part->getPart()->getNumber().'_('.$part->getColor()->getName().'_'.$part->getQuantity().'x).stl';
|
||||
|
||||
try {
|
||||
if($part->getPart()->getModel()) {
|
||||
$zip->addFromString($filename, $this->get('oneup_flysystem.media_filesystem')->read($part->getPart()->getModel()->getPath()));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
dump($e);
|
||||
}
|
||||
}
|
||||
$zip->close();
|
||||
|
||||
$response = new Response(file_get_contents($zipName));
|
||||
$response->headers->set('Content-Type', 'application/zip');
|
||||
$response->headers->set('Content-Disposition', 'attachment;filename="' . $zipName . '"');
|
||||
$response->headers->set('Content-length', filesize($zipName));
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
129
src/AppBundle/Controller/SetController.php
Normal file
129
src/AppBundle/Controller/SetController.php
Normal file
@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Controller;
|
||||
|
||||
use AppBundle\Api\Exception\EmptyResponseException;
|
||||
use AppBundle\Entity\LDraw\Model;
|
||||
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\Theme;
|
||||
use AppBundle\Form\FilterSetType;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* @Route("/sets")
|
||||
*/
|
||||
class SetController extends Controller
|
||||
{
|
||||
/**
|
||||
* @Route("/", name="set_index")
|
||||
*/
|
||||
public function indexAction(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$qb = $em->getRepository(Set::class)->createQueryBuilder('s');
|
||||
|
||||
$paginator = $this->get('knp_paginator');
|
||||
$sets = $paginator->paginate(
|
||||
$qb->getQuery(),
|
||||
$request->query->getInt('page', 1)/*page number*/,
|
||||
$request->query->getInt('limit', 30)/*limit per page*/
|
||||
);
|
||||
|
||||
return $this->render('set/index.html.twig', [
|
||||
'sets' => $sets,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{number}", name="set_detail")
|
||||
*/
|
||||
public function detailAction(Request $request, $number)
|
||||
{
|
||||
$brset = null;
|
||||
$rbset = null;
|
||||
try {
|
||||
if(($rbset = $this->getDoctrine()->getManager()->getRepository(Set::class)->find($number)) == null) {
|
||||
$this->addFlash('warning', 'Set not found in Rebrickable database');
|
||||
};
|
||||
|
||||
$brset = $this->get('api.manager.brickset')->getSetByNumber($number);
|
||||
} catch (EmptyResponseException $e) {
|
||||
$this->addFlash('warning', 'Set not found in Brickset database');
|
||||
} catch (\Exception $e) {
|
||||
$this->addFlash('error', $e->getMessage());
|
||||
}
|
||||
|
||||
return $this->render('set/detail.html.twig', [
|
||||
'rbset' => $rbset,
|
||||
'brset' => $brset,
|
||||
]);
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * @Route("/{number}/parts", name="set_parts")
|
||||
// */
|
||||
// public function partsAction(Set $set) {
|
||||
// $em = $this->getDoctrine()->getManager();
|
||||
//
|
||||
// $em->getRepository(Color::class)->findAll();
|
||||
// $em->getRepository(Part::class)->findAllBySetNumber($set->getNumber());
|
||||
//
|
||||
// $regularParts = $em->getRepository(Inventory_Part::class)->findAllRegularBySetNumber($set->getNumber());
|
||||
// $spareParts = $em->getRepository(Inventory_Part::class)->findAllSpareBySetNumber($set->getNumber());
|
||||
//
|
||||
// $count = 0;
|
||||
// /** @var Inventory_Part $inventoryPart */
|
||||
// foreach ($regularParts as $inventoryPart) {
|
||||
// $count += $inventoryPart->getQuantity();
|
||||
// }
|
||||
//
|
||||
// dump($count);
|
||||
//
|
||||
// return $this->render('rebrickable/set/parts.html.twig', [
|
||||
// 'regularParts' => $regularParts,
|
||||
// 'spareParts' => $spareParts,
|
||||
// 'totalParts' => $count
|
||||
// ]);
|
||||
// }
|
||||
//
|
||||
//// /**
|
||||
//// * @Route("/download/{number}", name="set_download")
|
||||
//// */
|
||||
//// public function downloadZipAction(Request $request, $number) {
|
||||
//// $em = $this->getDoctrine()->getManager();
|
||||
////
|
||||
//// $inventoryParts = $em->getRepository(Inventory_Part::class)->findAllBySetNumber($number);
|
||||
////
|
||||
//// $zip = new \ZipArchive();
|
||||
//// $zipName = 'set_'.$number.'.zip';
|
||||
//// $zip->open($zipName, \ZipArchive::CREATE);
|
||||
//// /** @var Inventory_Part $part */
|
||||
//// foreach ($inventoryParts as $part) {
|
||||
//// $filename = $part->getPart()->getNumber().'_('.$part->getColor()->getName().'_'.$part->getQuantity().'x).stl';
|
||||
////
|
||||
//// try {
|
||||
//// if($part->getPart()->getModel()) {
|
||||
//// $zip->addFromString($filename, $this->get('oneup_flysystem.media_filesystem')->read($part->getPart()->getModel()->getPath()));
|
||||
//// }
|
||||
//// } catch (\Exception $e) {
|
||||
//// dump($e);
|
||||
//// }
|
||||
//// }
|
||||
//// $zip->close();
|
||||
////
|
||||
//// $response = new Response(file_get_contents($zipName));
|
||||
//// $response->headers->set('Content-Type', 'application/zip');
|
||||
//// $response->headers->set('Content-Disposition', 'attachment;filename="' . $zipName . '"');
|
||||
//// $response->headers->set('Content-length', filesize($zipName));
|
||||
////
|
||||
//// return $response;
|
||||
//// }
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user