diff --git a/src/app/contentManagement/controllers/CollaboraOnlineController.php b/src/app/contentManagement/controllers/CollaboraOnlineController.php index b00dce26a8dc7e9336ade5c9cdebce4be86f9269..ca87b90fd7d9cd5e8792fe341cda56872043c8f0 100644 --- a/src/app/contentManagement/controllers/CollaboraOnlineController.php +++ b/src/app/contentManagement/controllers/CollaboraOnlineController.php @@ -55,7 +55,6 @@ class CollaboraOnlineController $document = CollaboraOnlineController::getDocument([ 'id' => $args['id'], 'type' => $tokenCheckResult['type'], - 'mode' => $tokenCheckResult['mode'], 'format' => $tokenCheckResult['format'] ]); @@ -77,14 +76,14 @@ class CollaboraOnlineController return $response->withStatus(404)->withJson(['errors' => 'Document not found on docserver']); } - if ($tokenCheckResult['mode'] == 'edition' && ($tokenCheckResult['type'] == 'resource' || $tokenCheckResult['type'] == 'attachment')) { + if ($tokenCheckResult['type'] == 'resourceModification' || $tokenCheckResult['type'] == 'attachmentModification') { $docserverType = DocserverTypeModel::getById(['id' => $docserver['docserver_type_id'], 'select' => ['fingerprint_mode']]); $fingerprint = StoreController::getFingerPrint(['filePath' => $pathToDocument, 'mode' => $docserverType['fingerprint_mode']]); - if (empty($convertedDocument) && empty($document['fingerprint']) && $tokenCheckResult['type'] == 'resource') { + if (empty($convertedDocument) && empty($document['fingerprint']) && $tokenCheckResult['type'] == 'resourceModification') { ResModel::update(['set' => ['fingerprint' => $fingerprint], 'where' => ['res_id = ?'], 'data' => [$args['id']]]); $document['fingerprint'] = $fingerprint; - } else if (empty($convertedDocument) && empty($document['fingerprint']) && $tokenCheckResult['type'] == 'attachment') { + } else if (empty($convertedDocument) && empty($document['fingerprint']) && $tokenCheckResult['type'] == 'attachmentModification') { AttachmentModel::update(['set' => ['fingerprint' => $fingerprint], 'where' => ['res_id = ?'], 'data' => [$args['id']]]); $document['fingerprint'] = $fingerprint; } @@ -94,16 +93,33 @@ class CollaboraOnlineController } } - $fileContent = file_get_contents($pathToDocument); - if ($fileContent === false) { - return $response->withStatus(404)->withJson(['errors' => 'Document not found on docserver']); + if ($tokenCheckResult['type'] == 'resourceCreation' || $tokenCheckResult['type'] == 'attachmentCreation') { + $dataToMerge = ['userId' => $GLOBALS['id']]; + if (!empty($tokenCheckResult['data']) && is_array($tokenCheckResult['data'])) { + $dataToMerge = array_merge($dataToMerge, $tokenCheckResult['data']); + } + + $mergedDocument = MergeController::mergeDocument([ + 'path' => $pathToDocument, + 'data' => $dataToMerge + ]); + $content = $mergedDocument['encodedDocument']; + $fileContent = base64_decode($content); + } else { + $fileContent = file_get_contents($pathToDocument); + if ($fileContent === false) { + return $response->withStatus(404)->withJson(['errors' => 'Document not found']); + } + + $content = base64_encode($fileContent); + $fileContent = base64_decode($content); } $finfo = new \finfo(FILEINFO_MIME_TYPE); $mimeType = $finfo->buffer($fileContent); $pathInfo = pathinfo($pathToDocument); - if ($tokenCheckResult['mode'] == 'encoded') { + if ($tokenCheckResult['type'] == 'templateEncoded') { unlink($document['path'] . $document['filename']); } @@ -128,7 +144,6 @@ class CollaboraOnlineController $document = CollaboraOnlineController::getDocument([ 'id' => $args['id'], 'type' => $tokenCheckResult['type'], - 'mode' => $tokenCheckResult['mode'], 'format' => $tokenCheckResult['format'] ]); @@ -182,7 +197,6 @@ class CollaboraOnlineController $document = CollaboraOnlineController::getDocument([ 'id' => $args['id'], 'type' => $tokenCheckResult['type'], - 'mode' => $tokenCheckResult['mode'], 'format' => $tokenCheckResult['format'] ]); @@ -194,7 +208,7 @@ class CollaboraOnlineController $extension = pathinfo($document['filename'], PATHINFO_EXTENSION); $tmpPath = CoreConfigModel::getTmpPath(); - $filename = "collabora_{$GLOBALS['id']}_{$tokenCheckResult['type']}_{$tokenCheckResult['mode']}_{$args['id']}.{$extension}"; + $filename = "collabora_{$GLOBALS['id']}_{$tokenCheckResult['type']}_{$args['id']}.{$extension}"; $put = file_put_contents($tmpPath . $filename, $fileContent); if ($put === false) { @@ -220,7 +234,6 @@ class CollaboraOnlineController $document = CollaboraOnlineController::getDocument([ 'id' => $tokenCheckResult['resId'], 'type' => $tokenCheckResult['type'], - 'mode' => $tokenCheckResult['mode'], 'format' => $tokenCheckResult['format'] ]); if (!empty($document['errors'])) { @@ -228,7 +241,7 @@ class CollaboraOnlineController } $extension = pathinfo($document['filename'], PATHINFO_EXTENSION); - $filename = "collabora_{$GLOBALS['id']}_{$tokenCheckResult['type']}_{$tokenCheckResult['mode']}_{$tokenCheckResult['resId']}.{$extension}"; + $filename = "collabora_{$GLOBALS['id']}_{$tokenCheckResult['type']}_{$tokenCheckResult['resId']}.{$extension}"; $tmpPath = CoreConfigModel::getTmpPath(); $pathToDocument = $tmpPath . $filename; @@ -236,26 +249,13 @@ class CollaboraOnlineController return $response->withStatus(404)->withJson(['errors' => 'Document not found']); } - if ($tokenCheckResult['mode'] == 'creation' && ($tokenCheckResult['type'] == 'resource' || $tokenCheckResult['type'] == 'attachment')) { - $dataToMerge = ['userId' => $GLOBALS['id']]; - if (!empty($body['data']) && is_array($body['data'])) { - $dataToMerge = array_merge($dataToMerge, $body['data']); - } - - $mergedDocument = MergeController::mergeDocument([ - 'path' => $pathToDocument, - 'data' => $dataToMerge - ]); - $content = $mergedDocument['encodedDocument']; - } else { - $fileContent = file_get_contents($pathToDocument); - if ($fileContent === false) { - return $response->withStatus(404)->withJson(['errors' => 'Document not found']); - } - - $content = base64_encode($fileContent); + $fileContent = file_get_contents($pathToDocument); + if ($fileContent === false) { + return $response->withStatus(404)->withJson(['errors' => 'Document not found']); } + $content = base64_encode($fileContent); + return $response->withJson(['content' => $content, 'format' => $extension]); } @@ -275,7 +275,6 @@ class CollaboraOnlineController $document = CollaboraOnlineController::getDocument([ 'id' => $tokenCheckResult['resId'], 'type' => $tokenCheckResult['type'], - 'mode' => $tokenCheckResult['mode'], 'format' => $tokenCheckResult['format'] ]); if (!empty($document['errors'])) { @@ -283,7 +282,7 @@ class CollaboraOnlineController } $extension = pathinfo($document['filename'], PATHINFO_EXTENSION); - $filename = "collabora_{$GLOBALS['id']}_{$tokenCheckResult['type']}_{$tokenCheckResult['mode']}_{$tokenCheckResult['resId']}.{$extension}"; + $filename = "collabora_{$GLOBALS['id']}_{$tokenCheckResult['type']}_{$tokenCheckResult['resId']}.{$extension}"; $tmpPath = CoreConfigModel::getTmpPath(); $pathToDocument = $tmpPath . $filename; @@ -332,20 +331,22 @@ class CollaboraOnlineController if (!Validator::stringType()->notEmpty()->validate($body['type'])) { return $response->withStatus(400)->withJson(['errors' => 'Body type is empty or not a string']); } - if (!Validator::stringType()->notEmpty()->validate($body['mode'])) { - return $response->withStatus(400)->withJson(['errors' => 'Body mode is empty or not a string']); - } if (!empty($body['format']) && !Validator::stringType()->validate($body['format'])) { return $response->withStatus(400)->withJson(['errors' => 'Body format is not a string']); } if (!empty($body['path']) && !Validator::stringType()->validate($body['path'])) { return $response->withStatus(400)->withJson(['errors' => 'Body path is not a string']); } + if (!empty($body['data']) && !Validator::arrayType()->validate($body['data'])) { + return $response->withStatus(400)->withJson(['errors' => 'Body data is not a string']); + } + if (!empty($body['lang']) && !Validator::stringType()->validate($body['lang'])) { + return $response->withStatus(400)->withJson(['errors' => 'Body lang is not a string']); + } $document = CollaboraOnlineController::getDocument([ 'id' => $body['resId'], 'type' => $body['type'], - 'mode' => $body['mode'], 'format' => $body['format'], 'path' => $body['path'] ]); @@ -393,23 +394,25 @@ class CollaboraOnlineController return $response->withStatus(400)->withJson(['errors' => 'File cannot be edited with Collabora Online', 'lang' => 'collaboraOnlineEditDenied']); } + $dataToMerge = ['userId' => $GLOBALS['id']]; + if (!empty($body['data']) && is_array($body['data'])) { + $dataToMerge = array_merge($dataToMerge, $body['data']); + } + $payload = [ 'userId' => $GLOBALS['id'], 'resId' => $body['resId'], 'type' => $body['type'], - 'mode' => $body['mode'], - 'format' => $extension + 'format' => $extension, + 'data' => json_encode($dataToMerge) ]; $jwt = JWT::encode($payload, CoreConfigModel::getEncryptKey()); $urlIFrame = $urlSrc . 'WOPISrc=' . $coreUrl . 'rest/wopi/files/' . $body['resId'] . '&access_token=' . $jwt . '&NotWOPIButIframe=true'; - $appLanguage = CoreConfigModel::getLanguage(); - if ($appLanguage == 'fr') { - $urlIFrame .= '&lang=fr-FR'; - } elseif ($appLanguage == 'nl') { - $urlIFrame .= '&lang=nl-NL'; + if (!empty($body['lang'])) { + $urlIFrame .= '&lang=' . $body['lang']; } return $response->withJson(['url' => $urlIFrame, 'token' => $jwt, 'coreUrl' => $coreUrl]); @@ -464,7 +467,7 @@ class CollaboraOnlineController return ['code' => 401, 'errors' => 'Collabora Online access token is invalid']; } - if (empty($jwt->resId) || empty($jwt->userId) || empty($jwt->type) || empty($jwt->mode)) { + if (empty($jwt->resId) || empty($jwt->userId) || empty($jwt->type)) { return ['code' => 401, 'errors' => 'Collabora Online access token is invalid']; } @@ -476,19 +479,19 @@ class CollaboraOnlineController return [ 'type' => $jwt->type, - 'mode' => $jwt->mode, 'resId' => $jwt->resId, - 'format' => $jwt->format + 'format' => $jwt->format, + 'data' => json_decode($jwt->data, true) ]; } private static function getDocument(array $args) { - ValidatorModel::notEmpty($args, ['id', 'type', 'mode']); - ValidatorModel::stringType($args, ['type', 'mode', 'format', 'path']); + ValidatorModel::notEmpty($args, ['id', 'type']); + ValidatorModel::stringType($args, ['type', 'format', 'path']); ValidatorModel::intVal($args, ['id']); - if ($args['mode'] == 'creation' && ($args['type'] == 'resource' || $args['type'] == 'attachment')) { + if ($args['type'] == 'resourceCreation' || $args['type'] == 'attachmentCreation') { $document = TemplateModel::getById(['select' => ['template_file_name', 'template_target', 'template_path', 'template_file_name'], 'id' => $args['id']]); if (empty($document)) { return ['code' => 400, 'errors' => 'Document does not exist']; @@ -520,7 +523,7 @@ class CollaboraOnlineController return ['code' => 400, 'errors' => 'Template is out of perimeter']; } - $templateTarget = $args['type'] == 'resource' ? 'indexingFile' : 'attachments'; + $templateTarget = $args['type'] == 'resourceCreation' ? 'indexingFile' : 'attachments'; if ($document['template_target'] != $templateTarget) { return ['code' => 400, 'errors' => 'Template is not for resource creation']; } @@ -530,7 +533,7 @@ class CollaboraOnlineController $document['modification_date'] = new \DateTime('now'); $document['modification_date'] = $document['modification_date']->format(\DateTime::ISO8601); - } else if ($args['type'] == 'resource' && $args['mode'] == 'edition') { + } else if ($args['type'] == 'resourceModification') { if (!ResController::hasRightByResId(['resId' => [$args['id']], 'userId' => $GLOBALS['id']])) { return ['code' => 403, 'errors' => 'Document out of perimeter']; } @@ -547,7 +550,7 @@ class CollaboraOnlineController if (!empty($convertedDocument[0])) { return ['code' => 400, 'errors' => 'Document was signed : it cannot be edited']; } - } else if ($args['type'] == 'attachment' && $args['mode'] == 'edition') { + } else if ($args['type'] == 'attachmentModification') { $document = AttachmentModel::getById([ 'select' => ['res_id_master', 'filename', 'filesize', 'modification_date', 'docserver_id', 'path', 'fingerprint', 'status'], 'id' => $args['id'] @@ -563,7 +566,7 @@ class CollaboraOnlineController if ($document['status'] == 'SIGN') { return ['code' => 400, 'errors' => 'Document was signed : it cannot be edited']; } - } else if ($args['type'] == 'template' && $args['mode'] == 'edition') { + } else if ($args['type'] == 'templateModification') { if (!PrivilegeController::hasPrivilege(['privilegeId' => 'admin_templates', 'userId' => $GLOBALS['id']])) { return ['code' => 403, 'errors' => 'Service forbidden']; } @@ -579,7 +582,7 @@ class CollaboraOnlineController $document['modification_date'] = new \DateTime('now'); $document['modification_date'] = $document['modification_date']->format(\DateTime::ISO8601); - } else if ($args['type'] == 'template' && $args['mode'] == 'encoded') { + } else if ($args['type'] == 'templateEncoded') { if (!PrivilegeController::hasPrivilege(['privilegeId' => 'admin_templates', 'userId' => $GLOBALS['id']])) { return ['code' => 403, 'errors' => 'Service forbidden']; } @@ -590,7 +593,7 @@ class CollaboraOnlineController $document['modification_date'] = new \DateTime('now'); $document['modification_date'] = $document['modification_date']->format(\DateTime::ISO8601); - } else if ($args['type'] == 'template' && $args['mode'] == 'creation') { + } else if ($args['type'] == 'templateCreation') { if (!PrivilegeController::hasPrivilege(['privilegeId' => 'admin_templates', 'userId' => $GLOBALS['id']])) { return ['code' => 403, 'errors' => 'Service forbidden']; } diff --git a/src/frontend/app/signature-book.component.html b/src/frontend/app/signature-book.component.html index 2e1bf5d36800b14dc7a7084db44bb2a8449f3c75..41323f89927cb88486d1470eac37994577caf8ea 100755 --- a/src/frontend/app/signature-book.component.html +++ b/src/frontend/app/signature-book.component.html @@ -225,7 +225,8 @@ [hideTools]="true" [mode]="signatureBook.attachments[rightSelectedThumbnail].isResource ? 'mainDocument' : 'attachment'" [resId]="signatureBook.attachments[rightSelectedThumbnail].res_id" - [title]="signatureBook.attachments[rightSelectedThumbnail].identifier"> + [title]="signatureBook.attachments[rightSelectedThumbnail].identifier" + [inSignatureBook]="true"> </app-document-viewer> <div *ngIf="signatureBook.attachments[rightSelectedThumbnail].format != 'pdf' && signatureBook.attachments[rightSelectedThumbnail].status != 'TMP' && !signatureBook.attachments[rightSelectedThumbnail].isConverted" [ngStyle]="{'height': showTopRightPanel ? '79%' : '96%'}" class="visaNoPdfWarning"> @@ -349,4 +350,4 @@ </div> </div> </span> -</div> \ No newline at end of file +</div> diff --git a/src/frontend/app/viewer/document-viewer.component.html b/src/frontend/app/viewer/document-viewer.component.html index e7f879f3b8cda7e1b63795f06d8494dc6469aafb..29104f76c3d30824570a9b7891afa221cb19cf36 100644 --- a/src/frontend/app/viewer/document-viewer.component.html +++ b/src/frontend/app/viewer/document-viewer.component.html @@ -111,12 +111,12 @@ <ng-container *ngIf="editInProgress && editor.mode === 'onlyoffice'"> <onlyoffice-viewer #onlyofficeViewer style="height:100%;width:100%;" [params]="editor.options" [file]="file" [editMode]="true" (triggerAfterUpdatedDoc)="triggerEvent.emit()" - (triggerCloseEditor)="closeEditor()" (triggerModifiedDocument)="isDocModified = true"></onlyoffice-viewer> + (triggerCloseEditor)="closeEditor()" (triggerModifiedDocument)="isDocModified = true" [inSignatureBook]="inSignatureBook"></onlyoffice-viewer> </ng-container> <ng-container *ngIf="editInProgress && editor.mode === 'collaboraOnline'"> <app-collabora-online-viewer #collaboraOnlineViewer style="height:100%;width:100%;" [params]="editor.options" [file]="file" [editMode]="true" (triggerAfterUpdatedDoc)="triggerEvent.emit()" - (triggerCloseEditor)="closeEditor()" (triggerModifiedDocument)="isDocModified = true"></app-collabora-online-viewer> + (triggerCloseEditor)="closeEditor()" (triggerModifiedDocument)="isDocModified = true" [inSignatureBook]="inSignatureBook"></app-collabora-online-viewer> <div *ngIf="collaboraOnlineViewer.isSaving" class="example-loading-shade"> <mat-spinner style="margin:auto;"></mat-spinner> </div> diff --git a/src/frontend/app/viewer/document-viewer.component.ts b/src/frontend/app/viewer/document-viewer.component.ts index a28831d20980eba9f7382ea7f5afb94370290d60..8747d73b3db3f81c4908cba5bd780f6b5c62d368 100755 --- a/src/frontend/app/viewer/document-viewer.component.ts +++ b/src/frontend/app/viewer/document-viewer.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input, ViewChild, EventEmitter, Output, ElementRef } from '@angular/core'; +import {Component, OnInit, Input, ViewChild, EventEmitter, Output, OnDestroy} from '@angular/core'; import { HttpClient, HttpEventType } from '@angular/common/http'; import { LANG } from '../translate.component'; import { NotificationService } from '../../service/notification/notification.service'; @@ -29,7 +29,7 @@ import { CollaboraOnlineViewerComponent } from '../../plugins/collabora-online/c providers: [SortPipe] }) -export class DocumentViewerComponent implements OnInit { +export class DocumentViewerComponent implements OnInit, OnDestroy { /** * document name stored in server (in tmp folder) @@ -84,6 +84,11 @@ export class DocumentViewerComponent implements OnInit { */ @Output() triggerEvent = new EventEmitter<string>(); + /** + * true if viewer in signature book + */ + @Input() inSignatureBook: boolean = false; + lang: any = LANG; loading: boolean = true; @@ -737,13 +742,11 @@ export class DocumentViewerComponent implements OnInit { this.editInProgress = true; } else if (this.editor.mode === 'collaboraOnline') { - const mode = this.mode === 'attachment' ? 'attachment' : 'resource'; this.editor.async = false; this.editInProgress = true; this.editor.options = { - objectType: mode, + objectType: this.mode === 'attachment' ? 'attachmentCreation' : 'resourceCreation', objectId: template.id, - objectMode: 'creation', dataToMerge: this.resourceDatas }; } else { @@ -798,9 +801,8 @@ export class DocumentViewerComponent implements OnInit { this.editor.async = false; this.editInProgress = true; this.editor.options = { - objectType: 'attachment', + objectType: 'attachmentModification', objectId: this.resId, - objectMode: 'edition', dataToMerge: this.resourceDatas }; } else { @@ -835,9 +837,8 @@ export class DocumentViewerComponent implements OnInit { } else if (this.editor.mode === 'collaboraOnline') { this.editor.async = false; this.editor.options = { - objectType: 'resource', + objectType: 'resourceModification', objectId: this.resId, - objectMode: 'edition', dataToMerge: this.resourceDatas }; this.editInProgress = true; diff --git a/src/frontend/plugins/collabora-online/collabora-online-viewer.component.html b/src/frontend/plugins/collabora-online/collabora-online-viewer.component.html index 2a446577ba0db257a78b6829ffb07b9fb40e97ec..c917a0caf08f05746fb2aa9b0d204cde30017bd7 100644 --- a/src/frontend/plugins/collabora-online/collabora-online-viewer.component.html +++ b/src/frontend/plugins/collabora-online/collabora-online-viewer.component.html @@ -1,12 +1,21 @@ <div *ngIf="loading" style="display:block;padding: 10px;">{{lang.checkCollaboraOnlineServer}}...</div> -<button *ngIf="!hideCloseEditor" class="collaboraOnlineButton_fullscreen" [class.fullScreen]="fullscreenMode" mat-mini-fab color="warn" +<button *ngIf="!hideButtons" class="collaboraOnlineButton_fullscreen" [class.fullScreen]="fullscreenMode" mat-mini-fab color="warn" [title]="lang.closeEditor" (click)="quit()"> <mat-icon class="fa fa-times" style="height:auto;"></mat-icon> </button> -<button mat-mini-fab class="collaboraOnlineButton_close" [class.fullScreen]="fullscreenMode" color="default" +<button *ngIf="!hideButtons" mat-mini-fab class="collaboraOnlineButton_close" [class.fullScreen]="fullscreenMode" color="default" [title]="fullscreenMode ? lang.closeFullscreen : lang.openFullscreen" (click)="openFullscreen()"> <mat-icon class="fas" [class.fa-expand]="!fullscreenMode" [class.fa-compress]="fullscreenMode" style="height:auto;"></mat-icon> </button> +<button *ngIf="!hideButtons" class="collaboraOnlineButton_hide" [class.fullScreen]="fullscreenMode" mat-mini-fab color="default" + [title]="lang.closeEditor" (click)="hideButtons = !hideButtons"> + <mat-icon class="fa fa-arrow-right" style="height:auto;"></mat-icon> +</button> +<button *ngIf="hideButtons" class="collaboraOnlineButton_show" [class.fullScreen]="fullscreenMode" mat-mini-fab color="default" + [title]="lang.closeEditor" (click)="hideButtons = !hideButtons"> + <mat-icon class="fa fa-arrow-left" style="height:auto;"></mat-icon> +</button> + <iframe #collaboraFrame *ngIf="editorUrl !== ''" [src]="editorUrl" id="collabora" width="100%" height="100%" name="frameEditor"> </iframe> diff --git a/src/frontend/plugins/collabora-online/collabora-online-viewer.component.scss b/src/frontend/plugins/collabora-online/collabora-online-viewer.component.scss index 53e992034f2b9744c0c2b3767bbc29fadf06b730..8ba1659b48805a5f54ee6f5edf6253c812bc5ee8 100644 --- a/src/frontend/plugins/collabora-online/collabora-online-viewer.component.scss +++ b/src/frontend/plugins/collabora-online/collabora-online-viewer.component.scss @@ -1,5 +1,5 @@ -.collaboraOnlineButton_fullscreen, .collaboraOnlineButton_close { +.collaboraOnlineButton_fullscreen, .collaboraOnlineButton_close, .collaboraOnlineButton_hide, .collaboraOnlineButton_show { position: absolute; top: 12px; z-index: 3; @@ -12,6 +12,12 @@ &_close { right: 56px; } + &_hide { + right: 106px; + } + &_show { + right: -15px; + } } .fullScreen { diff --git a/src/frontend/plugins/collabora-online/collabora-online-viewer.component.ts b/src/frontend/plugins/collabora-online/collabora-online-viewer.component.ts index 9617323edb178551022c424805b8c0c8d0c40ce6..eb352150498e473e181932376a68cd9b896cacc3 100644 --- a/src/frontend/plugins/collabora-online/collabora-online-viewer.component.ts +++ b/src/frontend/plugins/collabora-online/collabora-online-viewer.component.ts @@ -26,7 +26,7 @@ export class CollaboraOnlineViewerComponent implements OnInit, AfterViewInit, On @Input() editMode: boolean = false; @Input() file: any = {}; @Input() params: any = {}; - @Input() hideCloseEditor: any = false; + @Input() inSignatureBook: boolean = false; @Output() triggerAfterUpdatedDoc = new EventEmitter<string>(); @Output() triggerCloseEditor = new EventEmitter<string>(); @@ -37,6 +37,7 @@ export class CollaboraOnlineViewerComponent implements OnInit, AfterViewInit, On isSaving: boolean = false; isModified: boolean = false; fullscreenMode: boolean = false; + hideButtons: boolean = false; allowedExtension: string[] = [ 'doc', @@ -72,8 +73,10 @@ export class CollaboraOnlineViewerComponent implements OnInit, AfterViewInit, On this.isModified = false; } if (response.MessageId === 'Action_Save_Resp' && response.Values.success === true && !this.isModified) { - this.triggerAfterUpdatedDoc.emit(); - this.getTmpFile(); + setTimeout(() => { + this.triggerAfterUpdatedDoc.emit(); + this.getTmpFile(); + }, 500); } else if (response.MessageId === 'Doc_ModifiedStatus' && response.Values.Modified === false && this.isSaving) { // Collabora sends 'Action_Save_Resp' when it starts saving the document, then sends Doc_ModifiedStatus with Modified = false when it is done saving this.triggerAfterUpdatedDoc.emit(); @@ -145,20 +148,14 @@ export class CollaboraOnlineViewerComponent implements OnInit, AfterViewInit, On if (this.canLaunchCollaboraOnline()) { await this.checkServerStatus(); - if (this.params.objectType === 'templateModification' || this.params.objectType === 'templateCreation') { - this.params.objectMode = this.params.objectType === 'templateModification' ? 'edition' : 'creation'; - this.params.objectType = 'template'; - } - this.params.objectPath = undefined; - if (typeof this.params.objectId === 'string' && this.params.objectType === 'template') { + if (typeof this.params.objectId === 'string' && (this.params.objectType === 'templateModification' || this.params.objectType === 'templateCreation')) { this.params.objectPath = this.params.objectId; this.params.objectId = this.key; } else if (typeof this.params.objectId === 'string' && this.params.objectType === 'encodedResource') { this.params.content = this.params.objectId; this.params.objectId = this.key; - this.params.objectMode = 'encoded'; - this.params.objectType = 'template'; + this.params.objectType = 'templateEncoded'; await this.saveEncodedFile(); } @@ -206,7 +203,7 @@ export class CollaboraOnlineViewerComponent implements OnInit, AfterViewInit, On getTmpFile() { return new Promise((resolve) => { - this.http.post('../rest/collaboraOnline/file', {token: this.token, data: this.params.dataToMerge}).pipe( + this.http.post('../rest/collaboraOnline/file', {token: this.token}).pipe( tap((data: any) => { this.file = { name: this.key, @@ -277,9 +274,10 @@ export class CollaboraOnlineViewerComponent implements OnInit, AfterViewInit, On this.http.post('../rest/collaboraOnline/configuration', { resId: this.params.objectId, type: this.params.objectType, - mode: this.params.objectMode, format: this.file.format, - path: this.params.objectPath + path: this.params.objectPath, + data: this.params.dataToMerge, + lang: this.lang.langISO }).pipe( tap((data: any) => { this.editorUrl = data.url; @@ -306,21 +304,22 @@ export class CollaboraOnlineViewerComponent implements OnInit, AfterViewInit, On } openFullscreen() { - $('iframe[name=\'frameEditor\']').css('top', '0px'); - $('iframe[name=\'frameEditor\']').css('left', '0px'); + const iframe = $('iframe[name=\'frameEditor\']'); + iframe.css('top', '0px'); + iframe.css('left', '0px'); if (!this.fullscreenMode) { if (this.headerService.sideNavLeft !== null) { this.headerService.sideNavLeft.close(); } - $('iframe[name=\'frameEditor\']').css('position', 'fixed'); - $('iframe[name=\'frameEditor\']').css('z-index', '2'); + iframe.css('position', 'fixed'); + iframe.css('z-index', '2'); } else { - if (this.headerService.sideNavLeft !== null) { + if (this.headerService.sideNavLeft !== null && !this.inSignatureBook) { this.headerService.sideNavLeft.open(); } - $('iframe[name=\'frameEditor\']').css('position', 'initial'); - $('iframe[name=\'frameEditor\']').css('z-index', '1'); + iframe.css('position', 'initial'); + iframe.css('z-index', '1'); } this.fullscreenMode = !this.fullscreenMode; } diff --git a/src/frontend/plugins/onlyoffice-api-js/onlyoffice-viewer.component.html b/src/frontend/plugins/onlyoffice-api-js/onlyoffice-viewer.component.html index a2545c0bc0e74d0abd30605ed4b8fb7185b7c81d..0a27f305860aedae59ff8d8aa5c5709e65961798 100644 --- a/src/frontend/plugins/onlyoffice-api-js/onlyoffice-viewer.component.html +++ b/src/frontend/plugins/onlyoffice-api-js/onlyoffice-viewer.component.html @@ -1,10 +1,19 @@ <div *ngIf="loading" style="display:block;padding: 10px;">{{lang.checkOnlyofficeServer}}...</div> -<button *ngIf="!hideCloseEditor" class="onlyofficeButton_fullscreen" [class.fullScreen]="fullscreenMode" mat-mini-fab color="warn" +<button *ngIf="!hideCloseEditor && !hideButtons" class="onlyofficeButton_fullscreen" [class.fullScreen]="fullscreenMode" mat-mini-fab color="warn" [title]="lang.closeEditor" (click)="quit()"> <mat-icon class="fa fa-times" style="height:auto;"></mat-icon> </button> -<button mat-mini-fab class="onlyofficeButton_close" [class.fullScreen]="fullscreenMode" color="default" +<button *ngIf="!hideButtons" mat-mini-fab class="onlyofficeButton_close" [class.fullScreen]="fullscreenMode" color="default" [title]="fullscreenMode ? lang.closeFullscreen : lang.openFullscreen" (click)="openFullscreen()"> <mat-icon class="fas" [class.fa-expand]="!fullscreenMode" [class.fa-compress]="fullscreenMode" style="height:auto;"></mat-icon> </button> -<div id="placeholder"></div> \ No newline at end of file +<button *ngIf="!hideButtons" class="onlyofficeButton_hide" [class.fullScreen]="fullscreenMode" mat-mini-fab color="default" + [title]="lang.closeEditor" (click)="hideButtons = !hideButtons"> + <mat-icon class="fa fa-arrow-right" style="height:auto;"></mat-icon> +</button> +<button *ngIf="hideButtons" class="onlyofficeButton_show" [class.fullScreen]="fullscreenMode" mat-mini-fab color="default" + [title]="lang.closeEditor" (click)="hideButtons = !hideButtons"> + <mat-icon class="fa fa-arrow-left" style="height:auto;"></mat-icon> +</button> + +<div id="placeholder"></div> diff --git a/src/frontend/plugins/onlyoffice-api-js/onlyoffice-viewer.component.scss b/src/frontend/plugins/onlyoffice-api-js/onlyoffice-viewer.component.scss index 7e0ff7e03f31cfb67c1ac27d65dace3600de4ec7..ed1160cfb295a5b5d4d1ac7ef26ddfe4333ba1e0 100644 --- a/src/frontend/plugins/onlyoffice-api-js/onlyoffice-viewer.component.scss +++ b/src/frontend/plugins/onlyoffice-api-js/onlyoffice-viewer.component.scss @@ -1,5 +1,5 @@ -.onlyofficeButton_fullscreen, .onlyofficeButton_close { +.onlyofficeButton_fullscreen, .onlyofficeButton_close, .onlyofficeButton_hide, .onlyofficeButton_show { position: absolute; top: 12px; z-index: 3; @@ -12,6 +12,12 @@ &_close { right: 56px; } + &_hide { + right: 106px; + } + &_show { + right: -15px; + } } .fullScreen { @@ -21,4 +27,4 @@ .fullScreenEditor { top: 0px; left: 0px; -} \ No newline at end of file +} diff --git a/src/frontend/plugins/onlyoffice-api-js/onlyoffice-viewer.component.ts b/src/frontend/plugins/onlyoffice-api-js/onlyoffice-viewer.component.ts index ee842bfe152947efee7353d8a85fb900b4f1e5a6..c9aca8382978e5ee801892117872e5bf02b3b44c 100644 --- a/src/frontend/plugins/onlyoffice-api-js/onlyoffice-viewer.component.ts +++ b/src/frontend/plugins/onlyoffice-api-js/onlyoffice-viewer.component.ts @@ -37,6 +37,7 @@ export class EcplOnlyofficeViewerComponent implements OnInit, AfterViewInit, OnD @Input() file: any = {}; @Input() params: any = {}; @Input() hideCloseEditor: any = false; + @Input() inSignatureBook: boolean = false; @Output() triggerAfterUpdatedDoc = new EventEmitter<string>(); @Output() triggerCloseEditor = new EventEmitter<string>(); @@ -54,6 +55,7 @@ export class EcplOnlyofficeViewerComponent implements OnInit, AfterViewInit, OnD appUrl: string = ''; onlyOfficeUrl: string = ''; + hideButtons: boolean = false; allowedExtension: string[] = [ 'doc', @@ -357,7 +359,7 @@ export class EcplOnlyofficeViewerComponent implements OnInit, AfterViewInit, OnD $('iframe[name=\'frameEditor\']').css('position', 'fixed'); $('iframe[name=\'frameEditor\']').css('z-index', '2'); } else { - if (this.headerService.sideNavLeft !== null) { + if (this.headerService.sideNavLeft !== null && !this.inSignatureBook) { this.headerService.sideNavLeft.open(); } $('iframe[name=\'frameEditor\']').css('position', 'initial');