From 0fa10c4dedc7a2e5aed8593f2c49f36dde9a493a Mon Sep 17 00:00:00 2001 From: e-alfred Date: Tue, 14 May 2019 18:35:20 +0200 Subject: [PATCH] Add a overall files count and uploaded chunk function I am the maintainer of the Flowupload app for Nextcloud which uses ng-flow extensively. Recently @TessyPowder added two functions to ng-flow which adds a counter for all files and a function to count already uploaded chunks. I would like to bring these changes to upstream so other projects can use them as well and so they are in the right place. The original PR on my repository can be found here: https://github.com/e-alfred/flowupload/pull/57 --- dist/ng-flow-standalone.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/dist/ng-flow-standalone.js b/dist/ng-flow-standalone.js index a376676..b969e39 100644 --- a/dist/ng-flow-standalone.js +++ b/dist/ng-flow-standalone.js @@ -638,6 +638,16 @@ return ret; }, + /** + * Returns the count of files in the queue + * @function + * @returns {number} + */ + getFilesCount: function () { + var count = this.files.length; + return count; + }, + /** * Returns the total size of all files in bytes. * @function @@ -968,6 +978,22 @@ return this._prevProgress; }, + /** + * Get current number of complete chunks + * @function + * @returns {number} from 0 to chunks.length + */ + completeChunks: function () { + var completeChunks = 0; + + each(this.chunks, function (c) { + if(c.progress() === 1){ + completeChunks++; + } + }); + return completeChunks; + }, + /** * Indicates if file is being uploaded at the moment * @function @@ -1922,4 +1948,4 @@ angular.module('flow.transfers', ['flow.init']) }; }]); angular.module('flow', ['flow.provider', 'flow.init', 'flow.events', 'flow.btn', - 'flow.drop', 'flow.transfers', 'flow.img', 'flow.dragEvents']); \ No newline at end of file + 'flow.drop', 'flow.transfers', 'flow.img', 'flow.dragEvents']);