Merge branch 'develop' into main

pull/92/head
iglocska 2022-01-25 15:59:42 +01:00
commit 9ce2e1d73b
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
11 changed files with 46 additions and 10 deletions

View File

@ -110,6 +110,14 @@ class ResendFailedMessageProcessor extends BroodsOutboxProcessor implements Gene
$dataSent = $outboxRequest->data['sent'];
$response = $this->Broods->sendRequest($brood, $url, true, $dataSent);
$jsonReply = $response->getJson();
if (is_null($jsonReply)) {
$jsonReply = [
'success' => false,
'errors' => [
__('Brood returned an invalid JSON.')
]
];
}
$success = !empty($jsonReply['success']);
$messageSuccess = __('Message successfully sent to `{0}`', $brood->name);
$messageFail = __('Could not send message to `{0}`.', $brood->name);
@ -126,7 +134,7 @@ class ResendFailedMessageProcessor extends BroodsOutboxProcessor implements Gene
[],
$success,
$success ? $messageSuccess : $messageFail,
[]
$jsonReply['errors'] ?? []
);
}

View File

@ -88,7 +88,7 @@ class CRUDComponent extends Component
$this->Controller->restResponsePayload = $this->RestResponse->viewData($data, 'json');
} else {
$this->Controller->loadComponent('Paginator');
$data = $this->Controller->Paginator->paginate($query);
$data = $this->Controller->Paginator->paginate($query, $this->Controller->paginate ?? []);
if (isset($options['afterFind'])) {
$function = $options['afterFind'];
if (is_callable($options['afterFind'])) {

View File

@ -20,6 +20,12 @@ class InboxController extends AppController
public $quickFilterFields = ['scope', 'action', ['title' => true], ['comment' => true]];
public $containFields = ['Users'];
public $paginate = [
'order' => [
'Inbox.created' => 'desc'
]
];
public function beforeFilter(EventInterface $event)
{
parent::beforeFilter($event);

View File

@ -304,7 +304,17 @@ class LocalToolsController extends AppController
throw new MethodNotAllowedException(__('No local tool ID supplied.'));
}
$params['local_tool_id'] = $postParams['local_tool_id'];
$encodingResult = $this->LocalTools->encodeConnection($params);
try {
$encodingResult = $this->LocalTools->encodeConnection($params);
} catch (\Exception $e) {
$encodingResult = [
'inboxResult' => [
'success' => false,
'message' => __('Error while trying to encode connection'),
'errors' => [$e->getMessage()],
],
];
}
$inboxResult = $encodingResult['inboxResult'];
if ($inboxResult['success']) {
if ($this->ParamHandler->isRest()) {

View File

@ -9,6 +9,7 @@ use Cake\Core\Configure;
use Cake\Http\Client;
use Cake\Http\Client\Response;
use Cake\Http\Exception\NotFoundException;
use Cake\Http\Client\Exception\NetworkException;
use Cake\ORM\TableRegistry;
use Cake\Error\Debugger;
@ -69,7 +70,14 @@ class BroodsTable extends AppTable
{
$brood = $this->find()->where(['id' => $id])->first();
$start = microtime(true);
$response = $this->HTTPClientGET('/instance/status.json', $brood);
try {
$response = $this->HTTPClientGET('/instance/status.json', $brood);
} catch (NetworkException $e) {
return [
'error' => __('Could not query status'),
'reason' => $e->getMessage(),
];
}
$ping = ((int)(100 * (microtime(true) - $start)));
$errors = [
403 => [

View File

@ -62,8 +62,11 @@ class InboxTable extends AppTable
$this->Broods = \Cake\ORM\TableRegistry::getTableLocator()->get('Broods');
$this->Individuals = \Cake\ORM\TableRegistry::getTableLocator()->get('Individuals');
$errors = [];
$originUrl = trim($entryData['origin'], '/');
$brood = $this->Broods->find()
->where(['url' => $entryData['origin']])
->where([
'url IN' => [$originUrl, "{$originUrl}/"]
])
->first();
if (empty($brood)) {
$errors[] = __('Unkown brood `{0}`', $entryData['data']['cerebrateURL']);

View File

@ -52,7 +52,8 @@ echo $this->element('genericElements/IndexTable/index_table', [
'name' => __('Changed'),
'sort' => 'changed',
'data_path' => 'changed',
'element' => 'json'
'element' => 'json',
'class' => 'text-break'
],
],
'title' => __('Logs'),

View File

@ -1,4 +1,3 @@
<?php
echo $this->element('genericElements/IndexTable/index_table', $data);
echo '</div>';
?>

View File

@ -29,4 +29,3 @@
]
]);
?>
</div>

View File

@ -1,6 +1,6 @@
<?php
$tagsHtml = $this->Tag->tags($entity['tags'], [
'allTags' => [],
'allTags' => $allTags ?? [],
'picker' => true,
'editable' => true,
]);

View File

@ -55,8 +55,10 @@ function attachTestConnectionResultHtml(result, $container) {
$testResultDiv.append(getKVHtml('Internal error', result, ['text-danger fw-bold']))
} else {
if (result['error']) {
if (result['ping']) {
$testResultDiv.append('Status', 'OK', ['text-danger'], `${result['ping']} ms`);
}
$testResultDiv.append(
getKVHtml('Status', 'OK', ['text-danger'], `${result['ping']} ms`),
getKVHtml('Status', `Error: ${result['error']}`, ['text-danger']),
getKVHtml('Reason', result['reason'], ['text-danger'])
)