From 04b660d77724f1253e2fd74b0ab55a9c0daa9832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Mon, 9 Jan 2023 23:40:54 +0100 Subject: [PATCH] Finished builtin footprints viewer tool. --- config/permissions.yaml | 2 ++ src/Controller/ToolsController.php | 4 ++- src/Services/Trees/ToolsTreeBuilder.php | 6 +++++ .../UserSystem/PermissionPresetsHelper.php | 1 + .../BuiltInFootprintsViewer/main.html.twig | 9 +++++-- .../ApplicationAvailabilityFunctionalTest.php | 1 + translations/messages.en.xlf | 26 ++++++++++++++----- 7 files changed, 39 insertions(+), 10 deletions(-) diff --git a/config/permissions.yaml b/config/permissions.yaml index 41617666..9fbaf282 100644 --- a/config/permissions.yaml +++ b/config/permissions.yaml @@ -130,6 +130,8 @@ perms: # Here comes a list with all Permission names (they have a perm_[name] co label: "perm.tools.label_scanner" reel_calculator: label: "perm.tools.reel_calculator" + builtin_footprints_viewer: + label: "tools.builtin_footprints_viewer.title" groups: label: "perm.groups" diff --git a/src/Controller/ToolsController.php b/src/Controller/ToolsController.php index e9c68c3e..67bd2eff 100644 --- a/src/Controller/ToolsController.php +++ b/src/Controller/ToolsController.php @@ -90,12 +90,14 @@ class ToolsController extends AbstractController } /** - * @Route("/builtin_footprints") + * @Route("/builtin_footprints", name="tools_builtin_footprints_viewer") * @param AttachmentPathResolver $pathResolver * @return Response */ public function builtInFootprintsViewer(BuiltinAttachmentsFinder $builtinAttachmentsFinder, AttachmentURLGenerator $urlGenerator, ): Response { + $this->denyAccessUnlessGranted('@tools.builtin_footprints_viewer'); + $grouped_footprints = $builtinAttachmentsFinder->getListOfFootprintsGroupedByFolder(); $grouped_footprints = array_map(function($group) use ($urlGenerator) { return array_map(function($placeholder_filepath) use ($urlGenerator) { diff --git a/src/Services/Trees/ToolsTreeBuilder.php b/src/Services/Trees/ToolsTreeBuilder.php index d0384911..9ef07e17 100644 --- a/src/Services/Trees/ToolsTreeBuilder.php +++ b/src/Services/Trees/ToolsTreeBuilder.php @@ -131,6 +131,12 @@ class ToolsTreeBuilder $this->urlGenerator->generate('tools_reel_calculator') ))->setIcon('fa-treeview fa-fw fa-solid fa-ruler'); } + if ($this->security->isGranted('@tools.builtin_footprints_viewer')) { + $nodes[] = (new TreeViewNode( + $this->translator->trans('tools.builtin_footprints_viewer.title'), + $this->urlGenerator->generate('tools_builtin_footprints_viewer') + ))->setIcon('fa-treeview fa-fw fa-solid fa-images'); + } return $nodes; } diff --git a/src/Services/UserSystem/PermissionPresetsHelper.php b/src/Services/UserSystem/PermissionPresetsHelper.php index 20ae7248..54d4beff 100644 --- a/src/Services/UserSystem/PermissionPresetsHelper.php +++ b/src/Services/UserSystem/PermissionPresetsHelper.php @@ -139,6 +139,7 @@ class PermissionPresetsHelper $this->permissionResolver->setPermission($perm_holder, 'tools', 'statistics', PermissionData::ALLOW); $this->permissionResolver->setPermission($perm_holder, 'tools', 'label_scanner', PermissionData::ALLOW); $this->permissionResolver->setPermission($perm_holder, 'tools', 'reel_calculator', PermissionData::ALLOW); + $this->permissionResolver->setPermission($perm_holder, 'tools', 'builtin_footprints_viewer', PermissionData::ALLOW); //Set attachments permissions $this->permissionResolver->setPermission($perm_holder, 'attachments', 'list_attachments', PermissionData::ALLOW); diff --git a/templates/Tools/BuiltInFootprintsViewer/main.html.twig b/templates/Tools/BuiltInFootprintsViewer/main.html.twig index e57c3c90..d66d95fe 100644 --- a/templates/Tools/BuiltInFootprintsViewer/main.html.twig +++ b/templates/Tools/BuiltInFootprintsViewer/main.html.twig @@ -2,7 +2,7 @@ {% macro path_to_breadcrumb(path) %} {% endmacro %} +{% block title %}{% trans %}tools.builtin_footprints_viewer.title{% endtrans %}{% endblock %} + {% block card_title %} - Built in Footprints + {% trans %}tools.builtin_footprints_viewer.title{% endtrans %} {% endblock %} {% block card_content %} + +

{% trans %}tools.builtin_footprints_viewer.hint{% endtrans %}

+ {% for folder, file_array in grouped_footprints %} {{ _self.path_to_breadcrumb(folder) }} diff --git a/tests/ApplicationAvailabilityFunctionalTest.php b/tests/ApplicationAvailabilityFunctionalTest.php index 18fac229..2cf6bbfa 100644 --- a/tests/ApplicationAvailabilityFunctionalTest.php +++ b/tests/ApplicationAvailabilityFunctionalTest.php @@ -123,6 +123,7 @@ class ApplicationAvailabilityFunctionalTest extends WebTestCase //Tools yield ['/tools/reel_calc']; yield ['/tools/server_infos']; + yield ['/tools/builtin_footprints']; //Webauthn Register yield ['/webauthn/register']; diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index d66f855a..c2a2da87 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -147,7 +147,7 @@ New currency - + Part-DB1\templates\AdminPages\DeviceAdmin.html.twig:4 Part-DB1\templates\AdminPages\DeviceAdmin.html.twig:4 @@ -158,7 +158,7 @@ Project - + Part-DB1\templates\AdminPages\DeviceAdmin.html.twig:8 new @@ -168,7 +168,7 @@ Edit project - + Part-DB1\templates\AdminPages\DeviceAdmin.html.twig:12 new @@ -4095,7 +4095,7 @@ If you have done this incorrectly or if a computer is no longer trusted, you can Go! - + Part-DB1\templates\_sidebar.html.twig:37 Part-DB1\templates\_sidebar.html.twig:12 @@ -6025,7 +6025,7 @@ If you have done this incorrectly or if a computer is no longer trusted, you can Attachment type - + Part-DB1\src\Services\ElementTypeNameGenerator.php:82 Part-DB1\src\Services\ElementTypeNameGenerator.php:82 @@ -6215,7 +6215,7 @@ If you have done this incorrectly or if a computer is no longer trusted, you can Categories - + Part-DB1\src\Services\Trees\ToolsTreeBuilder.php:161 Part-DB1\src\Services\Trees\ToolsTreeBuilder.php:138 @@ -8112,7 +8112,7 @@ Element 3 Manufacturers - + obsolete obsolete @@ -10249,5 +10249,17 @@ Element 3 Move target + + + tools.builtin_footprints_viewer.title + Builtin footprint image gallery + + + + + tools.builtin_footprints_viewer.hint + This gallery lists all available builtin footprint images. If you want to use them in an attachment, type in the name (or a keyword) in the path field of the attachment and select the image from the dropdown select. + +