public inbox for [email protected]  
help / color / mirror / Atom feed
From: Surinder Kumar <[email protected]>
To: Dave Page <[email protected]>
Cc: Shruti B Iyer <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Cc: Matthew Kleiman <[email protected]>
Subject: Re: Re: [pgAdmin4][Patch][Feature #1971]: Remember column sizes between executions of the same query in the query tool
Date: Fri, 9 Jun 2017 13:09:43 +0530
Message-ID: <CAM5-9D-fn-VzWaramhajWvq3N0x_b6E0LiifRc7h83WAka0Dqg@mail.gmail.com> (raw)
In-Reply-To: <CA+OCxoxNxC-peERji_29CkNw0E6wguVctBVM6EhUENe5OApT8w@mail.gmail.com>
References: <CAM5-9D8qbLXBzs3rAjAMUZtj32hDNV11rnymXgxUfKePkqL-rQ@mail.gmail.com>
	<CAM5-9D_AAy6vLL3kMDVKPhtpDe_bNFH0o+uc-4RajZFeypFe+g@mail.gmail.com>
	<CACrUwh+iWeuscD94nZ8SGxfyvs=-JjundJ6sUZDeqDXsxFXC3g@mail.gmail.com>
	<CAM5-9D8yKkmvVdhexSK7qaCP3UUr3ORk9D7TNnPwJVJW=LSx7A@mail.gmail.com>
	<CA+OCxozDeO_=uEzT6Cg9brZ-O3JF1XJfknKWG0ZVkykC3sxhfA@mail.gmail.com>
	<CAM5-9D_9RX1+xd6kqyb=1OXfCLA4EsM+y2B-4hTDiOjxCojrrQ@mail.gmail.com>
	<CAM5-9D_ZuL=JCh6B54A0DnjMKgXCMecZM8sShQ7nqFOU_Fh3Kw@mail.gmail.com>
	<CA+OCxoxNxC-peERji_29CkNw0E6wguVctBVM6EhUENe5OApT8w@mail.gmail.com>
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

Hi

As the patch "Improvements to Query Results"
​ is merged, the columns width in edit grid needs some adjustments as
'checkboxes' are removed from columns.

​PFA patch.​

On Thu, Jun 8, 2017 at 5:12 PM, Dave Page <[email protected]> wrote:

> Nice! Thanks, patch applied.
>
> On Wed, Jun 7, 2017 at 4:03 PM, Surinder Kumar
> <[email protected]> wrote:
> > PFA patch after rebase
> >
> > On Wed, Jun 7, 2017 at 6:26 PM, Surinder Kumar
> > <[email protected]> wrote:
> >>
> >> Hi
> >>
> >> Please find rebased patch.
> >>
> >> On Wed, Jun 7, 2017 at 6:15 PM, Dave Page <[email protected]> wrote:
> >>>
> >>> Hi,
> >>>
> >>> Could you rebase this please?
> >>>
> >>> Thanks.
> >>>
> >>> On Tue, Jun 6, 2017 at 9:22 AM, Surinder Kumar
> >>> <[email protected]> wrote:
> >>> > Hi All,
> >>> >
> >>> > Please find updated patch which includes Jasmine test cases for
> >>> > functions
> >>> > getHash and calculateColumnWidth
> >>> >
> >>> > Thanks,
> >>> > Surinder
> >>> >
> >>> > On Mon, Jun 5, 2017 at 11:38 PM, Shruti B Iyer <[email protected]>
> >>> > wrote:
> >>> >>
> >>> >> Hi Surinder!
> >>> >>
> >>> >> We reviewed this patch. The changes look good and we especially like
> >>> >> that
> >>> >> you have extracted out the new utility functions and the
> >>> >> epicRandomString
> >>> >> function too.
> >>> >>
> >>> >> This patch will likely affect the Query Results patch that is
> >>> >> currently
> >>> >> under review. In order to assist either us or yourself when making a
> >>> >> merge
> >>> >> between these patches, it would help to have jasmine unit testing
> for
> >>> >> the
> >>> >> two new functions, getHash and calculate_column_width.
> >>> >>
> >>> >> Also, we suggest that you rename calculate_column_width to
> >>> >> calculateColumnWidth for consistency with javascript code style.
> >>> >>
> >>> >> Thanks,
> >>> >> Shruti and Matt
> >>> >>
> >>> >> On Mon, Jun 5, 2017 at 9:16 AM Surinder Kumar
> >>> >> <[email protected]> wrote:
> >>> >>>
> >>> >>> Staged changes are missed in previous patch, so please ignore.
> >>> >>> Please find attached updated patch.
> >>> >>>
> >>> >>> On Mon, Jun 5, 2017 at 4:29 PM, Surinder Kumar
> >>> >>> <[email protected]> wrote:
> >>> >>>>
> >>> >>>> Hi
> >>> >>>>
> >>> >>>> This patch contains two fixes:
> >>> >>>>
> >>> >>>> 1) In Query/tool or Edit grid, the width of table column header is
> >>> >>>> fixed
> >>> >>>> depending on the column type(int, boolean, char etc.) due to which
> >>> >>>> the
> >>> >>>> column name or type appears cut from right and doesn't looks good
> >>> >>>> from user
> >>> >>>> point of view. The main concern was to display as much as the
> >>> >>>> content of
> >>> >>>> column should be displayed.
> >>> >>>>
> >>> >>>> Now the width of column is decided using the text length of column
> >>> >>>> name
> >>> >>>> or column type so that the column takes exact width it required
> and
> >>> >>>> it don't
> >>> >>>> appears cut.
> >>> >>>>
> >>> >>>> 2) Remember column size after re-running a query.
> >>> >>>>
> >>> >>>> The approach is to extract table name from the query executed and
> >>> >>>> use it
> >>> >>>> to store its columns width.
> >>> >>>> Whenever the column(s) width of a table is adjusted, the
> >>> >>>> corresponding
> >>> >>>> values are updated into the object and used every time the same
> >>> >>>> query is
> >>> >>>> executed.
> >>> >>>>
> >>> >>>> If a query is executed for e.g:
> >>> >>>>
> >>> >>>> SELECT generate_series(1, 1000) as id, generate_series(1, 1000) as
> >>> >>>> name,
> >>> >>>> generate_series(1, 1000) as age
> >>> >>>>
> >>> >>>> it
> >>> >>>> displays 3 columns
> >>> >>>> but don't have any table name. In that case,
> >>> >>>>  i use a hash generator function which returns unique hash for a
> >>> >>>> query
> >>> >>>> written in query editor and adjusted column(s) width are stored
> >>> >>>> against that
> >>> >>>> hash in object.
> >>> >>>>
> >>> >>>> Is there any way to get temporary table name(avoiding unique hash)
> >>> >>>> for
> >>> >>>> such queries ?
> >>> >>>>
> >>> >>>> Also, Moved utilities functions into pgadmin/static/utils.js
> >>> >>>>
> >>> >>>> 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
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > --
> >>> > Sent via pgadmin-hackers mailing list ([email protected]
> g)
> >>> > 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
> >>
> >>
> >
>
>
>
> --
> 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] adjust_columns_width.patch (1.9K, 3-adjust_columns_width.patch)
  download | inline diff:
diff --git a/web/pgadmin/static/js/sqleditor_utils.js b/web/pgadmin/static/js/sqleditor_utils.js
index 2afc4de..e09dde1 100644
--- a/web/pgadmin/static/js/sqleditor_utils.js
+++ b/web/pgadmin/static/js/sqleditor_utils.js
@@ -48,7 +48,7 @@ define(['jquery'],
         $('body').append(
             '<span id="pg_text" style="visibility: hidden;">'+ text + '</span>'
         );
-        var width = $('#pg_text').width() + 30;
+        var width = $('#pg_text').width() + 23;
         $('#pg_text').remove(); // remove element
 
         return width;
diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
index f21d333..da24f77 100644
--- a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
@@ -559,15 +559,15 @@ define([
 
             // Get the columns width based on longer string among data type or
             // column name.
-            var label = c.label.split('<br>');
-            label = label[0].length > label[1].length ? label[0] : label[1];
+            var column_type = c.column_type.trim();
+            var label = c.name.length > column_type.length ? c.name : column_type;
 
             if (_.isUndefined(column_size[table_name][c.name])) {
-                options['width'] = SqlEditorUtils.calculateColumnWidth(label)
-                column_size[table_name][c.name] = SqlEditorUtils.calculateColumnWidth(label);
+              options['width'] = SqlEditorUtils.calculateColumnWidth(label);
+              column_size[table_name][c.name] = options['width'];
             }
             else {
-                options['width'] = column_size[table_name][c.name];
+              options['width'] = column_size[table_name][c.name];
             }
 
             // If grid is editable then add editor else make it readonly


view thread (10+ 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], [email protected], [email protected]
  Subject: Re: Re: [pgAdmin4][Patch][Feature #1971]: Remember column sizes between executions of the same query in the query tool
  In-Reply-To: <CAM5-9D-fn-VzWaramhajWvq3N0x_b6E0LiifRc7h83WAka0Dqg@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