Skip to content

Commit

Permalink
improve progress UI
Browse files Browse the repository at this point in the history
  • Loading branch information
joehand committed Feb 2, 2017
1 parent a7502f5 commit 31b8947
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = function sync (type, opts, dat) {
if (dat.owner && opts.import) {
debug('Importing updated & new files into archive')
// File Imports
progressOutput[2] = 'Importing new & updated files to archive...'
progressOutput[2] = 'Importing files...'

importStatus = dat.importFiles({
watch: opts.watch, // TODO: allow live: true. opts.live is used by archive.live though =(
Expand Down Expand Up @@ -125,7 +125,7 @@ module.exports = function sync (type, opts, dat) {
}

function updateImport () {
progressOutput[2] = importUI(importStatus)
progressOutput[3] = importUI(importStatus)
}

function updateNetwork () {
Expand Down
5 changes: 4 additions & 1 deletion lib/ui/import-progress.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
var Bar = require('./bar')
var prettyBytes = require('pretty-bytes')

module.exports = function () {
var bar = Bar()
var start = Date.now()
return function (importer) {
if (!importer || !importer.bytesImported) return ''
var importedBytes = importer.bytesImported
var speed = importer.bytesImported * 1000 / (Date.now() - start)
var progress = Math.round(importedBytes * 100 / importer.countStats.bytes)
return bar(progress) + ` ${importer.fileCount} ${importer.fileCount === 1 ? 'file' : 'files'} imported`
return bar(progress) + ` ${importer.fileCount} of ${importer.countStats.files} ${importer.countStats.files === 1 ? 'file' : 'files'}` + ' (' + prettyBytes(speed) + '/s' + ')'
}
}

0 comments on commit 31b8947

Please sign in to comment.