mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Migrated kicad category depth setting to new settings system
This commit is contained in:
parent
99c10ffe85
commit
5e512f8935
8 changed files with 110 additions and 14 deletions
4
.env
4
.env
|
@ -152,8 +152,8 @@ PROVIDER_LCSC_CURRENCY=EUR
|
|||
|
||||
# This value determines the depth of the category tree, that is visible inside KiCad
|
||||
# 0 means that only the top level categories are visible. Set to a value > 0 to show more levels.
|
||||
# Set to -1, to show all parts of Part-DB inside a single category in KiCad
|
||||
EDA_KICAD_CATEGORY_DEPTH=0
|
||||
# Set to -1, to show all parts of Part-DB inside a sigle cnategory in KiCad
|
||||
#EDA_KICAD_CATEGORY_DEPTH=0
|
||||
|
||||
###################################################################################
|
||||
# SAML Single sign on-settings
|
||||
|
|
|
@ -122,6 +122,4 @@ parameters:
|
|||
|
||||
env(SAML_ROLE_MAPPING): '{}'
|
||||
|
||||
env(EDA_KICAD_CATEGORY_DEPTH): 0
|
||||
|
||||
env(DATABASE_EMULATE_NATURAL_SORT): 0
|
||||
|
|
|
@ -234,13 +234,6 @@ services:
|
|||
arguments:
|
||||
$default_uri: '%partdb.default_uri%'
|
||||
|
||||
####################################################################################################################
|
||||
# EDA system
|
||||
####################################################################################################################
|
||||
App\Services\EDA\KiCadHelper:
|
||||
arguments:
|
||||
$category_depth: '%env(int:EDA_KICAD_CATEGORY_DEPTH)%'
|
||||
|
||||
####################################################################################################################
|
||||
# Symfony overrides
|
||||
####################################################################################################################
|
||||
|
|
|
@ -28,6 +28,7 @@ use App\Entity\Parts\Footprint;
|
|||
use App\Entity\Parts\Part;
|
||||
use App\Services\Cache\ElementCacheTagGenerator;
|
||||
use App\Services\Trees\NodesListBuilder;
|
||||
use App\Settings\MiscSettings\KiCadEDASettings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
@ -38,6 +39,9 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||
class KiCadHelper
|
||||
{
|
||||
|
||||
/** @var int The maximum level of the shown categories. 0 Means only the top level categories are shown. -1 means only a single one containing */
|
||||
private readonly int $category_depth;
|
||||
|
||||
public function __construct(
|
||||
private readonly NodesListBuilder $nodesListBuilder,
|
||||
private readonly TagAwareCacheInterface $kicadCache,
|
||||
|
@ -45,9 +49,9 @@ class KiCadHelper
|
|||
private readonly ElementCacheTagGenerator $tagGenerator,
|
||||
private readonly UrlGeneratorInterface $urlGenerator,
|
||||
private readonly TranslatorInterface $translator,
|
||||
/** The maximum level of the shown categories. 0 Means only the top level categories are shown. -1 means only a single one containing */
|
||||
private readonly int $category_depth,
|
||||
KiCadEDASettings $kiCadEDASettings,
|
||||
) {
|
||||
$this->category_depth = $kiCadEDASettings->categoryDepth;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||
namespace App\Settings;
|
||||
|
||||
use App\Settings\InfoProviderSystem\InfoProviderSettings;
|
||||
use App\Settings\MiscSettings\MiscSettings;
|
||||
use App\Settings\SystemSettings\AttachmentsSettings;
|
||||
use Jbtronics\SettingsBundle\Settings\EmbeddedSettings;
|
||||
use Jbtronics\SettingsBundle\Settings\Settings;
|
||||
|
@ -38,7 +39,9 @@ class AppSettings
|
|||
#[EmbeddedSettings()]
|
||||
public ?SystemSettings $system = null;
|
||||
|
||||
|
||||
#[EmbeddedSettings()]
|
||||
public ?InfoProviderSettings $infoProviders = null;
|
||||
|
||||
#[EmbeddedSettings()]
|
||||
public ?MiscSettings $miscSettings = null;
|
||||
}
|
46
src/Settings/MiscSettings/KiCadEDASettings.php
Normal file
46
src/Settings/MiscSettings/KiCadEDASettings.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 - 2024 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 Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace App\Settings\MiscSettings;
|
||||
|
||||
use App\Settings\SettingsIcon;
|
||||
use Jbtronics\SettingsBundle\Metadata\EnvVarMode;
|
||||
use Jbtronics\SettingsBundle\Settings\Settings;
|
||||
use Jbtronics\SettingsBundle\Settings\SettingsParameter;
|
||||
use Jbtronics\SettingsBundle\Settings\SettingsTrait;
|
||||
use Symfony\Component\Translation\TranslatableMessage as TM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
#[Settings(label: new TM("settings.misc.kicad_eda"))]
|
||||
#[SettingsIcon("fa-bolt-lightning")]
|
||||
class KiCadEDASettings
|
||||
{
|
||||
use SettingsTrait;
|
||||
|
||||
|
||||
#[SettingsParameter(label: new TM("settings.misc.kicad_eda.category_depth"),
|
||||
description: new TM("settings.misc.kicad_eda.category_depth.help"),
|
||||
envVar: "int:EDA_KICAD_CATEGORY_DEPTH", envVarMode: EnvVarMode::OVERWRITE)]
|
||||
#[Assert\Range(min: -1)]
|
||||
public int $categoryDepth = 0;
|
||||
}
|
34
src/Settings/MiscSettings/MiscSettings.php
Normal file
34
src/Settings/MiscSettings/MiscSettings.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 - 2024 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 Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace App\Settings\MiscSettings;
|
||||
|
||||
use Jbtronics\SettingsBundle\Settings\EmbeddedSettings;
|
||||
use Jbtronics\SettingsBundle\Settings\Settings;
|
||||
|
||||
#[Settings]
|
||||
class MiscSettings
|
||||
{
|
||||
#[EmbeddedSettings]
|
||||
public ?KiCadEDASettings $kicadEDA = null;
|
||||
}
|
|
@ -12594,5 +12594,23 @@ Please note, that you can not impersonate a disabled user. If you try you will g
|
|||
<target>Server settings</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="5WsYY.a" name="settings.misc.kicad_eda">
|
||||
<segment>
|
||||
<source>settings.misc.kicad_eda</source>
|
||||
<target>KiCAD integration</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="U83kTE5" name="settings.misc.kicad_eda.category_depth">
|
||||
<segment>
|
||||
<source>settings.misc.kicad_eda.category_depth</source>
|
||||
<target>Category depth</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="GudCzRb" name="settings.misc.kicad_eda.category_depth.help">
|
||||
<segment>
|
||||
<source>settings.misc.kicad_eda.category_depth.help</source>
|
||||
<target><![CDATA[This value determines the depth of the category tree, that is visible inside KiCad. 0 means that only the top level categories are visible. Set to a value > 0 to show more levels. Set to -1, to show all parts of Part-DB inside a sigle cnategory in KiCad.]]></target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue