summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Grassberger <petertheone@gmail.com>2016-01-31 16:52:43 (GMT)
committerPeter Grassberger <petertheone@gmail.com>2016-01-31 16:52:43 (GMT)
commite17fe1ce46af9990862f2e5f93064f4a9e4cbfd8 (patch)
tree061d2f949fb303e153f8e52d612b5a9cc1a8c8a6
parentf306d3578d0ec18e34df3b7ed30e20fa71339bf6 (diff)
musicpools: show carts/cuts, actions still missing
-rw-r--r--www/index.html4
-rw-r--r--www/js/importer.js26
-rw-r--r--www/js/jingles.js2
-rw-r--r--www/js/musicpools.js73
-rw-r--r--www/js/rivendell.js11
-rw-r--r--www/js/utils.js23
6 files changed, 105 insertions, 34 deletions
diff --git a/www/index.html b/www/index.html
index f2fce51..754eed7 100644
--- a/www/index.html
+++ b/www/index.html
@@ -319,6 +319,10 @@
<tr>
<th>Cart #</th>
<th>Titel</th>
+ <th>Länge</th>
+ <th>importiert</th>
+ <th># gespielt</th>
+ <th>zuletzt gespielt</th>
<th>Aktionen</th>
</tr>
</thead>
diff --git a/www/js/importer.js b/www/js/importer.js
index d2c1e3b..25924fb 100644
--- a/www/js/importer.js
+++ b/www/js/importer.js
@@ -34,13 +34,17 @@ Rivendell.Importer.prototype.resetModal = function() {
$('#uploadModal-confirm', this.$el).attr('disabled','disabled').off('click');
};
-Rivendell.Importer.prototype.openModal = function(group, createCart) {
+Rivendell.Importer.prototype.openModal = function(group, createCart, useMetadata) {
this.resetModal();
if (createCart === undefined) {
createCart = false;
}
+ if (useMetadata === undefined) {
+ useMetadata = false;
+ }
+
var $form = $('<form>');
var self = this;
$form.dropzone({
@@ -55,7 +59,7 @@ Rivendell.Importer.prototype.openModal = function(group, createCart) {
autoProcessQueue: false,
init: function() {
this.on('addedfile', function(file) {
- self.importFileAdded(this, file, group, createCart);
+ self.importFileAdded(this, file, group, createCart, useMetadata);
});
this.on('error', function(file, msg) {
self.importFileSelectError(this, file, msg);
@@ -67,7 +71,7 @@ Rivendell.Importer.prototype.openModal = function(group, createCart) {
this.$el.modal({keyboard: true});
};
-Rivendell.Importer.prototype.importFileAdded = function(dropzone, file, group, createCart) {
+Rivendell.Importer.prototype.importFileAdded = function(dropzone, file, group, createCart, useMetadata) {
// wtf? remove accepted files?
/*$(dropzone.getAcceptedFiles()).each(function(index, elem) {
dropzone.removeFile(elem);
@@ -78,7 +82,7 @@ Rivendell.Importer.prototype.importFileAdded = function(dropzone, file, group, c
var self = this;
$('#uploadModal-confirm', this.$el).off('click').on('click', function() {
- self.importCartConfirm(dropzone, group, createCart);
+ self.importCartConfirm(dropzone, group, createCart, useMetadata);
}).removeAttr('disabled');
};
@@ -87,7 +91,7 @@ Rivendell.Importer.prototype.importFileSelectError = function(dropzone, file, ms
dropzone.removeFile(file);
};
-Rivendell.Importer.prototype.importCartConfirm = function(dropzone, group, createCart) {
+Rivendell.Importer.prototype.importCartConfirm = function(dropzone, group, createCart, useMetadata) {
this.$el.modal('hide');
//var progressBar = group.addUpload();
@@ -120,11 +124,11 @@ Rivendell.Importer.prototype.importCartConfirm = function(dropzone, group, creat
if (createCart) {
rivendell.addCart(group.groupName, 'audio', null, function(cartXML) {
var cart = new Rivendell.Cart(cartXML, group);
- self.importAddCut(dropzone, group, files[0], createCart, cart);
+ self.importAddCut(dropzone, group, files[0], createCart, cart, useMetadata);
});
} else {
var cart = group.mainCart;
- self.importAddCut(dropzone, group, files[0], createCart, cart);
+ self.importAddCut(dropzone, group, files[0], createCart, cart, useMetadata);
}
};
@@ -171,7 +175,7 @@ Rivendell.Importer.prototype.importFileUploadError = function(dropzone, file, ms
dropzone.disable();
};
-Rivendell.Importer.prototype.importAddCut = function(dropzone, group, file, createCart, cart) {
+Rivendell.Importer.prototype.importAddCut = function(dropzone, group, file, createCart, cart, useMetadata) {
rivendell.addAndEditCut(cart.number, {DESCRIPTION: file.name}, function(cutXml) {
group.fetchCarts();
dropzone.on('sending', function(file, xhr, formData) {
@@ -194,7 +198,11 @@ Rivendell.Importer.prototype.importAddCut = function(dropzone, group, file, crea
formData.append('CHANNELS', 2);
formData.append('NORMALIZATION_LEVEL', cart.normlevel);
formData.append('AUTOTRIM_LEVEL', cart.trimlevel);
- formData.append('USE_METADATA', 0); // don't set USE_METADATA 1 for jingles
+ if (useMetadata) {
+ formData.append('USE_METADATA', 1);
+ } else {
+ formData.append('USE_METADATA', 0);
+ }
});
dropzone.processQueue();
}).fail(function(xhr, status, err) {
diff --git a/www/js/jingles.js b/www/js/jingles.js
index bd3b182..8d6ae38 100644
--- a/www/js/jingles.js
+++ b/www/js/jingles.js
@@ -112,7 +112,7 @@ Rivendell.JingleGroupView.prototype.render = function() {
$('table tbody tr', this.$el).remove();
$('.uploadButton', this.$el).on('click', function() {
- importer.openModal(self.model, false);
+ importer.openModal(self.model, false, false);
});
};
diff --git a/www/js/musicpools.js b/www/js/musicpools.js
index 1e9025f..b9f9107 100644
--- a/www/js/musicpools.js
+++ b/www/js/musicpools.js
@@ -102,10 +102,10 @@ Rivendell.MusicpoolsView.prototype.updateSelector = function() {
$musicpoolSelector.on('change', function() {
self.setCurrentPoolId($('option:selected', $musicpoolSelector).attr('value'));
- self.getCurrentPoolView().render();
+ self.getCurrentPoolView().model.fetchCarts();
});
- this.getCurrentPoolView().render();
+ this.getCurrentPoolView().model.fetchCarts();
};
Rivendell.Musicpool = function(groupName, description, lowcart, highcart, normlevel, trimlevel, title, clock) {
@@ -124,30 +124,77 @@ Rivendell.Musicpool.prototype.constructor = Rivendell.Musicpool;
Rivendell.MusicpoolView = function(model) {
this.model = model;
+ this.cartViews = [];
this.$el = null;
+
+ var self = this;
+ $(this.model).on('update', function() {
+ self.render();
+ });
};
Rivendell.MusicpoolView.prototype.render = function() {
var self = this;
- $(this.model).on('update', function() {
- self.$el = $('#hiddenTemplates .musicpoolTemplate').clone().removeClass('musicpoolTemplate');
- $('#app-musicpools .musicpoolContainer').html(self.$el);
- $('h2', self.$el).html(self.model.title);
- $('table tbody tr', self.$el).remove();
+ this.$el = $('#hiddenTemplates .musicpoolTemplate').clone().removeClass('musicpoolTemplate');
+ $('#app-musicpools .musicpoolContainer').html(this.$el);
- // todo
- $('.uploadButton', self.$el).on('click', function() {
- importer.openModal(self.model, true);
- });
+ $('h2', this.$el).html(this.model.title);
+ $('table tbody tr', this.$el).remove();
+
+ this.cartViews = [];
+ $(this.model.carts).each(function(index, cart) {
+ var cartView = new Rivendell.MusicpoolCartView(cart);
+ self.cartViews.push(cartView);
+ $('table > tbody', self.$el).append(cartView.$el);
+ });
+
+ // todo
+ $('.uploadButton', this.$el).on('click', function() {
+ importer.openModal(self.model, true, true);
});
- this.model.fetchCarts();
};
-Rivendell.MusicpoolCutView = function(model) {
+Rivendell.MusicpoolCartView = function(model) {
this.model = model;
this.$el = null;
+
+ this.render();
};
+
+Rivendell.MusicpoolCartView.prototype.render = function() {
+ var number = this.model.number;
+ var title = this.model.title;
+
+ var length = '-';
+ var imported = '-';
+ var playcnt = '-';
+ var lastplayed = '-';
+
+ if (this.model.cuts.length > 0) {
+ var cut = this.model.cuts[0];
+
+ //title = this.model.cuts[0].description;
+
+ length = msToTimeString(Number(cut.length));
+ imported = format_datetime(new Date(cut.originDatetime));
+ playcnt = cut.playcnt;
+ lastplayed = format_datetime(new Date(cut.lastPlayDatetime));
+ }
+
+ //todo
+ var actions = '';
+
+ this.$el = $('<tr>')
+ .append($('<td>').text(number))
+ .append($('<td>').text(title))
+ .append($('<td>').text(length))
+ .append($('<td>').text(imported))
+ .append($('<td>').text(playcnt))
+ .append($('<td>').text(lastplayed))
+ .append($('<td>').text(actions));
+};
+
diff --git a/www/js/rivendell.js b/www/js/rivendell.js
index 6e5d099..8566094 100644
--- a/www/js/rivendell.js
+++ b/www/js/rivendell.js
@@ -432,18 +432,27 @@ Rivendell.Cart.prototype.removeCut = function(cut) {
});
};
-Rivendell.Cut = function(name, description, cart) {
+Rivendell.Cut = function(name, description, cart, length, originDatetime,
+ playCounter, lastPlayDatetime) {
this.xml = null;
if (arguments.length === 2) {
this.xml = arguments[0];
this.name = $('cutName', this.xml).text();
this.description = $('description', this.xml).text();
+ this.length = $('length', this.xml).text();
+ this.originDatetime = $('originDatetime', this.xml).text();
+ this.playCounter = $('playCounter', this.xml).text();
+ this.lastPlayDatetime = $('lastPlayDatetime', this.xml).text();
this.cart = arguments[1];
} else {
this.name = name;
this.description = description;
this.cart = cart;
+ this.length = length;
+ this.originDatetime = originDatetime;
+ this.playCounter = playCounter;
+ this.lastPlayDatetime = lastPlayDatetime;
}
this.number = this.name.substr(-3);
this.cartNumber = this.cart.number;
diff --git a/www/js/utils.js b/www/js/utils.js
index 8a7ee9c..b8bfee7 100644
--- a/www/js/utils.js
+++ b/www/js/utils.js
@@ -53,17 +53,20 @@ weekday[6] = 'Samstag';
var weekday_short = new Array('So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa');
function format_datetime(d) {
- if(Object.prototype.toString.call(d) === '[object Date]') {
- var datetimestr = weekday_short[d.getDay()];
- datetimestr += ' ' + Number(d.getDate()).pad(2);
- datetimestr += '.' + Number(d.getMonth() + 1).pad(2);
- datetimestr += '.' + d.getFullYear();
- datetimestr += ' ' + Number(d.getHours()).pad(2);
- datetimestr += ':' + Number(d.getMinutes()).pad(2);
- datetimestr += ':' + Number(d.getSeconds()).pad(2);
- return datetimestr;
+ if(Object.prototype.toString.call(d) !== '[object Date]') {
+ return d;
}
- return d;
+ if (d.toString() === 'Invalid Date') {
+ return d;
+ }
+ var datetimestr = weekday_short[d.getDay()];
+ datetimestr += ' ' + Number(d.getDate()).pad(2);
+ datetimestr += '.' + Number(d.getMonth() + 1).pad(2);
+ datetimestr += '.' + d.getFullYear();
+ datetimestr += ' ' + Number(d.getHours()).pad(2);
+ datetimestr += ':' + Number(d.getMinutes()).pad(2);
+ datetimestr += ':' + Number(d.getSeconds()).pad(2);
+ return datetimestr;
}
function msToTimeString(time) {