SAAS-948 - ShowBuilder redesign initial commit

This commit is contained in:
Duncan Sommerville 2015-07-15 18:53:19 -04:00
parent d9117721b9
commit d7d9a994d5
19 changed files with 2786 additions and 30 deletions

View file

@ -130,9 +130,9 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
protected function _initTasks() {
/* We need to wrap this here so that we aren't checking when we're running the unit test suite
*/
$taskManager = TaskManager::getInstance();
$taskManager->runTask(AirtimeTask::UPGRADE); // Run the upgrade on each request (if it needs to be run)
if (getenv("AIRTIME_UNIT_TEST") != 1) {
$taskManager = TaskManager::getInstance();
$taskManager->runTask(AirtimeTask::UPGRADE); // Run the upgrade on each request (if it needs to be run)
//This will do the upgrade too if it's needed...
$taskManager->runTasks();
}

View file

@ -24,6 +24,7 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
->add(new Zend_Acl_Resource('dashboard'))
->add(new Zend_Acl_Resource('preference'))
->add(new Zend_Acl_Resource('showbuilder'))
->add(new Zend_Acl_Resource('show-builder'))
->add(new Zend_Acl_Resource('playouthistory'))
->add(new Zend_Acl_Resource('playouthistorytemplate'))
->add(new Zend_Acl_Resource('listenerstat'))
@ -49,6 +50,7 @@ $ccAcl->allow('G', 'index')
->allow('G', 'error')
->allow('G', 'user', 'edit-user')
->allow('G', 'showbuilder')
->allow('G', 'show-builder')
->allow('G', 'api')
->allow('G', 'schedule')
->allow('G', 'dashboard')

View file

@ -11,6 +11,7 @@ class LibraryController extends Zend_Controller_Action
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('contents-feed', 'json')
->addActionContext('contents-feed-test', 'json')
->addActionContext('delete', 'json')
->addActionContext('duplicate', 'json')
->addActionContext('delete-group', 'json')
@ -425,6 +426,19 @@ class LibraryController extends Zend_Controller_Action
$this->view->files = SecurityHelper::htmlescape_recursive($r["aaData"]);
}
public function contentsFeedTestAction()
{
$params = $this->getRequest()->getParams();
# terrible name for the method below. it does not only search files.
$r = Application_Model_StoredFile::searchLibraryFiles($params);
$this->view->sEcho = $r["sEcho"];
$this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"];
$this->view->iTotalRecords = $r["iTotalRecords"];
$this->view->files = SecurityHelper::htmlescape_recursive($r["aaData"]);
}
public function editFileMdAction()
{
$user = Application_Model_User::getCurrentUser();

View file

@ -0,0 +1,52 @@
<?php
class ShowBuilderController extends Zend_Controller_Action {
public function init() {
}
public function indexAction() {
$CC_CONFIG = Config::getConfig();
$baseUrl = Application_Common_OsPath::getBaseDir();
$userType = Application_Model_User::GetCurrentUser()->getType();
$this->view->headScript()->appendScript("localStorage.setItem( 'user-type', '$userType' );");
$this->view->headScript()->appendScript(Application_Common_GoogleAnalytics::generateGoogleTagManagerDataLayerJavaScript());
$this->view->headScript()->appendFile($baseUrl.'js/contextmenu/jquery.contextMenu.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/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.columnFilter.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/blockui/jquery.blockUI.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/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'css/media_library.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/library-test.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
// PLUPLOAD
$this->view->headScript()->appendFile($baseUrl.'js/libs/dropzone.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'css/dropzone/dropzone.min.css?'.$CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/showbuilder/builder_test.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/airtime/showbuilder/main_builder_test.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/showbuilder.css?'.$CC_CONFIG['airtime_version']);
$csrf_namespace = new Zend_Session_Namespace('csrf_namespace');
$csrf_element = new Zend_Form_Element_Hidden('csrf');
$csrf_element->setValue($csrf_namespace->authtoken)->setRequired('true')->removeDecorator('HtmlTag')->removeDecorator('Label');
$this->view->csrf = $csrf_element;
}
}

View file

@ -907,6 +907,112 @@ SQL;
return $results;
}
public static function searchLibraryFilesTest($datatables)
{
$con = Propel::getConnection(CcFilesPeer::DATABASE_NAME);
$displayColumns = self::getLibraryColumns();
$fileSelect = array();
foreach ($displayColumns as $key) {
if ($key === "id") {
$fileSelect[] = "FILES.id AS $key";
} elseif ($key === "owner_id") {
$fileSelect[] = "sub.login AS $key";
} //file length is displayed based on cueout - cuein.
else if ($key === "length") {
$fileSelect[] = "(cueout - cuein)::INTERVAL AS length";
} elseif ($key === "year") {
$fileSelect[] = "year AS ".$key;
} else {
$fileSelect[] = $key;
}
}
$fileSelect = "SELECT ". join(",", $fileSelect);
$fileTable = "({$fileSelect} FROM cc_files AS FILES LEFT JOIN cc_subjs AS sub ON (sub.id = FILES.owner_id) WHERE file_exists = 'TRUE' AND hidden='FALSE')";
$fromTable = $fileTable." AS File"; //need an alias for the table if it's standalone.
// update is_scheduled to false for tracks that
// have already played out
self::updatePastFilesIsScheduled();
$results = Application_Model_Datatables::findEntries($con, $displayColumns, $fromTable, $datatables);
$displayTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$utcTimezone = new DateTimeZone("UTC");
foreach ($results['aaData'] as &$row) {
$row['id'] = intval($row['id']);
//taken from Datatables.php, needs to be cleaned up there.
if (isset($r['ftype'])) {
if ($r['ftype'] == 'playlist') {
$pl = new Application_Model_Playlist($r['id']);
$r['length'] = $pl->getLength();
} elseif ($r['ftype'] == "block") {
$bl = new Application_Model_Block($r['id']);
$r['bl_type'] = $bl->isStatic() ? 'static' : 'dynamic';
$r['length'] = $bl->getLength();
}
}
if ($row['ftype'] === "audioclip") {
$cuein_formatter = new LengthFormatter($row["cuein"]);
$row["cuein"] = $cuein_formatter->format();
$cueout_formatter = new LengthFormatter($row["cueout"]);
$row["cueout"] = $cueout_formatter->format();
$cuein = Application_Common_DateHelper::playlistTimeToSeconds($row["cuein"]);
$cueout = Application_Common_DateHelper::playlistTimeToSeconds($row["cueout"]);
$row_length = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein);
$formatter = new SamplerateFormatter($row['sample_rate']);
$row['sample_rate'] = $formatter->format();
$formatter = new BitrateFormatter($row['bit_rate']);
$row['bit_rate'] = $formatter->format();
// for audio preview
$row['audioFile'] = $row['id'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION);
}
else {
$row['audioFile'] = $row['id'];
$row_length = $row['length'];
}
$len_formatter = new LengthFormatter($row_length);
$row['length'] = $len_formatter->format();
//convert mtime and utime to localtime
$row['mtime'] = new DateTime($row['mtime'], $utcTimezone);
$row['mtime']->setTimeZone($displayTimezone);
$row['mtime'] = $row['mtime']->format(DEFAULT_TIMESTAMP_FORMAT);
$row['utime'] = new DateTime($row['utime'], $utcTimezone);
$row['utime']->setTimeZone($displayTimezone);
$row['utime'] = $row['utime']->format(DEFAULT_TIMESTAMP_FORMAT);
//need to convert last played to localtime if it exists.
if (isset($row['lptime'])) {
$row['lptime'] = new DateTime($row['lptime'], $utcTimezone);
$row['lptime']->setTimeZone($displayTimezone);
$row['lptime'] = $row['lptime']->format(DEFAULT_TIMESTAMP_FORMAT);
}
// we need to initalize the checkbox and image row because we do not retrieve
// any data from the db for these and datatables will complain
$row['checkbox'] = "";
$row['image'] = "";
$type = substr($row['ftype'], 0, 2);
$row['tr_id'] = "{$type}_{$row['id']}";
}
return $results;
}
/**
* Copy a newly uploaded audio file from its temporary upload directory
* on the local disk (like /tmp) over to Airtime's "stor" directory,

View file

@ -0,0 +1,43 @@
<style>
body {
background: #242424;
}
.wrapper {
position: absolute;
background: #242424;
top: 138px;
left: 0;
right: 0;
/*padding: 0;*/
padding: 2em;
}
</style>
<form action="/rest/media" method="post" id="upload_form" class="dropzone dz-clickable" <?php if ($this->quotaLimitReached) { ?> class="hidden" <?php } ?>>
<?php echo $this->csrf ?>
<div class="dz-message">
<?php echo _("Drop files here or click to upload") ?>
</div>
</form>
<div id="media_type_nav">
<button id="new_media_selector" class="btn btn-small dropdown-toggle" data-toggle="dropdown">
New <span class="caret"></span>
</button>
<div class="media_type_selector selected" selection_id="1">Files</div>
<div class="media_type_selector" selection_id="2">Playlists</div>
<div class="media_type_selector" selection_id="3">Smart Blocks</div>
<div class="media_type_selector" selection_id="4">Webstreams</div>
</div>
<div id="library_content" class="lib-content tabs lib-test">
<?php echo $this->render('widgets/lib-table.phtml') ?>
</div>
<div id="show_builder" class="sb-content sb-test">
<div class="sb-timerange">
<?php echo $this->sb_form; ?>
</div>
<table id="show_builder_table" cellpadding="0" cellspacing="0" class="datatable"></table>
</div>
<?php echo $this->dialog ?>

View file

@ -0,0 +1,10 @@
<fieldset class="toggle closed" id="filter_options">
<legend style="cursor: pointer;">
<span class="ui-icon ui-icon-triangle-2-n-s"></span>
<?php echo _("Advanced Search Options") ?>
</legend>
<div id="advanced_search" class="advanced_search form-horizontal"></div>
</fieldset>
<table id="library_display" cellpadding="0" cellspacing="0" class="datatable">
</table>