From 2cee83d57009a37349d84e67ef2c42088ead4f90 Mon Sep 17 00:00:00 2001 From: Harvey Kandola Date: Tue, 26 Sep 2017 10:12:46 +0100 Subject: [PATCH] refactored, improved doc import routine to show progress --- gui/app/components/folder/space-view.js | 2 +- gui/app/components/folder/start-document.js | 30 +++++++++---------- .../components/folder/start-document.hbs | 6 ++++ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/gui/app/components/folder/space-view.js b/gui/app/components/folder/space-view.js index 15b8cced..a3a828a8 100644 --- a/gui/app/components/folder/space-view.js +++ b/gui/app/components/folder/space-view.js @@ -77,7 +77,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, AuthMixin, { }, onImport() { - // this.attrs.onRefresh(); + this.attrs.onRefresh(); }, onStartDocument() { diff --git a/gui/app/components/folder/start-document.js b/gui/app/components/folder/start-document.js index a705e932..91afb306 100644 --- a/gui/app/components/folder/start-document.js +++ b/gui/app/components/folder/start-document.js @@ -23,6 +23,7 @@ export default Ember.Component.extend(NotifierMixin, { templateService: service('template'), importedDocuments: [], savedTemplates: [], + importStatus: [], dropzone: null, newDocumentName: '', newDocumentNameMissing: computed.empty('newDocumentName'), @@ -69,7 +70,6 @@ export default Ember.Component.extend(NotifierMixin, { }, setupImport() { - console.log("setting up import"); // already done init? if (is.not.null(this.get('dropzone'))) { this.get('dropzone').destroy(); @@ -103,7 +103,7 @@ export default Ember.Component.extend(NotifierMixin, { console.log("Conversion failed for", x.name, x); // eslint-disable-line no-console }); - this.on("queuecomplete", function () {}); + // this.on("queuecomplete", function () {}); this.on("addedfile", function (file) { self.send('onDocumentImporting', file.name); @@ -146,30 +146,30 @@ export default Ember.Component.extend(NotifierMixin, { }, onDocumentImporting(filename) { - if (this.isDestroyed) { return; } - - this.send("showNotification", `Importing ${filename}`); - this.get('onHideStartDocument')(); - + let status = this.get('importStatus'); let documents = this.get('importedDocuments'); + + status.pushObject(`Converting ${filename}...`); documents.push(filename); - if (this.isDestroyed) { return; } + this.set('importStatus', status); this.set('importedDocuments', documents); }, onDocumentImported(filename /*, document*/ ) { - if (this.isDestroyed) { return; } - - this.send("showNotification", `${filename} ready`); - + let status = this.get('importStatus'); let documents = this.get('importedDocuments'); + + status.pushObject(`Successfully converted ${filename}`); documents.pop(filename); - if (this.isDestroyed) { return; } - + this.set('importStatus', status); this.set('importedDocuments', documents); - this.get('onImport')(); + + if (documents.length === 0) { + this.get('onHideStartDocument')(); + this.get('onImport')(); + } }, } }); diff --git a/gui/app/templates/components/folder/start-document.hbs b/gui/app/templates/components/folder/start-document.hbs index c57d4ad1..338fdd8a 100644 --- a/gui/app/templates/components/folder/start-document.hbs +++ b/gui/app/templates/components/folder/start-document.hbs @@ -39,4 +39,10 @@ Alternatively, click to select or drag-drop files
(doc, docx, md, markdown) +
+ {{#each importStatus as |status|}} +

{{status}}

+ {{/each}} +
+