diff --git a/ci/check_releases.sh b/ci/check_releases.sh index de25ed15f4b5c29f232865a490c57f6c1bfd2b4c..48e1ae931b9c3746a03fe15f7931a7449ef91df1 100644 --- a/ci/check_releases.sh +++ b/ci/check_releases.sh @@ -3,7 +3,7 @@ TAG_BASE="2301" EXIST=0 for row in $(curl --header "PRIVATE-TOKEN: $TOKEN_GITLAB" "https://labs.maarch.org/api/v4/projects/$CI_PROJECT_ID/repository/branches?search=2301_releases" | jq -r '.[] | @base64'); do _jq() { - echo ${row} | base64 --decode | jq -r ${1} + echo "${row}" | base64 --decode | jq -r "${1}" } EXIST=$((EXIST + 1)) done @@ -12,28 +12,18 @@ if [ $EXIST == 1 ] then echo "2301_releases already exist, skipping ..." else - echo "2301_releases branch does not exist, creating ..." - - # Create 2301_releases branche - echo "https://labs.maarch.org/api/v4/projects/$CI_PROJECT_ID/repository/branches?branch=2301_releases&ref=main" - - curl --request POST --header "PRIVATE-TOKEN: $TOKEN_GITLAB" "https://labs.maarch.org/api/v4/projects/$CI_PROJECT_ID/repository/branches?branch=2301_releases&ref=main" - - # Create 2301_releases mr - BODY="{\"id\":\"$CI_PROJECT_ID\",\"source_branch\":\"2301_releases\",\"target_branch\":\"main\",\"title\":\"Next tag release\",\"description\":\"\",\"remove_source_branch\":\"true\",\"squash\":\"false\"}" - - curl -v -H "PRIVATE-TOKEN: $TOKEN_GITLAB" -H "Content-Type: application/json" -X POST -d "$BODY" "https://labs.maarch.org/api/v4/projects/$CI_PROJECT_ID/merge_requests" + echo "Fetch all tags..." FIRST_TAG=0 for row in $(curl --header "PRIVATE-TOKEN: $TOKEN_GITLAB" "https://labs.maarch.org/api/v4/projects/$CI_PROJECT_ID/repository/tags?search=^$TAG_BASE" | jq -r '.[] | @base64'); do _jq() { - echo ${row} | base64 --decode | jq -r ${1} + echo "${row}" | base64 --decode | jq -r "${1}" } NAME=$(_jq '.name') - IS_TMA=$(echo $NAME | grep -o '[.]*_TMA[.]*') + IS_TMA=$(echo "$NAME" | grep -o '[.]*_TMA[.]*') if [[ -n $IS_TMA ]]; then echo "TMA tag branch : $NAME ! Skipping..." @@ -50,10 +40,10 @@ else NEXT_TAG="$TAG_BASE.0.0" NEXT_NEXT_TAG="$TAG_BASE.0.1" else - SORTED_TAGS=($(echo ${TAGS[*]} | tr " " "\n" | sort -Vr)) - LATEST_TAG=$(echo ${SORTED_TAGS[0]}) + SORTED_TAGS=($(echo "${TAGS[*]}" | tr " " "\n" | sort -Vr)) + LATEST_TAG=$(echo "${SORTED_TAGS[0]}") - structures=$(echo $LATEST_TAG | tr "." "\n") + structures=$(echo "$LATEST_TAG" | tr "." "\n") IT=1 for item in $structures; do @@ -78,25 +68,38 @@ else NEXT_TAG="$BRANCH_TAG_VERSION.$MAJOR_TAG_VERSION.$VERSION" NEXT_NEXT_TAG="$BRANCH_TAG_VERSION.$MAJOR_TAG_VERSION.$VERSION" fi + + echo "2301_releases branch does not exist, creating ..." + + # Create 2301_releases branche + echo "https://labs.maarch.org/api/v4/projects/$CI_PROJECT_ID/repository/branches?branch=2301_releases&ref=main" + + curl --request POST --header "PRIVATE-TOKEN: $TOKEN_GITLAB" "https://labs.maarch.org/api/v4/projects/$CI_PROJECT_ID/repository/branches?branch=2301_releases&ref=main" + + # Create 2301_releases mr + BODY="{\"id\":\"$CI_PROJECT_ID\",\"source_branch\":\"2301_releases\",\"target_branch\":\"main\",\"title\":\"Next tag release\",\"description\":\"\",\"remove_source_branch\":\"true\",\"squash\":\"false\"}" + + curl -v -H "PRIVATE-TOKEN: $TOKEN_GITLAB" -H "Content-Type: application/json" -X POST -d "$BODY" "https://labs.maarch.org/api/v4/projects/$CI_PROJECT_ID/merge_requests" + # Update files version git config --global user.email "$GITLAB_USER_EMAIL" && git config --global user.name "$GITLAB_USER_NAME" && git config core.fileMode false - git remote set-url origin "https://gitlab-ci-token:${TOKEN_GITLAB}@${GITLAB_URL}/${CI_PROJECT_PATH}.git" - git fetch git branch -D $TAG_BASE"_releases" git pull origin $TAG_BASE"_releases" git checkout $TAG_BASE"_releases" - cp package.json tmp_package.json - jq -r ".version |= \"$NEXT_NEXT_TAG\"" tmp_package.json >package.json + # Update app version + cp package.json tmp_package.json + cp package-lock.json tmp_package-lock.json - rm tmp_package.json + jq ".version = \"$NEXT_NEXT_TAG\"" tmp_package.json > package.json + jq ".version = \"$NEXT_NEXT_TAG\"" tmp_package-lock.json > package-lock.json - git add -f package.json + rm tmp_package.json tmp_package-lock.json + git add -f package.json package-lock.json git commit -m "Update next tag version files : $NEXT_NEXT_TAG" - git push fi diff --git a/ci/new_minor_tag.sh b/ci/new_minor_tag.sh index 2b038a5678fdd239918b634de3e5d6c69ebb0108..f367e0461665976a01996a2a20e833cc37b936d5 100644 --- a/ci/new_minor_tag.sh +++ b/ci/new_minor_tag.sh @@ -158,6 +158,8 @@ if [ $FIRST_TAG == 0 ]; then git pull origin $RELEASE_BRANCH git checkout $RELEASE_BRANCH + touch $FINAL_LOG + TAGS_COMP="$LATEST_TAG..$NEXT_TAG" REF_UPDATED=$(git log $TAGS_COMP --pretty=format:'%s' --grep='Update referential' --all-match) diff --git a/package.json b/package.json index 376189807e76453fa62e390697244648989ac6de..44d5f58207c617e7af7e602242095c004ae2299a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "parapheur", - "version": "2301.0.0", + "version": "2301.0.2", "description": "Annoter ou Signer vos documents sur votre tablette", "homepage": "https://labs.maarch.org/maarch/MaarchParapheur", "engines": { diff --git a/rest/index.php b/rest/index.php index 6fc30fccd47df48c65761133f524da4bd02eb161..a5263adfc8b765f6c54db5808a7ed99012b01ef2 100755 --- a/rest/index.php +++ b/rest/index.php @@ -94,7 +94,8 @@ $app->patch('/configurations/{id}', \Configuration\controllers\ConfigurationCont $app->delete('/configurations/{id}', \Configuration\controllers\ConfigurationController::class . ':delete'); $app->get('/configurations/{id}/connection', \Configuration\controllers\ConfigurationController::class . ':testConnection'); -// CommitInformation +// GitInformation +$app->get('/repoInformation', \SrcCore\controllers\AuthenticationController::class . ':getGitRepoInformation'); $app->get('/commitInformation', \SrcCore\controllers\AuthenticationController::class . ':getGitCommitInformation'); //Connectors diff --git a/src/app/attachment/controllers/AttachmentController.php b/src/app/attachment/controllers/AttachmentController.php index 2b5d4f515613139434070186e22d023dc25fa0f7..a24ed157ecd65e1b92b487e76dda4f37ccac7223 100755 --- a/src/app/attachment/controllers/AttachmentController.php +++ b/src/app/attachment/controllers/AttachmentController.php @@ -130,7 +130,8 @@ class AttachmentController ]); $configPath = CoreConfigModel::getConfigPath(); - exec("php src/app/convert/scripts/ThumbnailScript.php '{$configPath}' {$id} 'attachment' '{$GLOBALS['id']}' > /dev/null &"); + $libDir = CoreConfigModel::getLibrariesDirectory(); + exec("php src/app/convert/scripts/ThumbnailScript.php '{$configPath}' '{$libDir}' {$id} 'attachment' '{$GLOBALS['id']}' > /dev/null &"); return ['id' => $id]; } @@ -160,7 +161,8 @@ class AttachmentController $pathToThumbnail = $docserver['path'] . $adr[0]['path'] . $adr[0]['filename']; if (!is_file($pathToThumbnail) || !is_readable($pathToThumbnail)) { $configPath = CoreConfigModel::getConfigPath(); - exec("php src/app/convert/scripts/ThumbnailScript.php '{$configPath}' {$args['id']} 'attachment' '{$GLOBALS['id']}' > /dev/null"); + $libDir = CoreConfigModel::getLibrariesDirectory(); + exec("php src/app/convert/scripts/ThumbnailScript.php '{$configPath}' '{$libDir}' {$args['id']} 'attachment' '{$GLOBALS['id']}' > /dev/null"); $adr = AdrModel::getAttachmentsAdr([ 'select' => ['path', 'filename'], 'where' => ['attachment_id = ?', 'type = ?'], diff --git a/src/app/convert/scripts/ThumbnailScript.php b/src/app/convert/scripts/ThumbnailScript.php index fe9b0a22da4a130abefb2b92f347ffad0964590a..0555f20f75b20ed274f2463b7aedb0c4f89d856d 100644 --- a/src/app/convert/scripts/ThumbnailScript.php +++ b/src/app/convert/scripts/ThumbnailScript.php @@ -22,12 +22,13 @@ use History\controllers\HistoryController; use SrcCore\models\DatabasePDO; //configPath = $argv[1]; -//id = $argv[2]; -//type = $argv[3]; -//userId = $argv[4]; -//page = $argv[5]; Optionnal +//libDir = $argv[2]; +//id = $argv[3]; +//type = $argv[4]; +//userId = $argv[5]; +//page = $argv[6]; Optionnal -ThumbnailScript::convert(['configPath' => $argv[1], 'id' => $argv[2], 'type' => $argv[3], 'userId' => $argv[4], 'page' => $argv[5] ?? null]); +ThumbnailScript::convert(['configPath' => $argv[1], 'libDir' => $argv[2], 'id' => $argv[3], 'type' => $argv[4], 'userId' => $argv[5], 'page' => $argv[6] ?? null]); class ThumbnailScript { @@ -37,6 +38,8 @@ class ThumbnailScript new DatabasePDO(['configPath' => $args['configPath']]); $GLOBALS['id'] = $args['userId']; + $_SERVER['CONFIG_DIR'] = $args['configPath']; + $_SERVER['LIBRARIES_DIR'] = $args['libDir']; $document = DocumentModel::getById(['select' => ['status'], 'id' => $args['id']]); DocumentModel::update([ diff --git a/src/app/document/controllers/DocumentController.php b/src/app/document/controllers/DocumentController.php index d10f865ee7cc6b15b539c3a07c1794c2ea72e890..095559daee9f11f5fa754677eb344305cfcd2bb4 100644 --- a/src/app/document/controllers/DocumentController.php +++ b/src/app/document/controllers/DocumentController.php @@ -151,7 +151,8 @@ class DocumentController ]); if (empty($adr[0]['count']) && $document['status'] != 'CONVERTING') { $configPath = CoreConfigModel::getConfigPath(); - exec("php src/app/convert/scripts/ThumbnailScript.php '{$configPath}' {$args['id']} 'document' '{$GLOBALS['id']}' > /dev/null"); + $libDir = CoreConfigModel::getLibrariesDirectory(); + exec("php src/app/convert/scripts/ThumbnailScript.php '{$configPath}' '{$libDir}' {$args['id']} 'document' '{$GLOBALS['id']}' > /dev/null"); $adr[0]['count'] = 1; } @@ -823,7 +824,8 @@ class DocumentController $configPath = CoreConfigModel::getConfigPath(); - exec("php src/app/convert/scripts/ThumbnailScript.php '{$configPath}' {$id} 'document' '{$GLOBALS['id']}' > /dev/null &"); + $libDir = CoreConfigModel::getLibrariesDirectory(); + exec("php src/app/convert/scripts/ThumbnailScript.php '{$configPath}' '{$libDir}' {$id} 'document' '{$GLOBALS['id']}' > /dev/null &"); return $response->withJson(['id' => $id]); } @@ -1023,8 +1025,9 @@ class DocumentController } $configPath = CoreConfigModel::getConfigPath(); + $libDir = CoreConfigModel::getLibrariesDirectory(); foreach ($affectedPages as $page) { - exec("php src/app/convert/scripts/ThumbnailScript.php '{$configPath}' {$args['id']} 'document' '{$GLOBALS['id']}' {$page} > /dev/null &"); + exec("php src/app/convert/scripts/ThumbnailScript.php '{$configPath}' '{$libDir}' {$args['id']} 'document' '{$GLOBALS['id']}' {$page} > /dev/null &"); } } } @@ -1261,7 +1264,8 @@ class DocumentController $pathToThumbnail = $docserver['path'] . ($adr[0]['path'] ?? null) . ($adr[0]['filename'] ?? null); if (!is_file($pathToThumbnail) || !is_readable($pathToThumbnail)) { $configPath = CoreConfigModel::getConfigPath(); - exec("php src/app/convert/scripts/ThumbnailScript.php '{$configPath}' {$args['id']} 'document' '{$GLOBALS['id']}' {$args['page']} > /dev/null"); + $libDir = CoreConfigModel::getLibrariesDirectory(); + exec("php src/app/convert/scripts/ThumbnailScript.php '{$configPath}' '{$libDir}' {$args['id']} 'document' '{$GLOBALS['id']}' {$args['page']} > /dev/null"); $adr = AdrModel::getDocumentsAdr([ 'select' => ['path', 'filename'], 'where' => ['main_document_id = ?', 'type = ?'], diff --git a/src/app/document/controllers/WatermarkController.php b/src/app/document/controllers/WatermarkController.php index bc040493552abb2ce43a6119307114a04339bb97..d3bc1aa25b41dbc0344c024f30641cdaed8aa2cc 100644 --- a/src/app/document/controllers/WatermarkController.php +++ b/src/app/document/controllers/WatermarkController.php @@ -60,10 +60,33 @@ class WatermarkController require_once($libPath); } + $fileContent = null; try { + $flattenedFile = null; $watermarkFile = CoreConfigModel::getTmpPath() . "tmp_file_{$GLOBALS['id']}_" .rand(). "_watermark.pdf"; file_put_contents($watermarkFile, base64_decode($args['encodedDocument'])); + $isSigned = WatermarkController::checkDocumentSignatureField(['encodedDocument' => $args['encodedDocument']]); + if(!empty($isSigned)) { + return $fileContent; + } + + $libPath = CoreConfigModel::getSetaPdfFormFillerLibrary(); + if (!empty($libPath)) { + require_once($libPath); + + $flattenedFile = CoreConfigModel::getTmpPath() . "tmp_file_{$GLOBALS['id']}_" .rand(). "_watermark.pdf"; + $writer = new \SetaPDF_Core_Writer_File($flattenedFile); + $document = \SetaPDF_Core_Document::loadByFilename($watermarkFile, $writer); + + $formFiller = new \SetaPDF_FormFiller($document); + $fields = $formFiller->getFields(); + $fields->flatten(); + $document->save()->finish(); + + $watermarkFile = $flattenedFile; + } + $pdf = new Fpdi('P', 'pt'); $nbPages = $pdf->setSourceFile($watermarkFile); $pdf->setPrintHeader(false); @@ -79,10 +102,46 @@ class WatermarkController $pdf->Text(8, $watermark['posY'], $text, false, false, true, 0, 0, $watermark['align']); // Position X = 8 } $fileContent = $pdf->Output('', 'S'); + + if (!empty($flattenedFile) && is_file($flattenedFile)) { + unlink($flattenedFile); + } } catch (\Exception $e) { $fileContent = null; } return $fileContent; } + + public static function checkDocumentSignatureField(array $args) + { + $libPath = CoreConfigModel::getSetaPdfFormFillerLibrary(); + $alreadySigned = false; + + if (!empty($libPath) && is_file($libPath)) { + require_once($libPath); + + $targetFile = CoreConfigModel::getTmpPath() . "tmp_file_{$GLOBALS['id']}_" . rand() . "_target_watermark.pdf"; + file_put_contents($targetFile, base64_decode($args['encodedDocument'])); + $document = \SetaPDF_Core_Document::loadByFilename($targetFile); + + $formFiller = new \SetaPDF_FormFiller($document); + $fields = $formFiller->getFields(); + $allFields = $fields->getAll(); + + foreach ($allFields as $fieldValue) { + if ($fieldValue instanceof \SetaPDF_FormFiller_Field_Signature) { + $alreadySigned = true; + break; + } + } + // Release objects to free memory and cycled references. + // After calling this method the instance of $document is unusable! + $document->cleanUp(); + unlink($targetFile); + } + + return $alreadySigned; + } + } diff --git a/src/app/user/controllers/SignatureController.php b/src/app/user/controllers/SignatureController.php index 851b218e3b8c5b366b1dbbe92416cf9095d8f091..b342b88f410457c192c6b4c4aa7dd1711c104473 100755 --- a/src/app/user/controllers/SignatureController.php +++ b/src/app/user/controllers/SignatureController.php @@ -223,7 +223,7 @@ class SignatureController return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']); } - if (!UserController::hasRightByUserId(['activeUserId' => $GLOBALS['id'], 'targetUserId' => $args['id']]) && $GLOBALS['id'] !== $args['id']) { + if (!UserController::hasRightByUserId(['activeUserId' => $GLOBALS['id'], 'targetUserId' => $args['id']]) && $GLOBALS['id'] !== intval($args['id'])) { return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']); } diff --git a/src/app/user/controllers/UserController.php b/src/app/user/controllers/UserController.php index ae060a9498c0db49328a9440e8c23fa9d756cdc5..e9b83b6b05de1df51dd2e55e8e9d01c33d802dce 100755 --- a/src/app/user/controllers/UserController.php +++ b/src/app/user/controllers/UserController.php @@ -118,8 +118,10 @@ class UserController if ($GLOBALS['id'] != $args['id']) { $groupsIds = array_values(array_intersect($groupsIds, array_column(UserController::getManageableGroups(['userId' => $GLOBALS['id']]), 'id'))); } - $groups = GroupModel::get(['select' => ['label', 'id'], 'where' => ['id in (?)'], 'data' => [$groupsIds]]); - $user['groups'] = $groups; + if(!empty($groupsIds)){ + $groups = GroupModel::get(['select' => ['label', 'id'], 'where' => ['id in (?)'], 'data' => [$groupsIds]]); + $user['groups'] = $groups; + } } else { $user = UserModel::getById(['select' => ['id', 'firstname', 'lastname', 'email', 'phone', 'substitute'], 'id' => $args['id']]); } @@ -224,7 +226,7 @@ class UserController if (!Validator::intVal()->notEmpty()->validate($args['id'])) { return $response->withStatus(400)->withJson(['errors' => 'Route id is not an integer']); } - + $connection = ConfigurationModel::getConnection(); if (($GLOBALS['id'] != $args['id'] || $connection != 'default') && !UserController::hasRightByUserId(['activeUserId' => $GLOBALS['id'], 'targetUserId' => $args['id']])) { return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']); @@ -255,7 +257,7 @@ class UserController 'firstname' => $body['firstname'], 'lastname' => $body['lastname'], 'email' => $body['email'], - 'phone' => $body['phone'] ?? null, + 'phone' => $body['phone'] ?? null, 'signature_modes' => [] ]; diff --git a/src/app/workflow/controllers/FastOTPController.php b/src/app/workflow/controllers/FastOTPController.php index 4578b6a44a0dabc372d4f6e010061c80db342466..d0509478942fa927575ff3566e1e1ce6a4f8187c 100644 --- a/src/app/workflow/controllers/FastOTPController.php +++ b/src/app/workflow/controllers/FastOTPController.php @@ -137,7 +137,8 @@ class FastOTPController 'data' => [$documentId, 'TNL%'] ]); $configPath = CoreConfigModel::getConfigPath(); - exec("php src/app/convert/scripts/ThumbnailScript.php '{$configPath}' {$documentId} 'document' 0 > /dev/null &"); + $libDir = CoreConfigModel::getLibrariesDirectory(); + exec("php src/app/convert/scripts/ThumbnailScript.php '{$configPath}' '{$libDir}' {$documentId} 'document' 0 > /dev/null &"); } elseif (!empty($fastStatus) && $fastStatus == 'REFUSED') { diff --git a/src/app/workflow/controllers/YousignController.php b/src/app/workflow/controllers/YousignController.php index d19e98a1f0ac76cbe2f3b26418e37d1288947baf..0e88c4a4816a28b27fc19f078c218604b1bca07b 100755 --- a/src/app/workflow/controllers/YousignController.php +++ b/src/app/workflow/controllers/YousignController.php @@ -266,7 +266,8 @@ class YousignController 'data' => [$args['id'], 'TNL%'] ]); $configPath = CoreConfigModel::getConfigPath(); - exec("php src/app/convert/scripts/ThumbnailScript.php '{$configPath}' {$args['id']} 'document' 0 > /dev/null &"); + $libDir = CoreConfigModel::getLibrariesDirectory(); + exec("php src/app/convert/scripts/ThumbnailScript.php '{$configPath}' '{$libDir}' {$args['id']} 'document' 0 > /dev/null &"); } $GLOBALS['webhook'] = 'yousign webhook'; diff --git a/src/core/controllers/AuthenticationController.php b/src/core/controllers/AuthenticationController.php index a8256349f12a936c9df43997c74a1de3b9d260ee..e2a2a8c01230f35d078c0ab3ff6210c634c47886 100755 --- a/src/core/controllers/AuthenticationController.php +++ b/src/core/controllers/AuthenticationController.php @@ -556,6 +556,29 @@ class AuthenticationController return true; } + public function getGitRepoInformation(Request $request, Response $response) + { + $url = null; + + if (file_exists('package.json')) { + $license = json_decode(file_get_contents('package.json'), true); + + if (!empty($license['license'])) { + switch (strtolower($license['license'])) { + case 'gpl-3.0': + $url = 'https://labs.maarch.org/maarch/MaarchParapheur'; + break; + case 'maarch': + $url = 'https://labs.maarch.org/maarch/MaarchParapheurPro'; + break; + default: + break; + } + } + } + return $response->withJson(['url' => $url]); + } + public function getGitCommitInformation(Request $request, Response $response) { if (!file_exists('.git/HEAD')) { @@ -567,8 +590,14 @@ class AuthenticationController if ($head === false) { return $response->withJson(['hash' => null]); } - preg_match('#^ref:(.+)$#', $head, $matches); - $currentHead = trim($matches[1]); + + if (preg_match('#^ref:(.+)$#', $head, $matches)) { + // The HEAD file contains a reference to a branch + $currentHead = trim($matches[1]); + } else { + // The HEAD file contains a hash + return $response->withJson(['hash' => trim($head)]); + } if (empty($currentHead)) { return $response->withJson(['hash' => null]); diff --git a/src/frontend/app/home/aboutUs/about-us.component.html b/src/frontend/app/home/aboutUs/about-us.component.html index b057b38f2f082873103fa3315a9e6ad5a02368f4..03cfee63854f21e562373a59624b5d38d9dfcf2c 100644 --- a/src/frontend/app/home/aboutUs/about-us.component.html +++ b/src/frontend/app/home/aboutUs/about-us.component.html @@ -15,7 +15,7 @@ <ion-col size="8"> <ion-card-header> <ion-card-title class="appVersion">Maarch Parapheur {{applicationVersion}}</ion-card-title> - <ion-card-subtitle>Version: <a target="blank" href="https://labs.maarch.org/maarch/MaarchParapheur/commit/{{commitHash}}">{{commitHash}}</a></ion-card-subtitle> + <ion-card-subtitle>Version: <a target="blank" href="{{repoUrl}}/commit/{{commitHash}}">{{commitHash}}</a></ion-card-subtitle> </ion-card-header> <ion-card-content style="margin-bottom: -15px;"> <ion-item lines="none" style="font-style: italic;"> diff --git a/src/frontend/app/home/aboutUs/about-us.component.ts b/src/frontend/app/home/aboutUs/about-us.component.ts index 0a697dc415da5e634f9a61943f5a8334df978d24..96fbf1b3a7e82511d9118bd87d2f037f5d9f38cb 100644 --- a/src/frontend/app/home/aboutUs/about-us.component.ts +++ b/src/frontend/app/home/aboutUs/about-us.component.ts @@ -20,6 +20,7 @@ export class AboutUsComponent implements OnInit { loading: boolean = false; applicationVersion: string; currentYear: number; + repoUrl: string = this.translate.instant('lang.undefined'); commitHash: string = this.translate.instant('lang.undefined'); license: string = ''; xeliansLogo: any; @@ -78,6 +79,7 @@ export class AboutUsComponent implements OnInit { this.license = environment.LICENSE; this.currentYear = new Date().getFullYear(); await this.loadCommitInformation(); + await this.getGitRepoLink(); this.loading = false; } @@ -95,4 +97,19 @@ export class AboutUsComponent implements OnInit { ).subscribe(); }); } + + getGitRepoLink() { + return new Promise((resolve) => { + this.http.get('../rest/repoInformation').pipe( + tap((data: any) => { + this.repoUrl = data.url !== null ? data.url : this.translate.instant('lang.undefined'); + resolve(true); + }), + catchError((err: any) => { + this.notify.handleErrors(err); + return of(false); + }) + ).subscribe(); + }); + } } diff --git a/src/frontend/app/profile/profile.component.ts b/src/frontend/app/profile/profile.component.ts index ae0f5d42c7f2f59f1284c4c55b3f64d8bcda285a..b3569833c0f9ded3b2295717381e81d627d8334a 100644 --- a/src/frontend/app/profile/profile.component.ts +++ b/src/frontend/app/profile/profile.component.ts @@ -457,11 +457,16 @@ export class ProfileComponent implements OnInit { } toggleSignature(i: number) { - this.http.patch('../rest/users/' + this.authService.user.id + '/signatures/' + this.signaturesService.signaturesList[i].id + '/substituted', { 'substituted': !this.signaturesService.signaturesList[i].substituted }) - .subscribe(() => { + this.http.patch('../rest/users/' + this.authService.user.id + '/signatures/' + this.signaturesService.signaturesList[i].id + '/substituted', { 'substituted': !this.signaturesService.signaturesList[i].substituted }).pipe( + tap(() => { this.signaturesService.signaturesList[i].substituted = !this.signaturesService.signaturesList[i].substituted; this.notificationService.success('lang.modificationSaved'); - }); + }), + catchError((err: any) => { + this.notificationService.handleErrors(err); + return of(false); + }) + ).subscribe(); } getNotifications() { diff --git a/src/frontend/app/search/search.component.html b/src/frontend/app/search/search.component.html index f49702a6962928107f025b8316121f1c71e01d93..11cbc4ed9208816c12b587ee7df3183748d6c954 100644 --- a/src/frontend/app/search/search.component.html +++ b/src/frontend/app/search/search.component.html @@ -35,7 +35,7 @@ <ion-icon name="swap-horizontal-outline"></ion-icon> <ion-label>{{ item.label | translate}}</ion-label> <ion-icon name="close-circle"></ion-icon> - + </ion-chip> </div> <div *ngIf="currentFilter.id === 'workflowUsers' && currentFilter.val.length > 0"> @@ -149,7 +149,7 @@ {{'lang.download' | translate}} </ion-item-option> <ion-item-option *ngIf="element.status !== 'HARD_DEL'" color="primary" - [disabled]="!isValidPrivilege()" (click)="openActions(element)"> + [disabled]="!isValidPrivilege(element)" (click)="openActions(element)"> <ion-icon slot="bottom" name="settings-sharp"></ion-icon> {{'lang.actions' | translate}} </ion-item-option> @@ -210,4 +210,4 @@ </ion-button> </div> </ion-footer> -</ng-template> \ No newline at end of file +</ng-template> diff --git a/src/frontend/app/search/search.component.ts b/src/frontend/app/search/search.component.ts index bbf4444e379bd69d498cb8a2307c6a2d3c51ba9b..150bdb0f22bf648c9c86f02b7190284b5badaf45 100644 --- a/src/frontend/app/search/search.component.ts +++ b/src/frontend/app/search/search.component.ts @@ -595,8 +595,8 @@ export class SearchComponent implements OnInit { return ''; } - isValidPrivilege(): boolean { + isValidPrivilege(element: any): boolean { const privileges: string [] = this.authService.user.appPrivileges?.map((item: any) => item.id); - return privileges.indexOf('indexation') > -1 && privileges.indexOf('manage_documents') > -1; + return (element.typist === this.authService.user.id) || (privileges.indexOf('indexation') > -1 && privileges.indexOf('manage_documents') > -1); } }