summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
authorPeter Grassberger <petertheone@gmail.com>2016-07-15 18:43:12 (GMT)
committerPeter Grassberger <petertheone@gmail.com>2016-07-15 18:43:12 (GMT)
commit75035692396e859a47677723e281deac925ba726 (patch)
tree09aec9e94163c249ddc1811d5fdad3066da46004 /www/js
parentdc711297eaf4fedb78dd685b8705d99bb2b84ef5 (diff)
fix socket import errors
Diffstat (limited to 'www/js')
-rw-r--r--www/js/importer.js37
-rw-r--r--www/js/jingles.js17
-rw-r--r--www/js/musicpools.js12
-rw-r--r--www/js/shows.js18
4 files changed, 64 insertions, 20 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);
};
diff --git a/www/js/jingles.js b/www/js/jingles.js
index 3475faf..6457b5a 100644
--- a/www/js/jingles.js
+++ b/www/js/jingles.js
@@ -117,6 +117,9 @@ Rdxport.JingleGroupView.prototype.destroy = function() {
};
Rdxport.JingleGroupView.prototype.uploadProgress = function(upload) {
+ if (!upload.uploadId) {
+ return;
+ }
var $cut = $('tr[data-upload-id="' + upload.uploadId + '"]').first();
if (!$cut.hasClass('uploading')) {
var $progressBar = $('.progressBarTemplate.jingles').clone().removeClass('progressBarTemplate');
@@ -138,8 +141,13 @@ Rdxport.JingleGroupView.prototype.uploadProgress = function(upload) {
updateProgressBar($cut, upload);
};
-Rdxport.JingleGroupView.prototype.uploadError = function(upload, status, errorString, acknowledge) {
- var reason = $('<span>').addClass('label').addClass('label-danger').text(status).after($('<b>').text(' ' + errorString));
+
+Rdxport.JingleGroupView.prototype.uploadError = function(upload) {
+ Rdxport.JingleGroupView.uploadError(upload);
+};
+
+Rdxport.JingleGroupView.uploadError = function(upload) {
+ var reason = $('<span>').addClass('label').addClass('label-danger').text(upload.errorStatus).after($('<b>').text(' ' + upload.errorString));
var dismiss_button = '<button class="btn btn-info btn-xs">' +
'<span class="glyphicon glyphicon-remove"></span>&nbsp;&nbsp;Ok</button>';
@@ -164,7 +172,7 @@ Rdxport.JingleGroupView.prototype.uploadError = function(upload, status, errorSt
}
$('button', $errorRow).on('click', function() {
- acknowledge();
+ upload.close();
});
var $cart = $('tr[data-upload-id="' + upload.uploadId + '"]').first();
@@ -192,6 +200,9 @@ Rdxport.JingleCartView = function(model, groupView, active) {
$(uploads).each(function(index, upload) {
var $el = Rdxport.JingleCutView.renderUploading(upload, self.model.number);
$('table > tbody', self.groupView.$el).append($el);
+ if (upload.error) {
+ Rdxport.JingleGroupView.uploadError(upload);
+ }
});
}
};
diff --git a/www/js/musicpools.js b/www/js/musicpools.js
index 2292aa1..c56ab78 100644
--- a/www/js/musicpools.js
+++ b/www/js/musicpools.js
@@ -179,6 +179,9 @@ Rdxport.MusicpoolView.prototype.render = function() {
$(uploads).each(function(index, upload) {
var $el = Rdxport.MusicpoolCartView.renderUploading(upload, self.model.number);
$('table > tbody', self.$el).append($el);
+ if (upload.error) {
+ self.uploadError(upload);
+ }
});
@@ -188,6 +191,9 @@ Rdxport.MusicpoolView.prototype.render = function() {
};
Rdxport.MusicpoolView.prototype.uploadProgress = function(upload) {
+ if (!upload.uploadId) {
+ return;
+ }
var $cart = $('tr[data-upload-id="' + upload.uploadId + '"]').first();
if (!$cart.hasClass('uploading')) {
var $progressBar = $('.progressBarTemplate.musicpools').clone().removeClass('progressBarTemplate');
@@ -209,8 +215,8 @@ Rdxport.MusicpoolView.prototype.uploadProgress = function(upload) {
updateProgressBar($cart, upload);
};
-Rdxport.MusicpoolView.prototype.uploadError = function(upload, status, errorString, acknowledge) {
- var reason = $('<span>').addClass('label').addClass('label-danger').text(status).after($('<b>').text(' ' + errorString));
+Rdxport.MusicpoolView.prototype.uploadError = function(upload) {
+ var reason = $('<span>').addClass('label').addClass('label-danger').text(upload.errorStatus).after($('<b>').text(' ' + upload.errorString));
var dismiss_button = '<button class="btn btn-info btn-xs">' +
'<span class="glyphicon glyphicon-remove"></span>&nbsp;&nbsp;Ok</button>';
@@ -231,7 +237,7 @@ Rdxport.MusicpoolView.prototype.uploadError = function(upload, status, errorStri
}
$('button', $errorRow).on('click', function() {
- acknowledge();
+ upload.close();
});
var $cart = $('tr[data-upload-id="' + upload.uploadId + '"]').first();
diff --git a/www/js/shows.js b/www/js/shows.js
index 7dc94d3..ccea2e5 100644
--- a/www/js/shows.js
+++ b/www/js/shows.js
@@ -252,6 +252,9 @@ Rdxport.ShowView.prototype.render = function() {
var upload = importer.getUploadByCartNumber(log.cartNumber);
if (upload) {
$('#app-shows table > tbody').append(Rdxport.ShowCartView.renderUploading(upload));
+ if (upload.error) {
+ self.uploadError(upload);
+ }
} else if (cart) {
var cartView = new Rdxport.ShowCartView(cart, self);
self.cartViews.push(cartView);
@@ -264,7 +267,10 @@ Rdxport.ShowView.prototype.render = function() {
};
Rdxport.ShowView.prototype.uploadProgress = function(upload) {
- var $cart = $('tr[data-upload-id="' + upload.uploadId + '"]').first();
+ if (!upload.uploadId) {
+ return;
+ }
+ var $cart = $('tr[data-upload-id="' + upload.uploadId + '"]', this.$el).first();
if (!$cart.hasClass('uploading')) {
var $progressBar = $('.progressBarTemplate.shows').clone().removeClass('progressBarTemplate');
$cart.html($progressBar.html());
@@ -285,8 +291,8 @@ Rdxport.ShowView.prototype.uploadProgress = function(upload) {
updateProgressBar($cart, upload);
};
-Rdxport.ShowView.prototype.uploadError = function(upload, status, errorString, acknowledge) {
- var reason = $('<span>').addClass('label').addClass('label-danger').text(status).after($('<b>').text(' ' + errorString));
+Rdxport.ShowView.prototype.uploadError = function(upload) {
+ var reason = $('<span>').addClass('label').addClass('label-danger').text(upload.errorStatus).after($('<b>').text(' ' + upload.errorString));
var dismiss_button = '<button class="btn btn-info btn-xs">' +
'<span class="glyphicon glyphicon-remove"></span>&nbsp;&nbsp;Ok</button>';
@@ -307,10 +313,11 @@ Rdxport.ShowView.prototype.uploadError = function(upload, status, errorString, a
}
$('button', $errorRow).off('click').on('click', function() {
- acknowledge();
+ upload.close();
});
- var $cart = $('tr[data-upload-id="' + upload.uploadId + '"]').first();
+ var $cart = $('tr[data-upload-id="' + upload.uploadId + '"]', this.$el).first();
+ console.log($('tr'));
$cart.replaceWith($errorRow);
};
@@ -370,6 +377,7 @@ Rdxport.ShowCartView.renderUploading = function(upload) {
});
updateProgressBar($el, upload);
+
return $el;
};