* SAAS-1161 - refactor backend so episodes are loaded separately from podcast data to speed up loading and improve API readability

* Decouple imported and station podcast behaviour on the frontend
This commit is contained in:
Duncan Sommerville 2015-11-02 18:07:16 -05:00
parent c4be9aebb2
commit def8e7280b
9 changed files with 312 additions and 256 deletions

View File

@ -54,8 +54,7 @@ class PodcastManager {
* @return array array of episodes to append be downloaded
*/
protected static function _findUningestedEpisodes($podcast, $service) {
$podcastArray = Application_Service_PodcastService::getPodcastById($podcast->getDbPodcastId());
$episodeList = $podcastArray["episodes"];
$episodeList = $service->getPodcastEpisodes($podcast->getDbPodcastId());
$episodes = array();
usort($episodeList, array(static::class, "_sortByEpisodePubDate"));
for ($i = 0; $i < sizeof($episodeList); $i++) {

View File

@ -40,6 +40,7 @@ class Rest_PodcastEpisodesController extends Zend_Rest_Controller
$this->getResponse()
->setHttpResponseCode(201)
->setHeader('X-TOTAL-COUNT', $totalPodcastEpisodesCount)
->appendBody(json_encode($this->_service->getPodcastEpisodes($id, $offset, $limit, $sortColumn, $sortDir)));
} catch (PodcastNotFoundException $e) {

View File

@ -227,7 +227,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
public function getPodcastEpisodes($podcastId,
$offset=0,
$limit=10,
$sortColumn=PodcastEpisodesPeer::ID,
$sortColumn=PodcastEpisodesPeer::PUBLICATION_DATE,
$sortDir="ASC")
{
$podcast = PodcastQuery::create()->findPk($podcastId);
@ -235,26 +235,59 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
throw new PodcastNotFoundException();
}
//make sure valid $sortDir was passed in
if ($sortDir === "DESC") {
$sortDir = Criteria::DESC;
} else {
$sortDir = Criteria::ASC;
}
$sortDir = ($sortDir === "DESC") ? $sortDir = Criteria::DESC : Criteria::ASC;
$isStationPodcast = $podcastId === Application_Model_Preference::getStationPodcastId();
$episodes = PodcastEpisodesQuery::create()
->filterByDbPodcastId($podcastId)
->setLimit($limit)
->setOffset($offset)
->joinWith('PodcastEpisodes.CcFiles')
->filterByDbPodcastId($podcastId);
// TODO: how should we limit the number of episodes for imported podcasts (since they include feed episodes?)
// FIXME
if ($isStationPodcast) {
$episodes = $episodes->setLimit($limit);
}
$episodes = $episodes->setOffset($offset)
->orderBy($sortColumn, $sortDir)
->find();
return $isStationPodcast ? $this->_getStationPodcastEpisodeArray($episodes)
: $this->_getImportedPodcastEpisodeArray($podcast, $episodes);
}
private function _getStationPodcastEpisodeArray($episodes) {
$episodesArray = array();
foreach ($episodes as $episode) {
$episodeArr = $episode->toArray(BasePeer::TYPE_FIELDNAME);
$episodeArr["track_metadata"] = CcFiles::getSanitizedFileById($episode->getDbFileId());
/** @var PodcastEpisodes $episode */
$episodeArr = $episode->toArray(BasePeer::TYPE_FIELDNAME, true, [], true);
// $episodeArr["cc_files"] = CcFiles::getSanitizedFileById($episode->getDbFileId());
array_push($episodesArray, $episodeArr);
}
return $episodesArray;
}
public function _getImportedPodcastEpisodeArray($podcast, $episodes) {
$rss = Application_Service_PodcastService::getPodcastFeed($podcast->getDbUrl());
$episodeIds = array();
foreach ($episodes as $e) {
array_push($episodeIds, $e->getDbEpisodeGuid());
}
$episodesArray = array();
foreach ($rss->get_items() as $item) {
/** @var SimplePie_Item $item */
array_push($episodesArray, array(
"guid" => $item->get_id(),
"ingested" => in_array($item->get_id(), $episodeIds),
"title" => $item->get_title(),
// From the RSS spec best practices:
// 'An item's author element provides the e-mail address of the person who wrote the item'
"author" => $item->get_author()->get_email(),
"description" => $item->get_description(),
"pub_date" => $item->get_gmdate(),
"link" => $item->get_link(),
"enclosure" => $item->get_enclosure()
));
}
return $episodesArray;
}

View File

@ -130,7 +130,7 @@ class Application_Service_PodcastService
$importedPodcast->setPodcast($podcast);
$importedPodcast->save();
return self::_generatePodcastArray($podcast, $rss);
return $podcast->toArray(BasePeer::TYPE_FIELDNAME);
} catch(Exception $e) {
$podcast->delete();
throw $e;
@ -210,47 +210,6 @@ class Application_Service_PodcastService
}
}
/**
* Given a podcast object and a SimplePie feed object,
* generate a data array to pass back to the front-end
*
* @param $podcast Podcast model object
* @param SimplePie $rss SimplePie feed object
*
* @return array
*/
private static function _generatePodcastArray($podcast, $rss) {
$stationPodcast = StationPodcastQuery::create()->findOneByDbPodcastId($podcast->getDbId());
$ingestedEpisodes = PodcastEpisodesQuery::create()
->findByDbPodcastId($podcast->getDbId());
$episodeIds = array();
if (!$stationPodcast) {
foreach ($ingestedEpisodes as $e) {
array_push($episodeIds, $e->getDbEpisodeGuid());
}
}
$podcastArray = $podcast->toArray(BasePeer::TYPE_FIELDNAME);
$podcastArray["episodes"] = array();
foreach ($rss->get_items() as $item) {
/** @var SimplePie_Item $item */
array_push($podcastArray["episodes"], array(
"guid" => $item->get_id(),
"ingested" => in_array($item->get_id(), $episodeIds),
"title" => $item->get_title(),
// From the RSS spec best practices:
// 'An item's author element provides the e-mail address of the person who wrote the item'
"author" => $item->get_author()->get_email(),
"description" => $item->get_description(),
"pub_date" => $item->get_gmdate(),
"link" => $item->get_link(),
"enclosure" => $item->get_enclosure()
));
}
return $podcastArray;
}
/**
* Fetches a Podcast's rss feed and returns all its episodes with
* the Podcast object
@ -268,9 +227,7 @@ class Application_Service_PodcastService
throw new PodcastNotFoundException();
}
$rss = self::getPodcastFeed($podcast->getDbUrl());
return self::_generatePodcastArray($podcast, $rss);
return $podcast->toArray(BasePeer::TYPE_FIELDNAME);
}
/**

View File

@ -1,44 +1,46 @@
<div class="inner_editor_title">
<h2>
<?php echo _("Editing ") ?>"<span ng-bind="podcast.title" class="title_obj_name"></span>"
</h2>
</div>
<div class="inner_editor_wrapper">
<form class="podcast-metadata">
<input ng-value="podcast.id" class="obj_id" type="hidden"/>
<p>
<label for="podcast_name">
<?php echo _("Podcast Name") ?>
</label>
<input disabled name="podcast_name" ng-model="podcast.title" type="text"/>
</p>
<p>
<label for="podcast_url">
<?php echo _("Podcast URL") ?>
</label>
<input disabled name="podcast_url" ng-model="podcast.url" type="text"/>
</p>
<p>
<label for="podcast_auto_ingest">
<?php echo _("Automatically download latest episodes?") ?>
</label>
<input name="podcast_auto_ingest" ng-model="podcast.auto_ingest" type="checkbox"/>
</p>
</form>
</div>
<table class="datatable podcast_episodes" cellpadding="0" cellspacing="0"></table>
<div class="btn-toolbar clearfix">
<div class="btn-group pull-right">
<button ng-click="discard()" class="btn" type="button" name="cancel">
<?php echo _("Cancel") ?>
</button>
<div class="angular_wrapper" ng-controller="Podcast">
<div class="inner_editor_title">
<h2>
<?php echo _("Editing ") ?>"<span ng-bind="podcast.title" class="title_obj_name"></span>"
</h2>
</div>
<div class='btn-group pull-right'>
<button ng-click="savePodcast()" class="btn" title='<?php echo _("Save podcast") ?>' type="button">
<?php echo _("Save") ?>
</button>
<div class="inner_editor_wrapper">
<form class="podcast-metadata">
<input ng-value="podcast.id" class="obj_id" type="hidden"/>
<p>
<label for="podcast_name">
<?php echo _("Podcast Name") ?>
</label>
<input disabled name="podcast_name" ng-model="podcast.title" type="text"/>
</p>
<p>
<label for="podcast_url">
<?php echo _("Podcast URL") ?>
</label>
<input disabled name="podcast_url" ng-model="podcast.url" type="text"/>
</p>
<p>
<label for="podcast_auto_ingest">
<?php echo _("Automatically download latest episodes?") ?>
</label>
<input name="podcast_auto_ingest" ng-model="podcast.auto_ingest" type="checkbox"/>
</p>
</form>
</div>
<table class="datatable podcast_episodes" cellpadding="0" cellspacing="0"></table>
<div class="btn-toolbar clearfix">
<div class="btn-group pull-right">
<button ng-click="discard()" class="btn" type="button" name="cancel">
<?php echo _("Cancel") ?>
</button>
</div>
<div class='btn-group pull-right'>
<button ng-click="savePodcast()" class="btn" title='<?php echo _("Save podcast") ?>' type="button">
<?php echo _("Save") ?>
</button>
</div>
<div class='success' style='display:none'></span></div>
</div>
<div class='success' style='display:none'></span></div>
</div>

View File

@ -1,44 +1,46 @@
<div class="inner_editor_title">
<div class="angular_wrapper" ng-controller="StationPodcast">
<div class="inner_editor_title">
<h2>
<?php echo _("Editing ") ?>"<span ng-bind="podcast.title" class="title_obj_name"></span>"
</h2>
</div>
<div class="inner_editor_wrapper">
<form class="podcast-metadata">
<input ng-value="podcast.id" class="obj_id" type="hidden"/>
<p>
<label for="podcast_name">
<?php echo _("Podcast Name") ?>
</label>
<input name="podcast_name" ng-model="podcast.title" type="text"/>
</p>
<p>
<label for="podcast_creator">
<?php echo _("Podcast Creator") ?>
</label>
<input name="podcast_creator" ng-model="podcast.creator" type="text"/>
</p>
<p>
<label for="podcast_url">
<?php echo _("Podcast URL") ?>
</label>
<input disabled name="podcast_url" ng-model="podcast.url" type="text"/>
</p>
</form>
</div>
<table class="datatable podcast_episodes" cellpadding="0" cellspacing="0"></table>
<div class="btn-toolbar clearfix">
<div class="btn-group pull-right">
<button ng-click="discard()" class="btn" type="button" name="cancel">
<?php echo _("Cancel") ?>
</button>
</div>
<div class='btn-group pull-right'>
<button ng-click="saveStationPodcast()" class="btn" title='<?php echo _("Save station podcast") ?>' type="button">
<?php echo _("Save") ?>
</button>
<div class="inner_editor_wrapper">
<form class="podcast-metadata">
<input ng-value="podcast.id" class="obj_id" type="hidden"/>
<p>
<label for="podcast_name">
<?php echo _("Podcast Name") ?>
</label>
<input name="podcast_name" ng-model="podcast.title" type="text"/>
</p>
<p>
<label for="podcast_creator">
<?php echo _("Podcast Creator") ?>
</label>
<input name="podcast_creator" ng-model="podcast.creator" type="text"/>
</p>
<p>
<label for="podcast_url">
<?php echo _("Podcast URL") ?>
</label>
<input disabled name="podcast_url" ng-model="podcast.url" type="text"/>
</p>
</form>
</div>
<table class="datatable podcast_episodes" cellpadding="0" cellspacing="0"></table>
<div class="btn-toolbar clearfix">
<div class="btn-group pull-right">
<button ng-click="discard()" class="btn" type="button" name="cancel">
<?php echo _("Cancel") ?>
</button>
</div>
<div class='btn-group pull-right'>
<button ng-click="saveStationPodcast()" class="btn" title='<?php echo _("Save station podcast") ?>' type="button">
<?php echo _("Save") ?>
</button>
</div>
<div class='success' style='display:none'></span></div>
</div>
<div class='success' style='display:none'></span></div>
</div>

View File

@ -475,7 +475,7 @@ li.ui-state-default {
font-size: 14px;
}
.editor_pane_wrapper, .podcast-wrapper {
.editor_pane_wrapper, .angular_wrapper {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;

View File

@ -8,86 +8,168 @@ var AIRTIME = (function (AIRTIME) {
mod = AIRTIME.podcast;
var endpoint = 'rest/podcast/', PodcastTable;
//AngularJS app
var podcastApp = angular.module('podcast', [])
.controller('RestController', function($scope, $http, podcast, tab) {
// We need to pass in the tab object and the episodes table object so we can reference them
//We take a podcast object in as a parameter rather fetching the podcast by ID here because
//when you're creating a new podcast, we already have the object from the result of the POST. We're saving
//a roundtrip by not fetching it again here.
$scope.podcast = podcast;
tab.setName($scope.podcast.title);
$scope.csrf = jQuery("#csrf").val();
tab.contents.find("table").attr("id", "podcast_episodes_" + podcast.id);
// TODO: this solves a race condition, but we should look for the root cause
AIRTIME.tabs.onResize();
var episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatable(podcast, tab);
function PodcastController($scope, $http, podcast, tab) {
// We need to pass in the tab object and the episodes table object so we can reference them
var self = this;
/**
* 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);
episodeTable.reload($scope.podcast.id);
};
//We take a podcast object in as a parameter rather fetching the podcast by ID here because
//when you're creating a new podcast, we already have the object from the result of the POST. We're saving
//a roundtrip by not fetching it again here.
$scope.podcast = podcast;
$scope.tab = tab;
tab.setName($scope.podcast.title);
$scope.csrf = jQuery("#csrf").val();
tab.contents.find("table").attr("id", "podcast_episodes_" + podcast.id);
/**
* Internal function.
*
* Make a PUT request to the server to update the podcast object
*
* @private
*/
function _updatePodcast() {
$http.put(endpoint + $scope.podcast.id, { csrf_token: $scope.csrf, podcast: $scope.podcast })
.success(function() {
episodeTable.reload($scope.podcast.id);
AIRTIME.library.podcastDataTable.fnDraw();
tab.setName($scope.podcast.title);
});
}
/**
* 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();
};
/**
* For imported podcasts.
*
* Save each of the selected episodes and update the podcast object.
*/
$scope.savePodcast = function() {
var episodes = episodeTable.getSelectedRows();
/**
* Internal function.
*
* Make a PUT request to the server to update the podcast object
*
* @private
*/
function _updatePodcast() {
$http.put(endpoint + $scope.podcast.id, {csrf_token: $scope.csrf, podcast: $scope.podcast})
.success(function () {
// episodeTable.reload($scope.podcast.id);
self.episodeTable.getDatatable().fnDraw();
AIRTIME.library.podcastDataTable.fnDraw();
tab.setName($scope.podcast.title);
});
}
/**
* For imported podcasts.
*
* Save each of the selected episodes and update the podcast object.
*/
$scope.savePodcast = $scope.savePodcast || function () {
var episodes = self.episodeTable.getSelectedRows();
// TODO: Should we implement a batch endpoint for this instead?
jQuery.each(episodes, function() {
$http.post(endpoint + $scope.podcast.id + '/episodes', { csrf_token: $scope.csrf, episode: this });
jQuery.each(episodes, function () {
$http.post(endpoint + $scope.podcast.id + '/episodes', {
csrf_token: $scope.csrf,
episode: this
});
});
_updatePodcast();
};
/**
* For the station podcast.
*
* Update the station podcast object.
*/
$scope.saveStationPodcast = function() {
// TODO: We still need a way to delete episodes from the station podcast
_updatePodcast();
/**
* Close the tab and discard any changes made to the podcast data.
*/
$scope.discard = function () {
tab.close();
$scope.podcast = {};
};
self.$scope = $scope;
self.$http = $http;
self.initialize();
}
PodcastController.prototype._initTable = function() {
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 : [
/* GUID */ { "sTitle" : "" , "mDataProp" : "guid" , "sClass" : "podcast_episodes_guid" , "bVisible" : false },
/* Title */ { "sTitle" : $.i18n._("Title") , "mDataProp" : "title" , "sClass" : "podcast_episodes_title" , "sWidth" : "170px" },
/* Author */ { "sTitle" : $.i18n._("Author") , "mDataProp" : "author" , "sClass" : "podcast_episodes_author" , "sWidth" : "170px" },
/* Description */ { "sTitle" : $.i18n._("Description") , "mDataProp" : "description" , "sClass" : "podcast_episodes_description" , "sWidth" : "300px" },
/* Link */ { "sTitle" : $.i18n._("Link") , "mDataProp" : "link" , "sClass" : "podcast_episodes_link" , "sWidth" : "170px" },
/* Publication Date */ { "sTitle" : $.i18n._("Publication Date") , "mDataProp" : "pub_date" , "sClass" : "podcast_episodes_pub_date" , "sWidth" : "170px" }
]
},
buttons = {};
self.episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatable($scope.podcast, $scope.tab, params, buttons);
self.reloadEpisodeTable();
};
PodcastController.prototype.reloadEpisodeTable = function() {
this.episodeTable.reload(this.$scope.podcast.id);
};
PodcastController.prototype.initialize = function() {
var self = this;
// TODO: this solves a race condition, but we should look for the root cause
AIRTIME.tabs.onResize();
self._initTable();
};
function StationPodcastController($scope, $http, podcast, tab) {
// Super call to parent controller
PodcastController.call(this, $scope, $http, podcast, tab);
/**
* For the station podcast.
*
* Update the station podcast object.
*/
$scope.savePodcast = function () {
console.log("Saving station podcast");
// TODO: We still need a way to delete episodes from the station podcast
_updatePodcast();
};
}
StationPodcastController.prototype = Object.create(PodcastController.prototype);
StationPodcastController.prototype._initTable = function() {
var $scope = this.$scope,
buttons = {
0: {
'title' : $.i18n._('Delete'),
'iconClass' : "icon-trash",
extraBtnClass : "btn-danger",
elementId : '',
eventHandlers : {
click: function (e) {
// TODO: delete function for station podcast episodes
}
}
}
},
params = {
sAjaxSource : endpoint + $scope.podcast.id + '/episodes',
aoColumns: [
/* 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" }
]
};
/**
* Close the tab and discard any changes made to the podcast data.
*/
$scope.discard = function() {
tab.close();
$scope.podcast = {};
};
});
this.episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatable($scope.podcast, $scope.tab, params, buttons);
};
StationPodcastController.prototype.reloadEpisodeTable = function() {
self.episodeTable.getDatatable().fnDraw();
};
//AngularJS app
var podcastApp = angular.module('podcast', [])
.controller('Podcast', ['$scope', '$http', 'podcast', 'tab', PodcastController])
.controller('StationPodcast', ['$scope', '$http', 'podcast', 'tab', StationPodcastController]);
/**
* Implement bulk editing of podcasts in order to accommodate the existing selection
@ -129,8 +211,7 @@ var AIRTIME = (function (AIRTIME) {
function _bootstrapAngularApp(podcast, tab) {
podcastApp.value('podcast', podcast);
podcastApp.value('tab', tab);
var wrapper = tab.contents.find(".editor_pane_wrapper");
wrapper.attr("ng-controller", "RestController");
var wrapper = tab.contents.find(".angular_wrapper");
angular.bootstrap(wrapper.get(0), ["podcast"]);
}
@ -178,13 +259,13 @@ var AIRTIME = (function (AIRTIME) {
if (rowData.ingested) return null; // Don't create checkboxes for ingested items
return AIRTIME.widgets.Table.prototype._datatablesCheckboxDataDelegate.call(this, rowData, callType, dataToSave);
};
// Since we're using a static source, define a separate function to fetch and 'reload' the table data
// Since we're sometimes using a static source, define a separate function to fetch and 'reload' the table data
// We use this when we save the Podcast because we need to flag rows the user is ingesting
PodcastTable.prototype.reload = function(id) {
PodcastTable.prototype.reload = function (id) {
var dt = this._datatable;
$.get(endpoint + id, function(json) {
$.get(endpoint + id + '/episodes', function (json) {
dt.fnClearTable();
dt.fnAddData(JSON.parse(json).episodes);
dt.fnAddData(JSON.parse(json));
});
};
}
@ -252,59 +333,40 @@ var AIRTIME = (function (AIRTIME) {
/**
* Initialize the internal datatable for the podcast editor view to hold episode data passed back from the server.
*
* The episode data is taken from the RSS feed XML and contains all episodes in the feed, including but not
* limited to episodes already ingested (downloaded) into Airtime.
*
* Selection for the internal table represents episodes marked for ingest and is disabled for ingested episodes.
*
* @param podcast the podcast data JSON object. Includes episode data
* @param tab Tab object the podcast will be opened in
* @param podcast the podcast data JSON object.
* @param tab Tab object the podcast will be opened in
* @param params JSON object containing datatables parameters to override
* @param buttons JSON object containing datatables button parameters
*
* @returns {*} the created Table object
*/
mod.initPodcastEpisodeDatatable = function(podcast, tab) {
var aoColumns = [
/* GUID */ { "sTitle" : "" , "mDataProp" : "guid" , "sClass" : "podcast_episodes_guid" , "bVisible" : false },
/* Title */ { "sTitle" : $.i18n._("Title") , "mDataProp" : "title" , "sClass" : "podcast_episodes_title" , "sWidth" : "170px" },
/* Author */ { "sTitle" : $.i18n._("Author") , "mDataProp" : "author" , "sClass" : "podcast_episodes_author" , "sWidth" : "170px" },
/* Description */ { "sTitle" : $.i18n._("Description") , "mDataProp" : "description" , "sClass" : "podcast_episodes_description" , "sWidth" : "300px" },
/* Link */ { "sTitle" : $.i18n._("Link") , "mDataProp" : "link" , "sClass" : "podcast_episodes_link" , "sWidth" : "170px" },
/* Publication Date */ { "sTitle" : $.i18n._("Publication Date") , "mDataProp" : "pub_date" , "sClass" : "podcast_episodes_pub_date" , "sWidth" : "170px" }
];
mod.initPodcastEpisodeDatatable = function(podcast, tab, params, buttons) {
params = $.extend(params,
{
oColVis : {
sAlign: "right",
aiExclude: [0, 1],
buttonText: $.i18n._("Columns"),
iOverlayFade: 0,
oColReorder: {
iFixedColumns: 1 // Checkbox
}
}
}
);
if (typeof PodcastTable === 'undefined') {
_initPodcastTable();
}
var podcastToolbarButtons = AIRTIME.widgets.Table.getStandardToolbarButtons();
podcastToolbarButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.DELETE].eventHandlers.click = function(e) {
// TODO: add {this} reference to event handlers and implement deletion for station podcasts
};
// Set up the div with id "podcast_table" as a datatable.
var podcastEpisodesTableWidget = new PodcastTable(
tab.contents.find('.podcast_episodes'), // DOM node to create the table inside.
true, // Enable item selection
podcastToolbarButtons, // Toolbar buttons
{ // Datatables overrides.
'aoColumns' : aoColumns,
'bServerSide' : false,
// We want to make as few round trips as possible, so we get
// the episode data alongside the Podcast data and pass it in
// as json. Doing this caches all the episode data on the front-end,
// which means we also don't need to go back to the server for pagination
'sAjaxSource' : null,
'aaData' : podcast.episodes,
"oColVis": {
"sAlign": "right",
"aiExclude": [0, 1],
"buttonText": $.i18n._("Columns"),
"iOverlayFade": 0,
'oColReorder': {
'iFixedColumns': 1 // Checkbox
}
}
}
true, // Enable item selection
buttons, // Toolbar buttons
params // Datatables overrides.
);
podcastEpisodesTableWidget.getDatatable().addTitles("td");

View File

@ -15,7 +15,7 @@ var AIRTIME = (function (AIRTIME) {
//AngularJS app
var publishApp = angular.module(PUBLISH_APP_NAME, [])
.controller('RestController', function ($scope, $http, mediaId, tab) {
.controller('Publish', function ($scope, $http, mediaId, tab) {
$scope.publishSources = {};
function init () {
@ -100,7 +100,7 @@ var AIRTIME = (function (AIRTIME) {
publishApp.value('mediaId', mediaId);
publishApp.value('tab', tab);
var wrapper = AIRTIME.tabs.getActiveTab().contents.find(".editor_pane_wrapper");
wrapper.attr("ng-controller", "RestController");
wrapper.attr("ng-controller", "Publish");
angular.bootstrap(wrapper.get(0), [PUBLISH_APP_NAME]);
}