Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Martin Konecny 2012-04-02 15:06:12 -04:00
commit 8b88e0534a
11 changed files with 295 additions and 132 deletions

View File

@ -204,8 +204,7 @@ class LibraryController extends Zend_Controller_Action
Logging::log($data['MDATA_KEY_FILEPATH']);
Application_Model_RabbitMq::SendMessageToMediaMonitor("md_update", $data);
$this->_helper->redirector('index');
$this->_redirect('playlist/index');
}
}

View File

@ -22,6 +22,7 @@ class ScheduleController extends Zend_Controller_Action
->addActionContext('edit-show', 'json')
->addActionContext('add-show', 'json')
->addActionContext('cancel-show', 'json')
->addActionContext('cancel-current-show', 'json')
->addActionContext('get-form', 'json')
->addActionContext('upload-to-sound-cloud', 'json')
->addActionContext('content-context-menu', 'json')
@ -816,21 +817,21 @@ class ScheduleController extends Zend_Controller_Action
public function cancelCurrentShowAction()
{
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
$user = Application_Model_User::GetCurrentUser();
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$showInstanceId = $this->_getParam('id');
try{
$showInstance = new Application_Model_ShowInstance($showInstanceId);
}catch(Exception $e){
$this->view->show_error = true;
return false;
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$id = $this->_getParam('id');
try {
$scheduler = new Application_Model_Scheduler();
$scheduler->cancelShow($id);
}
catch (Exception $e) {
$this->view->error = $e->getMessage();
Logging::log($e->getMessage());
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
}
$showInstance->clearShow();
$showInstance->delete();
Application_Model_RabbitMq::PushSchedule();
}
}

View File

@ -93,10 +93,10 @@ class Application_Model_Scheduler {
throw new OutDatedScheduleException("The show {$show->getDbName()} is over and cannot be scheduled.");
}
$origTs = intval($instanceInfo[$id]);
$currTs = intval($instance->getDbLastScheduled("U")) ? : 0;
if ($origTs !== $currTs) {
Logging::log("orig {$origTs} current {$currTs}");
$ts = intval($instanceInfo[$id]);
$lastSchedTs = intval($instance->getDbLastScheduled("U")) ? : 0;
if ($ts < $lastSchedTs) {
Logging::log("ts {$ts} last sched {$lastSchedTs}");
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
}
}
@ -215,6 +215,41 @@ class Application_Model_Scheduler {
return $nextDT;
}
/*
* @param int $showInstance
* @param array $exclude
* ids of sched items to remove from the calulation.
*/
private function removeGaps($showInstance, $exclude=null) {
Logging::log("removing gaps from show instance #".$showInstance);
$instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con);
if (is_null($instance)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
}
$itemStartDT = $instance->getDbStarts(null);
$schedule = CcScheduleQuery::create()
->filterByDbInstanceId($showInstance)
->filterByDbId($exclude, Criteria::NOT_IN)
->orderByDbStarts()
->find($this->con);
foreach ($schedule as $item) {
$itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength());
$item->setDbStarts($itemStartDT)
->setDbEnds($itemEndDT)
->save($this->con);
$itemStartDT = $itemEndDT;
}
}
/*
* @param array $scheduledIds
@ -280,16 +315,16 @@ class Application_Model_Scheduler {
$sched = new CcSchedule();
}
$sched->setDbStarts($nextStartDT);
$sched->setDbEnds($endTimeDT);
$sched->setDbFileId($file['id']);
$sched->setDbCueIn($file['cuein']);
$sched->setDbCueOut($file['cueout']);
$sched->setDbFadeIn($file['fadein']);
$sched->setDbFadeOut($file['fadeout']);
$sched->setDbClipLength($file['cliplength']);
$sched->setDbInstanceId($instance->getDbId());
$sched->save($this->con);
$sched->setDbStarts($nextStartDT)
->setDbEnds($endTimeDT)
->setDbFileId($file['id'])
->setDbCueIn($file['cuein'])
->setDbCueOut($file['cueout'])
->setDbFadeIn($file['fadein'])
->setDbFadeOut($file['fadeout'])
->setDbClipLength($file['cliplength'])
->setDbInstanceId($instance->getDbId())
->save($this->con);
$nextStartDT = $endTimeDT;
}
@ -504,40 +539,48 @@ class Application_Model_Scheduler {
throw $e;
}
}
/*
* @param int $showInstance
* @param array $exclude
* ids of sched items to remove from the calulation.
* Used for cancelling the current show instance.
*
* @param $p_id id of the show instance to cancel.
*/
private function removeGaps($showInstance, $exclude=null) {
Logging::log("removing gaps from show instance #".$showInstance);
$instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con);
if (is_null($instance)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
}
$itemStartDT = $instance->getDbStarts(null);
$schedule = CcScheduleQuery::create()
->filterByDbInstanceId($showInstance)
->filterByDbId($exclude, Criteria::NOT_IN)
->orderByDbStarts()
->find($this->con);
foreach ($schedule as $item) {
$itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength());
$item->setDbStarts($itemStartDT);
$item->setDbEnds($itemEndDT);
$item->save($this->con);
$itemStartDT = $itemEndDT;
public function cancelShow($p_id) {
$this->con->beginTransaction();
try {
$instance = CcShowInstancesQuery::create()->findPK($p_id);
if (!$instance->getDbRecord()) {
$items = CcScheduleQuery::create()
->filterByDbInstanceId($p_id)
->filterByDbEnds($this->nowDT, Criteria::GREATER_THAN)
->find($this->con);
$remove = array();
$ts = $this->nowDT->format('U');
for($i = 0; $i < count($items); $i++) {
$remove[$i]["instance"] = $p_id;
$remove[$i]["timestamp"] = $ts;
$remove[$i]["id"] = $items[$i]->getDbId();
}
$this->removeItems($remove, false);
}
$instance->setDbEnds($this->nowDT);
$instance->save($this->con);
$this->con->commit();
}
catch (Exception $e) {
$this->con->rollback();
throw $e;
}
}
}

View File

@ -18,6 +18,7 @@ class Application_Model_ShowBuilder {
private $pos;
private $contentDT;
private $epoch_now;
private $currentShow;
private $defaultRowArray = array(
"header" => false,
@ -54,6 +55,7 @@ class Application_Model_ShowBuilder {
$this->user = Application_Model_User::GetCurrentUser();
$this->opts = $p_opts;
$this->epoch_now = floatval(microtime(true));
$this->currentShow = false;
}
//check to see if this row should be editable by the user.
@ -118,7 +120,7 @@ class Application_Model_ShowBuilder {
else if ($row["footer"] === true && $this->epoch_now < $p_epochItemEnd) {
$row["scheduled"] = 2;
}
else if ($row["header"] === true && $this->epoch_now > $p_epochItemStart) {
else if ($row["header"] === true && $this->epoch_now >= $p_epochItemStart) {
$row["scheduled"] = 0;
}
else if ($row["header"] === true && $this->epoch_now < $p_epochItemEnd) {
@ -156,6 +158,14 @@ class Application_Model_ShowBuilder {
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
$showEndDT->setTimezone(new DateTimeZone($this->timezone));
$endsEpoch = floatval($showEndDT->format("U.u"));
if ($startsEpoch < $this->epoch_now && $endsEpoch > $this->epoch_now) {
$row["currentShow"] = true;
$this->currentShow = true;
}
else {
$this->currentShow = false;
}
$row["header"] = true;
$row["starts"] = $showStartDT->format("Y-m-d H:i");
@ -224,6 +234,10 @@ class Application_Model_ShowBuilder {
$row["id"] = 0 ;
$row["instance"] = intval($p_item["si_id"]);
}
if ($this->currentShow = true) {
$row["currentShow"] = true;
}
$this->getItemColor($p_item, $row);
$this->getRowTimestamp($p_item, $row);
@ -256,6 +270,10 @@ class Application_Model_ShowBuilder {
$endsEpoch = floatval($showEndDT->format("U.u"));
$row["refresh"] = floatval($showEndDT->format("U.u")) - $this->epoch_now;
if ($this->currentShow = true) {
$row["currentShow"] = true;
}
$this->getScheduledStatus($startsEpoch, $endsEpoch, $row);
$this->isAllowed($p_item, $row);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 970 B

View File

@ -33,8 +33,8 @@
color:#bdbdbd;
margin:0;
height:15px;
padding-right:20px;
background:url(images/source-info_lines.png) no-repeat right 0;
padding-right:0;
overflow:visible;
}
.source-info-block li:first-child {
background-position: right -50px;
@ -44,51 +44,90 @@
background-position: right -150px;
padding-top:3px;
}
.source-info-block li div {
display:inline-block;
margin-right:10px;
.source-info-block li div.source-label {
margin-right:0;
min-width:95px;
float:left;
height:15px;
line-height:14px;
padding:0 2px 0 3px;
background:#3e3e3e;
-webkit-border-radius:2px;
-moz-border-radius:2px;
border-radius:2px;
border-right:2px solid #3e3e3e;
-webkit-border-radius:2px 0 0 2px;
-moz-border-radius:2px 0 0 2px;
border-radius:2px 0 0 2px;
}
.source-info-block li div.source-label.ready {
background:#2f2e2e;
color:#fff;
}
.source-info-block li .line-to-switch, .source-info-block li .line-to-switch.off {
margin:0;
width:12px;
float:left;
height:15px;
padding:0;
border-left:2px solid #3e3e3e;
background:url(images/source_to_switch_lines.png) repeat-x 0 0;
}
.source-info-block li .line-to-switch.off {
border-color:#3e3e3e;
background:url(images/source_to_switch_lines.png) repeat-x 0 0;
}
.source-info-block li .line-to-switch.on {
border-color:#ff611f;
background:url(images/source_to_switch_lines.png) repeat-x 0 -15px;
}
.source-info-block li .line-to-on-air, .source-info-block li .line-to-on-air.off {
margin:0;
width:20px;
float:left;
height:15px;
padding:0;
background:url(images/source_to_switch_lines.png) repeat-x 0 0;
}
.source-info-block li .line-to-on-air, .source-info-block li .line-to-on-air.off {
margin:0;
width:20px;
float:left;
height:15px;
padding:0;
background:url(images/source-info_lines.png) repeat-x 0 0;
}
.source-info-block li .line-to-on-air.off {
background:url(images/source-info_lines.png) no-repeat 0 0;
}
.source-info-block li .line-to-on-air.on {
background:url(images/source-info_lines.png) no-repeat 0 -15px;
}
.source-info-block li.ready {
.source-info-block li.active {
background-position: right -15px;
}
.source-info-block li.ready:first-child {
.source-info-block li.active:first-child {
background-position: right -70px;
}
.source-info-block li.ready:last-child {
.source-info-block li.active:last-child {
background-position: right -170px;
padding-top:3px;
}
.source-info-block li.active {
background-position: right -30px;
.source-info-block li:first-child .line-to-on-air, .source-info-block li:first-child .line-to-on-air.off {
background-position: right -50px;
margin-bottom:-3px;
height:18px;
}
.source-info-block li.active:first-child {
background-position: right -90px;
}
.source-info-block li.active:last-child {
background-position: right -190px;
padding-top:3px;
}
.source-info-block li.ready div, .source-info-block li.active div {
background:#2f2e2e;
border-color:#ff611f;
color:#fff;
.source-info-block li:first-child .line-to-on-air.on {
background-position: right -70px;
}
.source-info-block li.kicked div {
color:#737373;
}
.source-info-block li:last-child .line-to-on-air, .source-info-block li:last-child .line-to-on-air.off {
background-position: right -150px;
margin-top:-3px;
height:18px;
}
.source-info-block li:last-child .line-to-on-air.on {
background-position: right -170px;
}
.source-switch-button {
font-size:11px;

View File

@ -24,7 +24,7 @@
.sb-content .fg-toolbar ul {
float: left;
padding: 0;
margin: 0.5em 0 0 0;
margin: 0.5em 10px 0 0;
cursor: pointer;
}
@ -176,6 +176,10 @@ table.datatable tr.sb-header.odd:hover td, table.datatable tr.sb-header.even:hov
border-bottom-color:#6b6a6a !important;
}
.sb-header div.ui-state-default {
float: left;
}
.sb-content table th.ui-state-default {
background: -moz-linear-gradient(top, #b2b2b2 0, #a2a2a2 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #b2b2b2), color-stop(100%, #a2a2a2));

View File

@ -1,8 +1,14 @@
/**
*
* Schedule Dialog creation methods.
*
*/
var AIRTIME = (function(AIRTIME){
var mod;
if (AIRTIME.schedule === undefined) {
AIRTIME.schedule = {};
}
mod = AIRTIME.schedule;
return AIRTIME;
}(AIRTIME || {}));
var serverTimezoneOffset = 0;
@ -27,21 +33,27 @@ function checkShowLength(json) {
}
function confirmCancelShow(show_instance_id){
if (confirm('Erase current show and stop playback?')){
var url = "/Schedule/cancel-current-show/id/"+show_instance_id;
if (confirm('Cancel Current Show?')) {
var url = "/Schedule/cancel-current-show";
$.ajax({
url: url,
success: function(data){scheduleRefetchEvents(data);}
url: url,
data: {format: "json", id: show_instance_id},
success: function(data){
scheduleRefetchEvents(data);
}
});
}
}
function confirmCancelRecordedShow(show_instance_id){
if (confirm('Erase current show and stop recording?')){
var url = "/Schedule/cancel-current-show/id/"+show_instance_id;
if (confirm('Erase current show and stop recording?')) {
var url = "/Schedule/cancel-current-show";
$.ajax({
url: url,
success: function(data){scheduleRefetchEvents(data);}
url: url,
data: {format: "json", id: show_instance_id},
success: function(data){
scheduleRefetchEvents(data);
}
});
}
}

View File

@ -363,6 +363,10 @@ var AIRTIME = (function(AIRTIME){
else if (aData.status === 0) {
$(nRow).addClass("sb-over");
}
if (aData.currentShow === true) {
$(nRow).addClass("sb-current-show");
}
//call the context menu so we can prevent the event from propagating.
$(nRow).find('td:gt(1)').click(function(e){
@ -372,6 +376,20 @@ var AIRTIME = (function(AIRTIME){
return false;
});
},
//remove any selected nodes before the draw.
"fnPreDrawCallback": function( oSettings ) {
var oTT;
oTT = TableTools.fnGetInstance('show_builder_table');
oTT.fnSelectNone();
//disable jump to current button.
AIRTIME.button.disableButton("sb-button-current");
//disable deleting of overbooked tracks.
AIRTIME.button.disableButton("sb-button-trim");
//disable cancelling current show.
AIRTIME.button.disableButton("sb-button-cancel");
},
"fnDrawCallback": function(oSettings, json) {
var wrapperDiv,
markerDiv,
@ -413,7 +431,10 @@ var AIRTIME = (function(AIRTIME){
//if there is only 1 cursor on the page highlight it by default.
if ($cursorRows.length === 1) {
$cursorRows.addClass("cursor-selected-row");
$td = $cursorRows.find("td:first");
if (!$td.hasClass("dataTables_empty")) {
$cursorRows.addClass("cursor-selected-row");
}
}
}
@ -451,22 +472,16 @@ var AIRTIME = (function(AIRTIME){
//enable deleting of overbooked tracks.
AIRTIME.button.enableButton("sb-button-trim");
}
$tr = $sbTable.find('tr.sb-future:first');
if ($tr.hasClass('sb-current-show')) {
//enable cancelling current show.
AIRTIME.button.enableButton("sb-button-cancel");
}
},
"fnHeaderCallback": function(nHead) {
$(nHead).find("input[type=checkbox]").attr("checked", false);
},
//remove any selected nodes before the draw.
"fnPreDrawCallback": function( oSettings ) {
var oTT;
oTT = TableTools.fnGetInstance('show_builder_table');
oTT.fnSelectNone();
//disable jump to current button.
AIRTIME.button.disableButton("sb-button-current");
//disable deleting of overbooked tracks.
AIRTIME.button.disableButton("sb-button-trim");
},
"oColVis": {
"aiExclude": [ 0, 1 ]
@ -704,12 +719,44 @@ var AIRTIME = (function(AIRTIME){
//start setup of the builder toolbar.
$toolbar = $(".sb-content .fg-toolbar");
$toolbar
.append("<ul />")
.find('ul')
.append('<li class="ui-state-default ui-state-disabled sb-button-current" title="jump to the currently playing track"><span class="ui-icon ui-icon-arrowstop-1-s"></span></li>')
.append('<li class="ui-state-default ui-state-disabled sb-button-trim" title="delete all overbooked tracks"><span class="ui-icon ui-icon-scissors"></span></li>')
.append('<li class="ui-state-default ui-state-disabled sb-button-delete" title="delete selected items"><span class="ui-icon ui-icon-trash"></span></li>');
$ul = $("<ul/>");
$ul.append('<li class="ui-state-default ui-state-disabled sb-button-trim" title="delete all overbooked tracks"><span class="ui-icon ui-icon-scissors"></span></li>')
.append('<li class="ui-state-default ui-state-disabled sb-button-delete" title="delete selected items"><span class="ui-icon ui-icon-trash"></span></li>');
$toolbar.append($ul);
$ul = $("<ul/>");
$ul.append('<li class="ui-state-default ui-state-disabled sb-button-current" title="jump to the currently playing track"><span class="ui-icon ui-icon-arrowstop-1-s"></span></li>')
.append('<li class="ui-state-default ui-state-disabled sb-button-cancel" title="cancel current show"><span class="ui-icon ui-icon-eject"></span></li>');
$toolbar.append($ul);
//jump to current
$toolbar.find('.sb-button-cancel')
.click(function() {
var $tr,
data;
if (AIRTIME.button.isDisabled('sb-button-cancel') === true) {
return;
}
$tr = $sbTable.find('tr.sb-future:first');
if ($tr.hasClass('sb-current-show')) {
data = $tr.data("aData");
if (confirm('Cancel Current Show?')) {
var url = "/Schedule/cancel-current-show";
$.ajax({
url: url,
data: {format: "json", id: data.instance},
success: function(data){
var oTable = $sbTable.dataTable();
oTable.fnDraw();
}
});
}
}
});
//jump to current
$toolbar.find('.sb-button-current')

View File

@ -126,21 +126,21 @@ end
def append_dj_inputs(master_harbor_input_port, master_harbor_input_mount_point, dj_harbor_input_port, dj_harbor_input_mount_point, s) =
if master_harbor_input_port != 0 and master_harbor_input_mount_point != "" and dj_harbor_input_port != 0 and dj_harbor_input_mount_point != "" then
master_dj = input.harbor(id="master_harbor", master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client,
max=40., on_connect=master_dj_connect, on_disconnect=master_dj_disconnect)
dj_live = input.harbor(id="live_dj_harbor", dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client,
max=40., on_connect=live_dj_connect, on_disconnect=live_dj_disconnect)
master_dj = mksafe(input.harbor(id="master_harbor", master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client,
max=40., on_connect=master_dj_connect, on_disconnect=master_dj_disconnect))
dj_live = mksafe(input.harbor(id="live_dj_harbor", dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client,
max=40., on_connect=live_dj_connect, on_disconnect=live_dj_disconnect))
ignore(output.dummy(master_dj, fallible=true))
ignore(output.dummy(dj_live, fallible=true))
switch(id="master_dj_switch", track_sensitive=false, transitions=[transition, transition, transition], [({!master_dj_enabled},master_dj), ({!live_dj_enabled},dj_live), ({true}, s)])
elsif master_harbor_input_port != 0 and master_harbor_input_mount_point != "" then
master_dj = input.harbor(id="master_harbor", master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client,
max=40., on_connect=master_dj_connect, on_disconnect=master_dj_disconnect)
master_dj = mksafe(input.harbor(id="master_harbor", master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client,
max=40., on_connect=master_dj_connect, on_disconnect=master_dj_disconnect))
ignore(output.dummy(master_dj, fallible=true))
switch(id="master_dj_switch", track_sensitive=false, transitions=[transition, transition], [({!master_dj_enabled},master_dj), ({true}, s)])
elsif dj_harbor_input_port != 0 and dj_harbor_input_mount_point != "" then
dj_live = input.harbor(id="live_dj_harbor", dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client,
max=40., on_connect=live_dj_connect, on_disconnect=live_dj_disconnect)
dj_live = mksafe(input.harbor(id="live_dj_harbor", dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client,
max=40., on_connect=live_dj_connect, on_disconnect=live_dj_disconnect))
ignore(output.dummy(dj_live, fallible=true))
switch(id="live_dj_switch", track_sensitive=false, transitions=[transition, transition], [({!live_dj_enabled},dj_live), ({true}, s)])
else