got basic data tables working need to add show selection, redraw etc

This commit is contained in:
Robbt 2019-05-02 19:32:50 -04:00
parent 448d9b9e90
commit 7c783536db
4 changed files with 136 additions and 54 deletions

View file

@ -6,28 +6,23 @@ $(document).ready(function() {
timeEndId = "#his_time_end",
show_id = "#his_show_filter";
console.log(show_id);
// set width dynamically
var width = $("#showlistenerstat_content").width();
width = width * .91;
addDatePicker();
showlistenerstat_content.find("#sb_submit").click(function(){
var show_id = $("#sb_show_filter").val();
console.log(show_id);
showlistenerstat_content.find("#his_submit").click(function(){
// var show_id = $("#sb_show_filter").val();
var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
var start = oRange.start;
var end = oRange.end;
getShowData(start, end, show_id);
brokeDataTable();
});
});
function getShowData(startTimestamp, endTimestamp, show_id) {
// get data
$.get(baseUrl+'Listenerstat/get-show-data', {start: startTimestamp, end: endTimestamp, show_id: show_id}, function(data) {
$.get(baseUrl+'Listenerstat/get-all-show-data', {start: startTimestamp, end: endTimestamp }, function(data) {
return data;
});
}
@ -60,52 +55,50 @@ function addDatePicker() {
showlistenerstat_content.find(timeEndId).timepicker(oBaseTimePickerSettings);
}
function getStartEnd() {
return AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
}
function showSummaryList(start, end) {
var url = baseUrl+"playouthistory/show-history-feed",
data = {
format: "json",
start: start,
end: end
};
$.post(url, data, function(json) {
drawShowList(json);
});
}
function brokeDataTable() {
var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
var start = oRange.start;
var end = oRange.end;
var show_id = $("#sb_show_filter").val();
var dt = $('#show_stats_datatable');
info = getStartEnd();
dt.dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": baseUrl + "Listenerstat/get-show-data",
"fnServerParams": function (aoData) {
aoData.push({start: start, end: end, show_id: show_id});
},
"fnAddData": function (sSource, aoData, fnCallback) {
$.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
});
},
"aoColumns": [
/* first name */ {"sName": "show", "mDataProp": "show"},
/* air date */ {"sName": "time", "mDataProp": "time"},
/* last name */ {"sName": "average_number_of_listeners", "mDataProp": "average_number_of_listeners"},
/* last name */ {"sName": "max_number_of_listeners", "mDataProp": "max_number_of_listeners"},
/* del button */ {
"sName": "null as delete",
"bSearchable": false,
"bSortable": false,
"mDataProp": "delete"
}
],
"bJQueryUI": true,
"bAutoWidth": false,
"bLengthChange": false,
"oLanguage": getDatatablesStrings({
"sEmptyTable": $.i18n._("No Show Records Found"),
"sEmptyTable": $.i18n._("No show found"),
"sZeroRecords": $.i18n._("No show statistics found"),
"sInfo": $.i18n._("Showing _START_ to _END_ of _TOTAL_ users"),
"sInfoEmpty": $.i18n._("Showing 0 to 0 of 0 users"),
"sInfoFiltered": $.i18n._("(filtered from _MAX_ total users)"),
}),
"sDom": '<"H"lf<"dt-process-rel"r>><"#user_list_inner_wrapper"t><"F"ip>'
/* last name */ {"sName": "maximum_number_of_listeners", "mDataProp": "maximum_number_of_listeners"}],
"sAjaxSource": baseUrl+'Listenerstat/get-all-show-data',
"sAjaxDataProp": "",
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push({"start": start, "end": end});
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": {"start": start, "end": end},
"success": fnCallback
} );
},
});
}