BUG 5601 Documents are being loaded too slow
Fixed issue implementing pagination. Some other fixes and improvements applied in this commit: Better Refresh button for documents tree, bug 6919 fixed too
This commit is contained in:
@@ -42,7 +42,7 @@ class AppFolder extends BaseAppFolder {
|
||||
$oDataset->next ();
|
||||
if ($aRow = $oDataset->getRow ()) {//Folder exist, then return the ID
|
||||
$response['success']=false;
|
||||
$response['message']=$response['error']="Can't create folder <br /> A folder with same name already exists. <br /> $folderParent$folderName";
|
||||
$response['message']=$response['error']="Can't create folder <br /> A folder with same name already exists. <br /> $folderName";
|
||||
$response['folderUID']=$aRow ['FOLDER_UID'];
|
||||
//return ($aRow ['FOLDER_UID']);
|
||||
return ($response);
|
||||
@@ -58,7 +58,7 @@ class AppFolder extends BaseAppFolder {
|
||||
// we save it, since we get no validation errors, or do whatever else you like.
|
||||
$res = $tr->save ();
|
||||
$response['success']=true;
|
||||
$response['message']=$response['error']="Folder successfully created. <br /> $folderParent$folderName";
|
||||
$response['message']="Folder successfully created. <br /> $folderName";
|
||||
$response['folderUID']=$folderUID;
|
||||
return ($response);
|
||||
//return $folderUID;
|
||||
@@ -127,7 +127,7 @@ class AppFolder extends BaseAppFolder {
|
||||
* @param string(32) $folderID
|
||||
* @return multitype:
|
||||
*/
|
||||
function getFolderList($folderID) {
|
||||
function getFolderList($folderID, $limit=0, $start=0) {
|
||||
$Criteria = new Criteria ( 'workflow' );
|
||||
$Criteria->clearSelectColumns ()->clearOrderByColumns ();
|
||||
|
||||
@@ -141,15 +141,23 @@ class AppFolder extends BaseAppFolder {
|
||||
|
||||
$Criteria->addAscendingOrderByColumn ( AppFolderPeer::FOLDER_NAME );
|
||||
|
||||
$response['totalFoldersCount'] = AppFolderPeer::doCount($Criteria);
|
||||
$response['folders'] = array();
|
||||
|
||||
if($limit != 0){
|
||||
|
||||
$Criteria->setLimit($limit);
|
||||
$Criteria->setOffset($start);
|
||||
}
|
||||
$rs = appFolderPeer::doSelectRS ( $Criteria );
|
||||
$rs->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
$rs->next ();
|
||||
$folderResult = array ();
|
||||
while ( is_array ( $row = $rs->getRow () ) ) {
|
||||
$folderResult [] = $row;
|
||||
$response['folders'] [] = $row;
|
||||
$rs->next ();
|
||||
}
|
||||
return ($folderResult);
|
||||
return ($response);
|
||||
}
|
||||
/**
|
||||
* @param string(32) $folderUid
|
||||
@@ -190,7 +198,7 @@ class AppFolder extends BaseAppFolder {
|
||||
return $folderArray;
|
||||
}
|
||||
|
||||
function getFolderContent($folderID, $docIdFilter = array(), $keyword = NULL, $searchType = NULL) {
|
||||
function getFolderContent($folderID, $docIdFilter = array(), $keyword = NULL, $searchType = NULL, $limit=0, $start=0) {
|
||||
require_once ("classes/model/AppDocument.php");
|
||||
require_once ("classes/model/InputDocument.php");
|
||||
require_once ("classes/model/OutputDocument.php");
|
||||
@@ -213,12 +221,19 @@ class AppFolder extends BaseAppFolder {
|
||||
|
||||
$oCase->verifyTable ();
|
||||
|
||||
$oCriteria->setOffset(0);
|
||||
$oCriteria->setLimit(150);
|
||||
|
||||
$oCriteria->addAscendingOrderByColumn ( AppDocumentPeer::APP_DOC_INDEX );
|
||||
$oCriteria->addDescendingOrderByColumn ( AppDocumentPeer::DOC_VERSION );
|
||||
|
||||
|
||||
$response['totalDocumentsCount'] = AppDocumentPeer::doCount($oCriteria);
|
||||
$response['documents'] = array();
|
||||
|
||||
|
||||
|
||||
$oCriteria->setLimit($limit);
|
||||
$oCriteria->setOffset($start);
|
||||
|
||||
$rs = AppDocumentPeer::doSelectRS ( $oCriteria );
|
||||
$rs->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
|
||||
$rs->next ();
|
||||
@@ -238,15 +253,15 @@ class AppFolder extends BaseAppFolder {
|
||||
if ((in_array ( $row ['APP_DOC_UID'], $completeInfo ['INPUT_DOCUMENTS'] )) || (in_array ( $row ['APP_DOC_UID'], $completeInfo ['OUTPUT_DOCUMENTS'] )) || (in_array ( $completeInfo ['USR_UID'], array ($_SESSION ['USER_LOGGED'], '-1' ) ))) {
|
||||
if (count ( $docIdFilter ) > 0) {
|
||||
if (in_array ( $row ['APP_DOC_UID'], $docIdFilter )) {
|
||||
$filesResult [] = $completeInfo;
|
||||
$response['documents'][] = $completeInfo;
|
||||
}
|
||||
} elseif ($lastVersion == $row ['DOC_VERSION']) { //Only Last Document version
|
||||
if ($searchType == "ALL") {// If search in name of docs is active then filter
|
||||
if ((stripos ( $completeInfo ['APP_DOC_FILENAME'], $keyword ) !== false) || (stripos ( $completeInfo ['APP_DOC_TAGS'], $keyword ) !== false)) {
|
||||
$filesResult [] = $completeInfo;
|
||||
$response['documents'][] = $completeInfo;
|
||||
}
|
||||
} else {//No search filter active
|
||||
$filesResult [] = $completeInfo;
|
||||
$response['documents'][] = $completeInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +270,7 @@ class AppFolder extends BaseAppFolder {
|
||||
}
|
||||
$rs->next ();
|
||||
}
|
||||
return ($filesResult);
|
||||
return ($response);
|
||||
}
|
||||
function getCompleteDocumentInfo($appUid, $appDocUid, $docVersion, $docUid, $usrId) {
|
||||
require_once ("classes/model/AppDocument.php");
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
if (! isset ( $_REQUEST ['action'] )) {
|
||||
$res ['success'] = 'failure';
|
||||
$res ['success'] = false;
|
||||
$res ['message'] = 'You may request an action';
|
||||
print G::json_encode ( $res);
|
||||
die ();
|
||||
}
|
||||
if (! function_exists ( $_REQUEST ['action'] )) {
|
||||
$res ['success'] = 'failure';
|
||||
$res ['success'] = false;
|
||||
$res ['message'] = 'The requested action doesn\'t exists';
|
||||
print G::json_encode ( $res );
|
||||
die ();
|
||||
@@ -18,7 +18,27 @@ $functionParams = isset ( $_REQUEST ['params'] ) ? $_REQUEST ['params'] : array
|
||||
|
||||
$functionName ( $functionParams );
|
||||
|
||||
function getExtJSParams() {
|
||||
$validParams = array('callback' => '', 'dir' => 'DESC', 'sort' => '', 'start' => 0, 'limit' => 25, 'filter' => '', 'search' => '', 'action' => '', 'xaction' => '', 'data' => '', 'status' => '', 'query' => '', 'fields' => "");
|
||||
$result = array();
|
||||
foreach ($validParams as $paramName => $paramDefault) {
|
||||
$result[$paramName] = isset($_REQUEST[$paramName]) ? $_REQUEST[$paramName] : isset($_REQUEST[$paramName]) ? $_REQUEST[$paramName] : $paramDefault;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function sendJsonResultGeneric($response, $callback) {
|
||||
header("Content-Type: application/json");
|
||||
$finalResponse = json_encode($response);
|
||||
if ($callback != '') {
|
||||
print $callback . "($finalResponse);";
|
||||
} else {
|
||||
print $finalResponse;
|
||||
}
|
||||
}
|
||||
|
||||
function expandNode(){
|
||||
extract(getExtJSParams());
|
||||
require_once ("classes/model/AppFolder.php");
|
||||
|
||||
$oPMFolder = new AppFolder ( );
|
||||
@@ -28,12 +48,25 @@ function expandNode(){
|
||||
if($_POST ['node']=="") $_POST ['node'] ="/";
|
||||
if($_POST ['node']=="root") $_POST ['node'] ="/";
|
||||
if(!(isset($_POST['sendWhat']))) $_POST['sendWhat']="both";
|
||||
$totalItems=0;
|
||||
$totalFolders=0;
|
||||
$totalDocuments=0;
|
||||
if(($_POST['sendWhat']=="dirs")||($_POST['sendWhat']=="both")){
|
||||
$folderList = $oPMFolder->getFolderList ( $_POST ['node'] != 'root' ? $_POST ['node'] == 'NA' ? "" : $_POST ['node'] : $rootFolder );
|
||||
$folderListObj = $oPMFolder->getFolderList ( $_POST ['node'] != 'root' ? $_POST ['node'] == 'NA' ? "" : $_POST ['node'] : $rootFolder, $limit, $start );
|
||||
//G::pr($folderListObj);
|
||||
$folderList=$folderListObj['folders'];
|
||||
$totalFolders=$folderListObj['totalFoldersCount'];
|
||||
$totalItems+=count($folderList);
|
||||
|
||||
//G::pr($folderList);
|
||||
}
|
||||
if(($_POST['sendWhat']=="files")||($_POST['sendWhat']=="both")){
|
||||
$folderContent = $oPMFolder->getFolderContent ( $_POST ['node'] != 'root' ? $_POST ['node'] == 'NA' ? "" : $_POST ['node'] : $rootFolder );
|
||||
$folderContentObj = $oPMFolder->getFolderContent ( $_POST ['node'] != 'root' ? $_POST ['node'] == 'NA' ? "" : $_POST ['node'] : $rootFolder, array(), NULL, NULL, $limit, $start );
|
||||
//G::pr($folderContentObj);
|
||||
$folderContent=$folderContentObj['documents'];
|
||||
$totalDocuments=$folderContentObj['totalDocumentsCount'];
|
||||
$totalItems+=count($folderContent);
|
||||
|
||||
//G::pr($folderContent);
|
||||
}
|
||||
//G::pr($folderContent);
|
||||
@@ -162,7 +195,7 @@ function expandNode(){
|
||||
$tempTree ['appDocPlugin'] = $obj['APP_DOC_PLUGIN'];
|
||||
$tempTree ['appDocTags'] = $obj['APP_DOC_TAGS'];
|
||||
$tempTree ['appDocTitle'] = $obj['APP_DOC_TITLE'];
|
||||
$tempTree ['appDocComment'] = $obj['APP_DOC_COMMENT'];
|
||||
$tempTree ['appDocComment'] = $tempTree ['qtip'] = $obj['APP_DOC_COMMENT'];
|
||||
$tempTree ['appDocFileName'] = $obj['APP_DOC_FILENAME'];
|
||||
if(isset($obj['APP_NUMBER'])){
|
||||
$tempTree ['appLabel'] = sprintf("%s '%s' (%s)",$obj['APP_NUMBER'],$obj['APP_TITLE'],$obj['STATUS']);
|
||||
@@ -243,7 +276,8 @@ function expandNode(){
|
||||
}
|
||||
}
|
||||
if((isset($_POST['option']))&&($_POST['option']=="gridDocuments")){
|
||||
$processListTreeTemp['totalCount']=count($processListTree);
|
||||
$processListTreeTemp['totalCount']=$totalFolders+$totalDocuments;//count($processListTree);
|
||||
|
||||
$processListTreeTemp['items']=$processListTree;
|
||||
$processListTree = $processListTreeTemp;
|
||||
}
|
||||
@@ -1028,6 +1062,7 @@ function newFolder(){
|
||||
$oPMFolder = new AppFolder ( );
|
||||
//G::pr($_POST);
|
||||
if($_POST ['dir']=="") $_POST ['dir']="/";
|
||||
if($_POST ['dir']=="root") $_POST ['dir']="/";
|
||||
$folderStructure = $oPMFolder->getFolderStructure ( $_POST ['dir'] );
|
||||
//G::pr($folderStructure);
|
||||
$folderPath = $folderStructure ['PATH'];
|
||||
@@ -1206,9 +1241,11 @@ function getMime($fileName){
|
||||
$return['icon']="/images/documents/extension/document.png";
|
||||
if(count($fileNameA)>1){
|
||||
$extension=$fileNameA[count($fileNameA)-1];
|
||||
if(file_exists(PATH_HTML."images/documents/extension/".strtolower($extension).".png")){
|
||||
$return['description']=G::LoadTranslation("MIME_DES_".strtoupper($extension));
|
||||
$return['icon']="/images/documents/extension/".strtolower($extension).".png";
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,15 +24,21 @@ Ext.FlashComponent.EXPRESS_INSTALL_URL = '/images/expressinstall.swf';
|
||||
// The Quicktips are used for the toolbar and Tree mouseover tooltips!
|
||||
Ext.QuickTips.init();
|
||||
|
||||
try{rc=new RegExp('^("(\\\\.|[^"\\\\\\n\\r])*?"|[,:{}\\[\\]0-9.\\-+Eaeflnr-u \\n\\r\\t])+?$');}
|
||||
catch(z){rc=/^(true|false|null|\[.*\]|\{.*\}|".*"|\d+|\d+\.\d+)$/;}
|
||||
try{
|
||||
rc=new RegExp('^("(\\\\.|[^"\\\\\\n\\r])*?"|[,:{}\\[\\]0-9.\\-+Eaeflnr-u \\n\\r\\t])+?$');
|
||||
}
|
||||
catch(z){
|
||||
rc=/^(true|false|null|\[.*\]|\{.*\}|".*"|\d+|\d+\.\d+)$/;
|
||||
}
|
||||
|
||||
var conn = new Ext.data.Connection();
|
||||
|
||||
streamFilefromPM=function(fileStream) {
|
||||
Ext.Ajax.request({
|
||||
url:fileStream,
|
||||
params: {request:true},
|
||||
params: {
|
||||
request:true
|
||||
},
|
||||
success: function(response) {
|
||||
results = Ext.decode(response.responseText);
|
||||
if(results.success=='success'){
|
||||
@@ -78,7 +84,17 @@ function chDir( directory, loadGridOnly ) {
|
||||
datastore.directory = directory;
|
||||
var conn = datastore.proxy.getConnection();
|
||||
if( directory == '' || conn && !conn.isLoading()) {
|
||||
datastore.load({params:{start:0, limit:150, dir: directory, node: directory, option:'gridDocuments', action:'expandNode', sendWhat: datastore.sendWhat }});
|
||||
datastore.load({
|
||||
params:{
|
||||
start:0,
|
||||
limit:25,
|
||||
dir: directory,
|
||||
node: directory,
|
||||
option:'gridDocuments',
|
||||
action:'expandNode',
|
||||
sendWhat: datastore.sendWhat
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
tb = ext_itemgrid.getTopToolbar();
|
||||
@@ -103,7 +119,9 @@ function expandTreeToDir( node, dir ) {
|
||||
// console.info("Expanding Tree to Dir "+node+" - "+dir);
|
||||
dir = dir ? dir : new String('');
|
||||
var dirs = dir.split('/');
|
||||
if( dirs[0] == '') { dirs.shift(); }
|
||||
if( dirs[0] == '') {
|
||||
dirs.shift();
|
||||
}
|
||||
if( dirs.length > 0 ) {
|
||||
// console.log("Dir to expand... "+dirs[0]);
|
||||
node = dirTree.getNodeById( dirs[0] );
|
||||
@@ -112,7 +130,9 @@ function expandTreeToDir( node, dir ) {
|
||||
expandNode( node, dir );
|
||||
return;
|
||||
}
|
||||
node.on('load', function() { expandNode( node, dir ); } );
|
||||
node.on('load', function() {
|
||||
expandNode( node, dir );
|
||||
} );
|
||||
node.expand();
|
||||
}
|
||||
}
|
||||
@@ -121,7 +141,9 @@ function expandNode( node, dir ) {
|
||||
var fulldirpath, dirpath;
|
||||
|
||||
var dirs = dir.split('/');
|
||||
if( dirs[0] == '') { dirs.shift(); }
|
||||
if( dirs[0] == '') {
|
||||
dirs.shift();
|
||||
}
|
||||
if( dirs.length > 0 ) {
|
||||
fulldirpath = '';
|
||||
for( i=0; i < dirs.length; i++ ) {
|
||||
@@ -143,9 +165,16 @@ function expandNode( node, dir ) {
|
||||
dirpath += '_RRR_'+ dirs[i];
|
||||
// dirpath = dirpath.substr( 5 );
|
||||
var nextnode = dirTree.getNodeById( dirpath );
|
||||
if( !nextnode ) { return; }
|
||||
if( nextnode.isExpanded() ) { expandNode( nextnode, dir ); return;}
|
||||
nextnode.on( 'load', function() { expandNode( nextnode, dir ); } );
|
||||
if( !nextnode ) {
|
||||
return;
|
||||
}
|
||||
if( nextnode.isExpanded() ) {
|
||||
expandNode( nextnode, dir );
|
||||
return;
|
||||
}
|
||||
nextnode.on( 'load', function() {
|
||||
expandNode( nextnode, dir );
|
||||
} );
|
||||
|
||||
nextnode.expand();
|
||||
break;
|
||||
@@ -210,7 +239,11 @@ function openActionDialog( caller, action ) {
|
||||
selectedRows = Array( dirTree.getSelectionModel().getSelectedNode().id.replace( /_RRR_/g, '/' ) );
|
||||
}
|
||||
}
|
||||
var dontNeedSelection = { newFolder:1, uploadDocument:1, search:1 };
|
||||
var dontNeedSelection = {
|
||||
newFolder:1,
|
||||
uploadDocument:1,
|
||||
search:1
|
||||
};
|
||||
if( dontNeedSelection[action] == null && selectedRows.length < 1 ) {
|
||||
Ext.Msg.alert( 'Error',TRANSLATIONS.ID_NO_ITEMS_SELECTED);
|
||||
return false;
|
||||
@@ -251,7 +284,8 @@ function openActionDialog( caller, action ) {
|
||||
|
||||
});
|
||||
}
|
||||
Ext.Ajax.request( { url: '../appFolder/appFolderAjax.php',
|
||||
Ext.Ajax.request( {
|
||||
url: '../appFolder/appFolderAjax.php',
|
||||
params: Ext.urlEncode( requestParams ),
|
||||
scripts: true,
|
||||
callback: function(oElement, bSuccess, oResponse) {
|
||||
@@ -358,7 +392,9 @@ function openActionDialog( caller, action ) {
|
||||
});
|
||||
|
||||
if( action != "edit" ) {
|
||||
dialog.on( 'hide', function() { dialog.destroy(true); } );
|
||||
dialog.on( 'hide', function() {
|
||||
dialog.destroy(true);
|
||||
} );
|
||||
dialog.show();
|
||||
}
|
||||
break;
|
||||
@@ -409,7 +445,9 @@ function handleCallback(requestParams, node) {
|
||||
} else {
|
||||
datastore.reload();
|
||||
}
|
||||
} catch(e) { datastore.reload(); }
|
||||
} catch(e) {
|
||||
datastore.reload();
|
||||
}
|
||||
}else{
|
||||
statusBarMessage( json.message, false, false );
|
||||
}
|
||||
@@ -506,11 +544,15 @@ function handleCallback(requestParams, node) {
|
||||
return {
|
||||
msg : function(title, format){
|
||||
if(!msgCt){
|
||||
msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
|
||||
msgCt = Ext.DomHelper.insertFirst(document.body, {
|
||||
id:'msg-div'
|
||||
}, true);
|
||||
}
|
||||
msgCt.alignTo(document, 't-t');
|
||||
var s = String.format.apply(String, Array.prototype.slice.call(arguments, 1));
|
||||
var m = Ext.DomHelper.append(msgCt, {html:createBox(title, s)}, true);
|
||||
var m = Ext.DomHelper.append(msgCt, {
|
||||
html:createBox(title, s)
|
||||
}, true);
|
||||
m.setWidth(400 );
|
||||
m.position(null, 5000 );
|
||||
m.alignTo(document, 't-t');
|
||||
@@ -518,7 +560,9 @@ function handleCallback(requestParams, node) {
|
||||
Ext.get('x-box-mc-inner' ).setStyle('background-position', '5px 10px');
|
||||
Ext.get('x-box-mc-inner' ).setStyle('background-repeat', 'no-repeat');
|
||||
Ext.get('x-box-mc-inner' ).setStyle('padding-left', '35px');
|
||||
m.slideIn('t').pause(3).ghost("t", {remove:true});
|
||||
m.slideIn('t').pause(3).ghost("t", {
|
||||
remove:true
|
||||
});
|
||||
}
|
||||
};
|
||||
}();
|
||||
@@ -593,7 +637,7 @@ datastore = new Ext.data.Store({
|
||||
directory : "/",
|
||||
params : {
|
||||
start : 0,
|
||||
limit : 150,
|
||||
limit : 25,
|
||||
dir : this.directory,
|
||||
node : this.directory,
|
||||
option : "gridDocuments",
|
||||
@@ -601,7 +645,7 @@ datastore = new Ext.data.Store({
|
||||
}
|
||||
}),
|
||||
directory : "/",
|
||||
sendWhat : "both",
|
||||
sendWhat : "files",
|
||||
// create reader that reads the File records
|
||||
reader : new Ext.data.JsonReader({
|
||||
root : "items",
|
||||
@@ -672,7 +716,7 @@ datastore.on("beforeload",
|
||||
function(ds, options) {
|
||||
options.params.dir = options.params.dir ? options.params.dir
|
||||
: ds.directory;
|
||||
node = options.params.dir ? options.params.dir : ds.directory;
|
||||
options.params.node = options.params.dir ? options.params.dir : ds.directory;
|
||||
options.params.option = "gridDocuments";
|
||||
options.params.action = "expandNode";
|
||||
options.params.sendWhat = datastore.sendWhat;
|
||||
@@ -890,7 +934,7 @@ var gridtb = new Ext.Toolbar(
|
||||
new Ext.Toolbar.Button({
|
||||
text : TRANSLATIONS.ID_SHOW_DIRS,
|
||||
enableToggle : true,
|
||||
pressed : true,
|
||||
pressed : false,
|
||||
handler : function(btn, e) {
|
||||
if (btn.pressed) {
|
||||
datastore.sendWhat = 'both';
|
||||
@@ -1141,7 +1185,7 @@ function loadDir() {
|
||||
datastore.load({
|
||||
params : {
|
||||
start : 0,
|
||||
limit : 150,
|
||||
limit : 25,
|
||||
dir : datastore.directory,
|
||||
node : datastore.directory,
|
||||
option : 'gridDocuments',
|
||||
@@ -1430,7 +1474,7 @@ var documentsTab = {
|
||||
xtype : "treepanel",
|
||||
id : "dirTreePanel",
|
||||
region : "west",
|
||||
title : TRANSLATIONS.ID_DIRECTORY+' <img src="/images/refresh.gif" hspace="20" style="cursor:pointer;" title="reload" onclick="Ext.getCmp(\'dirTreePanel\').getRootNode().reload();" alt="Reload" align="middle" />',
|
||||
title : TRANSLATIONS.ID_DIRECTORY,
|
||||
closable : false,
|
||||
collapsible: true,
|
||||
collapseMode: 'mini',
|
||||
@@ -1439,7 +1483,14 @@ var documentsTab = {
|
||||
titlebar : true,
|
||||
autoScroll : true,
|
||||
animate : true,
|
||||
|
||||
tools:[
|
||||
{
|
||||
id:'refresh',
|
||||
handler:function() {
|
||||
Ext.getCmp('dirTreePanel').getRootNode().reload();
|
||||
}
|
||||
}
|
||||
],
|
||||
// rootVisible: false,
|
||||
loader : new Ext.tree.TreeLoader({
|
||||
preloadChildren : true,
|
||||
|
||||
Reference in New Issue
Block a user