From cf791cff1deb0f6aada52032e063abc36fd7e00e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 11 May 2025 00:41:22 +0200 Subject: [PATCH 001/138] New translations messages.en.xlf (English) --- translations/messages.en.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index e974d34a..260668d4 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -12360,7 +12360,7 @@ Please note, that you can not impersonate a disabled user. If you try you will g part_list.action.action.change_location - Change location (only for parts with single stock) + Change location (only for parts with single lot) From 6e28f2a74e11711fa1e9a91b4f66bf60ea121688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 6 Jul 2025 19:09:10 +0200 Subject: [PATCH 002/138] Moved rootNodeRedirectsToNewEntity option to new settings system --- src/Settings/BehaviorSettings/SidebarSettings.php | 4 ++++ translations/messages.en.xlf | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/Settings/BehaviorSettings/SidebarSettings.php b/src/Settings/BehaviorSettings/SidebarSettings.php index e0e9e31f..1266fa47 100644 --- a/src/Settings/BehaviorSettings/SidebarSettings.php +++ b/src/Settings/BehaviorSettings/SidebarSettings.php @@ -68,5 +68,9 @@ class SidebarSettings #[SettingsParameter(label: new TM("settings.behavior.sidebar.rootNodeExpanded"))] public bool $rootNodeExpanded = true; + /** + * @var bool Whether the root node should redirect to a new entity creation page when clicked. + */ + #[SettingsParameter(label: new TM("settings.behavior.sidebar.rootNodeRedirectsToNewEntity"))] public bool $rootNodeRedirectsToNewEntity = false; } \ No newline at end of file diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index 3ca784cd..76bf65fb 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -12922,5 +12922,11 @@ Please note, that you can not impersonate a disabled user. If you try you will g Pollin.de offers no official API, so this info provider webscrapes the website to extract info. It could break at any time, use it at your own risk. + + + settings.behavior.sidebar.rootNodeRedirectsToNewEntity + Root nodes redirect to new entity pages + + From 1dbcff66d16cbee47aa813c7e1c32195759be19f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 6 Jul 2025 19:32:55 +0200 Subject: [PATCH 003/138] Moved digikey IPS configuration to new settings system --- .env | 11 ---- config/packages/knpu_oauth2_client.yaml | 4 +- config/services.yaml | 7 -- .../Providers/DigikeyProvider.php | 16 ++--- .../InfoProviderSystem/DigikeySettings.php | 65 +++++++++++++++++++ .../InfoProviderSettings.php | 3 + translations/messages.en.xlf | 18 +++++ 7 files changed, 96 insertions(+), 28 deletions(-) create mode 100644 src/Settings/InfoProviderSystem/DigikeySettings.php diff --git a/.env b/.env index d3f99c76..0469f0eb 100644 --- a/.env +++ b/.env @@ -71,17 +71,6 @@ ERROR_PAGE_SHOW_HELP=1 # Info provider settings ################################################################################## -# Digikey Provider: -# You can get your client id and secret from https://developer.digikey.com/ -PROVIDER_DIGIKEY_CLIENT_ID= -PROVIDER_DIGIKEY_SECRET= -# The currency to get prices in -PROVIDER_DIGIKEY_CURRENCY=EUR -# The language to get results in (en, de, fr, it, es, zh, ja, ko) -PROVIDER_DIGIKEY_LANGUAGE=en -# The country to get results for -PROVIDER_DIGIKEY_COUNTRY=DE - # Octopart / Nexar Provider: # You can get your API key from https://nexar.com/api PROVIDER_OCTOPART_CLIENT_ID= diff --git a/config/packages/knpu_oauth2_client.yaml b/config/packages/knpu_oauth2_client.yaml index 7d296a8b..d84b094d 100644 --- a/config/packages/knpu_oauth2_client.yaml +++ b/config/packages/knpu_oauth2_client.yaml @@ -6,8 +6,8 @@ knpu_oauth2_client: type: generic provider_class: '\League\OAuth2\Client\Provider\GenericProvider' - client_id: '%env(PROVIDER_DIGIKEY_CLIENT_ID)%' - client_secret: '%env(PROVIDER_DIGIKEY_SECRET)%' + client_id: '%env(settings:digikey:clientId)%' + client_secret: '%env(settings:digikey:secret)%' redirect_route: 'oauth_client_check' redirect_params: {name: 'ip_digikey_oauth'} diff --git a/config/services.yaml b/config/services.yaml index dfc9a7c7..b65a4e78 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -199,13 +199,6 @@ services: arguments: $providers: !tagged_iterator 'app.info_provider' - App\Services\InfoProviderSystem\Providers\DigikeyProvider: - arguments: - $clientId: '%env(string:PROVIDER_DIGIKEY_CLIENT_ID)%' - $currency: '%env(string:PROVIDER_DIGIKEY_CURRENCY)%' - $language: '%env(string:PROVIDER_DIGIKEY_LANGUAGE)%' - $country: '%env(string:PROVIDER_DIGIKEY_COUNTRY)%' - App\Services\InfoProviderSystem\Providers\OctopartProvider: arguments: $clientId: '&env(string:PROVIDER_OCTOPART_CLIENT_ID)%' diff --git a/src/Services/InfoProviderSystem/Providers/DigikeyProvider.php b/src/Services/InfoProviderSystem/Providers/DigikeyProvider.php index b20368ce..c2113b4d 100644 --- a/src/Services/InfoProviderSystem/Providers/DigikeyProvider.php +++ b/src/Services/InfoProviderSystem/Providers/DigikeyProvider.php @@ -31,6 +31,7 @@ use App\Services\InfoProviderSystem\DTOs\PriceDTO; use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO; use App\Services\InfoProviderSystem\DTOs\SearchResultDTO; use App\Services\OAuth\OAuthTokenManager; +use App\Settings\InfoProviderSystem\DigikeySettings; use Symfony\Contracts\HttpClient\HttpClientInterface; class DigikeyProvider implements InfoProviderInterface @@ -55,17 +56,16 @@ class DigikeyProvider implements InfoProviderInterface ]; public function __construct(HttpClientInterface $httpClient, private readonly OAuthTokenManager $authTokenManager, - private readonly string $currency, private readonly string $clientId, - private readonly string $language, private readonly string $country) + private readonly DigikeySettings $settings,) { //Create the HTTP client with some default options $this->digikeyClient = $httpClient->withOptions([ "base_uri" => self::BASE_URI, "headers" => [ - "X-DIGIKEY-Client-Id" => $clientId, - "X-DIGIKEY-Locale-Site" => $this->country, - "X-DIGIKEY-Locale-Language" => $this->language, - "X-DIGIKEY-Locale-Currency" => $this->currency, + "X-DIGIKEY-Client-Id" => $this->settings->clientId, + "X-DIGIKEY-Locale-Site" => $this->settings->country, + "X-DIGIKEY-Locale-Language" => $this->settings->language, + "X-DIGIKEY-Locale-Currency" => $this->settings->currency, "X-DIGIKEY-Customer-Id" => 0, ] ]); @@ -101,7 +101,7 @@ class DigikeyProvider implements InfoProviderInterface public function isActive(): bool { //The client ID has to be set and a token has to be available (user clicked connect) - return $this->clientId !== '' && $this->authTokenManager->hasToken(self::OAUTH_APP_NAME); + return $this->settings->clientId !== '' && $this->authTokenManager->hasToken(self::OAUTH_APP_NAME); } public function searchByKeyword(string $keyword): array @@ -268,7 +268,7 @@ class DigikeyProvider implements InfoProviderInterface $prices = []; foreach ($price_breaks as $price_break) { - $prices[] = new PriceDTO(minimum_discount_amount: $price_break['BreakQuantity'], price: (string) $price_break['UnitPrice'], currency_iso_code: $this->currency); + $prices[] = new PriceDTO(minimum_discount_amount: $price_break['BreakQuantity'], price: (string) $price_break['UnitPrice'], currency_iso_code: $this->settings->currency); } return [ diff --git a/src/Settings/InfoProviderSystem/DigikeySettings.php b/src/Settings/InfoProviderSystem/DigikeySettings.php new file mode 100644 index 00000000..e92041bb --- /dev/null +++ b/src/Settings/InfoProviderSystem/DigikeySettings.php @@ -0,0 +1,65 @@ +. + */ + +declare(strict_types=1); + + +namespace App\Settings\InfoProviderSystem; + +use App\Settings\SettingsIcon; +use Jbtronics\SettingsBundle\Settings\Settings; +use Jbtronics\SettingsBundle\Settings\SettingsTrait; +use Symfony\Component\Form\Extension\Core\Type\CountryType; +use Symfony\Component\Form\Extension\Core\Type\CurrencyType; +use Symfony\Component\Form\Extension\Core\Type\LanguageType; +use Symfony\Component\Translation\TranslatableMessage as TM; +use Jbtronics\SettingsBundle\Settings\SettingsParameter; +use Symfony\Component\Validator\Constraints as Assert; + +#[Settings(label: new TM("settings.ips.digikey"))] +#[SettingsIcon("fa-plug")] +class DigikeySettings +{ + use SettingsTrait; + + #[SettingsParameter( + label: new TM("settings.ips.digikey.client_id"), + envVar: "PROVIDER_DIGIKEY_CLIENT_ID" + )] + public ?string $clientId = null; + + #[SettingsParameter( + label: new TM("settings.ips.digikey.secret"), + envVar: "PROVIDER_DIGIKEY_SECRET" + )] + public ?string $secret = null; + + #[SettingsParameter(label: new TM("settings.ips.tme.currency"), formType: CurrencyType::class, formOptions: ["preferred_choices" => ["EUR", "USD", "CHF", "GBP"]], envVar: "PROVIDER_DIGIKEY_CURRENCY")] + #[Assert\Currency()] + public string $currency = "EUR"; + + #[SettingsParameter(label: new TM("settings.ips.tme.country"), formType: CountryType::class, envVar: "PROVIDER_DIGIKEY_COUNTRY")] + #[Assert\Country] + public string $country = "DE"; + + #[SettingsParameter(label: new TM("settings.ips.tme.language"), formType: LanguageType::class, envVar: "PROVIDER_DIGIKEY_LANGUAGE")] + #[Assert\Language] + public string $language = "en"; +} \ No newline at end of file diff --git a/src/Settings/InfoProviderSystem/InfoProviderSettings.php b/src/Settings/InfoProviderSystem/InfoProviderSettings.php index 109fbc02..7ad3c0ea 100644 --- a/src/Settings/InfoProviderSystem/InfoProviderSettings.php +++ b/src/Settings/InfoProviderSystem/InfoProviderSettings.php @@ -32,6 +32,9 @@ class InfoProviderSettings { use SettingsTrait; + #[EmbeddedSettings] + public ?DigikeySettings $digikey = null; + #[EmbeddedSettings] public ?MouserSettings $mouser = null; diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index 76bf65fb..9efccd04 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -12928,5 +12928,23 @@ Please note, that you can not impersonate a disabled user. If you try you will g Root nodes redirect to new entity pages + + + settings.ips.digikey + Digikey + + + + + settings.ips.digikey.client_id + Client ID + + + + + settings.ips.digikey.secret + Secret + + From c0c847c5be0b2bde96b765a405da5b24217cd76e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 6 Jul 2025 20:18:14 +0200 Subject: [PATCH 004/138] Moved octopart / nexar integration configuration to the new settings system --- .env | 17 ----- config/packages/knpu_oauth2_client.yaml | 4 +- config/services.yaml | 10 --- .../Providers/OctopartProvider.php | 22 +++--- .../InfoProviderSettings.php | 3 + .../InfoProviderSystem/OctopartSettings.php | 70 +++++++++++++++++++ translations/messages.en.xlf | 30 ++++++++ 7 files changed, 116 insertions(+), 40 deletions(-) create mode 100644 src/Settings/InfoProviderSystem/OctopartSettings.php diff --git a/.env b/.env index 0469f0eb..4b292298 100644 --- a/.env +++ b/.env @@ -67,23 +67,6 @@ ERROR_PAGE_ADMIN_EMAIL='' # If this is set to true, solutions to common problems are shown on error pages. Disable this, if you do not want your users to see them... ERROR_PAGE_SHOW_HELP=1 -################################################################################## -# Info provider settings -################################################################################## - -# Octopart / Nexar Provider: -# You can get your API key from https://nexar.com/api -PROVIDER_OCTOPART_CLIENT_ID= -PROVIDER_OCTOPART_SECRET= -# The currency and country to get prices for (you have to set both to get meaningful results) -# 3 letter ISO currency code (e.g. EUR, USD, GBP) -PROVIDER_OCTOPART_CURRENCY=EUR -# 2 letter ISO country code (e.g. DE, US, GB) -PROVIDER_OCTOPART_COUNTRY=DE -# The number of results to get from Octopart while searching (please note that this counts towards your API limits) -PROVIDER_OCTOPART_SEARCH_LIMIT=10 -# Set to false to include non authorized offers in the results -PROVIDER_OCTOPART_ONLY_AUTHORIZED_SELLERS=1 ################################################################################## # EDA integration related settings diff --git a/config/packages/knpu_oauth2_client.yaml b/config/packages/knpu_oauth2_client.yaml index d84b094d..5e56d5c5 100644 --- a/config/packages/knpu_oauth2_client.yaml +++ b/config/packages/knpu_oauth2_client.yaml @@ -26,8 +26,8 @@ knpu_oauth2_client: type: generic provider_class: '\League\OAuth2\Client\Provider\GenericProvider' - client_id: '%env(PROVIDER_OCTOPART_CLIENT_ID)%' - client_secret: '%env(PROVIDER_OCTOPART_SECRET)%' + client_id: '%env(settings:octopart:clientId)%' + client_secret: '%env(settings:octopart:secret)%' redirect_route: 'oauth_client_check' redirect_params: { name: 'ip_octopart_oauth' } diff --git a/config/services.yaml b/config/services.yaml index b65a4e78..6133dce7 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -199,16 +199,6 @@ services: arguments: $providers: !tagged_iterator 'app.info_provider' - App\Services\InfoProviderSystem\Providers\OctopartProvider: - arguments: - $clientId: '&env(string:PROVIDER_OCTOPART_CLIENT_ID)%' - $secret: '%env(string:PROVIDER_OCTOPART_SECRET)%' - $country: '%env(string:PROVIDER_OCTOPART_COUNTRY)%' - $currency: '%env(string:PROVIDER_OCTOPART_CURRENCY)%' - $search_limit: '%env(int:PROVIDER_OCTOPART_SEARCH_LIMIT)%' - $onlyAuthorizedSellers: '%env(bool:PROVIDER_OCTOPART_ONLY_AUTHORIZED_SELLERS)%' - - #################################################################################################################### # API system #################################################################################################################### diff --git a/src/Services/InfoProviderSystem/Providers/OctopartProvider.php b/src/Services/InfoProviderSystem/Providers/OctopartProvider.php index e28162ba..ce1ec4a4 100644 --- a/src/Services/InfoProviderSystem/Providers/OctopartProvider.php +++ b/src/Services/InfoProviderSystem/Providers/OctopartProvider.php @@ -30,6 +30,7 @@ use App\Services\InfoProviderSystem\DTOs\PartDetailDTO; use App\Services\InfoProviderSystem\DTOs\PriceDTO; use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO; use App\Services\OAuth\OAuthTokenManager; +use App\Settings\InfoProviderSystem\OctopartSettings; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\HttpClient\HttpOptions; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -114,9 +115,8 @@ class OctopartProvider implements InfoProviderInterface public function __construct(private readonly HttpClientInterface $httpClient, private readonly OAuthTokenManager $authTokenManager, private readonly CacheItemPoolInterface $partInfoCache, - private readonly string $clientId, private readonly string $secret, - private readonly string $currency, private readonly string $country, - private readonly int $search_limit, private readonly bool $onlyAuthorizedSellers) + private readonly OctopartSettings $settings, + ) { } @@ -183,7 +183,7 @@ class OctopartProvider implements InfoProviderInterface { //The client ID has to be set and a token has to be available (user clicked connect) //return /*!empty($this->clientId) && */ $this->authTokenManager->hasToken(self::OAUTH_APP_NAME); - return $this->clientId !== '' && $this->secret !== ''; + return $this->settings->clientId !== '' && $this->settings->secret !== ''; } private function mapLifeCycleStatus(?string $value): ?ManufacturingStatus @@ -347,10 +347,10 @@ class OctopartProvider implements InfoProviderInterface $result = $this->makeGraphQLCall($graphQL, [ 'keyword' => $keyword, - 'limit' => $this->search_limit, - 'currency' => $this->currency, - 'country' => $this->country, - 'authorizedOnly' => $this->onlyAuthorizedSellers, + 'limit' => $this->settings->searchLimit, + 'currency' => $this->settings->currency, + 'country' => $this->settings->country, + 'authorizedOnly' => $this->settings->onlyAuthorizedSellers, ]); $tmp = []; @@ -383,9 +383,9 @@ class OctopartProvider implements InfoProviderInterface $result = $this->makeGraphQLCall($graphql, [ 'ids' => [$id], - 'currency' => $this->currency, - 'country' => $this->country, - 'authorizedOnly' => $this->onlyAuthorizedSellers, + 'currency' => $this->settings->currency, + 'country' => $this->settings->country, + 'authorizedOnly' => $this->settings->onlyAuthorizedSellers, ]); $tmp = $this->partResultToDTO($result['data']['supParts'][0]); diff --git a/src/Settings/InfoProviderSystem/InfoProviderSettings.php b/src/Settings/InfoProviderSystem/InfoProviderSettings.php index 7ad3c0ea..3c7159cb 100644 --- a/src/Settings/InfoProviderSystem/InfoProviderSettings.php +++ b/src/Settings/InfoProviderSystem/InfoProviderSettings.php @@ -44,6 +44,9 @@ class InfoProviderSettings #[EmbeddedSettings] public ?Element14Settings $element14 = null; + #[EmbeddedSettings] + public ?OctopartSettings $octopartSettings = null; + #[EmbeddedSettings] public ?LCSCSettings $lcsc = null; diff --git a/src/Settings/InfoProviderSystem/OctopartSettings.php b/src/Settings/InfoProviderSystem/OctopartSettings.php new file mode 100644 index 00000000..905f337f --- /dev/null +++ b/src/Settings/InfoProviderSystem/OctopartSettings.php @@ -0,0 +1,70 @@ +. + */ + +declare(strict_types=1); + + +namespace App\Settings\InfoProviderSystem; + +use App\Settings\SettingsIcon; +use Jbtronics\SettingsBundle\Settings\Settings; +use Jbtronics\SettingsBundle\Settings\SettingsParameter; +use Jbtronics\SettingsBundle\Settings\SettingsTrait; +use Symfony\Component\Form\Extension\Core\Type\CountryType; +use Symfony\Component\Form\Extension\Core\Type\CurrencyType; +use Symfony\Component\Form\Extension\Core\Type\NumberType; +use Symfony\Component\Translation\TranslatableMessage as TM; +use Symfony\Component\Validator\Constraints as Assert; + +#[Settings(label: new TM("settings.ips.octopart"))] +#[SettingsIcon("fa-plug")] +class OctopartSettings +{ + use SettingsTrait; + + #[SettingsParameter( + label: new TM("settings.ips.digikey.client_id"), + envVar: "PROVIDER_OCTOPART_CLIENT_ID" + )] + public ?string $clientId = null; + + #[SettingsParameter( + label: new TM("settings.ips.digikey.secret"), + envVar: "PROVIDER_OCTOPART_SECRET" + )] + public ?string $secret = null; + + #[SettingsParameter(label: new TM("settings.ips.tme.currency"), formType: CurrencyType::class, formOptions: ["preferred_choices" => ["EUR", "USD", "CHF", "GBP"]], envVar: "PROVIDER_OCTOPART_CURRENCY")] + #[Assert\Currency()] + public string $currency = "EUR"; + + #[SettingsParameter(label: new TM("settings.ips.tme.country"), formType: CountryType::class, envVar: "PROVIDER_OCTOPART_COUNTRY")] + #[Assert\Country] + public string $country = "DE"; + + #[SettingsParameter(label: new TM("settings.ips.octopart.searchLimit"), description: new TM("settings.ips.octopart.searchLimit.help"), + formType: NumberType::class, formOptions: ["attr" => ["min" => 1, "max" => 100]], envVar: "PROVIDER_OCTOPART_SEARCH_LIMIT")] + #[Assert\Range(min: 1, max: 100)] + public int $searchLimit = 10; + + #[SettingsParameter(label: new TM("settings.ips.octopart.onlyAuthorizedSellers"), description: new TM("settings.ips.octopart.onlyAuthorizedSellers.help"))] + public bool $onlyAuthorizedSellers = true; + +} \ No newline at end of file diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index 9efccd04..56f5cb27 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -12946,5 +12946,35 @@ Please note, that you can not impersonate a disabled user. If you try you will g Secret + + + settings.ips.octopart + Octopart / Nexar + + + + + settings.ips.octopart.searchLimit + Number of results + + + + + settings.ips.octopart.searchLimit.help + The number of results to get from Octopart while searching (please note that this counts towards your API limits) + + + + + settings.ips.octopart.onlyAuthorizedSellers + Only authorized sellers + + + + + settings.ips.octopart.onlyAuthorizedSellers.help + Set to false to include non-authorized offers in the results + + From a4f2a7a7df687c8399474358f85e5acc6591ba07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 6 Jul 2025 21:42:58 +0200 Subject: [PATCH 005/138] Moved fixer API config to settings bundle --- .env | 3 -- config/packages/swap.yaml | 2 +- .../MiscSettings/ExchangeRateSettings.php | 41 +++++++++++++++++++ src/Settings/MiscSettings/MiscSettings.php | 3 ++ translations/messages.en.xlf | 18 ++++++++ 5 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 src/Settings/MiscSettings/ExchangeRateSettings.php diff --git a/.env b/.env index 4b292298..3b82f715 100644 --- a/.env +++ b/.env @@ -129,9 +129,6 @@ NO_URL_REWRITE_AVAILABLE=0 # Set to 1, if Part-DB should redirect all HTTP requests to HTTPS. You dont need to configure this, if your webserver already does this. REDIRECT_TO_HTTPS=0 -# If you want to use fixer.io for currency conversion, you have to set this to your API key -FIXER_API_KEY=CHANGEME - # Override value if you want to show to show a given text on homepage. # When this is empty the content of config/banner.md is used as banner BANNER="" diff --git a/config/packages/swap.yaml b/config/packages/swap.yaml index 2767f740..beb41d26 100644 --- a/config/packages/swap.yaml +++ b/config/packages/swap.yaml @@ -6,5 +6,5 @@ florianv_swap: providers: european_central_bank: ~ # European Central Bank (only works for EUR base currency) fixer: # Fixer.io (needs an API key) - access_key: "%env(FIXER_API_KEY)%" + access_key: "%env(string:default:settings:exchange_rate:fixerApiKey:INVALID)%" #exchange_rates_api: ~ \ No newline at end of file diff --git a/src/Settings/MiscSettings/ExchangeRateSettings.php b/src/Settings/MiscSettings/ExchangeRateSettings.php new file mode 100644 index 00000000..70bf15dd --- /dev/null +++ b/src/Settings/MiscSettings/ExchangeRateSettings.php @@ -0,0 +1,41 @@ +. + */ + +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 Symfony\Component\Translation\TranslatableMessage as TM; + +#[Settings(name: "exchange_rate", label: new TM("settings.misc.exchange_rate"))] +#[SettingsIcon("fa-money-bill-transfer")] +class ExchangeRateSettings +{ + #[SettingsParameter(label: new TM("settings.misc.exchange_rate.fixer_api_key"), + description: new TM("settings.misc.exchange_rate.fixer_api_key.help"), + envVar: "FIXER_API_KEY", envVarMode: EnvVarMode::OVERWRITE, + )] + public ?string $fixerApiKey = null; +} \ No newline at end of file diff --git a/src/Settings/MiscSettings/MiscSettings.php b/src/Settings/MiscSettings/MiscSettings.php index a2ad0fd4..b8a3a73f 100644 --- a/src/Settings/MiscSettings/MiscSettings.php +++ b/src/Settings/MiscSettings/MiscSettings.php @@ -31,4 +31,7 @@ class MiscSettings { #[EmbeddedSettings] public ?KiCadEDASettings $kicadEDA = null; + + #[EmbeddedSettings] + public ?ExchangeRateSettings $exchangeRate = null; } \ No newline at end of file diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index 56f5cb27..07d642c4 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -12976,5 +12976,23 @@ Please note, that you can not impersonate a disabled user. If you try you will g Set to false to include non-authorized offers in the results + + + settings.misc.exchange_rate + Money exchange rates + + + + + settings.misc.exchange_rate.fixer_api_key + Fixer.io API Key + + + + + settings.misc.exchange_rate.fixer_api_key.help + If you need exchange rates between non-euro currencies, you can input an API key from fixer.io here. + + From dc81a5b3613ca71b68af7d0dcc5ebecf86d1e059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 6 Jul 2025 21:53:06 +0200 Subject: [PATCH 006/138] Moved SHOW_PART_IMAGE_OVERLAY to settings-bundle --- .env | 3 -- config/packages/twig.yaml | 1 - config/parameters.yaml | 1 - .../BehaviorSettings/BehaviorSettings.php | 3 ++ .../BehaviorSettings/PartInfoSettings.php | 43 +++++++++++++++++++ templates/parts/info/_picture.html.twig | 2 +- translations/messages.en.xlf | 18 ++++++++ 7 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 src/Settings/BehaviorSettings/PartInfoSettings.php diff --git a/.env b/.env index 3b82f715..a95b46fb 100644 --- a/.env +++ b/.env @@ -133,9 +133,6 @@ REDIRECT_TO_HTTPS=0 # 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 f113c254..674aa317 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -17,7 +17,6 @@ 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 8a798913..311b567c 100644 --- a/config/parameters.yaml +++ b/config/parameters.yaml @@ -48,7 +48,6 @@ 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/src/Settings/BehaviorSettings/BehaviorSettings.php b/src/Settings/BehaviorSettings/BehaviorSettings.php index 97a1759e..1251a097 100644 --- a/src/Settings/BehaviorSettings/BehaviorSettings.php +++ b/src/Settings/BehaviorSettings/BehaviorSettings.php @@ -37,4 +37,7 @@ class BehaviorSettings #[EmbeddedSettings] public ?TableSettings $table = null; + + #[EmbeddedSettings] + public ?PartInfoSettings $partInfo = null; } \ No newline at end of file diff --git a/src/Settings/BehaviorSettings/PartInfoSettings.php b/src/Settings/BehaviorSettings/PartInfoSettings.php new file mode 100644 index 00000000..4c44b9bb --- /dev/null +++ b/src/Settings/BehaviorSettings/PartInfoSettings.php @@ -0,0 +1,43 @@ +. + */ + +declare(strict_types=1); + + +namespace App\Settings\BehaviorSettings; + +use App\Settings\SettingsIcon; +use Jbtronics\SettingsBundle\Metadata\EnvVarMode; +use Jbtronics\SettingsBundle\Settings\Settings; +use Jbtronics\SettingsBundle\Settings\SettingsParameter; +use Symfony\Component\Translation\TranslatableMessage as TM; + +#[Settings(name: "part_info", label: new TM("settings.behavior.part_info"))] +#[SettingsIcon('fa-circle-info')] +class PartInfoSettings +{ + /** + * Whether to show the part image overlays in the part info view + * @var bool + */ + #[SettingsParameter(label: new TM("settings.behavior.part_info.show_part_image_overlay"), description: new TM("settings.behavior.part_info.show_part_image_overlay.help"), + envVar: "bool:SHOW_PART_IMAGE_OVERLAY", envVarMode: EnvVarMode::OVERWRITE)] + public bool $showPartImageOverlay = true; +} \ No newline at end of file diff --git a/templates/parts/info/_picture.html.twig b/templates/parts/info/_picture.html.twig index 6bfb2472..e6aa74b3 100644 --- a/templates/parts/info/_picture.html.twig +++ b/templates/parts/info/_picture.html.twig @@ -13,7 +13,7 @@