From 7b3c327edd4cfbf0c9cc1fc861b569eb5064a0f0 Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Fri, 11 Oct 2019 15:51:22 +0200 Subject: [PATCH] FEAT #11691 TIME 1:15 Refactoring route attachments + notes --- .../indexing_searching/choose_file.php | 6 - .../indexing_searching/details.php | 2 +- apps/maarch_entreprise/js/angularFunctions.js | 2 +- apps/maarch_entreprise/js/functions.js | 31 ----- core/class/LinkController.php | 2 +- modules/attachments/attachments_content.php | 4 +- modules/attachments/view_attachment.php | 2 +- modules/sendmail/load_toolbar_sendmail.php | 2 +- modules/sendmail/mail_form.php | 6 +- modules/sendmail/sendmail_ajax_content.php | 17 +-- rest/index.php | 35 +++--- .../controllers/AttachmentController.php | 65 +++++----- src/app/email/models/EmailModel.php | 19 --- src/app/note/controllers/NoteController.php | 112 +++++++++--------- .../resource/controllers/ResController.php | 5 - .../resource/controllers/StoreController.php | 25 ---- .../controllers/SignatureBookController.php | 8 +- .../send-shipping-action.component.html | 4 +- .../view-doc-action.component.ts | 2 +- .../attachments-list.component.html | 4 +- .../attachments/attachments-list.component.ts | 4 +- .../folder-document-list.component.ts | 6 +- src/frontend/app/home/home.component.ts | 6 +- .../app/list/basket-list.component.ts | 6 +- .../app/notes/note-editor.component.ts | 4 +- src/frontend/app/notes/notes.component.ts | 2 +- .../app/signature-book.component.html | 6 +- src/frontend/app/signature-book.component.ts | 4 +- 28 files changed, 152 insertions(+), 239 deletions(-) diff --git a/apps/maarch_entreprise/indexing_searching/choose_file.php b/apps/maarch_entreprise/indexing_searching/choose_file.php index 050629396c5..abbd9f5ca4d 100755 --- a/apps/maarch_entreprise/indexing_searching/choose_file.php +++ b/apps/maarch_entreprise/indexing_searching/choose_file.php @@ -178,12 +178,6 @@ $_SESSION['upfile']['fileNamePdfOnTmp'] = ''; <?php } ?> - <input type="file" name="file" id="file" onchange="uploadFiles();" - value="<?php $_REQUEST['with_file'] = 'false'; - if (isset($_SESSION['file_path'])) { - echo $_SESSION['file_path']; - } ?>" - style="width:200px;margin-left:33px;display:none;" /> </p> <p style="display:none;"> <label for="with_file"> diff --git a/apps/maarch_entreprise/indexing_searching/details.php b/apps/maarch_entreprise/indexing_searching/details.php index d35f67b55de..a6d7221c207 100755 --- a/apps/maarch_entreprise/indexing_searching/details.php +++ b/apps/maarch_entreprise/indexing_searching/details.php @@ -355,7 +355,7 @@ if ($stmt->rowCount() == 0) { <p id="viewdoc"> <?php if ($info_mail->filename) { ?> - <a href="../../rest/res/<?php functions::xecho($s_id); ?>/content" target="_blank"> + <a href="../../rest/resources/<?php functions::xecho($s_id); ?>/content" target="_blank"> <?php echo _VIEW_DOC;?> <i class="tooltip visaPjUp tooltipstered fa fa-eye fa-2x" style="height: auto; width: auto;font-size: 14px;margin-right:6px;margin-top: -9px;" title="<?php echo _VIEW_DOC; ?>"></i> </a> diff --git a/apps/maarch_entreprise/js/angularFunctions.js b/apps/maarch_entreprise/js/angularFunctions.js index b46e9b8d9b7..3d1caca679f 100755 --- a/apps/maarch_entreprise/js/angularFunctions.js +++ b/apps/maarch_entreprise/js/angularFunctions.js @@ -172,7 +172,7 @@ function setSessionForSignatureBook(resId) { } function displayThumbnail(resId) { - $j('#thumb_' + resId).html('<img src="../../rest/res/' + resId + '/thumbnail">'); + $j('#thumb_' + resId).html('<img src="../../rest/resources/' + resId + '/thumbnail">'); } var koKeys = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65]; diff --git a/apps/maarch_entreprise/js/functions.js b/apps/maarch_entreprise/js/functions.js index f02b6d105c9..3b3e0132659 100755 --- a/apps/maarch_entreprise/js/functions.js +++ b/apps/maarch_entreprise/js/functions.js @@ -3968,34 +3968,3 @@ function setSendAttachment(id, isVersion) { } }); } - -function uploadFiles () { - - var fileInfo = $j("#file")[0]["files"][0]; - - var extension = ""; - - // set extension according to filename - if (fileInfo.name.split('.').length > 1) { - extension = fileInfo.name.split('.').pop(); - } - - $j.ajax({ - url: '../../rest/resources/checkFileUpload', - type: 'POST', - dataType: "json", - data: { - extension : extension, - size : fileInfo.size, - type : fileInfo.type, - }, - success: function (answer) { - $j('#with_file')[0].value='false'; - $j("#select_file_form").attr('method','post'); - $j("#select_file_form").submit(); - }, - error: function (err) { - alert(err.responseJSON.errors); - } - }); -} diff --git a/core/class/LinkController.php b/core/class/LinkController.php index 47fb2bc3d11..5e1e4ba9066 100755 --- a/core/class/LinkController.php +++ b/core/class/LinkController.php @@ -118,7 +118,7 @@ class LinkController $delChild = $key; } $return .= '<td align="right">'; - $return .= '<div align="center" class="iconDoc"><a href="index.php?display=true&dir=indexing_searching&page=view_resource_controler&id='.$key.'" target="_blank" title="'._VIEW_DOC.'"><i class="fa fa-download fa-2x" title="'._VIEW_DOC.'"></i><span><img src="../../rest/res/'.$key.'/thumbnail"></span></a></div>'; + $return .= '<div align="center" class="iconDoc"><a href="index.php?display=true&dir=indexing_searching&page=view_resource_controler&id='.$key.'" target="_blank" title="'._VIEW_DOC.'"><i class="fa fa-download fa-2x" title="'._VIEW_DOC.'"></i><span><img src="../../rest/resources/'.$key.'/thumbnail"></span></a></div>'; $return .= '</td>'; $return .= '<td align="right">'; $return .= '<span onclick="'; diff --git a/modules/attachments/attachments_content.php b/modules/attachments/attachments_content.php index 6bfbbd745ef..ced53db6eac 100755 --- a/modules/attachments/attachments_content.php +++ b/modules/attachments/attachments_content.php @@ -1720,12 +1720,12 @@ $content .= '</div>'; // ATTACHMENT IFRAME if ($mode == 'edit') { - $srcAttachment = '../../rest/res/'.functions::xssafe($_SESSION['doc_id']).'/attachments/'.$_REQUEST['id'] . '/content'; + $srcAttachment = '../../rest/attachments/'.$_REQUEST['id'] . '/content'; $content .= '<iframe src="'.$srcAttachment.'" name="iframePjDocument_0" id="iframePjDocument_0" scrolling="auto" frameborder="0" style="width:100% !important;height:85vh;display:none" onmouseover="this.focus()"></iframe>'; } // MAIN DOCUMENT IFRAME -$content .= '<iframe src="../../rest/res/'.functions::xssafe($_SESSION['doc_id']).'/content" name="iframeMainDocument" id="iframeMainDocument" scrolling="auto" frameborder="0" style="width:100% !important;height:85vh;display:none" onmouseover="this.focus()"></iframe>'; +$content .= '<iframe src="../../rest/resources/'.functions::xssafe($_SESSION['doc_id']).'/content" name="iframeMainDocument" id="iframeMainDocument" scrolling="auto" frameborder="0" style="width:100% !important;height:85vh;display:none" onmouseover="this.focus()"></iframe>'; $content .= '</div>'; diff --git a/modules/attachments/view_attachment.php b/modules/attachments/view_attachment.php index 6b8ec147e4b..e38ad99910f 100755 --- a/modules/attachments/view_attachment.php +++ b/modules/attachments/view_attachment.php @@ -131,7 +131,7 @@ if (! empty($_SESSION['error'])) { if ((!empty($_GET['editingMode']) || !empty($_GET['viewpdf'])) && strpos($line->format, 'xl') === false && strpos($line->format, 'ppt') === false) { header( - "location: ../../rest/res/".$_REQUEST['res_id_master']."/attachments/".$_GET['id']."/content" + "location: ../../rest/attachments/".$_GET['id']."/content" ); $stmtPdf = $db->query( "SELECT docserver_id, path, filename, format, title diff --git a/modules/sendmail/load_toolbar_sendmail.php b/modules/sendmail/load_toolbar_sendmail.php index 81bb30ee953..ab27719c827 100755 --- a/modules/sendmail/load_toolbar_sendmail.php +++ b/modules/sendmail/load_toolbar_sendmail.php @@ -16,7 +16,7 @@ require_once "modules" . DIRECTORY_SEPARATOR . "sendmail" . DIRECTORY_SEPARATOR $sendmail_tools = new sendmail(); //Count mails -$nbr_emails = \Email\models\EmailModel::getCount(['resId' => $res_id]); +$nbr_emails = 0; if ($nbr_emails == 0) { $class = 'nbResZero'; $style2 = 'display:none;'; diff --git a/modules/sendmail/mail_form.php b/modules/sendmail/mail_form.php index 669048bed61..3492cfe5804 100755 --- a/modules/sendmail/mail_form.php +++ b/modules/sendmail/mail_form.php @@ -606,7 +606,7 @@ if ($mode == 'add') { if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) { $id = $_REQUEST['id']; $user = \User\models\UserModel::getByLogin(['login' => $_SESSION['user']['UserId'], 'select' => ['id']]); - $emailArray = \Email\controllers\EmailController::getById(['id' => $id, 'userId' => $user['id']]); + $emailArray = []; //Check if mail exists if (count($emailArray) > 0) { @@ -1016,7 +1016,7 @@ if ($mode == 'add') { $emailArray = ReadMessageExchangeController::getMessageExchange(['id' => $id]); } else { $user = \User\models\UserModel::getByLogin(['login' => $_SESSION['user']['UserId'], 'select' => ['id']]); - $emailArray = \Email\controllers\EmailController::getById(['id' => $id, 'userId' => $user['id']]); + $emailArray = []; } //Check if mail exists @@ -1392,4 +1392,4 @@ echo $content; ?> </body> -</html> \ No newline at end of file +</html> diff --git a/modules/sendmail/sendmail_ajax_content.php b/modules/sendmail/sendmail_ajax_content.php index a44df7ce276..8be3b8327eb 100755 --- a/modules/sendmail/sendmail_ajax_content.php +++ b/modules/sendmail/sendmail_ajax_content.php @@ -459,22 +459,7 @@ switch ($mode) { $entityInfo = \Entity\models\EntityModel::getByEntityId(['entityId' => $aSenderInfo[0], 'select' => ['id']]); } - $isSent = \Email\controllers\EmailController::update([ - 'userId' => $userInfo['id'], - 'emailId' => $id, - 'data' => [ - 'sender' => empty($entityInfo) ? ['email' => $userInfo['mail']] : ['email' => $aSenderInfo[1], 'entityId' => $entityInfo['id']], - 'recipients' => explode(",", $to), - 'cc' => explode(",", $cc), - 'cci' => explode(",", $cci), - 'object' => (empty($_REQUEST['object']) ? '' : substr($_REQUEST['object'], 0, 100)), - 'body' => $body, - 'document' => $document, - 'isHtml' => $isHtml, - 'status' => $email_status - ] - ]); - + if (!empty($isSent['errors'])) { $error = $isSent['errors']; } diff --git a/rest/index.php b/rest/index.php index 2ea0763fb7a..683f2b8d979 100755 --- a/rest/index.php +++ b/rest/index.php @@ -69,11 +69,11 @@ $app->get('/administration', \SrcCore\controllers\CoreController::class . ':getA //Attachments $app->post('/attachments', \Attachment\controllers\AttachmentController::class . ':create'); +$app->get('/attachments/{id}/content', \Attachment\controllers\AttachmentController::class . ':getFileContent'); +$app->get('/attachments/{id}/originalContent', \Attachment\controllers\AttachmentController::class . ':getOriginalFileContent'); +$app->get('/attachments/{id}/thumbnail', \Attachment\controllers\AttachmentController::class . ':getThumbnailContent'); +$app->put('/attachments/{id}/inSendAttachment', \Attachment\controllers\AttachmentController::class . ':setInSendAttachment'); $app->get('/attachmentsTypes', \Attachment\controllers\AttachmentController::class . ':getAttachmentsTypes'); -$app->get('/resources/{resId}/attachments', \Attachment\controllers\AttachmentController::class . ':getByResId'); -$app->get('/res/{resIdMaster}/attachments/{resId}/content', \Attachment\controllers\AttachmentController::class . ':getFileContent'); -$app->get('/resources/{resId}/attachments/{id}/originalContent', \Attachment\controllers\AttachmentController::class . ':getOriginalFileContent'); -$app->get('/res/{resIdMaster}/attachments/{resId}/thumbnail', \Attachment\controllers\AttachmentController::class . ':getThumbnailContent'); //AutoComplete $app->get('/autocomplete/contacts', \SrcCore\controllers\AutoCompleteController::class . ':getContacts'); @@ -169,6 +169,8 @@ $app->get('/administration/doctypes/new', \Doctype\controllers\FirstLevelControl //Emails $app->post('/emails', \Email\controllers\EmailController::class . ':send'); +$app->get('/emails/{id}', \Email\controllers\EmailController::class . ':getById'); +$app->put('/emails/{id}', \Email\controllers\EmailController::class . ':update'); $app->delete('/emails/{id}', \Email\controllers\EmailController::class . ':delete'); //Entities @@ -275,12 +277,11 @@ $app->put('/listTemplates/types/{typeId}/roles', \Entity\controllers\ListTemplat $app->get('/roles', \Entity\controllers\ListTemplateController::class . ':getRoles'); //Notes -$app->get('/notes/templates', \Note\controllers\NoteController::class . ':getTemplates'); -$app->get('/resources/{resId}/notes', \Note\controllers\NoteController::class . ':get'); -$app->post('/resources/{resId}/notes', \Note\controllers\NoteController::class . ':create'); -$app->get('/resources/{resId}/notes/{id}', \Note\controllers\NoteController::class . ':getById'); -$app->put('/resources/{resId}/notes/{id}', \Note\controllers\NoteController::class . ':update'); -$app->delete('/resources/{resId}/notes/{id}', \Note\controllers\NoteController::class . ':delete'); +$app->post('/notes', \Note\controllers\NoteController::class . ':create'); +$app->get('/notes/{id}', \Note\controllers\NoteController::class . ':getById'); +$app->put('/notes/{id}', \Note\controllers\NoteController::class . ':update'); +$app->delete('/notes/{id}', \Note\controllers\NoteController::class . ':delete'); +$app->get('/notesTemplates', \Note\controllers\NoteController::class . ':getTemplates'); //Parameters $app->get('/parameters', \Parameter\controllers\ParameterController::class . ':get'); @@ -309,18 +310,20 @@ $app->put('/reports/groups/{groupId}', \Report\controllers\ReportController::cla //Resources $app->post('/resources', \Resource\controllers\ResController::class . ':create'); -$app->get('/res/{resId}/content', \Resource\controllers\ResController::class . ':getFileContent'); +$app->get('/resources/{resId}/content', \Resource\controllers\ResController::class . ':getFileContent'); $app->get('/resources/{resId}/originalContent', \Resource\controllers\ResController::class . ':getOriginalFileContent'); -$app->get('/res/{resId}/thumbnail', \Resource\controllers\ResController::class . ':getThumbnailContent'); +$app->get('/resources/{resId}/thumbnail', \Resource\controllers\ResController::class . ':getThumbnailContent'); +$app->get('/resources/{resId}/isAllowed', \Resource\controllers\ResController::class . ':isAllowedForCurrentUser'); +$app->get('/resources/{resId}/attachments', \Attachment\controllers\AttachmentController::class . ':getByResId'); +$app->get('/resources/{resId}/emails', \Email\controllers\EmailController::class . ':getByResId'); +$app->get('/resources/{resId}/notes', \Note\controllers\NoteController::class . ':getByResId'); $app->get('/res/{resId}/acknowledgementReceipt/{id}', \AcknowledgementReceipt\controllers\AcknowledgementReceiptController::class . ':getAcknowledgementReceipt'); $app->put('/res/resource/status', \Resource\controllers\ResController::class . ':updateStatus'); $app->post('/res/list', \Resource\controllers\ResController::class . ':getList'); $app->get('/res/{resId}/notes/count', \Resource\controllers\ResController::class . ':getNotesCountForCurrentUserById'); $app->put('/res/externalInfos', \Resource\controllers\ResController::class . ':updateExternalInfos'); $app->get('/categories', \Resource\controllers\ResController::class . ':getCategories'); -$app->get('/natures', \Resource\controllers\ResController::class . ':getNatures'); -$app->get('/resources/{resId}/isAllowed', \Resource\controllers\ResController::class . ':isAllowedForCurrentUser'); -$app->post('/resources/checkFileUpload', \Resource\controllers\StoreController::class . ':checkFileUpload'); +$app->get('/resources/{resId}/users/{userId}/isDestinationChanging', \Action\controllers\PreProcessActionController::class . ':isDestinationChanging'); //ResourcesList $app->get('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}', \Resource\controllers\ResourceListController::class . ':get'); @@ -339,7 +342,6 @@ $app->post('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/ch $app->post('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/checkExternalNoteBook', \Action\controllers\PreProcessActionController::class . ':checkExternalNoteBook'); $app->get('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/actions/{actionId}/getRedirect', \Action\controllers\PreProcessActionController::class . ':getRedirectInformations'); $app->post('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/actions/{actionId}/checkShippings', \Action\controllers\PreProcessActionController::class . ':checkShippings'); -$app->get('/resources/{resId}/users/{userId}/isDestinationChanging', \Action\controllers\PreProcessActionController::class . ':isDestinationChanging'); //shipping $app->get('/administration/shippings', \Shipping\controllers\ShippingTemplateController::class . ':get'); @@ -348,7 +350,6 @@ $app->get('/administration/shippings/{id}', \Shipping\controllers\ShippingTempla $app->post('/administration/shippings', \Shipping\controllers\ShippingTemplateController::class . ':create'); $app->put('/administration/shippings/{id}', \Shipping\controllers\ShippingTemplateController::class . ':update'); $app->delete('/administration/shippings/{id}', \Shipping\controllers\ShippingTemplateController::class . ':delete'); -$app->put('/attachments/{id}/inSendAttachment', \Attachment\controllers\AttachmentController::class . ':setInSendAttachment'); //SignatureBook $app->get('/signatureBook/users/{userId}/groups/{groupId}/baskets/{basketId}/resources', \SignatureBook\controllers\SignatureBookController::class . ':getResources'); diff --git a/src/app/attachment/controllers/AttachmentController.php b/src/app/attachment/controllers/AttachmentController.php index d843c16149c..b83ab28f92b 100755 --- a/src/app/attachment/controllers/AttachmentController.php +++ b/src/app/attachment/controllers/AttachmentController.php @@ -217,25 +217,27 @@ class AttachmentController return $response->withJson(['success' => 'success']); } - public function getThumbnailContent(Request $request, Response $response, array $aArgs) + public function getThumbnailContent(Request $request, Response $response, array $args) { - if (!Validator::intVal()->validate($aArgs['resId']) || !Validator::intVal()->validate($aArgs['resIdMaster']) || !ResController::hasRightByResId(['resId' => [$aArgs['resIdMaster']], 'userId' => $GLOBALS['id']])) { - return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); + if (!Validator::intVal()->validate($args['id'])) { + return $response->withStatus(400)->withJson(['errors' => 'Route id is not an integer']); } - $pathToThumbnail = 'apps/maarch_entreprise/img/noThumbnail.png'; - $attachment = AttachmentModel::getOnView([ - 'select' => ['res_id', 'res_id_version', 'docserver_id', 'path', 'filename'], - 'where' => ['res_id = ? or res_id_version = ?', 'res_id_master = ?', 'status not in (?)'], - 'data' => [$aArgs['resId'], $aArgs['resId'], $aArgs['resIdMaster'], ['DEL', 'OBS']], + 'select' => ['res_id', 'res_id_version', 'docserver_id', 'path', 'filename', 'res_id_master'], + 'where' => ['res_id = ? or res_id_version = ?', 'status not in (?)'], + 'data' => [$args['id'], $args['id'], ['DEL', 'OBS']], 'limit' => 1 ]); - if (empty($attachment[0])) { return $response->withStatus(403)->withJson(['errors' => 'Attachment not found']); } + if (!ResController::hasRightByResId(['resId' => [$attachment[0]['res_id_master']], 'userId' => $GLOBALS['id']])) { + return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); + } + + $pathToThumbnail = 'apps/maarch_entreprise/img/noThumbnail.png'; $attachmentTodisplay = $attachment[0]; $isVersion = empty($attachmentTodisplay['res_id']); if ($isVersion) { @@ -246,17 +248,17 @@ class AttachmentController $tnlAdr = AdrModel::getTypedAttachAdrByResId([ 'select' => ['docserver_id', 'path', 'filename'], - 'resId' => $aArgs['resId'], + 'resId' => $args['id'], 'type' => 'TNL', 'isVersion' => $isVersion ]); if (empty($tnlAdr)) { - ConvertThumbnailController::convert(['collId' => $collId, 'resId' => $aArgs['resId'], 'isVersion' => $isVersion]); + ConvertThumbnailController::convert(['collId' => $collId, 'resId' => $args['id'], 'isVersion' => $isVersion]); $tnlAdr = AdrModel::getTypedAttachAdrByResId([ 'select' => ['docserver_id', 'path', 'filename'], - 'resId' => $aArgs['resId'], + 'resId' => $args['id'], 'type' => 'TNL', 'isVersion' => $isVersion ]); @@ -286,23 +288,26 @@ class AttachmentController return $response->withHeader('Content-Type', $mimeType); } - public function getFileContent(Request $request, Response $response, array $aArgs) + public function getFileContent(Request $request, Response $response, array $args) { - if (!Validator::intVal()->validate($aArgs['resIdMaster']) || !ResController::hasRightByResId(['resId' => [$aArgs['resIdMaster']], 'userId' => $GLOBALS['id']])) { - return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); + if (!Validator::intVal()->validate($args['id'])) { + return $response->withStatus(400)->withJson(['errors' => 'Route id is not an integer']); } $attachment = AttachmentModel::getOnView([ 'select' => ['res_id', 'res_id_version', 'docserver_id', 'path', 'filename'], - 'where' => ['res_id = ? or res_id_version = ?', 'res_id_master = ?', 'status not in (?)'], - 'data' => [$aArgs['resId'], $aArgs['resId'], $aArgs['resIdMaster'], ['DEL']], + 'where' => ['res_id = ? or res_id_version = ?', 'status not in (?)'], + 'data' => [$args['id'], $args['id'], ['DEL']], 'limit' => 1 ]); - if (empty($attachment[0])) { return $response->withStatus(403)->withJson(['errors' => 'Attachment not found']); } - + + if (!ResController::hasRightByResId(['resId' => [$attachment[0]['res_id_master']], 'userId' => $GLOBALS['id']])) { + return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); + } + $attachmentTodisplay = $attachment[0]; $id = (empty($attachmentTodisplay['res_id']) ? $attachmentTodisplay['res_id_version'] : $attachmentTodisplay['res_id']); $isVersion = empty($attachmentTodisplay['res_id']); @@ -349,7 +354,7 @@ class AttachmentController } elseif ($value == 'hour_now') { $tmp = date('H:i'); } else { - $backFromView = AttachmentModel::getOnView(['select' => [$value], 'where' => ['res_id = ?'], 'data' => [$aArgs['resId']]]); + $backFromView = AttachmentModel::getOnView(['select' => [$value], 'where' => ['res_id = ?'], 'data' => [$args['id']]]); if (!empty($backFromView[0][$value])) { $tmp = $backFromView[0][$value]; } @@ -414,7 +419,7 @@ class AttachmentController HistoryController::add([ 'tableName' => 'res_attachments', - 'recordId' => $aArgs['resId'], + 'recordId' => $args['id'], 'eventType' => 'VIEW', 'info' => _ATTACH_DISPLAYING . " : {$id}", 'moduleId' => 'attachments', @@ -426,20 +431,24 @@ class AttachmentController public function getOriginalFileContent(Request $request, Response $response, array $args) { - if (!Validator::intVal()->validate($args['resId']) || !ResController::hasRightByResId(['resId' => [$args['resId']], 'userId' => $GLOBALS['id']])) { - return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); + if (!Validator::intVal()->validate($args['id'])) { + return $response->withStatus(400)->withJson(['errors' => 'Route id is not an integer']); } $attachment = AttachmentModel::getOnView([ - 'select' => ['res_id', 'res_id_version', 'docserver_id', 'path', 'filename'], - 'where' => ['res_id = ? or res_id_version = ?', 'res_id_master = ?', 'status not in (?)'], - 'data' => [$args['id'], $args['id'], $args['resId'], ['DEL']], + 'select' => ['res_id', 'res_id_version', 'docserver_id', 'path', 'filename', 'res_id_master'], + 'where' => ['res_id = ? or res_id_version = ?', 'status not in (?)'], + 'data' => [$args['id'], $args['id'], ['DEL']], 'limit' => 1 ]); if (empty($attachment[0])) { return $response->withStatus(403)->withJson(['errors' => 'Attachment not found']); } + if (!ResController::hasRightByResId(['resId' => [$attachment[0]['res_id_master']], 'userId' => $GLOBALS['id']])) { + return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); + } + $attachmentTodisplay = $attachment[0]; $id = (empty($attachmentTodisplay['res_id']) ? $attachmentTodisplay['res_id_version'] : $attachmentTodisplay['res_id']); @@ -469,7 +478,7 @@ class AttachmentController $fileContent = file_get_contents($pathToDocument); } if ($fileContent === false) { - return $response->withStatus(404)->withJson(['errors' => 'Document not found on docserver']); + return $response->withStatus(400)->withJson(['errors' => 'Document not found on docserver']); } $finfo = new \finfo(FILEINFO_MIME_TYPE); @@ -481,7 +490,7 @@ class AttachmentController HistoryController::add([ 'tableName' => 'res_attachments', - 'recordId' => $args['resId'], + 'recordId' => $args['id'], 'eventType' => 'VIEW', 'info' => _ATTACH_DISPLAYING . " : {$id}", 'moduleId' => 'attachments', diff --git a/src/app/email/models/EmailModel.php b/src/app/email/models/EmailModel.php index 0c5cf9fe477..14825554498 100644 --- a/src/app/email/models/EmailModel.php +++ b/src/app/email/models/EmailModel.php @@ -57,25 +57,6 @@ class EmailModel return $email[0]; } - public static function getCount(array $aArgs) - { - ValidatorModel::notEmpty($aArgs, ['resId']); - ValidatorModel::intVal($aArgs, ['resId']); - - $email = DatabaseModel::select([ - 'select' => ['count(1) as nb'], - 'table' => ['emails'], - 'where' => ['document->>\'id\' = ?'], - 'data' => [$aArgs['resId']], - ]); - - if (!empty($email[0])) { - return $email[0]['nb']; - } - - return 0; - } - public static function create(array $aArgs) { ValidatorModel::notEmpty($aArgs, ['userId', 'sender', 'recipients', 'cc', 'cci', 'isHtml', 'status']); diff --git a/src/app/note/controllers/NoteController.php b/src/app/note/controllers/NoteController.php index 6b67dd99baf..3b6990339d6 100755 --- a/src/app/note/controllers/NoteController.php +++ b/src/app/note/controllers/NoteController.php @@ -31,40 +31,34 @@ use Resource\models\ResModel; class NoteController { - public function get(Request $request, Response $response, array $aArgs) + public function getByResId(Request $request, Response $response, array $args) { - $check = Validator::intVal()->notEmpty()->validate($aArgs['resId']); - if (!$check) { - return $response->withStatus(400)->withJson(['errors' => 'resId is empty or not an integer']); + if (!Validator::intVal()->validate($args['resId'])) { + return $response->withStatus(400)->withJson(['errors' => 'Route resId is not an integer']); } - if (!ResController::hasRightByResId(['resId' => [$aArgs['resId']], 'userId' => $GLOBALS['id']])) { + if (!ResController::hasRightByResId(['resId' => [$args['resId']], 'userId' => $GLOBALS['id']])) { return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); } - $user = UserModel::getByLogin(['select' => ['id'], 'login' => $GLOBALS['userId']]); - $aNotes = NoteModel::getByUserIdForResource(['select' => ['*'], 'resId' => $aArgs['resId'], 'userId' => $user['id']]); + $notes = NoteModel::getByUserIdForResource(['select' => ['*'], 'resId' => $args['resId'], 'userId' => $GLOBALS['id']]); - foreach ($aNotes as $key => $note) { + foreach ($notes as $key => $note) { $user = UserModel::getById(['select' => ['firstname', 'lastname', 'user_id'], 'id' => $note['user_id']]); $primaryEntity = UserModel::getPrimaryEntityByUserId(['userId' => $user['user_id']]); - $aNotes[$key]['firstname'] = $user['firstname']; - $aNotes[$key]['lastname'] = $user['lastname']; - $aNotes[$key]['entity_label'] = $primaryEntity['entity_label']; + $notes[$key]['firstname'] = $user['firstname']; + $notes[$key]['lastname'] = $user['lastname']; + $notes[$key]['entity_label'] = $primaryEntity['entity_label']; - $aNotes[$key]['value'] = $note['note_text']; - unset($aNotes[$key]['note_text']); + $notes[$key]['value'] = $note['note_text']; + unset($notes[$key]['note_text']); } - return $response->withJson($aNotes); + return $response->withJson(['notes' => $notes]); } public function getById(Request $request, Response $response, array $args) { - if (!ResController::hasRightByResId(['resId' => [$args['resId']], 'userId' => $GLOBALS['id']])) { - return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); - } - if (!NoteController::hasRightById(['id' => $args['id'], 'userId' => $GLOBALS['id']])) { return $response->withStatus(403)->withJson(['errors' => 'Note out of perimeter']); } @@ -83,14 +77,16 @@ class NoteController public function create(Request $request, Response $response, array $aArgs) { - if (!ResController::hasRightByResId(['resId' => [$aArgs['resId']], 'userId' => $GLOBALS['id']])) { - return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); - } - $body = $request->getParsedBody(); if (!Validator::stringType()->notEmpty()->validate($body['value'])) { - return $response->withStatus(400)->withJson(['errors' => 'Data value is empty or not a string']); + return $response->withStatus(400)->withJson(['errors' => 'Body value is empty or not a string']); + } elseif (!Validator::intVal()->notEmpty()->validate($body['resId'])) { + return $response->withStatus(400)->withJson(['errors' => 'Body resId is empty or not an integer']); + } + + if (!ResController::hasRightByResId(['resId' => [$body['resId']], 'userId' => $GLOBALS['id']])) { + return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); } if (!empty($body['entities'])) { @@ -104,7 +100,7 @@ class NoteController } $noteId = NoteModel::create([ - 'resId' => $aArgs['resId'], + 'resId' => $body['resId'], 'user_id' => $GLOBALS['id'], 'note_text' => $body['value'] ]); @@ -129,8 +125,8 @@ class NoteController public function update(Request $request, Response $response, array $args) { - if (!ResController::hasRightByResId(['resId' => [$args['resId']], 'userId' => $GLOBALS['id']])) { - return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); + if (!NoteController::hasRightById(['id' => $args['id'], 'userId' => $GLOBALS['id']])) { + return $response->withStatus(403)->withJson(['errors' => 'Note out of perimeter']); } $note = NoteModel::getById(['select' => ['user_id'], 'id' => $args['id']]); @@ -187,8 +183,8 @@ class NoteController public function delete(Request $request, Response $response, array $args) { - if (!ResController::hasRightByResId(['resId' => [$args['resId']], 'userId' => $GLOBALS['id']])) { - return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); + if (!NoteController::hasRightById(['id' => $args['id'], 'userId' => $GLOBALS['id']])) { + return $response->withStatus(403)->withJson(['errors' => 'Note out of perimeter']); } $note = NoteModel::getById(['select' => ['user_id'], 'id' => $args['id']]); @@ -217,31 +213,6 @@ class NoteController return $response->withStatus(204); } - public static function getEncodedPdfByIds(array $aArgs) - { - ValidatorModel::notEmpty($aArgs, ['ids']); - ValidatorModel::arrayType($aArgs, ['ids']); - - $pdf = new Fpdi('P', 'pt'); - $pdf->setPrintHeader(false); - $pdf->AddPage(); - - foreach ($aArgs['ids'] as $noteId) { - $note = NoteModel::getById(['id' => $noteId, 'select' => ['note_text', 'creation_date', 'user_id']]); - - $user = UserModel::getById(['id' => $note['user_id'], 'select' => ['firstname', 'lastname']]); - $date = new \DateTime($note['creation_date']); - $date = $date->format('d-m-Y H:i'); - - $pdf->Cell(0, 20, "{$user['firstname']} {$user['lastname']} : {$date}", 1, 2, 'C', false); - $pdf->MultiCell(0, 20, $note['note_text'], 1, 'L', false); - $pdf->SetY($pdf->GetY() + 40); - } - $fileContent = $pdf->Output('', 'S'); - - return ['encodedDocument' => base64_encode($fileContent)]; - } - public static function getTemplates(Request $request, Response $response) { $query = $request->getQueryParams(); @@ -270,19 +241,52 @@ class NoteController return $response->withJson(['templates' => $templates]); } + public static function getEncodedPdfByIds(array $aArgs) + { + ValidatorModel::notEmpty($aArgs, ['ids']); + ValidatorModel::arrayType($aArgs, ['ids']); + + $pdf = new Fpdi('P', 'pt'); + $pdf->setPrintHeader(false); + $pdf->AddPage(); + + foreach ($aArgs['ids'] as $noteId) { + $note = NoteModel::getById(['id' => $noteId, 'select' => ['note_text', 'creation_date', 'user_id']]); + + $user = UserModel::getById(['id' => $note['user_id'], 'select' => ['firstname', 'lastname']]); + $date = new \DateTime($note['creation_date']); + $date = $date->format('d-m-Y H:i'); + + $pdf->Cell(0, 20, "{$user['firstname']} {$user['lastname']} : {$date}", 1, 2, 'C', false); + $pdf->MultiCell(0, 20, $note['note_text'], 1, 'L', false); + $pdf->SetY($pdf->GetY() + 40); + } + $fileContent = $pdf->Output('', 'S'); + + return ['encodedDocument' => base64_encode($fileContent)]; + } + public static function hasRightById(array $args) { ValidatorModel::notEmpty($args, ['id', 'userId']); ValidatorModel::intVal($args, ['id', 'userId']); - $note = NoteModel::getById(['select' => ['user_id'], 'id' => $args['id']]); + $note = NoteModel::getById(['select' => ['user_id', 'identifier'], 'id' => $args['id']]); if (empty($note)) { return false; } + if (!ResController::hasRightByResId(['resId' => [$note['identifier']], 'userId' => $args['userId']])) { + return false; + } if ($note['user_id'] == $args['userId']) { return true; } + $noteEntities = NoteEntityModel::get(['select' => [1], 'where' => ['note_id = ?'], 'data' => [$args['id']]]); + if (empty($noteEntities)) { + return true; + } + $user = UserModel::getById(['select' => ['user_id'], 'id' => $args['userId']]); $userEntities = EntityModel::getByLogin(['login' => $user['user_id'], 'select' => ['entity_id']]); $userEntities = array_column($userEntities, 'entity_id'); diff --git a/src/app/resource/controllers/ResController.php b/src/app/resource/controllers/ResController.php index d03ce1cd9ed..c9a8536d41b 100755 --- a/src/app/resource/controllers/ResController.php +++ b/src/app/resource/controllers/ResController.php @@ -762,11 +762,6 @@ class ResController return $response->withJson(['categories' => ResModel::getCategories()]); } - public function getNatures(Request $request, Response $response) - { - return $response->withJson(['natures' => ResModel::getNatures()]); - } - public function isAllowedForCurrentUser(Request $request, Response $response, array $aArgs) { if (!Validator::intVal()->validate($aArgs['resId']) || !ResController::hasRightByResId(['resId' => [$aArgs['resId']], 'userId' => $GLOBALS['id']])) { diff --git a/src/app/resource/controllers/StoreController.php b/src/app/resource/controllers/StoreController.php index 9bd4bd10225..ba30ec8b0fd 100755 --- a/src/app/resource/controllers/StoreController.php +++ b/src/app/resource/controllers/StoreController.php @@ -258,31 +258,6 @@ class StoreController return $formatedData; } - public function checkFileUpload(Request $request, Response $response) - { - $body = $request->getParsedBody(); - - if (!Validator::notEmpty()->validate($body['size'])) { - return $response->withStatus(400)->withJson(['errors' => 'filesize is empty']); - } else if (!Validator::notEmpty()->validate($body['type'])) { - return $response->withStatus(400)->withJson(['errors' => 'no mime type detected']); - } else if (!Validator::notEmpty()->validate($body['extension'])) { - return $response->withStatus(400)->withJson(['errors' => 'this filename has no extension']); - } - - if (!StoreController::isFileAllowed($body)) { - return $response->withStatus(400)->withJson(['errors' => _FILE_NOT_ALLOWED_INFO_1.' "'.$body['extension'].'" '._FILE_NOT_ALLOWED_INFO_2.' "'. $body['type']. '" '._FILE_NOT_ALLOWED_INFO_3]); - } - - $maxFilesizeMo = ini_get('upload_max_filesize'); - $maxFilesizeKo = ini_get('upload_max_filesize')*1024; - - if ($body['size']/1024 > $maxFilesizeKo) { - return $response->withStatus(400)->withJson(['errors' => _MAX_SIZE_UPLOAD_REACHED.' ('.round($maxFilesizeMo).'Mo Max.)']); - } - return $response->withJson(['success']); - } - public static function isFileAllowed(array $args) { ValidatorModel::notEmpty($args, ['extension', 'type']); diff --git a/src/app/signatureBook/controllers/SignatureBookController.php b/src/app/signatureBook/controllers/SignatureBookController.php index 2179e245f65..c813d575ce0 100755 --- a/src/app/signatureBook/controllers/SignatureBookController.php +++ b/src/app/signatureBook/controllers/SignatureBookController.php @@ -183,8 +183,8 @@ class SignatureBookController 'alt_id' => $incomingMail['alt_identifier'], 'title' => $incomingMail['subject'], 'category_id' => $incomingMail['category_id'], - 'viewerLink' => "../../rest/res/{$resId}/content", - 'thumbnailLink' => "rest/res/{$resId}/thumbnail" + 'viewerLink' => "../../rest/resources/{$resId}/content", + 'thumbnailLink' => "rest/resources/{$resId}/thumbnail" ] ]; @@ -215,8 +215,8 @@ class SignatureBookController 'title' => $value['title'], 'format' => $value['format'], 'isConverted' => $isConverted, - 'viewerLink' => "../../rest/res/{$resId}/attachments/{$realId}/content", - 'thumbnailLink' => "rest/res/{$resId}/attachments/{$realId}/thumbnail" + 'viewerLink' => "../../rest/attachments/{$realId}/content", + 'thumbnailLink' => "rest/attachments/{$realId}/thumbnail" ]; } diff --git a/src/frontend/app/actions/send-shipping-action/send-shipping-action.component.html b/src/frontend/app/actions/send-shipping-action/send-shipping-action.component.html index 19e6f40ebd8..bd2f7f35f6b 100644 --- a/src/frontend/app/actions/send-shipping-action/send-shipping-action.component.html +++ b/src/frontend/app/actions/send-shipping-action/send-shipping-action.component.html @@ -97,7 +97,7 @@ </mat-sidenav-content> <mat-sidenav mode="side" fixedTopGap="56" position='end' [opened]="attachList.length > 0" style="width: 50%;"> <div class="pjList"> - <img *ngFor="let attach of attachList" title="{{attach.identifier}} : {{attach.title}}" src="../../rest/res/{{attach.res_id_master}}/attachments/{{attach.res_id!=0 ? attach.res_id : attach.res_id_version}}/thumbnail" /> + <img *ngFor="let attach of attachList" title="{{attach.identifier}} : {{attach.title}}" src="../../rest/attachments/{{attach.res_id!=0 ? attach.res_id : attach.res_id_version}}/thumbnail" /> </div> </mat-sidenav> </mat-sidenav-container> @@ -107,4 +107,4 @@ [disabled]="loading || currentShipping == null || attachList.length == 0" (click)="onSubmit()">{{lang.validate}}</button> <button mat-raised-button mat-button [disabled]="loading" [mat-dialog-close]="">{{lang.cancel}}</button> -</div> \ No newline at end of file +</div> diff --git a/src/frontend/app/actions/view-doc-action/view-doc-action.component.ts b/src/frontend/app/actions/view-doc-action/view-doc-action.component.ts index 8938c2df2e5..77d6a7d8b47 100644 --- a/src/frontend/app/actions/view-doc-action/view-doc-action.component.ts +++ b/src/frontend/app/actions/view-doc-action/view-doc-action.component.ts @@ -21,6 +21,6 @@ export class ViewDocActionComponent implements OnInit { } ngOnInit(): void { - this.docUrl = '../../rest/res/' + this.data.selectedRes[0] + '/content'; + this.docUrl = '../../rest/resources/' + this.data.selectedRes[0] + '/content'; } } diff --git a/src/frontend/app/attachments/attachments-list.component.html b/src/frontend/app/attachments/attachments-list.component.html index 67a5a72b154..5604e93a7ba 100644 --- a/src/frontend/app/attachments/attachments-list.component.html +++ b/src/frontend/app/attachments/attachments-list.component.html @@ -18,7 +18,7 @@ <button mat-menu-item *ngFor="let item of items">{{lang.version}} 1</button> </mat-menu>--> <a mat-button color="primary" class="downloadButton" title="{{lang.downloadOriginalFile}}" - href="../../rest/resources/{{resIds[0]}}/attachments/{{attachment.res_id}}/originalContent" + href="../../rest/attachments/{{attachment.res_id}}/originalContent" target="_blank"> {{attachment.format}} </a> @@ -118,4 +118,4 @@ </mat-accordion> </div> </mat-card> -</ng-container> \ No newline at end of file +</ng-container> diff --git a/src/frontend/app/attachments/attachments-list.component.ts b/src/frontend/app/attachments/attachments-list.component.ts index d4785e8ab36..0c559c2d5f4 100644 --- a/src/frontend/app/attachments/attachments-list.component.ts +++ b/src/frontend/app/attachments/attachments-list.component.ts @@ -33,7 +33,7 @@ export class AttachmentsListComponent implements OnInit { this.mailevaEnabled = data.mailevaEnabled; this.attachments = data.attachments; this.attachments.forEach((element: any) => { - element.thumbnailUrl = '../../rest/res/' + this.resIds[0] + '/attachments/' + element.res_id + '/thumbnail'; + element.thumbnailUrl = '../../rest/attachments/' + element.res_id + '/thumbnail'; }); this.reloadBadgeNotes.emit(`${this.attachments.length}`); this.loading = false; @@ -63,4 +63,4 @@ export class AttachmentsListComponent implements OnInit { this.notify.error(err.error.errors); }); } -} \ No newline at end of file +} diff --git a/src/frontend/app/folder/document-list/folder-document-list.component.ts b/src/frontend/app/folder/document-list/folder-document-list.component.ts index 419e9c91623..f414ed4ed44 100644 --- a/src/frontend/app/folder/document-list/folder-document-list.component.ts +++ b/src/frontend/app/folder/document-list/folder-document-list.component.ts @@ -207,10 +207,10 @@ export class FolderDocumentListComponent implements OnInit { goTo(row: any) { this.filtersListService.filterMode = false; - if (this.docUrl == '../../rest/res/' + row.res_id + '/content' && this.sidenavRight.opened) { + if (this.docUrl == '../../rest/resources/' + row.res_id + '/content' && this.sidenavRight.opened) { this.sidenavRight.close(); } else { - this.docUrl = '../../rest/res/' + row.res_id + '/content'; + this.docUrl = '../../rest/resources/' + row.res_id + '/content'; this.currentChrono = row.alt_identifier; this.innerHtml = this.sanitizer.bypassSecurityTrustHtml( "<iframe style='height:100%;width:100%;' src='" + this.docUrl + "' class='embed-responsive-item'>" + @@ -261,7 +261,7 @@ export class FolderDocumentListComponent implements OnInit { } viewThumbnail(row: any) { - this.thumbnailUrl = '../../rest/res/' + row.res_id + '/thumbnail'; + this.thumbnailUrl = '../../rest/resources/' + row.res_id + '/thumbnail'; $j('#viewThumbnail').show(); $j('#listContent').css({ "overflow": "hidden" }); } diff --git a/src/frontend/app/home/home.component.ts b/src/frontend/app/home/home.component.ts index 7b9ee1793b1..ec9b55e5e0b 100644 --- a/src/frontend/app/home/home.component.ts +++ b/src/frontend/app/home/home.component.ts @@ -82,10 +82,10 @@ export class HomeComponent implements OnInit { } goTo(row:any) { - if (this.docUrl == '../../rest/res/'+row.res_id+'/content' && this.sidenavRight.opened) { + if (this.docUrl == '../../rest/resources/' + row.res_id + '/content' && this.sidenavRight.opened) { this.sidenavRight.close(); } else { - this.docUrl = '../../rest/res/'+row.res_id+'/content'; + this.docUrl = '../../rest/resources/' + row.res_id + '/content'; this.innerHtml = this.sanitizer.bypassSecurityTrustHtml( "<iframe style='height:100%;width:100%;' src='" + this.docUrl + "' class='embed-responsive-item'>" + @@ -95,7 +95,7 @@ export class HomeComponent implements OnInit { } viewThumbnail(row:any) { - this.thumbnailUrl = '../../rest/res/' + row.res_id + '/thumbnail'; + this.thumbnailUrl = '../../rest/resources/' + row.res_id + '/thumbnail'; $j('#viewThumbnail').show(); $j('#listContent').css({"overflow":"hidden"}); } diff --git a/src/frontend/app/list/basket-list.component.ts b/src/frontend/app/list/basket-list.component.ts index 1acd41b8ff8..479006e89b8 100755 --- a/src/frontend/app/list/basket-list.component.ts +++ b/src/frontend/app/list/basket-list.component.ts @@ -207,10 +207,10 @@ export class BasketListComponent implements OnInit { goTo(row: any) { this.filtersListService.filterMode = false; - if (this.docUrl == '../../rest/res/' + row.res_id + '/content' && this.sidenavRight.opened) { + if (this.docUrl == '../../rest/resources/' + row.res_id + '/content' && this.sidenavRight.opened) { this.sidenavRight.close(); } else { - this.docUrl = '../../rest/res/' + row.res_id + '/content'; + this.docUrl = '../../rest/resources/' + row.res_id + '/content'; this.currentChrono = row.alt_identifier; this.innerHtml = this.sanitizer.bypassSecurityTrustHtml( "<iframe style='height:100%;width:100%;' src='" + this.docUrl + "' class='embed-responsive-item'>" + @@ -266,7 +266,7 @@ export class BasketListComponent implements OnInit { } viewThumbnail(row: any) { - this.thumbnailUrl = '../../rest/res/' + row.res_id + '/thumbnail'; + this.thumbnailUrl = '../../rest/resources/' + row.res_id + '/thumbnail'; $j('#viewThumbnail').show(); $j('#listContent').css({ "overflow": "hidden" }); } diff --git a/src/frontend/app/notes/note-editor.component.ts b/src/frontend/app/notes/note-editor.component.ts index 3ee0b0c6af3..b2a28eaa35d 100644 --- a/src/frontend/app/notes/note-editor.component.ts +++ b/src/frontend/app/notes/note-editor.component.ts @@ -30,7 +30,7 @@ export class NoteEditorComponent implements AfterViewInit { addNote() { this.loading = true; - this.http.post("../../rest/resources/" + this.resIds[0] + "/notes", { value: this.content }) + this.http.post("../../rest/notes", { value: this.content, resId: this.resIds[0] }) .subscribe((data: any) => { this.refreshNotes.emit(this.resIds[0]); this.loading = false; @@ -56,7 +56,7 @@ export class NoteEditorComponent implements AfterViewInit { if (this.resIds.length == 1) { params['resId'] = this.resIds[0]; } - this.http.get("../../rest/notes/templates", { params: params }) + this.http.get("../../rest/notesTemplates", { params: params }) .subscribe((data: any) => { this.templatesNote = data['templates']; }); diff --git a/src/frontend/app/notes/notes.component.ts b/src/frontend/app/notes/notes.component.ts index 0aa2eaab643..7cda4fcf4ef 100644 --- a/src/frontend/app/notes/notes.component.ts +++ b/src/frontend/app/notes/notes.component.ts @@ -29,7 +29,7 @@ export class NotesListComponent implements OnInit { this.loading = true; this.http.get("../../rest/resources/" + this.resIds[0] + "/notes") .subscribe((data: any) => { - this.notes = data; + this.notes = data['notes']; this.reloadBadgeNotes.emit(`${this.notes.length}`); this.loading = false; }); diff --git a/src/frontend/app/signature-book.component.html b/src/frontend/app/signature-book.component.html index 7349b1b8298..e12708e5134 100755 --- a/src/frontend/app/signature-book.component.html +++ b/src/frontend/app/signature-book.component.html @@ -93,7 +93,7 @@ <div *ngIf="leftSelectedThumbnail > 0 && signatureBook.documents[leftSelectedThumbnail].format != 'pdf' && !signatureBook.documents[leftSelectedThumbnail].isConverted" [ngStyle]="{'height': showTopLeftPanel ? '79%' : '96%'}" class="visaNoPdfWarning"> <div style="padding-top: 25%;">{{lang.noOverviewAvailable}}<br/><sub>{{lang.pdfVersionFile}} "{{signatureBook.documents[leftSelectedThumbnail].title}}.{{signatureBook.documents[leftSelectedThumbnail].format}}" {{lang.isNotAvailable}}.</sub></div> <div class="visaPjView"> - <a title="{{lang.dlAttachment}}" href="../../rest/resources/{{resId}}/attachments/{{signatureBook.documents[leftSelectedThumbnail].res_id}}/originalContent" target="_blank"> + <a title="{{lang.dlAttachment}}" href="../../rest/attachments/{{signatureBook.documents[leftSelectedThumbnail].res_id}}/originalContent" target="_blank"> <i class="fa fa-download fa-2x"></i> </a> </div> @@ -180,7 +180,7 @@ <div *ngIf="signatureBook.attachments[rightSelectedThumbnail].format != 'pdf' && signatureBook.attachments[rightSelectedThumbnail].status != 'TMP' && !signatureBook.attachments[rightSelectedThumbnail].isConverted" [ngStyle]="{'height': showTopRightPanel ? '79%' : '96%'}" class="visaNoPdfWarning"> <div style="padding-top: 25%;">{{lang.noOverviewAvailable}}<br/><sub>{{lang.pdfVersionFile}} "{{signatureBook.attachments[rightSelectedThumbnail].title}}.{{signatureBook.attachments[rightSelectedThumbnail].format}}" {{lang.isNotAvailable}}.</sub></div> <div class="visaPjView"> - <a title="{{lang.dlAttachment}}" href="../../rest/resources/{{resId}}/attachments/{{signatureBook.attachments[rightSelectedThumbnail].res_id}}/originalContent" target="_blank"> + <a title="{{lang.dlAttachment}}" href="../../rest/attachments/{{signatureBook.attachments[rightSelectedThumbnail].res_id}}/originalContent" target="_blank"> <i class="fa fa-download fa-2x"></i> </a> </div> @@ -257,7 +257,7 @@ <span>{{version.relation}}</span> <span>{{lang.object}} : </span> <span>{{version.title}}</span> - <a style="color:#135F7F" title="{{lang.dlAttachment}}" href="../../rest/resources/{{resId}}/attachments/{{version.resId}}/originalContent" target="_blank"> + <a style="color:#135F7F" title="{{lang.dlAttachment}}" href="../../rest/attachments/{{version.resId}}/originalContent" target="_blank"> <i class="fa fa-download fa-2x"></i> </a> </div> diff --git a/src/frontend/app/signature-book.component.ts b/src/frontend/app/signature-book.component.ts index c8005fdae28..7547df1d4c5 100755 --- a/src/frontend/app/signature-book.component.ts +++ b/src/frontend/app/signature-book.component.ts @@ -415,7 +415,7 @@ export class SignatureBookComponent implements OnInit { this.http.get(path, signature) .subscribe((data : any) => { if (data.status == 0) { - this.rightViewerLink = "../../rest/res/" + this.resId + "/attachments/" + data.new_id + "/content"; + this.rightViewerLink = "../../rest/attachments/" + data.new_id + "/content"; this.signatureBook.attachments[this.rightSelectedThumbnail].viewerLink = this.rightViewerLink; this.signatureBook.attachments[this.rightSelectedThumbnail].status = 'SIGN'; this.signatureBook.attachments[this.rightSelectedThumbnail].idToDl = data.new_id; @@ -462,7 +462,7 @@ export class SignatureBookComponent implements OnInit { this.http.put(this.coreUrl + 'rest/signatureBook/' + resId + '/unsign', {'table' : collId}) .subscribe(() => { - this.rightViewerLink = "../../rest/res/" + this.resId + "/attachments/" + resId + "/content"; + this.rightViewerLink = "../../rest/attachments/" + resId + "/content"; this.signatureBook.attachments[this.rightSelectedThumbnail].viewerLink = this.rightViewerLink; this.signatureBook.attachments[this.rightSelectedThumbnail].status = 'A_TRA'; this.signatureBook.attachments[this.rightSelectedThumbnail].idToDl = resId; -- GitLab