mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-25 19:28:51 +02:00
Show an error flash, if the info providers cannnot communicate with the servers instead of throwing an exception
This commit is contained in:
parent
dbff543fa8
commit
03712fcf96
2 changed files with 40 additions and 23 deletions
|
@ -33,14 +33,18 @@ use App\Services\InfoProviderSystem\ProviderRegistry;
|
|||
use App\Services\LogSystem\EventCommentHelper;
|
||||
use App\Services\Parts\PartFormHelper;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpClient\Exception\ClientException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
use function Symfony\Component\Translation\t;
|
||||
|
||||
#[Route('/tools/info_providers')]
|
||||
class InfoProviderController extends AbstractController
|
||||
{
|
||||
|
@ -64,7 +68,7 @@ class InfoProviderController extends AbstractController
|
|||
|
||||
#[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): Response
|
||||
public function search(Request $request, #[MapEntity(id: 'target')] ?Part $update_target, LoggerInterface $exceptionLogger): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('@info_providers.create_parts');
|
||||
|
||||
|
@ -83,7 +87,14 @@ class InfoProviderController extends AbstractController
|
|||
$keyword = $form->get('keyword')->getData();
|
||||
$providers = $form->get('providers')->getData();
|
||||
|
||||
try {
|
||||
$results = $this->infoRetriever->searchByKeyword(keyword: $keyword, providers: $providers);
|
||||
} catch (ClientException $e) {
|
||||
$this->addFlash('error', t('info_providers.search.error.client_exception'));
|
||||
$this->addFlash('error',$e->getMessage());
|
||||
//Log the exception
|
||||
$exceptionLogger->error('Error during info provider search: ' . $e->getMessage(), ['exception' => $e]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('info_providers/search/part_search.html.twig', [
|
||||
|
|
|
@ -11958,118 +11958,124 @@ Please note, that you can not impersonate a disabled user. If you try you will g
|
|||
</segment>
|
||||
</unit>
|
||||
<unit id="2NZFail" name="collection_type.new_element.tooltip">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>collection_type.new_element.tooltip</source>
|
||||
<target>This element was newly created and was not persisted to the database yet.</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="USUaBZ0" name="part.merge.title">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>part.merge.title</source>
|
||||
<target>Merge part</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="sCLZTwA" name="part.merge.title.into">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>part.merge.title.into</source>
|
||||
<target>into</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="nISUoQl" name="part.merge.confirm.title">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>part.merge.confirm.title</source>
|
||||
<target>Do you really want to merge <b>%other%</b> into <b>%target%</b>?</target>
|
||||
<target><![CDATA[Do you really want to merge <b>%other%</b> into <b>%target%</b>?]]></target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="qxHNYfX" name="part.merge.confirm.message">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>part.merge.confirm.message</source>
|
||||
<target><b>%other%</b> will be deleted, and the part will be saved with the shown information.</target>
|
||||
<target><![CDATA[<b>%other%</b> will be deleted, and the part will be saved with the shown information.]]></target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="BY9.T4F" name="part.info.merge_modal.title">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>part.info.merge_modal.title</source>
|
||||
<target>Merge parts</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="CasQeyD" name="part.info.merge_modal.other_part">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>part.info.merge_modal.other_part</source>
|
||||
<target>Other part</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="96Qzc6H" name="part.info.merge_modal.other_into_this">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>part.info.merge_modal.other_into_this</source>
|
||||
<target>Merge other part into this one (delete other part, keep this one)</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="Oe4cpRH" name="part.info.merge_modal.this_into_other">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>part.info.merge_modal.this_into_other</source>
|
||||
<target>Merge this part into other one (delete this part, keep other one)</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="pO3q5CN" name="part.info.merge_btn">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>part.info.merge_btn</source>
|
||||
<target>Merge part</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="efgWRwB" name="part.update_part_from_info_provider.btn">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>part.update_part_from_info_provider.btn</source>
|
||||
<target>Update part from info providers</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="n6_Ec0h" name="info_providers.update_part.title">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>info_providers.update_part.title</source>
|
||||
<target>Update existing part from info provider</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="lkIVIWr" name="part.merge.flash.please_review">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>part.merge.flash.please_review</source>
|
||||
<target>Data not saved yet. Review the changes and click save to persist the new data.</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="0nL5IhK" name="user.edit.flash.permissions_fixed">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>user.edit.flash.permissions_fixed</source>
|
||||
<target>Permissions required by other permissions were missing. This was corrected. Please check if the permissions are as you intended.</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="gjo2ZK7" name="permission.legend.dependency_note">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>permission.legend.dependency_note</source>
|
||||
<target>Please note that some permission operations depend on each other. If you encounter a warning that missing permissions were corrected and a permission was set to allow again, you have to set the dependent operation to forbid too. The dependents can normally found right of an operation.</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="VFdWqOX" name="log.part_stock_changed.timestamp">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>log.part_stock_changed.timestamp</source>
|
||||
<target>Timestamp</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="Hj7NX8C" name="part.info.withdraw_modal.timestamp">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>part.info.withdraw_modal.timestamp</source>
|
||||
<target>Action timestamp</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="USYGK0J" name="part.info.withdraw_modal.timestamp.hint">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>part.info.withdraw_modal.timestamp.hint</source>
|
||||
<target>This field allows you to specify the real date, when the stock operation actually was performed, and not just when it was logged. This value is saved in the extra field of the log entry.</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="GIR36qJ" name="part.info.withdraw_modal.delete_lot_if_empty">
|
||||
<segment state="translated">
|
||||
<segment>
|
||||
<source>part.info.withdraw_modal.delete_lot_if_empty</source>
|
||||
<target>Delete this lot, if it becomes empty</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="g_xxjdS" name="info_providers.search.error.client_exception">
|
||||
<segment>
|
||||
<source>info_providers.search.error.client_exception</source>
|
||||
<target>An error occurred while communicating with the information provider. Check the configuration for this provider and refresh the OAuth tokens if possible.</target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue