Merge branch 'saas-dev-publishing' of github.com:sourcefabric/airtime into saas-dev-publishing

This commit is contained in:
Duncan Sommerville 2015-11-16 11:36:24 -05:00
commit 610d860d6a
19 changed files with 271 additions and 200 deletions

View File

@ -37,6 +37,7 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
->add(new Zend_Acl_Resource('rest:show-image')) ->add(new Zend_Acl_Resource('rest:show-image'))
->add(new Zend_Acl_Resource('rest:podcast')) ->add(new Zend_Acl_Resource('rest:podcast'))
->add(new Zend_Acl_Resource('rest:podcast-episodes')) ->add(new Zend_Acl_Resource('rest:podcast-episodes'))
->add(new Zend_Acl_Resource('podcast'))
->add(new Zend_Acl_Resource('billing')) ->add(new Zend_Acl_Resource('billing'))
->add(new Zend_Acl_Resource('thank-you')) ->add(new Zend_Acl_Resource('thank-you'))
->add(new Zend_Acl_Resource('provisioning')) ->add(new Zend_Acl_Resource('provisioning'))
@ -76,6 +77,7 @@ $ccAcl->allow('G', 'index')
->allow('H', 'rest:media') ->allow('H', 'rest:media')
->allow('H', 'rest:podcast') ->allow('H', 'rest:podcast')
->allow('H', 'rest:podcast-episodes') ->allow('H', 'rest:podcast-episodes')
->allow('H', 'podcast')
->allow('H', 'preference', 'is-import-in-progress') ->allow('H', 'preference', 'is-import-in-progress')
->allow('H', 'usersettings') ->allow('H', 'usersettings')
->allow('H', 'plupload') ->allow('H', 'plupload')

View File

@ -8,6 +8,13 @@
* the navigation container below. * the navigation container below.
*/ */
$pages = array( $pages = array(
array(
'label' => "<i class='icon-music icon-white'></i>"._('My Podcast'),
'module' => 'default',
'controller' => 'podcast',
'action' => 'station',
'resource' => 'podcast'
),
array( array(
'label' => "<i class='icon-globe icon-white'></i>"._('Radio Page'), 'label' => "<i class='icon-globe icon-white'></i>"._('Radio Page'),
'uri' => '/', 'uri' => '/',

View File

@ -0,0 +1,35 @@
<?php
class PodcastController extends Zend_Controller_Action {
public function init() {
$CC_CONFIG = Config::getConfig();
$baseUrl = Application_Common_OsPath::getBaseDir();
$headScript = $this->view->headScript();
AirtimeTableView::injectTableJavaScriptDependencies($headScript, $baseUrl, $CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/widgets/table.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/podcast.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/dataTables.colReorder.min.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/station_podcast.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/dashboard.css?'.$CC_CONFIG['airtime_version']);
}
/**
* Renders the Station podcast view
*/
public function stationAction() {
$stationPodcastId = Application_Model_Preference::getStationPodcastId();
$podcast = Application_Service_PodcastService::getPodcastById($stationPodcastId);
$this->view->podcast = json_encode($podcast);
$this->view->form = new Application_Form_StationPodcast();
}
}

View File

@ -3,28 +3,26 @@
class Application_Form_PodcastPreferences extends Zend_Form_SubForm { class Application_Form_PodcastPreferences extends Zend_Form_SubForm {
public function init() { public function init() {
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/preferences_podcast.phtml'))
));
$isPrivate = Application_Model_Preference::getStationPodcastPrivacy(); $isPrivate = Application_Model_Preference::getStationPodcastPrivacy();
$stationPodcastPrivacy = new Zend_Form_Element_Radio('stationPodcastPrivacy'); $stationPodcastPrivacy = new Zend_Form_Element_Radio("stationPodcastPrivacy");
$stationPodcastPrivacy->setLabel(_('My Podcast Feed Privacy')); $stationPodcastPrivacy->setLabel(_('Feed Privacy'));
$stationPodcastPrivacy->setMultiOptions(array( $stationPodcastPrivacy->setMultiOptions(array(
_("Public"), _("Public"),
_("Private"), _("Private"),
)); ));
$stationPodcastPrivacy->setValue($isPrivate); $stationPodcastPrivacy->setValue($isPrivate);
$stationPodcastPrivacy->setDecorators(array('ViewHelper', 'Label'));
$this->addElement($stationPodcastPrivacy); $this->addElement($stationPodcastPrivacy);
$stationPodcast = PodcastQuery::create()->findOneByDbId(Application_Model_Preference::getStationPodcastId()); $stationPodcast = PodcastQuery::create()->findOneByDbId(Application_Model_Preference::getStationPodcastId());
$url = $stationPodcast->getDbUrl(); $url = $stationPodcast->getDbUrl();
$feedUrl = new Zend_Form_Element_Text("stationPodcastFeedUrl:"); $feedUrl = new Zend_Form_Element_Text("stationPodcastFeedUrl");
$feedUrl->setAttrib('class', 'input_text') $feedUrl->setAttrib('class', 'input_text')
->setAttrib('disabled', 'disabled') ->setAttrib('disabled', 'disabled')
->setRequired(false) ->setRequired(false)
->setLabel(_("My Podcast Feed URL")) ->setLabel(_("Feed URL"))
->setValue($url); ->setValue($url);
$feedUrl->setDecorators(array('ViewHelper', 'Label'));
$this->addElement($feedUrl); $this->addElement($feedUrl);
} }

View File

@ -26,10 +26,6 @@ class Application_Form_Preferences extends Zend_Form
$this->addSubForm($general_pref, 'preferences_general'); $this->addSubForm($general_pref, 'preferences_general');
// Station Podcast form
$podcastPreferences = new Application_Form_PodcastPreferences();
$this->addSubForm($podcastPreferences, 'preferences_podcast');
//tunein form //tunein form
$tuneinPreferences = new Application_Form_TuneInPreferences(); $tuneinPreferences = new Application_Form_TuneInPreferences();
$this->addSubForm($tuneinPreferences, 'preferences_tunein'); $this->addSubForm($tuneinPreferences, 'preferences_tunein');

View File

@ -0,0 +1,11 @@
<?php
class Application_Form_StationPodcast extends Zend_Form {
public function init() {
// Station Podcast form
$podcastPreferences = new Application_Form_PodcastPreferences();
$this->addSubForm($podcastPreferences, 'preferences_podcast');
}
}

View File

@ -99,7 +99,7 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
$disk = $partitions[0]; $disk = $partitions[0];
$used = $disk->totalSpace-$disk->totalFreeSpace; $used = $disk->totalSpace-$disk->totalFreeSpace;
$total = $disk->totalSpace; $total = $disk->totalSpace;
echo "var remainingDiskSpace = ".$disk->totalFreeSpace; echo "var remainingDiskSpace = ".$disk->totalFreeSpace.";";
?> ?>
</script> </script>
<div id="disk_usage" style="height: 13px; position:fixed; bottom: 5px; left: 10px;"> <div id="disk_usage" style="height: 13px; position:fixed; bottom: 5px; left: 10px;">

View File

@ -188,14 +188,19 @@ class Rest_PodcastController extends Zend_Rest_Controller
$this->_helper->json->sendJson($responseBody); $this->_helper->json->sendJson($responseBody);
} }
/**
* @throws PodcastNotFoundException
*
* @deprecated
*/
public function stationAction() { public function stationAction() {
$stationPodcastId = Application_Model_Preference::getStationPodcastId(); $stationPodcastId = Application_Model_Preference::getStationPodcastId();
$podcast = Application_Service_PodcastService::getPodcastById($stationPodcastId); $podcast = Application_Service_PodcastService::getPodcastById($stationPodcastId);
$path = 'podcast/station_podcast.phtml'; $path = 'podcast/station.phtml';
$this->view->podcast = $podcast; $this->view->podcast = $podcast;
$this->_helper->json->sendJson(array( $this->_helper->json->sendJson(array(
"podcast" => json_encode($podcast), "podcast" => json_encode($podcast),
"html" => $this->view->render($path), "html" => $this->view->render($path)
)); ));
} }

View File

@ -281,7 +281,7 @@ class Application_Service_PodcastService
// Check the StationPodcast table rather than checking // Check the StationPodcast table rather than checking
// the station podcast ID key in preferences for extensibility // the station podcast ID key in preferences for extensibility
$podcast = StationPodcastQuery::create()->findOneByDbPodcastId($podcastId); $podcast = StationPodcastQuery::create()->findOneByDbPodcastId($podcastId);
$path = $podcast ? 'podcast/station_podcast.phtml' : 'podcast/podcast.phtml'; $path = $podcast ? 'podcast/station.phtml' : 'podcast/podcast.phtml';
$podcast = Application_Service_PodcastService::getPodcastById($podcastId); $podcast = Application_Service_PodcastService::getPodcastById($podcastId);
return array( return array(
"podcast" => json_encode($podcast), "podcast" => json_encode($podcast),

View File

@ -3,11 +3,6 @@
<?php echo $this->element->getSubform('preferences_general') ?> <?php echo $this->element->getSubform('preferences_general') ?>
<h3 class="collapsible-header" id="podcast-heading"><span class="arrow-icon"></span><?php echo _("My Podcast Settings"); ?></h3>
<div class="collapsible-content" id="podcast-settings">
<?php echo $this->element->getSubform('preferences_podcast') ?>
</div>
<h3 class="collapsible-header" id="tunein-pref-heading"><span class="arrow-icon"></span><?php echo _("TuneIn Settings"); ?></h3> <h3 class="collapsible-header" id="tunein-pref-heading"><span class="arrow-icon"></span><?php echo _("TuneIn Settings"); ?></h3>
<div class="collapsible-content" id="tunein-settings"> <div class="collapsible-content" id="tunein-settings">
<?php echo $this->element->getSubform('preferences_tunein') ?> <?php echo $this->element->getSubform('preferences_tunein') ?>

View File

@ -1,6 +1,4 @@
<fieldset class="padded"> <fieldset class="padded">
<dl class="zend_form"> <?php echo $this->element->getElement('stationPodcastPrivacy')->render() ?>
<?php echo $this->element->getElement('stationPodcastPrivacy')->render() ?> <?php echo $this->element->getElement('stationPodcastFeedUrl')->render() ?>
<?php echo $this->element->getElement('stationPodcastFeedUrl')->render() ?>
</dl>
</fieldset> </fieldset>

View File

@ -7,11 +7,14 @@
<div class="inner_editor_wrapper"> <div class="inner_editor_wrapper">
<form class="podcast-metadata"> <form class="podcast-metadata">
<input ng-value="podcast.id" class="obj_id" type="hidden"/> <input ng-value="podcast.id" class="obj_id" type="hidden"/>
<label for="podcast_name"><?php echo _("Podcast Name") ?></label> <div>
<input disabled name="podcast_name" ng-model="podcast.title" type="text"/> <label for="podcast_name"><?php echo _("Podcast Name: ") ?></label>
<span class="podcast-metadata-field">{{podcast.title}}</span>
<label for="podcast_url"><?php echo _("Podcast URL") ?></label> </div>
<input disabled name="podcast_url" ng-model="podcast.url" type="text"/> <div>
<label for="podcast_url"><?php echo _("Podcast URL: ") ?></label>
<span class="podcast-metadata-field">{{podcast.url}}</span>
</div>
<label for="podcast_auto_ingest"><?php echo _("Automatically download latest episodes?") ?></label> <label for="podcast_auto_ingest"><?php echo _("Automatically download latest episodes?") ?></label>
<input name="podcast_auto_ingest" ng-model="podcast.auto_ingest" type="checkbox"/> <input name="podcast_auto_ingest" ng-model="podcast.auto_ingest" type="checkbox"/>

View File

@ -0,0 +1,111 @@
<div id="station_podcast">
<div class="angular_wrapper" ng-controller="StationPodcast">
<div class="station_podcast_wrapper">
<div class="inner_editor_title">
<h2>
<span class="title_obj_name"><?php echo _("My Podcast") ?></span>
</h2>
<a href="{{podcast.url}}" target="_blank">
<button class="btn"><?php echo _("View Feed") ?></button>
</a>
</div>
<form class="podcast-metadata">
<input ng-value="podcast.id" class="obj_id" type="hidden"/>
<h3 class="collapsible-header"><span class="arrow-icon"></span><?php echo _("General Fields") ?></h3>
<div class="collapsible-content">
<fieldset class="padded">
<label><?php echo _("Name") ?></label>
<input name="podcast_name" ng-model="podcast.title" type="text"/>
<label><?php echo _("Creator") ?></label>
<input name="podcast_creator" ng-model="podcast.creator" type="text"/>
<label><?php echo _("URL") ?></label>
<input disabled name="podcast_url" ng-model="podcast.url" type="text"/>
<label><?php echo _("Description") ?></label>
<textarea name="podcast_description" ng-model="podcast.description"></textarea>
<label><?php echo _("Language") ?></label>
<select name="podcast_language" ng-model="podcast.language">
<?php
foreach(Application_Common_LocaleHelper::getISO6391LanguageCodes() as $code=>$lang) {
echo "<option value='$code'>$lang</option>";
}
?>
</select>
<label><?php echo _("Copyright") ?></label>
<input name="podcast_copyright" ng-model="podcast.copyright" type="text"/>
<label><?php echo _("Link") ?></label>
<input name="podcast_link" ng-model="podcast.link" type="url"/>
</fieldset>
</div>
<h3 class="collapsible-header"><span class="arrow-icon"></span><?php echo _("iTunes Fields") ?></h3>
<div class="collapsible-content">
<fieldset class="padded">
<label><?php echo _("Author") ?></label>
<input name="podcast_itunes_author" ng-model="podcast.itunes_author" type="text"/>
<label><?php echo _("Keywords") ?></label>
<input name="podcast_itunes_keywords" ng-model="podcast.itunes_keywords" type="text"/>
<label><?php echo _("Summary") ?></label>
<textarea name="podcast_itunes_summary" ng-model="podcast.itunes_summary"></textarea>
<label><?php echo _("Subtitle") ?></label>
<textarea name="podcast_itunes_subtitle" ng-model="podcast.itunes_subtitle"></textarea>
<label><?php echo _("Category") ?></label>
<input name="podcast_itunes_category" ng-model="podcast.itunes_category" type="text"/>
<label><?php echo _("Explicit") ?></label>
<input name="podcast_itunes_explicit" ng-model="podcast.itunes_explicit" type="checkbox"/>
</fieldset>
</div>
<h3 class="collapsible-header" id="podcast-heading"><span class="arrow-icon"></span><?php echo _("Privacy Settings"); ?></h3>
<div class="collapsible-content" id="podcast-settings">
<?php echo $this->form->getSubform('preferences_podcast') ?>
</div>
<p id="station_podcast_help_text">
<?php echo(sprintf(_("For detailed information on what these metadata fields mean, please see the %sRSS specification%s
or %sApple's podcasting documentation%s."),
'<a href="http://cyber.law.harvard.edu/rss/rss.html#requiredChannelElements">', '</a>',
'<a target="_blank" href="http://www.apple.com/ca/itunes/podcasts/specs.html">', "</a>")); ?>
</p>
</form>
<div class="btn-toolbar clearfix">
<div class='btn-group pull-right'>
<button ng-click="savePodcast()" 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>
<table class="datatable podcast_episodes" cellpadding="0" cellspacing="0"></table>
</div>
</div>
<script>
$(document).ready(function () {
<?php echo "var podcast = " . $this->podcast . ";" ?>
AIRTIME.podcast.podcastApp.value('podcast', podcast);
AIRTIME.podcast.podcastApp.value('tab', null);
var wrapper = $(".angular_wrapper");
angular.bootstrap(wrapper.get(0), ["podcast"]);
});
$('.collapsible-header').click(function() {
$(this).next().toggle('fast');
$(this).toggleClass("closed");
return false;
});
</script>

View File

@ -1,99 +0,0 @@
<div class="angular_wrapper" ng-controller="StationPodcast">
<div class="inner_editor_title">
<h2>
<span class="title_obj_name"><?php echo _("My Podcast") ?></span>
</h2>
<a href="{{podcast.url}}" target="_blank">
<button class="btn"><?php echo _("View Feed") ?></button>
</a>
</div>
<div class="inner_editor_wrapper station_podcast_wrapper">
<form class="podcast-metadata">
<input ng-value="podcast.id" class="obj_id" type="hidden"/>
<div>
<label><?php echo _("Name") ?></label>
<input name="podcast_name" ng-model="podcast.title" type="text"/>
</div>
<div>
<label><?php echo _("Creator") ?></label>
<input name="podcast_creator" ng-model="podcast.creator" type="text"/>
</div>
<div>
<label><?php echo _("URL") ?></label>
<input disabled name="podcast_url" ng-model="podcast.url" type="text"/>
</div>
<div>
<label><?php echo _("Description") ?></label>
<textarea name="podcast_description" ng-model="podcast.description"></textarea>
</div>
<div>
<label><?php echo _("Language") ?></label>
<select name="podcast_language" ng-model="podcast.language">
<?php
foreach(Application_Common_LocaleHelper::getISO6391LanguageCodes() as $code=>$lang) {
echo "<option value='$code'>$lang</option>";
}
?>
</select>
</div>
<div>
<label><?php echo _("Copyright") ?></label>
<input name="podcast_copyright" ng-model="podcast.copyright" type="text"/>
</div>
<div>
<label><?php echo _("Link") ?></label>
<input name="podcast_link" ng-model="podcast.link" type="url"/>
</div>
<fieldset>
<legend><?php echo _("iTunes Fields") ?></legend>
<label><?php echo _("Author") ?></label>
<input name="podcast_itunes_author" ng-model="podcast.itunes_author" type="text"/>
<label><?php echo _("Keywords") ?></label>
<input name="podcast_itunes_keywords" ng-model="podcast.itunes_keywords" type="text"/>
<label><?php echo _("Summary") ?></label>
<textarea name="podcast_itunes_summary" ng-model="podcast.itunes_summary"></textarea>
<label><?php echo _("Subtitle") ?></label>
<textarea name="podcast_itunes_subtitle" ng-model="podcast.itunes_subtitle"></textarea>
<label><?php echo _("Category") ?></label>
<input name="podcast_itunes_category" ng-model="podcast.itunes_category" type="text"/>
<label><?php echo _("Explicit") ?></label>
<input name="podcast_itunes_explicit" ng-model="podcast.itunes_explicit" type="checkbox"/>
</fieldset>
<p>
<?php echo(sprintf(_("For detailed information on what these metadata fields mean, please see the %sRSS specification%s
or %sApple's podcasting documentation%s."),
'<a href="http://cyber.law.harvard.edu/rss/rss.html#requiredChannelElements">', '</a>',
'<a target="_blank" href="http://www.apple.com/ca/itunes/podcasts/specs.html">', "</a>")); ?>
</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 station podcast") ?>' type="button">
<?php echo _("Save") ?>
</button>
</div>
<div class='success' style='display:none'></span></div>
</div>
</div>

View File

@ -0,0 +1,52 @@
#station_podcast {
position: relative;
width: 100%;
height: 100%;
}
#station_podcast .angular_wrapper {
flex-flow: row;
overflow: hidden;
}
#station_podcast .inner_editor_title * {
margin: 0;
}
#station_podcast .collapsible-header {
margin: 0 0 20px;
top: 20px;
}
#station_podcast .dataTables_wrapper {
margin-left: 10px
}
#station_podcast .dataTables_filter input {
width: 100%;
}
.station_podcast_wrapper {
padding-right: 4px;
overflow-x: hidden;
}
#station_podcast_help_text {
padding-top: 20px;
font-size: 14px;
}
#podcast-settings label:nth-child(even) {
width: 100%;
text-align: left;
}
#podcast-settings label > input {
width: auto;
margin: 6px 6px 0 25%;
}
label {
text-align: right;
line-height: 26px;
}

View File

@ -4053,6 +4053,13 @@ li .ui-state-hover {
float: left; float: left;
} }
.podcast-metadata-field {
display: inline-block;
width: 60%;
margin: 4px 0;
line-height: 24px;
}
.podcast_episodes_imported { .podcast_episodes_imported {
text-align: center !important; text-align: center !important;
} }

View File

@ -90,7 +90,7 @@ var AIRTIME = (function(AIRTIME) {
emptyRow.hide(); emptyRow.hide();
var mediaType = parseInt($('.media_type_selector.selected').data('selection-id')), var mediaType = parseInt($('.media_type_selector.selected').data('selection-id')),
img = wrapper.find('.empty_placeholder_image'); img = wrapper.find('.empty_placeholder_image');
if (isNaN(mediaType)) { if (!opts && isNaN(mediaType)) {
return; return;
} }
// Remove all classes for when we change between empty media types // Remove all classes for when we change between empty media types

View File

@ -1405,6 +1405,7 @@ var AIRTIME = (function(AIRTIME) {
}; };
// Add a button to view the station podcast // Add a button to view the station podcast
/* Moved to a separate top-level menu item
podcastToolbarButtons["StationPodcast"] = { podcastToolbarButtons["StationPodcast"] = {
title : $.i18n._("My Podcast"), title : $.i18n._("My Podcast"),
iconClass : "icon-music", iconClass : "icon-music",
@ -1415,6 +1416,7 @@ var AIRTIME = (function(AIRTIME) {
}, },
validateConstraints: function () { return true; } validateConstraints: function () { return true; }
}; };
*/
//Set up the div with id "podcast_table" as a datatable. //Set up the div with id "podcast_table" as a datatable.
mod.podcastTableWidget = new AIRTIME.widgets.Table( mod.podcastTableWidget = new AIRTIME.widgets.Table(
@ -1586,6 +1588,8 @@ var AIRTIME = (function(AIRTIME) {
// If we load sequentially there's a delay before the table appears // If we load sequentially there's a delay before the table appears
aaData : {}, aaData : {},
oColVis : { oColVis : {
buttonText: $.i18n._("Columns"),
iOverlayFade: 0,
aiExclude: [0, 1, 2] aiExclude: [0, 1, 2]
}, },
oColReorder: { oColReorder: {

View File

@ -7,7 +7,7 @@ var AIRTIME = (function (AIRTIME) {
mod = AIRTIME.podcast; mod = AIRTIME.podcast;
var endpoint = 'rest/podcast/', PodcastEpisodeTable, $stationPodcastTab; var endpoint = '/rest/podcast/', PodcastEpisodeTable;
/** /**
* PodcastController constructor. * PodcastController constructor.
@ -23,7 +23,8 @@ var AIRTIME = (function (AIRTIME) {
*/ */
function PodcastController($scope, $http, 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 // We need to pass in the tab object and the episodes table object so we can reference them
var self = this; var self = this,
view = tab ? tab.contents : $(document);
//We take a podcast object in as a parameter rather fetching the podcast by ID here because //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 //when you're creating a new podcast, we already have the object from the result of the POST. We're saving
@ -31,7 +32,7 @@ var AIRTIME = (function (AIRTIME) {
$scope.podcast = podcast; $scope.podcast = podcast;
$scope.tab = tab; $scope.tab = tab;
$scope.csrf = jQuery("#csrf").val(); $scope.csrf = jQuery("#csrf").val();
tab.contents.find("table").attr("id", "podcast_episodes_" + podcast.id); view.find("table").attr("id", "podcast_episodes_" + podcast.id);
/** /**
* Save and update the podcast object. * Save and update the podcast object.
@ -40,7 +41,7 @@ var AIRTIME = (function (AIRTIME) {
$http.put(endpoint + $scope.podcast.id, {csrf_token: $scope.csrf, podcast: $scope.podcast}) $http.put(endpoint + $scope.podcast.id, {csrf_token: $scope.csrf, podcast: $scope.podcast})
.success(function () { .success(function () {
AIRTIME.library.podcastDataTable.fnDraw(); AIRTIME.library.podcastDataTable.fnDraw();
tab.close(); tab || tab.close();
}); });
}; };
@ -48,7 +49,7 @@ var AIRTIME = (function (AIRTIME) {
* Close the tab and discard any changes made to the podcast data. * Close the tab and discard any changes made to the podcast data.
*/ */
$scope.discard = function () { $scope.discard = function () {
tab.close(); tab || tab.close();
$scope.podcast = {}; $scope.podcast = {};
}; };
@ -95,35 +96,6 @@ var AIRTIME = (function (AIRTIME) {
function StationPodcastController($scope, $http, podcast, tab) { function StationPodcastController($scope, $http, podcast, tab) {
// Super call to parent controller // Super call to parent controller
PodcastController.call(this, $scope, $http, podcast, tab); PodcastController.call(this, $scope, $http, podcast, tab);
// Store the station podcast tab in module scope so it can be checked if the user clicks the
// Station Podcast button again - this way we don't have to go back to the server to get the ID.
$stationPodcastTab = tab;
/**
* @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; return this;
} }
@ -164,18 +136,6 @@ var AIRTIME = (function (AIRTIME) {
StationPodcastController.prototype._initTable = function() { StationPodcastController.prototype._initTable = function() {
var self = this, $scope = this.$scope, var self = this, $scope = this.$scope,
buttons = { buttons = {
editBtn: {
title : $.i18n._('Edit Metadata'),
iconClass : 'icon-pencil',
extraBtnClass : '',
elementId : '',
eventHandlers : {
click: self.openSelectedTabEditors.bind(self)
},
validateConstraints: function () {
return this.getSelectedRows().length >= 1;
}
},
deleteBtn: { deleteBtn: {
title : $.i18n._('Unpublish'), title : $.i18n._('Unpublish'),
iconClass : 'icon-trash', iconClass : 'icon-trash',
@ -187,8 +147,7 @@ var AIRTIME = (function (AIRTIME) {
validateConstraints: function () { validateConstraints: function () {
return this.getSelectedRows().length >= 1; return this.getSelectedRows().length >= 1;
} }
}, }
slideToggle: {}
}, },
params = { params = {
sAjaxSource : endpoint + $scope.podcast.id + '/episodes', sAjaxSource : endpoint + $scope.podcast.id + '/episodes',
@ -200,7 +159,7 @@ var AIRTIME = (function (AIRTIME) {
}; };
this.episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatable( this.episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatable(
$scope.tab.contents.find('.podcast_episodes'), $('.podcast_episodes'),
params, params,
buttons, buttons,
{ {
@ -222,9 +181,7 @@ var AIRTIME = (function (AIRTIME) {
* Initialize the Station podcast. * Initialize the Station podcast.
*/ */
StationPodcastController.prototype.initialize = function() { StationPodcastController.prototype.initialize = function() {
PodcastController.prototype.initialize.call(this);
// We want to override the default tab name behaviour and use "My Podcast" for clarity // We want to override the default tab name behaviour and use "My Podcast" for clarity
this.$scope.tab.setName(jQuery.i18n._("My Podcast"));
this._initTable(); this._initTable();
}; };
@ -242,7 +199,7 @@ var AIRTIME = (function (AIRTIME) {
* *
* Bootstrapped for each podcast or Station podcast tab. * Bootstrapped for each podcast or Station podcast tab.
*/ */
var podcastApp = angular.module('podcast', []) mod.podcastApp = angular.module('podcast', [])
.controller('Podcast', ['$scope', '$http', 'podcast', 'tab', PodcastController]) .controller('Podcast', ['$scope', '$http', 'podcast', 'tab', PodcastController])
.controller('StationPodcast', ['$scope', '$http', 'podcast', 'tab', StationPodcastController]); .controller('StationPodcast', ['$scope', '$http', 'podcast', 'tab', StationPodcastController]);
@ -285,8 +242,8 @@ var AIRTIME = (function (AIRTIME) {
* @private * @private
*/ */
function _bootstrapAngularApp(podcast, tab) { function _bootstrapAngularApp(podcast, tab) {
podcastApp.value('podcast', podcast); mod.podcastApp.value('podcast', podcast);
podcastApp.value('tab', tab); mod.podcastApp.value('tab', tab);
var wrapper = tab.contents.find(".angular_wrapper"); var wrapper = tab.contents.find(".angular_wrapper");
angular.bootstrap(wrapper.get(0), ["podcast"]); angular.bootstrap(wrapper.get(0), ["podcast"]);
} }
@ -481,19 +438,6 @@ var AIRTIME = (function (AIRTIME) {
}); });
}; };
/**
* Open a tab to view and edit the station podcast.
*/
mod.openStationPodcast = function () {
if (typeof $stationPodcastTab === 'undefined') {
$.get(endpoint + 'station', function(json) {
_initAppFromResponse(json);
});
} else if ($stationPodcastTab != AIRTIME.tabs.getActiveTab()) {
$stationPodcastTab.switchTo();
}
};
/** /**
* Create a bulk request to edit all currently selected podcasts. * Create a bulk request to edit all currently selected podcasts.
*/ */
@ -587,10 +531,12 @@ var AIRTIME = (function (AIRTIME) {
{ {
bDeferRender: true, bDeferRender: true,
oColVis: { oColVis: {
buttonText: $.i18n._("Columns"),
iOverlayFade: 0,
aiExclude: [0, 1], aiExclude: [0, 1],
oColReorder: { },
iFixedColumns: 1 // Checkbox oColReorder: {
} iFixedColumns: 1 // Checkbox
}, },
fnCreatedRow: function(nRow, aData, iDataIndex) { fnCreatedRow: function(nRow, aData, iDataIndex) {
var self = this; var self = this;