diff --git a/.env b/.env index 5f97c6d5..b51b1897 100644 --- a/.env +++ b/.env @@ -129,10 +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 -# 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="" - # Set this to zero, if you want to disable the year 2038 bug check on 32-bit systems (it will cause errors with current 32-bit PHP versions) DISABLE_YEAR2038_BUG_CHECK=0 diff --git a/assets/controllers.json b/assets/controllers.json index 29ea244b..480ad64e 100644 --- a/assets/controllers.json +++ b/assets/controllers.json @@ -1,5 +1,14 @@ { "controllers": { + "@symfony/ux-toggle-password": { + "toggle-password": { + "enabled": true, + "fetch": "eager", + "autoimport": { + "@symfony/ux-toggle-password/dist/style.min.css": true + } + } + }, "@symfony/ux-turbo": { "turbo-core": { "enabled": true, diff --git a/assets/css/app/bs-overrides.css b/assets/css/app/bs-overrides.css index 070f353d..ec5a8f7c 100644 --- a/assets/css/app/bs-overrides.css +++ b/assets/css/app/bs-overrides.css @@ -120,4 +120,11 @@ ins { del { background-color: #f09595; font-weight: bold; -} \ No newline at end of file +} + +/**************************************** + * Password toggle + ****************************************/ +.toggle-password-button { + top: 0.7rem !important; +} diff --git a/composer.json b/composer.json index c7c661b7..a602e505 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "hshn/base64-encoded-file": "^5.0", "jbtronics/2fa-webauthn": "^3.0.0", "jbtronics/dompdf-font-loader-bundle": "^1.0.0", - "jbtronics/settings-bundle": "^v2.7.0", + "jbtronics/settings-bundle": "^3.0.0", "jfcherng/php-diff": "^6.14", "knpuniversity/oauth2-client-bundle": "^2.15", "league/commonmark": "^2.7", @@ -80,6 +80,7 @@ "symfony/string": "7.3.*", "symfony/translation": "7.3.*", "symfony/twig-bundle": "7.3.*", + "symfony/ux-toggle-password": "^2.29", "symfony/ux-translator": "^2.10", "symfony/ux-turbo": "^2.0", "symfony/validator": "7.3.*", diff --git a/composer.lock b/composer.lock index e5262846..2a59f016 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2b0f46c3211d452d6bbd71a38ece8cbd", + "content-hash": "3b97b6338827ba56e0404860f3e98359", "packages": [ { "name": "amphp/amp", @@ -5090,16 +5090,16 @@ }, { "name": "jbtronics/settings-bundle", - "version": "v2.7.0", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/jbtronics/settings-bundle.git", - "reference": "2f579554d52b3d5226b8569ccd13988f6403f6af" + "reference": "34b9629af73c7ad8989d8284470e79f3f8d79712" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/jbtronics/settings-bundle/zipball/2f579554d52b3d5226b8569ccd13988f6403f6af", - "reference": "2f579554d52b3d5226b8569ccd13988f6403f6af", + "url": "https://api.github.com/repos/jbtronics/settings-bundle/zipball/34b9629af73c7ad8989d8284470e79f3f8d79712", + "reference": "34b9629af73c7ad8989d8284470e79f3f8d79712", "shasum": "" }, "require": { @@ -5160,7 +5160,7 @@ ], "support": { "issues": "https://github.com/jbtronics/settings-bundle/issues", - "source": "https://github.com/jbtronics/settings-bundle/tree/v2.7.0" + "source": "https://github.com/jbtronics/settings-bundle/tree/v3.0.0" }, "funding": [ { @@ -5172,7 +5172,7 @@ "type": "github" } ], - "time": "2025-08-15T22:13:15+00:00" + "time": "2025-08-24T17:17:43+00:00" }, { "name": "jfcherng/php-color-output", @@ -15188,6 +15188,90 @@ ], "time": "2025-06-27T19:55:54+00:00" }, + { + "name": "symfony/ux-toggle-password", + "version": "v2.29.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/ux-toggle-password.git", + "reference": "ea74e8611e30979d9ec9b4c29d194f18a460a781" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/ux-toggle-password/zipball/ea74e8611e30979d9ec9b4c29d194f18a460a781", + "reference": "ea74e8611e30979d9ec9b4c29d194f18a460a781", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/config": "^5.4|^6.0|^7.0|^8.0", + "symfony/dependency-injection": "^5.4|^6.0|^7.0|^8.0", + "symfony/form": "^5.4|^6.0|^7.0|^8.0", + "symfony/http-kernel": "^5.4|^6.0|^7.0|^8.0", + "symfony/options-resolver": "^5.4|^6.0|^7.0|^8.0", + "symfony/translation": "^5.4|^6.0|^7.0|^8.0" + }, + "require-dev": { + "symfony/framework-bundle": "^5.4|^6.0|^7.0|^8.0", + "symfony/phpunit-bridge": "^5.4|^6.0|^7.0|^8.0", + "symfony/twig-bundle": "^5.4|^6.0|^7.0|^8.0", + "symfony/var-dumper": "^5.4|^6.0|^7.0|^8.0", + "twig/twig": "^2.14.7|^3.0.4" + }, + "type": "symfony-bundle", + "extra": { + "thanks": { + "url": "https://github.com/symfony/ux", + "name": "symfony/ux" + } + }, + "autoload": { + "psr-4": { + "Symfony\\UX\\TogglePassword\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Félix Eymonot", + "email": "felix.eymonot@alximy.io" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Toggle visibility of password inputs for Symfony Forms", + "homepage": "https://symfony.com", + "keywords": [ + "symfony-ux" + ], + "support": { + "source": "https://github.com/symfony/ux-toggle-password/tree/v2.29.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-08-18T09:13:24+00:00" + }, { "name": "symfony/ux-translator", "version": "v2.29.2", diff --git a/config/banner.md b/config/banner.md index 997ca15e..1d38a3f3 100644 --- a/config/banner.md +++ b/config/banner.md @@ -1,14 +1,4 @@ -Welcome to Part-DB. - -If you want to change this banner, edit `config/banner.md` file or set the `BANNER` environment variable. +**Attention**: +Since Version 2.0.0 this file is no longer used. -
-

-And God said
-$\nabla \cdot \vec{D} = \rho$, -$\nabla \cdot \vec{B} = 0$, -$\nabla \times \vec{E} = -\frac{\partial \vec{B}}{\partial t}$, -$\nabla \times \vec{H} = \vec{j} + \frac{\partial \vec{D}}{\partial t}$,
-and then there was light. -

-
\ No newline at end of file +You can now set the banner text directly in the admin interface, or by setting the `BANNER` environment variable. diff --git a/config/bundles.php b/config/bundles.php index ae7dc9cc..084e6870 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -33,4 +33,5 @@ return [ Jbtronics\SettingsBundle\JbtronicsSettingsBundle::class => ['all' => true], Jbtronics\TranslationEditorBundle\JbtronicsTranslationEditorBundle::class => ['dev' => true], ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], + Symfony\UX\TogglePassword\TogglePasswordBundle::class => ['all' => true], ]; diff --git a/config/parameters.yaml b/config/parameters.yaml index 311b567c..154fbd8a 100644 --- a/config/parameters.yaml +++ b/config/parameters.yaml @@ -90,7 +90,6 @@ parameters: env(ERROR_PAGE_SHOW_HELP): 1 env(DEMO_MODE): 0 - env(BANNER): '' env(EMAIL_SENDER_EMAIL): 'noreply@partdb.changeme' diff --git a/docs/upgrade/1_to_2.md b/docs/upgrade/1_to_2.md index 44219c73..799e9ec6 100644 --- a/docs/upgrade/1_to_2.md +++ b/docs/upgrade/1_to_2.md @@ -24,4 +24,9 @@ easily upgrade your system to the new requirements. Otherwise, you can use the o ships all required dependencies and is always up to date with the latest requirements, so that you do not have to worry about the requirements at all. - +## Changes +* The `config/banner.md` file that could been used to customize the banner text, was removed. You can now set the banner text + directly in the admin interface, or by setting the `BANNER` environment variable. If you want to keep your existing + banner text, you will have to copy it from the `config/banner.md` file to the admin interface or set the `BANNER` + environment variable. + diff --git a/package.json b/package.json index 7a3efaa4..1080a74c 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "@hotwired/turbo": "^8.0.1", "@popperjs/core": "^2.10.2", "@symfony/stimulus-bridge": "^4.0.0", + "@symfony/ux-toggle-password": "file:vendor/symfony/ux-toggle-password/assets", "@symfony/ux-translator": "file:vendor/symfony/ux-translator/assets", "@symfony/ux-turbo": "file:vendor/symfony/ux-turbo/assets", "@symfony/webpack-encore": "^5.0.0", diff --git a/src/Controller/SettingsController.php b/src/Controller/SettingsController.php index cd317876..3479cf84 100644 --- a/src/Controller/SettingsController.php +++ b/src/Controller/SettingsController.php @@ -33,6 +33,8 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Contracts\Cache\TagAwareCacheInterface; +use function Symfony\Component\Translation\t; + class SettingsController extends AbstractController { public function __construct(private readonly SettingsManagerInterface $settingsManager, private readonly SettingsFormFactoryInterface $settingsFormFactory) @@ -63,6 +65,12 @@ class SettingsController extends AbstractController //It might be possible, that the tree settings have changed, so clear the cache $cache->invalidateTags(['tree_treeview', 'sidebar_tree_update']); + + $this->addFlash('success', t('settings.flash.saved')); + } + + if ($form->isSubmitted() && !$form->isValid()) { + $this->addFlash('error', t('settings.flash.invalid')); } //Render the form @@ -70,4 +78,4 @@ class SettingsController extends AbstractController 'form' => $form ]); } -} \ No newline at end of file +} diff --git a/src/Form/Type/APIKeyType.php b/src/Form/Type/APIKeyType.php new file mode 100644 index 00000000..ae72f2a6 --- /dev/null +++ b/src/Form/Type/APIKeyType.php @@ -0,0 +1,54 @@ +. + */ + +declare(strict_types=1); + + +namespace App\Form\Type; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\PasswordType; +use Symfony\Component\Form\FormInterface; +use Symfony\Component\Form\FormView; +use Symfony\Component\OptionsResolver\OptionsResolver; + +class APIKeyType extends AbstractType +{ + public function getParent(): string + { + return PasswordType::class; + } + + public function buildView(FormView $view, FormInterface $form, array $options): void + { + //Ensure that the field is never empty + $view->vars['value'] = $form->getViewData(); + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'always_empty' => false, + 'toggle' => true, + 'empty_data' => null, + 'attr' => ['autocomplete' => 'off'], + ]); + } +} diff --git a/src/Services/InfoProviderSystem/Providers/DigikeyProvider.php b/src/Services/InfoProviderSystem/Providers/DigikeyProvider.php index c2113b4d..5596ea2b 100644 --- a/src/Services/InfoProviderSystem/Providers/DigikeyProvider.php +++ b/src/Services/InfoProviderSystem/Providers/DigikeyProvider.php @@ -78,7 +78,7 @@ class DigikeyProvider implements InfoProviderInterface 'description' => 'This provider uses the DigiKey API to search for parts.', 'url' => 'https://www.digikey.com/', 'oauth_app_name' => self::OAUTH_APP_NAME, - 'disabled_help' => 'Set the PROVIDER_DIGIKEY_CLIENT_ID and PROVIDER_DIGIKEY_SECRET env option and connect OAuth to enable.' + 'disabled_help' => 'Set the Client ID and Secret in provider settings and connect OAuth to enable.' ]; } @@ -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->settings->clientId !== '' && $this->authTokenManager->hasToken(self::OAUTH_APP_NAME); + return $this->settings->clientId !== null && $this->settings->clientId !== '' && $this->authTokenManager->hasToken(self::OAUTH_APP_NAME); } public function searchByKeyword(string $keyword): array diff --git a/src/Services/InfoProviderSystem/Providers/Element14Provider.php b/src/Services/InfoProviderSystem/Providers/Element14Provider.php index 91249156..9ba5330d 100644 --- a/src/Services/InfoProviderSystem/Providers/Element14Provider.php +++ b/src/Services/InfoProviderSystem/Providers/Element14Provider.php @@ -66,7 +66,7 @@ class Element14Provider implements InfoProviderInterface 'name' => 'Farnell element14', 'description' => 'This provider uses the Farnell element14 API to search for parts.', 'url' => 'https://www.element14.com/', - 'disabled_help' => 'Configure the API key in the PROVIDER_ELEMENT14_KEY environment variable to enable.' + 'disabled_help' => 'Configure the API key in the provider settings to enable.' ]; } diff --git a/src/Services/InfoProviderSystem/Providers/LCSCProvider.php b/src/Services/InfoProviderSystem/Providers/LCSCProvider.php index 193ca366..bfb6ad97 100755 --- a/src/Services/InfoProviderSystem/Providers/LCSCProvider.php +++ b/src/Services/InfoProviderSystem/Providers/LCSCProvider.php @@ -51,7 +51,7 @@ class LCSCProvider implements InfoProviderInterface 'name' => 'LCSC', 'description' => 'This provider uses the (unofficial) LCSC API to search for parts.', 'url' => 'https://www.lcsc.com/', - 'disabled_help' => 'Set PROVIDER_LCSC_ENABLED to 1 (or true) in your environment variable config.' + 'disabled_help' => 'Enable this provider in the provider settings.' ]; } diff --git a/src/Services/InfoProviderSystem/Providers/MouserProvider.php b/src/Services/InfoProviderSystem/Providers/MouserProvider.php index 0348ec74..8bbdcd9c 100644 --- a/src/Services/InfoProviderSystem/Providers/MouserProvider.php +++ b/src/Services/InfoProviderSystem/Providers/MouserProvider.php @@ -61,7 +61,7 @@ class MouserProvider implements InfoProviderInterface 'name' => 'Mouser', 'description' => 'This provider uses the Mouser API to search for parts.', 'url' => 'https://www.mouser.com/', - 'disabled_help' => 'Configure the API key in the PROVIDER_MOUSER_KEY environment variable to enable.' + 'disabled_help' => 'Configure the API key in the provider settings to enable.' ]; } @@ -345,4 +345,4 @@ class MouserProvider implements InfoProviderInterface return $tmp; } -} \ No newline at end of file +} diff --git a/src/Services/InfoProviderSystem/Providers/OEMSecretsProvider.php b/src/Services/InfoProviderSystem/Providers/OEMSecretsProvider.php index bf97635f..ec035015 100644 --- a/src/Services/InfoProviderSystem/Providers/OEMSecretsProvider.php +++ b/src/Services/InfoProviderSystem/Providers/OEMSecretsProvider.php @@ -246,7 +246,7 @@ class OEMSecretsProvider implements InfoProviderInterface 'name' => 'OEMSecrets', 'description' => 'This provider uses the OEMSecrets API to search for parts.', 'url' => 'https://www.oemsecrets.com/', - 'disabled_help' => 'Configure the API key in the PROVIDER_OEMSECRETS_KEY environment variable to enable.' + 'disabled_help' => 'Configure the API key in the provider settings to enable.' ]; } /** @@ -265,7 +265,7 @@ class OEMSecretsProvider implements InfoProviderInterface */ public function isActive(): bool { - return $this->settings->apiKey !== ''; + return $this->settings->apiKey !== null && $this->settings->apiKey !== ''; } @@ -285,18 +285,18 @@ class OEMSecretsProvider implements InfoProviderInterface public function searchByKeyword(string $keyword): array { /* - oemsecrets Part Search API 3.0.1 + oemsecrets Part Search API 3.0.1 "https://oemsecretsapi.com/partsearch? searchTerm=BC547 &apiKey=icawpb0bspoo2c6s64uv4vpdfp2vgr7e27bxw0yct2bzh87mpl027x353uelpq2x ¤cy=EUR - &countryCode=IT" - + &countryCode=IT" + partsearch description: - Use the Part Search API to find distributor data for a full or partial manufacturer + Use the Part Search API to find distributor data for a full or partial manufacturer part number including part details, pricing, compliance and inventory. - + Required Parameter Format Description searchTerm string Part number you are searching for apiKey string Your unique API key provided to you by OEMsecrets @@ -304,14 +304,14 @@ class OEMSecretsProvider implements InfoProviderInterface Additional Parameter Format Description countryCode string The country you want to output for currency string / array The currency you want the prices to be displayed as - + To display the output for GB and to view prices in USD, add [ countryCode=GB ] and [ currency=USD ] as seen below: oemsecretsapi.com/partsearch?apiKey=abcexampleapikey123&searchTerm=bd04&countryCode=GB¤cy=USD - + To view prices in both USD and GBP add [ currency[]=USD¤cy[]=GBP ] oemsecretsapi.com/partsearch?searchTerm=bd04&apiKey=abcexampleapikey123¤cy[]=USD¤cy[]=GBP - + */ @@ -1465,4 +1465,4 @@ class OEMSecretsProvider implements InfoProviderInterface return $url; } -} \ No newline at end of file +} diff --git a/src/Services/InfoProviderSystem/Providers/OctopartProvider.php b/src/Services/InfoProviderSystem/Providers/OctopartProvider.php index ce1ec4a4..c05931d3 100644 --- a/src/Services/InfoProviderSystem/Providers/OctopartProvider.php +++ b/src/Services/InfoProviderSystem/Providers/OctopartProvider.php @@ -170,7 +170,7 @@ class OctopartProvider implements InfoProviderInterface 'name' => 'Octopart', 'description' => 'This provider uses the Nexar/Octopart API to search for parts on Octopart.', 'url' => 'https://www.octopart.com/', - 'disabled_help' => 'Set the PROVIDER_OCTOPART_CLIENT_ID and PROVIDER_OCTOPART_SECRET env option.' + 'disabled_help' => 'Set the Client ID and Secret in provider settings.' ]; } @@ -183,7 +183,8 @@ 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->settings->clientId !== '' && $this->settings->secret !== ''; + return $this->settings->clientId !== null && $this->settings->clientId !== '' + && $this->settings->secret !== null && $this->settings->secret !== ''; } private function mapLifeCycleStatus(?string $value): ?ManufacturingStatus @@ -337,7 +338,7 @@ class OctopartProvider implements InfoProviderInterface ) { hits results { - part + part %s } } @@ -403,4 +404,4 @@ class OctopartProvider implements InfoProviderInterface ProviderCapabilities::PRICE, ]; } -} \ No newline at end of file +} diff --git a/src/Services/InfoProviderSystem/Providers/PollinProvider.php b/src/Services/InfoProviderSystem/Providers/PollinProvider.php index 864effd9..5f2268e0 100644 --- a/src/Services/InfoProviderSystem/Providers/PollinProvider.php +++ b/src/Services/InfoProviderSystem/Providers/PollinProvider.php @@ -51,7 +51,7 @@ class PollinProvider implements InfoProviderInterface 'name' => 'Pollin', 'description' => 'Webscraping from pollin.de to get part information', 'url' => 'https://www.pollin.de/', - 'disabled_help' => 'Set PROVIDER_POLLIN_ENABLED env to 1' + 'disabled_help' => 'Enable the provider in provider settings' ]; } @@ -246,4 +246,4 @@ class PollinProvider implements InfoProviderInterface ProviderCapabilities::DATASHEET ]; } -} \ No newline at end of file +} diff --git a/src/Services/InfoProviderSystem/Providers/ReicheltProvider.php b/src/Services/InfoProviderSystem/Providers/ReicheltProvider.php index ebc62dd5..e836937b 100644 --- a/src/Services/InfoProviderSystem/Providers/ReicheltProvider.php +++ b/src/Services/InfoProviderSystem/Providers/ReicheltProvider.php @@ -51,7 +51,7 @@ class ReicheltProvider implements InfoProviderInterface 'name' => 'Reichelt', 'description' => 'Webscraping from reichelt.com to get part information', 'url' => 'https://www.reichelt.com/', - 'disabled_help' => 'Set PROVIDER_REICHELT_ENABLED env to 1' + 'disabled_help' => 'Enable provider in provider settings.' ]; } @@ -274,4 +274,4 @@ class ReicheltProvider implements InfoProviderInterface ProviderCapabilities::PRICE, ]; } -} \ No newline at end of file +} diff --git a/src/Services/InfoProviderSystem/Providers/TMEProvider.php b/src/Services/InfoProviderSystem/Providers/TMEProvider.php index 81939a78..7c846a65 100644 --- a/src/Services/InfoProviderSystem/Providers/TMEProvider.php +++ b/src/Services/InfoProviderSystem/Providers/TMEProvider.php @@ -54,7 +54,7 @@ class TMEProvider implements InfoProviderInterface 'name' => 'TME', 'description' => 'This provider uses the API of TME (Transfer Multipart).', 'url' => 'https://tme.eu/', - 'disabled_help' => 'Configure the PROVIDER_TME_KEY and PROVIDER_TME_SECRET environment variables to use this provider.' + 'disabled_help' => 'Configure the API Token and secret in provider settings to use this provider.' ]; } @@ -295,4 +295,4 @@ class TMEProvider implements InfoProviderInterface ProviderCapabilities::PRICE, ]; } -} \ No newline at end of file +} diff --git a/src/Services/System/BannerHelper.php b/src/Services/System/BannerHelper.php index 81925f2c..bb27158f 100644 --- a/src/Services/System/BannerHelper.php +++ b/src/Services/System/BannerHelper.php @@ -30,7 +30,7 @@ use App\Settings\SystemSettings\CustomizationSettings; */ class BannerHelper { - public function __construct(private CustomizationSettings $customizationSettings) + public function __construct(private readonly CustomizationSettings $customizationSettings) { } @@ -43,4 +43,4 @@ class BannerHelper { return $this->customizationSettings->banner ?? ""; } -} \ No newline at end of file +} diff --git a/src/Settings/InfoProviderSystem/DigikeySettings.php b/src/Settings/InfoProviderSystem/DigikeySettings.php index 17d05c5b..f42c1c1c 100644 --- a/src/Settings/InfoProviderSystem/DigikeySettings.php +++ b/src/Settings/InfoProviderSystem/DigikeySettings.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace App\Settings\InfoProviderSystem; +use App\Form\Type\APIKeyType; use App\Settings\SettingsIcon; use Jbtronics\SettingsBundle\Metadata\EnvVarMode; use Jbtronics\SettingsBundle\Settings\Settings; @@ -42,12 +43,14 @@ class DigikeySettings #[SettingsParameter( label: new TM("settings.ips.digikey.client_id"), + formType: APIKeyType::class, envVar: "PROVIDER_DIGIKEY_CLIENT_ID", envVarMode: EnvVarMode::OVERWRITE )] public ?string $clientId = null; #[SettingsParameter( label: new TM("settings.ips.digikey.secret"), + formType: APIKeyType::class, envVar: "PROVIDER_DIGIKEY_SECRET", envVarMode: EnvVarMode::OVERWRITE )] public ?string $secret = null; @@ -67,4 +70,4 @@ class DigikeySettings envVar: "PROVIDER_DIGIKEY_LANGUAGE", envVarMode: EnvVarMode::OVERWRITE)] #[Assert\Language] public string $language = "en"; -} \ No newline at end of file +} diff --git a/src/Settings/InfoProviderSystem/Element14Settings.php b/src/Settings/InfoProviderSystem/Element14Settings.php index 42e2de5d..a4cdbf0d 100644 --- a/src/Settings/InfoProviderSystem/Element14Settings.php +++ b/src/Settings/InfoProviderSystem/Element14Settings.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace App\Settings\InfoProviderSystem; +use App\Form\Type\APIKeyType; use App\Settings\SettingsIcon; use Jbtronics\SettingsBundle\Metadata\EnvVarMode; use Jbtronics\SettingsBundle\Settings\Settings; @@ -36,11 +37,12 @@ class Element14Settings { use SettingsTrait; - #[SettingsParameter(label: new TM("settings.ips.element14.apiKey"), description: new TM("settings.ips.element14.apiKey.help"), + #[SettingsParameter(label: new TM("settings.ips.element14.apiKey"), description: new TM("settings.ips.element14.apiKey.help"),# + formType: APIKeyType::class, formOptions: ["help_html" => true], envVar: "PROVIDER_ELEMENT14_KEY", envVarMode: EnvVarMode::OVERWRITE)] public ?string $apiKey = null; #[SettingsParameter(label: new TM("settings.ips.element14.storeId"), description: new TM("settings.ips.element14.storeId.help"), formOptions: ["help_html" => true], envVar: "PROVIDER_ELEMENT14_STORE_ID", envVarMode: EnvVarMode::OVERWRITE)] public string $storeId = "de.farnell.com"; -} \ No newline at end of file +} diff --git a/src/Settings/InfoProviderSystem/MouserSettings.php b/src/Settings/InfoProviderSystem/MouserSettings.php index b84deb50..0abaa7f2 100644 --- a/src/Settings/InfoProviderSystem/MouserSettings.php +++ b/src/Settings/InfoProviderSystem/MouserSettings.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace App\Settings\InfoProviderSystem; +use App\Form\Type\APIKeyType; use App\Settings\SettingsIcon; use Jbtronics\SettingsBundle\Metadata\EnvVarMode; use Jbtronics\SettingsBundle\Settings\Settings; @@ -35,6 +36,7 @@ use Symfony\Component\Translation\TranslatableMessage as TM; class MouserSettings { #[SettingsParameter(label: new TM("settings.ips.mouser.apiKey"), description: new TM("settings.ips.mouser.apiKey.help"), + formType: APIKeyType::class, formOptions: ["help_html" => true], envVar: "PROVIDER_MOUSER_KEY", envVarMode: EnvVarMode::OVERWRITE)] public ?string $apiKey = null; @@ -64,4 +66,4 @@ class MouserSettings return MouserSearchOptions::tryFrom($value) ?? MouserSearchOptions::NONE; } -} \ No newline at end of file +} diff --git a/src/Settings/InfoProviderSystem/OEMSecretsSettings.php b/src/Settings/InfoProviderSystem/OEMSecretsSettings.php index 75c2c821..77cf9080 100644 --- a/src/Settings/InfoProviderSystem/OEMSecretsSettings.php +++ b/src/Settings/InfoProviderSystem/OEMSecretsSettings.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace App\Settings\InfoProviderSystem; +use App\Form\Type\APIKeyType; use App\Settings\SettingsIcon; use Jbtronics\SettingsBundle\Metadata\EnvVarMode; use Jbtronics\SettingsBundle\Settings\Settings; @@ -43,6 +44,7 @@ class OEMSecretsSettings "NZD", "RUB", "SEK", "SGD", "TWD", "USD"]; #[SettingsParameter(label: new TM("settings.ips.element14.apiKey"), + formType: APIKeyType::class, envVar: "PROVIDER_OEMSECRETS_KEY", envVarMode: EnvVarMode::OVERWRITE)] public ?string $apiKey = null; @@ -85,4 +87,4 @@ class OEMSecretsSettings return OEMSecretsSortMode::tryFrom($value) ?? OEMSecretsSortMode::NONE; } -} \ No newline at end of file +} diff --git a/src/Settings/InfoProviderSystem/OctopartSettings.php b/src/Settings/InfoProviderSystem/OctopartSettings.php index 1b39d87a..c28da459 100644 --- a/src/Settings/InfoProviderSystem/OctopartSettings.php +++ b/src/Settings/InfoProviderSystem/OctopartSettings.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace App\Settings\InfoProviderSystem; +use App\Form\Type\APIKeyType; use App\Settings\SettingsIcon; use Jbtronics\SettingsBundle\Metadata\EnvVarMode; use Jbtronics\SettingsBundle\Settings\Settings; @@ -42,12 +43,14 @@ class OctopartSettings #[SettingsParameter( label: new TM("settings.ips.digikey.client_id"), - envVar: "PROVIDER_OCTOPART_CLIENT_ID", envVarMode: EnvVarMode::OVERWRITE + formType: APIKeyType::class, + envVar: "PROVIDER_OCTOPART_CLIENT_ID", envVarMode: EnvVarMode::OVERWRITE, )] public ?string $clientId = null; #[SettingsParameter( label: new TM("settings.ips.digikey.secret"), + formType: APIKeyType::class, envVar: "PROVIDER_OCTOPART_SECRET", envVarMode: EnvVarMode::OVERWRITE )] public ?string $secret = null; @@ -75,4 +78,4 @@ class OctopartSettings )] public bool $onlyAuthorizedSellers = true; -} \ No newline at end of file +} diff --git a/src/Settings/InfoProviderSystem/TMESettings.php b/src/Settings/InfoProviderSystem/TMESettings.php index c7b57ae7..d6f03d34 100644 --- a/src/Settings/InfoProviderSystem/TMESettings.php +++ b/src/Settings/InfoProviderSystem/TMESettings.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace App\Settings\InfoProviderSystem; +use App\Form\Type\APIKeyType; use App\Settings\SettingsIcon; use Jbtronics\SettingsBundle\Metadata\EnvVarMode; use Jbtronics\SettingsBundle\Settings\Settings; @@ -43,11 +44,13 @@ class TMESettings private const SUPPORTED_CURRENCIES = ["EUR", "USD", "PLN", "GBP"]; #[SettingsParameter(label: new TM("settings.ips.tme.token"), - description: new TM("settings.ips.tme.token.help"), formOptions: ["help_html" => true], + description: new TM("settings.ips.tme.token.help"), + formType: APIKeyType::class, formOptions: ["help_html" => true], envVar: "PROVIDER_TME_KEY", envVarMode: EnvVarMode::OVERWRITE)] public ?string $apiToken = null; #[SettingsParameter(label: new TM("settings.ips.tme.secret"), + formType: APIKeyType::class, envVar: "PROVIDER_TME_SECRET", envVarMode: EnvVarMode::OVERWRITE)] public ?string $apiSecret = null; @@ -69,4 +72,4 @@ class TMESettings #[SettingsParameter(label: new TM("settings.ips.tme.grossPrices"), envVar: "bool:PROVIDER_TME_GET_GROSS_PRICES", envVarMode: EnvVarMode::OVERWRITE)] public bool $grossPrices = true; -} \ No newline at end of file +} diff --git a/src/Settings/MiscSettings/ExchangeRateSettings.php b/src/Settings/MiscSettings/ExchangeRateSettings.php index 70bf15dd..744523c6 100644 --- a/src/Settings/MiscSettings/ExchangeRateSettings.php +++ b/src/Settings/MiscSettings/ExchangeRateSettings.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace App\Settings\MiscSettings; +use App\Form\Type\APIKeyType; use App\Settings\SettingsIcon; use Jbtronics\SettingsBundle\Metadata\EnvVarMode; use Jbtronics\SettingsBundle\Settings\Settings; @@ -35,7 +36,8 @@ class ExchangeRateSettings { #[SettingsParameter(label: new TM("settings.misc.exchange_rate.fixer_api_key"), description: new TM("settings.misc.exchange_rate.fixer_api_key.help"), + formType: APIKeyType::class, envVar: "FIXER_API_KEY", envVarMode: EnvVarMode::OVERWRITE, )] public ?string $fixerApiKey = null; -} \ No newline at end of file +} diff --git a/src/Settings/SystemSettings/CustomizationSettings.php b/src/Settings/SystemSettings/CustomizationSettings.php index abfeb880..d7e92a51 100644 --- a/src/Settings/SystemSettings/CustomizationSettings.php +++ b/src/Settings/SystemSettings/CustomizationSettings.php @@ -49,6 +49,7 @@ class CustomizationSettings #[SettingsParameter( label: new TM("settings.system.customization.banner"), formType: RichTextEditorType::class, formOptions: ['mode' => 'markdown-full'], + envVar: "BANNER", envVarMode: EnvVarMode::OVERWRITE, )] public ?string $banner = null; @@ -58,4 +59,4 @@ class CustomizationSettings )] #[ValidTheme] public string $theme = 'bootstrap'; -} \ No newline at end of file +} diff --git a/symfony.lock b/symfony.lock index d301c269..f484d13c 100644 --- a/symfony.lock +++ b/symfony.lock @@ -729,6 +729,9 @@ }, "files": [] }, + "symfony/ux-toggle-password": { + "version": "v2.29.2" + }, "symfony/ux-translator": { "version": "2.9", "recipe": { diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index 69b205f4..8a4f809b 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -13033,5 +13033,17 @@ Please note, that you can not impersonate a disabled user. If you try you will g The value of this parameter can be overridden by setting the environment variable "%env%". + + + settings.flash.saved + Settings saved successfully. + + + + + settings.flash.invalid + Settings are invalid. Please check your input! + + diff --git a/yarn.lock b/yarn.lock index 2a0b08eb..da4d24a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2023,6 +2023,9 @@ loader-utils "^2.0.0 || ^3.0.0" schema-utils "^3.0.0 || ^4.0.0" +"@symfony/ux-toggle-password@file:vendor/symfony/ux-toggle-password/assets": + version "2.29.1" + "@symfony/ux-translator@file:vendor/symfony/ux-translator/assets": version "2.29.1"