From fcbc37977f57005eb6d2ba84edaeca72c494a1ba Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Tue, 28 Jul 2015 11:42:04 -0400 Subject: [PATCH] SAAS-948 - Frontend tweaks --- airtime_mvc/application/Bootstrap.php | 3 + .../controllers/ShowBuilderController.php | 24 ++++ .../application/forms/ShowBuilderTest.php | 103 ++++++++++++++++++ .../views/scripts/form/show-builder.phtml | 8 ++ .../views/scripts/playlist/playlist.phtml | 20 ++-- .../views/scripts/playlist/smart-block.phtml | 20 ++-- .../views/scripts/webstream/webstream.phtml | 20 ++-- airtime_mvc/public/css/media_library.css | 4 +- airtime_mvc/public/css/showbuilder-test.css | 28 ++++- .../js/airtime/showbuilder/builder_test.js | 6 +- .../airtime/showbuilder/main_builder_test.js | 21 +--- 11 files changed, 198 insertions(+), 59 deletions(-) create mode 100644 airtime_mvc/application/forms/ShowBuilderTest.php create mode 100644 airtime_mvc/application/views/scripts/form/show-builder.phtml diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index abc9ad99b..7edb8b0ea 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -93,6 +93,9 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap $userType = ""; } $view->headScript()->appendScript("var userType = '$userType';"); + + $mimeTypes = FileDataHelper::getAudioMimeTypeArray(); + $view->headScript()->appendScript("var acceptedMimeTypes = ['".implode("','", array_keys($mimeTypes))."'];"); } /** diff --git a/airtime_mvc/application/controllers/ShowBuilderController.php b/airtime_mvc/application/controllers/ShowBuilderController.php index 67c58c512..66ac4bfb4 100644 --- a/airtime_mvc/application/controllers/ShowBuilderController.php +++ b/airtime_mvc/application/controllers/ShowBuilderController.php @@ -53,6 +53,30 @@ class ShowBuilderController extends Zend_Controller_Action { $csrf_element = new Zend_Form_Element_Hidden('csrf'); $csrf_element->setValue($csrf_namespace->authtoken)->setRequired('true')->removeDecorator('HtmlTag')->removeDecorator('Label'); $this->view->csrf = $csrf_element; + + $request = $this->getRequest(); + //populate date range form for show builder. + $now = time(); + $from = $request->getParam("from", $now); + $to = $request->getParam("to", $now + (3*60*60)); + + $utcTimezone = new DateTimeZone("UTC"); + $displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone()); + + $start = DateTime::createFromFormat("U", $from, $utcTimezone); + $start->setTimezone($displayTimeZone); + $end = DateTime::createFromFormat("U", $to, $utcTimezone); + $end->setTimezone($displayTimeZone); + + $form = new Application_Form_ShowBuilderTest(); + $form->populate(array( + 'sb_date_start' => $start->format("Y-m-d"), + 'sb_time_start' => $start->format("H:i"), + 'sb_date_end' => $end->format("Y-m-d"), + 'sb_time_end' => $end->format("H:i") + )); + + $this->view->sb_form = $form; } } diff --git a/airtime_mvc/application/forms/ShowBuilderTest.php b/airtime_mvc/application/forms/ShowBuilderTest.php new file mode 100644 index 000000000..d4b8b2d75 --- /dev/null +++ b/airtime_mvc/application/forms/ShowBuilderTest.php @@ -0,0 +1,103 @@ +setDecorators(array( + array('ViewScript', array('viewScript' => 'form/show-builder.phtml')) + )); + + // Add start date element + $startDate = new Zend_Form_Element_Text('sb_date_start'); + $startDate->class = 'input_text'; + $startDate->setRequired(true) + ->setLabel(_('Date Start:')) + ->setValue(date("Y-m-d")) + ->setFilters(array('StringTrim')) + ->setValidators(array( + 'NotEmpty', + array('date', false, array('YYYY-MM-DD')))) + ->setDecorators(array('ViewHelper')); + $startDate->setAttrib('alt', 'date'); + $this->addElement($startDate); + + // Add start time element + $startTime = new Zend_Form_Element_Text('sb_time_start'); + $startTime->class = 'input_text'; + $startTime->setRequired(true) + ->setValue('00:00') + ->setFilters(array('StringTrim')) + ->setValidators(array( + 'NotEmpty', + array('date', false, array('HH:mm')), + array('regex', false, array('/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered'))))) + ->setDecorators(array('ViewHelper')); + $startTime->setAttrib('alt', 'time'); + $this->addElement($startTime); + + // Add end date element + $endDate = new Zend_Form_Element_Text('sb_date_end'); + $endDate->class = 'input_text'; + $endDate->setRequired(true) + ->setLabel(_('Date End:')) + ->setValue(date("Y-m-d")) + ->setFilters(array('StringTrim')) + ->setValidators(array( + 'NotEmpty', + array('date', false, array('YYYY-MM-DD')))) + ->setDecorators(array('ViewHelper')); + $endDate->setAttrib('alt', 'date'); + $this->addElement($endDate); + + // Add end time element + $endTime = new Zend_Form_Element_Text('sb_time_end'); + $endTime->class = 'input_text'; + $endTime->setRequired(true) + ->setValue('01:00') + ->setFilters(array('StringTrim')) + ->setValidators(array( + 'NotEmpty', + array('date', false, array('HH:mm')), + array('regex', false, array('/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered'))))) + ->setDecorators(array('ViewHelper')); + $endTime->setAttrib('alt', 'time'); + $this->addElement($endTime); + + // add a select to choose a show. + $showSelect = new Zend_Form_Element_Select("sb_show_filter"); + $showSelect->setLabel(_("Show:")); + $showSelect->setMultiOptions($this->getShowNames()); + $showSelect->setValue(null); + $showSelect->setDecorators(array('ViewHelper')); + $this->addElement($showSelect); + + if ($user->getType() === 'H') { + $myShows = new Zend_Form_Element_Checkbox('sb_my_shows'); + $myShows->setLabel(_('All My Shows:')) + ->setDecorators(array('ViewHelper')); + $this->addElement($myShows); + } + } + + private function getShowNames() + { + $showNames = array("0" => "-------------------------"); + + $shows = CcShowQuery::create() + ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND) + ->orderByDbName() + ->find(); + + foreach ($shows as $show) { + + $showNames[$show->getDbId()] = $show->getDbName(); + } + + return $showNames; + } + +} diff --git a/airtime_mvc/application/views/scripts/form/show-builder.phtml b/airtime_mvc/application/views/scripts/form/show-builder.phtml new file mode 100644 index 000000000..d1ec22648 --- /dev/null +++ b/airtime_mvc/application/views/scripts/form/show-builder.phtml @@ -0,0 +1,8 @@ +element->getElement('sb_date_start'); ?> +element->getElement('sb_time_start'); ?> +element->getElement('sb_date_end'); ?> +element->getElement('sb_time_end'); ?> + + + + diff --git a/airtime_mvc/application/views/scripts/playlist/playlist.phtml b/airtime_mvc/application/views/scripts/playlist/playlist.phtml index d187dc866..263b9008c 100644 --- a/airtime_mvc/application/views/scripts/playlist/playlist.phtml +++ b/airtime_mvc/application/views/scripts/playlist/playlist.phtml @@ -6,16 +6,16 @@ if (isset($this->obj)) { ?>
-
- - -
+ + + + + + + + + + obj)) : ?>
diff --git a/airtime_mvc/application/views/scripts/playlist/smart-block.phtml b/airtime_mvc/application/views/scripts/playlist/smart-block.phtml index 716fdce38..8b9e0ad82 100644 --- a/airtime_mvc/application/views/scripts/playlist/smart-block.phtml +++ b/airtime_mvc/application/views/scripts/playlist/smart-block.phtml @@ -6,16 +6,16 @@ if (isset($this->obj)) { ?>
-
- - -
+ + + + + + + + + + obj)) : ?>
diff --git a/airtime_mvc/application/views/scripts/webstream/webstream.phtml b/airtime_mvc/application/views/scripts/webstream/webstream.phtml index 9c9af52b4..45790bb3b 100644 --- a/airtime_mvc/application/views/scripts/webstream/webstream.phtml +++ b/airtime_mvc/application/views/scripts/webstream/webstream.phtml @@ -1,15 +1,15 @@
-
- - -
+ + + + + + + + + + obj)) : ?>
diff --git a/airtime_mvc/public/css/media_library.css b/airtime_mvc/public/css/media_library.css index 446cc62b3..7f980b328 100644 --- a/airtime_mvc/public/css/media_library.css +++ b/airtime_mvc/public/css/media_library.css @@ -205,7 +205,7 @@ td.library_bitrate { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; - height: 25px; + height: 26px; vertical-align: middle; margin: 0 !important; line-height: 16px; @@ -218,7 +218,7 @@ td.library_bitrate { display: inline-block; float: none !important; margin: 0 !important; - height: 25px; + height: 26px; outline: none; vertical-align: middle !important; } \ No newline at end of file diff --git a/airtime_mvc/public/css/showbuilder-test.css b/airtime_mvc/public/css/showbuilder-test.css index 6fd1d1669..b896f471c 100644 --- a/airtime_mvc/public/css/showbuilder-test.css +++ b/airtime_mvc/public/css/showbuilder-test.css @@ -1,6 +1,6 @@ /* Show Builder*/ -@media screen and (max-width: 1015px) { +@media screen and (max-width: 1175px) { .lib-test, .sb-test, .media-builder-test, #media_type_nav { width: 100% !important; } @@ -13,6 +13,10 @@ text-align: center; margin: auto; } + #media_type_nav .dropdown-menu { + width: 100%; + text-align: center; + } #media_type_nav .media_type_selector { margin-top: .25em; } @@ -59,25 +63,39 @@ overflow: hidden !important; } -.sb-test, .media-builder-test { - margin-top: 4.6em; /* Standardize this somehow */ -} - .lib-test, .sb-test, .media-builder-test { /* 1em for the middle margin, 6 for half the width of the left pane */ width: calc(50% - 8em); min-width: 470px; } +/* Timeline */ + +.sb-test { + margin-top: 1.5em; +} + +#sb_submit { + text-decoration: none; + padding: .35em; + color: #efefef; +} + +.sb-timerange { + margin-bottom: 5px; +} + /* Media builder */ .media-builder-test { color: #efefef; + margin-top: 2em; /* Standardize this somehow */ } #side_playlist { width: calc(50% - 8em); font-size: inherit; + overflow: hidden; } /* Media type selector */ diff --git a/airtime_mvc/public/js/airtime/showbuilder/builder_test.js b/airtime_mvc/public/js/airtime/showbuilder/builder_test.js index 16f664897..efdf76127 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/builder_test.js +++ b/airtime_mvc/public/js/airtime/showbuilder/builder_test.js @@ -228,7 +228,7 @@ var AIRTIME = (function(AIRTIME){ }; mod.selectAll = function () { - var $trs = $sbTable.find("tr.lib-audio").not(".sb-past"); + var $trs = $sbTable.find("tr.lib-audio").not(".sb-past, .sb-empty"); $trs.addClass(SB_SELECTED_CLASS); mod.checkToolBarIcons(); @@ -643,7 +643,7 @@ var AIRTIME = (function(AIRTIME){ if (aData.scheduled === 1) { $nRow.addClass(NOW_PLAYING_CLASS); } - else if (aData.scheduled === 0) { + else if (aData.scheduled === 0 || aData.scheduled === undefined) { $nRow.addClass("sb-past"); } else { @@ -739,7 +739,7 @@ var AIRTIME = (function(AIRTIME){ "sAjaxSource": baseUrl+"showbuilder/builder-feed" }); - $sbTable.find("tbody").on("click", "tr:not(.sb-past)", function(ev) { + $sbTable.find("tbody").on("click", "tr:not(.sb-past, .sb-empty)", function(ev) { var $tr = $(this), // Get the ID of the selected row diff --git a/airtime_mvc/public/js/airtime/showbuilder/main_builder_test.js b/airtime_mvc/public/js/airtime/showbuilder/main_builder_test.js index e0895a0fb..c81dc1445 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/main_builder_test.js +++ b/airtime_mvc/public/js/airtime/showbuilder/main_builder_test.js @@ -145,26 +145,9 @@ AIRTIME = (function(AIRTIME) { mod.onReady = function() { // Normally we would just use audio/*, but it includes file types that we can't handle (like .m4a) - var acceptedTypes = ["audio/ogg", - "application/ogg", - "audio/vorbis", - "audio/mp3", - "audio/mpeg", - "audio/mpeg3", - "audio/x-aac", - "audio/aac", - "audio/aacp", - "audio/mp4", - "audio/x-flac", - "audio/wav", - "audio/x-wav", - "audio/mp2", - "audio/mp1", - "audio/x-ms-wma", - "audio/basic"]; - + // We initialize the acceptedMimeTypes variable in Bootstrap so we don't have to duplicate the list Dropzone.options.uploadForm = { - acceptedFiles: acceptedTypes.join(), + acceptedFiles: acceptedMimeTypes.join(), init: function () { this.on("sending", function (file, xhr, data) { data.append("csrf_token", $("#csrf").val());