From fafc599780d575a307b40f128772070367fab22c Mon Sep 17 00:00:00 2001 From: Robbt Date: Tue, 30 Apr 2019 20:40:22 -0400 Subject: [PATCH] Added show listener stats page needs data display still --- airtime_mvc/application/configs/ACL.php | 2 + .../application/configs/navigation.php | 10 ++- .../controllers/ListenerstatController.php | 35 ++++++++- .../airtime/listenerstat/showlistenerstat.js | 77 +++++++++++++++++++ 4 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 airtime_mvc/public/js/airtime/listenerstat/showlistenerstat.js diff --git a/airtime_mvc/application/configs/ACL.php b/airtime_mvc/application/configs/ACL.php index df4f38d07..be904e86e 100644 --- a/airtime_mvc/application/configs/ACL.php +++ b/airtime_mvc/application/configs/ACL.php @@ -26,6 +26,7 @@ $ccAcl->add(new Zend_Acl_Resource('library')) ->add(new Zend_Acl_Resource('playouthistory')) ->add(new Zend_Acl_Resource('playouthistorytemplate')) ->add(new Zend_Acl_Resource('listenerstat')) + ->add(new Zend_Acl_Resource('showlistenerstat')) ->add(new Zend_Acl_Resource('usersettings')) ->add(new Zend_Acl_Resource('audiopreview')) ->add(new Zend_Acl_Resource('webstream')) @@ -84,6 +85,7 @@ $ccAcl->allow('G', 'index') ->allow('H', 'playlist') ->allow('H', 'playouthistory') ->allow('H', 'listenerstat') + ->allow('H', 'showlistenerstat') ->allow('A', 'playouthistorytemplate') ->allow('A', 'user') ->allow('A', 'systemstatus') diff --git a/airtime_mvc/application/configs/navigation.php b/airtime_mvc/application/configs/navigation.php index b211b323f..fb666613c 100644 --- a/airtime_mvc/application/configs/navigation.php +++ b/airtime_mvc/application/configs/navigation.php @@ -138,6 +138,14 @@ $pages[] = array( 'action' => 'index', 'resource' => 'listenerstat' ), + array( + 'label' => _('Show Listener Stats'), + 'module' => 'default', + 'controller' => 'listenerstat', + 'action' => 'show', + 'resource' => 'showlistenerstat' + ), + ) ); if (LIBRETIME_ENABLE_BILLING === true) { @@ -221,4 +229,4 @@ $container = new Zend_Navigation($pages); $container->id = "nav"; //store it in the registry: -Zend_Registry::set('Zend_Navigation', $container); \ No newline at end of file +Zend_Registry::set('Zend_Navigation', $container); diff --git a/airtime_mvc/application/controllers/ListenerstatController.php b/airtime_mvc/application/controllers/ListenerstatController.php index 6a74e4b43..5670c08bc 100644 --- a/airtime_mvc/application/controllers/ListenerstatController.php +++ b/airtime_mvc/application/controllers/ListenerstatController.php @@ -56,6 +56,39 @@ class ListenerstatController extends Zend_Controller_Action $this->view->errorStatus = $out; $this->view->date_form = $form; } + public function showAction() { + $CC_CONFIG = Config::getConfig(); + + $request = $this->getRequest(); + $baseUrl = Application_Common_OsPath::getBaseDir(); + Zend_Layout::getMvcInstance()->assign('parent_page', 'Analytics'); + $this->view->headScript()->appendFile($baseUrl.'js/airtime/listenerstat/showlistenerstat.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.pluginAPI.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->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']); + $user = Application_Model_User::getCurrentUser(); + if ($user->isUserType(array(UTYPE_SUPERADMIN, UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { + $this->view->showAllShows = true; + } + $form = new Application_Form_ShowBuilder(); + + list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request); + $userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone()); + $startsDT->setTimezone($userTimezone); + $endsDT->setTimezone($userTimezone); + $form->populate(array( + 'sb_date_start' => $startsDT->format("Y-m-d"), + 'sb_time_start' => $startsDT->format("H:i"), + 'sb_date_end' => $endsDT->format("Y-m-d"), + 'sb_time_end' => $endsDT->format("H:i") + )); + + $this->view->sb_form = $form; + } public function getDataAction(){ list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($this->getRequest()); @@ -67,8 +100,6 @@ class ListenerstatController extends Zend_Controller_Action public function getShowDataAction(){ list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($this->getRequest()); $show_id = $this->getRequest()->getParam("show_id", null); - Logging::info($this->getRequest()->getParam("show_id", null)); - Logging::info($show_id); $data = Application_Model_ListenerStat::getShowDataPointsWithinRange($startsDT->format(DEFAULT_TIMESTAMP_FORMAT), $endsDT->format(DEFAULT_TIMESTAMP_FORMAT),$show_id); $this->_helper->json->sendJson($data); diff --git a/airtime_mvc/public/js/airtime/listenerstat/showlistenerstat.js b/airtime_mvc/public/js/airtime/listenerstat/showlistenerstat.js new file mode 100644 index 000000000..ab440c16d --- /dev/null +++ b/airtime_mvc/public/js/airtime/listenerstat/showlistenerstat.js @@ -0,0 +1,77 @@ +$(document).ready(function() { + showlistenerstat_content = $("#showlistenerstat_content") + dateStartId = "#sb_date_start", + timeStartId = "#sb_time_start", + dateEndId = "#sb_date_end", + timeEndId = "#sb_time_end", + show_id = "#sb_show_filter"; + + console.log(show_id); + // set width dynamically + var width = $("#showlistenerstat_content").width(); + width = width * .91; + showlistenerstat_content.find("#sb_submit").click(function(){ + var show_id = $("#sb_show_filter").val(); + console.log(show_id); + var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId); + var start = oRange.start; + var end = oRange.end; + getShowData(start, end, show_id); + }); +}); + +function getShowData(startTimestamp, endTimestamp, show_id) { + // get data + $.get(baseUrl+'Listenerstat/get-show-data', {start: startTimestamp, end: endTimestamp, show_id: show_id}, function(data) { + return data; + }); +} + +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'); + 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>' + }); +} \ No newline at end of file