summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorPeter Grassberger <petertheone@gmail.com>2016-07-15 17:15:05 (GMT)
committerPeter Grassberger <petertheone@gmail.com>2016-07-15 17:15:05 (GMT)
commita5241e6b6c3371e1f1fb11bcfbd00390038d1589 (patch)
treee0f6a77c72517579d7b446af08dcf6477b90d510 /www
parenta3d0413c9c77e24254a3280dce17c6672a2b8cc3 (diff)
fix error render, update cart-number and name on progress
Diffstat (limited to 'www')
-rw-r--r--www/js/importer.js47
-rw-r--r--www/js/jingles.js32
-rw-r--r--www/js/musicpools.js33
-rw-r--r--www/js/shows.js41
4 files changed, 96 insertions, 57 deletions
diff --git a/www/js/importer.js b/www/js/importer.js
index cbea665..7e72150 100644
--- a/www/js/importer.js
+++ b/www/js/importer.js
@@ -247,7 +247,7 @@ Rdxport.Importer.prototype.getUploadByCartNumber = function(cartNumber) {
}
var upload = null;
$.each(this.uploads, function(index, currentUpload) {
- if (currentUpload.cartNumber === cartNumber) {
+ if (parseInt(currentUpload.cartNumber) === parseInt(cartNumber)) {
upload = currentUpload;
return false; //break;
}
@@ -274,7 +274,7 @@ Rdxport.Importer.prototype.getUploadsByCartNumber = function(cartNumber) {
return null;
}
return this.uploads.filter(function (currentUpload) {
- return currentUpload.cartNumber === cartNumber;
+ return currentUpload.cartNumber === parseInt(cartNumber);
});
};
@@ -300,10 +300,12 @@ Rdxport.Upload = function(fileOrsourceUri, group, groupView, cartNumber, useMeta
this.filename = fileOrsourceUri.name;
this.sourceUri = 'attachment://' + fileOrsourceUri.size + '/' + this.filename;
}
+ this.title = this.filename;
this.group = group;
this.groupView = groupView;
this.cartNumber = cartNumber;
+ this.cutNumber = null;
this.useMetadata = useMetadata;
this.uploadId = null;
@@ -332,37 +334,44 @@ Rdxport.Upload.prototype.onerror = function(error) {
console.log('error');
console.log(error);
- var file = {
- cartNumber: this.cartNumber
- };
- this.importFileUploadError(file, 500, error);
+ this.importFileUploadError(500, error);
};
Rdxport.Upload.prototype.onmessage = function(event) {
var data = $.parseJSON(event.data);
this.uploadId = data.ID;
- var file = {
- cartNumber: this.cartNumber
- };
switch (data.TYPE.toLowerCase()) {
case Rdxport.Importer.TYPE_ERROR:
+ this.importFileUploadError(data.RESPONSE_CODE, data.ERROR_STRING);
+ break;
+ case Rdxport.Importer.TYPE_ACK:
console.log(data);
- this.importFileUploadError(file, data.RESPONSE_CODE, data.ERROR_STRING);
+ this.groupView.uploadProgress(this);
break;
case Rdxport.Importer.TYPE_PROGRESS:
+ console.log(data);
this.uploadprogress.current = data.CURRENT;
this.uploadprogress.total = data.TOTAL;
this.uploadprogress.progress = data.PROGRESS;
this.uploadprogress.progress_step = data.PROGRESS_STEP;
this.uploadprogress.progress_step_name = data.PROGRESS_STEP_NAME;
- this.groupView.uploadProgress(this, file);
+ if (data.CART_NUMBER) {
+ this.cartNumber = data.CART_NUMBER;
+ }
+ if (data.CUT_NUMBER) {
+ this.cutNumber = data.CUT_NUMBER;
+ }
+ if (data.TITLE) {
+ this.title = data.TITLE;
+ }
+ this.groupView.uploadProgress(this);
break;
case Rdxport.Importer.TYPE_DONE:
console.log(data);
if(data.RESPONSE_CODE < 400) {
this.importFileUploadSuccess();
} else {
- this.importFileUploadError(file, data.RESPONSE_CODE, data.ERROR_STRING);
+ this.importFileUploadError(data.RESPONSE_CODE, data.ERROR_STRING);
}
break;
}
@@ -421,7 +430,7 @@ Rdxport.Upload.prototype.import = function() {
sendOptions.REFERENCE_ID = self.group.groupName + '/' + self.cartNumber + '/' + self.filename;
sendOptions.CART_NUMBER = parseInt(self.cartNumber);
} else if (self.group instanceof Rdxport.Musicpool) {
- sendOptions.REFERENCE_ID = self.group.groupName + '/' + '/' + self.filename;
+ sendOptions.REFERENCE_ID = self.group.groupName + '/' + self.filename;
sendOptions.MUSIC_POOL_GROUP = self.group.groupName;
}
console.log(sendOptions);
@@ -454,15 +463,16 @@ Rdxport.Upload.prototype.reconnect = function(id, reference) {
Rdxport.Upload.prototype.close = function() {
this.webSocket.close();
- this.group.fetchCarts();
importer.removeUpload(this);
+ this.group.fetchCarts();
};
Rdxport.Upload.prototype.cancel = function() {
this.webSocket.send(JSON.stringify({ COMMAND: 'cancel' }));
this.webSocket.close();
- this.group.fetchCarts();
+ // todo: only do this when i get "done"
importer.removeUpload(this);
+ this.group.fetchCarts();
};
Rdxport.Upload.prototype.importFileUploadSuccess = function() {
@@ -470,9 +480,10 @@ Rdxport.Upload.prototype.importFileUploadSuccess = function() {
this.group.fetchCarts();
};
-Rdxport.Upload.prototype.importFileUploadError = function(file, status, errorString) {
+Rdxport.Upload.prototype.importFileUploadError = function(status, errorString) {
+ this.uploadprogress.progress_step = 99; // makes isUploading return false
var self = this;
- this.groupView.uploadError(this, file, status, errorString, function() {
- self.cancel();
+ this.groupView.uploadError(this, status, errorString, function() {
+ self.close();
});
};
diff --git a/www/js/jingles.js b/www/js/jingles.js
index 04ae087..3475faf 100644
--- a/www/js/jingles.js
+++ b/www/js/jingles.js
@@ -116,11 +116,10 @@ Rdxport.JingleGroupView.prototype.destroy = function() {
$('table > tbody', this.$el).empty();
};
-Rdxport.JingleGroupView.prototype.uploadProgress = function(upload, file) {
+Rdxport.JingleGroupView.prototype.uploadProgress = function(upload) {
var $cut = $('tr[data-upload-id="' + upload.uploadId + '"]').first();
if (!$cut.hasClass('uploading')) {
var $progressBar = $('.progressBarTemplate.jingles').clone().removeClass('progressBarTemplate');
- $('.file-name', $progressBar).text(upload.filename);
$cut.html($progressBar.html());
$('button', $cut).on('click', function() {
@@ -129,14 +128,17 @@ Rdxport.JingleGroupView.prototype.uploadProgress = function(upload, file) {
$cut.addClass('uploading');
}
+ if (upload.title) {
+ $('.file-name', $cut).text(upload.title);
+ }
+ if (upload.cutNumber) {
+ $('.cut-number', $cut).text(upload.cutNumber);
+ }
updateProgressBar($cut, upload);
};
-Rdxport.JingleGroupView.prototype.uploadError = function(upload, file, status, errorString, acknowledge) {
- if (!file.cartNumber || !file.cutNumber) {
- return;
- }
+Rdxport.JingleGroupView.prototype.uploadError = function(upload, status, errorString, acknowledge) {
var reason = $('<span>').addClass('label').addClass('label-danger').text(status).after($('<b>').text(' ' + errorString));
var dismiss_button = '<button class="btn btn-info btn-xs">' +
@@ -146,19 +148,27 @@ Rdxport.JingleGroupView.prototype.uploadError = function(upload, file, status, e
.addClass('label-danger').html('<span class="glyphicon glyphicon-fire"></span>');
var $errorRow = $('<tr>')
- .attr('id', 'jingle-' + file.cartNumber + '-' + file.cutNumber)
+ .attr('data-upload-id', upload.uploadId)
.append($('<td>').html(status))
- .append($('<td>').text(file.cartNumber))
- .append($('<td>').addClass('file-name').text(upload.filename))
+ .append($('<td>').addClass('cut-number').text('...'))
+ .append($('<td>').addClass('file-name'))
.append($('<td>').append($('<b>').text('Import Fehler')))
.append($('<td colspan="1">').append(reason))
.append($('<td>').css('text-align', 'center').append(dismiss_button));
+ if (upload.cutNumber) {
+ $('.cut-number', $errorRow).text(upload.cutNumber);
+ }
+ if (upload.title) {
+ $('.file-name', $errorRow).text(upload.title);
+ }
+
$('button', $errorRow).on('click', function() {
acknowledge();
});
- $('#jingle-' + file.cartNumber + '-' + file.cutNumber).replaceWith($errorRow);
+ var $cart = $('tr[data-upload-id="' + upload.uploadId + '"]').first();
+ $cart.replaceWith($errorRow);
};
Rdxport.JingleCartView = function(model, groupView, active) {
@@ -244,7 +254,7 @@ Rdxport.JingleCutView.prototype.render = function() {
Rdxport.JingleCutView.renderUploading = function(upload) {
var $progressBar = $('.progressBarTemplate.jingles').clone().removeClass('progressBarTemplate');
- $('.file-name', $progressBar).text(upload.filename);
+ $('.file-name', $progressBar).text(upload.title);
var $el = $('<tr>')
.html($progressBar.html())
diff --git a/www/js/musicpools.js b/www/js/musicpools.js
index d96d537..2292aa1 100644
--- a/www/js/musicpools.js
+++ b/www/js/musicpools.js
@@ -187,12 +187,10 @@ Rdxport.MusicpoolView.prototype.render = function() {
});
};
-Rdxport.MusicpoolView.prototype.uploadProgress = function(upload, file) {
+Rdxport.MusicpoolView.prototype.uploadProgress = function(upload) {
var $cart = $('tr[data-upload-id="' + upload.uploadId + '"]').first();
if (!$cart.hasClass('uploading')) {
var $progressBar = $('.progressBarTemplate.musicpools').clone().removeClass('progressBarTemplate');
- $('.file-name', $progressBar).text(upload.filename);
- $('.cart-number', $progressBar).text(file.cartNumber);
$cart.html($progressBar.html());
$('button', $cart).on('click', function() {
@@ -201,32 +199,43 @@ Rdxport.MusicpoolView.prototype.uploadProgress = function(upload, file) {
$cart.addClass('uploading');
}
+ if (upload.title) {
+ $('.file-name', $cart).text(upload.title);
+ }
+ if (upload.cartNumber) {
+ $('.cart-number', $cart).text(upload.cartNumber);
+ }
updateProgressBar($cart, upload);
};
-Rdxport.MusicpoolView.prototype.uploadError = function(upload, file, status, errorString, acknowledge) {
- if (!file.cartNumber) {
- return;
- }
+Rdxport.MusicpoolView.prototype.uploadError = function(upload, status, errorString, acknowledge) {
var reason = $('<span>').addClass('label').addClass('label-danger').text(status).after($('<b>').text(' ' + errorString));
var dismiss_button = '<button class="btn btn-info btn-xs">' +
'<span class="glyphicon glyphicon-remove"></span>&nbsp;&nbsp;Ok</button>';
var $errorRow = $('<tr>')
- .attr('id', 'musicpool-' + file.cartNumber)
- .append($('<td>').text(file.cartNumber))
- .append($('<td>').addClass('file-name').text(upload.filename))
+ .attr('data-upload-id', upload.uploadId)
+ .append($('<td>').addClass('.cart-number').text('...'))
+ .append($('<td>').addClass('file-name'))
.append($('<td>').append($('<b>').text('Import Fehler')))
.append($('<td colspan="5">').append(reason))
.append($('<td>').css('text-align', 'center').append(dismiss_button));
+ if (upload.cartNumber) {
+ $('.cart-number', $errorRow).text(upload.cartNumber);
+ }
+ if (upload.title) {
+ $('.file-name', $errorRow).text(upload.title);
+ }
+
$('button', $errorRow).on('click', function() {
acknowledge();
});
- $('#musicpool-' + file.cartNumber).replaceWith($errorRow);
+ var $cart = $('tr[data-upload-id="' + upload.uploadId + '"]').first();
+ $cart.replaceWith($errorRow);
};
Rdxport.MusicpoolCartView = function(model) {
@@ -281,7 +290,7 @@ Rdxport.MusicpoolCartView.prototype.render = function() {
Rdxport.MusicpoolCartView.renderUploading = function(upload) {
var $progressBar = $('.progressBarTemplate.musicpools').clone().removeClass('progressBarTemplate');
- $('.file-name', $progressBar).text(upload.filename);
+ $('.file-name', $progressBar).text(upload.title);
var $el = $('<tr>')
.html($progressBar.html())
diff --git a/www/js/shows.js b/www/js/shows.js
index 82e38b5..7dc94d3 100644
--- a/www/js/shows.js
+++ b/www/js/shows.js
@@ -251,7 +251,7 @@ Rdxport.ShowView.prototype.render = function() {
var cart = self.model.getCartByNumber(log.cartNumber);
var upload = importer.getUploadByCartNumber(log.cartNumber);
if (upload) {
- $('#app-shows table > tbody').append(Rdxport.ShowCartView.renderUploading(upload, log.cartNumber));
+ $('#app-shows table > tbody').append(Rdxport.ShowCartView.renderUploading(upload));
} else if (cart) {
var cartView = new Rdxport.ShowCartView(cart, self);
self.cartViews.push(cartView);
@@ -263,12 +263,10 @@ Rdxport.ShowView.prototype.render = function() {
});
};
-Rdxport.ShowView.prototype.uploadProgress = function(upload, file) {
+Rdxport.ShowView.prototype.uploadProgress = function(upload) {
var $cart = $('tr[data-upload-id="' + upload.uploadId + '"]').first();
if (!$cart.hasClass('uploading')) {
var $progressBar = $('.progressBarTemplate.shows').clone().removeClass('progressBarTemplate');
- $('.file-name', $progressBar).text(file.name);
- $('.cart-number', $progressBar).text(file.cartNumber);
$cart.html($progressBar.html());
$('button', $cart).off('click').on('click', function() {
@@ -277,32 +275,43 @@ Rdxport.ShowView.prototype.uploadProgress = function(upload, file) {
$cart.addClass('uploading');
}
+ if (upload.title) {
+ $('.file-name', $cart).text(upload.title);
+ }
+ if (upload.cartNumber) {
+ $('.cart-number', $cart).text(upload.cartNumber);
+ }
updateProgressBar($cart, upload);
};
-Rdxport.ShowView.prototype.uploadError = function(upload, file, status, errorString, acknowledge) {
- if (!file.cartNumber) {
- return;
- }
+Rdxport.ShowView.prototype.uploadError = function(upload, status, errorString, acknowledge) {
var reason = $('<span>').addClass('label').addClass('label-danger').text(status).after($('<b>').text(' ' + errorString));
var dismiss_button = '<button class="btn btn-info btn-xs">' +
'<span class="glyphicon glyphicon-remove"></span>&nbsp;&nbsp;Ok</button>';
var $errorRow = $('<tr>')
- .attr("id", "show-cart-" + file.cartNumber)
- .append($('<td>').text(file.cartNumber))
- .append($('<td>').addClass('file-name').text(upload.filename))
+ .attr('data-upload-id', upload.uploadId)
+ .append($('<td>').addClass('.cart-number').text('...'))
+ .append($('<td>').addClass('file-name'))
.append($('<td>').append($('<b>').text('Import Fehler')))
.append($('<td colspan="3">').append(reason))
.append($('<td>').css('text-align', 'center').append(dismiss_button));
+ if (upload.cartNumber) {
+ $('.cart-number', $errorRow).text(upload.cartNumber);
+ }
+ if (upload.title) {
+ $('.file-name', $errorRow).text(upload.title);
+ }
+
$('button', $errorRow).off('click').on('click', function() {
acknowledge();
});
- $('#show-cart-' + file.cartNumber).replaceWith($errorRow);
+ var $cart = $('tr[data-upload-id="' + upload.uploadId + '"]').first();
+ $cart.replaceWith($errorRow);
};
Rdxport.ShowCartView = function(model, groupView) {
@@ -345,14 +354,14 @@ Rdxport.ShowCartView.prototype.render = function() {
.append($('<td>').css('text-align', 'center').append($deleteButton));
};
-Rdxport.ShowCartView.renderUploading = function(upload, cartNumber) {
+Rdxport.ShowCartView.renderUploading = function(upload) {
var $progressBar = $('.progressBarTemplate.shows').clone().removeClass('progressBarTemplate');
- $('.file-name', $progressBar).text(upload.filename);
- $('.cart-number', $progressBar).text(cartNumber);
+ $('.file-name', $progressBar).text(upload.title);
+ $('.cart-number', $progressBar).text(upload.cartNumber);
var $el = $('<tr>')
.html($progressBar.html())
- .attr('id', 'show-cart-' + cartNumber)
+ .attr('id', 'show-cart-' + upload.cartNumber)
.addClass('uploading')
.attr('data-upload-id', upload.uploadId);