CC-3367: Display in Now Playing whether Live DJ stream and Live Master stream

are connected and give user the ability to block those streams

- added stream source switch interface
- backend code
This commit is contained in:
James 2012-03-08 17:42:38 -05:00
parent d4a387e113
commit f193047a1c
19 changed files with 383 additions and 38 deletions

View file

@ -29,6 +29,7 @@ class ApiController extends Zend_Controller_Action
->addActionContext('handle-watched-dir-missing', 'json')
->addActionContext('rabbitmq-do-push', 'json')
->addActionContext('check-live-stream-auth', 'json')
->addActionContext('update-source-status', 'json')
->initContext();
}
@ -862,6 +863,16 @@ class ApiController extends Zend_Controller_Action
Application_Model_StreamSetting::setLiquidsoapError($stream_id, $msg, $boot_time);
}
public function updateSourceStatusAction(){
$request = $this->getRequest();
$msg = $request->getParam('msg');
$sourcename = $request->getParam('sourcename');
$status = $request->getParam('status');
Application_Model_Preference::SetSourceStatus($sourcename, $status);
}
// handles addition/deletion of mount point which watched dirs reside
public function updateFileSystemMountAction(){

View file

@ -5,14 +5,42 @@ class DashboardController extends Zend_Controller_Action
public function init()
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('switch-source', 'json')
->initContext();
}
public function indexAction()
{
// action body
}
public function switchSourceAction(){
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$sourcename = $this->_getParam('sourcename');
$current_status = $this->_getParam('status');
$change_status_to = "on";
if(strtolower($current_status) == "on"){
$change_status_to = "off";
}
$data = array("sourcename"=>$sourcename, "status"=>$change_status_to);
Application_Model_RabbitMq::SendMessageToPypo("switch_source", $data);
if(strtolower($current_status) == "on"){
Application_Model_Preference::SetSourceSwitchStatus($sourcename, "off");
$this->view->status = "OFF";
}else{
Application_Model_Preference::SetSourceSwitchStatus($sourcename, "on");
$this->view->status = "ON";
}
}
public function switchOffSource(){
}
public function streamPlayerAction()
{
global $CC_CONFIG;

View file

@ -321,8 +321,18 @@ class ScheduleController extends Zend_Controller_Action
Application_Model_Show::ConvertToLocalTimeZone($range["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
Application_Model_Show::ConvertToLocalTimeZone($range["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
$source_status = array();
$live_dj = Application_Model_Preference::GetSourceStatus("live_dj");
$master_dj = Application_Model_Preference::GetSourceStatus("master_dj");
//might not be the correct place to implement this but for now let's just do it here
$source_status['live_dj_source'] = $live_dj;
$source_status['master_dj_source'] = $master_dj;
$this->view->source_status = $source_status;
$this->view->entries = $range;
}
public function removeGroupAction()

View file

@ -10,8 +10,11 @@
<div id="Panel">
<div class="logo"></div>
<?php echo $this->versionNotify() ?>
<?php echo $this->partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?>
<?php echo $this->versionNotify();
$sss = $this->SourceSwitchStatus();
$scs = $this->SourceConnectionStatus();?>
<?php echo $this->partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(),
"live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'])) ?>
<?php $partial = array('menu.phtml', 'default');
$this->navigation()->menu()->setPartial($partial); ?>

View file

@ -11,8 +11,12 @@
<div id="Panel">
<div class="logo"></div>
<?php echo $this->versionNotify() ?>
<?php echo $this->partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?>
<?php echo $this->versionNotify();
$sss = $this->SourceSwitchStatus();
$scs = $this->SourceConnectionStatus();
?>
<?php echo $this->partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(),
"live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'])) ?>
<?php $partial = array('menu.phtml', 'default');
$this->navigation()->menu()->setPartial($partial); ?>

View file

@ -11,8 +11,11 @@
<div id="Panel">
<div class="logo"></div>
<?php echo $this->versionNotify() ?>
<?php echo $this->partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?>
<?php echo $this->versionNotify();
$sss = $this->SourceSwitchStatus();
$scs = $this->SourceConnectionStatus(); ?>
<?php echo $this->partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(),
"live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'])) ?>
<?php $partial = array('menu.phtml', 'default');
$this->navigation()->menu()->setPartial($partial); ?>

View file

@ -728,6 +728,32 @@ class Application_Model_Preference
public static function GetLiveSteamMasterPassword(){
return self::GetValue("live_stream_master_password");
}
public static function SetSourceStatus($sourcename, $status){
self::SetValue($sourcename, $status, false);
}
public static function GetSourceStatus($sourcename){
$value = self::GetValue($sourcename);
if($value == null || $value == "false"){
return false;
}else{
return true;
}
}
public static function SetSourceSwitchStatus($sourcename, $status){
self::SetValue($sourcename."_switch", $status, false);
}
public static function GetSourceSwitchStatus($sourcename){
$value = self::GetValue($sourcename."_switch");
if($value == null || $value == "off"){
return "off";
}else{
return "on";
}
}
/* User specific preferences end */
}

View file

@ -0,0 +1,8 @@
<?php
class Airtime_View_Helper_SourceConnectionStatus extends Zend_View_Helper_Abstract{
public function SourceConnectionStatus(){
$status = array("live_dj"=>Application_Model_Preference::GetSourceStatus("live_dj"), "master_dj"=>Application_Model_Preference::GetSourceStatus("master_dj"));
return $status;
}
}

View file

@ -0,0 +1,9 @@
<?php
class Airtime_View_Helper_SourceSwitchStatus extends Zend_View_Helper_Abstract{
public function SourceSwitchStatus(){
$status = array("live_dj"=>Application_Model_Preference::GetSourceSwitchStatus("live_dj"), "master_dj"=>Application_Model_Preference::GetSourceSwitchStatus("master_dj"));
Logging::log(print_r($status,true));
return $status;
}
}

View file

@ -31,6 +31,14 @@
<li class="time-zone"><span id="time-zone"></span></li>
</ul>
</div>
<div class="source-info-block">
<ul>
<li>Source Streams</li>
<li><div id="airtime_connection" class="source-connection off"></div>Airtime</li>
<li><div id="live_dj_connection" class="source-connection off"></div>Live DJ<a href="#" id="live_dj" class="source-switch-button"><span><?php echo $this->live_dj_switch?></span></a></li>
<li><div id="master_dj_connection" class="source-connection off"></div>Master DJ<a href="#" id="master_dj" class="source-switch-button"><span><?php echo $this->master_dj_switch?></span></a></li>
</ul>
</div>
<div class="personal-block">
<ul>
<li><span class="name"><?php echo $this->user ?></span> | <a href="/Login/logout">Logout</a></li>

View file

@ -152,7 +152,7 @@ select {
position:relative;
}
.now-playing-block, .show-block, .on-air-block, .time-info-block, .personal-block, .listen-control-block, .trial-info-block {
.now-playing-block, .show-block, .on-air-block, .time-info-block, .personal-block, .listen-control-block, .trial-info-block, .source-info-block {
height:100px;
float:left;
margin-right:10px;
@ -263,7 +263,7 @@ select {
padding:0 12px 0 0;
background:url(images/masterpanel_spacer.png) no-repeat right 0;
}
.time-info-block {
.time-info-block {
padding:0 14px 0 2px;
background:url(images/masterpanel_spacer.png) no-repeat right 0;
min-width:105px;
@ -288,6 +288,25 @@ select {
font-size:17px;
margin-bottom:0;
}
.source-info-block {
padding:0 14px 0 2px;
background:url(images/masterpanel_spacer.png) no-repeat right 0;
min-width:150px;
}
.source-info-block li {
list-style-type:none;
font-size:14px;
color:#bdbdbd;
margin:0 0 6px;
}
.source-info-block ul {
margin:0;
padding:6px 0 0;
}
.on-air-info {
height:26px;
border:1px solid #242424;
@ -361,6 +380,59 @@ select {
color:#fff;
}
.source-switch-button {
font-size:11px;
text-transform:uppercase;
padding:0;
border:1px solid #242424;
color:#fff;
text-decoration:none;
font-weight:bold;
display:block;
text-align:center;
width: 40px;
float: right;
}
.source-switch-button span {
background-color: #6e6e6e;
background: -moz-linear-gradient(top, #868686 0, #6e6e6e 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #868686), color-stop(100%, #6e6e6e));
border:1px solid #a1a1a1;
border-width:1px 0;
border-bottom-color:#646464;
color:#dcdcdc;
text-shadow: #555555 0px -1px;
display:block;
}
.source-switch-button:hover {
border:1px solid #000;
}
.source-switch-button:hover span {
background-color: #292929;
background: -moz-linear-gradient(top, #3b3b3b 0, #292929 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #3b3b3b), color-stop(100%, #292929));
border:1px solid #555555;
border-width:1px 0;
border-bottom-color:#1e1e1e;
color:#fff;
color:#0C0;
text-shadow: #000 0px -1px;
display:block;
}
.source-connection {
border:1px solid #242424;
color:#fff;
min-height:14px;
min-width:14px;
background-color:#464646;
margin-right: 2px;
float: left;
}
/* END Master Panel */

View file

@ -74,14 +74,19 @@ function updateProgressBarValue(){
songPercentDone = 0;
currentSong = null;
} else {
if (currentSong.media_item_played == "t" && currentShow.length > 0)
if (currentSong.media_item_played == "t" && currentShow.length > 0){
$('#on-air-info').attr("class", "on-air-info on");
else
$("#airtime_connection").attr("class", "source-connection on");
}
else{
$('#on-air-info').attr("class", "on-air-info off");
$("#airtime_connection").attr("class", "source-connection off");
}
$('#progress-show').attr("class", "progress-show");
}
} else {
$('#on-air-info').attr("class", "on-air-info off");
$("#airtime_connection").attr("class", "source-connection off");
$('#progress-show').attr("class", "progress-show-error");
}
$('#progress-bar').attr("style", "width:"+songPercentDone+"%");
@ -218,10 +223,24 @@ function parseItems(obj){
localRemoteTimeOffset = date.getTime() - schedulePosixTime;
}
function parseSourceStatus(obj){
if(obj.live_dj_source == false){
$("#live_dj_connection").attr("class", "source-connection off");
}else{
$("#live_dj_connection").attr("class", "source-connection on");
}
if(obj.master_dj_source == false){
$("#master_dj_connection").attr("class", "source-connection off");
}else{
$("#master_dj_connection").attr("class", "source-connection on");
}
}
function getScheduleFromServer(){
$.ajax({ url: "/Schedule/get-current-playlist/format/json", dataType:"json", success:function(data){
parseItems(data.entries);
parseSourceStatus(data.source_status);
}, error:function(jqXHR, textStatus, errorThrown){}});
setTimeout(getScheduleFromServer, serverUpdateInterval);
}
@ -251,6 +270,30 @@ function setupQtip(){
}
}
function setSwitchListener(){
$(".source-switch-button").click(function(){
var sourcename = $(this).attr('id')
var status_span = $(this).find("span")
var status = status_span.html()
var _class = $(this).parent().find("div.source-connection").attr("class")
var source_connection_status = false
if(_class.indexOf("off") > 0){
source_connection_status = false
}else{
source_connection_status = true
}
if(source_connection_status){
$.get("/Dashboard/switch-source/format/json/sourcename/"+sourcename+"/status/"+status, function(data){
status_span.html(data.status)
});
}else{
alert("The source is not connected to Airtime!")
}
})
}
var stream_window = null;
function init() {
@ -262,6 +305,8 @@ function init() {
setupQtip();
setSwitchListener();
$('.listen-control-button').click(function() {
if (stream_window == null || stream_window.closed)
stream_window=window.open(baseUrl+"Dashboard/stream-player", 'name', 'width=400,height=178');