CC-2436: Save pulldown settings
For week and day views under Calendar page, save the change to pref db table when user updates the interval dropdown. Same thing goes for the "show XXX entries" dropdown found under Playlist Builder page. When visiting these pages, we retrieves the entry from database for current user and use those values. Defaults to 30m for interval and 10 entries for "show xxx entries" if values were never set.
This commit is contained in:
parent
3e441dc72f
commit
d2fe46baf0
6 changed files with 135 additions and 9 deletions
|
@ -25,6 +25,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
->addActionContext('register-component', 'json')
|
->addActionContext('register-component', 'json')
|
||||||
->addActionContext('update-liquidsoap-error', 'json')
|
->addActionContext('update-liquidsoap-error', 'json')
|
||||||
->addActionContext('update-liquidsoap-connection', 'json')
|
->addActionContext('update-liquidsoap-connection', 'json')
|
||||||
|
->addActionContext('library-init', 'json')
|
||||||
->initContext();
|
->initContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,9 +78,10 @@ class ApiController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->view->calendarInit = array(
|
$this->view->calendarInit = array(
|
||||||
"timestamp"=>time(),
|
"timestamp" => time(),
|
||||||
"timezoneOffset"=> date("Z"),
|
"timezoneOffset" => date("Z"),
|
||||||
"timeScale"=>Application_Model_Preference::GetCalendarTimeScale()
|
"timeScale" => Application_Model_Preference::GetCalendarTimeScale(),
|
||||||
|
"timeInterval" => Application_Model_Preference::GetCalendarTimeInterval()
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -731,5 +733,25 @@ class ApiController extends Zend_Controller_Action
|
||||||
// setting error_msg as "" when there is no error_msg
|
// setting error_msg as "" when there is no error_msg
|
||||||
Application_Model_StreamSetting::setLiquidsoapError($stream_id, "");
|
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()
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ class LibraryController extends Zend_Controller_Action
|
||||||
->addActionContext('get-file-meta-data', 'html')
|
->addActionContext('get-file-meta-data', 'html')
|
||||||
->addActionContext('upload-file-soundcloud', 'json')
|
->addActionContext('upload-file-soundcloud', 'json')
|
||||||
->addActionContext('get-upload-to-soundcloud-status', 'json')
|
->addActionContext('get-upload-to-soundcloud-status', 'json')
|
||||||
|
->addActionContext('set-num-entries', 'json')
|
||||||
->initContext();
|
->initContext();
|
||||||
|
|
||||||
$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
|
$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
|
||||||
|
@ -269,4 +270,14 @@ class LibraryController extends Zend_Controller_Action
|
||||||
$this->view->error_msg = $file->getSoundCloudErrorMsg();
|
$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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
->addActionContext('upload-to-sound-cloud', 'json')
|
->addActionContext('upload-to-sound-cloud', 'json')
|
||||||
->addActionContext('content-context-menu', 'json')
|
->addActionContext('content-context-menu', 'json')
|
||||||
->addActionContext('set-time-scale', 'json')
|
->addActionContext('set-time-scale', 'json')
|
||||||
|
->addActionContext('set-time-interval', 'json')
|
||||||
->initContext();
|
->initContext();
|
||||||
|
|
||||||
$this->sched_sess = new Zend_Session_Namespace("schedule");
|
$this->sched_sess = new Zend_Session_Namespace("schedule");
|
||||||
|
@ -737,6 +738,14 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
public function setTimeScaleAction() {
|
public function setTimeScaleAction() {
|
||||||
Application_Model_Preference::SetCalendarTimeScale($this->_getParam('timeScale'));
|
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'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -501,5 +501,37 @@ class Application_Model_Preference
|
||||||
public static function GetCalendarTimeScale() {
|
public static function GetCalendarTimeScale() {
|
||||||
return self::GetValue("calendar_time_scale", true /* user specific */);
|
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 */);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,11 +275,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();
|
function createDataTable(data) {
|
||||||
|
var dTable = $('#library_display').dataTable( {
|
||||||
$('#library_display').dataTable( {
|
|
||||||
"bProcessing": true,
|
"bProcessing": true,
|
||||||
"bServerSide": true,
|
"bServerSide": true,
|
||||||
"sAjaxSource": "/Library/contents/format/json",
|
"sAjaxSource": "/Library/contents/format/json",
|
||||||
|
@ -309,8 +318,28 @@ $(document).ready(function() {
|
||||||
"bAutoWidth": false,
|
"bAutoWidth": false,
|
||||||
"oLanguage": {
|
"oLanguage": {
|
||||||
"sSearch": ""
|
"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()
|
checkImportStatus()
|
||||||
setInterval( "checkImportStatus()", 5000 );
|
setInterval( "checkImportStatus()", 5000 );
|
||||||
|
|
|
@ -308,6 +308,17 @@ function getTimeScalePreference(data) {
|
||||||
return timeScale;
|
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){
|
function createFullCalendar(data){
|
||||||
|
|
||||||
serverTimezoneOffset = data.calendarInit.timezoneOffset;
|
serverTimezoneOffset = data.calendarInit.timezoneOffset;
|
||||||
|
@ -321,6 +332,7 @@ function createFullCalendar(data){
|
||||||
right: 'agendaDay, agendaWeek, month'
|
right: 'agendaDay, agendaWeek, month'
|
||||||
},
|
},
|
||||||
defaultView: getTimeScalePreference(data),
|
defaultView: getTimeScalePreference(data),
|
||||||
|
slotMinutes: getTimeIntervalPreference(data),
|
||||||
editable: false,
|
editable: false,
|
||||||
allDaySlot: false,
|
allDaySlot: false,
|
||||||
axisFormat: 'H:mm',
|
axisFormat: 'H:mm',
|
||||||
|
@ -355,6 +367,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() {
|
$(window).load(function() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue