diff --git a/demo-shell-ng2/.editorconfig b/demo-shell-ng2/.editorconfig index 6e87a003da..9d98de12fa 100644 --- a/demo-shell-ng2/.editorconfig +++ b/demo-shell-ng2/.editorconfig @@ -4,10 +4,20 @@ root = true [*] charset = utf-8 indent_style = space -indent_size = 2 +indent_size = 4 +end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true +[package.json] +indent_style = space +indent_size = 2 + [*.md] max_line_length = off trim_trailing_whitespace = false + +[resources/*.json] +indent_size = 2 +max_line_length = off +trim_trailing_whitespace = false diff --git a/demo-shell-ng2/resources/i18n/en.json b/demo-shell-ng2/resources/i18n/en.json index fefc1511c1..5eb65e5871 100644 --- a/demo-shell-ng2/resources/i18n/en.json +++ b/demo-shell-ng2/resources/i18n/en.json @@ -1,5 +1,10 @@ { "title": "Welcome", + "VERSION": { + "NO_PERMISSION": "You don't have permission to manage the versions of this content", + "NO_PERMISSION_EVENT": "You don't have the ${event.permission} permission to ${event.action} the ${event.type}", + "CHOOSE_FILE": "Please choose a document to see the versions of it" + }, "APP_LAYOUT": { "APP_NAME": "ADF Demo Application", "HOME": "Home", diff --git a/demo-shell-ng2/src/app/components/files/files.component.html b/demo-shell-ng2/src/app/components/files/files.component.html index c3247b2cf3..edee65b7cd 100644 --- a/demo-shell-ng2/src/app/components/files/files.component.html +++ b/demo-shell-ng2/src/app/components/files/files.component.html @@ -251,13 +251,13 @@
face - Please choose a document to see the versions of it. + {{'VERSION.CHOOSE_FILE' | translate}}
warning - You don't have permission to manage the versions of this content. + {{'VERSION.NO_PERMISSION' | translate}}
@@ -340,6 +340,7 @@ [multipleFiles]="multipleFileUpload" [uploadFolders]="folderUpload" [maxFilesSize]="maxFilesSize" + (error)="handleUploadError($event)" [versioning]="versioning" [adf-node-permission]="'create'" [adf-nodes]="getCurrentDocumentListNode()" @@ -357,6 +358,7 @@ [multipleFiles]="multipleFileUpload" [uploadFolders]="folderUpload" [versioning]="versioning" + (error)="handleUploadError($event)" [adf-node-permission]="'create'" [adf-nodes]="getCurrentDocumentListNode()" (permissionEvent)="handlePermissionError($event)"> diff --git a/demo-shell-ng2/src/app/components/files/files.component.ts b/demo-shell-ng2/src/app/components/files/files.component.ts index 3dbbf256e7..30f3c37db7 100644 --- a/demo-shell-ng2/src/app/components/files/files.component.ts +++ b/demo-shell-ng2/src/app/components/files/files.component.ts @@ -137,7 +137,7 @@ export class FilesComponent implements OnInit { getCurrentDocumentListNode(): MinimalNodeEntity[] { if (this.documentList.folderNode) { - return [ { entry: this.documentList.folderNode } ]; + return [{ entry: this.documentList.folderNode }]; } else { return []; } @@ -168,8 +168,21 @@ export class FilesComponent implements OnInit { } handlePermissionError(event: any) { + this.translateService.get('OPERATION.ERROR.NO_PERMISSION_EVENT', { + permission: event.permission, + action: event.action, + type: event.type + }).subscribe((message) => { + this.notificationService.openSnackMessage( + message, + 4000 + ); + }) + } + + handleUploadError(event: any) { this.notificationService.openSnackMessage( - `You don't have the ${event.permission} permission to ${event.action} the ${event.type} `, + event, 4000 ); } @@ -217,7 +230,11 @@ export class FilesComponent implements OnInit { const contentEntry = event.value.entry; if (this.contentService.hasPermission(contentEntry, 'update')) { - this.dialog.open(VersionManagerDialogAdapterComponent, { data: { contentEntry }, panelClass: 'adf-version-manager-dialog', width: '630px' }); + this.dialog.open(VersionManagerDialogAdapterComponent, { + data: { contentEntry }, + panelClass: 'adf-version-manager-dialog', + width: '630px' + }); } else { const translatedErrorMessage: any = this.translateService.get('OPERATION.ERROR.PERMISSION'); this.notificationService.openSnackMessage(translatedErrorMessage.value, 4000); diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts index ec359986ef..8195dc9611 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts @@ -283,6 +283,16 @@ describe('UploadButtonComponent', () => { expect(filesCalledWith[0].name).toBe('smallFile.png'); }); + it('should output an error when you try to upload a file too big', (done) => { + component.maxFilesSize = 100; + + component.error.subscribe(() => { + done(); + }); + + component.uploadFiles(files); + }); + it('should not filter out files if max file size is not set', () => { component.maxFilesSize = null; diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts index 4743a6dd74..8689a568e5 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts @@ -223,7 +223,17 @@ export class UploadButtonComponent implements OnInit, OnChanges, NodePermissionS * @param file FileModel */ private isFileSizeAcceptable(file: FileModel): boolean { - return this.maxFilesSize ? file.size <= this.maxFilesSize : true; + let acceptableSize = true; + + if (this.maxFilesSize && file.size > this.maxFilesSize) { + acceptableSize = false; + + this.translateService.get('FILE_UPLOAD.MESSAGES.EXCEED_MAX_FILE_SIZE', {fileName: file.name}).subscribe((message: string) => { + this.error.emit(message); + }) + } + + return acceptableSize; } /** @@ -270,7 +280,7 @@ export class UploadButtonComponent implements OnInit, OnChanges, NodePermissionS private hasCreatePermission(node: any): boolean { if (node && node.allowableOperations) { - return node.allowableOperations.find(permision => permision === 'create') ? true : false; + return node.allowableOperations.find(permission => permission === 'create') ? true : false; } return false; } diff --git a/ng2-components/ng2-alfresco-upload/src/i18n/en.json b/ng2-components/ng2-alfresco-upload/src/i18n/en.json index af55e1dd97..5647cfbda8 100644 --- a/ng2-components/ng2-alfresco-upload/src/i18n/en.json +++ b/ng2-components/ng2-alfresco-upload/src/i18n/en.json @@ -37,7 +37,8 @@ "FOLDER_ALREADY_EXIST": "The folder {0} already exists", "FOLDER_NOT_SUPPORTED": "Folder upload isn't supported by your browser, try a different browser", "REMOVE_FILE_ERROR": "{{ fileName }} couldn't be removed, try again or check with your IT Team.", - "REMOVE_FILES_ERROR": "{{ total }} files couldn't be removed, try again or check with your IT Team." + "REMOVE_FILES_ERROR": "{{ total }} files couldn't be removed, try again or check with your IT Team.", + "EXCEED_MAX_FILE_SIZE": "The size of the file {{ fileName }} exceed the max allowed file size" }, "ACTION": { "UNDO": "Undo"