fix: [localTools:action] Catch error if local tool's action returned unexpected data
parent
d55c1fd5d1
commit
8c4c75d83a
|
@ -6,6 +6,8 @@ use App\Controller\AppController;
|
|||
use Cake\Utility\Hash;
|
||||
use Cake\Utility\Text;
|
||||
use \Cake\Database\Expression\QueryExpression;
|
||||
use Cake\Http\Exception\NotFoundException;
|
||||
use Cake\Http\Exception\MethodNotAllowedException;
|
||||
|
||||
class LocalToolsController extends AppController
|
||||
{
|
||||
|
@ -110,6 +112,9 @@ class LocalToolsController extends AppController
|
|||
$actionDetails = $this->LocalTools->getActionDetails($actionName);
|
||||
$params['connection'] = $connection;
|
||||
$results = $this->LocalTools->action($this->ACL->getUser()['id'], $connection->connector, $actionName, $params, $this->request);
|
||||
if (empty($results)) {
|
||||
throw new MethodNotAllowedException(__('Could not execute the requested action.'));
|
||||
}
|
||||
if (!empty($results['redirect'])) {
|
||||
$this->redirect($results['redirect']);
|
||||
}
|
||||
|
|
|
@ -39,24 +39,22 @@
|
|||
var url = $('#view-child-body-<?= h($randomId) ?>').data('content-url');
|
||||
var loadon = $('#view-child-body-<?= h($randomId) ?>').data('load-on');
|
||||
if (loadon === 'ready') {
|
||||
$.ajax({
|
||||
success:function (data, textStatus) {
|
||||
$('#view-child-body-<?= h($randomId) ?>').html(data);
|
||||
},
|
||||
type: "get",
|
||||
cache: false,
|
||||
url: url,
|
||||
});
|
||||
AJAXApi.quickFetchURL(url, {})
|
||||
.then((html) => {
|
||||
$('#view-child-body-<?= h($randomId) ?>').html(html);
|
||||
})
|
||||
.catch((err) => {
|
||||
$('#view-child-body-<?= h($randomId) ?>').text(err.message);
|
||||
})
|
||||
} else {
|
||||
$('#view-child-<?= h($randomId) ?>').on('hidden.bs.collapse', function () {
|
||||
$.ajax({
|
||||
success:function (data, textStatus) {
|
||||
$('#view-child-body-<?= h($randomId) ?>').html(data);
|
||||
},
|
||||
type: "get",
|
||||
cache: false,
|
||||
url: url,
|
||||
});
|
||||
AJAXApi.quickFetchURL(url, {})
|
||||
.then((html) => {
|
||||
$('#view-child-body-<?= h($randomId) ?>').html(html);
|
||||
})
|
||||
.catch((err) => {
|
||||
$('#view-child-body-<?= h($randomId) ?>').text(err.message);
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue