-changes to list view. Framework so that we may change selected day

-changes to add-user. Started implementing Vladimirs design.
This commit is contained in:
mkonecny 2011-02-07 19:03:14 -05:00
parent e9691f9a4c
commit bc5b9efb4b
19 changed files with 351 additions and 69 deletions

View file

@ -76,6 +76,7 @@
<actionMethod actionName="index"/> <actionMethod actionName="index"/>
<actionMethod actionName="addUser"/> <actionMethod actionName="addUser"/>
<actionMethod actionName="getHosts"/> <actionMethod actionName="getHosts"/>
<actionMethod actionName="getUserDataTableInfo"/>
</controllerFile> </controllerFile>
<controllerFile controllerName="SidePlaylist"> <controllerFile controllerName="SidePlaylist">
<actionMethod actionName="index"/> <actionMethod actionName="index"/>
@ -84,6 +85,7 @@
<actionMethod actionName="index"/> <actionMethod actionName="index"/>
<actionMethod actionName="getDataGridData"/> <actionMethod actionName="getDataGridData"/>
<actionMethod actionName="livestream"/> <actionMethod actionName="livestream"/>
<actionMethod actionName="dayView"/>
</controllerFile> </controllerFile>
<controllerFile controllerName="Preference"> <controllerFile controllerName="Preference">
<actionMethod actionName="index"/> <actionMethod actionName="index"/>
@ -287,6 +289,12 @@
<viewControllerScriptsDirectory forControllerName="Library"> <viewControllerScriptsDirectory forControllerName="Library">
<viewScriptFile forActionName="getFileMetaData"/> <viewScriptFile forActionName="getFileMetaData"/>
</viewControllerScriptsDirectory> </viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Nowplaying">
<viewScriptFile forActionName="dayView"/>
</viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="User">
<viewScriptFile forActionName="getUserDataTableInfo"/>
</viewControllerScriptsDirectory>
</viewScriptsDirectory> </viewScriptsDirectory>
<viewHelpersDirectory/> <viewHelpersDirectory/>
<viewFiltersDirectory enabled="false"/> <viewFiltersDirectory enabled="false"/>

View file

@ -10,10 +10,23 @@
$pages = array( $pages = array(
array( array(
'label' => 'Now Playing', 'label' => 'Now Playing',
'module' => 'Nowplaying', 'uri' => 'javascript:void(null)',
'controller' => 'index', 'pages' => array(
'action' => 'index', array(
'order' => -100 //make sure home is the first page 'label' => 'Current',
'module' => 'default',
'controller' => 'Nowplaying',
'action' => 'index',
'resource' => 'Nowplaying'
),
array(
'label' => 'Daily View',
'module' => 'default',
'controller' => 'Nowplaying',
'action' => 'day-view',
'resource' => 'Nowplaying'
)
)
), ),
array( array(
'label' => 'Schedule', 'label' => 'Schedule',

View file

@ -6,27 +6,38 @@ class NowplayingController extends Zend_Controller_Action
public function init() public function init()
{ {
$ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('get-data-grid-data', 'json') $ajaxContext->addActionContext('get-data-grid-data', 'json')
->initContext(); ->initContext();
} }
public function indexAction() public function indexAction()
{ {
$this->view->headScript()->appendFile('/js/datatables/js/jquery.dataTables.min.js','text/javascript'); $this->view->headScript()->appendFile('/js/datatables/js/jquery.dataTables.min.js','text/javascript');
$this->view->headScript()->appendFile('/js/playlist/nowplayingdatagrid.js','text/javascript'); $this->view->headScript()->appendFile('/js/playlist/nowplayingdatagrid.js','text/javascript');
$this->view->headScript()->appendFile('/js/playlist/nowview.js','text/javascript');
} }
public function getDataGridDataAction() public function getDataGridDataAction()
{ {
$viewType = $this->_request->getParam('view'); $viewType = $this->_request->getParam('view');
$this->view->entries = Application_Model_Nowplaying::GetDataGridData($viewType); $dateString = $this->_request->getParam('date');
$this->view->entries = Application_Model_Nowplaying::GetDataGridData($viewType, $dateString);
} }
public function livestreamAction() public function livestreamAction()
{ {
//use bare bones layout (no header bar or menu) //use bare bones layout (no header bar or menu)
$this->_helper->layout->setLayout('bare'); $this->_helper->layout->setLayout('bare');
} }
public function dayViewAction()
{
$this->view->headScript()->appendFile('/js/datatables/js/jquery.dataTables.min.js','text/javascript');
$this->view->headScript()->appendFile('/js/playlist/nowplayingdatagrid.js','text/javascript');
$this->view->headScript()->appendFile('/js/playlist/dayview.js','text/javascript');
}
} }
@ -35,3 +46,5 @@ class NowplayingController extends Zend_Controller_Action

View file

@ -5,43 +5,54 @@ class UserController extends Zend_Controller_Action
public function init() public function init()
{ {
$ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('get-hosts', 'json') $ajaxContext->addActionContext('get-hosts', 'json')
->initContext(); ->addActionContext('get-user-data-table-info', 'json')
->initContext();
} }
public function indexAction() public function indexAction()
{ {
} }
public function addUserAction() public function addUserAction()
{ {
$this->view->headScript()->appendFile('/js/datatables/js/jquery.dataTables.js','text/javascript');
$this->view->headScript()->appendFile('/js/airtime/user/user.js','text/javascript');
$request = $this->getRequest(); $request = $this->getRequest();
$form = new Application_Form_AddUser(); $form = new Application_Form_AddUser();
if ($request->isPost()) { if ($request->isPost()) {
if ($form->isValid($request->getPost())) { if ($form->isValid($request->getPost())) {
$formdata = $form->getValues(); $formdata = $form->getValues();
User::addUser($formdata); User::addUser($formdata);
$form->reset(); $form->reset();
} }
} }
$this->view->form = $form; $this->view->form = $form;
} }
public function getHostsAction() public function getHostsAction()
{ {
$search = $this->_getParam('term'); $search = $this->_getParam('term');
$this->view->hosts = User::getHosts($search); $this->view->hosts = User::getHosts($search);
} }
public function getUserDataTableInfoAction()
{
$post = $this->getRequest()->getPost();
$users = User::getUsersDataTablesInfo($post);
die(json_encode($users));
}
} }

View file

@ -8,47 +8,54 @@ class Application_Form_AddUser extends Zend_Form
// Add login element // Add login element
$this->addElement('text', 'login', array( $this->addElement('text', 'login', array(
'label' => 'Username:', 'label' => 'Username:',
'class' => 'input_text',
'required' => true, 'required' => true,
'filters' => array('StringTrim'), 'filters' => array('StringTrim'),
'validators' => array('NotEmpty') 'validators' => array('NotEmpty')
)); ));
// Add password element // Add password element
$this->addElement('text', 'password', array( $this->addElement('text', 'password', array(
'label' => 'Password:', 'label' => 'Password:',
'class' => 'input_text',
'required' => true, 'required' => true,
'filters' => array('StringTrim'), 'filters' => array('StringTrim'),
'validators' => array('NotEmpty') 'validators' => array('NotEmpty')
)); ));
// Add first name element // Add first name element
$this->addElement('text', 'first_name', array( $this->addElement('text', 'first_name', array(
'label' => 'Firstname:', 'label' => 'Firstname:',
'class' => 'input_text',
'required' => true, 'required' => true,
'filters' => array('StringTrim'), 'filters' => array('StringTrim'),
'validators' => array('NotEmpty') 'validators' => array('NotEmpty')
)); ));
// Add last name element // Add last name element
$this->addElement('text', 'last_name', array( $this->addElement('text', 'last_name', array(
'label' => 'Lastname:', 'label' => 'Lastname:',
'class' => 'input_text',
'required' => true, 'required' => true,
'filters' => array('StringTrim'), 'filters' => array('StringTrim'),
'validators' => array('NotEmpty') 'validators' => array('NotEmpty')
)); ));
//Add type select //Add type select
$this->addElement('select', 'type', array( $this->addElement('select', 'type', array(
'required' => true, 'required' => true,
'class' => 'input_select',
'style' => 'width: 40%',
'multiOptions' => array( 'multiOptions' => array(
"A" => "admin", "A" => "admin",
"H" => "host", "H" => "host",
"G" => "guest", "G" => "guest",
), ),
)); ));
// Add the submit button // Add the submit button
$this->addElement('submit', 'submit', array( $this->addElement('submit', 'submit', array(
'class' => 'ui-button ui-state-default right-floated',
'ignore' => true, 'ignore' => true,
'label' => 'Submit', 'label' => 'Submit',
)); ));

View file

@ -12,6 +12,10 @@ class Application_Model_DateHelper
return date("Y-m-d H:i:s", $this->_timestamp); return date("Y-m-d H:i:s", $this->_timestamp);
} }
function setDate($dateString){
$this->_timestamp = strtotime($dateString);
}
function getNowDayStartDiff(){ function getNowDayStartDiff(){
$dayStartTS = strtotime(date("Y-m-d", $this->_timestamp)); $dayStartTS = strtotime(date("Y-m-d", $this->_timestamp));
return $this->_timestamp - $dayStartTS; return $this->_timestamp - $dayStartTS;

View file

@ -42,13 +42,13 @@ class Application_Model_Nowplaying
return $rows; return $rows;
} }
public static function GetDataGridData($viewType){ public static function GetDataGridData($viewType, $dateString){
$date = Schedule::GetSchedulerTime();
$timeNow = $date->getDate();
if ($viewType == "now"){ if ($viewType == "now"){
$date = new Application_Model_DateHelper;
$timeNow = $date->getDate();
/* When do "ORDER BY x DESC LIMIT 5" to ensure that we get the last 5 previously scheduled items. /* When do "ORDER BY x DESC LIMIT 5" to ensure that we get the last 5 previously scheduled items.
* However using DESC, puts our scheduled items in reverse order, so we need to reverse it again * However using DESC, puts our scheduled items in reverse order, so we need to reverse it again
* with array_reverse. * with array_reverse.
@ -58,6 +58,10 @@ class Application_Model_Nowplaying
$next = Schedule::Get_Scheduled_Item_Data($timeNow, 1, 10, "24 hours"); $next = Schedule::Get_Scheduled_Item_Data($timeNow, 1, 10, "24 hours");
} else { } else {
$date = new Application_Model_DateHelper;
$timeNow = $date->setDate($dateString);
$timeNow = $date->getDate();
$previous = array_reverse(Schedule::Get_Scheduled_Item_Data($timeNow, -1, "ALL", $date->getNowDayStartDiff()." seconds")); $previous = array_reverse(Schedule::Get_Scheduled_Item_Data($timeNow, -1, "ALL", $date->getNowDayStartDiff()." seconds"));
$current = Schedule::Get_Scheduled_Item_Data($timeNow, 0); $current = Schedule::Get_Scheduled_Item_Data($timeNow, 0);
$next = Schedule::Get_Scheduled_Item_Data($timeNow, 1, "ALL", $date->getNowDayEndDiff()." seconds"); $next = Schedule::Get_Scheduled_Item_Data($timeNow, 1, "ALL", $date->getNowDayEndDiff()." seconds");

View file

@ -419,21 +419,6 @@ class Schedule {
return $rows; return $rows;
} }
/**
* Returns the date of the server in the format
* "YYYY-MM-DD HH:mm:SS".
*
* Note: currently assuming that Web Server and Scheduler are on the
* same host.
*
* @return date Current server time.
*/
public static function GetSchedulerTime() {
$date = new Application_Model_DateHelper;
return $date;
}
/** /**
* Returns data related to the scheduled items. * Returns data related to the scheduled items.
* *
@ -447,7 +432,7 @@ class Schedule {
return array(); return array();
} }
$date = Schedule::GetSchedulerTime(); $date = new Application_Model_DateHelper;
$timeNow = $date->getDate(); $timeNow = $date->getDate();
return array("env"=>APPLICATION_ENV, return array("env"=>APPLICATION_ENV,
"schedulerTime"=>gmdate("Y-m-d H:i:s"), "schedulerTime"=>gmdate("Y-m-d H:i:s"),

View file

@ -1797,7 +1797,7 @@ class StoredFile {
return StoredFile::searchFiles($fromTable, $datatables); return StoredFile::searchFiles($fromTable, $datatables);
} }
private static function searchFiles($fromTable, $data) public static function searchFiles($fromTable, $data)
{ {
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;

View file

@ -71,5 +71,11 @@ class User {
public static function getHosts($search=NULL) { public static function getHosts($search=NULL) {
return User::getUsers(array('H', 'A'), $search); return User::getUsers(array('H', 'A'), $search);
} }
public static function getUsersDataTablesInfo($datatables_post) {
$fromTable = "cc_subjs";
return StoredFile::searchFiles($fromTable, $datatables_post);
}
} }

View file

@ -0,0 +1,2 @@
<input type="text" id="datepicker" class="input_text">
<div id='demo'></div>

View file

@ -1,2 +1 @@
<div style="text-align:right;"><a href="javascript:void(0);" onclick="setViewType(0)">Now View</a> | <a href="javascript:void(0);" onclick="setViewType(1)">Day View</a></div>
<div id='demo'></div> <div id='demo'></div>

View file

@ -1,3 +1,126 @@
<?php <?php
echo $this->form; //echo $this->form;
?>
<div class=
"ui-widget ui-widget-content block-shadow clearfix padded-strong user-management">
<h2>
Manage users
</h2>
<div class="user-list-wrapper">
<div id="schedule_playlists_wrapper" class="dataTables_wrapper">
<div class=
"fg-toolbar ui-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix">
<div class="dataTables_filter" id="schedule_playlists_filter">
<input type="text" class="input_text auto-search">
</div>
<div class="button-holder">
<button type="button" id="search_add_group" name=
"search_add_group" class=
"ui-button ui-widget ui-state-default ui-button-text-icon-primary">
<span class="ui-button-text">Add user</span></button>
</div>
</div>
<table cellspacing="0" cellpadding="0" style="" id="users_datatable" class="datatable">
<thead>
<tr>
<th>id</th>
<th>Name</th>
<th>Role</th>
<th>Delete</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
<div class="user-data simple-formblock">
<fieldset class="padded">
<?php echo $this->form ?>
</fieldset>
</div>
<!--
<div class="user-data simple-formblock">
<form method="post" action="" enctype=
"application/x-www-form-urlencoded">
<fieldset class="padded">
<dl class="zend_form">
<dt id="first_name-label">
<label class="required" for="first_name">Firstname:</label>
</dt>
<dd id="first_name-element">
<input type="text" value="" id="first_name" name="first_name"
class="input_text">
</dd>
<dt id="last_name-label">
<label class="required" for="last_name">Lastname:</label>
</dt>
<dd id="last_name-element">
<input type="text" value="" id="last_name" name="last_name"
class="input_text">
</dd>
<dt id="login-label">
<label class="required" for="login">Username:</label>
</dt>
<dd id="login-element">
<input type="text" value="" id="login" name="login" class=
"input_text">
</dd>
<dt id="password-label">
<label class="required" for="password">Password:</label>
</dt>
<dd id="password-element">
<input type="text" value="" id="password" name="password"
class="input_text">
</dd>
<dt id="type-label">
<label class="required" for="type">Role:</label>
</dt>
<dd id="type-element">
<select id="type" name="type" class="input_select" style=
"width:40%;">
<option label="admin" value="A">
admin
</option>
<option label="host" value="H">
host
</option>
<option label="guest" value="G">
guest
</option>
</select>
</dd>
</dl>
</fieldset>
<fieldset class="padded">
<dl class="zend_form">
<dt id="skype-label">
<label class="required" for="skype_name">Skype:</label>
</dt>
<dd id="skype-element">
<input type="text" value="" id="skype_name" name="skype_name"
class="input_text">
</dd>
<dt id="jabber-label">
<label class="required" for="jabber_name">Jabber:</label>
</dt>
<dd id="jabbert_name-element">
<input type="text" value="" id="jabber_name" name="jabber_name"
class="input_text">
</dd>
<dt id="email-label">
<label class="required" for="email">Email</label>
</dt>
<dd id="email-element">
<input type="text" value="" id="email" name="email" class=
"input_text">
</dd>
</dl>
</fieldset>
<fieldset class="padded">
<input type="submit" value="Save all" id="submit" name="submit"
class="ui-button ui-state-default right-floated">
</fieldset>
</form>
</div>-->
</div>

View file

@ -0,0 +1 @@
<br /><br /><center>View script for controller <b>User</b> and script/action name <b>getUserDataTableInfo</b></center>

View file

@ -762,7 +762,7 @@ dt.block-display, dd.block-display {
width:98% width:98%
} }
div.ui-datepicker { div.ui-datepicker {
font-size: 75%; /*font-size: 75%;*/
} }
@ -1059,4 +1059,61 @@ h2#scheduled_playlist_name span {
button, input { button, input {
margin-top:0; margin-top:0;
margin-bottom:0; margin-bottom:0;
}
.user-management {
width:810px;
}
.user-data {
float:left;
width:420px;
}
.user-list-wrapper {
float:left;
width:380px;
margin-right:10px;
}
.user-management div.user-list-wrapper .ui-widget-header:first-child {
background: none repeat scroll 0 0 transparent;
border-width: 0 0 1px;
color: #444444;
font-weight: bold;
}
.user-list-wrapper .ui-widget-header:first-child .dataTables_filter {
margin:0;
}
.user-management h2 {
font-size: 1.7em;
padding-bottom: 16px;
}
.user-management .dataTables_filter .auto-search {
width: 378px;
}
.user-data.simple-formblock dd {
width: 73%;
}
.user-data fieldset {
margin-bottom:8px;
}
.user-data fieldset:last-child {
margin-bottom:0;
}
.user-list-wrapper .button-holder {
padding:8px 0;
text-align:right;
}
.user-list-wrapper .button-holder .ui-button {
margin:0;
}
.ui-widget-content .user-list-wrapper .ui-icon.ui-icon-closethick {
background-image:url(redmond/images/ui-icons_666666_256x240.png);
cursor:pointer;
float:right;
margin-right:5px;
}
.ui-widget-content .user-list-wrapper .ui-icon.ui-icon-closethick:hover {
background-image:url(redmond/images/ui-icons_ff5d1a_256x240.png);
} }

View file

@ -0,0 +1,26 @@
$(document).ready(function() {
$('#users_datatable').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/User/get-user-data-table-info/format/json",
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
"aoColumns": [
/* Id */ { "sName": "id", "bSearchable": false, "bVisible": false },
/* user name */ { "sName": "login" },
/* user type */ { "sName": "type", "bSearchable": false },
/* del button */ { "sName": "first_name", "bSearchable": false, "bSortable": false}
],
"bJQueryUI": true,
"bAutoWidth": false,
"bLengthChange": false,
//"bFilter": false
});
});

View file

@ -0,0 +1 @@
var viewType = "day";

View file

@ -99,7 +99,6 @@ function createDataGrid(){
} }
var viewType = "now" //"day";
var mainLoopRegistered = false; var mainLoopRegistered = false;
function setViewType(type){ function setViewType(type){
@ -111,8 +110,29 @@ function setViewType(type){
init2(); init2();
} }
function getDateString(){
var date0 = $("#datepicker").datepicker("getDate");
return (date0.getFullYear() + "-" + date0.getMonth() + "-" + date0.getDate());
}
function getAJAXURL(){
var url = "/Nowplaying/get-data-grid-data/format/json/view/"+viewType;
if (viewType == "day"){
url += "/date/" + getDateString();
}
return url;
}
function init2(){ function init2(){
$.ajax({ url: "/Nowplaying/get-data-grid-data/format/json/view/" + viewType, dataType:"json", success:function(data){
if (!mainLoopRegistered){
setTimeout(init2, 5000);
mainLoopRegistered = true;
}
$.ajax({ url: getAJAXURL(), dataType:"json", success:function(data){
datagridData = data.entries; datagridData = data.entries;
createDataGrid(); createDataGrid();
}}); }});
@ -121,13 +141,14 @@ function init2(){
registered = true; registered = true;
registerSongEndListener(notifySongEnd); registerSongEndListener(notifySongEnd);
} }
if (!mainLoopRegistered){
setTimeout(init2, 5000);
mainLoopRegistered = true;
}
} }
$(document).ready(function() { $(document).ready(function() {
init2(); if (viewType == "day"){
$("#datepicker").datepicker();
var date = new Date();
$("#datepicker").datepicker("setDate", date);
}
init2();
}); });

View file

@ -0,0 +1 @@
var viewType = "now";