CC-733 : broadcast logs
adding time range selection for the log history.
This commit is contained in:
parent
7c63387dd5
commit
20db8d6fdf
8 changed files with 276 additions and 101 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue