public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin][RM4647] Select File Dialog Sort by file size does not take units into account
2+ messages / 2 participants
[nested] [flat]

* [pgAdmin][RM4647] Select File Dialog Sort by file size does not take units into account
@ 2019-11-01 07:03 Aditya Toshniwal <[email protected]>
  2019-11-01 15:00 ` Re: [pgAdmin][RM4647] Select File Dialog Sort by file size does not take units into account Dave Page <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Aditya Toshniwal @ 2019-11-01 07:03 UTC (permalink / raw)
  To: pgadmin-hackers

Hi Hackers,

Attached is the patch to fix sorting by file size in file dialog.
Kindly review.

-- 
Thanks and Regards,
Aditya Toshniwal
Sr. Software Engineer | EnterpriseDB India | Pune
"Don't Complain about Heat, Plant a TREE"


Attachments:

  [application/octet-stream] RM4647.patch (3.9K, 3-RM4647.patch)
  download | inline diff:
diff --git a/web/pgadmin/misc/file_manager/__init__.py b/web/pgadmin/misc/file_manager/__init__.py
index ec956ea57..160f3466f 100644
--- a/web/pgadmin/misc/file_manager/__init__.py
+++ b/web/pgadmin/misc/file_manager/__init__.py
@@ -62,7 +62,7 @@ encode_json = json.JSONEncoder().encode
 # utility functions
 # convert bytes type to human readable format
 def sizeof_fmt(num, suffix='B'):
-    for unit in ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z']:
+    for unit in ['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z']:
         if abs(num) < 1024.0:
             return "%3.1f %s%s" % (num, unit, suffix)
         num /= 1024.0
diff --git a/web/pgadmin/misc/file_manager/static/js/utility.js b/web/pgadmin/misc/file_manager/static/js/utility.js
index 77acc5be7..e3fc81a9f 100644
--- a/web/pgadmin/misc/file_manager/static/js/utility.js
+++ b/web/pgadmin/misc/file_manager/static/js/utility.js
@@ -20,7 +20,7 @@
 define([
   'jquery', 'underscore', 'pgadmin.alertifyjs',
   'sources/gettext', 'sources/url_for', 'dropzone', 'sources/pgadmin',
-  'sources/csrf', 'tablesorter',
+  'sources/csrf', 'tablesorter', 'tablesorter-metric',
 ], function($, _, Alertify, gettext, url_for, Dropzone, pgAdmin, csrfToken) {
 
   /*---------------------------------------------------------
@@ -588,8 +588,8 @@ define([
             result += '<table id="contents" class="table table-bordered table-noouter-border table-bottom-border table-hover tablesorter file_listing_table">';
             result += '<thead><tr><th>';
             result += '<span>' + lg.name + '</span></th>';
-            result += '<th><span>' + lg.size + '</span></th><th>';
-            result += '<span>' + lg.modified + '</span></th></tr></thead>';
+            result += '<th class="sorter-metric" data-metric-name-full="byte|Byte|BYTE" data-metric-name-abbr="b|B"><span>' + lg.size + '</span></th>';
+            result += '<th class="sorter-shortDate"><span>' + lg.modified + '</span></th></tr></thead>';
             result += '<tbody>';
 
             Object.keys(data).sort(function keyOrder(x, y) {
@@ -675,8 +675,8 @@ define([
            */
             result += '<table id="contents" class="table table-bordered table-noouter-border table-bottom-border table-hover tablesorter file_listing_table file_listing_table_no_data">';
             result += '<thead><tr><th><span>' + lg.name + '</span></th>' +
-                    '<th><span>' + lg.size + '</span></th>' +
-                    '<th><span>' + lg.modified + '</span></th>' +
+                    '<th class="sorter-metric" data-metric-name-full="byte|Byte|BYTE" data-metric-name-abbr="b|B"><span>' + lg.size + '</span></th>' +
+                    '<th class="sorter-shortDate"><span>' + lg.modified + '</span></th>' +
                     '</tr></thead>' +
                     '<tbody></tbody>';
             result += '</table>';
@@ -690,13 +690,7 @@ define([
 
         // Add the new markup to the DOM.
         $('.fileinfo .file_listing').html(result);
-        $('.fileinfo .file_listing #contents').tablesorter({
-          headers: {
-            2: {
-              sorter: 'shortDate',
-            },
-          },
-        });
+        $('.fileinfo .file_listing #contents').tablesorter();
 
         // rename file/folder
         $('.file_manager button.rename').off().on('click', function(e) {
diff --git a/web/webpack.shim.js b/web/webpack.shim.js
index b4d3b8591..2e2b7ed41 100644
--- a/web/webpack.shim.js
+++ b/web/webpack.shim.js
@@ -155,6 +155,7 @@ var webpackShimConfig = {
     'snap.svg': path.join(__dirname, './node_modules/snapsvg/dist/snap.svg-min'),
     'spectrum': path.join(__dirname, './node_modules/spectrum-colorpicker/spectrum'),
     'mousetrap': path.join(__dirname, './node_modules/mousetrap'),
+    'tablesorter-metric': path.join(__dirname, './node_modules/tablesorter/dist/js/parsers/parser-metric.min'),
 
     // AciTree
     'jquery.acitree': path.join(__dirname, './node_modules/acitree/js/jquery.aciTree.min'),


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [pgAdmin][RM4647] Select File Dialog Sort by file size does not take units into account
  2019-11-01 07:03 [pgAdmin][RM4647] Select File Dialog Sort by file size does not take units into account Aditya Toshniwal <[email protected]>
@ 2019-11-01 15:00 ` Dave Page <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Dave Page @ 2019-11-01 15:00 UTC (permalink / raw)
  To: Aditya Toshniwal <[email protected]>; +Cc: pgadmin-hackers

Thanks, patch applied.

On Fri, Nov 1, 2019 at 7:03 AM Aditya Toshniwal <
[email protected]> wrote:

> Hi Hackers,
>
> Attached is the patch to fix sorting by file size in file dialog.
> Kindly review.
>
> --
> Thanks and Regards,
> Aditya Toshniwal
> Sr. Software Engineer | EnterpriseDB India | Pune
> "Don't Complain about Heat, Plant a TREE"
>


-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2019-11-01 15:00 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-11-01 07:03 [pgAdmin][RM4647] Select File Dialog Sort by file size does not take units into account Aditya Toshniwal <[email protected]>
2019-11-01 15:00 ` Dave Page <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox