mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-05-10 15:12:12 +00:00
Allow to set no_cache options via info provider UI
Some checks are pending
Build assets artifact / Build assets artifact (push) Waiting to run
Docker Image Build / build (linux/amd64, amd64, ubuntu-latest) (push) Waiting to run
Docker Image Build / build (linux/arm/v7, armv7, ubuntu-24.04-arm) (push) Waiting to run
Docker Image Build / build (linux/arm64, arm64, ubuntu-24.04-arm) (push) Waiting to run
Docker Image Build / merge (push) Blocked by required conditions
Docker Image Build (FrankenPHP) / build (linux/amd64, amd64, ubuntu-latest) (push) Waiting to run
Docker Image Build (FrankenPHP) / build (linux/arm/v7, armv7, ubuntu-24.04-arm) (push) Waiting to run
Docker Image Build (FrankenPHP) / build (linux/arm64, arm64, ubuntu-24.04-arm) (push) Waiting to run
Docker Image Build (FrankenPHP) / merge (push) Blocked by required conditions
Static analysis / Static analysis (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, sqlite) (push) Waiting to run
Some checks are pending
Build assets artifact / Build assets artifact (push) Waiting to run
Docker Image Build / build (linux/amd64, amd64, ubuntu-latest) (push) Waiting to run
Docker Image Build / build (linux/arm/v7, armv7, ubuntu-24.04-arm) (push) Waiting to run
Docker Image Build / build (linux/arm64, arm64, ubuntu-24.04-arm) (push) Waiting to run
Docker Image Build / merge (push) Blocked by required conditions
Docker Image Build (FrankenPHP) / build (linux/amd64, amd64, ubuntu-latest) (push) Waiting to run
Docker Image Build (FrankenPHP) / build (linux/arm/v7, armv7, ubuntu-24.04-arm) (push) Waiting to run
Docker Image Build (FrankenPHP) / build (linux/arm64, arm64, ubuntu-24.04-arm) (push) Waiting to run
Docker Image Build (FrankenPHP) / merge (push) Blocked by required conditions
Static analysis / Static analysis (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, sqlite) (push) Waiting to run
This commit is contained in:
parent
4137bde194
commit
fe4dc1f1e4
6 changed files with 60 additions and 9 deletions
|
|
@ -31,6 +31,7 @@ use App\Services\InfoProviderSystem\ExistingPartFinder;
|
|||
use App\Services\InfoProviderSystem\PartInfoRetriever;
|
||||
use App\Services\InfoProviderSystem\ProviderRegistry;
|
||||
use App\Services\InfoProviderSystem\Providers\GenericWebProvider;
|
||||
use App\Services\InfoProviderSystem\Providers\InfoProviderInterface;
|
||||
use App\Settings\AppSettings;
|
||||
use App\Settings\InfoProviderSystem\InfoProviderGeneralSettings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
|
@ -172,10 +173,15 @@ class InfoProviderController extends AbstractController
|
|||
$keyword = $form->get('keyword')->getData();
|
||||
$providers = $form->get('providers')->getData();
|
||||
|
||||
$no_cache_search = $form->get('no_cache_search')->getData();
|
||||
$no_cache_details = $form->get('no_cache_details')->getData();
|
||||
|
||||
$dtos = [];
|
||||
|
||||
try {
|
||||
$dtos = $this->infoRetriever->searchByKeyword(keyword: $keyword, providers: $providers);
|
||||
$dtos = $this->infoRetriever->searchByKeyword(keyword: $keyword, providers: $providers, options: [
|
||||
InfoProviderInterface::OPTION_NO_CACHE => $no_cache_search
|
||||
]);
|
||||
} catch (ClientException $e) {
|
||||
$this->addFlash('error', t('info_providers.search.error.client_exception'));
|
||||
$this->addFlash('error',$e->getMessage());
|
||||
|
|
@ -207,7 +213,8 @@ class InfoProviderController extends AbstractController
|
|||
return $this->render('info_providers/search/part_search.html.twig', [
|
||||
'form' => $form,
|
||||
'results' => $results,
|
||||
'update_target' => $update_target
|
||||
'update_target' => $update_target,
|
||||
'no_cache_details' => $no_cache_details ?? false,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -346,10 +346,13 @@ final class PartController extends AbstractController
|
|||
$this->denyAccessUnlessGranted('edit', $part);
|
||||
$this->denyAccessUnlessGranted('@info_providers.create_parts');
|
||||
|
||||
//Force info providers to not use cache, when retrieving part details for creating a new part, because otherwise we might end up with outdated information
|
||||
$no_cache = $request->query->getBoolean('no_cache', false);
|
||||
|
||||
//Save the old name of the target part for the template
|
||||
$old_name = $part->getName();
|
||||
|
||||
$dto = $infoRetriever->getDetails($providerKey, $providerId);
|
||||
$dto = $infoRetriever->getDetails($providerKey, $providerId, [InfoProviderInterface::OPTION_NO_CACHE => $no_cache]);
|
||||
$provider_part = $infoRetriever->dtoToPart($dto);
|
||||
|
||||
$part = $partMerger->merge($part, $provider_part);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||
namespace App\Form\InfoProviderSystem;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SearchType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
|
@ -40,8 +41,17 @@ class PartSearchType extends AbstractType
|
|||
'help' => 'info_providers.search.providers.help',
|
||||
]);
|
||||
|
||||
$builder->add('no_cache_search', CheckboxType::class, [
|
||||
'label' => 'info_providers.no_cache_search',
|
||||
'required' => false,
|
||||
]);
|
||||
$builder->add('no_cache_details', CheckboxType::class, [
|
||||
'label' => 'info_providers.no_cache_details',
|
||||
'required' => false,
|
||||
]);
|
||||
|
||||
$builder->add('submit', SubmitType::class, [
|
||||
'label' => 'info_providers.search.submit'
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ final class PartInfoRetriever
|
|||
}
|
||||
|
||||
/** @noinspection SlowArrayOperationsInLoopInspection */
|
||||
$results = array_merge($results, $this->searchInProvider($provider, $keyword));
|
||||
$results = array_merge($results, $this->searchInProvider($provider, $keyword, $options));
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,19 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-2">
|
||||
<div class="{{ col_input }} {{ offset_label }}">
|
||||
<a data-bs-toggle="collapse" href="#infoSearchAdvancedPanel">{% trans %}info_providers.search.advanced_options{% endtrans %}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="collapse" id="infoSearchAdvancedPanel">
|
||||
<div class="card card-body mb-2">
|
||||
{{ form_row(form.no_cache_search) }}
|
||||
{{ form_row(form.no_cache_details) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ form_row(form.submit) }}
|
||||
|
||||
{{ form_end(form) }}
|
||||
|
|
@ -116,16 +129,16 @@
|
|||
|
||||
{% if update_target %} {# We update an existing part #}
|
||||
{% set href = path('info_providers_update_part',
|
||||
{'providerKey': dto.provider_key, 'providerId': dto.provider_id, 'id': update_target.iD}) %}
|
||||
{'providerKey': dto.provider_key, 'providerId': dto.provider_id, 'id': update_target.iD, 'no_cache': no_cache_details ? 1 : null}) %}
|
||||
{% else %} {# Create a fresh part #}
|
||||
{% set href = path('info_providers_create_part',
|
||||
{'providerKey': dto.provider_key, 'providerId': dto.provider_id}) %}
|
||||
{'providerKey': dto.provider_key, 'providerId': dto.provider_id, 'no_cache': no_cache_details ? 1 : null}) %}
|
||||
{% endif %}
|
||||
|
||||
{# If we have no local part, then we can just show the create button #}
|
||||
{% if localPart is null %}
|
||||
<a class="btn btn-primary" href="{{ href }}"
|
||||
target="_blank" title="{% trans %}part.create.btn{% endtrans %}">
|
||||
target="_blank" title="{% trans %}part.create.btn{% endtrans %}">
|
||||
<i class="fa-solid fa-plus-square"></i>
|
||||
</a>
|
||||
{% else %} {# Otherwise add a button group with all three buttons #}
|
||||
|
|
@ -139,7 +152,7 @@
|
|||
target="_blank" title="{% trans %}info_providers.search.show_existing_part{% endtrans %}">
|
||||
<i class="fa-solid fa-search"></i>
|
||||
</a>
|
||||
<a class="btn btn-primary" href="{{ path("info_providers_update_part", {'id': localPart.id, 'providerKey': dto.provider_key, 'providerId': dto.provider_id}) }}"
|
||||
<a class="btn btn-primary" href="{{ path("info_providers_update_part", {'id': localPart.id, 'providerKey': dto.provider_key, 'providerId': dto.provider_id, 'no_cache': no_cache_details ? 1 : null }) }}"
|
||||
target="_blank" title="{% trans %}info_providers.search.update_existing_part{% endtrans %}">
|
||||
<i class="fa-solid fa-arrows-rotate"></i>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -13139,5 +13139,23 @@ Buerklin-API Authentication server:
|
|||
<target>The additional instructions will be appended to the system prompt.</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="Ycfssj2" name="info_providers.search.advanced_options">
|
||||
<segment>
|
||||
<source>info_providers.search.advanced_options</source>
|
||||
<target>Advanced options</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="xfxZrXn" name="info_providers.no_cache_search">
|
||||
<segment>
|
||||
<source>info_providers.no_cache_search</source>
|
||||
<target>Do not cache search results / Force fresh search</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="b_oc3T1" name="info_providers.no_cache_details">
|
||||
<segment>
|
||||
<source>info_providers.no_cache_details</source>
|
||||
<target>Do not cache result details / Force fresh part detail retrieval</target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue