CC-3174 : showbuilder

making library table only scroll on the table part.
This commit is contained in:
Naomi Aro 2012-03-07 18:27:32 +01:00
parent e9627bca07
commit fe3c340a90
6 changed files with 59 additions and 44 deletions

View File

@ -395,7 +395,7 @@ class Application_Model_StoredFile {
} }
private function constructGetFileUrl($p_serverName, $p_serverPort){ private function constructGetFileUrl($p_serverName, $p_serverPort){
Logging::log("getting media! - 2"); Logging::log("getting media! - 2");
return "http://$p_serverName:$p_serverPort/api/get-media/file/".$this->getGunId().".".$this->getFileExtension(); return "http://$p_serverName:$p_serverPort/api/get-media/file/".$this->getGunId().".".$this->getFileExtension();
} }
@ -660,7 +660,7 @@ Logging::log("getting media! - 2");
if($type == "au"){//&& isset( $audioResults )) { if($type == "au"){//&& isset( $audioResults )) {
$row['audioFile'] = $row['gunid'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION); $row['audioFile'] = $row['gunid'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION);
$row['image'] = '<div class="big_play"><img src="/css/images/icon_audioclip.png"></div>'; $row['image'] = '<img src="/css/images/icon_audioclip.png">';
} }
else { else {
$row['image'] = '<img src="/css/images/icon_playlist.png">'; $row['image'] = '<img src="/css/images/icon_playlist.png">';
@ -669,22 +669,22 @@ Logging::log("getting media! - 2");
return $results; return $results;
} }
public static function searchFiles($displayColumns, $fromTable, $data) public static function searchFiles($displayColumns, $fromTable, $data)
{ {
$con = Propel::getConnection(CcFilesPeer::DATABASE_NAME); $con = Propel::getConnection(CcFilesPeer::DATABASE_NAME);
$where = array(); $where = array();
if ($data["sSearch"] !== "") { if ($data["sSearch"] !== "") {
$searchTerms = explode(" ", $data["sSearch"]); $searchTerms = explode(" ", $data["sSearch"]);
} }
$selectorCount = "SELECT COUNT(*) "; $selectorCount = "SELECT COUNT(*) ";
$selectorRows = "SELECT ".join(",", $displayColumns)." "; $selectorRows = "SELECT ".join(",", $displayColumns)." ";
$sql = $selectorCount." FROM ".$fromTable; $sql = $selectorCount." FROM ".$fromTable;
$sqlTotalRows = $sql; $sqlTotalRows = $sql;
if (isset($searchTerms)) { if (isset($searchTerms)) {
$searchCols = array(); $searchCols = array();
for ($i = 0; $i < $data["iColumns"]; $i++) { for ($i = 0; $i < $data["iColumns"]; $i++) {
@ -692,12 +692,12 @@ Logging::log("getting media! - 2");
$searchCols[] = $data["mDataProp_{$i}"]; $searchCols[] = $data["mDataProp_{$i}"];
} }
} }
$outerCond = array(); $outerCond = array();
foreach ($searchTerms as $term) { foreach ($searchTerms as $term) {
$innerCond = array(); $innerCond = array();
foreach ($searchCols as $col) { foreach ($searchCols as $col) {
$escapedTerm = pg_escape_string($term); $escapedTerm = pg_escape_string($term);
$innerCond[] = "{$col}::text ILIKE '%{$escapedTerm}%'"; $innerCond[] = "{$col}::text ILIKE '%{$escapedTerm}%'";
@ -707,7 +707,7 @@ Logging::log("getting media! - 2");
$where[] = "(".join(" AND ", $outerCond).")"; $where[] = "(".join(" AND ", $outerCond).")";
} }
// End Where clause // End Where clause
// Order By clause // Order By clause
$orderby = array(); $orderby = array();
for ($i = 0; $i < $data["iSortingCols"]; $i++){ for ($i = 0; $i < $data["iSortingCols"]; $i++){
@ -717,22 +717,22 @@ Logging::log("getting media! - 2");
$orderby[] = "id"; $orderby[] = "id";
$orderby = join("," , $orderby); $orderby = join("," , $orderby);
// End Order By clause // End Order By clause
if (count($where) > 0) { if (count($where) > 0) {
$where = join(" AND ", $where); $where = join(" AND ", $where);
$sql = $selectorCount." FROM ".$fromTable." WHERE ".$where; $sql = $selectorCount." FROM ".$fromTable." WHERE ".$where;
$sqlTotalDisplayRows = $sql; $sqlTotalDisplayRows = $sql;
$sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"]; $sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
} }
else { else {
$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"];
} }
try { try {
$r = $con->query($sqlTotalRows); $r = $con->query($sqlTotalRows);
$totalRows = $r->fetchColumn(0); $totalRows = $r->fetchColumn(0);
if (isset($sqlTotalDisplayRows)) { if (isset($sqlTotalDisplayRows)) {
$r = $con->query($sqlTotalDisplayRows); $r = $con->query($sqlTotalDisplayRows);
$totalDisplayRows = $r->fetchColumn(0); $totalDisplayRows = $r->fetchColumn(0);
@ -740,7 +740,7 @@ Logging::log("getting media! - 2");
else { else {
$totalDisplayRows = $totalRows; $totalDisplayRows = $totalRows;
} }
$r = $con->query($sql); $r = $con->query($sql);
$r->setFetchMode(PDO::FETCH_ASSOC); $r->setFetchMode(PDO::FETCH_ASSOC);
$results = $r->fetchAll(); $results = $r->fetchAll();
@ -748,10 +748,10 @@ Logging::log("getting media! - 2");
catch (Exception $e) { catch (Exception $e) {
Logging::log($e->getMessage()); Logging::log($e->getMessage());
} }
//display sql executed in airtime log for testing //display sql executed in airtime log for testing
Logging::log($sql); Logging::log($sql);
return array("sEcho" => intval($data["sEcho"]), "iTotalDisplayRecords" => $totalDisplayRows, "iTotalRecords" => $totalRows, "aaData" => $results); return array("sEcho" => intval($data["sEcho"]), "iTotalDisplayRecords" => $totalDisplayRows, "iTotalRecords" => $totalRows, "aaData" => $results);
} }
@ -764,15 +764,15 @@ Logging::log("getting media! - 2");
header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false); header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); header("Pragma: no-cache");
// Settings // Settings
$cleanupTargetDir = false; // Remove old files $cleanupTargetDir = false; // Remove old files
$maxFileAge = 60 * 60; // Temp file age in seconds $maxFileAge = 60 * 60; // Temp file age in seconds
// 5 minutes execution time // 5 minutes execution time
@set_time_limit(5 * 60); @set_time_limit(5 * 60);
// usleep(5000); // usleep(5000);
// Get parameters // Get parameters
$chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0; $chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0;
$chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0; $chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0;
@ -781,29 +781,29 @@ Logging::log("getting media! - 2");
// Clean the fileName for security reasons // Clean the fileName for security reasons
//this needs fixing for songs not in ascii. //this needs fixing for songs not in ascii.
//$fileName = preg_replace('/[^\w\._]+/', '', $fileName); //$fileName = preg_replace('/[^\w\._]+/', '', $fileName);
// Create target dir // Create target dir
if (!file_exists($p_targetDir)) if (!file_exists($p_targetDir))
@mkdir($p_targetDir); @mkdir($p_targetDir);
// Remove old temp files // Remove old temp files
if (is_dir($p_targetDir) && ($dir = opendir($p_targetDir))) { if (is_dir($p_targetDir) && ($dir = opendir($p_targetDir))) {
while (($file = readdir($dir)) !== false) { while (($file = readdir($dir)) !== false) {
$filePath = $p_targetDir . DIRECTORY_SEPARATOR . $file; $filePath = $p_targetDir . DIRECTORY_SEPARATOR . $file;
// Remove temp files if they are older than the max age // Remove temp files if they are older than the max age
if (preg_match('/\.tmp$/', $file) && (filemtime($filePath) < time() - $maxFileAge)) if (preg_match('/\.tmp$/', $file) && (filemtime($filePath) < time() - $maxFileAge))
@unlink($filePath); @unlink($filePath);
} }
closedir($dir); closedir($dir);
} else } else
die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}'); die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
// Look for the content type header // Look for the content type header
if (isset($_SERVER["HTTP_CONTENT_TYPE"])) if (isset($_SERVER["HTTP_CONTENT_TYPE"]))
$contentType = $_SERVER["HTTP_CONTENT_TYPE"]; $contentType = $_SERVER["HTTP_CONTENT_TYPE"];
if (isset($_SERVER["CONTENT_TYPE"])) if (isset($_SERVER["CONTENT_TYPE"]))
$contentType = $_SERVER["CONTENT_TYPE"]; $contentType = $_SERVER["CONTENT_TYPE"];
@ -819,13 +819,13 @@ Logging::log("getting media! - 2");
if ($out) { if ($out) {
// Read binary input stream and append it to temp file // Read binary input stream and append it to temp file
$in = fopen($_FILES['file']['tmp_name'], "rb"); $in = fopen($_FILES['file']['tmp_name'], "rb");
if ($in) { if ($in) {
while ($buff = fread($in, 4096)) while ($buff = fread($in, 4096))
fwrite($out, $buff); fwrite($out, $buff);
} else } else
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}'); die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
fclose($out); fclose($out);
unlink($_FILES['file']['tmp_name']); unlink($_FILES['file']['tmp_name']);
} else } else
@ -838,18 +838,18 @@ Logging::log("getting media! - 2");
if ($out) { if ($out) {
// Read binary input stream and append it to temp file // Read binary input stream and append it to temp file
$in = fopen("php://input", "rb"); $in = fopen("php://input", "rb");
if ($in) { if ($in) {
while ($buff = fread($in, 4096)) while ($buff = fread($in, 4096))
fwrite($out, $buff); fwrite($out, $buff);
} else } else
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}'); die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
fclose($out); fclose($out);
} else } else
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}'); die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
} }
return $tempFilePath; return $tempFilePath;
} }
@ -899,7 +899,7 @@ Logging::log("getting media! - 2");
Logging::log("copyFileToStor: moving file $audio_file to $audio_stor"); Logging::log("copyFileToStor: moving file $audio_file to $audio_stor");
//Martin K.: changed to rename: Much less load + quicker since this is an atomic operation //Martin K.: changed to rename: Much less load + quicker since this is an atomic operation
$r = @rename($audio_file, $audio_stor); $r = @rename($audio_file, $audio_stor);
if ($r === false) { if ($r === false) {
#something went wrong likely there wasn't enough space in the audio_stor to move the file too. #something went wrong likely there wasn't enough space in the audio_stor to move the file too.
#warn the user that the file wasn't uploaded and they should check if there is enough disk space. #warn the user that the file wasn't uploaded and they should check if there is enough disk space.

View File

@ -1,7 +1,7 @@
#library_content { #library_content {
float: left; float: left;
width: 50%; width: 50%;
overflow: auto; overflow: hidden;
} }
#library_display { #library_display {
@ -84,5 +84,4 @@ td.library_track,
td.library_sr, td.library_sr,
td.library_bitrate { td.library_bitrate {
text-align: right; text-align: right;
padding-right: 1em !important;
} }

View File

@ -554,6 +554,14 @@ dl.inline-list dd {
border-width: 0px 1px 0 1px; border-width: 0px 1px 0 1px;
} }
.dataTables_scrolling {
overflow: auto;
}
.dataTables_scrolling table{
border-width: 0px 1px 0 1px;
}
.DataTables_sort_wrapper .ui-icon { .DataTables_sort_wrapper .ui-icon {
display: block; display: block;
float: left; float: left;
@ -611,6 +619,7 @@ dl.inline-list dd {
.dataTables_paginate { .dataTables_paginate {
float: right; float: right;
padding: 8px 0 8px 8px; padding: 8px 0 8px 8px;
clear: left;
} }
.dataTables_paginate .ui-button { .dataTables_paginate .ui-button {
font-size:12px; font-size:12px;

View File

@ -42,14 +42,17 @@ var AIRTIME = (function(AIRTIME) {
}; };
libraryInit = function() { libraryInit = function() {
var oTable; var oTable,
libContentDiv = $("#library_content");
tableHeight = libContentDiv.height() - 140;
oTable = $('#library_display').dataTable( { oTable = $('#library_display').dataTable( {
//put hidden columns at the top to insure they can never be visible on the table through column reordering.
"aoColumns": [ "aoColumns": [
/* Checkbox */ {"sTitle": "<input type='checkbox' name='pl_cb_all'>", "mDataProp": "checkbox", "bSortable": false, "bSearchable": false, "sWidth": "25px", "sClass": "library_checkbox"},
/* Type */ {"sTitle": "", "mDataProp": "image", "bSearchable": false, "sWidth": "25px", "sClass": "library_type", "iDataSort": 2},
/* ftype */ {"sTitle": "", "mDataProp": "ftype", "bSearchable": false, "bVisible": false}, /* ftype */ {"sTitle": "", "mDataProp": "ftype", "bSearchable": false, "bVisible": false},
/* Checkbox */ {"sTitle": "<input type='checkbox' name='pl_cb_all'>", "mDataProp": "checkbox", "bSortable": false, "bSearchable": false, "sWidth": "25px", "sClass": "library_checkbox"},
/* Type */ {"sTitle": "", "mDataProp": "image", "bSearchable": false, "sWidth": "25px", "sClass": "library_type", "iDataSort": 0},
/* Title */ {"sTitle": "Title", "mDataProp": "track_title", "sClass": "library_title"}, /* Title */ {"sTitle": "Title", "mDataProp": "track_title", "sClass": "library_title"},
/* Creator */ {"sTitle": "Creator", "mDataProp": "artist_name", "sClass": "library_creator"}, /* Creator */ {"sTitle": "Creator", "mDataProp": "artist_name", "sClass": "library_creator"},
/* Album */ {"sTitle": "Album", "mDataProp": "album_title", "sClass": "library_album"}, /* Album */ {"sTitle": "Album", "mDataProp": "album_title", "sClass": "library_album"},
@ -227,9 +230,9 @@ var AIRTIME = (function(AIRTIME) {
"oLanguage": { "oLanguage": {
"sSearch": "" "sSearch": ""
}, },
// R = ColReorder, C = ColVis, T = TableTools // R = ColReorder, C = ColVis, T = TableTools
"sDom": 'Rl<"#library_display_type">fr<"H"T<"library_toolbar"C>>t<"F"ip>', "sDom": 'Rl<"#library_display_type">fr<"H"T<"library_toolbar"C>><"dataTables_scrolling"t><"F"ip>',
"oTableTools": { "oTableTools": {
"sRowSelect": "multi", "sRowSelect": "multi",
@ -285,6 +288,8 @@ var AIRTIME = (function(AIRTIME) {
}); });
oTable.fnSetFilteringDelay(350); oTable.fnSetFilteringDelay(350);
libContentDiv.find(".dataTables_scrolling").css("max-height", tableHeight);
AIRTIME.library.events.setupLibraryToolbar(oTable); AIRTIME.library.events.setupLibraryToolbar(oTable);

View File

@ -105,7 +105,8 @@ var AIRTIME = (function(AIRTIME){
mod.builderDataTable = function() { mod.builderDataTable = function() {
var tableDiv = $('#show_builder_table'), var tableDiv = $('#show_builder_table'),
oTable, oTable,
fnRemoveSelectedItems; fnRemoveSelectedItems,
tableHeight;
fnRemoveSelectedItems = function() { fnRemoveSelectedItems = function() {
var oTT = TableTools.fnGetInstance('show_builder_table'), var oTT = TableTools.fnGetInstance('show_builder_table'),
@ -405,7 +406,7 @@ var AIRTIME = (function(AIRTIME){
}, },
// R = ColReorderResize, C = ColVis, T = TableTools // R = ColReorderResize, C = ColVis, T = TableTools
"sDom": 'Rr<"H"CT>t<"F">', "sDom": 'Rr<"H"CT>t',
"sAjaxDataProp": "schedule", "sAjaxDataProp": "schedule",
"sAjaxSource": "/showbuilder/builder-feed" "sAjaxSource": "/showbuilder/builder-feed"

View File

@ -135,7 +135,8 @@ $(document).ready(function(){
var $button = $(this), var $button = $(this),
$lib = $("#library_content"), $lib = $("#library_content"),
$builder = $("#show_builder"), $builder = $("#show_builder"),
oTable = $("#show_builder_table").dataTable(); schedTable = $("#show_builder_table").dataTable(),
libTable = $lib.find("#library_display").dataTable();
if ($button.hasClass("sb-edit")) { if ($button.hasClass("sb-edit")) {
@ -160,7 +161,7 @@ $(document).ready(function(){
$button.val("Add Files"); $button.val("Add Files");
} }
oTable.fnDraw(); schedTable.fnDraw();
}); });
oRange = fnGetScheduleRange(); oRange = fnGetScheduleRange();