mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-07-04 08:21:40 +00:00
Compare commits
No commits in common. "d70fe0fbaaca33a8ad676f154f4d459489f1570e" and "eaaf44b391237936456d3dac0a68020bfa0c3c15" have entirely different histories.
d70fe0fbaa
...
eaaf44b391
16 changed files with 23 additions and 126 deletions
12
composer.lock
generated
12
composer.lock
generated
|
|
@ -5090,16 +5090,16 @@
|
|||
},
|
||||
{
|
||||
"name": "jbtronics/settings-bundle",
|
||||
"version": "v3.0.1",
|
||||
"version": "v3.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jbtronics/settings-bundle.git",
|
||||
"reference": "9103bd7f78f0b223d1c7167feb824004fc2a9f07"
|
||||
"reference": "34b9629af73c7ad8989d8284470e79f3f8d79712"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/jbtronics/settings-bundle/zipball/9103bd7f78f0b223d1c7167feb824004fc2a9f07",
|
||||
"reference": "9103bd7f78f0b223d1c7167feb824004fc2a9f07",
|
||||
"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/v3.0.1"
|
||||
"source": "https://github.com/jbtronics/settings-bundle/tree/v3.0.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -5172,7 +5172,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2025-08-24T21:20:15+00:00"
|
||||
"time": "2025-08-24T17:17:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "jfcherng/php-color-output",
|
||||
|
|
|
|||
|
|
@ -29,14 +29,10 @@ use App\Form\InfoProviderSystem\PartSearchType;
|
|||
use App\Services\InfoProviderSystem\ExistingPartFinder;
|
||||
use App\Services\InfoProviderSystem\PartInfoRetriever;
|
||||
use App\Services\InfoProviderSystem\ProviderRegistry;
|
||||
use App\Settings\AppSettings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Jbtronics\SettingsBundle\Form\SettingsFormFactoryInterface;
|
||||
use Jbtronics\SettingsBundle\Manager\SettingsManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\HttpClient\Exception\ClientException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
|
@ -50,9 +46,7 @@ class InfoProviderController extends AbstractController
|
|||
|
||||
public function __construct(private readonly ProviderRegistry $providerRegistry,
|
||||
private readonly PartInfoRetriever $infoRetriever,
|
||||
private readonly ExistingPartFinder $existingPartFinder,
|
||||
private readonly SettingsManagerInterface $settingsManager,
|
||||
private readonly SettingsFormFactoryInterface $settingsFormFactory
|
||||
private readonly ExistingPartFinder $existingPartFinder
|
||||
)
|
||||
{
|
||||
|
||||
|
|
@ -69,48 +63,6 @@ class InfoProviderController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
#[Route('/provider/{provider}/settings', name: 'info_providers_provider_settings')]
|
||||
public function providerSettings(string $provider, Request $request): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('@config.change_system_settings');
|
||||
$this->denyAccessUnlessGranted('@info_providers.create_parts');
|
||||
|
||||
$providerInstance = $this->providerRegistry->getProviderByKey($provider);
|
||||
$settingsClass = $providerInstance->getProviderInfo()['settings_class'] ?? throw new \LogicException('Provider ' . $provider . ' does not have a settings class defined');
|
||||
|
||||
//Create a clone of the settings object
|
||||
$settings = $this->settingsManager->createTemporaryCopy($settingsClass);
|
||||
|
||||
//Create a form builder for the settings object
|
||||
$builder = $this->settingsFormFactory->createSettingsFormBuilder($settings);
|
||||
|
||||
//Add a submit button to the form
|
||||
$builder->add('submit', SubmitType::class, ['label' => 'save']);
|
||||
|
||||
//Create the form
|
||||
$form = $builder->getForm();
|
||||
$form->handleRequest($request);
|
||||
|
||||
//If the form was submitted and is valid, save the settings
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->settingsManager->mergeTemporaryCopy($settings);
|
||||
$this->settingsManager->save($settings);
|
||||
|
||||
$this->addFlash('success', t('settings.flash.saved'));
|
||||
}
|
||||
|
||||
if ($form->isSubmitted() && !$form->isValid()) {
|
||||
$this->addFlash('error', t('settings.flash.invalid'));
|
||||
}
|
||||
|
||||
//Render the form
|
||||
return $this->render('info_providers/settings/provider_settings.html.twig', [
|
||||
'form' => $form,
|
||||
'info_provider_key' => $provider,
|
||||
'info_provider_info' => $providerInstance->getProviderInfo(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/search', name: 'info_providers_search')]
|
||||
#[Route('/update/{target}', name: 'info_providers_update_part_search')]
|
||||
public function search(Request $request, #[MapEntity(id: 'target')] ?Part $update_target, LoggerInterface $exceptionLogger): Response
|
||||
|
|
@ -176,4 +128,4 @@ class InfoProviderController extends AbstractController
|
|||
'update_target' => $update_target
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -78,8 +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 Client ID and Secret in provider settings and connect OAuth to enable.',
|
||||
'settings_class' => DigikeySettings::class,
|
||||
'disabled_help' => 'Set the Client ID and Secret in provider settings and connect OAuth to enable.'
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,8 +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 settings to enable.',
|
||||
'settings_class' => Element14Settings::class,
|
||||
'disabled_help' => 'Configure the API key in the provider settings to enable.'
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,9 +39,8 @@ interface InfoProviderInterface
|
|||
* - url?: The url of the provider (e.g. "https://www.digikey.com")
|
||||
* - disabled_help?: A help text which is shown when the provider is disabled, explaining how to enable it
|
||||
* - oauth_app_name?: The name of the OAuth app which is used for authentication (e.g. "ip_digikey_oauth"). If this is set a connect button will be shown
|
||||
* - settings_class?: The class name of the settings class which contains the settings for this provider (e.g. "App\Settings\InfoProviderSettings\DigikeySettings"). If this is set a link to the settings will be shown
|
||||
*
|
||||
* @phpstan-return array{ name: string, description?: string, logo?: string, url?: string, disabled_help?: string, oauth_app_name?: string, settings_class?: class-string }
|
||||
* @phpstan-return array{ name: string, description?: string, logo?: string, url?: string, disabled_help?: string, oauth_app_name?: string }
|
||||
*/
|
||||
public function getProviderInfo(): array;
|
||||
|
||||
|
|
@ -79,4 +78,4 @@ interface InfoProviderInterface
|
|||
* @return ProviderCapabilities[]
|
||||
*/
|
||||
public function getCapabilities(): array;
|
||||
}
|
||||
}
|
||||
|
|
@ -51,8 +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' => 'Enable this provider in the provider settings.',
|
||||
'settings_class' => LCSCSettings::class,
|
||||
'disabled_help' => 'Enable this provider in the provider settings.'
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,8 +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 settings to enable.',
|
||||
'settings_class' => MouserSettings::class
|
||||
'disabled_help' => 'Configure the API key in the provider settings to enable.'
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -246,8 +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 settings to enable.',
|
||||
'settings_class' => OEMSecretsSettings::class
|
||||
'disabled_help' => 'Configure the API key in the provider settings to enable.'
|
||||
];
|
||||
}
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -170,8 +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 Client ID and Secret in provider settings.',
|
||||
'settings_class' => OctopartSettings::class
|
||||
'disabled_help' => 'Set the Client ID and Secret in provider settings.'
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,8 +51,7 @@ class PollinProvider implements InfoProviderInterface
|
|||
'name' => 'Pollin',
|
||||
'description' => 'Webscraping from pollin.de to get part information',
|
||||
'url' => 'https://www.pollin.de/',
|
||||
'disabled_help' => 'Enable the provider in provider settings',
|
||||
'settings_class' => PollinSettings::class,
|
||||
'disabled_help' => 'Enable the provider in provider settings'
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,8 +51,7 @@ class ReicheltProvider implements InfoProviderInterface
|
|||
'name' => 'Reichelt',
|
||||
'description' => 'Webscraping from reichelt.com to get part information',
|
||||
'url' => 'https://www.reichelt.com/',
|
||||
'disabled_help' => 'Enable provider in provider settings.',
|
||||
'settings_class' => ReicheltSettings::class,
|
||||
'disabled_help' => 'Enable provider in provider settings.'
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,8 +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 API Token and secret in provider settings to use this provider.',
|
||||
'settings_class' => TMESettings::class
|
||||
'disabled_help' => 'Configure the API Token and secret in provider settings to use this provider.'
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
{% else %}
|
||||
{{ provider.providerInfo.name | trans }}
|
||||
{% endif %}
|
||||
|
||||
</h5>
|
||||
<div>
|
||||
{% if provider.providerInfo.description is defined and provider.providerInfo.description is not null %}
|
||||
|
|
@ -22,11 +23,6 @@
|
|||
|
||||
</div>
|
||||
<div class="col-6">
|
||||
{% if provider.providerInfo.settings_class is defined %}
|
||||
<a href="{{ path('info_providers_provider_settings', {'provider': provider.providerKey}) }}" class="btn btn-primary btn-sm"
|
||||
title="{% trans %}info_providers.settings.title{% endtrans %}"
|
||||
><i class="fa-solid fa-cog"></i></a>
|
||||
{% endif %}
|
||||
{% for capability in provider.capabilities %}
|
||||
{# @var capability \App\Services\InfoProviderSystem\Providers\ProviderCapabilities #}
|
||||
<span class="badge text-bg-secondary">
|
||||
|
|
@ -56,4 +52,4 @@
|
|||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endmacro %}
|
||||
{% endmacro %}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
{% extends "main_card.html.twig" %}
|
||||
{% macro genId(widget) %}{{ widget.vars.full_name }}{% endmacro %}
|
||||
|
||||
{% form_theme form "form/settings_form.html.twig" %}
|
||||
|
||||
{% block title %}{% trans %}info_providers.settings.title{% endtrans %}: {{ info_provider_info.name }}{% endblock %}
|
||||
|
||||
{% block card_title %}<i class="fa-solid fa-gear fa-fw"></i> {% trans %}info_providers.settings.title{% endtrans %}: <b>{{ info_provider_info.name }}</b>{% endblock %}
|
||||
|
||||
{% block card_content %}
|
||||
<div class="offset-sm-3">
|
||||
<h3>
|
||||
{% if info_provider_info.url %}
|
||||
<a href="{{ info_provider_info.url }}" class="link-external" target="_blank" rel="nofollow">{{ info_provider_info.name }}</a>
|
||||
{% else %}
|
||||
{{ info_provider_info.name }}
|
||||
{% endif %}
|
||||
</h3>
|
||||
{% if info_provider_info.description %}
|
||||
<p class="text-muted">{{ info_provider_info.description }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{{ form_start(form) }}
|
||||
<div class="row">
|
||||
<div class="offset-sm-3 col mb-3 ps-2">
|
||||
<b>{{ form_help(form) }}</b>
|
||||
</div>
|
||||
</div>
|
||||
{{ form_end(form) }}
|
||||
{% endblock %}
|
||||
|
|
@ -42,12 +42,8 @@
|
|||
<i class="fa-solid {{ settings_icon(settings_object)|default('fa-sliders') }} fa-fw"></i>
|
||||
{{ (section_widget.vars.label ?? section_widget.vars.name|humanize)|trans }}
|
||||
</legend>
|
||||
<div class="row">
|
||||
<div class="offset-sm-3 col mb-3 ps-2">
|
||||
<b>{{ form_help(section_widget) }}</b>
|
||||
{{ form_errors(section_widget) }}
|
||||
</div>
|
||||
</div>
|
||||
{{ form_help(section_widget) }}
|
||||
{{ form_errors(section_widget) }}
|
||||
{{ form_widget(section_widget) }}
|
||||
</fieldset>
|
||||
{% if not loop.last %}
|
||||
|
|
|
|||
|
|
@ -13045,11 +13045,5 @@ Please note, that you can not impersonate a disabled user. If you try you will g
|
|||
<target>Settings are invalid. Please check your input!</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="yRXWSRN" name="info_providers.settings.title">
|
||||
<segment>
|
||||
<source>info_providers.settings.title</source>
|
||||
<target>Info provider settings</target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue