CC-3439: Live Stream: Only admin should be able to turn on/of switch and

able to see kick out button

- done
This commit is contained in:
James 2012-03-14 10:34:44 -04:00
parent 06e810c35d
commit 2ee4b227fc
8 changed files with 113 additions and 68 deletions

View File

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

View File

@ -14,10 +14,11 @@
<?php echo $this->versionNotify(); <?php echo $this->versionNotify();
$sss = $this->SourceSwitchStatus(); $sss = $this->SourceSwitchStatus();
$scs = $this->SourceConnectionStatus(); $scs = $this->SourceConnectionStatus();
$isAdmin = $this->isAdmin();
?> ?>
<?php echo $this->partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(), <?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'], "live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'],
"scheduled_play_switch"=>$sss['scheduled_play'])) ?> "scheduled_play_switch"=>$sss['scheduled_play'], "isAdmin"=>$isAdmin)) ?>
<?php $partial = array('menu.phtml', 'default'); <?php $partial = array('menu.phtml', 'default');
$this->navigation()->menu()->setPartial($partial); ?> $this->navigation()->menu()->setPartial($partial); ?>

View File

@ -13,10 +13,12 @@
<div class="logo"></div> <div class="logo"></div>
<?php echo $this->versionNotify(); <?php echo $this->versionNotify();
$sss = $this->SourceSwitchStatus(); $sss = $this->SourceSwitchStatus();
$scs = $this->SourceConnectionStatus(); ?> $scs = $this->SourceConnectionStatus();
<?php echo $this->partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining(), $isAdmin = $this->isAdmin();
"live_dj_switch"=>$sss['live_dj'], "live_dj_connection"=>$scs['live_dj'], "master_dj_switch"=>$sss['master_dj'], "master_dj_connection"=>$scs['master_dj'], ?>
"scheduled_play_switch"=>$sss['scheduled_play'])) ?> <?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'],
"scheduled_play_switch"=>$sss['scheduled_play'], "isAdmin"=>$isAdmin)) ?>
<?php $partial = array('menu.phtml', 'default'); <?php $partial = array('menu.phtml', 'default');
$this->navigation()->menu()->setPartial($partial); ?> $this->navigation()->menu()->setPartial($partial); ?>

View File

@ -11,8 +11,14 @@
<div id="Panel"> <div id="Panel">
<div class="logo"></div> <div class="logo"></div>
<?php echo $this->versionNotify() ?> <?php echo $this->versionNotify();
<?php echo $this->partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?> $sss = $this->SourceSwitchStatus();
$scs = $this->SourceConnectionStatus();
$isAdmin = $this->isAdmin();
?>
<?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'],
"scheduled_play_switch"=>$sss['scheduled_play'], "isAdmin"=>$isAdmin)) ?>
<?php $partial = array('menu.phtml', 'default'); <?php $partial = array('menu.phtml', 'default');
$this->navigation()->menu()->setPartial($partial); ?> $this->navigation()->menu()->setPartial($partial); ?>

View File

@ -0,0 +1,11 @@
<?php
class Airtime_View_Helper_IsAdmin extends Zend_View_Helper_Abstract
{
public function isAdmin()
{
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
return $user->isAdmin();
}
}

View File

@ -23,9 +23,32 @@
<div class="source-info-block"> <div class="source-info-block">
<ul> <ul>
<li>Source Streams</li> <li>Source Streams</li>
<li><div id="scheduled_play_connection" style="width:19px;"></div>Scheduled Play<div class="line-to-on-air off"></div><a href="#" id="scheduled_play" class="source-switch-button"><span><?php echo $this->scheduled_play_switch?></span></a><div class="line-to-switch off"></div></li> <li>
<li><div id="live_dj_connection" class="source-connection off"></div>Live DJ<div class="line-to-on-air off"></div><a href="#" id="live_dj" class="source-switch-button"><span><?php echo $this->live_dj_switch?></span></a><div class="line-to-switch off"></div></li> <div id="scheduled_play_div">
<li><div id="master_dj_connection" class="source-connection off"></div>Master DJ<div class="line-to-on-air off"></div><a href="#" id="master_dj" class="source-switch-button"><span><?php echo $this->master_dj_switch?></span></a><div class="line-to-switch off"></div></li> Scheduled Play
<div class="line-to-on-air off"></div>
<a href="#" id="scheduled_play" class="source-switch-button" onclick="<?php echo ($this->isAdmin)?"setSwitchListener(this);":"return false"?>"><span><?php echo $this->scheduled_play_switch?></span></a>
<div class="line-to-switch off"></div>
</div>
</li>
<li>
<div id="live_dj_div">
<?php if($this->isAdmin){?><a id="live_dj_connection" class="source-kick-button" onclick="kickSource(this)"></a><?php }?>
Live DJ
<div class="line-to-on-air off"></div>
<a href="#" id="live_dj" class="source-switch-button" onclick="<?php echo ($this->isAdmin)?"setSwitchListener(this);":"return false"?>"><span><?php echo $this->live_dj_switch?></span></a>
<div class="line-to-switch off"></div>
</div>
</li>
<li>
<div id="master_dj_div">
<?php if($this->isAdmin){?><a id="master_dj_connection" class="source-kick-button" onclick="kickSource(this)"></a><?php }?>
Master DJ
<div class="line-to-on-air off"></div>
<a href="#" id="master_dj" class="source-switch-button" onclick="<?php echo ($this->isAdmin)?"setSwitchListener(this);":"return false"?>"><span><?php echo $this->master_dj_switch?></span></a>
<div class="line-to-switch off"></div>
</div>
</li>
</ul> </ul>
</div> </div>
<div class="on-air-block"> <div class="on-air-block">

View File

@ -16,6 +16,7 @@ var uiUpdateInterval = 200;
var master_dj_on_air = false; var master_dj_on_air = false;
var live_dj_on_air = false; var live_dj_on_air = false;
var scheduled_play_on_air = false; var scheduled_play_on_air = false;
var scheduled_play_source = false;
//var timezoneOffset = 0; //var timezoneOffset = 0;
@ -80,20 +81,20 @@ function updateProgressBarValue(){
songPercentDone = 0; songPercentDone = 0;
currentSong = null; currentSong = null;
} else { } else {
var scheduled_play_connection = $("#scheduled_play_connection").parent().find(".line-to-switch") var scheduled_play_line_to_switch = $("#scheduled_play_div").find(".line-to-switch")
if (currentSong.media_item_played == "t" && currentShow.length > 0){ if (currentSong.media_item_played == "t" && currentShow.length > 0){
scheduled_play_connection.attr("class", "line-to-switch on"); scheduled_play_line_to_switch.attr("class", "line-to-switch on");
//scheduled_play_on_air = true; scheduled_play_source = true;
} }
else{ else{
//scheduled_play_on_air = false; scheduled_play_source = false;
scheduled_play_connection.attr("class", "line-to-switch off"); scheduled_play_line_to_switch.attr("class", "line-to-switch off");
} }
$('#progress-show').attr("class", "progress-show"); $('#progress-show').attr("class", "progress-show");
} }
} else { } else {
$('#on-air-info').attr("class", "on-air-info off"); scheduled_play_source = false;
$("#scheduled_play_connection").parent().find(".line-to-switch").attr("class", "line-to-switch off"); $("#scheduled_play_div").find(".line-to-switch").attr("class", "line-to-switch off");
$('#progress-show').attr("class", "progress-show-error"); $('#progress-show').attr("class", "progress-show-error");
} }
$('#progress-bar').attr("style", "width:"+songPercentDone+"%"); $('#progress-bar').attr("style", "width:"+songPercentDone+"%");
@ -231,8 +232,8 @@ function parseItems(obj){
} }
function parseSourceStatus(obj){ function parseSourceStatus(obj){
var live_div = $("#live_dj_connection").parent().find(".line-to-switch") var live_div = $("#live_dj_div").find(".line-to-switch")
var master_div = $("#master_dj_connection").parent().find(".line-to-switch") var master_div = $("#master_dj_div").find(".line-to-switch")
if(obj.live_dj_source == false){ if(obj.live_dj_source == false){
live_div.attr("class", "line-to-switch off") live_div.attr("class", "line-to-switch off")
@ -248,8 +249,6 @@ function parseSourceStatus(obj){
} }
function parseSwitchStatus(obj){ function parseSwitchStatus(obj){
var live_div = $("#live_dj_connection")
var master_div = $("#master_dj_connection")
if(obj.live_dj_source == "on" && obj.master_dj_source == "off"){ if(obj.live_dj_source == "on" && obj.master_dj_source == "off"){
live_dj_on_air = true; live_dj_on_air = true;
@ -275,7 +274,7 @@ function parseSwitchStatus(obj){
} }
function controlOnAirLight(){ function controlOnAirLight(){
if(scheduled_play_on_air || live_dj_on_air || master_dj_on_air){ if((scheduled_play_on_air && scheduled_play_source)|| live_dj_on_air || master_dj_on_air){
$('#on-air-info').attr("class", "on-air-info on"); $('#on-air-info').attr("class", "on-air-info on");
}else{ }else{
$('#on-air-info').attr("class", "on-air-info off"); $('#on-air-info').attr("class", "on-air-info off");
@ -283,26 +282,26 @@ function controlOnAirLight(){
} }
function controlSwitchLight(){ function controlSwitchLight(){
var live_div = $("#live_dj_connection") var live_div = $("#live_dj_div")
var master_div = $("#master_dj_connection") var master_div = $("#master_dj_div")
var scheduled_play_div = $("#scheduled_play_connection") var scheduled_play_div = $("#scheduled_play_div")
if(scheduled_play_on_air && !live_dj_on_air && !master_dj_on_air){ if((scheduled_play_on_air && scheduled_play_source) && !live_dj_on_air && !master_dj_on_air){
scheduled_play_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air on") scheduled_play_div.find(".line-to-on-air").attr("class", "line-to-on-air on")
live_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") live_div.find(".line-to-on-air").attr("class", "line-to-on-air off")
master_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") master_div.find(".line-to-on-air").attr("class", "line-to-on-air off")
}else if(live_dj_on_air && !master_dj_on_air){ }else if(live_dj_on_air && !master_dj_on_air){
scheduled_play_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") scheduled_play_div.find(".line-to-on-air").attr("class", "line-to-on-air off")
live_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air on") live_div.find(".line-to-on-air").attr("class", "line-to-on-air on")
master_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") master_div.find(".line-to-on-air").attr("class", "line-to-on-air off")
}else if(master_dj_on_air){ }else if(master_dj_on_air){
scheduled_play_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") scheduled_play_div.find(".line-to-on-air").attr("class", "line-to-on-air off")
live_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") live_div.find(".line-to-on-air").attr("class", "line-to-on-air off")
master_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air on") master_div.find(".line-to-on-air").attr("class", "line-to-on-air on")
}else{ }else{
scheduled_play_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") scheduled_play_div.find(".line-to-on-air").attr("class", "line-to-on-air off")
live_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") live_div.find(".line-to-on-air").attr("class", "line-to-on-air off")
master_div.parent().find(".line-to-on-air").attr("class", "line-to-on-air off") master_div.find(".line-to-on-air").attr("class", "line-to-on-air off")
} }
} }
@ -340,28 +339,31 @@ function setupQtip(){
} }
} }
function setSwitchListener(){ function setSwitchListener(ele){
$(".source-switch-button").click(function(){ var sourcename = $(ele).attr('id')
var sourcename = $(this).attr('id') var status_span = $(ele).find("span")
var status_span = $(this).find("span") var status = status_span.html()
var status = status_span.html() var _class = $(ele).parent().find("div.line-to-switch").attr("class")
var _class = $(this).parent().find("div.line-to-switch").attr("class") var source_connection_status = false
var source_connection_status = false
// user should be able to turn on/off scheduled_play switch anytime.
if(_class.indexOf("off") > 0){ if(sourcename.indexOf("scheduled_play") > 0 && _class.indexOf("off") > 0){
source_connection_status = false source_connection_status = false
}else{ }else{
source_connection_status = true source_connection_status = true
} }
if(source_connection_status){ if(source_connection_status){
$.get("/Dashboard/switch-source/format/json/sourcename/"+sourcename+"/status/"+status, function(data){ $.get("/Dashboard/switch-source/format/json/sourcename/"+sourcename+"/status/"+status, function(data){
status_span.html(data.status) status_span.html(data.status)
}); });
}else{ }else{
alert("The source is not connected to Airtime!") alert("The source is not connected to Airtime!")
} }
}) }
function kickSource(ele){
} }
var stream_window = null; var stream_window = null;
@ -375,8 +377,6 @@ function init() {
setupQtip(); setupQtip();
setSwitchListener();
$('.listen-control-button').click(function() { $('.listen-control-button').click(function() {
if (stream_window == null || stream_window.closed) if (stream_window == null || stream_window.closed)
stream_window=window.open(baseUrl+"Dashboard/stream-player", 'name', 'width=400,height=178'); stream_window=window.open(baseUrl+"Dashboard/stream-player", 'name', 'width=400,height=178');

View File

@ -45,7 +45,7 @@ ignore(output.dummy(default, fallible=true))
master_dj_enabled = ref false; master_dj_enabled = ref false;
live_dj_enabled = ref false; live_dj_enabled = ref false;
scheduled_play_enabled = ref true; scheduled_play_enabled = ref false;
def make_master_dj_available() def make_master_dj_available()
master_dj_enabled := true master_dj_enabled := true