CC-3174 : showbuilder
mostly done with new context menu, need to finish add/delete button actions on lib table for both screens.
This commit is contained in:
parent
da5e1ac302
commit
6c2475bf1f
9 changed files with 305 additions and 424 deletions
|
@ -30,7 +30,7 @@ $pages = array(
|
||||||
'resource' => 'library'
|
'resource' => 'library'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'label' => 'Show Builder',
|
'label' => 'Airtimeline',
|
||||||
'module' => 'default',
|
'module' => 'default',
|
||||||
'controller' => 'Showbuilder',
|
'controller' => 'Showbuilder',
|
||||||
'action' => 'index',
|
'action' => 'index',
|
||||||
|
|
|
@ -49,7 +49,6 @@ class LibraryController extends Zend_Controller_Action
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.TableTools.js','text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.TableTools.js','text/javascript');
|
||||||
|
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js','text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js','text/javascript');
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/advancedsearch.js','text/javascript');
|
|
||||||
|
|
||||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css');
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css');
|
||||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css');
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css');
|
||||||
|
@ -74,6 +73,8 @@ class LibraryController extends Zend_Controller_Action
|
||||||
|
|
||||||
$id = $this->_getParam('id');
|
$id = $this->_getParam('id');
|
||||||
$type = $this->_getParam('type');
|
$type = $this->_getParam('type');
|
||||||
|
//playlist||timeline
|
||||||
|
$screen = $this->_getParam('screen');
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$baseUrl = $request->getBaseUrl();
|
$baseUrl = $request->getBaseUrl();
|
||||||
|
|
||||||
|
@ -87,7 +88,7 @@ class LibraryController extends Zend_Controller_Action
|
||||||
$menu["edit"] = array("name"=> "Edit Metadata", "icon" => "edit", "url" => "/library/edit-file-md/id/{$id}");
|
$menu["edit"] = array("name"=> "Edit Metadata", "icon" => "edit", "url" => "/library/edit-file-md/id/{$id}");
|
||||||
|
|
||||||
if ($user->isAdmin()) {
|
if ($user->isAdmin()) {
|
||||||
$menu["delete"] = array("name"=> "Delete", "icon" => "delete");
|
$menu["del"] = array("name"=> "Delete", "icon" => "delete", "url" => "/library/delete");
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = $file->getRelativeFileUrl($baseUrl).'/download/true';
|
$url = $file->getRelativeFileUrl($baseUrl).'/download/true';
|
||||||
|
@ -120,11 +121,11 @@ class LibraryController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
else if ($type === "playlist") {
|
else if ($type === "playlist") {
|
||||||
|
|
||||||
if (!isset($this->pl_sess->id) || $this->pl_sess->id !== $id) {
|
if ($this->pl_sess->id !== $id && $screen == "playlist") {
|
||||||
$menu["edit"] = array("name"=> "Edit", "icon" => "edit");
|
$menu["edit"] = array("name"=> "Edit", "icon" => "edit");
|
||||||
}
|
}
|
||||||
|
|
||||||
$menu["delete"] = array("name"=> "Delete", "icon" => "delete");
|
$menu["del"] = array("name"=> "Delete", "icon" => "delete", "url" => "/library/delete");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->view->items = $menu;
|
$this->view->items = $menu;
|
||||||
|
@ -132,40 +133,52 @@ class LibraryController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function deleteAction()
|
public function deleteAction()
|
||||||
{
|
{
|
||||||
$ids = $this->_getParam('ids');
|
//array containing id and type of media to delete.
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$mediaItems = $this->_getParam('media', null);
|
||||||
$user = new Application_Model_User($userInfo->id);
|
|
||||||
|
|
||||||
if ($user->isAdmin()) {
|
$user = Application_Model_User::GetCurrentUser();
|
||||||
|
|
||||||
|
$files = array();
|
||||||
|
$playlists = array();
|
||||||
|
|
||||||
|
$message = null;
|
||||||
|
|
||||||
|
foreach ($mediaItems as $media) {
|
||||||
|
|
||||||
|
if ($media["type"] === "audioclip") {
|
||||||
|
$files[] = intval($media["id"]);
|
||||||
|
}
|
||||||
|
else if ($media["type"] === "playlist") {
|
||||||
|
$playlists[] = intval($media["id"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($playlists)) {
|
||||||
|
Application_Model_Playlist::DeletePlaylists($playlists);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$user->isAdmin()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($files as $id) {
|
||||||
|
Logging::log("deleting file {$id}");
|
||||||
|
|
||||||
if (!is_null($ids)) {
|
|
||||||
foreach ($ids as $key => $id) {
|
|
||||||
$file = Application_Model_StoredFile::Recall($id);
|
$file = Application_Model_StoredFile::Recall($id);
|
||||||
|
|
||||||
if (PEAR::isError($file)) {
|
if (isset($file)) {
|
||||||
$this->view->message = $file->getMessage();
|
try {
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if(is_null($file)) {
|
|
||||||
$this->view->message = "file doesn't exist";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$res = $file->delete();
|
$res = $file->delete();
|
||||||
|
|
||||||
if (PEAR::isError($res)) {
|
|
||||||
$this->view->message = $res->getMessage();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else {
|
//could throw a scheduled in future exception.
|
||||||
$res = settype($res, "integer");
|
catch (Exception $e) {
|
||||||
$data = array("filepath" => $file->getFilePath(), "delete" => $res);
|
$message = "Could not delete some scheduled files.";
|
||||||
Application_Model_RabbitMq::SendMessageToMediaMonitor("file_delete", $data);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->view->ids = $ids;
|
if (isset($message)) {
|
||||||
}
|
$this->view->message = $message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,13 +265,15 @@ class LibraryController extends Zend_Controller_Action
|
||||||
public function getUploadToSoundcloudStatusAction(){
|
public function getUploadToSoundcloudStatusAction(){
|
||||||
$id = $this->_getParam('id');
|
$id = $this->_getParam('id');
|
||||||
$type = $this->_getParam('type');
|
$type = $this->_getParam('type');
|
||||||
|
|
||||||
if ($type == "show") {
|
if ($type == "show") {
|
||||||
$show_instance = new Application_Model_ShowInstance($id);
|
$show_instance = new Application_Model_ShowInstance($id);
|
||||||
$this->view->sc_id = $show_instance->getSoundCloudFileId();
|
$this->view->sc_id = $show_instance->getSoundCloudFileId();
|
||||||
$file = $show_instance->getRecordedFile();
|
$file = $show_instance->getRecordedFile();
|
||||||
$this->view->error_code = $file->getSoundCloudErrorCode();
|
$this->view->error_code = $file->getSoundCloudErrorCode();
|
||||||
$this->view->error_msg = $file->getSoundCloudErrorMsg();
|
$this->view->error_msg = $file->getSoundCloudErrorMsg();
|
||||||
}else{
|
}
|
||||||
|
else if ($type == "file") {
|
||||||
$file = Application_Model_StoredFile::Recall($id);
|
$file = Application_Model_StoredFile::Recall($id);
|
||||||
$this->view->sc_id = $file->getSoundCloudId();
|
$this->view->sc_id = $file->getSoundCloudId();
|
||||||
$this->view->error_code = $file->getSoundCloudErrorCode();
|
$this->view->error_code = $file->getSoundCloudErrorCode();
|
||||||
|
|
|
@ -103,17 +103,18 @@ class PlaylistController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function editAction()
|
public function editAction()
|
||||||
{
|
{
|
||||||
$pl_id = $this->_getParam('id', null);
|
$id = $this->_getParam('id', null);
|
||||||
|
Logging::log("editing playlist {$id}");
|
||||||
|
|
||||||
if (!is_null($pl_id)) {
|
if (!is_null($id)) {
|
||||||
$this->changePlaylist($pl_id);
|
$this->changePlaylist($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$pl = $this->getPlaylist();
|
$pl = $this->getPlaylist();
|
||||||
}
|
}
|
||||||
catch (PlaylistNotFoundException $e) {
|
catch (PlaylistNotFoundException $e) {
|
||||||
Logging::log("Playlist {$pl_id} not found");
|
Logging::log("Playlist {$id} not found");
|
||||||
$this->changePlaylist(null);
|
$this->changePlaylist(null);
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
|
|
|
@ -227,30 +227,6 @@ class Application_Model_StoredFile {
|
||||||
return $md;
|
return $md;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete and insert media file
|
|
||||||
*
|
|
||||||
* @param string $p_localFilePath
|
|
||||||
* local path
|
|
||||||
* @return TRUE|PEAR_Error
|
|
||||||
*/
|
|
||||||
public function replaceFile($p_localFilePath, $p_copyMedia=TRUE)
|
|
||||||
{
|
|
||||||
// Dont do anything if the source and destination files are
|
|
||||||
// the same.
|
|
||||||
if ($this->name == $p_localFilePath) {
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->exists) {
|
|
||||||
$r = $this->deleteFile();
|
|
||||||
if (PEAR::isError($r)) {
|
|
||||||
return $r;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $this->addFile($p_localFilePath, $p_copyMedia);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set state of virtual file
|
* Set state of virtual file
|
||||||
*
|
*
|
||||||
|
@ -301,97 +277,27 @@ class Application_Model_StoredFile {
|
||||||
*
|
*
|
||||||
* @param boolean $p_deleteFile
|
* @param boolean $p_deleteFile
|
||||||
*
|
*
|
||||||
* @return void|PEAR_Error
|
|
||||||
*/
|
*/
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
if ($this->exists()) {
|
// Check if the file is scheduled to be played in the future
|
||||||
if ($this->getFormat() == 'audioclip') {
|
if (Application_Model_Schedule::IsFileScheduledInTheFuture($this->getId())) {
|
||||||
$res = $this->deleteFile();
|
throw new DeleteScheduledFileException();
|
||||||
if (PEAR::isError($res)) {
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't delete from the playslist. We might want to put a flag
|
$filepath = $this->getFilePath();
|
||||||
//Application_Model_Playlist::DeleteFileFromAllPlaylists($this->getId());
|
|
||||||
|
if (file_exists($filepath)) {
|
||||||
|
|
||||||
|
$data = array("filepath" => $filepath, "delete" => 1);
|
||||||
|
Application_Model_RabbitMq::SendMessageToMediaMonitor("file_delete", $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
Application_Model_Playlist::DeleteFileFromAllPlaylists($this->getId());
|
||||||
|
|
||||||
// set file_exists falg to false
|
// set file_exists falg to false
|
||||||
$this->_file->setDbFileExists(false);
|
$this->_file->setDbFileExists(false);
|
||||||
$this->_file->save();
|
$this->_file->save();
|
||||||
//$this->_file->delete();
|
|
||||||
|
|
||||||
if (isset($res)) {
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete media file from filesystem.
|
|
||||||
* You cant delete a file if it is being accessed.
|
|
||||||
* You cant delete a file if it is scheduled to be played in the future.
|
|
||||||
* The file will be removed from all playlists it is a part of.
|
|
||||||
*
|
|
||||||
* @return boolean|PEAR_Error
|
|
||||||
*/
|
|
||||||
public function deleteFile()
|
|
||||||
{
|
|
||||||
global $CC_CONFIG;
|
|
||||||
|
|
||||||
if ($this->isAccessed()) {
|
|
||||||
return PEAR::raiseError('Cannot delete a file that is currently accessed.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the file is scheduled to be played in the future
|
|
||||||
if (Application_Model_Schedule::IsFileScheduledInTheFuture($this->getId())) {
|
|
||||||
return PEAR::raiseError('Cannot delete a file that is scheduled in the future.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if media file exists
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function exists()
|
|
||||||
{
|
|
||||||
if ($this->_file->isDeleted()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ($this->getFormat() == 'audioclip') {
|
|
||||||
return $this->existsFile();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if raw media file exists
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function existsFile() {
|
|
||||||
|
|
||||||
$filepath = $this->getFilePath();
|
|
||||||
|
|
||||||
if (!isset($filepath) || !file_exists($filepath) || !is_readable($filepath)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if virtual file is currently in use.<br>
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function isAccessed()
|
|
||||||
{
|
|
||||||
return ($this->_file->getDbCurrentlyaccessing() > 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -824,7 +730,7 @@ class Application_Model_StoredFile {
|
||||||
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
|
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
|
||||||
}
|
}
|
||||||
|
|
||||||
Logging::log($sql);
|
//Logging::log($sql);
|
||||||
|
|
||||||
$results = $CC_DBC->getAll($sql);
|
$results = $CC_DBC->getAll($sql);
|
||||||
|
|
||||||
|
@ -1093,3 +999,4 @@ class Application_Model_StoredFile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class DeleteScheduledFileException extends Exception {}
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
function addRemove(el) {
|
|
||||||
var id, span;
|
|
||||||
|
|
||||||
id = $(el).attr("id").split("_").pop();
|
|
||||||
|
|
||||||
span = $('<a href="#" id="search_remove_'+id+'" class="ui-button ui-button-icon-only ui-widget ui-state-default"><span class="ui-icon ui-icon-closethick"></span><span class="ui-button-text">Remove</span></a>').click(function(){
|
|
||||||
$(this).parent().parent().remove();
|
|
||||||
});
|
|
||||||
|
|
||||||
$(el).find("dl input").after(span);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ajaxAddRow() {
|
|
||||||
var group_id;
|
|
||||||
|
|
||||||
group_id = $(this).parent().parent().attr("id").split("_").pop();
|
|
||||||
|
|
||||||
var url = '/Search/newfield/format/json';
|
|
||||||
|
|
||||||
$.post(url, {group: group_id}, function(json) {
|
|
||||||
|
|
||||||
var newRow = $(json.html).find("#fieldset-row_"+json.row);
|
|
||||||
addRemove(newRow);
|
|
||||||
|
|
||||||
$("#fieldset-group_"+group_id+" dl:first").append(newRow);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeGroup() {
|
|
||||||
$(this).parent().parent().remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
function ajaxAddGroup() {
|
|
||||||
|
|
||||||
var url = '/Search/newgroup/format/json';
|
|
||||||
|
|
||||||
$.post(url, function(json) {
|
|
||||||
|
|
||||||
var group = $(json.html);
|
|
||||||
addRemove(group);
|
|
||||||
group.find('[id$="search_add_row"]').click(ajaxAddRow);
|
|
||||||
group.find('[id$="search_remove_group"]').click(removeGroup);
|
|
||||||
$(".zend_form").append(group);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function advancedSearchSubmit() {
|
|
||||||
var data = $("#advancedSearch form").serializeArray();
|
|
||||||
|
|
||||||
$.post("/Search/index", {format: "json", data: data}, function(json){
|
|
||||||
var x;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
|
|
||||||
$("#search_add_group").click(ajaxAddGroup);
|
|
||||||
$("#search_submit").click(advancedSearchSubmit);
|
|
||||||
|
|
||||||
$('[id$="search_add_row"]').click(ajaxAddRow);
|
|
||||||
$('[id$="search_remove_group"]').click(removeGroup);
|
|
||||||
|
|
||||||
$('[id^="fieldset-row_"]').each(function(i, el){
|
|
||||||
addRemove(el);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,25 +1,27 @@
|
||||||
function fnLibraryTableRowCallback( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
|
var AIRTIME = (function(AIRTIME){
|
||||||
|
var mod;
|
||||||
|
|
||||||
$(nRow).attr("id", aData["tr_id"]);
|
if (AIRTIME.library === undefined) {
|
||||||
$(nRow).data("aData", aData);
|
AIRTIME.library = {}
|
||||||
|
|
||||||
//var oTT = TableTools.fnGetInstance('library_display');
|
|
||||||
//oTT.fnSelect(el);
|
|
||||||
|
|
||||||
/*
|
|
||||||
$(nRow).find('td')
|
|
||||||
.jjmenu("rightClick",
|
|
||||||
[{get:"/Library/context-menu/format/json/id/#id#/type/#type#"}],
|
|
||||||
{id: aData["id"], type: aData["ftype"]},
|
|
||||||
{xposition: "mouse", yposition: "mouse"});
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fnLibraryTableDrawCallback() {
|
AIRTIME.library.events = {};
|
||||||
|
mod = AIRTIME.library.events;
|
||||||
|
|
||||||
|
mod.fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
|
||||||
|
var $nRow = $(nRow);
|
||||||
|
|
||||||
|
$nRow.attr("id", aData["tr_id"])
|
||||||
|
.data("aData", aData)
|
||||||
|
.data("screen", "playlist");
|
||||||
|
}
|
||||||
|
|
||||||
|
mod.fnDrawCallback = function() {
|
||||||
|
|
||||||
$('#library_display tr[id ^= "au"]').draggable({
|
$('#library_display tr[id ^= "au"]').draggable({
|
||||||
helper: 'clone',
|
helper: 'clone',
|
||||||
/*
|
/* customize the helper on dragging to look like a pl item
|
||||||
|
*
|
||||||
helper: function(ev) {
|
helper: function(ev) {
|
||||||
var data, li;
|
var data, li;
|
||||||
|
|
||||||
|
@ -39,9 +41,8 @@ function fnLibraryTableDrawCallback() {
|
||||||
/*
|
/*
|
||||||
* @param oTable the datatables instance for the library.
|
* @param oTable the datatables instance for the library.
|
||||||
*/
|
*/
|
||||||
function setupLibraryToolbar(oLibTable) {
|
mod.setupLibraryToolbar = function( oLibTable ) {
|
||||||
var aButtons,
|
var aButtons,
|
||||||
oLibTT = TableTools.fnGetInstance('library_display'),
|
|
||||||
fnResetCol;
|
fnResetCol;
|
||||||
|
|
||||||
fnResetCol = function () {
|
fnResetCol = function () {
|
||||||
|
@ -59,3 +60,8 @@ function setupLibraryToolbar(oLibTable) {
|
||||||
|
|
||||||
addToolBarButtonsLibrary(aButtons);
|
addToolBarButtonsLibrary(aButtons);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return AIRTIME;
|
||||||
|
|
||||||
|
}(AIRTIME || {}));
|
||||||
|
|
|
@ -1,14 +1,22 @@
|
||||||
function fnLibraryTableRowCallback( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
|
var AIRTIME = (function(AIRTIME){
|
||||||
var jRow = $(nRow);
|
var mod;
|
||||||
|
|
||||||
jRow.attr("id", aData["tr_id"]);
|
if (AIRTIME.library === undefined) {
|
||||||
jRow.addClass("lib-sb");
|
AIRTIME.library = {}
|
||||||
|
|
||||||
//save some info for reordering purposes.
|
|
||||||
jRow.data({"aData": aData});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fnLibraryTableDrawCallback() {
|
AIRTIME.library.events = {};
|
||||||
|
mod = AIRTIME.library.events;
|
||||||
|
|
||||||
|
mod.fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
|
||||||
|
var $nRow = $(nRow);
|
||||||
|
|
||||||
|
$nRow.attr("id", aData["tr_id"])
|
||||||
|
.data("aData", aData)
|
||||||
|
.data("screen", "timeline");
|
||||||
|
}
|
||||||
|
|
||||||
|
mod.fnDrawCallback = function() {
|
||||||
|
|
||||||
$('#library_display tr:not(:first)').draggable({
|
$('#library_display tr:not(:first)').draggable({
|
||||||
helper: 'clone',
|
helper: 'clone',
|
||||||
|
@ -17,14 +25,11 @@ function fnLibraryTableDrawCallback() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupLibraryToolbar(oLibTable) {
|
mod.setupLibraryToolbar = function(oLibTable) {
|
||||||
var aButtons,
|
var aButtons,
|
||||||
fnTest,
|
fnTest,
|
||||||
fnResetCol,
|
fnResetCol,
|
||||||
fnAddSelectedItems,
|
fnAddSelectedItems,
|
||||||
oSchedTable = $("#show_builder_table").dataTable(),
|
|
||||||
oLibTT = TableTools.fnGetInstance('library_display'),
|
|
||||||
oSchedTT = TableTools.fnGetInstance('show_builder_table');
|
|
||||||
|
|
||||||
fnTest = function() {
|
fnTest = function() {
|
||||||
alert("hi");
|
alert("hi");
|
||||||
|
@ -40,7 +45,10 @@ function setupLibraryToolbar(oLibTable) {
|
||||||
item,
|
item,
|
||||||
temp,
|
temp,
|
||||||
aMediaIds = [],
|
aMediaIds = [],
|
||||||
aSchedIds = [];
|
aSchedIds = [],
|
||||||
|
oSchedTable = $("#show_builder_table").dataTable(),
|
||||||
|
oLibTT = TableTools.fnGetInstance('library_display'),
|
||||||
|
oSchedTT = TableTools.fnGetInstance('show_builder_table');;
|
||||||
|
|
||||||
//process selected files/playlists.
|
//process selected files/playlists.
|
||||||
for (item in aData) {
|
for (item in aData) {
|
||||||
|
@ -78,3 +86,7 @@ function setupLibraryToolbar(oLibTable) {
|
||||||
|
|
||||||
addToolBarButtonsLibrary(aButtons);
|
addToolBarButtonsLibrary(aButtons);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return AIRTIME;
|
||||||
|
|
||||||
|
}(AIRTIME || {}));
|
|
@ -37,39 +37,6 @@ function disableGroupBtn(btnId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteItem(type, id) {
|
|
||||||
var tr_id, tr, dt;
|
|
||||||
|
|
||||||
tr_id = type+"_"+id;
|
|
||||||
tr = $("#"+tr_id);
|
|
||||||
|
|
||||||
dt = $("#library_display").dataTable();
|
|
||||||
dt.fnDeleteRow( tr );
|
|
||||||
}
|
|
||||||
|
|
||||||
function deleteAudioClip(json) {
|
|
||||||
if(json.message) {
|
|
||||||
alert(json.message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (json.ids != undefined) {
|
|
||||||
for (var i = json.ids.length - 1; i >= 0; i--) {
|
|
||||||
deleteItem("au", json.ids[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (json.id != undefined) {
|
|
||||||
deleteItem("au", json.id);
|
|
||||||
}
|
|
||||||
location.reload(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function confirmDeleteGroup() {
|
|
||||||
if(confirm('Are you sure you want to delete the selected items?')){
|
|
||||||
groupDelete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkImportStatus(){
|
function checkImportStatus(){
|
||||||
$.getJSON('/Preference/is-import-in-progress', function(data){
|
$.getJSON('/Preference/is-import-in-progress', function(data){
|
||||||
var div = $('#import_status');
|
var div = $('#import_status');
|
||||||
|
@ -81,40 +48,41 @@ function checkImportStatus(){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deletePlaylist(json) {
|
|
||||||
if(json.message) {
|
|
||||||
alert(json.message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (json.ids != undefined) {
|
|
||||||
for (var i = json.ids.length - 1; i >= 0; i--) {
|
|
||||||
deleteItem("pl", json.ids[i]);
|
|
||||||
}
|
|
||||||
} else if (json.id != undefined) {
|
|
||||||
deleteItem("pl", json.id);
|
|
||||||
}
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
function addProgressIcon(id) {
|
function addProgressIcon(id) {
|
||||||
if($("#au_"+id).find("td.library_title").find("span").length > 0){
|
var tr = $("#au_"+id),
|
||||||
$("#au_"+id).find("td.library_title").find("span").removeClass();
|
span;
|
||||||
$("span[id="+id+"]").addClass("small-icon progress");
|
|
||||||
}else{
|
span = tr.find("td.library_title").find("span");
|
||||||
$("#au_"+id).find("td.library_title").append('<span id="'+id+'" class="small-icon progress"></span>');
|
|
||||||
|
if (span.length > 0){
|
||||||
|
span.removeClass()
|
||||||
|
.addClass("small-icon progress");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
tr.find("td.library_title")
|
||||||
|
.append('<span class="small-icon progress"></span>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkSCUploadStatus(){
|
function checkSCUploadStatus(){
|
||||||
var url = '/Library/get-upload-to-soundcloud-status/format/json';
|
|
||||||
|
var url = '/Library/get-upload-to-soundcloud-status';
|
||||||
|
|
||||||
$("span[class*=progress]").each(function(){
|
$("span[class*=progress]").each(function(){
|
||||||
var id = $(this).attr("id");
|
var span, id;
|
||||||
|
|
||||||
|
span = $(this);
|
||||||
|
id = span.parentsUntil('tr').attr("id").split("_").pop();
|
||||||
|
|
||||||
$.post(url, {format: "json", id: id, type:"file"}, function(json){
|
$.post(url, {format: "json", id: id, type:"file"}, function(json){
|
||||||
if (json.sc_id > 0) {
|
if (json.sc_id > 0) {
|
||||||
$("span[id="+id+"]").removeClass("progress").addClass("soundcloud");
|
span.removeClass("progress")
|
||||||
}else if(json.sc_id == "-3"){
|
.addClass("soundcloud");
|
||||||
$("span[id="+id+"]").removeClass("progress").addClass("sc-error");
|
|
||||||
|
}
|
||||||
|
else if (json.sc_id == "-3") {
|
||||||
|
span.removeClass("progress")
|
||||||
|
.addClass("sc-error");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -280,10 +248,9 @@ function createDataTable(data) {
|
||||||
"success": testCallback
|
"success": testCallback
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
"fnRowCallback": fnLibraryTableRowCallback,
|
"fnRowCallback": AIRTIME.library.events.fnRowCallback,
|
||||||
"fnCreatedRow": fnCreatedRow,
|
"fnCreatedRow": fnCreatedRow,
|
||||||
"fnCreatedRowCallback": fnCreatedRow,
|
"fnDrawCallback": AIRTIME.library.events.fnDrawCallback,
|
||||||
"fnDrawCallback": fnLibraryTableDrawCallback,
|
|
||||||
"fnHeaderCallback": function(nHead) {
|
"fnHeaderCallback": function(nHead) {
|
||||||
$(nHead).find("input[type=checkbox]").attr("checked", false);
|
$(nHead).find("input[type=checkbox]").attr("checked", false);
|
||||||
},
|
},
|
||||||
|
@ -353,7 +320,7 @@ function createDataTable(data) {
|
||||||
});
|
});
|
||||||
oTable.fnSetFilteringDelay(350);
|
oTable.fnSetFilteringDelay(350);
|
||||||
|
|
||||||
setupLibraryToolbar(oTable);
|
AIRTIME.library.events.setupLibraryToolbar(oTable);
|
||||||
|
|
||||||
$('[name="pl_cb_all"]').click(function(){
|
$('[name="pl_cb_all"]').click(function(){
|
||||||
var oTT = TableTools.fnGetInstance('library_display');
|
var oTT = TableTools.fnGetInstance('library_display');
|
||||||
|
@ -385,9 +352,11 @@ $(document).ready(function() {
|
||||||
ignoreRightClick: true,
|
ignoreRightClick: true,
|
||||||
|
|
||||||
build: function($el, e) {
|
build: function($el, e) {
|
||||||
var x, request, data, items, callback;
|
var x, request, data, screen, items, callback, $tr;
|
||||||
|
|
||||||
data = $el.parent().data("aData");
|
$tr = $el.parent();
|
||||||
|
data = $tr.data("aData");
|
||||||
|
screen = $tr.data("screen");
|
||||||
|
|
||||||
function processMenuItems(oItems) {
|
function processMenuItems(oItems) {
|
||||||
|
|
||||||
|
@ -400,11 +369,46 @@ $(document).ready(function() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
callback = function() {
|
||||||
|
AIRTIME.playlist.fnEdit(data.id);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
oItems.edit.callback = callback;
|
oItems.edit.callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//define a delete callback.
|
||||||
|
if (oItems.del !== undefined) {
|
||||||
|
|
||||||
|
//delete through the playlist controller, will reset
|
||||||
|
//playlist screen if this is the currently edited playlist.
|
||||||
|
if (data.ftype === "playlist" && screen === "playlist") {
|
||||||
|
callback = function() {
|
||||||
|
|
||||||
|
if (confirm('Are you sure you want to delete the selected item?')) {
|
||||||
|
AIRTIME.playlist.fnDelete(data.id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
callback = function() {
|
||||||
|
var media = [];
|
||||||
|
|
||||||
|
if (confirm('Are you sure you want to delete the selected item?')) {
|
||||||
|
|
||||||
|
media.push({"id": data.id, "type": data.ftype});
|
||||||
|
$.post(oItems.del.url, {format: "json", media: media }, function(json){
|
||||||
|
var oTable, tr;
|
||||||
|
|
||||||
|
oTable = $("#library_display").dataTable();
|
||||||
|
oTable.fnDeleteRow( $tr[0] );
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
oItems.del.callback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
//define a download callback.
|
//define a download callback.
|
||||||
if (oItems.download !== undefined) {
|
if (oItems.download !== undefined) {
|
||||||
|
|
||||||
|
@ -444,7 +448,7 @@ $(document).ready(function() {
|
||||||
request = $.ajax({
|
request = $.ajax({
|
||||||
url: "/library/context-menu",
|
url: "/library/context-menu",
|
||||||
type: "GET",
|
type: "GET",
|
||||||
data: {id : data.id, type: data.ftype, format: "json"},
|
data: {id : data.id, type: data.ftype, format: "json", "screen": screen},
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
async: false,
|
async: false,
|
||||||
success: function(json){
|
success: function(json){
|
||||||
|
@ -452,16 +456,7 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// this callback is executed every time the menu is to be shown
|
|
||||||
// its results are destroyed every time the menu is hidden
|
|
||||||
// e is the original contextmenu event, containing e.pageX and e.pageY (amongst other data)
|
|
||||||
return {
|
return {
|
||||||
callback: function(key, options) {
|
|
||||||
var m = "clicked: " + key;
|
|
||||||
window.console && console.log(m) || alert(m);
|
|
||||||
},
|
|
||||||
items: items,
|
items: items,
|
||||||
determinePosition : function($menu, x, y) {
|
determinePosition : function($menu, x, y) {
|
||||||
$menu.css('display', 'block')
|
$menu.css('display', 'block')
|
||||||
|
|
|
@ -538,15 +538,26 @@ var AIRTIME = (function(AIRTIME){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
mod.fnEdit = function() {
|
mod.fnEdit = function(id) {
|
||||||
|
var url;
|
||||||
|
|
||||||
|
stopAudioPreview();
|
||||||
|
|
||||||
|
url = '/Playlist/edit';
|
||||||
|
|
||||||
|
$.post(url,
|
||||||
|
{format: "json", id: id},
|
||||||
|
function(json){
|
||||||
|
openPlaylist(json);
|
||||||
|
//redrawLib();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
mod.fnDelete = function() {
|
mod.fnDelete = function(plid) {
|
||||||
var url, id, lastMod;
|
var url, id, lastMod;
|
||||||
|
|
||||||
stopAudioPreview();
|
stopAudioPreview();
|
||||||
id = getId();
|
id = (plid === undefined) ? getId() : plid;
|
||||||
lastMod = getModified();
|
lastMod = getModified();
|
||||||
url = '/Playlist/delete';
|
url = '/Playlist/delete';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue