summaryrefslogtreecommitdiff
path: root/www/js/jingles.js
diff options
context:
space:
mode:
authorPeter Grassberger <petertheone@gmail.com>2016-06-27 23:07:42 (GMT)
committerPeter Grassberger <petertheone@gmail.com>2016-06-27 23:07:42 (GMT)
commitc208d100066d87c39ae5fa1287955998e10d5154 (patch)
tree0d6b571790c10b0816f15523cc309af957e358fe /www/js/jingles.js
parent03af1fed48370ddc4772709207f064c16191f5c1 (diff)
parentbd6186e7233de72b85c0566d12273ede449453b5 (diff)
Merge branch 'websocket2' into websocket
Diffstat (limited to 'www/js/jingles.js')
-rw-r--r--www/js/jingles.js44
1 files changed, 19 insertions, 25 deletions
diff --git a/www/js/jingles.js b/www/js/jingles.js
index e819570..64735f0 100644
--- a/www/js/jingles.js
+++ b/www/js/jingles.js
@@ -32,7 +32,7 @@ function jingles_init() {
}
function jingles_cleanup() {
- importer.cancelAllUploads();
+ importer.closeAllUploads();
if (jingleGroupListView) {
jingleGroupListView.destroy();
jingleGroupListView = null;
@@ -56,7 +56,6 @@ Rdxport.JingleGroupListView = function(model) {
};
Rdxport.JingleGroupListView.prototype.destroy = function() {
- var self = this;
$(this.jingleGroupViews).each(function(index, groupView) {
groupView.destroy();
});
@@ -109,7 +108,7 @@ Rdxport.JingleGroupView.prototype.render = function() {
$('table tbody tr', this.$el).remove();
$('.uploadButton', this.$el).on('click', function() {
- importer.openModal(self.model, self, false, null, false);
+ importer.openModal(self.model, self, self.model.carts[0].number, null, false);
});
};
@@ -118,14 +117,10 @@ Rdxport.JingleGroupView.prototype.destroy = function() {
};
Rdxport.JingleGroupView.prototype.uploadProgress = function(upload, file) {
- if (!file.cartNumber || !file.cutNumber) {
- return;
- }
- var $cut = $('#jingle-' + file.cartNumber + '-' + file.cutNumber).first();
+ var $cut = $('tr[data-upload-id="' + upload.uploadId + '"]').first();
if (!$cut.hasClass('uploading')) {
var $progressBar = $('.progressBarTemplate.jingles').clone().removeClass('progressBarTemplate');
- $('.file-name', $progressBar).text(file.name);
- $('.cart-number', $progressBar).text(file.cartNumber);
+ $('.file-name', $progressBar).text(upload.filename);
$cut.html($progressBar.html());
$('button', $cut).on('click', function() {
@@ -161,7 +156,7 @@ Rdxport.JingleGroupView.prototype.uploadError = function(upload, file, msg, xhr,
.attr('id', 'jingle-' + file.cartNumber + '-' + file.cutNumber)
.append($('<td>').html(status))
.append($('<td>').text(file.cartNumber))
- .append($('<td>').addClass('file-name').text(file.name))
+ .append($('<td>').addClass('file-name').text(upload.filename))
.append($('<td>').append($('<b>').text('Import Fehler')))
.append($('<td colspan="1">').append(reason))
.append($('<td>').css('text-align', 'center').append(dismiss_button));
@@ -190,6 +185,11 @@ Rdxport.JingleCartView = function(model, groupView, active) {
$('table > tbody', self.groupView.$el).append(cutView.$el);
});
+ var uploads = importer.getUploadsByCartNumber(this.model.number);
+ $(uploads).each(function(index, upload) {
+ var $el = Rdxport.JingleCutView.renderUploading(upload, self.model.number);
+ $('table > tbody', self.groupView.$el).append($el);
+ });
}
};
@@ -198,13 +198,7 @@ Rdxport.JingleCutView = function(model) {
this.$spinner = null;
this.$el = null;
-
- var upload = null;
- if ((upload = importer.getUploadByCartAndCutNumber(this.model.cartNumber, this.model.number)) !== null) {
- this.renderUploading(upload);
- } else {
- this.render();
- }
+ this.render();
};
Rdxport.JingleCutView.prototype.render = function() {
@@ -255,21 +249,21 @@ Rdxport.JingleCutView.prototype.render = function() {
);
};
-Rdxport.JingleCutView.prototype.renderUploading = function(upload) {
+Rdxport.JingleCutView.renderUploading = function(upload) {
var $progressBar = $('.progressBarTemplate.jingles').clone().removeClass('progressBarTemplate');
- $('.file-name', $progressBar).text(this.model.name);
- $('.cart-number', $progressBar).text(this.model.number);
+ $('.file-name', $progressBar).text(upload.filename);
- this.$el = $('<tr>')
- .attr('id', 'jingle-' + this.model.cartNumber + '-' + this.model.number)
+ var $el = $('<tr>')
.html($progressBar.html())
- .addClass('uploading');
+ .addClass('uploading')
+ .attr('data-upload-id', upload.uploadId);
- $('button', this.$el).on('click', function() {
+ $('button', $el).on('click', function() {
upload.cancel();
});
- updateProgressBar(this.$el, upload);
+ updateProgressBar($el, upload);
+ return $el;
};
Rdxport.JingleCutView.prototype.move = function() {