From cb62cff2779003131cffad3b79e02577b99d9081 Mon Sep 17 00:00:00 2001 From: Robbt Date: Wed, 12 Dec 2018 17:17:37 -0500 Subject: [PATCH 01/11] give user ability to edit podcast name --- airtime_mvc/application/views/scripts/podcast/podcast.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/views/scripts/podcast/podcast.phtml b/airtime_mvc/application/views/scripts/podcast/podcast.phtml index 1472bc78b..aa2a07603 100644 --- a/airtime_mvc/application/views/scripts/podcast/podcast.phtml +++ b/airtime_mvc/application/views/scripts/podcast/podcast.phtml @@ -9,7 +9,7 @@
- +
From 6cd5550721df91ae3865c4aa261e43ddea8d40e7 Mon Sep 17 00:00:00 2001 From: Robbt Date: Wed, 12 Dec 2018 22:53:28 -0500 Subject: [PATCH 02/11] added button to generate smartblock and playlist for podcast --- .../application/modules/rest/Bootstrap.php | 11 +++++++++++ .../rest/controllers/PodcastController.php | 19 +++++++++++++++++++ .../application/services/PodcastService.php | 6 ++++++ .../views/scripts/podcast/podcast.phtml | 5 +++++ .../public/js/airtime/library/podcast.js | 11 +++++++++++ 5 files changed, 52 insertions(+) diff --git a/airtime_mvc/application/modules/rest/Bootstrap.php b/airtime_mvc/application/modules/rest/Bootstrap.php index b8575a2cf..3ac5a1891 100644 --- a/airtime_mvc/application/modules/rest/Bootstrap.php +++ b/airtime_mvc/application/modules/rest/Bootstrap.php @@ -21,6 +21,17 @@ class Rest_Bootstrap extends Zend_Application_Module_Bootstrap ); $router->addRoute('podcast-bulk', $podcastBulkRoute); + + $smartblockPodcastRoute = new Zend_Controller_Router_Route( + 'rest/podcast/smartblock', + array( + 'controller' => 'podcast', + 'action' => 'smartblock', + 'module' => 'rest' + ) + ); + $router->addRoute('podcast-smartblock', $smartblockPodcastRoute); + $stationPodcastRoute = new Zend_Controller_Router_Route( 'rest/podcast/station', array( diff --git a/airtime_mvc/application/modules/rest/controllers/PodcastController.php b/airtime_mvc/application/modules/rest/controllers/PodcastController.php index f80b16c34..b3fc38832 100644 --- a/airtime_mvc/application/modules/rest/controllers/PodcastController.php +++ b/airtime_mvc/application/modules/rest/controllers/PodcastController.php @@ -191,6 +191,25 @@ class Rest_PodcastController extends Zend_Rest_Controller $this->_helper->json->sendJson($responseBody); } + + /** + * Endpoint for triggering the generation of a smartblock and playlist to match the podcast name + */ + + public function smartblockAction() { + + $id = $this->_getParam('id', []); + if (!$id) { + return; + } + $podcast = Application_Service_PodcastService::getPodcastById($id); + + logging::info($podcast); + Application_Service_PodcastService::createPodcastSmartblockAndPlaylist($podcast); + } + + + /** * @throws PodcastNotFoundException * diff --git a/airtime_mvc/application/services/PodcastService.php b/airtime_mvc/application/services/PodcastService.php index b9aecb389..f5abb8590 100644 --- a/airtime_mvc/application/services/PodcastService.php +++ b/airtime_mvc/application/services/PodcastService.php @@ -167,6 +167,12 @@ class Application_Service_PodcastService public static function createPodcastSmartblockAndPlaylist($podcast) { + if (is_array($podcast)) { + $newpodcast = new Podcast(); + $newpodcast->fromArray($podcast, BasePeer::TYPE_FIELDNAME); + $podcast = $newpodcast; + } + // Base class $newBl = new Application_Model_Block(); $newBl->setCreator(Application_Model_User::getCurrentUser()->getId()); $newBl->setName($podcast->getDbTitle()); diff --git a/airtime_mvc/application/views/scripts/podcast/podcast.phtml b/airtime_mvc/application/views/scripts/podcast/podcast.phtml index aa2a07603..6c715d8b3 100644 --- a/airtime_mvc/application/views/scripts/podcast/podcast.phtml +++ b/airtime_mvc/application/views/scripts/podcast/podcast.phtml @@ -25,6 +25,11 @@
+
+ +
diff --git a/airtime_mvc/public/js/airtime/library/podcast.js b/airtime_mvc/public/js/airtime/library/podcast.js index 1f23c9cf8..1e578fdb3 100644 --- a/airtime_mvc/public/js/airtime/library/podcast.js +++ b/airtime_mvc/public/js/airtime/library/podcast.js @@ -49,6 +49,14 @@ var AIRTIME = (function (AIRTIME) { }); }; + + /** + * Generate a smartblock and playlist for this smartblock. + */ + $scope.createSmartblock = function () { + console.log($scope.podcast.id); + $.post(endpoint + "smartblock", {csrf_token: $("#csrf").val(), id: $scope.podcast.id}, callback); + /** * Close the tab and discard any changes made to the podcast data. */ @@ -64,6 +72,9 @@ var AIRTIME = (function (AIRTIME) { return self; } + + + /** * Initialize the controller. * From ac10de50909370a210feb3864ab18a9e6a6c79f9 Mon Sep 17 00:00:00 2001 From: Robbt Date: Thu, 13 Dec 2018 21:26:08 -0500 Subject: [PATCH 03/11] fixed missing closing bracket and removed debugging log --- airtime_mvc/public/js/airtime/library/podcast.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/airtime_mvc/public/js/airtime/library/podcast.js b/airtime_mvc/public/js/airtime/library/podcast.js index 1e578fdb3..38d5728db 100644 --- a/airtime_mvc/public/js/airtime/library/podcast.js +++ b/airtime_mvc/public/js/airtime/library/podcast.js @@ -54,9 +54,8 @@ var AIRTIME = (function (AIRTIME) { * Generate a smartblock and playlist for this smartblock. */ $scope.createSmartblock = function () { - console.log($scope.podcast.id); $.post(endpoint + "smartblock", {csrf_token: $("#csrf").val(), id: $scope.podcast.id}, callback); - + }; /** * Close the tab and discard any changes made to the podcast data. */ From 15b73580c11f242dfe0d56ccf1bdc3aea9640518 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 14 Dec 2018 05:40:47 -0600 Subject: [PATCH 04/11] podcasts: change icon from cog to edit pencil --- airtime_mvc/public/js/airtime/library/library.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index 351c71e57..b1e3b5075 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -1379,8 +1379,8 @@ var AIRTIME = (function(AIRTIME) { }); $.extend(true, podcastToolbarButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.EDIT], { - title: $.i18n._('Settings'), - iconClass : "icon-cog", + title: $.i18n._('Edit'), + iconClass : "icon-pencil", eventHandlers: { click: AIRTIME.podcast.editSelectedPodcasts }, From 15cf291bc990c081018ffa8a55bbad0ed684d9c0 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 14 Dec 2018 15:24:28 -0600 Subject: [PATCH 05/11] set auto-generated smartblock and playlist title directly from input --- .../rest/controllers/PodcastController.php | 5 +- .../application/services/PodcastService.php | 75 ++++++++++--------- .../public/js/airtime/library/podcast.js | 13 +++- 3 files changed, 53 insertions(+), 40 deletions(-) diff --git a/airtime_mvc/application/modules/rest/controllers/PodcastController.php b/airtime_mvc/application/modules/rest/controllers/PodcastController.php index b3fc38832..eb454cb94 100644 --- a/airtime_mvc/application/modules/rest/controllers/PodcastController.php +++ b/airtime_mvc/application/modules/rest/controllers/PodcastController.php @@ -198,14 +198,15 @@ class Rest_PodcastController extends Zend_Rest_Controller public function smartblockAction() { + $title = $this->_getParam('title', []); $id = $this->_getParam('id', []); if (!$id) { return; } $podcast = Application_Service_PodcastService::getPodcastById($id); - logging::info($podcast); - Application_Service_PodcastService::createPodcastSmartblockAndPlaylist($podcast); + // logging::info($podcast); + Application_Service_PodcastService::createPodcastSmartblockAndPlaylist($podcast, $title); } diff --git a/airtime_mvc/application/services/PodcastService.php b/airtime_mvc/application/services/PodcastService.php index f5abb8590..b67028a8c 100644 --- a/airtime_mvc/application/services/PodcastService.php +++ b/airtime_mvc/application/services/PodcastService.php @@ -162,55 +162,56 @@ class Application_Service_PodcastService /** * @param $podcast + * @param $title passed in directly from web UI input * This will automatically create a smartblock and playlist for this podcast. */ - public static function createPodcastSmartblockAndPlaylist($podcast) + public static function createPodcastSmartblockAndPlaylist($podcast, $title) { if (is_array($podcast)) { $newpodcast = new Podcast(); $newpodcast->fromArray($podcast, BasePeer::TYPE_FIELDNAME); $podcast = $newpodcast; } - // Base class - $newBl = new Application_Model_Block(); - $newBl->setCreator(Application_Model_User::getCurrentUser()->getId()); - $newBl->setName($podcast->getDbTitle()); - $newBl->setDescription('Auto-generated smartblock for podcast'); - $newBl->saveType('dynamic'); - // limit the smartblock to 1 item - $row = new CcBlockcriteria(); - $row->setDbCriteria('limit'); - $row->setDbModifier('items'); - $row->setDbValue(1); - $row->setDbBlockId($newBl->getId()); - $row->save(); + // Base class + $newBl = new Application_Model_Block(); + $newBl->setCreator(Application_Model_User::getCurrentUser()->getId()); + $newBl->setName($title); + $newBl->setDescription('Auto-generated smartblock for podcast'); + $newBl->saveType('dynamic'); + // limit the smartblock to 1 item + $row = new CcBlockcriteria(); + $row->setDbCriteria('limit'); + $row->setDbModifier('items'); + $row->setDbValue(1); + $row->setDbBlockId($newBl->getId()); + $row->save(); - // sort so that it is the newest item - $row = new CcBlockcriteria(); - $row->setDbCriteria('sort'); - $row->setDbModifier('N/A'); - $row->setDbValue('newest'); - $row->setDbBlockId($newBl->getId()); - $row->save(); + // sort so that it is the newest item + $row = new CcBlockcriteria(); + $row->setDbCriteria('sort'); + $row->setDbModifier('N/A'); + $row->setDbValue('newest'); + $row->setDbBlockId($newBl->getId()); + $row->save(); - // match the track by ensuring the album title matches the podcast - $row = new CcBlockcriteria(); - $row->setDbCriteria('album_title'); - $row->setDbModifier('is'); - $row->setDbValue($newBl->getName()); - $row->setDbBlockId($newBl->getId()); - $row->save(); + // match the track by ensuring the album title matches the podcast + $row = new CcBlockcriteria(); + $row->setDbCriteria('album_title'); + $row->setDbModifier('is'); + $row->setDbValue($title); + $row->setDbBlockId($newBl->getId()); + $row->save(); - $newPl = new Application_Model_Playlist(); - $newPl->setName($podcast->getDbTitle()); - $newPl->setCreator(Application_Model_User::getCurrentUser()->getId()); - $row = new CcPlaylistcontents(); - $row->setDbBlockId($newBl->getId()); - $row->setDbPlaylistId($newPl->getId()); - $row->setDbType(2); - $row->save(); - } + $newPl = new Application_Model_Playlist(); + $newPl->setName($title); + $newPl->setCreator(Application_Model_User::getCurrentUser()->getId()); + $row = new CcPlaylistcontents(); + $row->setDbBlockId($newBl->getId()); + $row->setDbPlaylistId($newPl->getId()); + $row->setDbType(2); + $row->save(); + } public static function createStationPodcast() diff --git a/airtime_mvc/public/js/airtime/library/podcast.js b/airtime_mvc/public/js/airtime/library/podcast.js index 38d5728db..70a125eb1 100644 --- a/airtime_mvc/public/js/airtime/library/podcast.js +++ b/airtime_mvc/public/js/airtime/library/podcast.js @@ -54,7 +54,18 @@ var AIRTIME = (function (AIRTIME) { * Generate a smartblock and playlist for this smartblock. */ $scope.createSmartblock = function () { - $.post(endpoint + "smartblock", {csrf_token: $("#csrf").val(), id: $scope.podcast.id}, callback); + // send smarblock creation instruction to API + $.post( + endpoint + "smartblock", + { + csrf_token: $("#csrf").val(), + id: $scope.podcast.id, + title: $scope.podcast.title + }, + callback + ); + // save podcast + $scope.savePodcast(); }; /** * Close the tab and discard any changes made to the podcast data. From 58299962023342027aeed50d85a629cb7eb92dc7 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 14 Dec 2018 15:26:37 -0600 Subject: [PATCH 06/11] remove podcast pane close upon save --- airtime_mvc/public/js/airtime/library/podcast.js | 1 - 1 file changed, 1 deletion(-) diff --git a/airtime_mvc/public/js/airtime/library/podcast.js b/airtime_mvc/public/js/airtime/library/podcast.js index 70a125eb1..b4aad6219 100644 --- a/airtime_mvc/public/js/airtime/library/podcast.js +++ b/airtime_mvc/public/js/airtime/library/podcast.js @@ -36,7 +36,6 @@ var AIRTIME = (function (AIRTIME) { self.onSaveCallback = function () { AIRTIME.library.podcastDataTable.fnDraw(); - tab.close(); }; /** From bde87c7afb50dd5f736b828cd5388811d203a32d Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 15 Dec 2018 05:09:19 -0600 Subject: [PATCH 07/11] podcast smartblock generation: add success message and conditional hide --- .../views/scripts/podcast/podcast.phtml | 40 ++++---- airtime_mvc/public/css/styles.css | 95 +++++++------------ .../public/js/airtime/library/podcast.js | 11 ++- 3 files changed, 65 insertions(+), 81 deletions(-) diff --git a/airtime_mvc/application/views/scripts/podcast/podcast.phtml b/airtime_mvc/application/views/scripts/podcast/podcast.phtml index 6c715d8b3..b13d88f3f 100644 --- a/airtime_mvc/application/views/scripts/podcast/podcast.phtml +++ b/airtime_mvc/application/views/scripts/podcast/podcast.phtml @@ -7,28 +7,34 @@