CC-733 : broadcast logs
adding time range selection for the log history.
This commit is contained in:
parent
7c63387dd5
commit
20db8d6fdf
|
@ -16,8 +16,28 @@ class PlayoutHistoryController extends Zend_Controller_Action
|
|||
|
||||
$this->_helper->layout->setLayout('playouthistory');
|
||||
|
||||
$request = $this->getRequest();
|
||||
$baseUrl = $request->getBaseUrl();
|
||||
$request = $this->getRequest();
|
||||
$baseUrl = $request->getBaseUrl();
|
||||
|
||||
//default time is the last 24 hours.
|
||||
$now = time();
|
||||
$from = $request->getParam("from", $now - (24*60*60));
|
||||
$to = $request->getParam("to", $now);
|
||||
|
||||
$start = DateTime::createFromFormat("U", $from, new DateTimeZone("UTC"));
|
||||
$start->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
$end = DateTime::createFromFormat("U", $to, new DateTimeZone("UTC"));
|
||||
$end->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
|
||||
$form = new Application_Form_DateRange();
|
||||
$form->populate(array(
|
||||
'his_date_start' => $start->format("Y-m-d"),
|
||||
'his_time_start' => $start->format("H:i"),
|
||||
'his_date_end' => $end->format("Y-m-d"),
|
||||
'his_time_end' => $end->format("H:i")
|
||||
));
|
||||
|
||||
$this->view->date_form = $form;
|
||||
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
|
@ -25,13 +45,18 @@ class PlayoutHistoryController extends Zend_Controller_Action
|
|||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/TableTools/js/ZeroClipboard.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/TableTools/js/TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
|
||||
|
||||
$offset = date("Z") * -1;
|
||||
$this->view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds");
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker.js','text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/playouthistory/historytable.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/js/datatables/plugin/TableTools/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
|
||||
//$this->view->headLink()->appendStylesheet($baseUrl.'/js/datatables/plugin/TableTools/css/TableTools_JUI.css?'.$CC_CONFIG['airtime_version']);
|
||||
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css');
|
||||
}
|
||||
|
||||
public function playoutHistoryFeedAction()
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
class Application_Form_DateRange extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/daterange.phtml'))
|
||||
));
|
||||
|
||||
// Add start date element
|
||||
$startDate = new Zend_Form_Element_Text('his_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('his_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-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('his_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('his_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-9:]+$/', 'messages' => 'Invalid character entered'))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$endTime->setAttrib('alt', 'time');
|
||||
$this->addElement($endTime);
|
||||
}
|
||||
}
|
|
@ -51,16 +51,27 @@ class Application_Model_Datatables {
|
|||
$orderby[] = "id";
|
||||
$orderby = join("," , $orderby);
|
||||
// End Order By clause
|
||||
|
||||
|
||||
$displayLength = intval($data["iDisplayLength"]);
|
||||
if (count($where) > 0) {
|
||||
$where = join(" AND ", $where);
|
||||
$sql = $selectorCount." FROM ".$fromTable." WHERE ".$where;
|
||||
$sqlTotalDisplayRows = $sql;
|
||||
|
||||
$sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
|
||||
|
||||
$sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby;
|
||||
|
||||
//limit the results returned.
|
||||
if ($displayLength !== -1) {
|
||||
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
|
||||
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby;
|
||||
|
||||
//limit the results returned.
|
||||
if ($displayLength !== -1) {
|
||||
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<div class="his-timerange">
|
||||
<?php echo $this->element->getElement('his_date_start') ?>
|
||||
<?php echo $this->element->getElement('his_time_start') ?>
|
||||
<?php echo $this->element->getElement('his_date_end') ?>
|
||||
<?php echo $this->element->getElement('his_time_end') ?>
|
||||
<input type="button" id="his_submit" class="ui-button ui-state-default" value="GO"></input>
|
||||
</div>
|
|
@ -1 +1,2 @@
|
|||
<?php echo $this->date_form; ?>
|
||||
<table id="history_table" cellpadding="0" cellspacing="0" class="datatable"></table>
|
|
@ -9,8 +9,29 @@ var AIRTIME = (function(AIRTIME) {
|
|||
mod.historyTable = function() {
|
||||
var oTable,
|
||||
historyContentDiv = $("#history_content"),
|
||||
historyTableDiv = historyContentDiv.find("#history_table");
|
||||
tableHeight = historyContentDiv.height() - 140;
|
||||
historyTableDiv = historyContentDiv.find("#history_table"),
|
||||
tableHeight = historyContentDiv.height() - 140,
|
||||
fnServerData;
|
||||
|
||||
fnServerData = function ( sSource, aoData, fnCallback ) {
|
||||
|
||||
if (fnServerData.hasOwnProperty("start")) {
|
||||
aoData.push( { name: "start", value: fnServerData.start} );
|
||||
}
|
||||
if (fnServerData.hasOwnProperty("end")) {
|
||||
aoData.push( { name: "end", value: fnServerData.end} );
|
||||
}
|
||||
|
||||
aoData.push( { name: "format", value: "json"} );
|
||||
|
||||
$.ajax( {
|
||||
"dataType": 'json',
|
||||
"type": "GET",
|
||||
"url": sSource,
|
||||
"data": aoData,
|
||||
"success": fnCallback
|
||||
} );
|
||||
};
|
||||
|
||||
oTable = historyTableDiv.dataTable( {
|
||||
|
||||
|
@ -28,26 +49,18 @@ var AIRTIME = (function(AIRTIME) {
|
|||
"sAjaxSource": "/Playouthistory/playout-history-feed",
|
||||
"sAjaxDataProp": "history",
|
||||
|
||||
"fnServerData": function ( sSource, aoData, fnCallback ) {
|
||||
|
||||
aoData.push( { name: "format", value: "json"} );
|
||||
|
||||
$.ajax( {
|
||||
"dataType": 'json',
|
||||
"type": "GET",
|
||||
"url": sSource,
|
||||
"data": aoData,
|
||||
"success": fnCallback
|
||||
} );
|
||||
},
|
||||
"fnServerData": fnServerData,
|
||||
|
||||
"oLanguage": {
|
||||
"sSearch": ""
|
||||
},
|
||||
|
||||
"aLengthMenu": [[50, 100, 500, -1], [50, 100, 500, "All"]],
|
||||
"iDisplayLength": 50,
|
||||
|
||||
"sPaginationType": "full_numbers",
|
||||
"bJQueryUI": true,
|
||||
"bAutoWidth": false,
|
||||
"bAutoWidth": true,
|
||||
|
||||
"sDom": 'lfr<"H"T><"dataTables_scrolling"t><"F"ip>',
|
||||
|
||||
|
@ -56,6 +69,8 @@ var AIRTIME = (function(AIRTIME) {
|
|||
}
|
||||
});
|
||||
oTable.fnSetFilteringDelay(350);
|
||||
|
||||
return oTable;
|
||||
};
|
||||
|
||||
return AIRTIME;
|
||||
|
@ -67,12 +82,52 @@ $(document).ready(function(){
|
|||
var viewport = AIRTIME.utilities.findViewportDimensions(),
|
||||
history_content = $("#history_content"),
|
||||
widgetHeight = viewport.height - 185,
|
||||
screenWidth = Math.floor(viewport.width - 110);
|
||||
screenWidth = Math.floor(viewport.width - 110),
|
||||
oBaseDatePickerSettings,
|
||||
oBaseTimePickerSettings,
|
||||
oTable,
|
||||
dateStartId = "#his_date_start",
|
||||
timeStartId = "#his_time_start",
|
||||
dateEndId = "#his_date_end",
|
||||
timeEndId = "#his_time_end";
|
||||
|
||||
history_content
|
||||
.height(widgetHeight)
|
||||
.width(screenWidth);
|
||||
|
||||
AIRTIME.history.historyTable();
|
||||
oBaseDatePickerSettings = {
|
||||
dateFormat: 'yy-mm-dd',
|
||||
onSelect: function(sDate, oDatePicker) {
|
||||
$(this).datepicker( "setDate", sDate );
|
||||
}
|
||||
};
|
||||
|
||||
oBaseTimePickerSettings = {
|
||||
showPeriodLabels: false,
|
||||
showCloseButton: true,
|
||||
showLeadingZero: false,
|
||||
defaultTime: '0:00'
|
||||
};
|
||||
|
||||
oTable = AIRTIME.history.historyTable();
|
||||
|
||||
history_content.find(dateStartId).datepicker(oBaseDatePickerSettings);
|
||||
history_content.find(timeStartId).timepicker(oBaseTimePickerSettings);
|
||||
history_content.find(dateEndId).datepicker(oBaseDatePickerSettings);
|
||||
history_content.find(timeEndId).timepicker(oBaseTimePickerSettings);
|
||||
|
||||
|
||||
history_content.find("#his_submit").click(function(ev){
|
||||
var fn,
|
||||
oRange;
|
||||
|
||||
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
||||
|
||||
fn = oTable.fnSettings().fnServerData;
|
||||
fn.start = oRange.start;
|
||||
fn.end = oRange.end;
|
||||
|
||||
oTable.fnDraw();
|
||||
});
|
||||
|
||||
});
|
|
@ -7,7 +7,11 @@ $(document).ready(function(){
|
|||
screenWidth = Math.floor(viewport.width - 110),
|
||||
oBaseDatePickerSettings,
|
||||
oBaseTimePickerSettings,
|
||||
oRange;
|
||||
oRange,
|
||||
dateStartId = "#sb_date_start",
|
||||
timeStartId = "#sb_time_start",
|
||||
dateEndId = "#sb_date_end",
|
||||
timeEndId = "#sb_time_end";
|
||||
|
||||
//set the heights of the main widgets.
|
||||
lib.height(widgetHeight);
|
||||
|
@ -30,78 +34,10 @@ $(document).ready(function(){
|
|||
defaultTime: '0:00'
|
||||
};
|
||||
|
||||
/*
|
||||
* Get the schedule range start in unix timestamp form (in seconds).
|
||||
* defaults to NOW if nothing is selected.
|
||||
*
|
||||
* @param String sDatePickerId
|
||||
*
|
||||
* @param String sTimePickerId
|
||||
*
|
||||
* @return Number iTime
|
||||
*/
|
||||
function fnGetTimestamp(sDatePickerId, sTimePickerId) {
|
||||
var date,
|
||||
time,
|
||||
iTime,
|
||||
iServerOffset,
|
||||
iClientOffset;
|
||||
|
||||
if ($(sDatePickerId).val() === "") {
|
||||
return 0;
|
||||
}
|
||||
|
||||
date = $(sDatePickerId).val();
|
||||
time = $(sTimePickerId).val();
|
||||
|
||||
date = date.split("-");
|
||||
time = time.split(":");
|
||||
|
||||
//0 based month in js.
|
||||
oDate = new Date(date[0], date[1]-1, date[2], time[0], time[1]);
|
||||
|
||||
iTime = oDate.getTime(); //value is in millisec.
|
||||
iTime = Math.round(iTime / 1000);
|
||||
iServerOffset = serverTimezoneOffset;
|
||||
iClientOffset = oDate.getTimezoneOffset() * -60;//function returns minutes
|
||||
|
||||
//adjust for the fact the the Date object is in client time.
|
||||
iTime = iTime + iClientOffset + iServerOffset;
|
||||
|
||||
return iTime;
|
||||
}
|
||||
/*
|
||||
* Returns an object containing a unix timestamp in seconds for the start/end range
|
||||
*
|
||||
* @return Object {"start", "end", "range"}
|
||||
*/
|
||||
function fnGetScheduleRange() {
|
||||
var iStart,
|
||||
iEnd,
|
||||
iRange,
|
||||
DEFAULT_RANGE = 60*60*24;
|
||||
|
||||
iStart = fnGetTimestamp("#sb_date_start", "#sb_time_start");
|
||||
iEnd = fnGetTimestamp("#sb_date_end", "#sb_time_end");
|
||||
|
||||
iRange = iEnd - iStart;
|
||||
|
||||
if (iRange === 0 || iEnd < iStart) {
|
||||
iEnd = iStart + DEFAULT_RANGE;
|
||||
iRange = DEFAULT_RANGE;
|
||||
}
|
||||
|
||||
return {
|
||||
start: iStart,
|
||||
end: iEnd,
|
||||
range: iRange
|
||||
};
|
||||
}
|
||||
|
||||
$("#sb_date_start").datepicker(oBaseDatePickerSettings);
|
||||
$("#sb_time_start").timepicker(oBaseTimePickerSettings);
|
||||
$("#sb_date_end").datepicker(oBaseDatePickerSettings);
|
||||
$("#sb_time_end").timepicker(oBaseTimePickerSettings);
|
||||
builder.find(dateStartId).datepicker(oBaseDatePickerSettings);
|
||||
builder.find(timeStartId).timepicker(oBaseTimePickerSettings);
|
||||
builder.find(dateEndId).datepicker(oBaseDatePickerSettings);
|
||||
builder.find(timeEndId).timepicker(oBaseTimePickerSettings);
|
||||
|
||||
$("#sb_submit").click(function(ev){
|
||||
var fn,
|
||||
|
@ -112,7 +48,7 @@ $(document).ready(function(){
|
|||
//reset timestamp value since input values could have changed.
|
||||
AIRTIME.showbuilder.resetTimestamp();
|
||||
|
||||
oRange = fnGetScheduleRange();
|
||||
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
||||
|
||||
fn = oTable.fnSettings().fnServerData;
|
||||
fn.start = oRange.start;
|
||||
|
@ -135,8 +71,7 @@ $(document).ready(function(){
|
|||
var $button = $(this),
|
||||
$lib = $("#library_content"),
|
||||
$builder = $("#show_builder"),
|
||||
schedTable = $("#show_builder_table").dataTable(),
|
||||
libTable = $lib.find("#library_display").dataTable();
|
||||
schedTable = $("#show_builder_table").dataTable();
|
||||
|
||||
if ($button.hasClass("sb-edit")) {
|
||||
|
||||
|
@ -164,7 +99,7 @@ $(document).ready(function(){
|
|||
schedTable.fnDraw();
|
||||
});
|
||||
|
||||
oRange = fnGetScheduleRange();
|
||||
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
||||
AIRTIME.showbuilder.fnServerData.start = oRange.start;
|
||||
AIRTIME.showbuilder.fnServerData.end = oRange.end;
|
||||
|
||||
|
|
|
@ -35,6 +35,79 @@ var AIRTIME = (function(AIRTIME){
|
|||
};
|
||||
};
|
||||
|
||||
/*
|
||||
* Get the schedule range start in unix timestamp form (in seconds).
|
||||
* defaults to NOW if nothing is selected.
|
||||
*
|
||||
* @param String sDatePickerId
|
||||
*
|
||||
* @param String sTimePickerId
|
||||
*
|
||||
* @return Number iTime
|
||||
*/
|
||||
mod.fnGetTimestamp = function(sDateId, sTimeId) {
|
||||
var date,
|
||||
time,
|
||||
iTime,
|
||||
iServerOffset,
|
||||
iClientOffset,
|
||||
temp;
|
||||
|
||||
temp = $(sDateId).val();
|
||||
if ( temp === "") {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
date = temp;
|
||||
}
|
||||
|
||||
time = $(sTimeId).val();
|
||||
|
||||
date = date.split("-");
|
||||
time = time.split(":");
|
||||
|
||||
//0 based month in js.
|
||||
oDate = new Date(date[0], date[1]-1, date[2], time[0], time[1]);
|
||||
|
||||
iTime = oDate.getTime(); //value is in millisec.
|
||||
iTime = Math.round(iTime / 1000);
|
||||
iServerOffset = serverTimezoneOffset;
|
||||
iClientOffset = oDate.getTimezoneOffset() * -60;//function returns minutes
|
||||
|
||||
//adjust for the fact the the Date object is in client time.
|
||||
iTime = iTime + iClientOffset + iServerOffset;
|
||||
|
||||
return iTime;
|
||||
};
|
||||
|
||||
/*
|
||||
* Returns an object containing a unix timestamp in seconds for the start/end range
|
||||
*
|
||||
* @return Object {"start", "end", "range"}
|
||||
*/
|
||||
mod.fnGetScheduleRange = function(dateStart, timeStart, dateEnd, timeEnd) {
|
||||
var iStart,
|
||||
iEnd,
|
||||
iRange,
|
||||
DEFAULT_RANGE = 60*60*24;
|
||||
|
||||
iStart = AIRTIME.utilities.fnGetTimestamp(dateStart, timeStart);
|
||||
iEnd = AIRTIME.utilities.fnGetTimestamp(dateEnd, timeEnd);
|
||||
|
||||
iRange = iEnd - iStart;
|
||||
|
||||
if (iRange === 0 || iEnd < iStart) {
|
||||
iEnd = iStart + DEFAULT_RANGE;
|
||||
iRange = DEFAULT_RANGE;
|
||||
}
|
||||
|
||||
return {
|
||||
start: iStart,
|
||||
end: iEnd,
|
||||
range: iRange
|
||||
};
|
||||
};
|
||||
|
||||
return AIRTIME;
|
||||
|
||||
}(AIRTIME || {}));
|
Loading…
Reference in New Issue