-
-
+
+
+
-
-
- {{'ADF_FILE_UPLOAD.FILE_LIST.NAME' | translate}} |
- {{'ADF_FILE_UPLOAD.FILE_LIST.PROGRESS' | translate}} |
- {{'ADF_FILE_UPLOAD.FILE_LIST.SIZE' | translate}} |
- {{'ADF_FILE_UPLOAD.FILE_LIST.ACTION' | translate}} |
-
-
-
-
- |
-
- error_outline
- block
-
-
-
-
- |
-
- {{ file.size | adfFileSize }}
- |
-
-
- done
-
-
- remove_circle_outline
-
- |
-
-
diff --git a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.scss b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.scss
new file mode 100644
index 0000000000..23e92102c2
--- /dev/null
+++ b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.scss
@@ -0,0 +1,4 @@
+:host {
+ display:flex;
+ flex-direction: column;
+}
diff --git a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.ts b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.ts
index 0f4ad6d081..279863a78c 100644
--- a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.ts
+++ b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.ts
@@ -15,22 +15,31 @@
* limitations under the License.
*/
-import { Component, Input } from '@angular/core';
-import { FileModel, FileUploadStatus, UploadService } from 'ng2-alfresco-core';
+import { Component, ContentChild, Input, TemplateRef } from '@angular/core';
+import { AlfrescoTranslationService, FileModel, FileUploadStatus, NodesApiService, NotificationService, UploadService } from 'ng2-alfresco-core';
+import { FileUploadService } from '../services/file-uploading.service';
@Component({
selector: 'adf-file-uploading-list, alfresco-file-uploading-list',
templateUrl: './file-uploading-list.component.html',
- styleUrls: ['./file-uploading-list.component.css']
+ styleUrls: ['./file-uploading-list.component.scss']
})
export class FileUploadingListComponent {
FileUploadStatus = FileUploadStatus;
- @Input()
- files: FileModel[];
+ @ContentChild(TemplateRef)
+ template: any;
- constructor(private uploadService: UploadService) {
+ @Input()
+ files: FileModel[] = [];
+
+ constructor(
+ private fileUploadService: FileUploadService,
+ private uploadService: UploadService,
+ private nodesApi: NodesApiService,
+ private notificationService: NotificationService,
+ private translateService: AlfrescoTranslationService) {
}
/**
@@ -44,6 +53,16 @@ export class FileUploadingListComponent {
this.uploadService.cancelUpload(file);
}
+ removeFile(file: FileModel): void {
+ const { id } = file.data.entry;
+ this.nodesApi
+ .deleteNode(id, { permanent: true })
+ .subscribe(
+ () => this.onRemoveSuccess(file),
+ () => this.onRemoveFail(file)
+ );
+ }
+
/**
* Call the abort method for each file
*/
@@ -51,7 +70,20 @@ export class FileUploadingListComponent {
if (event) {
event.preventDefault();
}
- this.uploadService.cancelUpload(...this.files);
+
+ this.files.forEach((file) => {
+ const { status } = file;
+ const { Complete, Progress, Pending } = FileUploadStatus;
+
+ if (status === Complete) {
+ this.removeFile(file);
+ }
+
+ if (status === Progress || status === Pending) {
+ this.cancelFileUpload(file);
+ }
+
+ });
}
/**
@@ -71,4 +103,38 @@ export class FileUploadingListComponent {
}
return isAllCompleted;
}
+
+ /**
+ * Check if all the files are not in the Progress state.
+ * @returns {boolean} - false if there is at least one file in Progress
+ */
+ isUploadCancelled(): boolean {
+ return this.files
+ .filter((file) => file.status !== FileUploadStatus.Error)
+ .every((file) => file.status === FileUploadStatus.Cancelled
+ || file.status === FileUploadStatus.Aborted);
+ }
+
+ uploadErrorFiles(): FileModel[] {
+ return this.files.filter((item) => item.status === FileUploadStatus.Error);
+ }
+
+ totalErrorFiles(): number {
+ return this.files.filter((item) => item.status === FileUploadStatus.Error).length;
+ }
+
+ private onRemoveSuccess(file: FileModel): void {
+ const { uploadService, fileUploadService } = this;
+
+ uploadService.cancelUpload(file);
+ fileUploadService.emitFileRemoved(file);
+ }
+
+ private onRemoveFail(file: FileModel): void {
+ this.translateService
+ .get('FILE_UPLOAD.MESSAGES.REMOVE_FILE_ERROR', { fileName: file.name})
+ .subscribe((message) => {
+ this.notificationService.openSnackMessage(message, 4000);
+ });
+ }
}
diff --git a/ng2-components/ng2-alfresco-upload/src/i18n/en.json b/ng2-components/ng2-alfresco-upload/src/i18n/en.json
index b8f19e1f76..29ca74f81b 100644
--- a/ng2-components/ng2-alfresco-upload/src/i18n/en.json
+++ b/ng2-components/ng2-alfresco-upload/src/i18n/en.json
@@ -1,24 +1,32 @@
{
"ADF_FILE_UPLOAD": {
- "FILE_LIST": {
- "NAME": "Name",
- "PROGRESS": "Progress",
- "SIZE": "Size",
- "ACTION": "Action"
+ "BUTTON": {
+ "MINIMIZE": "Minimize",
+ "MAXIMIZE": "Maximize",
+ "CLOSE": "Close",
+ "CANCEL_ALL": "Cancel uploads",
+ "CANCEL_FILE": "Cancel upload",
+ "REMOVE_FILE": "Remove uploaded file"
+ },
+ "STATUS": {
+ "FILE_CANCELED_STATUS": "Cancelled"
}
},
"FILE_UPLOAD": {
"BUTTON": {
"UPLOAD_FILE": "Upload file",
- "UPLOAD_FOLDER": "Upload folder",
- "CANCEL_ALL": "Cancell all"
+ "UPLOAD_FOLDER": "Upload folder"
},
"MESSAGES": {
- "SINGLE_COMPLETED": "upload complete",
- "COMPLETED": "uploads complete",
+ "UPLOAD_CANCELED": "Upload canceled",
+ "UPLOAD_COMPLETED": "Uploaded {{ completed }} / {{ total }}",
+ "UPLOAD_PROGRESS": "Uploading {{ completed }} / {{ total }}",
+ "UPLOAD_ERROR": "{{ total }} error",
+ "UPLOAD_ERRORS": "{{ total }} errors",
"PROGRESS": "Upload in progress...",
"FOLDER_ALREADY_EXIST": "The folder {0} already exist",
- "FOLDER_NOT_SUPPORTED": "Folder upload isn't supported by your browser"
+ "FOLDER_NOT_SUPPORTED": "Folder upload isn't supported by your browser",
+ "REMOVE_FILE_ERROR": "Error removing file {{ fileName }}"
},
"ACTION": {
"UNDO": "Undo"
diff --git a/ng2-components/ng2-alfresco-upload/src/i18n/it.json b/ng2-components/ng2-alfresco-upload/src/i18n/it.json
index f824da8fea..52ac661bf2 100644
--- a/ng2-components/ng2-alfresco-upload/src/i18n/it.json
+++ b/ng2-components/ng2-alfresco-upload/src/i18n/it.json
@@ -1,25 +1,33 @@
{
- "FILE_UPLOAD": {
- "BUTTON": {
- "UPLOAD_FILE": "Carica un file",
- "UPLOAD_FOLDER": "Carica una cartella",
- "CANCEL_ALL": "CANCELLA"
+ "ADF_FILE_UPLOAD": {
+ "BUTTON": {
+ "MINIMIZE": "Minimizzare",
+ "MAXIMIZE": "Massimizzare",
+ "CLOSE": "Vicino",
+ "CANCEL_ALL": "Annulla i caricamenti"
+ },
+ "STATUS": {
+ "FILE_CANCELED_STATUS": "Annullato"
+ }
},
- "MESSAGES": {
- "SINGLE_COMPLETED": "caricamento completato",
- "COMPLETED": "caricamenti completati",
- "PROGRESS": "caricamento in corso...",
- "FOLDER_ALREADY_EXIST": "Cartella {0} già presente",
- "FOLDER_NOT_SUPPORTED": "L' upload di cartelle non é supportato dal tuo browser"
- },
- "FILE_INFO": {
- "NAME": "Nome file",
- "PROGRESS": "Percentuale caricamento",
- "SIZE": "Dimensione file",
- "ACTION": "Azioni"
- },
- "ACTION": {
- "UNDO": "Annulla"
+ "FILE_UPLOAD": {
+ "BUTTON": {
+ "UPLOAD_FILE": "Carica un file",
+ "UPLOAD_FOLDER": "Carica una cartella"
+ },
+ "MESSAGES": {
+ "UPLOAD_CANCELED": "Carica annullata",
+ "UPLOAD_COMPLETED": "Caricato {{ completed }} / {{ total }}",
+ "UPLOAD_PROGRESS": "Caricamento {{ completed }} / {{ total }}",
+ "UPLOAD_ERROR": "{{ total }} errore",
+ "UPLOAD_ERRORS": "{{ total }} errori",
+ "PROGRESS": "caricamento in corso...",
+ "FOLDER_ALREADY_EXIST": "Cartella {0} già presente",
+ "FOLDER_NOT_SUPPORTED": "L' upload di cartelle non é supportato dal tuo browser",
+ "REMOVE_FILE_ERROR": "Errore durante la rimozione del file {{ fileName }}"
+ },
+ "ACTION": {
+ "UNDO": "Annulla"
+ }
}
- }
-}
+}
\ No newline at end of file
diff --git a/ng2-components/ng2-alfresco-upload/src/i18n/ru.json b/ng2-components/ng2-alfresco-upload/src/i18n/ru.json
index 3c79cb7eeb..cd25cf87e6 100644
--- a/ng2-components/ng2-alfresco-upload/src/i18n/ru.json
+++ b/ng2-components/ng2-alfresco-upload/src/i18n/ru.json
@@ -1,25 +1,34 @@
{
- "FILE_UPLOAD": {
- "BUTTON": {
- "UPLOAD_FILE": "Загрузить файл",
- "UPLOAD_FOLDER": "Загрузить папку",
- "CANCEL_ALL": "Отменить все"
+ "ADF_FILE_UPLOAD": {
+ "BUTTON": {
+ "MINIMIZE": "Минимизировать",
+ "MAXIMIZE": "Mаксимизировать",
+ "CLOSE": "Закрыть",
+ "CANCEL_ALL": "Отменить загрузку"
+ },
+ "STATUS": {
+ "FILE_CANCELED_STATUS": "Oтменен"
+ }
},
- "MESSAGES": {
- "SINGLE_COMPLETED": "файл загружен",
- "COMPLETED": "файлы загружены",
- "PROGRESS": "Идет загрузка...",
- "FOLDER_ALREADY_EXIST": "Папка {0} уже существует",
- "FOLDER_NOT_SUPPORTED": "Данный браузер не поддерживает загрузку папки"
- },
- "FILE_INFO": {
- "NAME": "Имя файла",
- "PROGRESS": "File progress",
- "SIZE": "Размер",
- "ACTION": "Действие"
- },
- "ACTION": {
- "UNDO": "Отменить"
+ "FILE_UPLOAD": {
+ "BUTTON": {
+ "UPLOAD_FILE": "Загрузить файл",
+ "UPLOAD_FOLDER": "Загрузить папку",
+ "CANCEL_ALL": "Отменить все"
+ },
+ "MESSAGES": {
+ "UPLOAD_CANCELED": "Отменить отмену",
+ "UPLOAD_COMPLETED": "закачанный {{ completed }} / {{ total }}",
+ "UPLOAD_PROGRESS": "загрузка {{ completed }} / {{ total }}",
+ "UPLOAD_ERROR": "{{ total }} ошибка",
+ "UPLOAD_ERRORS": "{{ total }} ошибки",
+ "PROGRESS": "Идет загрузка...",
+ "FOLDER_ALREADY_EXIST": "Папка {0} уже существует",
+ "FOLDER_NOT_SUPPORTED": "Данный браузер не поддерживает загрузку папки",
+ "REMOVE_FILE_ERROR": "Ошибка удаления файла {{ fileName }}"
+ },
+ "ACTION": {
+ "UNDO": "Отменить"
+ }
}
- }
-}
+}
\ No newline at end of file
diff --git a/ng2-components/ng2-alfresco-upload/src/services/file-uploading.service.ts b/ng2-components/ng2-alfresco-upload/src/services/file-uploading.service.ts
new file mode 100644
index 0000000000..e03c27bcf6
--- /dev/null
+++ b/ng2-components/ng2-alfresco-upload/src/services/file-uploading.service.ts
@@ -0,0 +1,30 @@
+/*!
+ * @license
+ * Copyright 2016 Alfresco Software, Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Injectable } from '@angular/core';
+import { Observable } from 'rxjs/Observable';
+import { Subject } from 'rxjs/Rx';
+
+@Injectable()
+export class FileUploadService {
+ public remove = new Subject
();
+ public onRemoveFile = this.remove.asObservable();
+
+ emitFileRemoved(item: any) {
+ this.remove.next(item);
+ }
+}