Skip to content

Commit 212bda7

Browse files
authored
Merge pull request #57 from TessyPowder/master
Add summary progress bar and counter for uploaded chunks
2 parents ca7992e + 89633d4 commit 212bda7

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

js/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']);

templates/main.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<a class="btn btn-small btn-danger" ng-click="$flow.pause()"><?= $l->t('Pause'); ?></a>
1818
<a class="btn btn-small btn-info" ng-click="$flow.cancel()"><?= $l->t('Cancel'); ?></a>
1919
<span class="label label-info"><?= $l->t('Size'); ?>: {{$flow.getSize() | bytes}}</span>
20+
<span class="label label-info" ng-if="$flow.getFilesCount() != 0"><?= $l->t('Progress'); ?>: {{$flow.progress()*100 | number:2}}%</span>
2021
<span class="label label-info" ng-if="$flow.isUploading()"><?= $l->t('Uploading'); ?>...</span>
2122
</p>
2223
<table class="table table-hover table-bordered table-striped" flow-transfers>
@@ -32,7 +33,7 @@
3233
<tr ng-repeat="file in transfers">
3334
<td>{{$index+1}}</td>
3435
<td title="UID: {{file.uniqueIdentifier}}">{{file.relativePath}}</td>
35-
<td title="Chunks: {{file.chunks.length}}"><span ng-if="file.isUploading()">{{file.size*file.progress() | bytes}}/</span>{{file.size | bytes}}</td>
36+
<td title="Chunks: {{file.completeChunks()}} / {{file.chunks.length}}"><span ng-if="file.isUploading()">{{file.size*file.progress() | bytes}}/</span>{{file.size | bytes}}</td>
3637
<td>
3738
<div class="btn-group" ng-if="!file.isComplete() || file.error">
3839
<progress max="1" value="{{file.progress()}}" title="{{file.progress()}}" ng-if="file.isUploading()" style="width:auto; height:auto; display:inline"></progress>

0 commit comments

Comments
 (0)