Merge branch 'saas-dev-publishing' of https://github.com/sourcefabric/Airtime into saas-dev-publishing
This commit is contained in:
commit
9fc4e1c603
|
@ -323,6 +323,10 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
|
|||
$ingested = in_array($itemId, $episodeIds) ? (empty($episodeFiles[$itemId]) ? -1 : 1) : 0;
|
||||
$file = $ingested > 0 && !empty($episodeFiles[$itemId]) ?
|
||||
CcFiles::getSanitizedFileById($episodeFiles[$itemId]) : array();
|
||||
// If the analyzer hasn't finished with the file, leave it as pending
|
||||
if (!empty($file) && $file["import_status"] == CcFiles::IMPORT_STATUS_PENDING) {
|
||||
$ingested = -1;
|
||||
}
|
||||
|
||||
array_push($episodesArray, array(
|
||||
"podcast_id" => $podcast->getDbId(),
|
||||
|
|
|
@ -78,11 +78,12 @@ class Application_Service_PublishService {
|
|||
* @param int $fileId the ID of the file to check
|
||||
*
|
||||
* @return int 1 if the file has been published to SoundCloud,
|
||||
* 0 if the file has yet to be published, or -1 if the
|
||||
* file is in a pending state
|
||||
* 0 if the file has yet to be published,
|
||||
* -1 if the file is in a pending state
|
||||
*/
|
||||
private static function getSoundCloudPublishStatus($fileId) {
|
||||
$soundcloudService = new Application_Service_SoundcloudService();
|
||||
if (!$soundcloudService->hasAccessToken()) { return 2; }
|
||||
return ($soundcloudService->referenceExists($fileId));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
<fieldset>
|
||||
<legend><?php echo _("Publish to:"); ?></legend>
|
||||
<div class="publish-sources" ng-repeat="source in sources.toPublish">
|
||||
<input ng-model="publishData[source.source]" type="checkbox" name="publish_sources" id="{{source.source}}">
|
||||
<label class="source-name" for="{{source.source}}">{{source.label}}</label><br/>
|
||||
<input ng-disabled="{{source.status == 2}}" ng-model="publishData[source.source]" type="checkbox" name="publish_sources" id="{{source.source}}">
|
||||
<label class="source-name" for="{{source.source}}">{{source.label}}</label>
|
||||
<span ng-if="source.status == 2" style="margin: auto"><?php echo _("You aren't connected to this source.") ?></span>
|
||||
</div>
|
||||
<div ng-if="sources.toPublish.length == 0">
|
||||
<?php echo _("You have already published this track to all available sources!") . "<br/>"
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
</div>
|
||||
<div class="inner_editor_wrapper station_podcast_wrapper">
|
||||
<form class="podcast-metadata">
|
||||
<H4>About your Podcast</H4>
|
||||
<input ng-value="podcast.id" class="obj_id" type="hidden"/>
|
||||
|
||||
<div>
|
||||
|
|
|
@ -335,6 +335,7 @@ thead th.ui-state-default:focus {
|
|||
|
||||
#sb_show_filter {
|
||||
right: 0;
|
||||
max-width: 125px;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
|
|
|
@ -4011,6 +4011,10 @@ li .ui-state-hover {
|
|||
top: 74px !important;
|
||||
}
|
||||
|
||||
.angular_wrapper > .btn-toolbar {
|
||||
padding: 5px 0 0 5px;
|
||||
}
|
||||
|
||||
.podcast-metadata p {
|
||||
text-align: center;
|
||||
padding: 0 10px;
|
||||
|
@ -4135,6 +4139,11 @@ li .ui-state-hover {
|
|||
|
||||
/* Publishing Dialog */
|
||||
|
||||
.icon-soundcloud-white {
|
||||
background: url(images/icon_soundcloud_cm_white.png) 0 0 no-repeat;
|
||||
width: 24px;
|
||||
}
|
||||
|
||||
.source-name {
|
||||
text-align: left !important;
|
||||
}
|
||||
|
|
|
@ -70,8 +70,9 @@ var AIRTIME = (function(AIRTIME) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Draw a placeholder for the given table to show if it has no data.
|
||||
*
|
||||
* @param {jQuery} table
|
||||
* @param {jQuery} table jQuery object containing the table DOM node
|
||||
*/
|
||||
mod.drawEmptyPlaceholder = function (table) {
|
||||
var emptyRow = table.find('tr:has(td.dataTables_empty)'),
|
||||
|
@ -82,18 +83,26 @@ var AIRTIME = (function(AIRTIME) {
|
|||
emptyRow.hide();
|
||||
var mediaType = parseInt($('.media_type_selector.selected').data('selection-id')),
|
||||
img = wrapper.find('.empty_placeholder_image');
|
||||
if (isNaN(mediaType)) { return; }
|
||||
// Remove all classes for when we change between empty media types
|
||||
img.removeClass(function() {
|
||||
return $(this).attr("class");
|
||||
});
|
||||
img.removeClass(function() { return $(this).attr("class"); });
|
||||
|
||||
var opts = AIRTIME.library.placeholder(mediaType);
|
||||
img.addClass("empty_placeholder_image icon-white " + opts.icon);
|
||||
wrapper.find('.empty_placeholder_text').html(
|
||||
$.i18n._("You haven't added any " + opts.media + ".")
|
||||
+ "<br/>" + $.i18n._(opts.subtext)
|
||||
+ "<br/><a target='_blank' href='" + opts.href + "'>" + $.i18n._("Learn about " + opts.media) + "</a>"
|
||||
);
|
||||
if (table[0] == AIRTIME.library.podcastEpisodeDataTable[0]) {
|
||||
img.addClass("empty_placeholder_image icon-white icon-th-list");
|
||||
wrapper.find('.empty_placeholder_text').html(
|
||||
$.i18n._("This podcast doesn't have any episodes!")
|
||||
+ "<br/>" + $.i18n._("Make sure the RSS feed contains audio items (with enclosure tags).")
|
||||
+ "<br/><a target='_blank' href='http://www.apple.com/ca/itunes/podcasts/specs.html'>" + $.i18n._("Learn about podcasts") + "</a>"
|
||||
);
|
||||
} else {
|
||||
var opts = AIRTIME.library.placeholder(mediaType);
|
||||
img.addClass("empty_placeholder_image icon-white " + opts.icon);
|
||||
wrapper.find('.empty_placeholder_text').html(
|
||||
$.i18n._("You haven't added any " + opts.media + ".")
|
||||
+ "<br/>" + $.i18n._(opts.subtext)
|
||||
+ "<br/><a target='_blank' href='" + opts.href + "'>" + $.i18n._("Learn about " + opts.media) + "</a>"
|
||||
);
|
||||
}
|
||||
|
||||
libEmpty.show();
|
||||
} else {
|
||||
|
@ -305,9 +314,22 @@ var AIRTIME = (function(AIRTIME) {
|
|||
}
|
||||
});
|
||||
|
||||
$toolbar.find('#publish-btn').click(function () {
|
||||
if (AIRTIME.button.isDisabled('btn-group #publish-btn') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var selected = $(".lib-selected");
|
||||
|
||||
selected.each(function (i, el) {
|
||||
var data = $(el).data("aData");
|
||||
AIRTIME.publish.openPublishDialog(data.id);
|
||||
});
|
||||
});
|
||||
|
||||
// delete from library.
|
||||
$toolbar.find('.icon-trash').parent().click(function () {
|
||||
if (AIRTIME.button.isDisabled('icon-trash') === true) {
|
||||
$toolbar.find('#sb-delete').click(function () {
|
||||
if (AIRTIME.button.isDisabled('btn-group #sb-delete') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -229,12 +229,23 @@ var AIRTIME = (function(AIRTIME) {
|
|||
"</div>"
|
||||
).append(
|
||||
"<div class='btn-group' title=" + $.i18n._('Delete') + ">" +
|
||||
"<button class='btn btn-small btn-danger' id='sb-trash'>" +
|
||||
"<button class='btn btn-small btn-danger' id='sb-delete'>" +
|
||||
"<i class='icon-white icon-trash'></i>" +
|
||||
"<span>" + $.i18n._('Delete') + "</span>" +
|
||||
"</button>" +
|
||||
"</div>"
|
||||
);
|
||||
|
||||
if (onDashboard) {
|
||||
$menu.append(
|
||||
"<div class='btn-group' title=" + $.i18n._('Publish') + ">" +
|
||||
"<button class='btn btn-small' id='publish-btn'>" +
|
||||
"<i class='icon-soundcloud-white'></i>" +
|
||||
"<span>" + $.i18n._('Publish') + "</span>" +
|
||||
"</button>" +
|
||||
"</div>"
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
mod.createToolbarDropDown = function() {
|
||||
|
@ -252,10 +263,10 @@ var AIRTIME = (function(AIRTIME) {
|
|||
}
|
||||
|
||||
if (check === true) {
|
||||
AIRTIME.button.enableButton("btn-group #sb-trash", false);
|
||||
AIRTIME.button.enableButton("btn-group #sb-delete", false);
|
||||
}
|
||||
else {
|
||||
AIRTIME.button.disableButton("btn-group #sb-trash", false);
|
||||
AIRTIME.button.disableButton("btn-group #sb-delete", false);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -291,11 +302,28 @@ var AIRTIME = (function(AIRTIME) {
|
|||
}
|
||||
};
|
||||
|
||||
mod.checkPublishButton = function() {
|
||||
var selected = mod.getChosenItemsLength(),
|
||||
mediaType = $(".media_type_selector.selected").data("selection-id"),
|
||||
check = false;
|
||||
|
||||
if (mediaType == AIRTIME.library.MediaTypeIntegerEnum.FILE && selected > 0) {
|
||||
check = true;
|
||||
}
|
||||
|
||||
if (check === true) {
|
||||
AIRTIME.button.enableButton("btn-group #publish-btn", false);
|
||||
} else {
|
||||
AIRTIME.button.disableButton("btn-group #publish-btn", false);
|
||||
}
|
||||
};
|
||||
|
||||
mod.checkToolBarIcons = function() {
|
||||
AIRTIME.library.checkAddButton();
|
||||
AIRTIME.library.checkDeleteButton();
|
||||
AIRTIME.library.checkEditButton();
|
||||
AIRTIME.library.checkNewButton();
|
||||
AIRTIME.library.checkPublishButton();
|
||||
};
|
||||
|
||||
mod.getSelectedData = function() {
|
||||
|
@ -454,7 +482,7 @@ var AIRTIME = (function(AIRTIME) {
|
|||
|
||||
mod.fnDeleteItems = function(aMedia) {
|
||||
//Prevent the user from spamming the delete button while the AJAX request is in progress
|
||||
AIRTIME.button.disableButton("btn-group #sb-trash", false);
|
||||
AIRTIME.button.disableButton("btn-group #sb-delete", false);
|
||||
var openTabObjectIds = $(".obj_id"),
|
||||
mediaIds = [];
|
||||
for (var i in aMedia) {
|
||||
|
@ -483,7 +511,7 @@ var AIRTIME = (function(AIRTIME) {
|
|||
}
|
||||
|
||||
//Re-enable the delete button
|
||||
AIRTIME.button.enableButton("btn-group #sb-trash", false);
|
||||
AIRTIME.button.enableButton("btn-group #sb-delete", false);
|
||||
});
|
||||
mod.selectNone();
|
||||
};
|
||||
|
@ -573,6 +601,8 @@ var AIRTIME = (function(AIRTIME) {
|
|||
);
|
||||
}
|
||||
|
||||
var colExclude = onDashboard ? [0, 1, 2, 32] : [0, 1, 2];
|
||||
|
||||
/* ############################################
|
||||
DATATABLES
|
||||
############################################ */
|
||||
|
@ -749,7 +779,7 @@ var AIRTIME = (function(AIRTIME) {
|
|||
|
||||
"oColVis": {
|
||||
"sAlign": "right",
|
||||
"aiExclude": [0, 1, 2, 32],
|
||||
"aiExclude": colExclude,
|
||||
"sSize": "css",
|
||||
"fnStateChange": setFilterElement,
|
||||
"buttonText": $.i18n._("Columns"),
|
||||
|
@ -1484,7 +1514,6 @@ var AIRTIME = (function(AIRTIME) {
|
|||
click: function () {
|
||||
var data = [], episodes = mod.podcastEpisodeTableWidget.getSelectedRows();
|
||||
$.each(episodes, function () {
|
||||
if (this.file.ftype === "") { this.file.ftype = "audioclip"; }
|
||||
data.push({id: this.file.id, type: this.file.ftype});
|
||||
});
|
||||
mod.fnDeleteItems(data);
|
||||
|
@ -1557,6 +1586,9 @@ var AIRTIME = (function(AIRTIME) {
|
|||
},
|
||||
oColReorder: {
|
||||
iFixedColumns: 3 // Checkbox + imported
|
||||
},
|
||||
fnDrawCallback: function () {
|
||||
AIRTIME.library.drawEmptyPlaceholder($(this));
|
||||
}
|
||||
},
|
||||
buttons,
|
||||
|
|
|
@ -33,21 +33,6 @@ var AIRTIME = (function (AIRTIME) {
|
|||
$scope.csrf = jQuery("#csrf").val();
|
||||
tab.contents.find("table").attr("id", "podcast_episodes_" + podcast.id);
|
||||
|
||||
/**
|
||||
* Override the switchTo function to reload the table when the tab is focused.
|
||||
* Should help to reduce the number of cases where the frontend doesn't match the state
|
||||
* of the backend (due to automatic ingestion).
|
||||
*
|
||||
* Note that these cases should already be very few and far between.
|
||||
*
|
||||
* TODO: make sure this doesn't noticeably slow performance
|
||||
* XXX: it's entirely possible that this (in the angular app) is not where we want this function...
|
||||
*/
|
||||
tab.switchTo = function () {
|
||||
AIRTIME.tabs.Tab.prototype.switchTo.call(this);
|
||||
self.reloadEpisodeTable();
|
||||
};
|
||||
|
||||
/**
|
||||
* Save and update the podcast object.
|
||||
*/
|
||||
|
@ -74,72 +59,6 @@ var AIRTIME = (function (AIRTIME) {
|
|||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the podcast episode table.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
PodcastController.prototype._initTable = function() {
|
||||
/*
|
||||
* Remove the episode table for imported podcasts since its functionality is replicated in the left-hand pane
|
||||
*
|
||||
var self = this,
|
||||
$scope = self.$scope;
|
||||
// We want to fetch the data statically for imported podcasts because we would need to implement sorting
|
||||
// in a very convoluted way on the backend to accommodate the nonexistent rows for uningested episodes
|
||||
var params = {
|
||||
bServerSide : false,
|
||||
sAjaxSource : null,
|
||||
// Initialize the table with empty data so we can defer loading
|
||||
// If we load sequentially there's a delay before the table appears
|
||||
aaData : {},
|
||||
aoColumns : [
|
||||
{ "sTitle" : "" , "mDataProp" : "guid" , "sClass" : "podcast_episodes_guid" , "bVisible" : false },
|
||||
{ "sTitle" : $.i18n._("Title") , "mDataProp" : "title" , "sClass" : "podcast_episodes_title" , "sWidth" : "170px" },
|
||||
{ "sTitle" : $.i18n._("Author") , "mDataProp" : "author" , "sClass" : "podcast_episodes_author" , "sWidth" : "170px" },
|
||||
{ "sTitle" : $.i18n._("Description") , "mDataProp" : "description" , "sClass" : "podcast_episodes_description" , "sWidth" : "300px" },
|
||||
{ "sTitle" : $.i18n._("Link") , "mDataProp" : "link" , "sClass" : "podcast_episodes_link" , "sWidth" : "170px" },
|
||||
{ "sTitle" : $.i18n._("Publication Date") , "mDataProp" : "pub_date" , "sClass" : "podcast_episodes_pub_date" , "sWidth" : "170px" }
|
||||
]
|
||||
},
|
||||
buttons = {
|
||||
slideToggle: {},
|
||||
importBtn: {
|
||||
title : $.i18n._('Import Selected'),
|
||||
iconClass : '',
|
||||
extraBtnClass : 'btn-new',
|
||||
elementId : '',
|
||||
eventHandlers : {
|
||||
click: function () {
|
||||
mod.importSelectedEpisodes(self.episodeTable.getSelectedRows(), self.episodeTable);
|
||||
}
|
||||
},
|
||||
validateConstraints: function () {
|
||||
// Only importable rows can be selected
|
||||
return this.getSelectedRows().length >= 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
self.episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatable(
|
||||
$scope.tab.contents.find('.podcast_episodes'),
|
||||
params,
|
||||
buttons,
|
||||
{
|
||||
hideIngestCheckboxes: true,
|
||||
podcastId: $scope.podcast.id
|
||||
}
|
||||
);
|
||||
self.reloadEpisodeTable();
|
||||
*/
|
||||
};
|
||||
|
||||
/**
|
||||
* Reload the podcast episode table.
|
||||
*/
|
||||
PodcastController.prototype.reloadEpisodeTable = function() {
|
||||
this.episodeTable.reload();
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize the controller.
|
||||
*
|
||||
|
@ -150,7 +69,6 @@ var AIRTIME = (function (AIRTIME) {
|
|||
// TODO: this solves a race condition, but we should look for the root cause
|
||||
AIRTIME.tabs.onResize();
|
||||
self.$scope.tab.setName(self.$scope.podcast.title);
|
||||
self._initTable();
|
||||
// Add an onclose hook to the tab to remove the table object and the
|
||||
// import listener so we don't cause memory leaks.
|
||||
if (self.episodeTable) {
|
||||
|
@ -182,15 +100,31 @@ var AIRTIME = (function (AIRTIME) {
|
|||
$stationPodcastTab = tab;
|
||||
|
||||
/**
|
||||
* Override the tab close function to 'unset' the module-scope $stationPodcastTab.
|
||||
*
|
||||
* @override
|
||||
*
|
||||
* Override the tab close function to 'unset' the module-scope $stationPodcastTab.
|
||||
*/
|
||||
tab.close = function () {
|
||||
AIRTIME.tabs.Tab.prototype.close.call(this);
|
||||
$stationPodcastTab = undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*
|
||||
* Override the switchTo function to reload the table when the tab is focused.
|
||||
* Should help to reduce the number of cases where the frontend doesn't match the state
|
||||
* of the backend (due to automatic ingestion).
|
||||
*
|
||||
* Note that these cases should already be very few and far between.
|
||||
*
|
||||
* XXX: it's entirely possible that this (in the angular module) is not where we want this function...
|
||||
*/
|
||||
tab.switchTo = function () {
|
||||
AIRTIME.tabs.Tab.prototype.switchTo.call(this);
|
||||
self.reloadEpisodeTable();
|
||||
};
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -259,7 +193,7 @@ var AIRTIME = (function (AIRTIME) {
|
|||
params = {
|
||||
sAjaxSource : endpoint + $scope.podcast.id + '/episodes',
|
||||
aoColumns: [
|
||||
// TODO: it might be dangerous to use CcFiles here? We should alias this instead
|
||||
// TODO: it might be wrong to use CcFiles here? We should alias this instead
|
||||
/* Title */ { "sTitle" : $.i18n._("Title") , "mDataProp" : "CcFiles.track_title" , "sClass" : "podcast_episodes_title" , "sWidth" : "170px" },
|
||||
/* Description */ { "sTitle" : $.i18n._("Description") , "mDataProp" : "CcFiles.description" , "sClass" : "podcast_episodes_description" , "sWidth" : "300px" }
|
||||
]
|
||||
|
@ -283,12 +217,13 @@ var AIRTIME = (function (AIRTIME) {
|
|||
PodcastController.prototype.initialize.call(this);
|
||||
// We want to override the default tab name behaviour and use "Station Podcast" for clarity
|
||||
this.$scope.tab.setName(jQuery.i18n._("Station Podcast"));
|
||||
self._initTable();
|
||||
};
|
||||
|
||||
/**
|
||||
* Reload the Station podcast episode table.
|
||||
*
|
||||
* @override
|
||||
*
|
||||
* Reload the Station podcast episode table.
|
||||
*/
|
||||
StationPodcastController.prototype.reloadEpisodeTable = function() {
|
||||
this.episodeTable.getDatatable().fnDraw();
|
||||
|
@ -406,12 +341,13 @@ var AIRTIME = (function (AIRTIME) {
|
|||
* @private
|
||||
*/
|
||||
PodcastEpisodeTable.prototype._datatablesCheckboxDataDelegate = function(rowData, callType, dataToSave) {
|
||||
var importIcon = "<span class='sp-checked-icon checked-icon imported-flag'></span>",
|
||||
var defaultIcon = "<span class='icon-white icon-import'></span>",
|
||||
importIcon = "<span class='sp-checked-icon checked-icon imported-flag'></span>",
|
||||
pendingIcon = "<span class='loading-icon'></span>";
|
||||
if (this.config.hideIngestCheckboxes && rowData.ingested && rowData.ingested != 0) {
|
||||
return rowData.ingested > 0 ? importIcon : pendingIcon;
|
||||
}
|
||||
rowData.importIcon = (rowData.ingested != 0) ? (rowData.ingested > 0 ? importIcon : pendingIcon) : null;
|
||||
rowData.importIcon = (rowData.ingested != 0) ? (rowData.ingested > 0 ? importIcon : pendingIcon) : defaultIcon;
|
||||
return AIRTIME.widgets.Table.prototype._datatablesCheckboxDataDelegate.call(this, rowData, callType, dataToSave);
|
||||
};
|
||||
|
||||
|
@ -433,10 +369,8 @@ var AIRTIME = (function (AIRTIME) {
|
|||
applyPlatformOpacityRules: false
|
||||
});
|
||||
$.get(endpoint + self.config.podcastId + '/episodes', function (json) {
|
||||
dt.fnClearTable();
|
||||
self.clearSelection();
|
||||
dt.fnClearTable(false);
|
||||
dt.fnAddData(JSON.parse(json));
|
||||
// dt.fnDraw();
|
||||
}).done(function () {
|
||||
dt.unblock();
|
||||
});
|
||||
|
@ -482,7 +416,7 @@ var AIRTIME = (function (AIRTIME) {
|
|||
if (delta) { // Has there been a change?
|
||||
// We already have the data, so there's no reason to call
|
||||
// reload() here; this also provides a smoother transition
|
||||
dt.fnClearTable();
|
||||
dt.fnClearTable(false);
|
||||
dt.fnAddData(data);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -16,7 +16,6 @@ var AIRTIME = (function (AIRTIME) {
|
|||
//AngularJS app
|
||||
var publishApp = angular.module(PUBLISH_APP_NAME, [])
|
||||
.controller('Publish', function ($scope, $http, mediaId, tab) {
|
||||
$scope.publishSources = {};
|
||||
$scope.publishData = {};
|
||||
var sourceInterval;
|
||||
|
||||
|
@ -34,7 +33,7 @@ var AIRTIME = (function (AIRTIME) {
|
|||
.success(function (json) {
|
||||
$scope.sources = { toPublish: [], published: []};
|
||||
$.each(json, function () {
|
||||
if (this.status != 0) {
|
||||
if (Math.abs(this.status) == 1) {
|
||||
$scope.sources.published.push(this);
|
||||
} else {
|
||||
$scope.sources.toPublish.push(this);
|
||||
|
|
Loading…
Reference in New Issue