Re: [pgAdmin4][Patch]: Switching between Tabs resets table viewport to first row in gird - Query tool

2017-11-23 Thread Murtuza Zabuawala
Hi Dave,

PFA updated patch.


On Wed, Nov 22, 2017 at 10:26 PM, Dave Page  wrote:

> Hi
>
> On Wed, Nov 22, 2017 at 3:18 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch to fix the issue where while switching the tabs in query tool
>> resets the position of the table viewport to the first row.
>> RM#2875
>>
>> *Steps:*
>> 1) Open query tool
>> 2) Execute:
>> select * from generate_series(1, 1000) as "column-1";
>> 3) Scroll till the End OR till ~250 row
>> 4) Click on 'Explain' Tab
>> 5) Go back to 'Data output' Tab
>>
>
> Hmm, minor issue; each time I return the to data tab, the data moves up
> two rows! It's almost like it's calculating the viewport taking into
> account the row header (e.g. row 250 is visible immediate below the
> header), but then re-positioning without taking it into account (e.g. row
> 250 is aligned with the top of the row header, thus making row 252 the
> first visible one).
>
​Fixed.​


>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js 
b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
index ba0ce67..f3d4267 100644
--- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
@@ -917,7 +917,8 @@ define('tools.querytool', [
   // fetch asynchronous
   setTimeout(self.fetch_next.bind(self));
 }
-  })
+  });
+
   // Resize SlickGrid when window resize
   $(window).resize(function () {
 // Resize grid only when 'Data Output' panel is visible.
@@ -1025,9 +1026,36 @@ define('tools.querytool', [
 
 /* This function is responsible to render output grid */
 grid_resize: function (grid) {
-  var h = $($('#editor-panel').find('.wcFrame')[1]).height() - 35;
-  $('#datagrid').css({'height': h + 'px'});
+  var prev_height = $('#datagrid').height(),
+h = $($('#editor-panel').find('.wcFrame')[1]).height() - 35,
+prev_viewport = grid.getViewport(),
+prev_viewport_rows = grid.getRenderedRange(),
+prev_cell = grid.getActiveCell();
+
+  // Apply css only if necessary, To avoid DOM operation
+  if (prev_height != h) {
+$('#datagrid').css({'height': h + 'px'});
+  }
+
   grid.resizeCanvas();
+
+  /*
+   * If there is an active cell from user then we have to go to that cell
+   */
+  if(prev_cell) {
+grid.scrollCellIntoView(prev_cell.row, prev_cell.cell);
+  }
+
+  // If already displaying from first row
+  if (prev_viewport.top == prev_viewport_rows.top) {
+return
+  }
+  // if user has scroll to the end/last row
+  else if (prev_viewport.bottom - 2 == prev_viewport_rows.bottom) {
+grid.scrollRowIntoView(prev_viewport.bottom);
+  } else {
+grid.scrollRowIntoView(prev_viewport.bottom - 2);
+  }
 },
 
 /* This function is responsible to create and render the


pgAdmin 4 commit: Fix bundle creation on Windows which was failing due

2017-11-23 Thread Dave Page
Fix bundle creation on Windows which was failing due to \r\n line endings in 
code mirror. Fixes #2908

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=5f5c590ffd2a0d33ea38d35fd9a66d98468f998c
Author: Maxim Zakharov 

Modified Files
--
web/.eslintrc.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



Re: [pgAdmin4][Patch]: Switching between Tabs resets table viewport to first row in gird - Query tool

2017-11-23 Thread Dave Page
Thanks, applied.

On Thu, Nov 23, 2017 at 8:03 AM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Dave,
>
> PFA updated patch.
>
>
> On Wed, Nov 22, 2017 at 10:26 PM, Dave Page  wrote:
>
>> Hi
>>
>> On Wed, Nov 22, 2017 at 3:18 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> PFA patch to fix the issue where while switching the tabs in query tool
>>> resets the position of the table viewport to the first row.
>>> RM#2875
>>>
>>> *Steps:*
>>> 1) Open query tool
>>> 2) Execute:
>>> select * from generate_series(1, 1000) as "column-1";
>>> 3) Scroll till the End OR till ~250 row
>>> 4) Click on 'Explain' Tab
>>> 5) Go back to 'Data output' Tab
>>>
>>
>> Hmm, minor issue; each time I return the to data tab, the data moves up
>> two rows! It's almost like it's calculating the viewport taking into
>> account the row header (e.g. row 250 is visible immediate below the
>> header), but then re-positioning without taking it into account (e.g. row
>> 250 is aligned with the top of the row header, thus making row 252 the
>> first visible one).
>>
> ​Fixed.​
>
>
>>
>> --
>> 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


pgAdmin 4 commit: Ensure the scroll location is retains in the query to

2017-11-23 Thread Dave Page
Ensure the scroll location is retains in the query tool data grid if the user 
changes tab and then returns. Fixes #2875

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=38f111d969d3faee673afad7dd0cd147f86758f7
Author: Murtuza Zabuawala 

Modified Files
--
web/pgadmin/tools/sqleditor/static/js/sqleditor.js | 34 --
1 file changed, 31 insertions(+), 3 deletions(-)



pgAdmin 4 commit: Make the "Save Changes" prompts in the query tool opt

2017-11-23 Thread Dave Page
Make the "Save Changes" prompts in the query tool optional. Fixes #2845

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=05a00f4ac80542a63b48ef4e062932c3e9744994
Author: Harshal Dhumal 

Modified Files
--
web/pgadmin/tools/datagrid/__init__.py | 10 +-
.../tools/datagrid/templates/datagrid/index.html   |  2 +-
web/pgadmin/tools/sqleditor/__init__.py| 20 +++
web/pgadmin/tools/sqleditor/static/js/sqleditor.js | 40 --
4 files changed, 52 insertions(+), 20 deletions(-)



Re: Fix for RM2845: Make "Save changes" prompt configurable

2017-11-23 Thread Dave Page
Thanks, applied.

On Thu, Nov 23, 2017 at 7:04 AM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> Please find attached patch to fix RM2845
>
> --
> *Harshal Dhumal*
> *Sr. Software Engineer*
>
> EnterpriseDB India: 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


Re: [pgAdmin4][Patch]: RM-2859: Can't create new user

2017-11-23 Thread Dave Page
Hi

On Thu, Nov 23, 2017 at 5:03 AM, Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

> Hi,
>
> Please find the attached patch to fix RM #2859:  Can't create new user.
>
> The "User Management" dialogue footer was overlapping the back-grid table
> which has been fixed.
>

If my screen is too small, it now looks like the attached screenshot, which
is really quite ugly.

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

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


pgAdmin 4 commit: Disable the line ending check entirely in eslint, as

2017-11-23 Thread Dave Page
Disable the line ending check entirely in eslint, as the previous 
platform-specific fix doesn't work with all versions.

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=fd077e25364c2ac52778cf3bd801389308a7b6e6

Modified Files
--
web/.eslintrc.js | 5 +
1 file changed, 1 insertion(+), 4 deletions(-)



Re: [pgAdmin4][Patch]: RM-2859: Can't create new user

2017-11-23 Thread Khushboo Vashi
On Thu, Nov 23, 2017 at 2:58 PM, Dave Page  wrote:

> Hi
>
> On Thu, Nov 23, 2017 at 5:03 AM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Please find the attached patch to fix RM #2859:  Can't create new user.
>>
>> The "User Management" dialogue footer was overlapping the back-grid table
>> which has been fixed.
>>
>
> If my screen is too small, it now looks like the attached screenshot,
> which is really quite ugly.
>
> If we don't leave the bottom blank space then in case of error the
error-message will shown on the grid itself and user can't perform any task.
Please refer the attached screen-shot for the same.

-- 
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


[pgAdmin4][Patch]: Do not use actual path when displaying dummy SSL certificates files

2017-11-23 Thread Murtuza Zabuawala
Hi,

PFA patch to fix the issue where we were exposing the actual storage
directory path when user did not provided their own SSL certificates in
Server mode.
RM#2866

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py 
b/web/pgadmin/browser/server_groups/servers/__init__.py
index 91b27f7..7cd7ef5 100644
--- a/web/pgadmin/browser/server_groups/servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/__init__.py
@@ -25,7 +25,6 @@ import config
 from config import PG_DEFAULT_DRIVER
 from pgadmin.model import db, Server, ServerGroup, User
 from pgadmin.utils.driver import get_driver
-from pgadmin.utils import get_storage_directory
 
 def has_any(data, keys):
 """
@@ -295,10 +294,9 @@ class ServerNode(PGChildNodeView):
 field in required_ssl_fields_server_mode:
 # Set file manager directory from preference
 import os
-storage_dir = get_storage_directory()
 file_extn = '.key' if field.endswith('key') else '.crt'
 dummy_ssl_file = os.path.join(
-storage_dir, '.postgresql',
+'', '.postgresql',
 'postgresql' + file_extn
 )
 data[field] = dummy_ssl_file


[pgAdmin4][Patch]: RM #2849 - Allow editing of data on tables with OIDs but no primary key

2017-11-23 Thread Khushboo Vashi
Hi,

Please find the attached patch for RM #2849: Allow editing of data on
tables with OIDs but no primary key.

Thanks,
Khushboo
diff --git a/docs/en_US/query_tool.rst b/docs/en_US/query_tool.rst
index e6dec55..957dcf7 100644
--- a/docs/en_US/query_tool.rst
+++ b/docs/en_US/query_tool.rst
@@ -148,7 +148,7 @@ If the Query tool is opened through the *Query tool* menu option on the *Tools*
 
 All rowsets from previous queries or commands that are displayed in the *Data Output* panel will be discarded when you invoke another query; open another query tool browser tab to keep your previous results available.
 
-If the Query Tool is opened using the *View Data* menu option and the data is updatable and has a primary key, then you can double-click on values on the *Data Output* tab and edit them:
+If the Query Tool is opened using the *View Data* menu option and the data is updatable and has a primary key or oid, then you can double-click on values on the *Data Output* tab and edit them:
 
 * To enter a NULL, clear the value of the string.
 * To enter a blank set the value of the cell to ''.
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/nodes.sql
index f3353d6..2c3e573 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/nodes.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/nodes.sql
@@ -15,9 +15,13 @@ WHERE
 {% if clid %}
 AND att.attnum = {{ clid|qtLiteral }}
 {% endif %}
-{### To show system objects ###}
-{% if not show_sys_objects %}
+{### To show system objects ###}
+{% if not show_sys_objects and not has_oids %}
 AND att.attnum > 0
-{% endif %}
+{% endif %}
+{### To show oids in view data ###}
+{% if has_oids %}
+AND (att.attnum > 0 OR (att.attname = 'oid' AND att.attnum < 0))
+{% endif %}
 AND att.attisdropped IS FALSE
 ORDER BY att.attnum
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/nodes.sql
index 4f1de2a..584f7b1 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/nodes.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/nodes.sql
@@ -16,8 +16,12 @@ WHERE
 AND att.attnum = {{ clid|qtLiteral }}
 {% endif %}
 {### To show system objects ###}
-{% if not show_sys_objects %}
+{% if not show_sys_objects and not has_oids %}
 AND att.attnum > 0
 {% endif %}
+{### To show oids in view data ###}
+{% if has_oids %}
+AND (att.attnum > 0 OR (att.attname = 'oid' AND att.attnum < 0))
+{% endif %}
 AND att.attisdropped IS FALSE
 ORDER BY att.attnum
diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py
index d360d91..7bf6c44 100644
--- a/web/pgadmin/tools/sqleditor/__init__.py
+++ b/web/pgadmin/tools/sqleditor/__init__.py
@@ -413,6 +413,9 @@ def start_view_data(trans_id):
 sql = trans_obj.get_sql()
 pk_names, primary_keys = trans_obj.get_primary_keys(default_conn)
 
+# Fetch OIDs status
+has_oids = trans_obj.has_oids(default_conn)
+
 # Fetch the applied filter.
 filter_applied = trans_obj.is_filter_applied()
 
@@ -424,6 +427,10 @@ def start_view_data(trans_id):
 
 # Store the primary keys to the session object
 session_obj['primary_keys'] = primary_keys
+
+# Store the OIDs status into session object
+session_obj['has_oids'] = has_oids
+
 update_session_grid_transaction(trans_id, session_obj)
 
 # Execute sql asynchronously
@@ -635,6 +642,8 @@ def poll(trans_id):
 types = {}
 client_primary_key = None
 rset = None
+has_oids = False
+oids = None
 
 # Check the transaction and connection status
 status, error_msg, conn, trans_obj, session_obj = check_transaction_status(trans_id)
@@ -660,6 +669,11 @@ def poll(trans_id):
 if 'primary_keys' in session_obj:
 primary_keys = session_obj['primary_keys']
 
+if 'has_oids' in session_obj:
+has_oids = session_obj['has_oids']
+if has_oids:
+oids = {'oid': 'oid'}
+
 # Fetch column information
 columns_info = conn.get_column_info()
 client_primary_key = generate_client_primary_key_name(
@@ -678,7 +692,8 @@ def poll(trans_id):
 
 SQL = render_template("/".join([template_path,
 'nodes.sql']),
-