diff options
author | Peter Grassberger <petertheone@gmail.com> | 2016-07-15 18:43:12 (GMT) |
---|---|---|
committer | Peter Grassberger <petertheone@gmail.com> | 2016-07-15 18:43:12 (GMT) |
commit | 75035692396e859a47677723e281deac925ba726 (patch) | |
tree | 09aec9e94163c249ddc1811d5fdad3066da46004 /www/js/importer.js | |
parent | dc711297eaf4fedb78dd685b8705d99bb2b84ef5 (diff) |
fix socket import errors
Diffstat (limited to 'www/js/importer.js')
-rw-r--r-- | www/js/importer.js | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/www/js/importer.js b/www/js/importer.js index 39864a7..c7e13c7 100644 --- a/www/js/importer.js +++ b/www/js/importer.js @@ -182,14 +182,29 @@ Rdxport.Importer.prototype.openModal = function(group, groupView, cartNumber, us .removeAttr('disabled').focus(); } + $('form', this.$el).off('submit').on('submit', function(event) { + event.preventDefault(); + }); + $('.modal-body #sourceUri', this.$el).off().on('keyup change', function(event) { + $form = $(this).parent('form'); if ($(this).val() === '') { $('#uploadModal-confirm', self.$el).off('click').attr('disabled', 'disabled'); + $form.off('submit'); return; } $('.modal-body .drop', self.$el).css("background-image", "url('/img/dz-backdrop.png')"); $('.modal-body .drop form input[type="file"]', this.$el).val(''); - $('#uploadModal-confirm', self.$el).off('click').on('click', function() { + $form.off('submit').on('submit', function(event) { + event.preventDefault(); + handleSource(); + }); + $('#uploadModal-confirm', self.$el).off('click').on('click', function(event) { + event.preventDefault(); + handleSource(); + }).removeAttr('disabled'); + + function handleSource() { var sourceUri = $('.modal-body #sourceUri', self.$el).val(); var upload = new Rdxport.Upload(sourceUri, group, groupView, cartNumber, useMetadata); upload.import(); @@ -197,8 +212,7 @@ Rdxport.Importer.prototype.openModal = function(group, groupView, cartNumber, us self.$el.off('hide.bs.modal'); self.$el.modal('hide'); - }) - .removeAttr('disabled'); + } }); this.$el.modal({keyboard: true}); @@ -318,10 +332,14 @@ Rdxport.Upload = function(fileOrsourceUri, group, groupView, cartNumber, useMeta progress_step_name: '' }; this.sendingFile = false; + + this.error = false; + this.errorStatus = ''; + this.errorString = ''; }; Rdxport.Upload.prototype.isUploading = function() { - return this.file && this.uploadprogress.progress_step < 2; + return this.file && !this.error && this.uploadprogress.progress_step < 2; }; Rdxport.Upload.prototype.onclose = function(code, reason) { @@ -346,6 +364,7 @@ Rdxport.Upload.prototype.onmessage = function(event) { break; case Rdxport.Importer.TYPE_ACK: console.log(data); + this.group.fetchCarts(); this.groupView.uploadProgress(this); break; case Rdxport.Importer.TYPE_PROGRESS: @@ -435,8 +454,6 @@ Rdxport.Upload.prototype.import = function() { } console.log(sendOptions); this.send(JSON.stringify(sendOptions)); - - self.group.fetchCarts(); }; }; @@ -481,9 +498,11 @@ Rdxport.Upload.prototype.importFileUploadSuccess = function() { }; Rdxport.Upload.prototype.importFileUploadError = function(status, errorString) { + this.error = true; + this.errorStatus = status; + this.errorString = errorString; + this.uploadprogress.progress_step = 99; // makes isUploading return false var self = this; - this.groupView.uploadError(this, status, errorString, function() { - self.close(); - }); + this.groupView.uploadError(this); }; |