mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#139 Fixed complete counter
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<div *ngIf="filesUploadingList" class="file-dialog" [ngClass]="{show: isDialogActive}">
|
||||
<div class="header">
|
||||
<div class="title">
|
||||
{{filesUploadingList.length}} {{'FILE_UPLOAD.MESSAGES.COMPLETED' | translate}}
|
||||
{{totalCompleted}} {{'FILE_UPLOAD.MESSAGES.COMPLETED' | translate}}
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<div class="minimize-button" [ngClass]="{active: _isDialogMinimized}" (click)="toggleDialogMinimize()">
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, ChangeDetectorRef } from 'angular2/core';
|
||||
import { Component, ChangeDetectorRef, OnInit } from 'angular2/core';
|
||||
import { FileModel } from '../models/file.model';
|
||||
import { FileUploadingListComponent } from './file-uploading-list.component';
|
||||
import { AlfrescoPipeTranslate } from 'ng2-alfresco-core/dist/ng2-alfresco-core';
|
||||
@@ -43,12 +43,14 @@ declare let __moduleName: string;
|
||||
host: {'[class.dialog-show]': 'toggleShowDialog'},
|
||||
pipes: [AlfrescoPipeTranslate]
|
||||
})
|
||||
export class FileUploadingDialogComponent {
|
||||
export class FileUploadingDialogComponent implements OnInit{
|
||||
|
||||
isDialogActive: boolean = false;
|
||||
|
||||
filesUploadingList: FileModel [];
|
||||
|
||||
totalCompleted: number = 0;
|
||||
|
||||
private _isDialogMinimized: boolean = false;
|
||||
|
||||
constructor(private cd: ChangeDetectorRef,
|
||||
@@ -62,6 +64,10 @@ export class FileUploadingDialogComponent {
|
||||
this.cd.detectChanges();
|
||||
}
|
||||
});
|
||||
this._uploaderService.totalCompleted$.subscribe((total: number) => {
|
||||
this.totalCompleted = total;
|
||||
this.cd.detectChanges();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -26,7 +26,6 @@
|
||||
<span *ngIf="file.uploading" (click)="abort(file.id)" class="cursor" ><i data-automation-id="abort_cancel_upload"
|
||||
class="material-icons">remove_circle_outline</i></span>
|
||||
<span *ngIf="file.abort"><i class="material-icons">remove_circle</i></span>
|
||||
<span *ngIf="!file.abort && !file.uploading && !file.done"><i class="material-icons">pause</i></span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@@ -43,13 +43,18 @@ export class UploadService {
|
||||
private _queue: FileModel[] = [];
|
||||
|
||||
filesUpload$: Observable<FileModel[]>;
|
||||
totalCompleted$: Observable<number>;
|
||||
private _filesUploadObserver: Observer<FileModel[]>;
|
||||
private _totalCompletedObserver: Observer<number>;
|
||||
|
||||
private _alfrescoClient: any;
|
||||
|
||||
public totalCompleted: number = 0;
|
||||
|
||||
constructor(private settings: AlfrescoSettingsService) {
|
||||
console.log('UploadService constructor');
|
||||
this.filesUpload$ = new Observable(observer => this._filesUploadObserver = observer).share();
|
||||
this.totalCompleted$ = new Observable(observer => this._totalCompletedObserver = observer).share();
|
||||
this._alfrescoClient = this.getAlfrescoClient();
|
||||
}
|
||||
|
||||
@@ -195,6 +200,11 @@ export class UploadService {
|
||||
xmlHttpRequest.statusText,
|
||||
xmlHttpRequest.response
|
||||
);
|
||||
if (!uploadingFileModel.abort && !uploadingFileModel.error) {
|
||||
if (this._totalCompletedObserver) {
|
||||
this._totalCompletedObserver.next(++this.totalCompleted);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
return xmlHttpRequest;
|
||||
|
Reference in New Issue
Block a user