summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js')
-rw-r--r--www/js/importer.js45
-rw-r--r--www/js/jingles.js12
-rw-r--r--www/js/musicpools.js4
-rw-r--r--www/js/shows.js6
4 files changed, 35 insertions, 32 deletions
diff --git a/www/js/importer.js b/www/js/importer.js
index eacfd57..6dfba76 100644
--- a/www/js/importer.js
+++ b/www/js/importer.js
@@ -53,13 +53,13 @@ Rdxport.Importer.prototype.initListWebSocket = function() {
this.listWebSocket = new WebSocket(this.rhimpordEndpoint);
this.listWebSocket.onclose = function(code, reason) {
- console.log('close');
- console.log(code);
- console.log(reason);
+ //console.log('close');
+ //console.log(code);
+ //console.log(reason);
};
this.listWebSocket.onerror = function(error) {
- console.log('error');
+ //console.log('error');
console.log(error);
};
@@ -74,41 +74,39 @@ Rdxport.Importer.prototype.initListWebSocket = function() {
this.listWebSocket.onmessage = function(event) {
var data = $.parseJSON(event.data);
- console.log(data);
+ //console.log(data);
if (data.TYPE.toLowerCase() !== Rdxport.Importer.TYPE_LIST) {
return;
}
$.each(data.SESSIONS_ADDED, function(id, reference) {
- self.sessions[id] = reference;
+ self.sessions.push({id: id, reference: reference});
});
$.each(data.SESSIONS_REMOVED, function(id, reference) {
- delete self.sessions[id];
+ self.sessions = self.sessions.filter(function(element) {
+ return element.reference !== reference;
+ });
});
- console.log('sessions');
- console.log(self.sessions);
};
};
Rdxport.Importer.prototype.syncUploads = function(route, groupView, done) {
- console.log('syncUploads');
-
- var sessions = this.sessions.filter(function(reference) {
- var reference = reference.split('/');
+ var sessions = this.sessions.filter(function(session) {
+ var reference = session.reference.split('/');
return route === reference[0] && groupView.model.groupName === reference[1];
});
var self = this;
- $.each(sessions, function(id, reference) {
- if (importer.getUploadById(id) !== null) {
+ $.each(sessions, function(index, session) {
+ if (importer.getUploadById(session.id) !== null) {
return true; //continue;
}
- var reference = reference.split('/');
+ var reference = session.reference.split('/');
var cartNumber = reference[2];
var filename = reference[3];
var group = groupView.model;
- var upload = new Rdxport.Upload('/' + filename, group, groupView, cartNumber, cartNumber, null);
- upload.reconnect(id, reference);
+ var upload = new Rdxport.Upload('/' + filename, group, groupView, cartNumber, null);
+ upload.reconnect(session.id, session.reference);
self.uploads.push(upload);
});
if (done) {
@@ -355,9 +353,9 @@ Rdxport.Upload.prototype.isUploading = function() {
};
Rdxport.Upload.prototype.onclose = function(code, reason) {
- console.log('close');
- console.log(code);
- console.log(reason);
+ //console.log('close');
+ //console.log(code);
+ //console.log(reason);
};
Rdxport.Upload.prototype.onerror = function(error) {
@@ -375,7 +373,7 @@ Rdxport.Upload.prototype.onmessage = function(event) {
this.importFileUploadError(data.RESPONSE_CODE, data.ERROR_STRING);
break;
case Rdxport.Importer.TYPE_ACK:
- console.log(data);
+ //console.log(data);
this.group.fetchCarts();
this.groupView.uploadProgress(this);
break;
@@ -430,7 +428,7 @@ Rdxport.Upload.prototype.onmessage = function(event) {
end += chunkSize;
end = end > self.file.size ? self.file.size : end;
}
- }, 10);
+ }, 50);
}
};
@@ -525,6 +523,5 @@ Rdxport.Upload.prototype.importFileUploadError = function(status, errorString) {
this.errorString = errorString;
this.uploadprogress.progress_step = 99; // makes isUploading return false
- var self = this;
this.groupView.uploadError(this);
};
diff --git a/www/js/jingles.js b/www/js/jingles.js
index fd2ddf1..8d9ed86 100644
--- a/www/js/jingles.js
+++ b/www/js/jingles.js
@@ -85,13 +85,15 @@ Rdxport.JingleGroupView = function(model) {
var self = this;
$(this.model).on('update', function() {
- $('table > tbody', self.$el).empty();
+ importer.syncUploads('jingles', self, function() {
+ $('table > tbody', self.$el).empty();
- self.model.mainCart = self.model.carts[0];
- self.mainCartView = new Rdxport.JingleCartView(self.model.mainCart, self, true);
+ self.model.mainCart = self.model.carts[0];
+ self.mainCartView = new Rdxport.JingleCartView(self.model.mainCart, self, true);
- self.model.deactivateCart = self.model.carts[1];
- self.deactivateCartView = new Rdxport.JingleCartView(self.model.deactivateCart, self, false);
+ self.model.deactivateCart = self.model.carts[1];
+ self.deactivateCartView = new Rdxport.JingleCartView(self.model.deactivateCart, self, false);
+ });
});
this.model.fetchCarts();
diff --git a/www/js/musicpools.js b/www/js/musicpools.js
index 6e7f81c..c873eab 100644
--- a/www/js/musicpools.js
+++ b/www/js/musicpools.js
@@ -154,7 +154,9 @@ Rdxport.MusicpoolView = function(model) {
var self = this;
$(this.model).on('update', function() {
- self.render();
+ importer.syncUploads('musicpools', self, function() {
+ self.render();
+ });
});
};
diff --git a/www/js/shows.js b/www/js/shows.js
index b9eb834..b8f0c2a 100644
--- a/www/js/shows.js
+++ b/www/js/shows.js
@@ -216,7 +216,9 @@ Rdxport.ShowView = function(model) {
this.$el = null;
var self = this;
this.model.$this.off('update').on('update', function() {
- self.render();
+ importer.syncUploads('shows', self, function() {
+ self.render();
+ });
});
};
@@ -245,7 +247,7 @@ Rdxport.ShowView.prototype.render = function() {
this.cartViews = [];
var self = this;
- $(this.model.logs).each(function(index, log) {
+ $(self.model.logs).each(function(index, log) {
var cart = self.model.getCartByNumber(log.cartNumber);
var upload = importer.getUploadByCartNumber(log.cartNumber);
if (upload) {