diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 74c324ee9..b25ba74fb 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -25,6 +25,7 @@ class ApiController extends Zend_Controller_Action ->addActionContext('register-component', 'json') ->addActionContext('update-liquidsoap-error', 'json') ->addActionContext('update-liquidsoap-connection', 'json') + ->addActionContext('library-init', 'json') ->initContext(); } @@ -77,9 +78,11 @@ class ApiController extends Zend_Controller_Action } $this->view->calendarInit = array( - "timestamp"=>time(), - "timezoneOffset"=> date("Z"), - "timeScale"=>Application_Model_Preference::GetCalendarTimeScale() + "timestamp" => time(), + "timezoneOffset" => date("Z"), + "timeScale" => Application_Model_Preference::GetCalendarTimeScale(), + "timeInterval" => Application_Model_Preference::GetCalendarTimeInterval(), + "weekStartDay" => Application_Model_Preference::GetWeekStartDay() ); } @@ -731,5 +734,25 @@ class ApiController extends Zend_Controller_Action // setting error_msg as "" when there is no error_msg Application_Model_StreamSetting::setLiquidsoapError($stream_id, ""); } + + /** + * Sets up and send init values used in the Library. + * This is being used by library.js + */ + public function libraryInitAction(){ + $this->view->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(true); + + if(is_null(Zend_Auth::getInstance()->getStorage()->read())) { + header('HTTP/1.0 401 Unauthorized'); + print 'You are not allowed to access this resource.'; + return; + } + + $this->view->libraryInit = array( + "numEntries"=>Application_Model_Preference::GetLibraryNumEntries() + ); + + } } diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 06f195a40..6aa4a5b43 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -15,6 +15,7 @@ class LibraryController extends Zend_Controller_Action ->addActionContext('get-file-meta-data', 'html') ->addActionContext('upload-file-soundcloud', 'json') ->addActionContext('get-upload-to-soundcloud-status', 'json') + ->addActionContext('set-num-entries', 'json') ->initContext(); $this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME); @@ -278,4 +279,14 @@ class LibraryController extends Zend_Controller_Action $this->view->error_msg = $file->getSoundCloudErrorMsg(); } } + + /** + * Stores the number of entries user chose to show in the Library + * to the pref db + */ + public function setNumEntriesAction() { + $request = $this->getRequest(); + $numEntries = $request->getParam('numEntries'); + Application_Model_Preference::SetLibraryNumEntries($numEntries); + } } diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index cc9080e53..ece06790e 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -36,6 +36,7 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetStreamLabelFormat($values["preferences_general"]["streamFormat"]); Application_Model_Preference::SetAllow3rdPartyApi($values["preferences_general"]["thirdPartyApi"]); Application_Model_Preference::SetTimezone($values["preferences_general"]["timezone"]); + Application_Model_Preference::SetWeekStartDay($values["preferences_general"]["weekStartDay"]); Application_Model_Preference::SetAutoUploadRecordedShowToSoundcloud($values["preferences_soundcloud"]["UseSoundCloud"]); Application_Model_Preference::SetUploadToSoundcloudOption($values["preferences_soundcloud"]["UploadToSoundcloudOption"]); diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 716051390..6e8e445fa 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -29,6 +29,7 @@ class ScheduleController extends Zend_Controller_Action ->addActionContext('upload-to-sound-cloud', 'json') ->addActionContext('content-context-menu', 'json') ->addActionContext('set-time-scale', 'json') + ->addActionContext('set-time-interval', 'json') ->initContext(); $this->sched_sess = new Zend_Session_Namespace("schedule"); @@ -737,6 +738,14 @@ class ScheduleController extends Zend_Controller_Action public function setTimeScaleAction() { Application_Model_Preference::SetCalendarTimeScale($this->_getParam('timeScale')); } + +/** + * Sets the user specific preference for which time interval to use in Calendar. + * This is only being used by schedule.js at the moment. + */ + public function setTimeIntervalAction() { + Application_Model_Preference::SetCalendarTimeInterval($this->_getParam('timeInterval')); + } } diff --git a/airtime_mvc/application/forms/GeneralPreferences.php b/airtime_mvc/application/forms/GeneralPreferences.php index 7b0da1400..61b79dbc8 100644 --- a/airtime_mvc/application/forms/GeneralPreferences.php +++ b/airtime_mvc/application/forms/GeneralPreferences.php @@ -65,6 +65,14 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm $timezone->setValue(Application_Model_Preference::GetTimezone()); $timezone->setDecorators(array('ViewHelper')); $this->addElement($timezone); + + /* Form Element for setting which day is the start of the week */ + $week_start_day = new Zend_Form_Element_Select("weekStartDay"); + $week_start_day->setLabel("Week Starts On"); + $week_start_day->setMultiOptions($this->getWeekStartDays()); + $week_start_day->setValue(Application_Model_Preference::GetWeekStartDay()); + $week_start_day->setDecorators(array('ViewHelper')); + $this->addElement($week_start_day); } private function getTimezones(){ @@ -90,7 +98,19 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm return $tzlist; } + - + private function getWeekStartDays() { + $days = array( + 'Sunday', + 'Monday', + 'Tuesday', + 'Wednesday', + 'Thursday', + 'Friday', + 'Saturday' + ); + return $days; + } } diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index e58dafb5f..200b4448f 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -485,6 +485,21 @@ class Application_Model_Preference public static function GetSoundCloudDownloadbleOption() { return self::GetValue("soundcloud_downloadable"); } + + public static function SetWeekStartDay($day) { + self::SetValue("week_start_day", $day); + } + + public static function GetWeekStartDay() { + $val = self::GetValue("week_start_day"); + if (strlen($val) == 0){ + return "0"; + } else { + return $val; + } + } + + /* User specific preferences start */ /** * Sets the time scale preference (day/week/month) in Calendar. @@ -501,5 +516,39 @@ class Application_Model_Preference public static function GetCalendarTimeScale() { return self::GetValue("calendar_time_scale", true /* user specific */); } + + /** + * Sets the number of entries to show preference in library under Playlist Builder. + * + * @param $numEntries new number of entries to show + */ + public static function SetLibraryNumEntries($numEntries) { + return self::SetValue("library_num_entries", $numEntries, true /* user specific */); + } + + /** + * Retrieves the number of entries to show preference in library under Playlist Builder. + */ + public static function GetLibraryNumEntries() { + return self::GetValue("library_num_entries", true /* user specific */); + } + + /** + * Sets the time interval preference in Calendar. + * + * @param $timeInterval new time interval + */ + public static function SetCalendarTimeInterval($timeInterval) { + return self::SetValue("calendar_time_interval", $timeInterval, true /* user specific */); + } + + /** + * Retrieves the time interval preference for the current user. + */ + public static function GetCalendarTimeInterval() { + return self::GetValue("calendar_time_interval", true /* user specific */); + } + + /* User specific preferences end */ } diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 28856510a..90cb2970e 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -443,7 +443,7 @@ class Application_Model_StoredFile { $serverName = $_SERVER['SERVER_NAME']; $serverPort = $_SERVER['SERVER_PORT']; - return constructGetFileUrl($serverName, $serverPort); + return $this->constructGetFileUrl($serverName, $serverPort); } /** @@ -456,7 +456,7 @@ class Application_Model_StoredFile { $serverName = $CC_CONFIG['baseUrl']; $serverPort = $CC_CONFIG['basePort']; - return constructGetFileUrl($serverName, $serverPort); + return $this->constructGetFileUrl($serverName, $serverPort); } private function constructGetFileUrl($p_serverName, $p_serverPort){ diff --git a/airtime_mvc/application/views/scripts/dashboard/stream-player.phtml b/airtime_mvc/application/views/scripts/dashboard/stream-player.phtml index 21e9d9a30..7b9d6a796 100644 --- a/airtime_mvc/application/views/scripts/dashboard/stream-player.phtml +++ b/airtime_mvc/application/views/scripts/dashboard/stream-player.phtml @@ -42,7 +42,7 @@ $(document).ready(function(){ ?> }); - +
Select stream:
diff --git a/airtime_mvc/application/views/scripts/form/preferences_general.phtml b/airtime_mvc/application/views/scripts/form/preferences_general.phtml index 3c11ced5b..f8d7b23f7 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_general.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_general.phtml @@ -72,7 +72,7 @@ - +
+ +
+
+ element->getElement('weekStartDay')->getValue(); + ?> + + + element->getElement('weekStartDay')->hasErrors()) : ?> + + +
diff --git a/airtime_mvc/public/css/add-show.css b/airtime_mvc/public/css/add-show.css index fbd1c6be5..0dd479a3c 100644 --- a/airtime_mvc/public/css/add-show.css +++ b/airtime_mvc/public/css/add-show.css @@ -75,7 +75,7 @@ } label.wrapp-label input[type="checkbox"] { float:left; - margin:-1px 4px 0 0; + margin:-1px 2px 0 0; } #schedule-add-show fieldset:last-child { @@ -91,7 +91,7 @@ label.wrapp-label input[type="checkbox"] { #add_show_day_check-element.block-display label.wrapp-label { font-size:12px; float:left; - margin-right:5px; + margin-right:10px; } #add_show_name-element .input_text { /*width:99%;*/ diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index f97e13f97..dffc71432 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -279,11 +279,20 @@ function addMetadataQtip(){ }) } -$(document).ready(function() { +/** + * Use user preference for number of entries to show; + * defaults to 10 if preference was never set + */ +function getNumEntriesPreference(data) { + var numEntries = data.libraryInit.numEntries; + if(numEntries == '') { + numEntries = '10'; + } + return parseInt(numEntries); +} - $('.tabs').tabs(); - - $('#library_display').dataTable( { +function createDataTable(data) { + var dTable = $('#library_display').dataTable( { "bProcessing": true, "bServerSide": true, "sAjaxSource": "/Library/contents/format/json", @@ -313,8 +322,28 @@ $(document).ready(function() { "bAutoWidth": false, "oLanguage": { "sSearch": "" - } - }).fnSetFilteringDelay(350); + }, + "iDisplayLength": getNumEntriesPreference(data) + }); + dTable.fnSetFilteringDelay(350); + + // Updates pref db when user changes the # of entries to show + $('select[name=library_display_length]').change(function() { + var url = '/Library/set-num-entries/format/json'; + $.post(url, {numEntries: $(this).val()}, + function(json){ + if(json.error) { + alert(json.error); + } + }); + }); +} + +$(document).ready(function() { + $('.tabs').tabs(); + + $.ajax({ url: "/Api/library-init/format/json", dataType:"json", success:createDataTable + , error:function(jqXHR, textStatus, errorThrown){}}); checkImportStatus() setInterval( "checkImportStatus()", 5000 ); diff --git a/airtime_mvc/public/js/airtime/preferences/musicdirs.js b/airtime_mvc/public/js/airtime/preferences/musicdirs.js index 44974d483..796baec96 100644 --- a/airtime_mvc/public/js/airtime/preferences/musicdirs.js +++ b/airtime_mvc/public/js/airtime/preferences/musicdirs.js @@ -13,7 +13,7 @@ function setWatchedDirEvents() { //knownPaths: [{text:'Desktop', image:'desktop.png', path:'/home'}], knownPaths: [], imageUrl: 'img/icons/', - systemImageUrl: 'img/browser/', + systemImageUrl: '/css/img/', handlerUrl: '/Preference/server-browse/format/json', title: 'Choose Storage Folder', basePath: '', diff --git a/airtime_mvc/public/js/airtime/schedule/schedule.js b/airtime_mvc/public/js/airtime/schedule/schedule.js index 5ac30358b..5c7ee99f0 100644 --- a/airtime_mvc/public/js/airtime/schedule/schedule.js +++ b/airtime_mvc/public/js/airtime/schedule/schedule.js @@ -308,6 +308,17 @@ function getTimeScalePreference(data) { return timeScale; } +/** + * Use user preference for time interval; defaults to 30m if preference was never set + */ +function getTimeIntervalPreference(data) { + var timeInterval = data.calendarInit.timeInterval; + if(timeInterval == '') { + timeInterval = '30'; + } + return parseInt(timeInterval); +} + function createFullCalendar(data){ serverTimezoneOffset = data.calendarInit.timezoneOffset; @@ -321,6 +332,8 @@ function createFullCalendar(data){ right: 'agendaDay, agendaWeek, month' }, defaultView: getTimeScalePreference(data), + slotMinutes: getTimeIntervalPreference(data), + firstDay: data.calendarInit.weekStartDay, editable: false, allDaySlot: false, axisFormat: 'H:mm', @@ -347,7 +360,7 @@ function createFullCalendar(data){ //Update time scale preference when day/week/month button is clicked $(".fc-button-content").click(function() { - url = '/Schedule/set-time-scale/format/json'; + var url = '/Schedule/set-time-scale/format/json'; $.post(url, {timeScale: $(this).text()}, function(json){ if(json.error) { @@ -355,6 +368,17 @@ function createFullCalendar(data){ } }); }); + + //Update time interval preference when dropdown is updated + $(".schedule_change_slots.input_select").change(function() { + var url = '/Schedule/set-time-interval/format/json'; + $.post(url, {timeInterval: $(this).val()}, + function(json){ + if(json.error) { + alert(json.error); + } + }); + }); } $(window).load(function() { diff --git a/dev_tools/fabric/fab_setup.py b/dev_tools/fabric/fab_setup.py index 8dbe87bda..45b428f5a 100644 --- a/dev_tools/fabric/fab_setup.py +++ b/dev_tools/fabric/fab_setup.py @@ -126,7 +126,12 @@ def airtime_182_tar(): reboot(45) sudo('airtime-check-system') -def airtime_182_deb(): +def airtime_194_tar(): + run('wget http://downloads.sourceforge.net/project/airtime/1.9.4/airtime-1.9.4.tar.gz') + run('tar xfz airtime-1.9.4.tar.gz') + sudo('cd ~/airtime-1.9.4/install_full/ubuntu && ./airtime-full-install') + +def airtime_latest_deb(): append('/etc/apt/sources.list', "deb http://apt.sourcefabric.org/ lucid main", use_sudo=True) append('/etc/apt/sources.list', "deb http://archive.ubuntu.com/ubuntu/ lucid multiverse", use_sudo=True) sudo('apt-get update') @@ -135,11 +140,6 @@ def airtime_182_deb(): sudo('apt-get install -y icecast2') sudo('apt-get purge -y pulseaudio') sudo('apt-get install -y --force-yes airtime') - -def airtime_194_tar(): - run('wget http://downloads.sourceforge.net/project/airtime/1.9.4/airtime-1.9.4.tar.gz') - run('tar xfz airtime-1.9.4.tar.gz') - sudo('cd ~/airtime-1.9.4/install_full/ubuntu && ./airtime-full-install') def airtime_devel(): sudo('apt-get update')