Skip to content

Commit 0fa10c4

Browse files
authored
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: e-alfred/flowupload#57
1 parent f7815f6 commit 0fa10c4

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

dist/ng-flow-standalone.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,16 @@
638638
return ret;
639639
},
640640

641+
/**
642+
* Returns the count of files in the queue
643+
* @function
644+
* @returns {number}
645+
*/
646+
getFilesCount: function () {
647+
var count = this.files.length;
648+
return count;
649+
},
650+
641651
/**
642652
* Returns the total size of all files in bytes.
643653
* @function
@@ -968,6 +978,22 @@
968978
return this._prevProgress;
969979
},
970980

981+
/**
982+
* Get current number of complete chunks
983+
* @function
984+
* @returns {number} from 0 to chunks.length
985+
*/
986+
completeChunks: function () {
987+
var completeChunks = 0;
988+
989+
each(this.chunks, function (c) {
990+
if(c.progress() === 1){
991+
completeChunks++;
992+
}
993+
});
994+
return completeChunks;
995+
},
996+
971997
/**
972998
* Indicates if file is being uploaded at the moment
973999
* @function
@@ -1922,4 +1948,4 @@ angular.module('flow.transfers', ['flow.init'])
19221948
};
19231949
}]);
19241950
angular.module('flow', ['flow.provider', 'flow.init', 'flow.events', 'flow.btn',
1925-
'flow.drop', 'flow.transfers', 'flow.img', 'flow.dragEvents']);
1951+
'flow.drop', 'flow.transfers', 'flow.img', 'flow.dragEvents']);

0 commit comments

Comments
 (0)