From fe3c340a90ded23a81731dfdc56009c18adc67a4 Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Wed, 7 Mar 2012 18:27:32 +0100 Subject: [PATCH] CC-3174 : showbuilder making library table only scroll on the table part. --- airtime_mvc/application/models/StoredFile.php | 66 +++++++++---------- airtime_mvc/public/css/media_library.css | 3 +- airtime_mvc/public/css/styles.css | 9 +++ .../public/js/airtime/library/library.js | 15 +++-- .../public/js/airtime/showbuilder/builder.js | 5 +- .../js/airtime/showbuilder/main_builder.js | 5 +- 6 files changed, 59 insertions(+), 44 deletions(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 9dfd99e46..9615875f6 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -395,7 +395,7 @@ class Application_Model_StoredFile { } 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(); } @@ -660,7 +660,7 @@ Logging::log("getting media! - 2"); if($type == "au"){//&& isset( $audioResults )) { $row['audioFile'] = $row['gunid'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION); - $row['image'] = '
'; + $row['image'] = ''; } else { $row['image'] = ''; @@ -669,22 +669,22 @@ Logging::log("getting media! - 2"); return $results; } - + public static function searchFiles($displayColumns, $fromTable, $data) { $con = Propel::getConnection(CcFilesPeer::DATABASE_NAME); $where = array(); - + if ($data["sSearch"] !== "") { $searchTerms = explode(" ", $data["sSearch"]); } - + $selectorCount = "SELECT COUNT(*) "; $selectorRows = "SELECT ".join(",", $displayColumns)." "; - + $sql = $selectorCount." FROM ".$fromTable; $sqlTotalRows = $sql; - + if (isset($searchTerms)) { $searchCols = array(); for ($i = 0; $i < $data["iColumns"]; $i++) { @@ -692,12 +692,12 @@ Logging::log("getting media! - 2"); $searchCols[] = $data["mDataProp_{$i}"]; } } - + $outerCond = array(); - + foreach ($searchTerms as $term) { $innerCond = array(); - + foreach ($searchCols as $col) { $escapedTerm = pg_escape_string($term); $innerCond[] = "{$col}::text ILIKE '%{$escapedTerm}%'"; @@ -707,7 +707,7 @@ Logging::log("getting media! - 2"); $where[] = "(".join(" AND ", $outerCond).")"; } // End Where clause - + // Order By clause $orderby = array(); for ($i = 0; $i < $data["iSortingCols"]; $i++){ @@ -717,22 +717,22 @@ Logging::log("getting media! - 2"); $orderby[] = "id"; $orderby = join("," , $orderby); // End Order By clause - + if (count($where) > 0) { $where = join(" AND ", $where); $sql = $selectorCount." FROM ".$fromTable." WHERE ".$where; $sqlTotalDisplayRows = $sql; - + $sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"]; } else { $sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"]; } - + try { $r = $con->query($sqlTotalRows); $totalRows = $r->fetchColumn(0); - + if (isset($sqlTotalDisplayRows)) { $r = $con->query($sqlTotalDisplayRows); $totalDisplayRows = $r->fetchColumn(0); @@ -740,7 +740,7 @@ Logging::log("getting media! - 2"); else { $totalDisplayRows = $totalRows; } - + $r = $con->query($sql); $r->setFetchMode(PDO::FETCH_ASSOC); $results = $r->fetchAll(); @@ -748,10 +748,10 @@ Logging::log("getting media! - 2"); catch (Exception $e) { Logging::log($e->getMessage()); } - + //display sql executed in airtime log for testing Logging::log($sql); - + 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: post-check=0, pre-check=0", false); header("Pragma: no-cache"); - + // Settings $cleanupTargetDir = false; // Remove old files $maxFileAge = 60 * 60; // Temp file age in seconds - + // 5 minutes execution time @set_time_limit(5 * 60); // usleep(5000); - + // Get parameters $chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0; $chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0; @@ -781,29 +781,29 @@ Logging::log("getting media! - 2"); // Clean the fileName for security reasons //this needs fixing for songs not in ascii. //$fileName = preg_replace('/[^\w\._]+/', '', $fileName); - + // Create target dir if (!file_exists($p_targetDir)) @mkdir($p_targetDir); - + // Remove old temp files if (is_dir($p_targetDir) && ($dir = opendir($p_targetDir))) { while (($file = readdir($dir)) !== false) { $filePath = $p_targetDir . DIRECTORY_SEPARATOR . $file; - + // Remove temp files if they are older than the max age if (preg_match('/\.tmp$/', $file) && (filemtime($filePath) < time() - $maxFileAge)) @unlink($filePath); } - + closedir($dir); } else die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}'); - + // Look for the content type header if (isset($_SERVER["HTTP_CONTENT_TYPE"])) $contentType = $_SERVER["HTTP_CONTENT_TYPE"]; - + if (isset($_SERVER["CONTENT_TYPE"])) $contentType = $_SERVER["CONTENT_TYPE"]; @@ -819,13 +819,13 @@ Logging::log("getting media! - 2"); if ($out) { // Read binary input stream and append it to temp file $in = fopen($_FILES['file']['tmp_name'], "rb"); - + if ($in) { while ($buff = fread($in, 4096)) fwrite($out, $buff); } else die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}'); - + fclose($out); unlink($_FILES['file']['tmp_name']); } else @@ -838,18 +838,18 @@ Logging::log("getting media! - 2"); if ($out) { // Read binary input stream and append it to temp file $in = fopen("php://input", "rb"); - + if ($in) { while ($buff = fread($in, 4096)) fwrite($out, $buff); } else die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}'); - + fclose($out); } else die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}'); } - + return $tempFilePath; } @@ -899,7 +899,7 @@ Logging::log("getting media! - 2"); 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 $r = @rename($audio_file, $audio_stor); - + if ($r === false) { #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. diff --git a/airtime_mvc/public/css/media_library.css b/airtime_mvc/public/css/media_library.css index 172c26a0a..1456c04e7 100644 --- a/airtime_mvc/public/css/media_library.css +++ b/airtime_mvc/public/css/media_library.css @@ -1,7 +1,7 @@ #library_content { float: left; width: 50%; - overflow: auto; + overflow: hidden; } #library_display { @@ -84,5 +84,4 @@ td.library_track, td.library_sr, td.library_bitrate { text-align: right; - padding-right: 1em !important; } \ No newline at end of file diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index 31e12329c..457e91a0f 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -554,6 +554,14 @@ dl.inline-list dd { border-width: 0px 1px 0 1px; } +.dataTables_scrolling { + overflow: auto; +} + +.dataTables_scrolling table{ + border-width: 0px 1px 0 1px; +} + .DataTables_sort_wrapper .ui-icon { display: block; float: left; @@ -611,6 +619,7 @@ dl.inline-list dd { .dataTables_paginate { float: right; padding: 8px 0 8px 8px; + clear: left; } .dataTables_paginate .ui-button { font-size:12px; diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index e74ab9405..82512833c 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -42,14 +42,17 @@ var AIRTIME = (function(AIRTIME) { }; libraryInit = function() { - var oTable; + var oTable, + libContentDiv = $("#library_content"); + tableHeight = libContentDiv.height() - 140; oTable = $('#library_display').dataTable( { + //put hidden columns at the top to insure they can never be visible on the table through column reordering. "aoColumns": [ - /* Checkbox */ {"sTitle": "", "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}, + /* Checkbox */ {"sTitle": "", "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"}, /* Creator */ {"sTitle": "Creator", "mDataProp": "artist_name", "sClass": "library_creator"}, /* Album */ {"sTitle": "Album", "mDataProp": "album_title", "sClass": "library_album"}, @@ -227,9 +230,9 @@ var AIRTIME = (function(AIRTIME) { "oLanguage": { "sSearch": "" }, - + // 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": { "sRowSelect": "multi", @@ -285,6 +288,8 @@ var AIRTIME = (function(AIRTIME) { }); oTable.fnSetFilteringDelay(350); + + libContentDiv.find(".dataTables_scrolling").css("max-height", tableHeight); AIRTIME.library.events.setupLibraryToolbar(oTable); diff --git a/airtime_mvc/public/js/airtime/showbuilder/builder.js b/airtime_mvc/public/js/airtime/showbuilder/builder.js index e82fe625d..21f0f5350 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/builder.js +++ b/airtime_mvc/public/js/airtime/showbuilder/builder.js @@ -105,7 +105,8 @@ var AIRTIME = (function(AIRTIME){ mod.builderDataTable = function() { var tableDiv = $('#show_builder_table'), oTable, - fnRemoveSelectedItems; + fnRemoveSelectedItems, + tableHeight; fnRemoveSelectedItems = function() { var oTT = TableTools.fnGetInstance('show_builder_table'), @@ -405,7 +406,7 @@ var AIRTIME = (function(AIRTIME){ }, // R = ColReorderResize, C = ColVis, T = TableTools - "sDom": 'Rr<"H"CT>t<"F">', + "sDom": 'Rr<"H"CT>t', "sAjaxDataProp": "schedule", "sAjaxSource": "/showbuilder/builder-feed" diff --git a/airtime_mvc/public/js/airtime/showbuilder/main_builder.js b/airtime_mvc/public/js/airtime/showbuilder/main_builder.js index 2000f6a34..9c97d3e63 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/main_builder.js +++ b/airtime_mvc/public/js/airtime/showbuilder/main_builder.js @@ -135,7 +135,8 @@ $(document).ready(function(){ var $button = $(this), $lib = $("#library_content"), $builder = $("#show_builder"), - oTable = $("#show_builder_table").dataTable(); + schedTable = $("#show_builder_table").dataTable(), + libTable = $lib.find("#library_display").dataTable(); if ($button.hasClass("sb-edit")) { @@ -160,7 +161,7 @@ $(document).ready(function(){ $button.val("Add Files"); } - oTable.fnDraw(); + schedTable.fnDraw(); }); oRange = fnGetScheduleRange();