ref
This commit is contained in:
@@ -255,10 +255,17 @@
|
||||
{
|
||||
"route": "/Export",
|
||||
"method": "post",
|
||||
"params": {
|
||||
"controller": "Export",
|
||||
"action": "process"
|
||||
}
|
||||
"actionClassName": "Espo\\Tools\\Export\\Api\\PostProcess"
|
||||
},
|
||||
{
|
||||
"route": "/Export/:id/status",
|
||||
"method": "get",
|
||||
"actionClassName": "Espo\\Tools\\Export\\Api\\GetStatus"
|
||||
},
|
||||
{
|
||||
"route": "/Export/:id/subscribe",
|
||||
"method": "post",
|
||||
"actionClassName": "Espo\\Tools\\Export\\Api\\PostSubscribe"
|
||||
},
|
||||
{
|
||||
"route": "/Kanban/order",
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\Export\Api;
|
||||
|
||||
use Espo\Core\Api\Action;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Api\ResponseComposer;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Tools\Export\Service;
|
||||
|
||||
/**
|
||||
* Export status.
|
||||
*/
|
||||
class GetStatus implements Action
|
||||
{
|
||||
public function __construct(private Service $service)
|
||||
{}
|
||||
|
||||
public function process(Request $request): Response
|
||||
{
|
||||
$id = $request->getRouteParam('id');
|
||||
|
||||
if (!$id) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$result = $this->service->getStatusData($id);
|
||||
|
||||
return ResponseComposer::json($result);
|
||||
}
|
||||
}
|
||||
+15
-36
@@ -27,26 +27,26 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Controllers;
|
||||
namespace Espo\Tools\Export\Api;
|
||||
|
||||
use Espo\Core\Api\Action;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Api\ResponseComposer;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
|
||||
use Espo\Core\Utils\Json;
|
||||
|
||||
use Espo\Tools\Export\Params;
|
||||
use Espo\Tools\Export\Service;
|
||||
use Espo\Tools\Export\ServiceParams;
|
||||
use Espo\Tools\Export\Params;
|
||||
|
||||
use stdClass;
|
||||
|
||||
class Export
|
||||
class PostProcess implements Action
|
||||
{
|
||||
public function __construct(private Service $service)
|
||||
{}
|
||||
|
||||
public function postActionProcess(Request $request): stdClass
|
||||
public function process(Request $request): Response
|
||||
{
|
||||
$params = $this->fetchRawParamsFromRequest($request);
|
||||
|
||||
@@ -60,40 +60,19 @@ class Export
|
||||
|
||||
assert($subResult !== null);
|
||||
|
||||
return (object) [
|
||||
'id' => $subResult->getAttachmentId(),
|
||||
];
|
||||
return ResponseComposer::json([
|
||||
'id' => $subResult->getAttachmentId()
|
||||
]);
|
||||
}
|
||||
|
||||
return (object) [
|
||||
'exportId' => $result->getId(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getActionStatus(Request $request): stdClass
|
||||
{
|
||||
$id = $request->getQueryParam('id');
|
||||
|
||||
if (!$id) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
return $this->service->getStatusData($id);
|
||||
}
|
||||
|
||||
public function postActionSubscribeToNotificationOnSuccess(Request $request, Response $response): void
|
||||
{
|
||||
$id = $request->getParsedBody()->id ?? null;
|
||||
|
||||
if (!$id || !is_string($id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->service->subscribeToNotificationOnSuccess($id);
|
||||
|
||||
$response->writeBody('true');
|
||||
return ResponseComposer::json([
|
||||
'exportId' => $result->getId()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
*/
|
||||
private function fetchRawParamsFromRequest(Request $request): Params
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\Export\Api;
|
||||
|
||||
use Espo\Core\Api\Action;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Api\ResponseComposer;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Tools\Export\Service;
|
||||
|
||||
/**
|
||||
* Subscribes to a notification on export success.
|
||||
*/
|
||||
class PostSubscribe implements Action
|
||||
{
|
||||
public function __construct(private Service $service)
|
||||
{}
|
||||
|
||||
public function process(Request $request): Response
|
||||
{
|
||||
$id = $request->getRouteParam('id');
|
||||
|
||||
if (!$id) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->service->subscribeToNotificationOnSuccess($id);
|
||||
|
||||
return ResponseComposer::json(true);
|
||||
}
|
||||
}
|
||||
@@ -113,9 +113,7 @@ define('views/export/modals/idle', ['views/modal', 'model'], function (Dep, Mode
|
||||
return;
|
||||
}
|
||||
|
||||
Espo.Ajax.postRequest('Export/action/subscribeToNotificationOnSuccess', {
|
||||
id: this.id,
|
||||
});
|
||||
Espo.Ajax.postRequest(`Export/${this.id}/subscribe`);
|
||||
});
|
||||
|
||||
this.checkStatus();
|
||||
@@ -123,9 +121,7 @@ define('views/export/modals/idle', ['views/modal', 'model'], function (Dep, Mode
|
||||
|
||||
checkStatus: function () {
|
||||
Espo.Ajax
|
||||
.getRequest('Export/action/status', {
|
||||
id: this.id,
|
||||
})
|
||||
.getRequest(`Export/${this.id}/status`)
|
||||
.then(response => {
|
||||
let status = response.status;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user