diff options
-rw-r--r-- | www/index.html | 1 | ||||
-rw-r--r-- | www/js/jingles.js | 29 | ||||
-rw-r--r-- | www/js/rivendell.js | 249 | ||||
-rw-r--r-- | www/js/rivendell.rh.js | 35 | ||||
-rw-r--r-- | www/js/shows.js | 45 |
5 files changed, 317 insertions, 42 deletions
diff --git a/www/index.html b/www/index.html index 084a183..4af12a1 100644 --- a/www/index.html +++ b/www/index.html @@ -21,6 +21,7 @@ <script src="/javascript/twitter-bootstrap/js/bootstrap-modal.min.js"></script> <script src="/js/dropzone.js"></script> <script src="/js/rivendell.js"></script> + <script src="/js/rivendell.rh.js"></script> <script src="/js/utils.js"></script> <script src="/js/clock.js"></script> <script src="/js/auth.js"></script> diff --git a/www/js/jingles.js b/www/js/jingles.js index 16fbf8d..112772d 100644 --- a/www/js/jingles.js +++ b/www/js/jingles.js @@ -27,7 +27,8 @@ var jinglesGroupList = null; var importer = null; function jingles_init() { - rivendell = new Rivendell.Rivendell(auth_username, auth_token); + rivendell = new Rivendell.Rivendell(auth_username, auth_token, '/rd-bin/rdxport.cgi'); + rivendell.setListDropboxesEndpoint('/rh-bin/listdropboxes.cgi'); importer = new Importer(); jinglesGroupList = new JingleGroupList(); jinglesGroupList.fetch(); @@ -38,6 +39,7 @@ function jingles_cleanup() { jinglesGroupList.destroy(); jinglesGroupList = null; } + rivendell = null; } var JingleGroupList = function() { @@ -50,12 +52,10 @@ var JingleGroupList = function() { }; JingleGroupList.prototype.fetch = function() { - console.log('JingleGroupList.prototype.fetchGroups'); this.groups = []; var self = this; - var command = { LOGIN_NAME: auth_username, PASSWORD: auth_token }; - $.post("/rh-bin/listdropboxes.cgi", command, function(groupsXml, status, req) { + rivendell.listDropboxes(function(groupsXml, status, req) { var dbs = $(groupsXml).find("dropboxList").children(); dbs.each(function(index, groupXml) { if ($('type', groupXml).text() !== 'jingle') { @@ -86,11 +86,10 @@ JingleGroupList.prototype.fetch = function() { self.groups.push(jingleGroup); }); - }, "xml"); + }); }; JingleGroupList.prototype.render = function() { - console.log('JingleGroupList.prototype.render'); $('#app-jingles .groups').html(''); $(this.groups).each(function(index, group) { group.render(); @@ -119,17 +118,14 @@ var JingleGroup = function(title, groupName, description, lowcart, highcart, nor }; JingleGroup.prototype.fetchCarts = function() { - console.log('JingleGroup.prototype.fetchCarts'); var self = this; - var command1 = { COMMAND: 7, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: this.lowcart, INCLUDE_CUTS: 1 }; - var command2 = { COMMAND: 7, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: this.highcart, INCLUDE_CUTS: 1 }; $.when( - $.post("/rd-bin/rdxport.cgi", command1, function(cartXml) { + rivendell.listCart(this.lowcart, 1, function(cartXml) { self.mainCart = self.createCartFromXml(cartXml, true); - }, "xml"), - $.post("/rd-bin/rdxport.cgi", command2, function(cartXml) { + }), + rivendell.listCart(this.highcart, 1, function(cartXml) { self.deactivateCart = self.createCartFromXml(cartXml, false); - }, "xml") + }) ).then(function() { $(self.mainCart).on('add', function() { $(self).trigger('add'); @@ -180,7 +176,6 @@ JingleGroup.prototype.createCartFromXml = function(cartXml, active) { }; JingleGroup.prototype.render = function() { - console.log('JingleGroup.prototype.render'); var self = this; this.$el = $('.jingleGroupTemplate').clone().removeClass('jingleGroupTemplate'); @@ -275,7 +270,6 @@ JingleCut.prototype.delete = function() { }; JingleCut.prototype.render = function() { - console.log('JingleCut.prototype.render'); var moveButton = $('<button class="btn btn-info btn-mini"><i class="icon-arrow-right icon-white"></i> Verschieben</button>'); var activateButton; @@ -341,8 +335,7 @@ var Importer = function() { Importer.prototype.importAddCut = function(cart, dz, file) { // todo: set additional parameters like DESCRIPTION here, when patch has been applied. - var data = { COMMAND: 10, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: cart.number, DESCRIPTION: 'test' }; - $.post("/rd-bin/rdxport.cgi", data, null, "xml").done(function(cutXml) { + rivendell.addCut(cart.number, function(cutXml) { var cutNumber = $(cutXml).find('cutNumber').text(); dz.on('sending', function(file, xhr, formData) { formData.append('COMMAND', 2); @@ -442,8 +435,6 @@ Importer.prototype.importFileSelectError = function(dropzone, file, msg) { }; Importer.prototype.showUploadModal = function(cart) { - console.log('Importer.prototype.showUploadModal'); - var uploadModal = $('#uploadModal'); $('div.modal-header h3', uploadModal).text("Datei auswählen..."); var form = $('<form>'); diff --git a/www/js/rivendell.js b/www/js/rivendell.js index 1531de2..7d0365c 100644 --- a/www/js/rivendell.js +++ b/www/js/rivendell.js @@ -24,9 +24,135 @@ var Rivendell = Rivendell || {}; -Rivendell.Rivendell = function(username, token) { +Rivendell.Rivendell = function(username, token, rdxportEndpoint) { this.username = username; - this.token = token + this.token = token; + this.rdxportEndpoint = rdxportEndpoint; +}; + +Rivendell.Rivendell.prototype.listLog = function(name, success) { + var command = { + COMMAND: 22, + LOGIN_NAME: this.username, + PASSWORD: this.token, + NAME: name + }; + return $.post(this.rdxportEndpoint, command, success, "xml"); +}; + +Rivendell.Rivendell.prototype.listLogs = function(success) { + var command = { + COMMAND: 20, + LOGIN_NAME: this.username, + PASSWORD: this.token + //todo: fix optionals + /*SERVICE_NAME: serviceName, + TRACKABLE: trackable*/ + }; + return $.post(this.rdxportEndpoint, command, success, "xml"); +}; + +Rivendell.Rivendell.prototype.listServices = function(success) { + var command = { + COMMAND: 21, + LOGIN_NAME: this.username, + PASSWORD: this.token + //todo: fix optionals + /*TRACKABLE: trackable*/ + }; + return $.post(this.rdxportEndpoint, command, success, "xml"); +}; + +Rivendell.Rivendell.prototype.listGroup = function(groupName, success) { + var command = { + COMMAND: 5, + LOGIN_NAME: this.username, + PASSWORD: this.token, + GROUP_NAME: groupName + }; + return $.post(this.rdxportEndpoint, command, success, "xml"); +}; + +Rivendell.Rivendell.prototype.listGroups = function(success) { + var command = { + COMMAND: 4, + LOGIN_NAME: this.username, + PASSWORD: this.token + }; + return $.post(this.rdxportEndpoint, command, success, "xml"); +}; + +Rivendell.Rivendell.prototype.listCart = function(cartNumber, includeCuts, success) { + var command = { + COMMAND: 7, + LOGIN_NAME: this.username, + PASSWORD: this.token, + CART_NUMBER: cartNumber, + INCLUDE_CUTS: includeCuts + }; + return $.post(this.rdxportEndpoint, command, success); +}; + +Rivendell.Rivendell.prototype.listCarts = function(groupName, includeCuts, success) { + var command = { + COMMAND: 6, + LOGIN_NAME: this.username, + PASSWORD: this.token, + GROUP_NAME: groupName, + INCLUDE_CUTS: includeCuts + }; + return $.post(this.rdxportEndpoint, command, success, "xml"); +}; + +Rivendell.Rivendell.prototype.addCart = function(groupName, type, cartNumber, success) { + var command = { + COMMAND: 12, + LOGIN_NAME: this.username, + PASSWORD: this.token, + GROUP_NAME: groupName, + TYPE: type, + CART_NUMBER: cartNumber + }; + return $.post(this.rdxportEndpoint, command, success, "xml"); +}; + +Rivendell.Rivendell.prototype.editCart = function(cartNumber, options, success) { + options.COMMAND = 14; + options.LOGIN_NAME = this.username; + options.PASSWORD = this.token; + options.CART_NUMBER = cartNumber; + return $.post(this.rdxportEndpoint, options, success, "xml"); +}; + +Rivendell.Rivendell.prototype.removeCart = function(cartNumber, success) { + var command = { + COMMAND: 13, + LOGIN_NAME: this.username, + PASSWORD: this.token, + CART_NUMBER: cartNumber + }; + return $.post(this.rdxportEndpoint, command, success, "xml"); +}; + +Rivendell.Rivendell.prototype.listCut = function(cartNumber, cutNumber, success) { + var command = { + COMMAND: 8, + LOGIN_NAME: this.username, + PASSWORD: this.token, + CART_NUMBER: cartNumber, + CUT_NUMBER: cutNumber + }; + return $.post(this.rdxportEndpoint, command, success, 'xml'); +}; + +Rivendell.Rivendell.prototype.listCuts = function(cartNumber, success) { + var command = { + COMMAND: 9, + LOGIN_NAME: this.username, + PASSWORD: this.token, + CART_NUMBER: cartNumber + }; + return $.post(this.rdxportEndpoint, command, success, 'xml'); }; Rivendell.Rivendell.prototype.addCut = function(cartNumber, success) { @@ -36,7 +162,16 @@ Rivendell.Rivendell.prototype.addCut = function(cartNumber, success) { PASSWORD: this.token, CART_NUMBER: cartNumber }; - return $.post("/rd-bin/rdxport.cgi", command, success, 'xml'); + return $.post(this.rdxportEndpoint, command, success, 'xml'); +}; + +Rivendell.Rivendell.prototype.editCut = function(cartNumber, cutNumber, options, success) { + options.COMMAND = 15; + options.LOGIN_NAME = this.username; + options.PASSWORD = this.token; + options.CART_NUMBER = cartNumber; + options.CUT_NUMBER = cutNumber; + return $.post(this.rdxportEndpoint, options, success, "xml"); }; Rivendell.Rivendell.prototype.removeCut = function(destinationCartNumber, destinationCutNumber, success) { @@ -47,11 +182,22 @@ Rivendell.Rivendell.prototype.removeCut = function(destinationCartNumber, destin CART_NUMBER: destinationCartNumber, CUT_NUMBER: destinationCutNumber }; - return $.post("/rd-bin/rdxport.cgi", command, success, 'xml'); + return $.post(this.rdxportEndpoint, command, success, 'xml'); }; +/** + * + * todo: copy description and other data. + * + * @param sourceCartNumber + * @param sourceCutNumber + * @param destinationCartNumber + * @param success + * @returns {*} + */ Rivendell.Rivendell.prototype.copyCut = function(sourceCartNumber, sourceCutNumber, destinationCartNumber, success) { + var self = this; var returnJqXHR; this.addCut(destinationCartNumber, function(data, textStatus, jqXHR) { @@ -91,5 +237,98 @@ Rivendell.Rivendell.prototype.copyAudio = function(sourceCartNumber, sourceCutNu DESTINATION_CART_NUMBER: destinationCartNumber, DESTINATION_CUT_NUMBER: destinationCutNumber }; - return $.post("/rd-bin/rdxport.cgi", command, success, 'xml'); + return $.post(this.rdxportEndpoint, command, success, 'xml'); +}; + +Rivendell.Rivendell.prototype.audioInfo = function(cartNumber, cutNumber, success) { + var command = { + COMMAND: 19, + LOGIN_NAME: this.username, + PASSWORD: this.token, + CART_NUMBER: cartNumber, + CUT_NUMBER: cutNumber + }; + return $.post(this.rdxportEndpoint, command, success, 'xml'); +}; + +Rivendell.Rivendell.prototype.audioStore = function(success) { + var command = { + COMMAND: 23, + LOGIN_NAME: this.username, + PASSWORD: this.token + }; + return $.post(this.rdxportEndpoint, command, success, 'xml'); +}; + +Rivendell.Rivendell.prototype.import = function(cartNumber, cutNumber, channels, normalizationLevel, autotrimLevel, + useMetadata, filename, success) { + var command = { + COMMAND: 2, + LOGIN_NAME: this.username, + PASSWORD: this.token, + CART_NUMBER: cartNumber, + CUT_NUMBER: cutNumber, + CHANNELS: channels, + NORMALIZATION_LEVEL: normalizationLevel, + AUTOTRIM_LEVEL: autotrimLevel, + USE_METADATA: useMetadata, + FILENAME: filename + }; + return $.post(this.rdxportEndpoint, command, success, 'xml'); +}; + +Rivendell.Rivendell.prototype.export = function(cartNumber, cutNumber, format, channels, sampleRate, bitRate, + quality, startPoint, endPoint, normalizationLevel, enableMetadata, + success) { + var command = { + COMMAND: 1, + LOGIN_NAME: this.username, + PASSWORD: this.token, + CART_NUMBER: cartNumber, + CUT_NUMBER: cutNumber, + FORMAT: format, + CHANNELS: channels, + SAMPLE_RATE: sampleRate, + BIT_RATE: bitRate, + QUALITY: quality, + START_POINT: startPoint, + END_POINT: endPoint, + NORMALIZATION_LEVEL: normalizationLevel, + ENABLE_METADATA: enableMetadata + }; + return $.post(this.rdxportEndpoint, command, success, 'xml'); +}; + +Rivendell.Rivendell.prototype.exportPeaks = function(cartNumber, cutNumber, success) { + var command = { + COMMAND: 16, + LOGIN_NAME: this.username, + PASSWORD: this.token, + CART_NUMBER: cartNumber, + CUT_NUMBER: cutNumber + }; + return $.post(this.rdxportEndpoint, command, success, 'xml'); +}; + +Rivendell.Rivendell.prototype.trimAudio = function(cartNumber, cutNumber, trimLevel, success) { + var command = { + COMMAND: 17, + LOGIN_NAME: this.username, + PASSWORD: this.token, + CART_NUMBER: cartNumber, + CUT_NUMBER: cutNumber, + TRIM_LEVEL: trimLevel + }; + return $.post(this.rdxportEndpoint, command, success, 'xml'); +}; + +Rivendell.Rivendell.prototype.deleteAudio = function(cartNumber, cutNumber, success) { + var command = { + COMMAND: 3, + LOGIN_NAME: this.username, + PASSWORD: this.token, + CART_NUMBER: cartNumber, + CUT_NUMBER: cutNumber + }; + return $.post(this.rdxportEndpoint, command, success, 'xml'); }; diff --git a/www/js/rivendell.rh.js b/www/js/rivendell.rh.js new file mode 100644 index 0000000..04897b0 --- /dev/null +++ b/www/js/rivendell.rh.js @@ -0,0 +1,35 @@ +/* + * rhwebimport + * + * Copyright (C) 2014-2015 Christian Pointner <equinox@helsinki.at> + * Copyright (C) 2015 Peter Grassberger <petertheone@gmail.at> + * + * This file is part of rhwebimport. + * + * rhwebimport is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * rhwebimport is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with rhwebimport. If not, see <http://www.gnu.org/licenses/>. + */ + +"use strict"; + +Rivendell.Rivendell.prototype.setListDropboxesEndpoint = function(listDropboxesEndpoint) { + this.listDropboxesEndpoint = listDropboxesEndpoint; +}; + +Rivendell.Rivendell.prototype.listDropboxes = function(success) { + var command = { + LOGIN_NAME: this.username, + PASSWORD: this.token + }; + return $.post(this.listDropboxesEndpoint, command, success, 'xml'); +}; diff --git a/www/js/shows.js b/www/js/shows.js index 33beb60..1dde924 100644 --- a/www/js/shows.js +++ b/www/js/shows.js @@ -20,6 +20,7 @@ * along with rhwebimport. If not, see <http://www.gnu.org/licenses/>. */ +var rivendell = null; var shows_currentid; var shows_list = []; var shows_current; @@ -29,21 +30,25 @@ var shows_clock; function shows_deleteCart(cart) { - data = { COMMAND: 13, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: cart }; - $.post("/rd-bin/rdxport.cgi", data, null, "xml").done(function() { shows_updateGroupCartInfo(cart); }); + rivendell.removeCart(cart, function() { + shows_updateGroupCartInfo(cart); + }); } function shows_importAddCut(cart, dz, file) { - data = { COMMAND: 10, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: cart }; - $.post("/rd-bin/rdxport.cgi", data, null, "xml").done(function() { dz.processQueue(); }) - .fail(function(xhr, status, err) { shows_importFileUploadError(cart, dz, file, err, xhr); }); + rivendell.addCut(cart, function() { + dz.processQueue(); + }).fail(function(xhr, status, err) { + shows_importFileUploadError(cart, dz, file, err, xhr); + }); } function shows_importAddCart(cart, dz, file) { - data = { COMMAND: 12, LOGIN_NAME: auth_username, PASSWORD: auth_token, - GROUP_NAME: shows_current.group.name, TYPE: 'audio', CART_NUMBER: cart }; - $.post("/rd-bin/rdxport.cgi", data, null, "xml").done(function() { shows_importAddCut(cart, dz, file); }) - .fail(function(xhr, status, err) { shows_importFileUploadError(cart, dz, file, err, xhr); }); + rivendell.addCart(shows_current.group.name, 'audio', cart, function() { + shows_importAddCut(cart, dz, file); + }).fail(function(xhr, status, err) { + shows_importFileUploadError(cart, dz, file, err, xhr); + }); } function shows_importCartCancel(cart, dz) { @@ -206,10 +211,13 @@ function shows_newImportErrorEntry(cart, msg) { } function shows_updateGroupCartInfo(cart) { - data = { COMMAND: 7, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: cart, INCLUDE_CUTS: 1 }; - $.post("/rd-bin/rdxport.cgi", data, shows_updateGroupCartList, "xml") - .fail(function() { delete shows_group_carts[cart]; shows_redrawCartEntry(cart); }) - .done(function() { shows_redrawCartEntry(cart); }); + rivendell.listCart(cart, 1, function(data) { + shows_updateGroupCartList(data); + shows_redrawCartEntry(cart); + }).fail(function() { + delete shows_group_carts[cart]; + shows_redrawCartEntry(cart); + }); } function shows_redrawCartEntry(cart) { @@ -223,7 +231,7 @@ function shows_updateCartListing() { }); } -function shows_updateGroupCartList(data, status, req) { +function shows_updateGroupCartList(data) { var cartlist = $(data).find("cartList"); var carts = cartlist.children(); carts.each(function() { @@ -268,12 +276,10 @@ function shows_showSelected() { $('#show-length').text(shows_current.length + ' Min.'); shows_log_carts = []; - data = { COMMAND: 22, LOGIN_NAME: auth_username, PASSWORD: auth_token, NAME: shows_current.log }; - lcd = $.post("/rd-bin/rdxport.cgi", data, shows_updateLogCartList, "xml"); + var lcd = rivendell.listLog(shows_current.log, shows_updateLogCartList); shows_group_carts = {}; - data = { COMMAND: 6, LOGIN_NAME: auth_username, PASSWORD: auth_token, GROUP_NAME: shows_current.group.name, INCLUDE_CUTS: 1 }; - gcd = $.post("/rd-bin/rdxport.cgi", data, shows_updateGroupCartList, "xml"); + var gcd = rivendell.listCarts(shows_current.group.name, 1, shows_updateGroupCartList); $.when(lcd, gcd).done( function(lcres, gcres) { @@ -322,6 +328,8 @@ function shows_updateList(data, status, req) { } function shows_init() { + rivendell = new Rivendell.Rivendell(auth_username, auth_token, '/rd-bin/rdxport.cgi'); + rivendell.setListDropboxesEndpoint('/rh-bin/listdropboxes.cgi'); shows_currentid = sessionStorage.getItem("shows_currentid"); shows_list = []; data = { LOGIN_NAME: auth_username, PASSWORD: auth_token }; @@ -337,4 +345,5 @@ function shows_cleanup() { shows_list = []; shows_group_carts = {}; shows_log_carts = []; + rivendell = null; } |