Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Martin Konecny 2012-01-16 13:58:45 -05:00
commit 54ee177f7d
73 changed files with 8423 additions and 518 deletions

View file

@ -1,13 +1,17 @@
var dTable;
var checkedCount = 0;
var checkedPLCount = 0;
//used by jjmenu
function getId() {
var tr_id = $(this.triggerElement).attr("id");
var tr_id = $(this.triggerElement).parent().attr("id");
tr_id = tr_id.split("_");
return tr_id[1];
}
function getType() {
var tr_id = $(this.triggerElement).attr("id");
var tr_id = $(this.triggerElement).parent().attr("id");
tr_id = tr_id.split("_");
return tr_id[0];
@ -30,8 +34,20 @@ function deleteAudioClip(json) {
return;
}
deleteItem("au", json.id);
if (json.ids != undefined) {
for (var i = json.ids.length - 1; i >= 0; i--) {
deleteItem("au", json.ids[i]);
}
} else if (json.id != undefined) {
deleteItem("au", json.id);
}
location.reload(true);
}
function confirmDeleteGroup() {
if(confirm('Are you sure you want to delete the selected items?')){
groupDelete();
}
}
//callbacks called by jjmenu
@ -73,11 +89,17 @@ function checkImportStatus(){
function deletePlaylist(json) {
if(json.message) {
alert(json.message);
return;
alert(json.message);
return;
}
deleteItem("pl", json.id);
if (json.ids != undefined) {
for (var i = json.ids.length - 1; i >= 0; i--) {
deleteItem("pl", json.ids[i]);
}
} else if (json.id != undefined) {
deleteItem("pl", json.id);
}
window.location.reload();
}
//end callbacks called by jjmenu
@ -90,7 +112,7 @@ function addLibraryItemEvents() {
cursor: 'pointer'
});
$('#library_display tbody tr')
$('#library_display tbody tr td').not('[class=library_checkbox]')
.jjmenu("click",
[{get:"/Library/context-menu/format/json/id/#id#/type/#type#"}],
{id: getId, type: getType},
@ -101,36 +123,36 @@ function addLibraryItemEvents() {
function dtRowCallback( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var id, type, once;
type = aData[6].substring(0,2);
id = aData[0];
type = aData["ftype"].substring(0,2);
id = aData["id"];
if(type == "au") {
$('td:eq(5)', nRow).html( '<img src="css/images/icon_audioclip.png">' );
}
else if(type == "pl") {
$('td:eq(5)', nRow).html( '<img src="css/images/icon_playlist.png">' );
$('td.library_type', nRow).html( '<img src="css/images/icon_audioclip.png">' );
} else if(type == "pl") {
$('td.library_type', nRow).html( '<img src="css/images/icon_playlist.png">' );
}
$(nRow).attr("id", type+'_'+id);
$(nRow).attr("id", type+'_'+id);
// insert id on lenth field
$('td:eq(4)', nRow).attr("id", "length");
// insert id on lenth field
$('td.library_length', nRow).attr("id", "length");
return nRow;
return nRow;
}
function dtDrawCallback() {
addLibraryItemEvents();
addMetadataQtip();
saveNumEntriesSetting();
addLibraryItemEvents();
addMetadataQtip();
saveNumEntriesSetting();
setupGroupActions();
}
function addProgressIcon(id) {
if($("#au_"+id).find("td:eq(0)").find("span").length > 0){
$("#au_"+id).find("td:eq(0)").find("span").removeClass();
if($("#au_"+id).find("td.library_title").find("span").length > 0){
$("#au_"+id).find("td.library_title").find("span").removeClass();
$("span[id="+id+"]").addClass("small-icon progress");
}else{
$("#au_"+id).find("td:eq(0)").append('<span id="'+id+'" class="small-icon progress"></span>')
$("#au_"+id).find("td.library_title").append('<span id="'+id+'" class="small-icon progress"></span>')
}
}
@ -229,7 +251,7 @@ function addQtipToSCIcons(){
function addMetadataQtip(){
var tableRow = $('#library_display tbody tr');
tableRow.each(function(){
var title = $(this).find('td:eq(0)').html()
var title = $(this).find('td.library_title').html()
var info = $(this).attr("id")
info = info.split("_");
var id = info[1];
@ -297,31 +319,212 @@ function getNumEntriesPreference(data) {
return parseInt(data.libraryInit.numEntries);
}
function groupAdd() {
if (checkedPLCount > 0) {
alert("Can't add playlist to another playlist");
return;
}
disableGroupBtn('library_group_add');
var ids = new Array();
var addGroupUrl = '/Playlist/add-group';
var newSPLUrl = '/Playlist/new/format/json';
var dirty = true;
$('#library_display tbody tr').each(function() {
var idSplit = $(this).attr('id').split("_");
var id = idSplit.pop();
var type = idSplit.pop();
if (dirty && $(this).find(":checkbox").attr("checked")) {
if (type == "au") {
ids.push(id);
} else if (type == "pl") {
alert("Can't add playlist to another playlist");
dirty = false;
}
}
});
if (dirty && ids.length > 0) {
stopAudioPreview();
if ($('#spl_sortable').length == 0) {
$.post(newSPLUrl, function(json) {
openDiffSPL(json);
redrawDataTablePage();
$.post(addGroupUrl, {format: "json", ids: ids}, setSPLContent);
});
} else {
$.post(addGroupUrl, {format: "json", ids: ids}, setSPLContent);
}
}
}
function groupDelete() {
disableGroupBtn('library_group_delete');
var auIds = new Array();
var plIds = new Array();
var auUrl = '/Library/delete-group';
var plUrl = '/Playlist/delete-group';
var dirty = true;
$('#library_display tbody tr').each(function() {
var idSplit = $(this).attr('id').split("_");
var id = idSplit.pop();
var type = idSplit.pop();
if (dirty && $(this).find(":checkbox").attr("checked")) {
if (type == "au") {
auIds.push(id);
} else if (type == "pl") {
plIds.push(id);
}
}
});
if (dirty && (auIds.length > 0 || plIds.length > 0)) {
stopAudioPreview();
if (auIds.length > 0) {
$.post(auUrl, {format: "json", ids: auIds}, deleteAudioClip);
}
if (plIds.length > 0) {
$.post(plUrl, {format: "json", ids: plIds}, deletePlaylist);
}
}
}
function toggleAll() {
var checked = $(this).attr("checked");
$('#library_display tr').each(function() {
var idSplit = $(this).attr('id').split("_");
var type = idSplit[0];
$(this).find(":checkbox").attr("checked", checked);
if (checked) {
if (type == "pl") {
checkedPLCount++;
}
$(this).addClass('selected');
} else {
$(this).removeClass('selected');
}
});
if (checked) {
checkedCount = $('#library_display tbody tr').size();
enableGroupBtn('library_group_add', groupAdd);
enableGroupBtn('library_group_delete', confirmDeleteGroup);
} else {
checkedCount = 0;
checkedPLCount = 0;
disableGroupBtn('library_group_add');
disableGroupBtn('library_group_delete');
}
}
function enableGroupBtn(btnId, func) {
btnId = '#' + btnId;
if ($(btnId).hasClass('ui-state-disabled')) {
$(btnId).removeClass('ui-state-disabled');
$(btnId).unbind("click").click(func);
}
}
function disableGroupBtn(btnId) {
btnId = '#' + btnId;
if (!$(btnId).hasClass('ui-state-disabled')) {
$(btnId).addClass('ui-state-disabled');
$(btnId).unbind("click");
}
}
function checkBoxChanged() {
var cbAll = $('#library_display thead').find(":checkbox");
var cbAllChecked = cbAll.attr("checked");
var checked = $(this).attr("checked");
var size = $('#library_display tbody tr').size();
var idSplit = $(this).parent().parent().attr('id').split("_");
var type = idSplit[0];
if (checked) {
if (checkedCount < size) {
checkedCount++;
}
if (type == "pl" && checkedPLCount < size) {
checkedPLCount++;
}
enableGroupBtn('library_group_add', groupAdd);
enableGroupBtn('library_group_delete', confirmDeleteGroup);
$(this).parent().parent().addClass('selected');
} else {
if (checkedCount > 0) {
checkedCount--;
}
if (type == "pl" && checkedPLCount > 0) {
checkedPLCount--;
}
if (checkedCount == 0) {
disableGroupBtn('library_group_add');
disableGroupBtn('library_group_delete');
}
$(this).parent().parent().removeClass('selected');
}
if (cbAllChecked && checkedCount < size) {
cbAll.attr("checked", false);
} else if (!cbAllChecked && checkedCount == size) {
cbAll.attr("checked", true);
}
}
function setupGroupActions() {
checkedCount = 0;
checkedPLCount = 0;
$('#library_display tr:nth-child(1)').find(":checkbox").attr("checked", false);
$('#library_display thead').find(":checkbox").unbind('change').change(toggleAll);
$('#library_display tbody tr').each(function() {
$(this).find(":checkbox").unbind('change').change(checkBoxChanged);
});
disableGroupBtn('library_group_add');
disableGroupBtn('library_group_delete');
}
function fnShowHide(iCol) {
/* Get the DataTables object again - this is not a recreation, just a get of the object */
var oTable = dTable;
var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
oTable.fnSetColumnVis( iCol, bVis ? false : true );
}
function createDataTable(data) {
var dTable = $('#library_display').dataTable( {
dTable = $('#library_display').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/Library/contents/format/json",
"fnServerData": function ( sSource, aoData, fnCallback ) {
"fnServerData": function ( sSource, aoData, testCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
"success": testCallback
} );
},
"fnRowCallback": dtRowCallback,
"fnDrawCallback": dtDrawCallback,
"aoColumns": [
/* Id */ { "sName": "id", "bSearchable": false, "bVisible": false },
/* Title */ { "sTitle": "Title", "sName": "track_title" },
/* Creator */ { "sTitle": "Creator", "sName": "artist_name" },
/* Album */ { "sTitle": "Album", "sName": "album_title" },
/* Genre */ { "sTitle": "Genre", "sName": "genre" },
/* Length */ { "sTitle": "Length", "sName": "length" },
/* Type */ { "sTitle": "Type", "sName": "ftype", "bSearchable": false }
],
/* Checkbox */ {"sTitle": "<input type='checkbox' name='cb_all'>", "bSortable": false, "bSearchable": false, "mDataProp": "checkbox", "sWidth": "25px", "sClass": "library_checkbox"},
/* Id */ {"sName": "id", "bSearchable": false, "bVisible": false, "mDataProp": "id", "sClass": "library_id"},
/* Title */ {"sTitle": "Title", "sName": "track_title", "mDataProp": "track_title", "sClass": "library_title"},
/* Creator */ {"sTitle": "Creator", "sName": "artist_name", "mDataProp": "artist_name", "sClass": "library_creator"},
/* Album */ {"sTitle": "Album", "sName": "album_title", "mDataProp": "album_title", "sClass": "library_album"},
/* Genre */ {"sTitle": "Genre", "sName": "genre", "mDataProp": "genre", "sWidth": "10%", "sClass": "library_genre"},
/* Year */ {"sTitle": "Year", "sName": "year", "mDataProp": "year", "sWidth": "8%", "sClass": "library_year"},
/* Length */ {"sTitle": "Length", "sName": "length", "mDataProp": "length", "sWidth": "10%", "sClass": "library_length"},
/* Type */ {"sTitle": "Type", "sName": "ftype", "bSearchable": false, "mDataProp": "ftype", "sWidth": "9%", "sClass": "library_type"},
/* Upload Time */ {"sTitle": "Upload Time", "sName": "utime", "mDataProp": "utime", "sClass": "library_upload_time"},
/* Last Modified */ {"sTitle": "Last Modified", "sName": "mtime", "bVisible": false, "mDataProp": "mtime", "sClass": "library_modified_time"},
],
"aaSorting": [[2,'asc']],
"sPaginationType": "full_numbers",
"bJQueryUI": true,
@ -330,20 +533,42 @@ function createDataTable(data) {
"sSearch": ""
},
"iDisplayLength": getNumEntriesPreference(data),
"bStateSave": true
"bStateSave": true,
// R = ColReorder, C = ColVis, see datatables doc for others
"sDom": 'Rlfr<"H"C<"library_toolbar">>t<"F"ip>',
"oColVis": {
"buttonText": "Show/Hide Columns",
"sAlign": "right",
"aiExclude": [0, 1, 2],
"sSize": "css",
"bShowAll": true
},
"oColReorder": {
"aiOrder": [ 0, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] /* code this */,
"iFixedColumns": 3
}
});
dTable.fnSetFilteringDelay(350);
$("div.library_toolbar").html('<span class="fg-button ui-button ui-state-default" id="library_order_reset">Reset Order</span>' +
'<span class="fg-button ui-button ui-state-default ui-state-disabled" id="library_group_delete">Delete</span>' +
'<span class="fg-button ui-button ui-state-default ui-state-disabled" id="library_group_add">Add</span>');
$('#library_order_reset').click(function() {
ColReorder.fnReset( dTable );
return false;
});
}
$(document).ready(function() {
$('.tabs').tabs();
$.ajax({ url: "/Api/library-init/format/json", dataType:"json", success:createDataTable,
$.ajax({url: "/Api/library-init/format/json", dataType:"json", success:createDataTable,
error:function(jqXHR, textStatus, errorThrown){}});
checkImportStatus()
checkImportStatus();
setInterval( "checkImportStatus()", 5000 );
setInterval( "checkSCUploadStatus()", 5000 );
addQtipToSCIcons()
});

View file

@ -449,6 +449,9 @@ function setUpSPL() {
}
$("#fieldset-metadate_change").addClass("closed");
// update the "Last Modified" time for this playlist
redrawDataTablePage();
});
});

View file

@ -33,7 +33,8 @@ function createDateInput(el, onSelect) {
onSelect: onSelect,
dateFormat: 'yy-mm-dd',
closeText: 'Close',
showButtonPanel: true
showButtonPanel: true,
firstDay: weekStart
});
}
@ -190,7 +191,8 @@ function setAddShowEvents() {
minDate: adjustDateToServerDate(new Date(), timezoneOffset),
dateFormat: 'yy-mm-dd',
closeText: 'Close',
showButtonPanel: true
showButtonPanel: true,
firstDay: weekStart
});
form.find('input[name^="add_show_rebroadcast_time"]').timepicker({
amPmText: ['', ''],

View file

@ -86,7 +86,7 @@ function setScheduleDialogEvents(dialog) {
}
function dtRowCallback( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var id = "pl_" + aData[0];
var id = "pl_" + aData['id'];
$(nRow).attr("id", id);
@ -125,12 +125,12 @@ function makeScheduleDialog(dialog, json) {
"fnRowCallback": dtRowCallback,
"fnDrawCallback": dtDrawCallback,
"aoColumns": [
/* Id */ { "sName": "pl.id", "bSearchable": false, "bVisible": false },
/* Description */ { "sName": "pl.description", "bVisible": false },
/* Name */ { "sName": "pl.name" },
/* Creator */ { "sName": "pl.creator" },
/* Length */ { "sName": "plt.length" },
/* Editing */ { "sName": "sub.login" }
/* Id */ {"sTitle": "ID", "sName": "pl.id", "bSearchable": false, "bVisible": false, "mDataProp": "id"},
/* Description */ {"sTitle": "Description", "sName": "pl.description", "bSearchable": false, "bVisible": false, "mDataProp": "description"},
/* Name */ {"sTitle": "Title", "sName": "pl.name", "mDataProp": "name"},
/* Creator */ {"sTitle": "Creator", "sName": "pl.creator", "mDataProp": "creator"},
/* Length */ {"sTitle": "Length", "sName": "plt.length", "mDataProp": "length"},
/* Editing */ {"sTitle": "Editing", "sName": "sub.login", "mDataProp": "login"}
],
"aaSorting": [[2,'asc']],
"sPaginationType": "full_numbers",
@ -184,6 +184,16 @@ function confirmCancelShow(show_instance_id){
}
}
function confirmCancelRecordedShow(show_instance_id){
if(confirm('Erase current show and stop recording?')){
var url = "/Schedule/cancel-current-show/id/"+show_instance_id;
$.ajax({
url: url,
success: function(data){scheduleRefetchEvents(data);}
});
}
}
function uploadToSoundCloud(show_instance_id){
var url = "/Schedule/upload-to-sound-cloud";
@ -219,7 +229,11 @@ function buildContentDialog(json){
alertShowErrorAndReload();
}
var dialog = $(json.dialog);
dialog.find("#show_progressbar").progressbar({
value: json.percentFilled
});
var viewportwidth;
var viewportheight;

View file

@ -35,23 +35,23 @@ function removeUserCallback(row_id, nRow){
}
function rowCallback( nRow, aData, iDisplayIndex ){
$(nRow).click(function(){rowClickCallback(aData[0])});
if( aData[5] != "self"){
$('td:eq(4)', nRow).append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); removeUserCallback(aData[0], nRow)});
$(nRow).click(function(){rowClickCallback(aData['id'])});
if( aData['delete'] != "self"){
$('td:eq(4)', nRow).append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); removeUserCallback(aData['id'], nRow)});
}else{
$('td:eq(4)', nRow).empty().append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); alert("Can't delete yourself!")});
}
if ( aData[4] == "A" )
if ( aData['type'] == "A" )
{
$('td:eq(3)', nRow).html( 'Admin' );
} else if ( aData[4] == "H" )
} else if ( aData['type'] == "H" )
{
$('td:eq(3)', nRow).html( 'DJ' );
} else if ( aData[4] == "G" )
} else if ( aData['type'] == "G" )
{
$('td:eq(3)', nRow).html( 'Guest' );
} else if ( aData[4] == "P" )
} else if ( aData['type'] == "P" )
{
$('td:eq(3)', nRow).html( 'Program Manager' );
}
@ -75,12 +75,12 @@ $(document).ready(function() {
},
"fnRowCallback": rowCallback,
"aoColumns": [
/* Id */ { "sName": "id", "bSearchable": false, "bVisible": false },
/* user name */ { "sName": "login" },
/* first name */ { "sName": "first_name" },
/* last name */ { "sName": "last_name" },
/* user type */ { "sName": "type", "bSearchable": false },
/* del button */ { "sName": "null as delete", "bSearchable": false, "bSortable": false}
/* Id */ { "sName": "id", "bSearchable": false, "bVisible": false, "mDataProp": "id" },
/* user name */ { "sName": "login", "mDataProp": "login" },
/* first name */ { "sName": "first_name", "mDataProp": "first_name" },
/* last name */ { "sName": "last_name", "mDataProp": "last_name" },
/* user type */ { "sName": "type", "bSearchable": false, "mDataProp": "type" },
/* del button */ { "sName": "null as delete", "bSearchable": false, "bSortable": false, "mDataProp": "delete"}
],
"bJQueryUI": true,
"bAutoWidth": false,