Forráskód Böngészése

Progressbar improvements

Artur Paikin 9 éve
szülő
commit
07c22b1e1c

+ 17 - 12
src/plugins/Progress.js → src/plugins/Progressbar.js

@@ -8,7 +8,7 @@ import Plugin from './Plugin'
 export default class Progress extends Plugin {
 export default class Progress extends Plugin {
   constructor (core, opts) {
   constructor (core, opts) {
     super(core, opts)
     super(core, opts)
-    this.type = 'visualizer'
+    this.type = 'progress'
 
 
     // set default options
     // set default options
     const defaultOptions = {}
     const defaultOptions = {}
@@ -31,20 +31,25 @@ export default class Progress extends Plugin {
   initEvents () {
   initEvents () {
     this.core.emitter.on('progress', data => {
     this.core.emitter.on('progress', data => {
       const percentage = data.percentage
       const percentage = data.percentage
-      console.log('this is what the progress is: ' + percentage)
+      const plugin = data.plugin
+      console.log(`this is what the progress is: ${percentage}, and its set by ${plugin}`)
       this.progressBar(percentage)
       this.progressBar(percentage)
     })
     })
   }
   }
 
 
-  run (results) {
-    console.log({
-      class: 'Progress',
-      method: 'run',
-      results: results
-    })
-
-    this.initEvents()
-
-    return Promise.resolve(results)
+  // run (results) {
+  //   console.log({
+  //     class: 'Progress',
+  //     method: 'run',
+  //     results: results
+  //   })
+  //
+  //   this.initEvents()
+  //
+  //   return Promise.resolve(results)
+  // }
+
+  install() {
+    return this.initEvents()
   }
   }
 }
 }

+ 2 - 1
src/plugins/Tus10.js

@@ -72,7 +72,8 @@ export default class Tus10 extends Plugin {
 
 
         // Dispatch progress event
         // Dispatch progress event
         this.core.emitter.emit('progress', {
         this.core.emitter.emit('progress', {
-          percentage
+          plugin: this,
+          percentage: percentage
         })
         })
       },
       },
       onSuccess: () => {
       onSuccess: () => {

+ 2 - 2
src/plugins/index.js

@@ -7,7 +7,7 @@ import Dropbox from './Dropbox'
 import Formtag from './Formtag'
 import Formtag from './Formtag'
 
 
 // Visualizers
 // Visualizers
-import Progress from './Progress'
+import Progressbar from './Progressbar'
 
 
 // Uploaders
 // Uploaders
 import Tus10 from './Tus10'
 import Tus10 from './Tus10'
@@ -18,7 +18,7 @@ import TransloaditBasic from './TransloaditBasic'
 
 
 export default {
 export default {
   Plugin,
   Plugin,
-  Progress,
+  Progressbar,
   DragDrop,
   DragDrop,
   Dropbox,
   Dropbox,
   Formtag,
   Formtag,

+ 2 - 2
website/src/examples/dragdrop/app.es6

@@ -1,11 +1,11 @@
 import Uppy from 'uppy/core'
 import Uppy from 'uppy/core'
-import { DragDrop, Progress, Tus10 } from 'uppy/plugins'
+import { DragDrop, Progressbar, Tus10 } from 'uppy/plugins'
 
 
 const uppyOne = new Uppy({autoProceed: true, debug: true})
 const uppyOne = new Uppy({autoProceed: true, debug: true})
 uppyOne
 uppyOne
-  .use(Progress)
   .use(DragDrop, {target: '.UppyDragDrop-One'})
   .use(DragDrop, {target: '.UppyDragDrop-One'})
   .use(Tus10, {endpoint: 'http://master.tus.io:8080/files/', progress: '#UppyDragDrop-Two'})
   .use(Tus10, {endpoint: 'http://master.tus.io:8080/files/', progress: '#UppyDragDrop-Two'})
+  .use(Progressbar)
   .run()
   .run()
 
 
 // const uppyTwo = new Uppy({debug: true})
 // const uppyTwo = new Uppy({debug: true})