public inbox for [email protected]
help / color / mirror / Atom feedFrom: Surinder Kumar <[email protected]>
To: Dave Page <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [pgAdmin4][Patch]: Listing of files/folders not sorted alphabetically in Storage Manager
Date: Mon, 17 Oct 2016 13:02:05 +0530
Message-ID: <CAM5-9D8ii0U9tn=rNgxbCfQLM48Gsk42h2Sp8grTumi+Juk75w@mail.gmail.com> (raw)
In-Reply-To: <CA+OCxoyW1Y5C3CdHZC1rzzzhuARdWFJM6U5cRDZtU5QqmfmaMA@mail.gmail.com>
References: <CAM5-9D8sNyL=Y0DMmM5gPCvYhy0dPiyxjjqddwZEgAoPhWG3kw@mail.gmail.com>
<CA+OCxoyW1Y5C3CdHZC1rzzzhuARdWFJM6U5cRDZtU5QqmfmaMA@mail.gmail.com>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgadmin-hackers>
Hi Dave,
As we have already been using natural sort in pgAdmin4 for sorting browser
tree nodes. So I have used the same for sorting Storage Manager's
filesystem.
Please find updated patch and let me know for comments.
On Fri, Oct 7, 2016 at 5:10 PM, Dave Page <[email protected]> wrote:
> Hi
>
> The patch fixes the filename length issue, but does not seem to
> resolve the sorting. Please see the attached screenshot.
>
> On Fri, Oct 7, 2016 at 8:48 AM, Surinder Kumar
> <[email protected]> wrote:
> > Hi,
> >
> > Issues fixed:
> > 1) Listing of files/folders not sorted alphabetically.
> > 2) Some file names are truncated despite the fact that there is plenty of
> > room to be displayed.
> >
> > Not Fixed:
> > In Table mode, clicking on Name bar makes no difference.
> > As discussed with Ashesh we are not implementing it now. It requires a
> lot
> > of changes with current implementation.
> >
> > Please find attached patch and review.
> >
> > Thanks,
> > Surinder Kumar
> >
> >
> > --
> > Sent via pgadmin-hackers mailing list ([email protected])
> > To make changes to your subscription:
> > http://www.postgresql.org/mailpref/pgadmin-hackers
> >
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
Attachments:
[application/octet-stream] RM1792_v1.patch (3.9K, 3-RM1792_v1.patch)
download | inline diff:
diff --git a/web/pgadmin/misc/file_manager/__init__.py b/web/pgadmin/misc/file_manager/__init__.py
index e262208..5c6a908 100644
--- a/web/pgadmin/misc/file_manager/__init__.py
+++ b/web/pgadmin/misc/file_manager/__init__.py
@@ -415,7 +415,7 @@ class Filemanager(object):
except:
drive_size = 0
protected = 1 if drive_size == 0 else 0
- files[drive] = {
+ files[file_name] = {
"Filename": file_name,
"Path": path,
"file_type": 'drive',
@@ -441,7 +441,12 @@ class Filemanager(object):
orig_path = unquote(orig_path)
try:
- for f in sorted(os.listdir(orig_path)):
+ def custom_sort(x, y):
+ return y.lower() > x.lower()
+
+ mylist = [x for x in sorted(os.listdir(orig_path),
+ cmp=custom_sort)]
+ for f in mylist:
protected = 0
system_path = os.path.join(os.path.join(orig_path, f))
@@ -474,7 +479,7 @@ class Filemanager(object):
continue
# create a list of files and folders
- files[user_path] = {
+ files[f] = {
"Filename": f,
"Path": user_path,
"file_type": file_extension,
diff --git a/web/pgadmin/misc/file_manager/templates/file_manager/js/utility.js b/web/pgadmin/misc/file_manager/templates/file_manager/js/utility.js
index 1bf7cd6..f1a5ef4 100755
--- a/web/pgadmin/misc/file_manager/templates/file_manager/js/utility.js
+++ b/web/pgadmin/misc/file_manager/templates/file_manager/js/utility.js
@@ -236,7 +236,7 @@ var setUploader = function(path) {
// template for creating new folder
folder_div =
- "<li class='cap_downloadcap_deletecap_select_filecap_select_foldercap_renamecap_createcap_upload'>" +
+ "<li class='cap_download cap_delete cap_select_file cap_select_folder cap_rename cap_create cap_upload'>" +
"<div class='clip'><span data-alt='' class='fa fa-folder-open fm_folder'></span></div>" +
"<p><input type='text' class='fm_file_rename'><span title=''>New_Folder</span></p>" +
"<span class='meta size'></span><span class='meta created'></span><span class='meta modified'></span></li>";
@@ -686,7 +686,9 @@ var getFolderInfo = function(path, file_type) {
if (!_.isEmpty(data)) {
if ($('.fileinfo').data('view') == 'grid') {
result += '<ul id="contents" class="grid">';
- Object.keys(data).forEach(function (key) {
+ Object.keys(data).sort(function keyOrder(x, y) {
+ return pgAdmin.natural_sort(x.toLowerCase(), y.toLowerCase());
+ }).forEach(function (key) {
var props = (data[key]).Properties,
cap_classes = "";
@@ -760,7 +762,9 @@ var getFolderInfo = function(path, file_type) {
result += '<span>' + lg.modified + '</span></th></tr></thead>';
result += '<tbody>';
- Object.keys(data).forEach(function (key) {
+ Object.keys(data).sort(function keyOrder(x, y) {
+ return pgAdmin.natural_sort(x.toLowerCase(), y.toLowerCase());
+ }).forEach(function (key) {
var path = encodeURI((data[key]).Path),
props = (data[key]).Properties,
cap_classes = "", cap, class_type;
@@ -787,8 +791,8 @@ var getFolderInfo = function(path, file_type) {
result += '<tr class="' + cap_classes + '">';
var fm_filename = (data[key]).Filename;
- if (fm_filename.length > 15 ) {
- fm_filename = (data[key]).Filename.substr(0, 10) +'...';
+ if (fm_filename.length > 48) {
+ fm_filename = (data[key]).Filename.substr(0, 48) +'...';
}
result += '<td title="' + path + '" class="'+class_type+'">';
view thread (4+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: [pgAdmin4][Patch]: Listing of files/folders not sorted alphabetically in Storage Manager
In-Reply-To: <CAM5-9D8ii0U9tn=rNgxbCfQLM48Gsk42h2Sp8grTumi+Juk75w@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox