mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Added a basic admin page for footprints.
This commit is contained in:
parent
defd169737
commit
2ea0dc16e0
4 changed files with 131 additions and 0 deletions
110
src/Controller/FootprintController.php
Normal file
110
src/Controller/FootprintController.php
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* part-db version 0.1
|
||||||
|
* Copyright (C) 2005 Christoph Lechner
|
||||||
|
* http://www.cl-projects.de/
|
||||||
|
*
|
||||||
|
* part-db version 0.2+
|
||||||
|
* Copyright (C) 2009 K. Jacobs and others (see authors.php)
|
||||||
|
* http://code.google.com/p/part-db/
|
||||||
|
*
|
||||||
|
* Part-DB Version 0.4+
|
||||||
|
* Copyright (C) 2016 - 2019 Jan Böhmer
|
||||||
|
* https://github.com/jbtronics
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Entity\AttachmentType;
|
||||||
|
|
||||||
|
use App\Entity\Footprint;
|
||||||
|
use App\Form\BaseEntityAdminForm;
|
||||||
|
use App\Services\EntityExporter;
|
||||||
|
use App\Services\EntityImporter;
|
||||||
|
use App\Services\StructuralElementRecursionHelper;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/footprint")
|
||||||
|
* @package App\Controller
|
||||||
|
*/
|
||||||
|
class FootprintController extends BaseAdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $entity_class = Footprint::class;
|
||||||
|
protected $twig_template = 'AdminPages/FootprintAdmin.html.twig';
|
||||||
|
protected $form_class = BaseEntityAdminForm::class;
|
||||||
|
protected $route_base = "footprint";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/{id}/edit", requirements={"id"="\d+"}, name="footprint_edit")
|
||||||
|
* @Route("/{id}/", requirements={"id"="\d+"})
|
||||||
|
*/
|
||||||
|
public function edit(Footprint $entity, Request $request, EntityManagerInterface $em)
|
||||||
|
{
|
||||||
|
return $this->_edit($entity, $request, $em);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/new", name="footprint_new")
|
||||||
|
* @Route("/")
|
||||||
|
*
|
||||||
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
|
*/
|
||||||
|
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
|
||||||
|
{
|
||||||
|
return $this->_new($request, $em, $importer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/{id}", name="footprint_delete", methods={"DELETE"})
|
||||||
|
*/
|
||||||
|
public function delete(Request $request, Footprint $entity, StructuralElementRecursionHelper $recursionHelper)
|
||||||
|
{
|
||||||
|
return $this->_delete($request, $entity, $recursionHelper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/export", name="footprint_export_all")
|
||||||
|
* @param Request $request
|
||||||
|
* @param SerializerInterface $serializer
|
||||||
|
* @param EntityManagerInterface $em
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||||
|
{
|
||||||
|
return $this->_exportAll($em, $exporter, $request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/{id}/export", name="footprint_export")
|
||||||
|
* @param Request $request
|
||||||
|
* @param AttachmentType $entity
|
||||||
|
*/
|
||||||
|
public function exportEntity(AttachmentType $entity, EntityExporter $exporter, Request $request)
|
||||||
|
{
|
||||||
|
return $this->_exportEntity($entity, $exporter, $request);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -32,6 +32,7 @@ namespace App\Services;
|
||||||
use App\Entity\AttachmentType;
|
use App\Entity\AttachmentType;
|
||||||
use App\Entity\Category;
|
use App\Entity\Category;
|
||||||
use App\Entity\Device;
|
use App\Entity\Device;
|
||||||
|
use App\Entity\Footprint;
|
||||||
use App\Entity\Manufacturer;
|
use App\Entity\Manufacturer;
|
||||||
use App\Entity\NamedDBElement;
|
use App\Entity\NamedDBElement;
|
||||||
use App\Entity\Part;
|
use App\Entity\Part;
|
||||||
|
@ -139,6 +140,10 @@ class EntityURLGenerator
|
||||||
return $this->urlGenerator->generate("store_location_edit", ['id' => $entity->getID()]);
|
return $this->urlGenerator->generate("store_location_edit", ['id' => $entity->getID()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($entity instanceof Footprint) {
|
||||||
|
return $this->urlGenerator->generate("footprint_edit", ['id' => $entity->getID()]);
|
||||||
|
}
|
||||||
|
|
||||||
//Otherwise throw an error
|
//Otherwise throw an error
|
||||||
throw new EntityNotSupported('The given entity is not supported yet!');
|
throw new EntityNotSupported('The given entity is not supported yet!');
|
||||||
}
|
}
|
||||||
|
@ -180,6 +185,10 @@ class EntityURLGenerator
|
||||||
return $this->urlGenerator->generate('store_location_new');
|
return $this->urlGenerator->generate('store_location_new');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($entity instanceof Footprint) {
|
||||||
|
return $this->urlGenerator->generate('footprint_new');
|
||||||
|
}
|
||||||
|
|
||||||
throw new EntityNotSupported('The given entity is not supported yet!');
|
throw new EntityNotSupported('The given entity is not supported yet!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,6 +251,10 @@ class EntityURLGenerator
|
||||||
return $this->urlGenerator->generate('store_location_new', ['id' => $entity->getID()]);
|
return $this->urlGenerator->generate('store_location_new', ['id' => $entity->getID()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($entity instanceof Footprint) {
|
||||||
|
return $this->urlGenerator->generate('footprint_new', ['id' => $entity->getID()]);
|
||||||
|
}
|
||||||
|
|
||||||
throw new EntityNotSupported('The given entity is not supported yet!');
|
throw new EntityNotSupported('The given entity is not supported yet!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,9 @@ class ToolsTreeBuilder
|
||||||
$nodes[] = new TreeViewNode($this->translator->trans('tree.tools.edit.storelocation'),
|
$nodes[] = new TreeViewNode($this->translator->trans('tree.tools.edit.storelocation'),
|
||||||
$this->urlGenerator->generate('store_location_new'));
|
$this->urlGenerator->generate('store_location_new'));
|
||||||
|
|
||||||
|
$nodes[] = new TreeViewNode($this->translator->trans('tree.tools.edit.footprint'),
|
||||||
|
$this->urlGenerator->generate('footprint_new'));
|
||||||
|
|
||||||
$nodes[] = new TreeViewNode($this->translator->trans('tree.tools.edit.part'),
|
$nodes[] = new TreeViewNode($this->translator->trans('tree.tools.edit.part'),
|
||||||
$this->urlGenerator->generate('part_new'));
|
$this->urlGenerator->generate('part_new'));
|
||||||
|
|
||||||
|
|
5
templates/AdminPages/FootprintAdmin.html.twig
Normal file
5
templates/AdminPages/FootprintAdmin.html.twig
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{% extends "AdminPages/EntityAdminBase.html.twig" %}
|
||||||
|
|
||||||
|
{% block card_title %}
|
||||||
|
<i class="fas fa-microchip fa-fw"></i> {% trans %}footprint.labelp{% endtrans %}
|
||||||
|
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue