mirror of
https://github.com/documize/community.git
synced 2025-07-21 14:19:43 +02:00
refactored, improved doc import routine to show progress
This commit is contained in:
parent
a0a1dd396a
commit
2cee83d570
3 changed files with 22 additions and 16 deletions
|
@ -77,7 +77,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
||||||
},
|
},
|
||||||
|
|
||||||
onImport() {
|
onImport() {
|
||||||
// this.attrs.onRefresh();
|
this.attrs.onRefresh();
|
||||||
},
|
},
|
||||||
|
|
||||||
onStartDocument() {
|
onStartDocument() {
|
||||||
|
|
|
@ -23,6 +23,7 @@ export default Ember.Component.extend(NotifierMixin, {
|
||||||
templateService: service('template'),
|
templateService: service('template'),
|
||||||
importedDocuments: [],
|
importedDocuments: [],
|
||||||
savedTemplates: [],
|
savedTemplates: [],
|
||||||
|
importStatus: [],
|
||||||
dropzone: null,
|
dropzone: null,
|
||||||
newDocumentName: '',
|
newDocumentName: '',
|
||||||
newDocumentNameMissing: computed.empty('newDocumentName'),
|
newDocumentNameMissing: computed.empty('newDocumentName'),
|
||||||
|
@ -69,7 +70,6 @@ export default Ember.Component.extend(NotifierMixin, {
|
||||||
},
|
},
|
||||||
|
|
||||||
setupImport() {
|
setupImport() {
|
||||||
console.log("setting up import");
|
|
||||||
// already done init?
|
// already done init?
|
||||||
if (is.not.null(this.get('dropzone'))) {
|
if (is.not.null(this.get('dropzone'))) {
|
||||||
this.get('dropzone').destroy();
|
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
|
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) {
|
this.on("addedfile", function (file) {
|
||||||
self.send('onDocumentImporting', file.name);
|
self.send('onDocumentImporting', file.name);
|
||||||
|
@ -146,30 +146,30 @@ export default Ember.Component.extend(NotifierMixin, {
|
||||||
},
|
},
|
||||||
|
|
||||||
onDocumentImporting(filename) {
|
onDocumentImporting(filename) {
|
||||||
if (this.isDestroyed) { return; }
|
let status = this.get('importStatus');
|
||||||
|
|
||||||
this.send("showNotification", `Importing ${filename}`);
|
|
||||||
this.get('onHideStartDocument')();
|
|
||||||
|
|
||||||
let documents = this.get('importedDocuments');
|
let documents = this.get('importedDocuments');
|
||||||
|
|
||||||
|
status.pushObject(`Converting ${filename}...`);
|
||||||
documents.push(filename);
|
documents.push(filename);
|
||||||
|
|
||||||
if (this.isDestroyed) { return; }
|
this.set('importStatus', status);
|
||||||
this.set('importedDocuments', documents);
|
this.set('importedDocuments', documents);
|
||||||
},
|
},
|
||||||
|
|
||||||
onDocumentImported(filename /*, document*/ ) {
|
onDocumentImported(filename /*, document*/ ) {
|
||||||
if (this.isDestroyed) { return; }
|
let status = this.get('importStatus');
|
||||||
|
|
||||||
this.send("showNotification", `${filename} ready`);
|
|
||||||
|
|
||||||
let documents = this.get('importedDocuments');
|
let documents = this.get('importedDocuments');
|
||||||
|
|
||||||
|
status.pushObject(`Successfully converted ${filename}`);
|
||||||
documents.pop(filename);
|
documents.pop(filename);
|
||||||
|
|
||||||
if (this.isDestroyed) { return; }
|
this.set('importStatus', status);
|
||||||
|
|
||||||
this.set('importedDocuments', documents);
|
this.set('importedDocuments', documents);
|
||||||
|
|
||||||
|
if (documents.length === 0) {
|
||||||
|
this.get('onHideStartDocument')();
|
||||||
this.get('onImport')();
|
this.get('onImport')();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -39,4 +39,10 @@
|
||||||
Alternatively, click to select or drag-drop files <br/>(doc, docx, md, markdown)
|
Alternatively, click to select or drag-drop files <br/>(doc, docx, md, markdown)
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="import-status">
|
||||||
|
{{#each importStatus as |status|}}
|
||||||
|
<p>{{status}}</p>
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue