From 699a5c935f4a7fc4cbe0a0d4d29e42f0bed5d900 Mon Sep 17 00:00:00 2001 From: d-buchmann Date: Wed, 2 Jul 2025 22:11:28 +0200 Subject: [PATCH 1/2] fix sidebar root node links (#957) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix sidebar root node links link sidebar root nodes to their corresponding "new" route * Use "Show all parts" for most root categories and started to make it configurable for the future --------- Co-authored-by: Jan Böhmer --- src/Services/Trees/TreeViewGenerator.php | 29 ++++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/Services/Trees/TreeViewGenerator.php b/src/Services/Trees/TreeViewGenerator.php index 23d6a406..c66f2ee2 100644 --- a/src/Services/Trees/TreeViewGenerator.php +++ b/src/Services/Trees/TreeViewGenerator.php @@ -63,7 +63,8 @@ class TreeViewGenerator private readonly UrlGeneratorInterface $router, protected bool $rootNodeExpandedByDefault, protected bool $rootNodeEnabled, - + //TODO: Make this configurable in the future + protected bool $rootNodeRedirectsToNewEntity = false, ) { } @@ -174,10 +175,7 @@ class TreeViewGenerator } if (($mode === 'list_parts_root' || $mode === 'devices') && $this->rootNodeEnabled) { - //We show the root node as a link to the list of all parts - $show_all_parts_url = $this->router->generate('parts_show_all'); - - $root_node = new TreeViewNode($this->entityClassToRootNodeString($class), $show_all_parts_url, $generic); + $root_node = new TreeViewNode($this->entityClassToRootNodeString($class), $this->entityClassToRootNodeHref($class), $generic); $root_node->setExpanded($this->rootNodeExpandedByDefault); $root_node->setIcon($this->entityClassToRootNodeIcon($class)); @@ -187,6 +185,27 @@ class TreeViewGenerator return array_merge($head, $generic); } + protected function entityClassToRootNodeHref(string $class): ?string + { + //If the root node should redirect to the new entity page, we return the URL for the new entity. + if ($this->rootNodeRedirectsToNewEntity) { + return match ($class) { + Category::class => $this->router->generate('category_new'), + StorageLocation::class => $this->router->generate('store_location_new'), + Footprint::class => $this->router->generate('footprint_new'), + Manufacturer::class => $this->router->generate('manufacturer_new'), + Supplier::class => $this->router->generate('supplier_new'), + Project::class => $this->router->generate('project_new'), + default => null, + }; + } + + return match ($class) { + Project::class => $this->router->generate('project_new'), + default => $this->router->generate('parts_show_all') + }; + } + protected function entityClassToRootNodeString(string $class): string { return match ($class) { From 00a74ed96ad4a08f3c98ddb8c64fa3b4ce506b86 Mon Sep 17 00:00:00 2001 From: d-buchmann Date: Wed, 2 Jul 2025 22:31:13 +0200 Subject: [PATCH 2/2] Add env option to disable part image overlay (#960) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add env option to disable part image overlay Fixes #369 while preserving the state as-is * Added documentation and use 1 instead of true for new env --------- Co-authored-by: Jan Böhmer --- .docker/symfony.conf | 1 + .env | 3 +++ config/packages/twig.yaml | 1 + config/parameters.yaml | 1 + docs/configuration.md | 2 ++ templates/parts/info/_picture.html.twig | 2 ++ 6 files changed, 10 insertions(+) diff --git a/.docker/symfony.conf b/.docker/symfony.conf index b5229bf6..0d69c00c 100644 --- a/.docker/symfony.conf +++ b/.docker/symfony.conf @@ -47,6 +47,7 @@ PassEnv PROVIDER_REICHELT_ENABLED PROVIDER_REICHELT_CURRENCY PROVIDER_REICHELT_COUNTRY PROVIDER_REICHELT_LANGUAGE PROVIDER_REICHELT_INCLUDE_VAT PassEnv PROVIDER_POLLIN_ENABLED PassEnv EDA_KICAD_CATEGORY_DEPTH + PassEnv SHOW_PART_IMAGE_OVERLAY # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to diff --git a/.env b/.env index 1806e9c6..886de47f 100644 --- a/.env +++ b/.env @@ -305,6 +305,9 @@ FIXER_API_KEY=CHANGEME # When this is empty the content of config/banner.md is used as banner BANNER="" +# Enable the part image overlay which shows name and filename of the picture +SHOW_PART_IMAGE_OVERLAY=1 + APP_ENV=prod APP_SECRET=a03498528f5a5fc089273ec9ae5b2849 diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index 5b2d64e5..044f7d21 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -21,6 +21,7 @@ twig: available_themes: '%partdb.available_themes%' saml_enabled: '%partdb.saml.enabled%' part_preview_generator: '@App\Services\Attachments\PartPreviewGenerator' + img_overlay: '%partdb.show_part_image_overlay%' when@test: twig: diff --git a/config/parameters.yaml b/config/parameters.yaml index b2c10893..5e647766 100644 --- a/config/parameters.yaml +++ b/config/parameters.yaml @@ -74,6 +74,7 @@ parameters: # Miscellaneous ###################################################################################################################### partdb.demo_mode: '%env(bool:DEMO_MODE)%' # If set to true, all potentially dangerous things are disabled (like changing passwords of the own user) + partdb.show_part_image_overlay: '%env(bool:SHOW_PART_IMAGE_OVERLAY)%' # If set to false, the filename overlay of the part image will be disabled # Set the themes from which the user can choose from in the settings. # Themes commented here by default, are not really usable, because of display problems. Enable them at your own risk! diff --git a/docs/configuration.md b/docs/configuration.md index 0ad30a00..b4e5efc4 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -95,6 +95,8 @@ bundled with Part-DB. Set `DATABASE_MYSQL_SSL_VERIFY_CERT` if you want to accept particularly for securing and protecting various aspects of your application. It's a secret key that is used for cryptographic operations and security measures (session management, CSRF protection, etc..). Therefore this value should be handled as confidential data and not shared publicly. +* `SHOW_PART_IMAGE_OVERLAY`: Set to 0 to disable the part image overlay, which appears if you hover over an image in the + part image gallery ### E-Mail settings diff --git a/templates/parts/info/_picture.html.twig b/templates/parts/info/_picture.html.twig index b532f9b9..6bfb2472 100644 --- a/templates/parts/info/_picture.html.twig +++ b/templates/parts/info/_picture.html.twig @@ -13,6 +13,7 @@ {% endfor %}