[pgAdmin4][Patch]: Fixed #2487: get_preference() uses a synchronous AJAX request

2017-06-21 Thread Khushboo Vashi
Hi,

Please find attached patch to fix RM #2487: get_preference() uses a
synchronous AJAX request.

Introduced the client side caching for preferences to get rid of
synchronous AJAX request.


Thanks,
Khushboo
diff --git a/web/pgadmin/browser/templates/browser/js/browser.js b/web/pgadmin/browser/templates/browser/js/browser.js
index e8ea93d..a89c6dd 100644
--- a/web/pgadmin/browser/templates/browser/js/browser.js
+++ b/web/pgadmin/browser/templates/browser/js/browser.js
@@ -325,6 +325,9 @@ define(
   }
   obj.initialized = true;
 
+  // Cache preferences
+  obj.cache_preferences();
+
   // Initialize the Docker
   obj.docker = new wcDocker(
 '#dockerContainer', {
@@ -597,7 +600,7 @@ define(
 
 // This will hold preference data (Works as a cache object)
 // Here node will be a key and it's preference data will be value
-node_preference_data: {},
+preferences_cache: {},
 
 // Add menus of module/extension at appropriate menu
 add_menus: function(menus) {
@@ -749,24 +752,42 @@ define(
   }
 },
 
-get_preference: function (module, preference_name) {
-  var preference = null;
+// Get preference value from cache
+get_preference: function(module, preference) {
+  var self = this;
+  // If cache is not yet loaded then keep checking
+  if(_.size(self.preferences_cache) == 0) {
+var preference_data = setInterval(check_preference, 1000);
+
+function check_preference() {
+  if(_.size(self.preferences_cache) > 0) {
+clearInterval(preference_data);
+return _.findWhere(self.preferences_cache, {'module': module, 'name': preference});
+  }
+}
+  }
+  else {
+return _.findWhere(self.preferences_cache, {'module': module, 'name': preference});
+  }
+},
+
+// Get and cache the preferences
+cache_preferences: function () {
+  var self = this;
   $.ajax({
-async: false,
-url: url_for(
-  'preferences.get_by_name', {
-'module': module,
-'preference': preference_name
-  }),
+url: url_for('preferences.get_all'),
 success: function(res) {
-  preference = res;
+  self.preferences_cache = res;
 },
 error: function(xhr, status, error) {
-
+  try {
+var err = $.parseJSON(xhr.responseText);
+Alertify.alert(gettext('Preferences loading failed.'),
+  err.errormsg
+);
+  } catch (e) {}
 }
   });
-
-  return preference;
 },
 
 _findTreeChildNode: function(_i, _d, _o) {
diff --git a/web/pgadmin/preferences/__init__.py b/web/pgadmin/preferences/__init__.py
index 52f3f56..a59e26d 100644
--- a/web/pgadmin/preferences/__init__.py
+++ b/web/pgadmin/preferences/__init__.py
@@ -60,7 +60,7 @@ class PreferencesModule(PgAdminModule):
 Returns:
 list: a list of url endpoints exposed to the client.
 """
-return ['preferences.index', 'preferences.get_by_name']
+return ['preferences.index', 'preferences.get_by_name', 'preferences.get_all']
 
 
 blueprint = PreferencesModule(MODULE_NAME, __name__)
@@ -142,6 +142,27 @@ def preferences(module=None, preference=None):
 )
 
 
+@blueprint.route("/get_all", methods=["GET"], endpoint='get_all')
+@login_required
+def preferences_s():
+"""Fetch all preferences for caching."""
+# Load Preferences
+pref = Preferences.preferences()
+res = []
+
+for m in pref:
+if len(m['categories']):
+for c in m['categories']:
+for p in c['preferences']:
+p['module'] = m['label']
+res.append(p)
+
+return ajax_response(
+response=res,
+status=200
+)
+
+
 @blueprint.route("/", methods=["PUT"], endpoint="update")
 @login_required
 def save(pid):
diff --git a/web/pgadmin/preferences/templates/preferences/preferences.js b/web/pgadmin/preferences/templates/preferences/preferences.js
index 080bc38..8fc3cd8 100644
--- a/web/pgadmin/preferences/templates/preferences/preferences.js
+++ b/web/pgadmin/preferences/templates/preferences/preferences.js
@@ -389,6 +389,8 @@ define([
 
   if (e.button.text == gettext('OK')){
 preferences.updateAll();
+// Refresh preferences cache
+pgBrowser.cache_preferences();
   }
 },
 build: function() {
diff --git a/web/pgadmin/static/js/check_node_visibility.js b/web/pgadmin/static/js/check_node_visibility.js
index 987a395..e50c2f5 100644
--- a/web/pgadmin/static/js/check_node_visibility.js
+++ b/web/pgadmin/static/js/check_node_visibility.js
@@ -30,21 +30,12 @@ define(['jquery', 'underscore', 'underscore.string'],
 return true;
   }
 
-  // If we have already fetched preference earlier then pick
-  // it from our cache object
-  if (_.has(pgBrowser.no

Re: [pgAdmin4][Patch]: Fixed #2487: get_preference() uses a synchronous AJAX request

2017-06-22 Thread Khushboo Vashi
Hi,

Please find the attached fix for the same.

Thanks,
Khushboo

On Thu, Jun 22, 2017 at 2:18 PM, Dave Page  wrote:

> Hmm, yes - and it's not giving the normal error instructing the user
> to set the path, but another one: "Failed to load preference
> pg_bin_dir of module paths".
>
> Khushboo, can you investigate and fix ASAP please?
>
> On Thu, Jun 22, 2017 at 9:31 AM, Murtuza Zabuawala
>  wrote:
> > Hi Khusboo,
> >
> > Looks like given change have broken Backup, Restore, Import/Export &
> > Maintenance, even if I have binary path set it is throwing an error.
> >
> > --
> > Regards,
> > Murtuza Zabuawala
> > EnterpriseDB: http://www.enterprisedb.com
> > The Enterprise PostgreSQL Company
> >
> > On Wed, Jun 21, 2017 at 9:40 PM, Dave Page  wrote:
> >>
> >> Thanks, patch applied!
> >>
> >> On Wed, Jun 21, 2017 at 12:44 PM, Khushboo Vashi
> >>  wrote:
> >> > Hi,
> >> >
> >> > Please find attached patch to fix RM #2487: get_preference() uses a
> >> > synchronous AJAX request.
> >> >
> >> > Introduced the client side caching for preferences to get rid of
> >> > synchronous
> >> > AJAX request.
> >> >
> >> >
> >> > Thanks,
> >> > Khushboo
> >>
> >>
> >>
> >> --
> >> 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
>
diff --git a/web/pgadmin/preferences/__init__.py b/web/pgadmin/preferences/__init__.py
index a59e26d..e3af7d0 100644
--- a/web/pgadmin/preferences/__init__.py
+++ b/web/pgadmin/preferences/__init__.py
@@ -154,7 +154,7 @@ def preferences_s():
 if len(m['categories']):
 for c in m['categories']:
 for p in c['preferences']:
-p['module'] = m['label']
+p['module'] = m['name']
 res.append(p)
 
 return ajax_response(
diff --git a/web/pgadmin/utils/preferences.py b/web/pgadmin/utils/preferences.py
index 3148417..c7127c9 100644
--- a/web/pgadmin/utils/preferences.py
+++ b/web/pgadmin/utils/preferences.py
@@ -303,6 +303,7 @@ class Preferences(object):
 res = {
 'id': self.mid,
 'label': self.label or self.name,
+'name': self.name,
 'categories': []
 }
 for c in self.categories:


Re: [pgAdmin4][Patch]: Fixed #2487: get_preference() uses a synchronous AJAX request

2017-06-22 Thread Khushboo Vashi
Hi Dave,

One more fix for this module.

Thanks,
Khushboo

On Thu, Jun 22, 2017 at 4:49 PM, Dave Page  wrote:

> Thanks, patch applied.
>
> On Thu, Jun 22, 2017 at 11:06 AM, Khushboo Vashi
>  wrote:
> > Hi,
> >
> > Please find the attached fix for the same.
> >
> > Thanks,
> > Khushboo
> >
> > On Thu, Jun 22, 2017 at 2:18 PM, Dave Page  wrote:
> >>
> >> Hmm, yes - and it's not giving the normal error instructing the user
> >> to set the path, but another one: "Failed to load preference
> >> pg_bin_dir of module paths".
> >>
> >> Khushboo, can you investigate and fix ASAP please?
> >>
> >> On Thu, Jun 22, 2017 at 9:31 AM, Murtuza Zabuawala
> >>  wrote:
> >> > Hi Khusboo,
> >> >
> >> > Looks like given change have broken Backup, Restore, Import/Export &
> >> > Maintenance, even if I have binary path set it is throwing an error.
> >> >
> >> > --
> >> > Regards,
> >> > Murtuza Zabuawala
> >> > EnterpriseDB: http://www.enterprisedb.com
> >> > The Enterprise PostgreSQL Company
> >> >
> >> > On Wed, Jun 21, 2017 at 9:40 PM, Dave Page  wrote:
> >> >>
> >> >> Thanks, patch applied!
> >> >>
> >> >> On Wed, Jun 21, 2017 at 12:44 PM, Khushboo Vashi
> >> >>  wrote:
> >> >> > Hi,
> >> >> >
> >> >> > Please find attached patch to fix RM #2487: get_preference() uses a
> >> >> > synchronous AJAX request.
> >> >> >
> >> >> > Introduced the client side caching for preferences to get rid of
> >> >> > synchronous
> >> >> > AJAX request.
> >> >> >
> >> >> >
> >> >> > Thanks,
> >> >> > Khushboo
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> 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
> >
> >
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/static/js/check_node_visibility.js b/web/pgadmin/static/js/check_node_visibility.js
index e50c2f5..ddd1990 100644
--- a/web/pgadmin/static/js/check_node_visibility.js
+++ b/web/pgadmin/static/js/check_node_visibility.js
@@ -30,7 +30,7 @@ define(['jquery', 'underscore', 'underscore.string'],
 return true;
   }
 
-  preference = pgBrowser.get_preference("Browser", 'show_node_'+node_type);
+  preference = pgBrowser.get_preference("browser", 'show_node_'+node_type);
 
   if (preference) {
 return preference.value


[pgAdmin4][Patch]: Feature #2506 - Allow the dashboard panel to be closed

2017-06-25 Thread Khushboo Vashi
Hi,

Please find the attached patch for the feature #2506: Allow the dashboard
panel to be closed.

Thanks,
Khushboo
diff --git a/web/pgadmin/browser/static/js/panel.js b/web/pgadmin/browser/static/js/panel.js
index 71d2c68..bfa2e32 100644
--- a/web/pgadmin/browser/static/js/panel.js
+++ b/web/pgadmin/browser/static/js/panel.js
@@ -7,7 +7,8 @@ function(_, pgAdmin) {
   pgAdmin.Browser.Panel = function(options) {
 var defaults = [
   'name', 'title', 'width', 'height', 'showTitle', 'isCloseable',
-  'isPrivate', 'content', 'icon', 'events', 'onCreate', 'elContainer'
+  'isPrivate', 'content', 'icon', 'events', 'onCreate', 'elContainer',
+  'canHide', 'limit'
 ];
 _.extend(this, _.pick(options, defaults));
   }
@@ -25,12 +26,14 @@ function(_, pgAdmin) {
 panel: null,
 onCreate: null,
 elContainer: false,
+limit: null,
 load: function(docker, title) {
   var that = this;
   if (!that.panel) {
 docker.registerPanelType(that.name, {
   title: that.title,
   isPrivate: that.isPrivate,
+  limit: that.limit,
   onCreate: function(myPanel) {
 $(myPanel).data('pgAdminName', that.name);
 myPanel.initSize(that.width, that.height);
@@ -85,6 +88,25 @@ function(_, pgAdmin) {
   });
   that.resizedContainer.apply(myPanel);
 }
+
+// Bind events only if they are configurable
+if (that.canHide) {
+  myPanel.on(wcDocker.EVENT.CLOSED, function() {
+ pgBrowser.save_current_layout(pgBrowser);
+  });
+  myPanel.on(wcDocker.EVENT.VISIBILITY_CHANGED, function() {
+ if (pgBrowser.tree) {
+   pgBrowser.save_current_layout(pgBrowser);
+   var selectedNode = pgBrowser.tree.selected();
+   // Discontinue this event after first time visible
+   myPanel.off(wcDocker.EVENT.VISIBILITY_CHANGED);
+   // Explicitly trigger tree selected event when we add the tab.
+   pgBrowser.Events.trigger('pgadmin-browser:tree:selected', selectedNode,
+pgBrowser.tree.itemData(selectedNode), pgBrowser.Node);
+ }
+
+  });
+}
   }
 });
   }
diff --git a/web/pgadmin/browser/templates/browser/js/browser.js b/web/pgadmin/browser/templates/browser/js/browser.js
index 4494e7a..4588128 100644
--- a/web/pgadmin/browser/templates/browser/js/browser.js
+++ b/web/pgadmin/browser/templates/browser/js/browser.js
@@ -177,7 +177,9 @@ define(
 showTitle: {% if panel_item.showTitle %}true{% else %}false{% endif %},
 isCloseable: {% if panel_item.isCloseable %}true{% else %}false{% endif %},
 isPrivate: {% if panel_item.isPrivate %}true{% else %}false{% endif %},
-content: '{{ panel_item.content }}'{% if panel_item.events is not none %},
+content: '{{ panel_item.content }}',
+canHide: {% if panel_item.canHide %}true{% else %}false{% endif %}{% if panel_item.limit is not none %},
+limit: {{ panel_item.limit }}{% endif %}{% if panel_item.events is not none %},
 events: {{ panel_item.events }} {% endif %}
   }){% endif %}{% endfor %}
 },
@@ -364,15 +366,17 @@ define(
 
 // Listen to panel attach/detach event so that last layout will be remembered
 _.each(obj.panels, function(panel, name) {
-  panel.panel.on(wcDocker.EVENT.ATTACHED, function() {
-obj.save_current_layout(obj);
-  });
-  panel.panel.on(wcDocker.EVENT.DETACHED, function() {
-obj.save_current_layout(obj);
-  });
-  panel.panel.on(wcDocker.EVENT.MOVE_ENDED, function() {
-obj.save_current_layout(obj);
-  });
+  if (panel.panel) {
+panel.panel.on(wcDocker.EVENT.ATTACHED, function() {
+  obj.save_current_layout(obj);
+});
+panel.panel.on(wcDocker.EVENT.DETACHED, function() {
+  obj.save_current_layout(obj);
+});
+panel.panel.on(wcDocker.EVENT.MOVE_ENDED, function() {
+  obj.save_current_layout(obj);
+});
+  }
 });
   }
 
diff --git a/web/pgadmin/dashboard/__init__.py b/web/pgadmin/dashboard/__init__.py
index a95ba53..8f813d7 100644
--- a/web/pgadmin/dashboard/__init__.py
+++ b/web/pgadmin/dashboard/__init__.py
@@ -58,9 +58,11 @@ class DashboardModule(PgAdminModule):
 title=gettext('Dashboard'),
 icon='fa fa-tachometer',
 content='',
-isCloseable=False,
-isPrivate=True,
-isIframe=False)
+isCloseable=True,
+isPrivate=False,
+limit=1,
+isIframe=False,
+canHide=True)
 ]
 
 def register_preferences(self):
diff --git a/web/pg

[pgAdmin4][patch]: Fixed RM #2507 : REVOKE privileges do not display in SQL tab for the function

2017-06-26 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix the RM #2507: REVOKE privileges do
not display in SQL tab for the function

Thanks,
Khushboo
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
index 77f21b8..e3277e3 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
@@ -988,6 +988,9 @@ class FunctionView(PGChildNodeView, DataTypeReader):
 if 'acl' in resp_data:
 resp_data['acl'] = parse_priv_to_db(resp_data['acl'], ['X'])
 
+# Check Revoke all for public
+resp_data['revoke_all'] = self._set_revoke_all(resp_data['acl'])
+
 # Generate sql for "SQL panel"
 # func_def is procedure signature with default arguments
 # query_for - To distinguish the type of call
@@ -1008,6 +1011,9 @@ class FunctionView(PGChildNodeView, DataTypeReader):
 if 'acl' in resp_data:
 resp_data['acl'] = parse_priv_to_db(resp_data['acl'], ['X'])
 
+# Check Revoke all for public
+resp_data['revoke_all'] = self._set_revoke_all(resp_data['acl'])
+
 SQL = render_template("/".join([self.sql_template_path,
 'get_definition.sql']
), data=resp_data,
@@ -1215,6 +1221,9 @@ class FunctionView(PGChildNodeView, DataTypeReader):
 if 'acl' in data:
 data['acl'] = parse_priv_to_db(data['acl'], ["X"])
 
+# Check Revoke all for public
+data['revoke_all'] = self._set_revoke_all(data['acl'])
+
 args = u''
 args_without_name = []
 cnt = 1
@@ -1325,6 +1334,19 @@ class FunctionView(PGChildNodeView, DataTypeReader):
 
 return schema_name
 
+def _set_revoke_all(self, privileges):
+"""
+Check whether the function requires REVOKE statement
+for PUBLIC or not.
+"""
+revoke_all = True if len(privileges) > 0 else False
+for p in privileges:
+if p['grantee'] == 'PUBLIC':
+revoke_all = False
+break;
+
+return revoke_all
+
 @check_precondition
 def dependents(self, gid, sid, did, scid, fnid):
 """
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/create.sql
index 8676b33..7300fd8 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/create.sql
@@ -47,6 +47,10 @@ ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args
 {{ PRIVILEGE.SET(conn, "FUNCTION", p.grantee, data.name, p.without_grant, p.with_grant, data.pronamespace, data.func_args_without)}}
 {% endfor -%}
 {% endif -%}
+{% if data.revoke_all %}
+
+{{ PRIVILEGE.UNSETALL(conn, "FUNCTION", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}}
+{% endif %}
 {% if data.description %}
 
 COMMENT ON FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}})
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/create.sql
index 74c09c3..0f7f4f0 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/create.sql
@@ -46,6 +46,10 @@ ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args
 
 {{ PRIVILEGE.SET(conn, "FUNCTION", p.grantee, data.name, p.without_grant, p.with_grant, data.pronamespace, data.func_args_without)}}
 {% endfor %}{% endif %}
+{% if data.revoke_all %}
+
+{{ PRIVILEGE.UNSETALL(conn, "FUNCTION", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}}
+{% endif %}
 {% if data.description %}
 
 COMMENT ON FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}})
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.6_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.6_plus/create.sql
index 09022fd..0e2495d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.6_plu

[pgAdmin4][Patch]: Fixed RM #1920 - [Web Based] Unexpected behaviour observed when connect server with save password option.

2017-06-26 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix RM #1920 -  [Web Based] Unexpected
behaviour observed when connect server with save password option.

Thanks,
Khushboo
diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py
index d88363a..0634e3f 100644
--- a/web/pgadmin/browser/server_groups/servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/__init__.py
@@ -746,6 +746,8 @@ class ServerNode(PGChildNodeView):
 _=gettext
 )
 )
+else:
+password = conn_passwd or server.password
 else:
 password = data['password'] if 'password' in data else None
 save_password = \


Re: [pgAdmin4][Patch]: Feature #2506 - Allow the dashboard panel to be closed

2017-06-26 Thread Khushboo Vashi
Hi,

Please find the attached updated patch.

Thanks,
Khushboo

On Mon, Jun 26, 2017 at 5:08 PM, Dave Page  wrote:

> Hi
>
> Looks good, except that when I close the dashboard panel, it continues
> to run the queries to update the graphs until I change the selected
> treeview node. Can we stop it immediately?
>
> Fixed

> On Mon, Jun 26, 2017 at 1:56 AM, Khushboo Vashi
>  wrote:
> > Hi,
> >
> > Please find the attached patch for the feature #2506: Allow the dashboard
> > panel to be closed.
> >
> > Thanks,
> > Khushboo
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/browser/static/js/panel.js b/web/pgadmin/browser/static/js/panel.js
index 71d2c68..ce21f0d 100644
--- a/web/pgadmin/browser/static/js/panel.js
+++ b/web/pgadmin/browser/static/js/panel.js
@@ -7,7 +7,8 @@ function(_, pgAdmin) {
   pgAdmin.Browser.Panel = function(options) {
 var defaults = [
   'name', 'title', 'width', 'height', 'showTitle', 'isCloseable',
-  'isPrivate', 'content', 'icon', 'events', 'onCreate', 'elContainer'
+  'isPrivate', 'content', 'icon', 'events', 'onCreate', 'elContainer',
+  'canHide', 'limit'
 ];
 _.extend(this, _.pick(options, defaults));
   }
@@ -25,12 +26,14 @@ function(_, pgAdmin) {
 panel: null,
 onCreate: null,
 elContainer: false,
+limit: null,
 load: function(docker, title) {
   var that = this;
   if (!that.panel) {
 docker.registerPanelType(that.name, {
   title: that.title,
   isPrivate: that.isPrivate,
+  limit: that.limit,
   onCreate: function(myPanel) {
 $(myPanel).data('pgAdminName', that.name);
 myPanel.initSize(that.width, that.height);
@@ -85,6 +88,14 @@ function(_, pgAdmin) {
   });
   that.resizedContainer.apply(myPanel);
 }
+
+// Bind events only if they are configurable
+if (that.canHide) {
+  _.each([wcDocker.EVENT.CLOSED, wcDocker.EVENT.VISIBILITY_CHANGED],
+function(ev) {
+  myPanel.on(ev, that.handleVisibility.bind(myPanel, ev));
+});
+}
   }
 });
   }
@@ -134,7 +145,32 @@ function(_, pgAdmin) {
   100
 );
   }
+},
+handleVisibility: function(eventName) {
+  // Currently this function only works with dashboard panel but
+  // as per need it can be extended
+  if (this._type != 'dashboard')
+return;
+
+  if (eventName == 'panelClosed') {
+pgBrowser.save_current_layout(pgBrowser);
+pgAdmin.Dashboard.toggleVisibility(false);
+  }
+  else if (eventName == 'panelVisibilityChanged') {
+if (pgBrowser.tree) {
+  pgBrowser.save_current_layout(pgBrowser);
+  var selectedNode = pgBrowser.tree.selected();
+  // Discontinue this event after first time visible
+  this.off(wcDocker.EVENT.VISIBILITY_CHANGED);
+  if (!_.isUndefined(pgAdmin.Dashboard))
+pgAdmin.Dashboard.toggleVisibility(true);
+  // Explicitly trigger tree selected event when we add the tab.
+  pgBrowser.Events.trigger('pgadmin-browser:tree:selected', selectedNode,
+  pgBrowser.tree.itemData(selectedNode), pgBrowser.Node);
+}
+  }
 }
+
   });
 
   return pgAdmin.Browser.Panel;
diff --git a/web/pgadmin/browser/templates/browser/js/browser.js b/web/pgadmin/browser/templates/browser/js/browser.js
index 4494e7a..4588128 100644
--- a/web/pgadmin/browser/templates/browser/js/browser.js
+++ b/web/pgadmin/browser/templates/browser/js/browser.js
@@ -177,7 +177,9 @@ define(
 showTitle: {% if panel_item.showTitle %}true{% else %}false{% endif %},
 isCloseable: {% if panel_item.isCloseable %}true{% else %}false{% endif %},
 isPrivate: {% if panel_item.isPrivate %}true{% else %}false{% endif %},
-content: '{{ panel_item.content }}'{% if panel_item.events is not none %},
+content: '{{ panel_item.content }}',
+canHide: {% if panel_item.canHide %}true{% else %}false{% endif %}{% if panel_item.limit is not none %},
+limit: {{ panel_item.limit }}{% endif %}{% if panel_item.events is not none %},
 events: {{ panel_item.events }} {% endif %}
   }){% endif %}{% endfor %}
 },
@@ -364,15 +366,17 @@ define(
 
 // Listen to panel attach/detach event so that last layout will be remembered
 _.each(obj.panels, fu

Re: crypto.py bug on server add form (button save) with python 3.5 - Can't convert 'bytes' object to str implicitly

2017-06-27 Thread Khushboo Vashi
Hi,

Can you send the patch for the same. I think this is the valid fix.

Thanks,
Khushboo

On Tue, Jun 27, 2017 at 3:02 PM, Ladislav Jech  wrote:

> I am running on following Gentoo system with Python 3.5 as default
> (although i have 2.7 and 3.4 available to switch as well).
>
> I compiled from source code via github:
> commit 15cb9fc35b41736a331a452b9303a79e8f13ee36 (HEAD -> master,
> origin/master, origin/HEAD)
>
> The error appears when I want to click on Save while adding new server to
> the list, I put few lines into the code to detect the times:
> 2017-06-27 13:21:48,329: DEBUG pgadmin: Not running under the desktop
> runtime, port: 5050
> Starting pgAdmin 4. Please navigate to http://127.0.0.1:5050 in your
> browser.
> str var python type is 
> str var object's type is str
> padding_string var python type is 
> padding_string var object's type is bytes
> 2017-06-27 13:21:53,028: ERROR pgadmin: Can't convert 'bytes' object to
> str implicitly
> Traceback (most recent call last):
>   File "/home/zangetsu/devel/tmp/pgadmin4/web/pgadmin/browser/
> server_groups/servers/__init__.py", line 619, in create
> password = encrypt(password, current_user.password)
>   File "/home/zangetsu/devel/tmp/pgadmin4/web/pgadmin/utils/crypto.py",
> line 31, in encrypt
> cipher = AES.new(pad(key), AES.MODE_CFB, iv)
>   File "/home/zangetsu/devel/tmp/pgadmin4/web/pgadmin/utils/crypto.py",
> line 80, in pad
> return str + ((32 - len(str) % 32) * padding_string)
> TypeError: Can't convert 'bytes' object to str implicitly
> 2017-06-27 13:21:53,031: INFO werkzeug: 127.0.0.1 - - [27/Jun/2017
> 13:21:53] "POST /browser/server/obj/2/ HTTP/1.1" 410 -
> 2017-06-27 13:22:49,936: INFO werkzeug: * Detected change in
> '/home/zangetsu/devel/tmp/pgadmin4/web/pgadmin/utils/crypto.py', reloading
> 2017-06-27 13:22:50,138: INFO werkzeug: * Restarting with reloader
>
> So this is the error:
> Can't convert 'bytes' object to str implicitly
>
> To fix this on Python 3.5 I simply changed in 
> pgadmin4/web/pgadmin/utils/crypto.py
> file this line:
> return str + ((32 - len(str) % 32) * padding_string)
> to
> return str + ((32 - len(str) % 32) * padding_string.decode())
>
> Another solution could be to change whole str into bytes. Not sure what is
> better, but now it works.
>


Re: [pgadmin-hackers] Re: Server side cursor limitations for on demand loading of data in query tool [RM2137] [pgAdmin4]

2017-06-27 Thread Khushboo Vashi
On 27 Jun 2017 18:33, "Dave Page"  wrote:

Thanks - patch committed!

Awsome job :-)

Gr8. Finally no more rebase request for Harshal. :)

On Tue, Jun 27, 2017 at 3:26 AM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> Please find rebased patch.
>
> --
> *Harshal Dhumal*
> *Sr. Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Mon, Jun 26, 2017 at 5:24 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> yes i'm working on that only :)
>>
>>
>> --
>> *Harshal Dhumal*
>> *Sr. Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Mon, Jun 26, 2017 at 5:22 PM, Dave Page  wrote:
>>
>>> I'm sorry, it needs rebasing again. If you can do it quickly, I'll
>>> make sure it's the next patch I work on in that area.
>>>
>>> Thanks.
>>>
>>> On Mon, Jun 26, 2017 at 5:16 AM, Harshal Dhumal
>>>  wrote:
>>> > Hi Dave,
>>> >
>>> > Please find updated rebased patch for RM2137
>>> >
>>> > On Fri, Jun 23, 2017 at 9:00 PM, Dave Page  wrote:
>>> >>
>>> >> Hi Harshal,
>>> >>
>>> >> When can we expect an updated version of this patch? I think it's
>>> >> important to get this into the next release.
>>> >>
>>> >> Thanks!
>>> >>
>>> >> On Fri, Jun 16, 2017 at 10:55 AM, Dave Page 
>>> wrote:
>>> >> > Hi,
>>> >> >
>>> >> > That's better - the failures are far less random now :-). I got the
>>> >> > following two though, on both PG and EPAS 9.5:
>>> >> >
>>> >> > 
>>> ==
>>> >> > ERROR: runTest
>>> >> > (pgadmin.feature_tests.query_tool_tests.QueryToolFeatureTest)
>>> >> > Query tool feature test
>>> >> > 
>>> --
>>> >> > Traceback (most recent call last):
>>> >> >   File
>>> >> > "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_t
>>> ool_tests.py",
>>> >> > line 95, in runTest
>>> >> > self._query_tool_explain_analyze_buffers()
>>> >> >   File
>>> >> > "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_t
>>> ool_tests.py",
>>> >> > line 443, in _query_tool_explain_analyze_buffers
>>> >> > canvas.find_element_by_xpath("//*[contains(string(), 'Shared
>>> Read
>>> >> > Blocks')]")
>>> >> >   File
>>> >> > "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa
>>> ges/selenium/webdriver/remote/webelement.py",
>>> >> > line 260, in find_element_by_xpath
>>> >> > return self.find_element(by=By.XPATH, value=xpath)
>>> >> >   File
>>> >> > "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa
>>> ges/selenium/webdriver/remote/webelement.py",
>>> >> > line 508, in find_element
>>> >> > {"using": by, "value": value})['value']
>>> >> >   File
>>> >> > "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa
>>> ges/selenium/webdriver/remote/webelement.py",
>>> >> > line 491, in _execute
>>> >> > return self._parent.execute(command, params)
>>> >> >   File
>>> >> > "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa
>>> ges/selenium/webdriver/remote/webdriver.py",
>>> >> > line 238, in execute
>>> >> > self.error_handler.check_response(response)
>>> >> >   File
>>> >> > "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa
>>> ges/selenium/webdriver/remote/errorhandler.py",
>>> >> > line 193, in check_response
>>> >> > raise exception_class(message, screen, stacktrace)
>>> >> > NoSuchElementException: Message: no such element: Unable to locate
>>> >> > element: {"method":"xpath","selector":"//*[contains(string(),
>>> 'Shared
>>> >> > Read Blocks')]"}
>>> >> >   (Session info: chrome=58.0.3029.110)
>>> >> >   (Driver info: chromedriver=2.29.461585
>>> >> > (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b),platform=Mac OS X
>>> 10.12.3
>>> >> > x86_64)
>>> >> >
>>> >> >
>>> >> > 
>>> ==
>>> >> > ERROR: runTest
>>> >> > (pgadmin.feature_tests.view_data_dml_queries.CheckForViewDataTest)
>>> >> > Validate Insert, Update operations in View data with given test data
>>> >> > 
>>> --
>>> >> > Traceback (most recent call last):
>>> >> >   File
>>> >> > "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/view_da
>>> ta_dml_queries.py",
>>> >> > line 104, in runTest
>>> >> > self._add_row()
>>> >> >   File
>>> >> > "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/view_da
>>> ta_dml_queries.py",
>>> >> > line 255, in _add_row
>>> >> > self._update_cell(cell_xpath, config_data[str(idx)])
>>> >> >   File
>>> >> > "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/view_da
>>> ta_dml_queries.py",
>>> >> > line 164, in _update_cell
>>> >> > cell_el = self.page.find_by_xpath(xpath)
>>> >> >   File
>>> >> > "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgad
>>> min_page.py",
>>> >> > line 122, in find_by_xpath
>>> >> > return self.wa

Re: [pgadmin-hackers][patch] History Detail Pane

2017-06-27 Thread Khushboo Vashi
On Tue, Jun 27, 2017 at 8:26 PM, Dave Page  wrote:

> Thanks - patch applied (just in time for Raffi's & my talk)!
>
> The history tab looks really very good.

> On Tue, Jun 27, 2017 at 10:05 AM, Joao Pedro De Almeida Pereira <
> jdealmeidapere...@pivotal.io> wrote:
>
>> Yep,
>> please see attached
>>
>> On Tue, Jun 27, 2017 at 9:11 AM, Dave Page  wrote:
>>
>>> Can you rebase this patch please?
>>>
>>> Thankfully I think we're basically at the end of our changes in this
>>> area!
>>>
>>> On Mon, Jun 26, 2017 at 10:08 AM, Joao Pedro De Almeida Pereira <
>>> jdealmeidapere...@pivotal.io> wrote:
>>>
 Hi Surinder,

 You can find our answers inline and attached the patch with the change
 of scrolls from "scroll" to "auto"

 On Mon, Jun 26, 2017 at 4:47 AM, Surinder Kumar <
 surinder.ku...@enterprisedb.com> wrote:

> Hi
> On Fri, Jun 23, 2017 at 11:39 PM, George Gelashvili <
> ggelashv...@pivotal.io> wrote:
>
>> On Fri, Jun 23, 2017 at 11:24 AM, Surinder Kumar <
>> surinder.ku...@enterprisedb.com> wrote:
>>
>>> Hi
>>>
>>> Review comments:
>>>
>>> ​1. ​
>>> Can we set "message"(in message detail) style property scroll to
>>> ​'​
>>> auto
>>> ​'​
>>>  instead of
>>> ​'​
>>> scroll
>>> ​'​
>>>  ?
>>>
>>
>> Could you elaborate why 'auto' is what we want?
>>
> ​The scroll bars should appear only when content is beyond the
> width/height of container.​ Now with 'scroll', the border layout around
> container appears irrespective of content width/height. If we set 'auto',
> it won't appear.
>

 We changed that in the attached patch. The scroll bars will now appear
 when the text exceeds the window.


>> ​2. CSS property flex is supported for IE >= 9 as per reference
 
 ​. I tested this patch on IE and layout is broken.​

  Anyways IE-9/10 are outdated and no longer supported by
>>> Microsoft, the only supported browsers are IE-11+.
>>>
>>
>> Does this patch work in supported IEs?
>>
> ​I use Windows 7 which has IE9,10, but if we can fix it for IE9,10 we
> should fix. Majority of people are still using IE9,10.​
>

 We based almost 100% of this patch on Flexbox. In order to use another
 structure, we would have to rewrite the html blocks (the majority of the
 UI). If the community believes that is important to keep giving support to
 Browsers that are no longer supported then we can use a library like
 modernizr  to try to support all the existing
 browser. Nevertheless we believe that this should be done in a future 
 patch.


>> 3. ​Can the CSS styles in ‘history_detail_message.jsx’ moved out in
>>> a separate stylesheet file
>>> ​ as inline styles in html are never recommended.​
>>>
>>
>> We've been trying to use inline styles rather than classes for our
>> react jsx code, as this keeps element behavior declarative. This includes
>> both functionality and appearance.
>> So far the pattern has been to extract styles used by more than one
>> component to jsx/styles.
>>
> ​Can we use classes and then write css around classes thus preserving
> element behaviour declarative ?​
>

 We believe that this should be a conversation to have next Friday in
 the Hackers Community Forum. In the meanwhile we hope this is not a blocker
 to the merge of this patch.


>
>> ​4. In 'codemirror.jsx', setInterval is used to bind
>>> hydrateWhenBecomesVisible function after every 100ms. Can setTimeout ​be
>>> used as it needs to bind only once ?
>>> Also if setInterval is used, in componentWillUnmount
>>> clearInterval(...) should be implemented.
>>>
>>
>> We actually need to poll, as otherwise the codemirror element will
>> render with its last state (so, incorrect query history)
>>
>> 5. The text like 'Rows Affected' or 'Duration' should be wrapped in
>>> 'gettext' for translation?
>>
>>
>> We are working on using translations in React components. This needs
>> additional effort and we'll send this in a separate patch.
>>
>> Thanks
>> Shruti and George
>>
>
>
 Thanks,
 Joao and Shruti

>>>
>>>
>>>
>>> --
>>> 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
>


Re: [pgAdmin4][Patch]: Feature #2506 - Allow the dashboard panel to be closed

2017-06-27 Thread Khushboo Vashi
Hi Dave,

On Tue, Jun 27, 2017 at 8:08 PM, Dave Page  wrote:

> Hi
>
> I've had to revert this. Whilst it seems to work, after showing/hiding the
> dashboard, I later find that when I completely reload the app, it fails,
> leaving just the object menu present. I haven't come up with a concrete
> case to reproduce it. In the console, I see:
>
>
> wcDocker.min.js:38 Uncaught TypeError: Cannot read property '__save' of
> null at e.save (wcDocker.min.js:38) at Object.save_current_layout (
> browser.js:340) at e.handleVisibility (panel.js:156) at e.__trigger (
> wcDocker.min.js:34) at e.trigger (wcDocker.min.js:38) at e.clear (
> wcDocker.min.js:38) at Object.init (browser.js:386) at (index):278 at
> Object.execCb (require.min.js:29) at Z.check (require.min.js:18)
>
> I couldn't reproduce this issue. I have tried many things to reproduce it
but not succeeded. I also switched server_mode but no luck.
I think there should be any specific condition that fails this but have no
clue.

I have rebased this patch and attached.


> On Tue, Jun 27, 2017 at 9:21 AM, Dave Page  wrote:
>
>> Thanks, patch applied.
>>
>> On Tue, Jun 27, 2017 at 2:58 AM, Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> Please find the attached updated patch.
>>>
>>> Thanks,
>>> Khushboo
>>>
>>> On Mon, Jun 26, 2017 at 5:08 PM, Dave Page  wrote:
>>>
>>>> Hi
>>>>
>>>> Looks good, except that when I close the dashboard panel, it continues
>>>> to run the queries to update the graphs until I change the selected
>>>> treeview node. Can we stop it immediately?
>>>>
>>>> Fixed
>>>
>>>> On Mon, Jun 26, 2017 at 1:56 AM, Khushboo Vashi
>>>>  wrote:
>>>> > Hi,
>>>> >
>>>> > Please find the attached patch for the feature #2506: Allow the
>>>> dashboard
>>>> > panel to be closed.
>>>> >
>>>> > Thanks,
>>>> > Khushboo
>>>>
>>>>
>>>>
>>>> --
>>>> 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
>>
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/browser/static/js/panel.js b/web/pgadmin/browser/static/js/panel.js
index 71d2c68..ce21f0d 100644
--- a/web/pgadmin/browser/static/js/panel.js
+++ b/web/pgadmin/browser/static/js/panel.js
@@ -7,7 +7,8 @@ function(_, pgAdmin) {
   pgAdmin.Browser.Panel = function(options) {
 var defaults = [
   'name', 'title', 'width', 'height', 'showTitle', 'isCloseable',
-  'isPrivate', 'content', 'icon', 'events', 'onCreate', 'elContainer'
+  'isPrivate', 'content', 'icon', 'events', 'onCreate', 'elContainer',
+  'canHide', 'limit'
 ];
 _.extend(this, _.pick(options, defaults));
   }
@@ -25,12 +26,14 @@ function(_, pgAdmin) {
 panel: null,
 onCreate: null,
 elContainer: false,
+limit: null,
 load: function(docker, title) {
   var that = this;
   if (!that.panel) {
 docker.registerPanelType(that.name, {
   title: that.title,
   isPrivate: that.isPrivate,
+  limit: that.limit,
   onCreate: function(myPanel) {
 $(myPanel).data('pgAdminName', that.name);
 myPanel.initSize(that.width, that.height);
@@ -85,6 +88,14 @@ function(_, pgAdmin) {
   });
   that.resizedContainer.apply(myPanel);
 }
+
+// Bind events only if they are configurable
+if (that.canHide) {
+  _.each([wcDocker.EVENT.CLOSED, wcDocker.EVENT.VISIBILITY_CHANGED],
+function(ev) {
+  myPanel.on(ev, that.handleVisibility.bind(myPanel, ev));
+});
+}
   }
 });
   }
@@ -134,7 +145,32 @@ function(_, pgAdmin) {
   100
 );
   }
+},
+handleVisibility:

Re: crypto.py bug on server add form (button save) with python 3.5 - Can't convert 'bytes' object to str implicitly

2017-06-27 Thread Khushboo Vashi
Hi,

Please find the attached patch which will fix the password
encryption/decryption for python3.
I have modified the fix suggested by Ladislav to work with both python2 and
python3.

Thanks,
Khushboo

On Tue, Jun 27, 2017 at 4:41 PM, Ladislav Jech  wrote:

> Hi,
> It will be good if you support fully github or any GIT repository for
> managing pull requests. Is there any or you wan't me to generate *.patch
> file? I am new to pgadmin 4, so not sure how this works. Let me know.
> Ladislav
>
> 2017-06-27 11:52 GMT+02:00 Khushboo Vashi  >:
>
>> Hi,
>>
>> Can you send the patch for the same. I think this is the valid fix.
>>
>> Thanks,
>> Khushboo
>>
>> On Tue, Jun 27, 2017 at 3:02 PM, Ladislav Jech 
>> wrote:
>>
>>> I am running on following Gentoo system with Python 3.5 as default
>>> (although i have 2.7 and 3.4 available to switch as well).
>>>
>>> I compiled from source code via github:
>>> commit 15cb9fc35b41736a331a452b9303a79e8f13ee36 (HEAD -> master,
>>> origin/master, origin/HEAD)
>>>
>>> The error appears when I want to click on Save while adding new server
>>> to the list, I put few lines into the code to detect the times:
>>> 2017-06-27 13:21:48,329: DEBUG pgadmin: Not running under the desktop
>>> runtime, port: 5050
>>> Starting pgAdmin 4. Please navigate to http://127.0.0.1:5050 in your
>>> browser.
>>> str var python type is 
>>> str var object's type is str
>>> padding_string var python type is 
>>> padding_string var object's type is bytes
>>> 2017-06-27 13:21:53,028: ERROR pgadmin: Can't convert 'bytes' object to
>>> str implicitly
>>> Traceback (most recent call last):
>>>   File 
>>> "/home/zangetsu/devel/tmp/pgadmin4/web/pgadmin/browser/server_groups/servers/__init__.py",
>>> line 619, in create
>>> password = encrypt(password, current_user.password)
>>>   File "/home/zangetsu/devel/tmp/pgadmin4/web/pgadmin/utils/crypto.py",
>>> line 31, in encrypt
>>> cipher = AES.new(pad(key), AES.MODE_CFB, iv)
>>>   File "/home/zangetsu/devel/tmp/pgadmin4/web/pgadmin/utils/crypto.py",
>>> line 80, in pad
>>> return str + ((32 - len(str) % 32) * padding_string)
>>> TypeError: Can't convert 'bytes' object to str implicitly
>>> 2017-06-27 13:21:53,031: INFO werkzeug: 127.0.0.1 - - [27/Jun/2017
>>> 13:21:53] "POST /browser/server/obj/2/ HTTP/1.1" 410 -
>>> 2017-06-27 13:22:49,936: INFO werkzeug: * Detected change in
>>> '/home/zangetsu/devel/tmp/pgadmin4/web/pgadmin/utils/crypto.py',
>>> reloading
>>> 2017-06-27 13:22:50,138: INFO werkzeug: * Restarting with reloader
>>>
>>> So this is the error:
>>> Can't convert 'bytes' object to str implicitly
>>>
>>> To fix this on Python 3.5 I simply changed in
>>> pgadmin4/web/pgadmin/utils/crypto.py file this line:
>>> return str + ((32 - len(str) % 32) * padding_string)
>>> to
>>> return str + ((32 - len(str) % 32) * padding_string.decode())
>>>
>>> Another solution could be to change whole str into bytes. Not sure what
>>> is better, but now it works.
>>>
>>
>>
>
diff --git a/web/pgadmin/utils/crypto.py b/web/pgadmin/utils/crypto.py
index 5d8bb50..1c16e6d 100644
--- a/web/pgadmin/utils/crypto.py
+++ b/web/pgadmin/utils/crypto.py
@@ -71,6 +71,10 @@ def pad(str):
 if str_len == 16 or str_len == 24 or str_len == 32:
 return str
 
+# Convert bytes to string (python3)
+if not hasattr(str, 'decode'):
+padding_string = padding_string.decode()
+
 # Add padding to make key 32 bytes long
 return str + ((32 - len(str) % 32) * padding_string)
 


[pgAdmin4][Patch]: Fixed RM #2489: Copy from the results grid is extremely slow and fails with large datasets

2017-06-28 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix the RM #2489: Copy from the results
grid is extremely slow and fails with large datasets.

Thanks,
Khushboo
diff --git a/web/pgadmin/static/js/selection/clipboard.js b/web/pgadmin/static/js/selection/clipboard.js
index 9794ae7..844e20c 100644
--- a/web/pgadmin/static/js/selection/clipboard.js
+++ b/web/pgadmin/static/js/selection/clipboard.js
@@ -46,15 +46,17 @@ define(['sources/gettext', 'alertify'], function (gettext, alertify) {
 
   textArea.select();
 
-  try {
-document.execCommand('copy');
-  } catch (err) {
-alertify.alert(
-  gettext('Error'),
-  gettext('Oops, unable to copy to clipboard'));
-  }
-
-  document.body.removeChild(textArea);
+  $(textArea).on('select', function(){
+try {
+  document.execCommand('copy');
+} catch (err) {
+  alertify.alert(
+gettext('Error'),
+gettext('Oops, unable to copy to clipboard'));
+}
+
+document.body.removeChild(textArea);
+  });
 },
   };
   return clipboard;


Re: [pgAdmin4][Patch]: Feature #2506 - Allow the dashboard panel to be closed

2017-06-29 Thread Khushboo Vashi
Hi,

Please find the attached updated patch.

Thanks,
Khushboo

On Wed, Jun 28, 2017 at 7:08 PM, Dave Page  wrote:

> Hi
>
> On Tue, Jun 27, 2017 at 11:54 PM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> On Tue, Jun 27, 2017 at 8:08 PM, Dave Page  wrote:
>>
>>> Hi
>>>
>>> I've had to revert this. Whilst it seems to work, after showing/hiding
>>> the dashboard, I later find that when I completely reload the app, it
>>> fails, leaving just the object menu present. I haven't come up with a
>>> concrete case to reproduce it. In the console, I see:
>>>
>>>
>>> wcDocker.min.js:38 Uncaught TypeError: Cannot read property '__save' of
>>> null at e.save (wcDocker.min.js:38) at Object.save_current_layout (
>>> browser.js:340) at e.handleVisibility (panel.js:156) at e.__trigger (
>>> wcDocker.min.js:34) at e.trigger (wcDocker.min.js:38) at e.clear (
>>> wcDocker.min.js:38) at Object.init (browser.js:386) at (index):278 at
>>> Object.execCb (require.min.js:29) at Z.check (require.min.js:18)
>>>
>>> I couldn't reproduce this issue. I have tried many things to reproduce
>> it but not succeeded. I also switched server_mode but no luck.
>> I think there should be any specific condition that fails this but have
>> no clue.
>>
>> I have rebased this patch and attached.
>>
>
> Thanks. I applied the patch, restarted my server, and did a hard-reload in
> my browser and immediately saw the problem - see the attached screenshot.
>
Fixed

>
>
Clearing the saved browser layout from the config DB solved the problem for
> me (once I refreshed the browser), so something is likely getting messed up
> in there. I've attached the value that was previously saved as inserting
> that into a test database will likely be easier than trying to reproduce
> the issue.
>
> Thanks!
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/browser/static/js/panel.js b/web/pgadmin/browser/static/js/panel.js
index 71d2c68..20f865d 100644
--- a/web/pgadmin/browser/static/js/panel.js
+++ b/web/pgadmin/browser/static/js/panel.js
@@ -7,7 +7,8 @@ function(_, pgAdmin) {
   pgAdmin.Browser.Panel = function(options) {
 var defaults = [
   'name', 'title', 'width', 'height', 'showTitle', 'isCloseable',
-  'isPrivate', 'content', 'icon', 'events', 'onCreate', 'elContainer'
+  'isPrivate', 'content', 'icon', 'events', 'onCreate', 'elContainer',
+  'canHide', 'limit'
 ];
 _.extend(this, _.pick(options, defaults));
   }
@@ -25,12 +26,14 @@ function(_, pgAdmin) {
 panel: null,
 onCreate: null,
 elContainer: false,
+limit: null,
 load: function(docker, title) {
   var that = this;
   if (!that.panel) {
 docker.registerPanelType(that.name, {
   title: that.title,
   isPrivate: that.isPrivate,
+  limit: that.limit,
   onCreate: function(myPanel) {
 $(myPanel).data('pgAdminName', that.name);
 myPanel.initSize(that.width, that.height);
@@ -85,6 +88,14 @@ function(_, pgAdmin) {
   });
   that.resizedContainer.apply(myPanel);
 }
+
+// Bind events only if they are configurable
+if (that.canHide) {
+  _.each([wcDocker.EVENT.CLOSED, wcDocker.EVENT.VISIBILITY_CHANGED],
+function(ev) {
+  myPanel.on(ev, that.handleVisibility.bind(myPanel, ev));
+});
+}
   }
 });
   }
@@ -134,7 +145,32 @@ function(_, pgAdmin) {
   100
 );
   }
+},
+handleVisibility: function(eventName) {
+  // Currently this function only works with dashboard panel but
+  // as per need it can be extended
+  if (this._type != 'dashboard' || _.isUndefined(pgAdmin.Dashboard))
+return;
+
+  if (eventName == 'panelClosed') {
+pgBrowser.save_current_layout(pgBrowser);
+pgAdmin.Dashboard.toggleVisibility(false);
+  }
+  else if (eventName == 'panelVisibilityChanged') {
+if (pgBrowser.tree) {
+  pgBrowser.save_current_layout(pgBrowser);
+  var selectedNode = pgBrowser.tree.selected();
+  // Discontinue this event after first time visible
+  this.off(wcDocker.EVENT.VISIBILITY_CHANGED);
+  if (!_.isUndefined(pgAdmin

Re: UI issue

2017-06-30 Thread Khushboo Vashi
Hi,

Please find the attached patch for the same.
This is due to my precious patch.

Thanks,
Khushboo

On Fri, Jun 30, 2017 at 5:06 PM, Dave Page  wrote:

>
>
> On Fri, Jun 30, 2017 at 12:29 PM, Dave Page  wrote:
>
>>
>>
>> On Fri, Jun 30, 2017 at 12:25 PM, Dave Page  wrote:
>>
>>>
>>>
>>> On Fri, Jun 30, 2017 at 12:23 PM, Harshal Dhumal <
>>> harshal.dhu...@enterprisedb.com> wrote:
>>>


 On Fri, Jun 30, 2017 at 4:39 PM, Dave Page  wrote:

>
>
> On Fri, Jun 30, 2017 at 12:07 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> I'm getting this wired ui issue when I launched query tool using
>> view/edit menu. Is anybody getting such issue?
>>
>
> Looks like you dragged the query tool off the main tab bar and docked
> it to the left of the browser. Did you try resetting your view?
>
 I just tried again by resetting layout and opened query tool using
 view/edit data -> view all rows and still getting same issue

>>>
>>> Weird. I don't see it. Anyone else?
>>>
>>
>> I take that back; I just saw it happen in the feature tests.
>>
>
> So, further info: I see this effect with View Data, but *not* with the
> Query Tool. Could it be related to the renaming of the menu options/tabs?
>
>
> --
> 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/datagrid/templates/datagrid/js/datagrid.js b/web/pgadmin/tools/datagrid/templates/datagrid/js/datagrid.js
index 9b72a11..2096e16 100644
--- a/web/pgadmin/tools/datagrid/templates/datagrid/js/datagrid.js
+++ b/web/pgadmin/tools/datagrid/templates/datagrid/js/datagrid.js
@@ -379,7 +379,7 @@ define([
 newWin.document.title = grid_title;
   });
 } else {
-  var dashboardPanel = pgBrowser.docker.findPanels('properites');
+  var dashboardPanel = pgBrowser.docker.findPanels('properties');
   var dataGridPanel = pgBrowser.docker.addPanel('frm_datagrid', wcDocker.DOCK.STACKED, dashboardPanel[0]);
 
   // Set panel title and icon


[pgAdmin4][Patch]: Fixed couple of minor issues

2017-07-02 Thread Khushboo Vashi
Hi,

1. When we try to delete the table row with the column definition having
NOT NULL TRUE and HAS NO DEFAULT VALUE then it fails.
Please find the attached patch for the same. (delete_row.patch)

2. The debugger can not be opened from the View trigger.
Please find the attached patch for the same. (view_debugger.patch)

Thanks,
Khushboo
diff --git a/web/pgadmin/tools/sqleditor/command.py b/web/pgadmin/tools/sqleditor/command.py
index 3b7efd0..94aec09 100644
--- a/web/pgadmin/tools/sqleditor/command.py
+++ b/web/pgadmin/tools/sqleditor/command.py
@@ -464,6 +464,7 @@ class TableCommand(GridCommand):
 continue
 
 column_type = {}
+column_data = {}
 for each_col in columns_info:
 if (
 columns_info[each_col]['not_null'] and
diff --git a/web/pgadmin/tools/debugger/templates/debugger/js/debugger.js b/web/pgadmin/tools/debugger/templates/debugger/js/debugger.js
index 624ca80..e26076a 100644
--- a/web/pgadmin/tools/debugger/templates/debugger/js/debugger.js
+++ b/web/pgadmin/tools/debugger/templates/debugger/js/debugger.js
@@ -234,11 +234,16 @@ define([
   var baseUrl = "{{ url_for('debugger.index') }}" + "initialize_target/" + "indirect/" + treeInfo.server._id +
 "/" + treeInfo.database._id + "/" + treeInfo.schema._id + "/" + treeInfo.trigger_function._id;
 }
-else if (d._type == "trigger") {
+else if (d._type == "trigger" && "table" in treeInfo) {
   var baseUrl = "{{ url_for('debugger.index') }}" + "initialize_target/" + "indirect/" + treeInfo.server._id +
 "/" + treeInfo.database._id + "/" + treeInfo.schema._id + "/" + treeInfo.table._id +
 "/" + treeInfo.trigger._id;
 }
+else if (d._type == "trigger" && "view" in treeInfo) {
+  var baseUrl = "{{ url_for('debugger.index') }}" + "initialize_target/" + "indirect/" + treeInfo.server._id +
+"/" + treeInfo.database._id + "/" + treeInfo.schema._id + "/" + treeInfo.view._id +
+"/" + treeInfo.trigger._id;
+}
 
 $.ajax({
   url: baseUrl,


[pgAdmin4][Patch]: Fixed the issue related to Domain Constraint module

2017-07-03 Thread Khushboo Vashi
Hi,

The Domain Constraint module doesn't load as it can not find the
domain_constraints.js file.
To fix this issue, renamed the domain_constraint.js to
domain_constraints.js.

Please find the attached fix.
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraint.js
deleted file mode 100644
index 61d0553..000
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraint.js
+++ /dev/null
@@ -1,146 +0,0 @@
-// Domain Constraint Module: Collection and Node
-define('pgadmin.node.domain_constraints', [
-  'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
-  'underscore.string', 'pgadmin', 'pgadmin.browser', 'alertify',
-  'pgadmin.browser.collection'
-], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify) {
-
-  // Define Domain Constraint Collection Node
-  if (!pgBrowser.Nodes['coll-domain_constraints']) {
-var domain_constraints = pgAdmin.Browser.Nodes['coll-domain_constraints'] =
-  pgAdmin.Browser.Collection.extend({
-node: 'domain_constraints',
-label: gettext('Domain Constraints'),
-type: 'coll-domain_constraints',
-columns: ['name', 'description']
-  });
-  };
-
-  // Domain Constraint Node
-  if (!pgBrowser.Nodes['domain_constraints']) {
-pgAdmin.Browser.Nodes['domain_constraints'] = pgBrowser.Node.extend({
-  type: 'domain_constraints',
-  sqlAlterHelp: 'sql-alterdomain.html',
-  sqlCreateHelp: 'sql-alterdomain.html',
-  dialogHelp: url_for('help.static', {'filename': 'domain_constraint_dialog.html'}),
-  label: gettext('Domain Constraints'),
-  collection_type: 'coll-domain_constraints',
-  hasSQL: true,
-  hasDepends: true,
-  parent_type: ['domain'],
-  Init: function() {
-// Avoid mulitple registration of menus
-if (this.initialized)
-return;
-
-this.initialized = true;
-
-pgBrowser.add_menus([{
-  name: 'create_domain_on_coll', node: 'coll-domain_constraints', module: this,
-  applies: ['object', 'context'], callback: 'show_obj_properties',
-  category: 'create', priority: 5, label: gettext('Domain Constraint...'),
-  icon: 'wcTabIcon icon-domain_constraints', data: {action: 'create', check: true},
-  enable: 'canCreate'
-},{
-  name: 'create_domain_constraints', node: 'domain_constraints', module: this,
-  applies: ['object', 'context'], callback: 'show_obj_properties',
-  category: 'create', priority: 5, label: gettext('Domain Constraint...'),
-  icon: 'wcTabIcon icon-domain_constraints', data: {action: 'create', check: true},
-  enable: 'canCreate'
-},{
-  name: 'create_domain_constraints', node: 'domain', module: this,
-  applies: ['object', 'context'], callback: 'show_obj_properties',
-  category: 'create', priority: 5, label: gettext('Domain Constraint...'),
-  icon: 'wcTabIcon icon-domain_constraints', data: {action: 'create', check: false},
-  enable: 'canCreate'
-}
-]);
-
-  },
-  canDrop: pgBrowser.Nodes['schema'].canChildDrop,
-  model: pgAdmin.Browser.Node.Model.extend({
-defaults: {
-  name: undefined,
-  oid: undefined,
-  description: undefined,
-  consrc: undefined,
-  connoinherit: undefined,
-  convalidated: true
-},
-// Domain Constraint Schema
-schema: [{
-  id: 'name', label: gettext('Name'), type:'text', cell:'string',
-  disabled: 'isDisabled'
-},{
-  id: 'oid', label: gettext('OID'), cell: 'string',
-  type: 'text' , mode: ['properties']
-},{
-  id: 'description', label: gettext('Comment'), type: 'multiline', cell:
-  'string', mode: ['properties', 'create', 'edit'], min_version: 90500,
-},{
-  id: 'consrc', label: gettext('Check'), type: 'multiline', cel:
-  'string', group: gettext('Definition'), mode: ['properties',
-  'create', 'edit'], disabled: function(m) { return !m.isNew(); }
-},{
-  id: 'connoinherit', label: gettext('No inherit'), type:
-  'switch', cell: 'boolean', group: gettext('Definition'), mode:
-  ['properties', 'create', 'edit'], disabled: 'isDisabled',
-  visible: false
-},{
-  id: 'convalidated', label: gettext("Validate?"), type: 'switch', cell:
-  'boolean', group: gettext('Definition'), min_version: 90200,
-  disabled: function(m) {
-  if (!m.isNew()) {
-var server = this.node_info.server;
-if (server.version < 90200) { return true;
-}
-else if(m.get('convalidated')) {
-

Re: [pgAdmin4][Patch]: Fixed couple of minor issues

2017-07-03 Thread Khushboo Vashi
Nope. I found these issues when I tried to reproduce another issue :).

On Mon, Jul 3, 2017 at 3:29 PM, Dave Page  wrote:

> Are there RMs for these?
>
> On Mon, Jul 3, 2017 at 2:27 AM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> 1. When we try to delete the table row with the column definition having
>> NOT NULL TRUE and HAS NO DEFAULT VALUE then it fails.
>> Please find the attached patch for the same. (delete_row.patch)
>>
>> 2. The debugger can not be opened from the View trigger.
>> Please find the attached patch for the same. (view_debugger.patch)
>>
>> Thanks,
>> Khushboo
>>
>>
>>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


Re: [pgAdmin4][Patch]: Fixed couple of minor issues

2017-07-03 Thread Khushboo Vashi
On Mon, Jul 3, 2017 at 11:57 AM, Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

> Hi,
>
> 1. When we try to delete the table row with the column definition having
> NOT NULL TRUE and HAS NO DEFAULT VALUE then it fails.
> Please find the attached patch for the same. (delete_row.patch)
>
> Created RM #2527  <https://redmine.postgresql.org/issues/2527>

2. The debugger can not be opened from the View trigger.
> Please find the attached patch for the same. (view_debugger.patch)
>
> Created RM #2528  <https://redmine.postgresql.org/issues/2528>

> Thanks,
> Khushboo
>
>
>


Re: [pgAdmin4][Patch]: Fixed the issue related to Domain Constraint module

2017-07-03 Thread Khushboo Vashi
On Mon, Jul 3, 2017 at 1:10 PM, Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

> Hi,
>
> The Domain Constraint module doesn't load as it can not find the
> domain_constraints.js file.
> To fix this issue, renamed the domain_constraint.js to
> domain_constraints.js.
>
> RM #2529 <https://redmine.postgresql.org/issues/2529> created for the
same.

> Please find the attached fix.
>
>


Re: [pgAdmin4][Patch]: Fixed the issue related to Domain Constraint module

2017-07-03 Thread Khushboo Vashi
Hi,

Please find the attached updated patch which includes following fixes:

1. The plus button to add a constraint with the domain dialogue doesn't
work.
2. The Domain Constraint node doesn't load.
3. On update, the domain constraint node name doesn't change.

Thanks,
Khushboo


On Mon, Jul 3, 2017 at 7:52 PM, Dave Page  wrote:

> Hi
>
> On Mon, Jul 3, 2017 at 6:10 AM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>>
>>
>> On Mon, Jul 3, 2017 at 1:10 PM, Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> The Domain Constraint module doesn't load as it can not find the
>>> domain_constraints.js file.
>>> To fix this issue, renamed the domain_constraint.js to
>>> domain_constraints.js.
>>>
>>> RM #2529 <https://redmine.postgresql.org/issues/2529> created for the
>> same.
>>
>>> Please find the attached fix.
>>>
>>>
>>
> I think this is still broken. If I try to create a new domain called abc,
> with a basetype of text, then hit the + button to add a constraint, I get:
>
>
> domain.js:24 Uncaught TypeError: Cannot read property 'server' of
> undefined at s.initialize (domain.js:24) at s.e.Model (backbone-min.js:1)
> at s [as constructor] (backbone-min.js:1) at new s (backbone-min.js:1) at
> s._prepareModel (backbone-min.js:1) at set (backbone-min.js:1) at s.add (
> backbone-min.js:1) at s.insertRow (backgrid.min.js:8) at s.insertRow (
> backgrid.min.js:8) at HTMLButtonElement. (
> backform.pgadmin.js:1347)
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py
index 85cd1c0..b20cb38 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py
@@ -410,7 +410,7 @@ class DomainConstraintView(PGChildNodeView):
 """
 data = self.request
 try:
-status, SQL = self.get_sql(gid, sid, data, scid, doid)
+status, SQL, name = self.get_sql(gid, sid, data, scid, doid)
 if not status:
 return SQL
 
@@ -517,7 +517,7 @@ class DomainConstraintView(PGChildNodeView):
 coid: Domain Constraint Id
 """
 data = self.request
-status, SQL = self.get_sql(gid, sid, data, scid, doid, coid)
+status, SQL, name = self.get_sql(gid, sid, data, scid, doid, coid)
 if not status:
 return SQL
 
@@ -534,18 +534,13 @@ class DomainConstraintView(PGChildNodeView):
 else:
 icon = ''
 
-return make_json_response(
-success=1,
-info="Domain Constraint updated",
-data={
-'id': coid,
-'doid': doid,
-'scid': scid,
-'sid': sid,
-'gid': gid,
-'did': did,
-'icon': icon
-}
+return jsonify(
+node=self.blueprint.generate_browser_node(
+coid,
+doid,
+name,
+icon=icon
+)
 )
 else:
 return make_json_response(
@@ -629,7 +624,7 @@ class DomainConstraintView(PGChildNodeView):
 """
 data = self.request
 
-status, SQL = self.get_sql(gid, sid, data, scid, doid, coid)
+status, SQL, name = self.get_sql(gid, sid, data, scid, doid, coid)
 if status and SQL:
 return make_json_response(
 data=SQL,
@@ -677,9 +672,9 @@ class DomainConstraintView(PGChildNodeView):
 SQL = render_template("/".join([self.template_path,
 'create.sql']),
   data=data, domain=domain, schema=schema)
-return True, SQL.strip('\n')
+return True, SQL.strip('\n'), data['name'] if 'name' in data else old_data['name']
 except Exception as e:
-return False, internal_server_error(errormsg=str(e))
+ 

[pgAdmin4][Patch]: Fixed #2532 - Left side tree: The node disappears on update if there is only one child exist for that category.

2017-07-09 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix the RM #2532 : Left side tree: The
node disappears on update if there is only one child exist for that
category.


Thanks,
Khushboo
diff --git a/web/pgadmin/browser/templates/browser/js/browser.js b/web/pgadmin/browser/templates/browser/js/browser.js
index 0cccf9c..6b260dc 100644
--- a/web/pgadmin/browser/templates/browser/js/browser.js
+++ b/web/pgadmin/browser/templates/browser/js/browser.js
@@ -826,6 +826,10 @@ define(
   _o.d = null;
   _o.pI.push({coll: true, item: i, d: d});
 
+  // Set load to false when the current collection node's inode is false
+  if (!_o.t.isInode(i)) {
+_o.load = false;
+  }
   _o.b._findTreeChildNode(i, _d, _o);
   return;
 }
@@ -1502,27 +1506,39 @@ define(
   }
 });
   } else {
-ctx.t.append(ctx.i, {
-  itemData: _new,
-  success: function() {
-var new_item = $(arguments[1].items[0]);
-ctx.t.openPath(new_item);
-ctx.t.select(new_item);
-if (
-  ctx.o && ctx.o.success && typeof(ctx.o.success) == 'function'
-) {
-  ctx.o.success.apply(ctx.t, [ctx.i, _old, _new]);
-}
-  },
-  fail: function() {
-console.log('Failed to append');
-if (
-  ctx.o && ctx.o.fail && typeof(ctx.o.fail) == 'function'
-) {
-  ctx.o.fail.apply(ctx.t, [ctx.i, _old, _new]);
+var _appendNode = function() {
+  ctx.t.append(ctx.i, {
+itemData: _new,
+success: function() {
+  var new_item = $(arguments[1].items[0]);
+  ctx.t.openPath(new_item);
+  ctx.t.select(new_item);
+  if (
+ctx.o && ctx.o.success && typeof(ctx.o.success) == 'function'
+  ) {
+ctx.o.success.apply(ctx.t, [ctx.i, _old, _new]);
+  }
+},
+fail: function() {
+  console.log('Failed to append');
+  if (
+ctx.o && ctx.o.fail && typeof(ctx.o.fail) == 'function'
+  ) {
+ctx.o.fail.apply(ctx.t, [ctx.i, _old, _new]);
+  }
 }
-  }
-});
+  })
+};
+
+// If the current node's inode is false
+if (ctx.i && !ctx.t.isInode(ctx.i)) {
+  ctx.t.setInode(ctx.i, {success: _appendNode});
+} else {
+  // Handle case for node without parent i.e. server-group
+  // or if parent node's inode is true.
+  _appendNode();
+}
+
   }
 }.bind(ctx);
 


[pgAdmin4][Patch]: Fixed RM #1165 - Too many request to update dashboard graphs when server is disconnected.

2017-07-10 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix the RM #1165 - Too many request to
update dashboard graphs when server is disconnected.

Thanks,
Khushboo
diff --git a/web/pgadmin/dashboard/templates/dashboard/js/dashboard.js b/web/pgadmin/dashboard/templates/dashboard/js/dashboard.js
index 34a1ab7..e858faa 100644
--- a/web/pgadmin/dashboard/templates/dashboard/js/dashboard.js
+++ b/web/pgadmin/dashboard/templates/dashboard/js/dashboard.js
@@ -89,28 +89,35 @@ function(r, $, pgAdmin, _, Backbone, gettext) {
 );
 
 if (div) {
-// Avoid unnecessary reloads
-if (url != $(dashboardPanel).data('dashboard_url')) {
-// Clear out everything so any existing timers die off
+if (itemData.connected || _.isUndefined(itemData.connected)) {
+// Avoid unnecessary reloads
+if (url != $(dashboardPanel).data('dashboard_url')) {
+// Clear out everything so any existing timers die off
+$(div).empty();
+
+$.ajax({
+url: url,
+type: "GET",
+dataType: "html",
+success: function (data) {
+$(div).html(data);
+},
+error: function (xhr, status) {
+$(div).html(
+'' + gettext('An error occurred whilst loading the dashboard.') + ''
+);
+}
+});
+}
+}
+else {
 $(div).empty();
-
-$.ajax({
-url: url,
-type: "GET",
-dataType: "html",
-success: function (data) {
-$(div).html(data);
-},
-error: function (xhr, status) {
-$(div).html(
-'' + gettext('An error occurred whilst loading the dashboard.') + ''
-);
-}
-});
-
-// Cache the current IDs for next time
-$(dashboardPanel).data('dashboard_url', url);
+$(div).html(
+'' + gettext('Please connect to the selected server to view the dashboard.') + ''
+);
 }
+// Cache the current IDs for next time
+$(dashboardPanel).data('dashboard_url', url);
 }
 }
 }


Re: [pgAdmin4][Patch]: Fixed RM #1165 - Too many request to update dashboard graphs when server is disconnected.

2017-07-10 Thread Khushboo Vashi
Hi,

please find the attached updated patch.

Thanks,
Khushboo

On Mon, Jul 10, 2017 at 6:54 PM, Dave Page  wrote:

> Hi
>
> On Mon, Jul 10, 2017 at 2:14 PM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Please find the attached patch to fix the RM #1165 - Too many request to
>> update dashboard graphs when server is disconnected.
>>
>
> If I disconnect the server, it doesn't stop trying to get data until I
> refresh the browser by clicking on another node that causes it to reload.
>
> Fixed

> If I then click back on the server node, it doesn't redraw the dashboard
> and start displaying new data upon reconnect. I have to change nodes again
> before it will respond to the re-connection.
>
> Fixed

> Thanks.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/dashboard/templates/dashboard/js/dashboard.js b/web/pgadmin/dashboard/templates/dashboard/js/dashboard.js
index 34a1ab7..1bbe5a4 100644
--- a/web/pgadmin/dashboard/templates/dashboard/js/dashboard.js
+++ b/web/pgadmin/dashboard/templates/dashboard/js/dashboard.js
@@ -22,10 +22,14 @@ function(r, $, pgAdmin, _, Backbone, gettext) {
 
 // Bind the Dashboard object with the 'object_selected' function
 var selected = this.object_selected.bind(this);
+var disconnected = this.object_disconnected.bind(this);
 
 // Listen for selection of any of object
 pgBrowser.Events.on('pgadmin-browser:tree:selected', selected);
 
+// Listen for server disconnected event
+pgBrowser.Events.on('pgadmin:server:disconnect', disconnected);
+
 // Load the default welcome dashboard
 url = '{{ url_for('dashboard.index') }}';
 
@@ -55,6 +59,11 @@ function(r, $, pgAdmin, _, Backbone, gettext) {
 }
 },
 
+// Handle Server Disconnect
+object_disconnected: function(obj) {
+this.object_selected(obj.item, obj.data, pgBrowser.Nodes[obj.data._type]);
+},
+
 // Handle treeview clicks
 object_selected: function(item, itemData, node) {
 if (itemData && itemData._type && dashboardVisible) {
@@ -89,28 +98,40 @@ function(r, $, pgAdmin, _, Backbone, gettext) {
 );
 
 if (div) {
-// Avoid unnecessary reloads
-if (url != $(dashboardPanel).data('dashboard_url')) {
-// Clear out everything so any existing timers die off
-$(div).empty();
+if (itemData.connected || _.isUndefined(itemData.connected)) {
+// Avoid unnecessary reloads
+if (url != $(dashboardPanel).data('dashboard_url') ||
+   (url == $(dashboardPanel).data('dashboard_url') && $(dashboardPanel).data('server_status') == false )) {
+// Clear out everything so any existing timers die off
+$(div).empty();
+
+$.ajax({
+url: url,
+type: "GET",
+dataType: "html",
+success: function (data) {
+$(div).html(data);
+},
+error: function (xhr, status) {
+$(div).html(
+'' + gettext('An error occurred whilst loading the dashboard.') + ''
+);
+}
+});
+$(dashboardPanel).data('server_status', true);
+}
 
-$.ajax({
-url: url,
-type: "GET",
-dataType: "html",
-success: function (data) {
-$(div).html(data);
-},
-error: function (xhr, status) {
-$(div).html(
-'' + gettext('An error occurred whilst loading the dashboard.') + ''
-);
-   

Re: pgAdmin 4 v1.6 Released!

2017-07-14 Thread Khushboo Vashi
On Fri, Jul 14, 2017 at 12:23 PM, Pawel Hadam  wrote:

> Hi,
>
> I have also installed "pgadmin4-1.6-x86.exe" on Windows 10 PRO (AMD
> FX, 6 cores, 16 GB RAM, SSD) and tried to run it. After 1min 58 sec I
> got a message saying "The application server could not be contacted".
>
> pgAdmin 4 v 1.5 was starting successfully in 55-60 sec. before I did
> this installation. Nothing else has changed, just reinstalled pgAdmin.
>
> Anybody had the same error and any ideas what's wrong?
>
> I faced similar issue, by moving the pgadmin4.db file to another location
(or can rename) worked for me.

> Thanks and regards
> Pawel
>
>
> On 14 July 2017 at 01:00, Shira Bezalel  wrote:
> > I downloaded the Windows pgAdmin 1.6 version, and after launching it, it
> > simply shows a black display. My colleague also on Windows 10 had the
> same
> > experience.
> >
> > Does this sound like a known problem?
> >
> > Shira
> >
> > On Thu, Jul 13, 2017 at 11:18 AM, Lazaro Garcia 
> > wrote:
> >>
> >> The download links are wrong, the links downloads 1.5 and not 1.6.
> >>
> >>
> >>
> >> Regards.
> >>
> >>
> >>
> >> De: Dave Page [mailto:dp...@pgadmin.org]
> >> Enviado el: jueves, 13 de julio de 2017 11:18 a. m.
> >> Para: pgAdmin Support; pgadmin-hackers
> >> Asunto: pgAdmin 4 v1.6 Released!
> >>
> >>
> >>
> >> The pgAdmin Development Team are pleased to announce the release of
> >> pgAdmin 4 version 1.6. This release of pgAdmin 4 includes over 70 bug
> fixes
> >> and a dozen new features. For details, please see the release notes
> >> (https://www.pgadmin.org/docs/pgadmin4/dev/release_notes_1_6.html).
> >>
> >>
> >>
> >> Notable changes in this release include:
> >>
> >>
> >>
> >> * Significant performance improvements on Windows, massively reducing
> >> initial load time and improving UI response for the vast majority of
> users
> >> during testing.
> >>
> >>
> >>
> >> * Enhancements to the Query Tool enabling the viewing of large query
> >> resultsets far more quickly. For example, a simple test query with 96K
> rows
> >> rendered results within 1 second vs. 22 seconds in pgAdmin III during
> >> testing!
> >>
> >>
> >>
> >> * A major rewrite of the Query History tab allows browsing of queries
> >> executed in the query tool with full details including the entire
> query, in
> >> a much nicer user interface.
> >>
> >>
> >>
> >> * The Desktop Runtime now supports detachable tabs, allowing the Query
> >> Tool and Debugger to be opened in new tabs and then moved to alternate
> >> displays (from 1.5 this was possible in web mode only)
> >>
> >>
> >>
> >> * The Query Tool's Results Grid has been overhauled with a new, sleek
> look
> >> an feel supporting selection of arbitrary rows, columns or blocks of
> cells
> >> with full copy support and column sizing retention.
> >>
> >>
> >>
> >> * The Dashboard tab can now be closed if desired, to minimise query
> >> traffic resulting from graph updates.
> >>
> >>
> >>
> >> For more information, checkout the online documentation, and of course
> the
> >> download page:
> >>
> >>
> >>
> >> Docs: https://www.pgadmin.org/docs/pgadmin4/dev/index.html
> >>
> >>
> >>
> >> Download: https://www.pgadmin.org/download
> >>
> >>
> >>
> >>
> >>
> >> --
> >>
> >> Dave Page
> >> Blog: http://pgsnake.blogspot.com
> >> Twitter: @pgsnake
> >
> >
> >
> >
>
>


Re: pgAdmin 4 v1.6 Released!

2017-07-14 Thread Khushboo Vashi
On Fri, Jul 14, 2017 at 1:55 PM, Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

>
> On Fri, Jul 14, 2017 at 12:23 PM, Pawel Hadam  wrote:
>
>> Hi,
>>
>> I have also installed "pgadmin4-1.6-x86.exe" on Windows 10 PRO (AMD
>> FX, 6 cores, 16 GB RAM, SSD) and tried to run it. After 1min 58 sec I
>> got a message saying "The application server could not be contacted".
>>
>> pgAdmin 4 v 1.5 was starting successfully in 55-60 sec. before I did
>> this installation. Nothing else has changed, just reinstalled pgAdmin.
>>
>> Anybody had the same error and any ideas what's wrong?
>>
>> I faced similar issue, by moving the pgadmin4.db file to another location
> (or can rename) worked for me.
>
If you are on windows, then you can find the file at
C:\Users\username\AppData\Roaming\pgAdmin  location.

> Thanks and regards
>> Pawel
>>
>>
>> On 14 July 2017 at 01:00, Shira Bezalel  wrote:
>> > I downloaded the Windows pgAdmin 1.6 version, and after launching it, it
>> > simply shows a black display. My colleague also on Windows 10 had the
>> same
>> > experience.
>> >
>> > Does this sound like a known problem?
>> >
>> > Shira
>> >
>> > On Thu, Jul 13, 2017 at 11:18 AM, Lazaro Garcia 
>> > wrote:
>> >>
>> >> The download links are wrong, the links downloads 1.5 and not 1.6.
>> >>
>> >>
>> >>
>> >> Regards.
>> >>
>> >>
>> >>
>> >> De: Dave Page [mailto:dp...@pgadmin.org]
>> >> Enviado el: jueves, 13 de julio de 2017 11:18 a. m.
>> >> Para: pgAdmin Support; pgadmin-hackers
>> >> Asunto: pgAdmin 4 v1.6 Released!
>> >>
>> >>
>> >>
>> >> The pgAdmin Development Team are pleased to announce the release of
>> >> pgAdmin 4 version 1.6. This release of pgAdmin 4 includes over 70 bug
>> fixes
>> >> and a dozen new features. For details, please see the release notes
>> >> (https://www.pgadmin.org/docs/pgadmin4/dev/release_notes_1_6.html).
>> >>
>> >>
>> >>
>> >> Notable changes in this release include:
>> >>
>> >>
>> >>
>> >> * Significant performance improvements on Windows, massively reducing
>> >> initial load time and improving UI response for the vast majority of
>> users
>> >> during testing.
>> >>
>> >>
>> >>
>> >> * Enhancements to the Query Tool enabling the viewing of large query
>> >> resultsets far more quickly. For example, a simple test query with 96K
>> rows
>> >> rendered results within 1 second vs. 22 seconds in pgAdmin III during
>> >> testing!
>> >>
>> >>
>> >>
>> >> * A major rewrite of the Query History tab allows browsing of queries
>> >> executed in the query tool with full details including the entire
>> query, in
>> >> a much nicer user interface.
>> >>
>> >>
>> >>
>> >> * The Desktop Runtime now supports detachable tabs, allowing the Query
>> >> Tool and Debugger to be opened in new tabs and then moved to alternate
>> >> displays (from 1.5 this was possible in web mode only)
>> >>
>> >>
>> >>
>> >> * The Query Tool's Results Grid has been overhauled with a new, sleek
>> look
>> >> an feel supporting selection of arbitrary rows, columns or blocks of
>> cells
>> >> with full copy support and column sizing retention.
>> >>
>> >>
>> >>
>> >> * The Dashboard tab can now be closed if desired, to minimise query
>> >> traffic resulting from graph updates.
>> >>
>> >>
>> >>
>> >> For more information, checkout the online documentation, and of course
>> the
>> >> download page:
>> >>
>> >>
>> >>
>> >> Docs: https://www.pgadmin.org/docs/pgadmin4/dev/index.html
>> >>
>> >>
>> >>
>> >> Download: https://www.pgadmin.org/download
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> --
>> >>
>> >> Dave Page
>> >> Blog: http://pgsnake.blogspot.com
>> >> Twitter: @pgsnake
>> >
>> >
>> >
>> >
>>
>>
>


Re: pgAdmin 4 v1.6 Released!

2017-07-14 Thread Khushboo Vashi
On Fri, Jul 14, 2017 at 4:18 PM, Raymond O'Donnell  wrote:

> Hi all,
>
> I'm trying to install pgAdmin4 in server mode on my laptop (Debian
> Jessie), and I've got as far as:
>
>python setup.py
>
> I don't have a python environment set up, so I'm apt-getting my way
> through various unmet dependencies, and one has defeated me:
>
> Traceback (most recent call last):
>   File "setup.py", line 23, in 
> from pgadmin import create_app
>   File "/var/www/pgadmin/pgadmin/__init__.py", line 19, in 
> from flask_htmlmin import HTMLMIN
> ImportError: No module named flask_htmlmin
>
>
>
Please refer README file for the proper installation steps (Configuring
Python Environment section) .

I can't find any corresponding Debian package for flask_htmlmin - what
> should I be looking for?
>
> Thanks,
>
> Ray.
>
> --
> Raymond O'Donnell :: Galway :: Ireland
> r...@iol.ie
>
>


[pgAdmin4][Patch]: Minor patch to fix a typo in README

2017-07-16 Thread Khushboo Vashi
Hi,

Please find a minor patch to fix a typo in README.

Thanks,
Khushboo


README_typo.patch
Description: Binary data


[pgAdmin4][Patch]: RM #2556: Runtime connection retry loop timeout

2017-07-17 Thread Khushboo Vashi
Hi,

Please find the attached patch for RM #2556: Runtime connection retry loop
timeout

Thanks,
Khushboo
diff --git a/docs/en_US/desktop_deployment.rst b/docs/en_US/desktop_deployment.rst
index 9765c77..745b83f 100644
--- a/docs/en_US/desktop_deployment.rst
+++ b/docs/en_US/desktop_deployment.rst
@@ -73,6 +73,13 @@ semi-colon character, for example:
 
  /Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/;/Users/dpage/python-libs/
 
-The configuration settings are stored using the QSettings class in Qt, which 
-will use an INI file on Unix systems, a plist file on Mac OS X, and the registry
-on Windows. The Python Path setting is stored in the ``PythonPath`` key.
\ No newline at end of file
+The configuration settings are stored using the QSettings class in Qt, which
+will use an INI file on Unix systems, a plist file on Mac OS X, and the registry on Windows.
+
+The configuration settings:
+
+Key Description of settings
+-
+``PythonPath``- The Python Path
+``ApplicationPath``   - The Application Path
+``ConnectionTimeout`` - The Connection Timeout in seconds
diff --git a/runtime/pgAdmin4.cpp b/runtime/pgAdmin4.cpp
index 9054e9e..391cf45 100644
--- a/runtime/pgAdmin4.cpp
+++ b/runtime/pgAdmin4.cpp
@@ -340,28 +340,36 @@ int main(int argc, char * argv[])
 // Generate the app server URL
 QString appServerUrl = QString("http://127.0.0.1:%1/?key=%2";).arg(port).arg(key);
 
+// Read the server connection timeout from the registry or set the default timeout.
+QSettings settings;
+int timeout = settings.value("ConnectionTimeout", 30).toInt();
+
 // Now the server should be up, we'll attempt to connect and get a response.
 // We'll retry in a loop a few time before aborting if necessary.
-int attempt = 0;
-while (attempt++ < 50)
+
+QTime endTime = QTime::currentTime().addSecs(timeout);
+bool alive = false;
+
+while(QTime::currentTime() <= endTime)
 {
-bool alive = PingServer(QUrl(appServerUrl));
+alive = PingServer(QUrl(appServerUrl));
 
 if (alive)
 {
 break;
 }
 
-if (attempt == 50)
-{
-splash->finish(NULL);
-QString error(QWidget::tr("The application server could not be contacted."));
-QMessageBox::critical(NULL, QString(QWidget::tr("Fatal Error")), error);
+delay(200);
+}
 
-exit(1);
-}
+// Attempt to connect one more time in case of a long network timeout while looping
+if(!alive && !PingServer(QUrl(appServerUrl)))
+{
+splash->finish(NULL);
+QString error(QWidget::tr("The application server could not be contacted."));
+QMessageBox::critical(NULL, QString(QWidget::tr("Fatal Error")), error);
 
-delay(200);
+exit(1);
 }
 
 // Create & show the main window


Re: [pgAdmin4]: Webpacking of static JS/CSS

2017-07-18 Thread Khushboo Vashi
On Tue, Jul 18, 2017 at 7:46 PM, Dave Page  wrote:

> Thanks - applied!
>
> Awesome work - on an average of 3 tests on my Mac, load time reduced from
> 11.55s with v1.6 to 5.53s with GIT Head.
>
> Surinder, great work...


> On Mon, Jul 17, 2017 at 5:57 PM, Surinder Kumar <
> surinder.ku...@enterprisedb.com> wrote:
>
>> Hi
>>
>> Now all test cases are executing.
>> Please find updated patch.
>>
>> Thanks
>> Surinder
>>
>> On Mon, Jul 17, 2017 at 6:57 PM, Surinder Kumar <
>> surinder.ku...@enterprisedb.com> wrote:
>>
>>> On Mon, Jul 17, 2017 at 4:52 PM, Dave Page  wrote:
>>>
 Hi

 No errors now, but do you know why JS tests are being skipped?

>>> ​No errors/warning in console even after settings `logLevel:
>>> config.LOG_DEBUG`. I am still debugging.
>>>

 PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 4 of 216 (skipped 212)
 SUCCESS (0.085 secs / 0.046 secs)

 Thanks!

 On Mon, Jul 17, 2017 at 12:07 PM, Surinder Kumar <
 surinder.ku...@enterprisedb.com> wrote:

> ​Hi Dave,
>
> I didn't removed the vendor modules when i ran regression test cases,
> so modules were being referenced from vendor dir and passed for me.
> Now I have fixed path references and test cases are working.
>
> Please find attached patch.
>
> Thanks
> Surinder​
>
> On Mon, Jul 17, 2017 at 3:18 PM, Surinder Kumar <
> surinder.ku...@enterprisedb.com> wrote:
>
>> Hi
>>
>> I'm currently working on first TODO: "Automatically handle static and
>> template JS files"
>>
>> As discussed with Ashesh, currently the paths to module id are
>> written manually in webpack.config.js, instead the path defined in 
>> moudle's
>> `def get_own_javascript()`  should be used.
>>
>> So, we will be generating a paths.json file which will contain:
>>
>> 1. resolve > alias - path with reference to module id.(Static files)
>>
>> 2. externals - list of modules to be loaded dynamically on
>> demand(Template files)
>>
>> 3. Shim module dependency
>>
>> 4. List of JS modules to be loaded in specified order.
>>
>> *Implementation:*
>>
>> To generate `paths.json` file, we will be using `Flask's test_client`
>> to make an http request internally within the app context so we can call
>> `current_app.javascripts` property and return the list of JS paths and
>> write those into paths.json file and then use it in webpack.shim.js 
>> before
>> the execution of `yarn run bundle` in `javascript_bundler.py`
>>
>> *For example:*
>>
>> @app.route('/get_script_paths')
>> def get_script_paths():
>> from flask import current_app
>> from pgadmin.utils.ajax import make_json_response
>>
>> return make_json_response(data=current_app.javascripts)
>>
>> if config.DEBUG:
>> with app.test_client() as client:
>> import simplejson as json
>> list_scripts = client.get('/get_script_paths')
>> scripts = json.loads(list_scripts.data)
>>
>> javascriptBundler = JavascriptBundler()
>> javascriptBundler.bundle(scripts['data'])
>>
>>
>> This also needs little change in module dependency we defined using
>> 'When': 'node_name' in `def get_own_javascripts(...)` method
>> the module specified(name: module_name) is loaded when module given
>> in `When` is expanded in node. Since we are using Webpack in which
>> behaviour to load module is little different.
>>
>> Now in webpack we are using `imports-loader` to load specific
>> modules. So this is how it should work.
>>
>> 1. First load all modules which do not have dependency on any node
>> like 'about', 'dashboard',  'server-group', 'server' etc.
>>
>> 2. Load module such as `Databases` node first before its child nodes
>> are loaded.
>> Similarly load `Schemas` node before its child nodes are loaded as
>> they are dependent on parent node.
>>
>> Thanks,
>> Surinder
>> On Wed, Jul 5, 2017 at 8:22 PM, Sarah McAlear 
>> wrote:
>>
>>> Hello,
>>>
>>>
 *​Things to discuss:*

 How to differentiate between a static and template JS
 ​​
 .

>>>
>>> What is the advantage of webpacking templated JS? It seems as though
>>> this creates a system in which the bundled dependencies have to refer 
>>> back
>>> to the backend to load the templates.
>>>
>> ​Templated JS will not be part of generated bundle JS, they will load
>> externally( an extra request will be made to server For example:
>> translations.js)
>>
>>>
>>> If there is a performance win in packing templated JS then looking
>>> at it makes sense.  Otherwise it may make sense to put off until it is
>>> clear that the templated files should be dealt with by either 
>

[pgAdmin4][Patch]: Backform control visibility fix

2017-07-25 Thread Khushboo Vashi
Hi,

Please find the attached patch to handle the control visibility even in the
javascript strict mode.

Thanks,
Khushboo
diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/role/js/role.js b/web/pgadmin/browser/server_groups/servers/roles/templates/role/js/role.js
index 1c0917d..44703f1 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/templates/role/js/role.js
+++ b/web/pgadmin/browser/server_groups/servers/roles/templates/role/js/role.js
@@ -174,10 +174,10 @@ define('pgadmin.node.role', [
   }
 
   // Clean up first
-  this.$el.removeClass(Backform.hiddenClassname);
+  this.$el.removeClass(Backform.hiddenClassName);
 
   if (!data.visible)
-this.$el.addClass(Backform.hiddenClassname);
+this.$el.addClass(Backform.hiddenClassName);
 
   this.$el.html(this.template(data)).addClass(field.name);
   this.updateInvalid();
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index af95d9f..e3b5b6c 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -227,10 +227,10 @@
   });
 
   // Clean up first
-  this.$el.removeClass(Backform.hiddenClassname);
+  this.$el.removeClass(Backform.hiddenClassName);
 
   if (!data.visible)
-this.$el.addClass(Backform.hiddenClassname);
+this.$el.addClass(Backform.hiddenClassName);
 
   this.$el.html(this.template(data)).addClass(field.name);
   this.updateInvalid();
@@ -346,10 +346,10 @@
 }
 
 // Clean up first
-this.$el.removeClass(Backform.hiddenClassname);
+this.$el.removeClass(Backform.hiddenClassName);
 
 if (!data.visible)
-  this.$el.addClass(Backform.hiddenClassname);
+  this.$el.addClass(Backform.hiddenClassName);
 
 this.$el.html(this.template(data)).addClass(field.name);
 this.updateInvalid();
@@ -1179,10 +1179,10 @@
   var grid = (data.subnode == undefined) ? "" : this.showGridControl(data);
 
   // Clean up first
-  this.$el.removeClass(Backform.hiddenClassname);
+  this.$el.removeClass(Backform.hiddenClassName);
 
   if (!data.visible)
-this.$el.addClass(Backform.hiddenClassname);
+this.$el.addClass(Backform.hiddenClassName);
 
   this.$el.html(grid).addClass(field.name);
   this.updateInvalid();
@@ -1787,10 +1787,10 @@
   }
 
   // Clean up first
-  this.$el.removeClass(Backform.hiddenClassname);
+  this.$el.removeClass(Backform.hiddenClassName);
 
   if (!data.visible)
-this.$el.addClass(Backform.hiddenClassname);
+this.$el.addClass(Backform.hiddenClassName);
 
   this.$el.html(this.template(data)).addClass(field.name);
 
@@ -2065,7 +2065,7 @@
   }
 
   if (!isVisible)
-self.$el.addClass(Backform.hiddenClassname);
+self.$el.addClass(Backform.hiddenClassName);
 
   // There is an issue with the Code Mirror SQL.
   //
@@ -2277,14 +2277,14 @@
   if (this.has_datepicker)
 this.$el.find("input").datetimepicker('destroy');
   this.$el.empty();
-  this.$el.removeClass(Backform.hiddenClassname);
+  this.$el.removeClass(Backform.hiddenClassName);
 
 
   this.$el.html(this.template(data)).addClass(field.name);
 
   if (!data.visible) {
 this.has_datepicker = false;
-this.$el.addClass(Backform.hiddenClassname);
+this.$el.addClass(Backform.hiddenClassName);
   } else {
 this.has_datepicker = true;
 var self = this;


[pgAdmin4][Patch]: Fixed RM #2603 - Import/Export File issues

2017-07-26 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix the RM #2603: Import/Export File
issues.

Fixed Issues:
 1. Couldn't click on the File Control once gets an error
 2. The encoding is not in alphabetical order

Thanks,
Khsuhboo
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/get_encodings.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/get_encodings.sql
index 7d583b0..e8e531c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/get_encodings.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/get_encodings.sql
@@ -6,7 +6,7 @@ SELECT *
 FROM
 (SELECT pg_encoding_to_char(s.i) AS encoding
 FROM (SELECT generate_series(0, 100, 1) as i) s) a
-WHERE encoding != '';
+WHERE encoding != '' ORDER BY encoding;
 
 {#
 -- For future use, Do not delete
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/get_encodings.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/get_encodings.sql
index 0058423..4ef6379 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/get_encodings.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/get_encodings.sql
@@ -5,7 +5,7 @@
 SELECT * FROM
 (SELECT pg_encoding_to_char(s.i) AS encoding
 FROM (SELECT generate_series(0, 100, 1) as i) s) a
-WHERE encoding != '';
+WHERE encoding != '' ORDER BY encoding;
 
 {#
 -- For future use, Do not delete
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index e3b5b6c..bfad2b4 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -2201,6 +2201,16 @@
 
   // Set selected value into the model
   this.model.set(name, decodeURI(value));
+},
+clearInvalid: function() {
+  Backform.InputControl.prototype.clearInvalid.apply(this, arguments);
+  this.$el.removeClass("pgadmin-file-has-error");
+  return this;
+},
+updateInvalid: function() {
+  Backform.InputControl.prototype.updateInvalid.apply(this, arguments);
+  // Introduce a new class to fix the error icon placement on the control
+  this.$el.addClass("pgadmin-file-has-error");
 }
   });
 
diff --git a/web/pgadmin/static/scss/_backform.overrides.scss b/web/pgadmin/static/scss/_backform.overrides.scss
index 8527880..9c2f41c 100644
--- a/web/pgadmin/static/scss/_backform.overrides.scss
+++ b/web/pgadmin/static/scss/_backform.overrides.scss
@@ -18,4 +18,10 @@
 padding-top: 10px;
 z-index: 1;
   }
-}
\ No newline at end of file
+}
+
+.pgadmin-file-has-error {
+  .pgadmin-controls:before {
+right: 40px !important;
+  }
+}


[pgAdmin4][Patch]: Dashboard requests don't stop even after closing the panel

2017-07-26 Thread Khushboo Vashi
Hi,

If we close the Dashboard tab even then the requests don't stop. This is
the regression of web-packing of browser.js file.
Please find the attached patch for the same.

Thanks,
Khushboo
diff --git a/web/pgadmin/browser/templates/browser/js/browser.js b/web/pgadmin/browser/templates/browser/js/browser.js
index c353418..c89cfb8 100644
--- a/web/pgadmin/browser/templates/browser/js/browser.js
+++ b/web/pgadmin/browser/templates/browser/js/browser.js
@@ -222,7 +222,8 @@ define(
 isCloseable: panel.isCloseable,
 isPrivate: panel.isPrivate,
 content: (panel.content) ? panel.content : '',
-events: (panel.events) ? panel.events : ''
+events: (panel.events) ? panel.events : '',
+canHide: (panel.canHide) ? panel.canHide : ''
   })
 }
   });


Re: Error using pgadmin4 HEAD

2017-07-27 Thread Khushboo Vashi
Hi Dave,

Please provide below information to investigate:

1. OS Details
2. pgAdmin 4 version
3. The steps you followed to install the application


pgAdmin 4 documentation
 to help in
deployment process.

Thanks,
Khushboo

On Fri, Jul 28, 2017 at 3:08 AM, Dave Cramer  wrote:

> When I start pgadmin4 application I get the following error
>
> The application server could not be contacted!
>
> Thanks,
>
> Dave Cramer
>


Re: [gpAdmin4][patch] query history updates

2017-08-08 Thread Khushboo Vashi
Hi Wenlin & Violet,


On Tue, Aug 8, 2017 at 12:05 PM, Wenlin Zhang  wrote:

> Hi Khushboo,
>
>  Thanks for your review.
>
>  About the copy/paste function bug, we just found that this is an
> existing bug in master. Except for the query History tab, this bug also
> exist in the query data output . If you copy the data row in "Data Output"
> tab,  it works fine, but the copy/paste in query tool won't work either. We
> will create a Redmine bug later.
>
>  And the feature test failure, we've already sent a new patch that
> fixed it. See this patch
> <https://www.postgresql.org/message-id/flat/CAEawo3JKQFuVeSK-xw9wU4fUSY57KXU5GeXKcdCusQeHkjTykA%40mail.gmail.com>
>
> I need to test this patch with the history tab update patch. Right now I
can not apply this patch on top of the history update patch.
Can you please re-base that patch?

> Thanks,
>
> Wenlin & Violet
>
>
> On Mon, Aug 7, 2017 at 1:45 PM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi Sarah & Hao,
>>
>> The copy/paste functionality through the added copy button is working
>> fine, however once I copy the query text from the History tab through the
>> copy button, I can not perform copy/paste for some another text in the
>> Query tool.
>>
>> Also, the feature test (QueryToolJourneyTest) is failing, please refer
>> the attached screen-shot.
>>
>> Thanks,
>> Khushboo
>>
>> On Thu, Aug 3, 2017 at 9:03 AM, Hao Wang  wrote:
>>
>>> Hi Hackers,
>>>
>>> Here is a patch for query tools history UX improvements:
>>>
>>>- Add copy button for query text
>>>- Historical queries are binned by day
>>>
>>> Thanks,
>>> Sarah & Hao
>>>
>>
>>
>
Thanks,
Khushboo


Re: [pgAdmin4][patch] Fix feature tests failure

2017-08-08 Thread Khushboo Vashi
Hi Sarah,

I am doing this and didn't reply on this thread as we are discussing this
on the another thread (the History Update patch).

Thanks,
Khushboo

On Wed, Aug 9, 2017 at 9:10 AM, Sarah McAlear  wrote:

> Hi Hackers!
>
> Could someone review this patch, please?
>
> Thanks so much!
> Sarah
>
> On Mon, Aug 7, 2017 at 4:42 PM, Wenlin Zhang  wrote:
>
>> Hi Hackers,
>>
>> This patch is about fixing the feature tests failure.
>>
>> Thanks,
>> Wenlin, Violet & Hao
>>
>
>


Re: [gpAdmin4][patch] query history updates

2017-08-09 Thread Khushboo Vashi
Hi,

The patch looks good to me.
The feature test for the QueryToolJourneyTest still fails on my Ubuntu
machine with/without this patch
<https://www.postgresql.org/message-id/flat/CAEawo3JKQFuVeSK-xw9wU4fUSY57KXU5GeXKcdCusQeHkjTykA%40mail.gmail.com>,
but works on Mac.

Thanks,
Khushboo


On Wed, Aug 9, 2017 at 9:07 AM, Sarah McAlear  wrote:

> Hi Khushboo!
>
> These are 2 separate patches. The failure of the feature test you're
> describing happens on Master even without this patch. The other patch fixes
> this, but is unrelated to this patch. Right now it applies cleanly on
> Master. If we rebase it here, we won't be able to apply it on master.
>
> Thanks,
> Sarah
>
> On Tue, Aug 8, 2017 at 6:27 PM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi Wenlin & Violet,
>>
>>
>> On Tue, Aug 8, 2017 at 12:05 PM, Wenlin Zhang  wrote:
>>
>>> Hi Khushboo,
>>>
>>>  Thanks for your review.
>>>
>>>  About the copy/paste function bug, we just found that this is an
>>> existing bug in master. Except for the query History tab, this bug also
>>> exist in the query data output . If you copy the data row in "Data Output"
>>> tab,  it works fine, but the copy/paste in query tool won't work either. We
>>> will create a Redmine bug later.
>>>
>>>  And the feature test failure, we've already sent a new patch that
>>> fixed it. See this patch
>>> <https://www.postgresql.org/message-id/flat/CAEawo3JKQFuVeSK-xw9wU4fUSY57KXU5GeXKcdCusQeHkjTykA%40mail.gmail.com>
>>>
>>> I need to test this patch with the history tab update patch. Right now I
>> can not apply this patch on top of the history update patch.
>> Can you please re-base that patch?
>>
>>> Thanks,
>>>
>>> Wenlin & Violet
>>>
>>>
>>> On Mon, Aug 7, 2017 at 1:45 PM, Khushboo Vashi <
>>> khushboo.va...@enterprisedb.com> wrote:
>>>
>>>> Hi Sarah & Hao,
>>>>
>>>> The copy/paste functionality through the added copy button is working
>>>> fine, however once I copy the query text from the History tab through the
>>>> copy button, I can not perform copy/paste for some another text in the
>>>> Query tool.
>>>>
>>>> Also, the feature test (QueryToolJourneyTest) is failing, please refer
>>>> the attached screen-shot.
>>>>
>>>> Thanks,
>>>> Khushboo
>>>>
>>>> On Thu, Aug 3, 2017 at 9:03 AM, Hao Wang  wrote:
>>>>
>>>>> Hi Hackers,
>>>>>
>>>>> Here is a patch for query tools history UX improvements:
>>>>>
>>>>>- Add copy button for query text
>>>>>- Historical queries are binned by day
>>>>>
>>>>> Thanks,
>>>>> Sarah & Hao
>>>>>
>>>>
>>>>
>>>
>> Thanks,
>> Khushboo
>>
>
>


Re: [pgAdmin4][patch] extract generate_url function from node.js and collection.js

2017-08-16 Thread Khushboo Vashi
Hi,

The patch looks good to me.

> Thanks,
Khushboo

On Fri, Aug 11, 2017 at 12:08 PM, Ashesh Vashi <
ashesh.va...@enterprisedb.com> wrote:

> On Thu, Aug 10, 2017 at 1:15 PM, Violet Cheng  wrote:
>
>> Hi hackers,
>>
>> We tried to extract and refactor generate_url function in node.js and
>> collection.js. Please see the patch attached.
>>
> Khushboo,
>
> Please review this one.
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> 
>
>
> *http://www.linkedin.com/in/asheshvashi*
> 
>
>>
>> Thanks,
>> Violet & Sarah
>>
>
>


Re: v2.0 RC2 test builds

2017-09-19 Thread Khushboo Vashi
The setting which worked for me is "*Anywhere", not "**App Store and
identified developers" for me*.

On Tue, Sep 19, 2017 at 4:29 PM, Dave Page  wrote:

> Is this accurate?
>
> https://www.pgadmin.org/faq/#9
>
> On Tue, Sep 19, 2017 at 10:58 AM, Dave Page  wrote:
>
>>
>>
>> On Tue, Sep 19, 2017 at 10:21 AM, Surinder Kumar <
>> surinder.ku...@enterprisedb.com> wrote:
>>
>>> Hi
>>> On Tue, Sep 19, 2017 at 1:51 PM, Dave Page  wrote:
>>>
 I assume that's the same as:

 Allow apps downloaded from:

  [ ] App Store
  [x] Apps Store and identified developers

>>> ​I see the same settings with second options ticked in my machine. but
>>> the error message "pgAdmin4 is damaged and can't be opened. You should
>>> eject the disk image" doesn't gives the clue to user to tick the settings
>>> "Allow apps downloaded from: anywhere".
>>>
>>> Can this message be changed or it is system defined?
>>>
>>
>> It's system defined :-(.
>>
>>
>>
>>>
>>>
 In later releases of macOS?


 On Tue, Sep 19, 2017 at 8:12 AM, Surinder Kumar <
 surinder.ku...@enterprisedb.com> wrote:

> Hi Fahar,
>
> It gets installed successfully when I checked the option "Allow apps
> downloaded from" to "Anywhere" in Security & Privacy option.
> However, If I install another downloaded app, It asks the user to
> enable the install for this app by going to Security & Privacy option.
>
> Thanks to Khushboo for help.
>
> On Tue, Sep 19, 2017 at 11:36 AM, Fahar Abbas <
> fahar.ab...@enterprisedb.com> wrote:
>
>> Hi Surinder,
>>
>> I tested pgAdmin4 Build on MAC 10.10 and i don't see any issue
>> related to this.
>>
>> Steps:
>> 1. Downloaded MAC OS Build on 10.12 Firefox Browser and then scp on
>> MAC 10.10 fresh VM.
>>
>> Note: pgAdmin4 will not work on MAC 10.9 and we have already dropped
>> this support.
>>
>> Can you please share the exact steps so it could reproduce on my
>> fresh VM?
>>
>> Kind Regards,
>>
>>
>> On Tue, Sep 19, 2017 at 10:45 AM, Surinder Kumar <
>> surinder.ku...@enterprisedb.com> wrote:
>>
>>> Hi
>>>
>>> Today I downloaded the pgAdmin4 build(pgadmin4-2.0-rc2.dmg
>>> )
>>> for Mac but it is failed to open. When I double click on pgAdmin4 icon 
>>> to
>>> open pgAdmin4, I got an error, please refer the screenshot attached.
>>>
>>> *OS details:*
>>>
>>> Mac OS X Yosemite
>>> Version 10.10.2
>>>
>>> Even on Akshay's machine pgAdmin4 doesn't open
>>>
>>> *OS details:*
>>>
>>> Mac OS X Mavericks
>>> Version 10.09.05
>>>
>>> *Error:*
>>>
>>> The application server couldn't be contacted.
>>>
>>> @Fahar, Can you please verify If you got same error?
>>>
>>> Thanks,
>>> Surinder
>>>
>>>
>>> On Tue, Sep 19, 2017 at 1:27 AM, Anthony DeBarros <
>>> adebar...@gmail.com> wrote:
>>>
 No show-stoppers to report. Just to say that it looks great and
 loads fast. Nice work!

 Only stylistic item is that the column names in the result grid
 used to be bold but are now the same weight as the data type.

 Anthony


 On September 18, 2017 at 12:13:03 PM, Dave Page (dp...@pgadmin.org)
 wrote:

 I've put v2.0-rc2 test builds at https://developer.pgadmin.o
 rg/~dpage/2.0-rc2/ for anyone who needs them. Please report any
 show-stopper issues ASAP!

 Devrim; these includes the WSGI fix needed for the problem I ran
 into when testing the RPMs in web mode.

 Thanks.

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

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


>>>
>>
>>
>> --
>> Fahar Abbas
>> QMG
>> EnterpriseDB Corporation
>> Phone Office: +92-51-835-8874
>> Phone Direct: +92-51-8466803 <+92%2051%208466803>
>> Mobile: +92-333-5409707 <+92%20333%205409707>
>> Skype ID: syed.fahar.abbas
>> Website: www.enterprisedb.com
>>
>
>


 --
 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
>>
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


[pgAdmin4][Patch]: RM #2651 : "Create Script" view of functions always shows "ROWS 0"

2017-11-01 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix RM #2651 : "Create Script" view of
functions always shows "ROWS 0".

Right now function displays ROWS 0 in case of empty ROWS field. Now it will
display correct value of the filed. This has been fixed in
Create/Update/View function.


Thanks,
Khushboo
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
index dd677a1..a740b41 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
@@ -1132,7 +1132,7 @@ class FunctionView(PGChildNodeView, DataTypeReader):
 fun_change_args = ['lanname', 'prosrc', 'probin', 'prosrc_c',
'provolatile', 'proisstrict', 'prosecdef',
'proparallel', 'procost', 'proleakproof',
-   'arguments']
+   'arguments', 'prorows']
 
 data['change_func'] = False
 for arg in fun_change_args:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/create.sql
index 7300fd8..c4864db 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/create.sql
@@ -23,7 +23,7 @@ CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ con
 {% if data.proisstrict %}STRICT {% endif %}
 {% if data.prosecdef %}SECURITY DEFINER {% endif %}
 {% if data.proiswindow %}WINDOW{% endif %}
-{% if data.prorows %}
+{% if data.prorows and (data.prorows | int) > 0 %}
 
 ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %}
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/update.sql
index 9e69a1a..6f092a8 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/update.sql
@@ -29,7 +29,7 @@ CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if d
 
 {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows %}
 
-ROWS {{data.prorows}}{% elif o_data.prorows and o_data.prorows != '0' %}ROWS {{o_data.prorows}}{% endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %}
+ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %}ROWS {{o_data.prorows}}{% endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %}
 
 SET {{ conn|qtIdent(v.name) }}={{ v.value|qtLiteral }}{% endfor -%}
 {% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/create.sql
index 0f7f4f0..f030af41 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/create.sql
@@ -23,7 +23,7 @@ CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ con
 {% if data.proisstrict %}STRICT {% endif %}
 {% if data.prosecdef %}SECURITY DEFINER {% endif %}
 {% if data.proiswindow %}WINDOW{% endif %}
-{% if data.prorows %}
+{% if data.prorows and (data.prorows | int) > 0 %}
 
 ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %}
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/update.sql
index be24303..5d6926b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/update.sql
@@ -30,7 +30,7 @@ CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if d
 
 {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}

[pgAdmin4][Patch]: RM #2846: Add a context menu option to manually (re)count rows in tables

2017-11-07 Thread Khushboo Vashi
Hi,

Please find the attached patch for RM #2846 : Add a context menu option to
manually (re)count rows in tables, including those with >2K rows

Thanks,
Khushboo
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
index 1b24ee5..aa2adc9 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
@@ -242,7 +242,8 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings):
 'select_sql': [{'get': 'select_sql'}],
 'insert_sql': [{'get': 'insert_sql'}],
 'update_sql': [{'get': 'update_sql'}],
-'delete_sql': [{'get': 'delete_sql'}]
+'delete_sql': [{'get': 'delete_sql'}],
+'count_rows': [{'get': 'count_rows'}]
 })
 
 @BaseTableView.check_precondition
@@ -346,7 +347,8 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings):
 icon="icon-partition" if 'is_partitioned' in row and row['is_partitioned'] else "icon-table",
 tigger_count=row['triggercount'],
 has_enable_triggers=row['has_enable_triggers'],
-is_partitioned=row['is_partitioned'] if 'is_partitioned' in row else False
+is_partitioned=row['is_partitioned'] if 'is_partitioned' in row else False,
+rows_cnt=0
 ))
 
 return make_json_response(
@@ -1461,4 +1463,39 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings):
 """
 return BaseTableView.get_table_statistics(self, scid, tid)
 
+@BaseTableView.check_precondition
+def count_rows(self, gid, sid, did, scid, tid):
+"""
+Count the rows of a table.
+Args:
+gid: Server Group Id
+sid: Server Id
+did: Database Id
+scid: Schema Id
+tid: Table Id
+
+Returns the total rows of a table.
+"""
+data = {}
+data['schema'], data['name'] = \
+super(TableView, self).get_schema_and_table_name(tid)
+
+SQL = render_template(
+"/".join(
+[self.table_template_path, 'get_table_row_count.sql']
+), data=data
+)
+
+status, count = self.conn.execute_scalar(SQL)
+
+if not status:
+return internal_server_error(errormsg=count)
+
+return make_json_response(
+status=200,
+info=gettext("Table rows counted"),
+data={'total_rows': count}
+)
+
+
 TableView.register_node_view(blueprint)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
index 90217e0..359a356 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
@@ -90,6 +90,11 @@ define('pgadmin.node.table', [
   applies: ['object', 'context'], callback: 'reset_table_stats',
   category: 'Reset', priority: 4, label: gettext('Reset Statistics'),
   icon: 'fa fa-bar-chart', enable : 'canCreate'
+},{
+  name: 'count_table_rows', node: 'table', module: this,
+  applies: ['object', 'context'], callback: 'count_table_rows',
+  category: 'Count', priority: 2, label: gettext('Count'),
+  enable: true
 }
 ]);
 pgBrowser.Events.on(
@@ -206,8 +211,8 @@ define('pgadmin.node.table', [
 }
   }, function() {}
 );
-   },
-   reset_table_stats: function(args) {
+},
+reset_table_stats: function(args) {
   var input = args || {},
 obj = this,
 t = pgBrowser.tree,
@@ -255,7 +260,41 @@ define('pgadmin.node.table', [
 },
 function() {}
   );
-   }
+},
+count_table_rows: function(args) {
+  var input = args || {},
+  obj = this,
+  t = pgBrowser.tree,
+  i = input.item || t.selected(),
+  d = i && i.length == 1 ? t.itemData(i) : undefined;
+  if (!d)
+return false;
+
+  // Fetch the total rows of a table
+  $.ajax({
+url: obj.generate_url(i, 'count_rows' , d, true),
+type:'GET',
+success: function(res) {
+alertify.success(res.info);
+d.rows_cnt = res.data.total_rows;
+t.unload(i);
+t.setInode(i);
+t.deselect(i);
+setTimeout(function() {
+  t.select(i);
+}, 10);
+},
+error: function(xhr, status, error) {
+  try {
+  

[pgAdmin4][Patch]: RM #2781 - New option to set the quotation mark for copying to clipboard.

2017-11-16 Thread Khushboo Vashi
Hi,

Please find the attached patch for RM #2781 : New option to set the
quotation mark for copying to clipboard.

This patch includes:

- Provide options in preferences to control the CSV output which includes
copy to clipboard and download as CSV features in Query Tool
- Modified related jasmine tests
- Modified related feature tests

Thanks,
Khushboo
diff --git a/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py b/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
index d01bf66..41fd6da 100644
--- a/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
+++ b/web/pgadmin/feature_tests/copy_selected_query_results_feature_test.py
@@ -66,7 +66,7 @@ class CopySelectedQueryResultsFeatureTest(BaseFeatureTest):
 
 self.page.find_by_xpath("//*[@id='btn-copy-row']").click()
 
-self.assertEqual("'Some-Name','6','some info'",
+self.assertEqual('"Some-Name","6","some info"',
  pyperclip.paste())
 
 def _copies_columns(self):
@@ -75,9 +75,9 @@ class CopySelectedQueryResultsFeatureTest(BaseFeatureTest):
 self.page.find_by_xpath("//*[@id='btn-copy-row']").click()
 
 self.assertEqual(
-"""'Some-Name'
-'Some-Other-Name'
-'Yet-Another-Name'""",
+"""\"Some-Name"
+"Some-Other-Name"
+"Yet-Another-Name\,
 pyperclip.paste())
 
 def _copies_row_using_keyboard_shortcut(self):
@@ -86,7 +86,7 @@ class CopySelectedQueryResultsFeatureTest(BaseFeatureTest):
 
 ActionChains(self.page.driver).key_down(Keys.CONTROL).send_keys('c').key_up(Keys.CONTROL).perform()
 
-self.assertEqual("'Some-Name','6','some info'",
+self.assertEqual('"Some-Name","6","some info"',
  pyperclip.paste())
 
 def _copies_column_using_keyboard_shortcut(self):
@@ -96,9 +96,9 @@ class CopySelectedQueryResultsFeatureTest(BaseFeatureTest):
 ActionChains(self.page.driver).key_down(Keys.CONTROL).send_keys('c').key_up(Keys.CONTROL).perform()
 
 self.assertEqual(
-"""'Some-Name'
-'Some-Other-Name'
-'Yet-Another-Name'""",
+"""\"Some-Name"
+"Some-Other-Name"
+"Yet-Another-Name\,
 pyperclip.paste())
 
 def _copies_rectangular_selection(self):
@@ -112,8 +112,8 @@ class CopySelectedQueryResultsFeatureTest(BaseFeatureTest):
 .release(bottom_right_cell).perform()
 ActionChains(self.page.driver).key_down(Keys.CONTROL).send_keys('c').key_up(Keys.CONTROL).perform()
 
-self.assertEqual("""'Some-Other-Name','22'
-'Yet-Another-Name','14'""", pyperclip.paste())
+self.assertEqual("""\"Some-Other-Name","22"
+"Yet-Another-Name","14\, pyperclip.paste())
 
 def _shift_resizes_rectangular_selection(self):
 pyperclip.copy("old clipboard contents")
@@ -128,8 +128,8 @@ class CopySelectedQueryResultsFeatureTest(BaseFeatureTest):
 ActionChains(self.page.driver).key_down(Keys.SHIFT).send_keys(Keys.ARROW_RIGHT).key_up(Keys.SHIFT).perform()
 ActionChains(self.page.driver).key_down(Keys.CONTROL).send_keys('c').key_up(Keys.CONTROL).perform()
 
-self.assertEqual("""'Some-Other-Name','22','some other info'
-'Yet-Another-Name','14','cool info'""", pyperclip.paste())
+self.assertEqual("""\"Some-Other-Name","22","some other info"
+"Yet-Another-Name","14","cool info\, pyperclip.paste())
 
 def _shift_resizes_column_selection(self):
 pyperclip.copy("old clipboard contents")
@@ -141,9 +141,9 @@ class CopySelectedQueryResultsFeatureTest(BaseFeatureTest):
 ActionChains(self.page.driver).key_down(Keys.CONTROL).send_keys('c').key_up(Keys.CONTROL).perform()
 
 self.assertEqual(
-"""'Some-Name','6'
-'Some-Other-Name','22'
-'Yet-Another-Name','14'""",
+"""\"Some-Name","6"
+"Some-Other-Name","22"
+"Yet-Another-Name","14\,
 pyperclip.paste())
 
 def _mouseup_outside_grid_still_makes_a_selection(self):
@@ -160,7 +160,7 @@ class CopySelectedQueryResultsFeatureTest(BaseFeatureTest):
 
 ActionChains(self.page.driver).key_down(Keys.CONTROL).send_keys('c').key_up(Keys.CONTROL).perform()
 
-self.assertEqual("'cool info'", pyperclip.paste())
+self.assertEqual('"cool info"', pyperclip.paste())
 
 def after(self):
 self.page.close_query_tool()
diff --git a/web/pgadmin/feature_tests/query_tool_journey_test.py b/web/pgadmin/feature_tests/query_tool_journey_test.py
index 87514b1..6b79948 100644
--- a/web/pgadmin/feature_tests/query_tool_journey_test.py
+++ b/web/pgadmin/feature_tests/query_tool_journey_test.py
@@ -54,7 +54,7 @@ class QueryToolJourneyTest(BaseFeatureTest):
 self.page.find_by_xpath("//*[contains(@class, 'slick-row')]/*[1]").click()
 self.page.find_by_xpath("//*[@id='btn-copy-row']").click()
 
-self.assertEqual("'Some-Name','6','some info'",
+self.assertEqual('"Some-Name","6","some info"',
  pype

Re: [pgAdmin4][Patch]: RM #2781 - New option to set the quotation mark for copying to clipboard.

2017-11-16 Thread Khushboo Vashi
Hi Dave,

Thanks for reviewing the patch.

On Thu, Nov 16, 2017 at 7:42 PM, Dave Page  wrote:

> Hi
>
> On Thu, Nov 16, 2017 at 10:01 AM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Please find the attached patch for RM #2781 : New option to set the
>> quotation mark for copying to clipboard.
>>
>> This patch includes:
>>
>> - Provide options in preferences to control the CSV output which includes
>> copy to clipboard and download as CSV features in Query Tool
>> - Modified related jasmine tests
>> - Modified related feature tests
>>
>
> Thanks. At first glance, I see a few issues with this patch:
>
> - I can type into the combo boxes in the preferences, but only to search.
> That means (for example) that the only quote character I can use is ". I
> can't use anything else as a might want. The same applies to the field
> separator.
>
> - I can click the x to clear the options in the combo boxes, but then the
> settings can be accepted and stored. For the separator and quote char, I
> assume they just become blank, however the quoting method makes no sense to
> be unspecified.
>
> Will fix above issues.


> - There don't seem to be any documentation updates.
>
> Will do.

> - The CSV Quoting options appear to apply to copying from the grid, but
> they should apply to saving results as CSV.
>
>
All 3 CSV options are applicable for both, copying from grid and download
as CSV as I understood this way.
I had a doubt regarding this and have asked regarding this in the ticket
but didn't get reply, so implemented this way.
Now I understood correctly, so will change accordingly.


> - The Result Copy quoting options (which should apply to copied data) are
> missing altogether.
>
> To be clear, there should be 6 new config options, 3 of which apply to
> data when copied from the grid, and the other 3 which apply when saving
> data as CSV. Please see the original RM case in which I detailed what the
> settings should be and what they should do.
>
> Thanks.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>

Thanks,
Khushboo


Re: [pgAdmin4][Patch]: RM #2781 - New option to set the quotation mark for copying to clipboard.

2017-11-20 Thread Khushboo Vashi
On 20 Nov 2017 19:45, "Dave Page"  wrote:

Though whilst it worked fine when I was testing, I now get the following.
Khushboo - can you investigate please?

Exception in thread Thread-96:

Traceback (most recent call last):

File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
line 810, in __bootstrap_inner

self.run()

File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
line 763, in run

self.__target(*self.__args, **self.__kwargs)

File "/System/Library/Frameworks/Python.framework/Versions/2.7/
lib/python2.7/SocketServer.py", line 602, in process_request_thread

self.handle_error(request, client_address)

File "/System/Library/Frameworks/Python.framework/Versions/2.7/
lib/python2.7/SocketServer.py", line 599, in process_request_thread

self.finish_request(request, client_address)

File "/System/Library/Frameworks/Python.framework/Versions/2.7/
lib/python2.7/SocketServer.py", line 334, in finish_request

self.RequestHandlerClass(request, client_address, self)

File "/System/Library/Frameworks/Python.framework/Versions/2.7/
lib/python2.7/SocketServer.py", line 655, in __init__

self.handle()

File 
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
line 200, in handle

rv = BaseHTTPRequestHandler.handle(self)

File "/System/Library/Frameworks/Python.framework/Versions/2.7/
lib/python2.7/BaseHTTPServer.py", line 340, in handle

self.handle_one_request()

File 
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
line 235, in handle_one_request

return self.run_wsgi()

File 
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
line 177, in run_wsgi

execute(self.server.app)

File 
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
line 167, in execute

for data in application_iter:

File 
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/wsgi.py",
line 691, in __next__

return self._next()

File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
packages/werkzeug/wrappers.py", line 81, in _iter_encoded

for item in iterable:

File "/Users/dpage/git/pgadmin4/web/pgadmin/utils/driver/psycopg2/__init__.py",
line 828, in gen

quotechar=quote_char

File 
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/backports/csv.py",
line 670, in __init__

self.writer = writer(f, dialect, *args, **kwds)

File 
"/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/backports/csv.py",
line 185, in __init__

raise TypeError(*e.args)

TypeError: "delimiter" must be string, not bytes

Please share your CSV Output settings.


On Mon, Nov 20, 2017 at 1:51 PM, Dave Page  wrote:

> Thanks, applied.
>
> On Mon, Nov 20, 2017 at 5:18 AM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Please find the attached updated patch.
>>
>>
>> On Thu, Nov 16, 2017 at 7:42 PM, Dave Page  wrote:
>>
>>> Hi
>>>
>>> On Thu, Nov 16, 2017 at 10:01 AM, Khushboo Vashi <
>>> khushboo.va...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Please find the attached patch for RM #2781 : New option to set the
>>>> quotation mark for copying to clipboard.
>>>>
>>>> This patch includes:
>>>>
>>>> - Provide options in preferences to control the CSV output which
>>>> includes copy to clipboard and download as CSV features in Query Tool
>>>> - Modified related jasmine tests
>>>> - Modified related feature tests
>>>>
>>>
>>> Thanks. At first glance, I see a few issues with this patch:
>>>
>>> - I can type into the combo boxes in the preferences, but only to
>>> search. That means (for example) that the only quote character I can use is
>>> ". I can't use anything else as a might want. The same applies to the field
>>> separator.
>>>
>>
>>>
>> Provided provision to add user defined field separator and quote
>> character.
>>
>> - I can click the x to clear the options in the combo boxes, but then the
>>> settings can be accepted and stored. For the separator and quote char, I
>>> assume they just become blank, however the quoting method makes no sense to
>>> be unspecified.
>>>
>>> Fixed. User can not clear the combo-boxes.
>>
>> - There don't seem to be any documentation updates.
>>>
>> The documents of SQL Editor and Preferences are updated.
&g

Re: [pgAdmin4][Patch]: RM #2781 - New option to set the quotation mark for copying to clipboard.

2017-11-20 Thread Khushboo Vashi
Hi Dave,

Please find the attached patch to fix the issue.
I have fixed the issue looking at the error you got as I can not reproduce
the issue on Python 2.7 or Python 3.5.

Thanks,
Khushboo



On Mon, Nov 20, 2017 at 8:05 PM, Dave Page  wrote:

>
>
> On Mon, Nov 20, 2017 at 2:20 PM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>>
>>
>> On 20 Nov 2017 19:45, "Dave Page"  wrote:
>>
>> Though whilst it worked fine when I was testing, I now get the following.
>> Khushboo - can you investigate please?
>>
>> Exception in thread Thread-96:
>>
>> Traceback (most recent call last):
>>
>> File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
>> line 810, in __bootstrap_inner
>>
>> self.run()
>>
>> File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
>> line 763, in run
>>
>> self.__target(*self.__args, **self.__kwargs)
>>
>> File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py",
>> line 602, in process_request_thread
>>
>> self.handle_error(request, client_address)
>>
>> File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py",
>> line 599, in process_request_thread
>>
>> self.finish_request(request, client_address)
>>
>> File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py",
>> line 334, in finish_request
>>
>> self.RequestHandlerClass(request, client_address, self)
>>
>> File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py",
>> line 655, in __init__
>>
>> self.handle()
>>
>> File 
>> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
>> line 200, in handle
>>
>> rv = BaseHTTPRequestHandler.handle(self)
>>
>> File "/System/Library/Frameworks/Python.framework/Versions/2.7/li
>> b/python2.7/BaseHTTPServer.py", line 340, in handle
>>
>> self.handle_one_request()
>>
>> File 
>> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
>> line 235, in handle_one_request
>>
>> return self.run_wsgi()
>>
>> File 
>> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
>> line 177, in run_wsgi
>>
>> execute(self.server.app)
>>
>> File 
>> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
>> line 167, in execute
>>
>> for data in application_iter:
>>
>> File 
>> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/wsgi.py",
>> line 691, in __next__
>>
>> return self._next()
>>
>> File 
>> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/wrappers.py",
>> line 81, in _iter_encoded
>>
>> for item in iterable:
>>
>> File 
>> "/Users/dpage/git/pgadmin4/web/pgadmin/utils/driver/psycopg2/__init__.py",
>> line 828, in gen
>>
>> quotechar=quote_char
>>
>> File 
>> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/backports/csv.py",
>> line 670, in __init__
>>
>> self.writer = writer(f, dialect, *args, **kwds)
>>
>> File 
>> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/backports/csv.py",
>> line 185, in __init__
>>
>> raise TypeError(*e.args)
>>
>> TypeError: "delimiter" must be string, not bytes
>>
>> Please share your CSV Output settings.
>>
>
> Screenshot attached.
>
>
>
>>
>> On Mon, Nov 20, 2017 at 1:51 PM, Dave Page  wrote:
>>
>>> Thanks, applied.
>>>
>>> On Mon, Nov 20, 2017 at 5:18 AM, Khushboo Vashi <
>>> khushboo.va...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Please find the attached updated patch.
>>>>
>>>>
>>>> On Thu, Nov 16, 2017 at 7:42 PM, Dave Page  wrote:
>>>>
>>>>> Hi
>>>>>
>>>>> On Thu, Nov 16, 2017 at 10:01 AM, Khushboo Vashi <
>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>

Re: [pgAdmin4][Patch]: RM #2781 - New option to set the quotation mark for copying to clipboard.

2017-11-20 Thread Khushboo Vashi
Hi Dave,

Please find the attached patch.

Thanks,
Khushboo

On Mon, Nov 20, 2017 at 8:59 PM, Dave Page  wrote:

> Hi
>
> Thanks, but I'm still getting the same error.
>
>
On Mon, Nov 20, 2017 at 3:23 PM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> Please find the attached patch to fix the issue.
>> I have fixed the issue looking at the error you got as I can not
>> reproduce the issue on Python 2.7 or Python 3.5.
>>
>> Thanks,
>> Khushboo
>>
>>
>>
>> On Mon, Nov 20, 2017 at 8:05 PM, Dave Page  wrote:
>>
>>>
>>>
>>> On Mon, Nov 20, 2017 at 2:20 PM, Khushboo Vashi <
>>> khushboo.va...@enterprisedb.com> wrote:
>>>
>>>>
>>>>
>>>> On 20 Nov 2017 19:45, "Dave Page"  wrote:
>>>>
>>>> Though whilst it worked fine when I was testing, I now get the
>>>> following. Khushboo - can you investigate please?
>>>>
>>>> Exception in thread Thread-96:
>>>>
>>>> Traceback (most recent call last):
>>>>
>>>> File 
>>>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
>>>> line 810, in __bootstrap_inner
>>>>
>>>> self.run()
>>>>
>>>> File 
>>>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
>>>> line 763, in run
>>>>
>>>> self.__target(*self.__args, **self.__kwargs)
>>>>
>>>> File 
>>>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py",
>>>> line 602, in process_request_thread
>>>>
>>>> self.handle_error(request, client_address)
>>>>
>>>> File 
>>>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py",
>>>> line 599, in process_request_thread
>>>>
>>>> self.finish_request(request, client_address)
>>>>
>>>> File 
>>>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py",
>>>> line 334, in finish_request
>>>>
>>>> self.RequestHandlerClass(request, client_address, self)
>>>>
>>>> File 
>>>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py",
>>>> line 655, in __init__
>>>>
>>>> self.handle()
>>>>
>>>> File 
>>>> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
>>>> line 200, in handle
>>>>
>>>> rv = BaseHTTPRequestHandler.handle(self)
>>>>
>>>> File "/System/Library/Frameworks/Python.framework/Versions/2.7/li
>>>> b/python2.7/BaseHTTPServer.py", line 340, in handle
>>>>
>>>> self.handle_one_request()
>>>>
>>>> File 
>>>> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
>>>> line 235, in handle_one_request
>>>>
>>>> return self.run_wsgi()
>>>>
>>>> File 
>>>> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
>>>> line 177, in run_wsgi
>>>>
>>>> execute(self.server.app)
>>>>
>>>> File 
>>>> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
>>>> line 167, in execute
>>>>
>>>> for data in application_iter:
>>>>
>>>> File 
>>>> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/wsgi.py",
>>>> line 691, in __next__
>>>>
>>>> return self._next()
>>>>
>>>> File 
>>>> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/wrappers.py",
>>>> line 81, in _iter_encoded
>>>>
>>>> for item in iterable:
>>>>
>>>> File 
>>>> "/Users/dpage/git/pgadmin4/web/pgadmin/utils/driver/psycopg2/__init__.py",
>>>> line 828, in gen
>>>>
>>>> quotechar=quote_char
>>>>
>>>> File 
>>>> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/backports/csv.py",
>&g

Re: [pgAdmin4][Patch]: Allow user to choose background colour for server

2017-11-21 Thread Khushboo Vashi
On Tue, Nov 21, 2017 at 5:37 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Dave,
>
> PFA updated patch with changes suggested by Ashesh.
> Hopefully the last revision :)
>
> +1 :)

>
> On Tue, Nov 21, 2017 at 4:12 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> Please find updated patch.
>>
>> On Tue, Nov 21, 2017 at 2:43 PM, Dave Page  wrote:
>>
>>> Hi
>>>
>>> On Mon, Nov 20, 2017 at 5:47 PM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
 On Mon, Nov 20, 2017 at 10:40 PM, Dave Page  wrote:

> Hi
>
> On Mon, Nov 20, 2017 at 4:19 PM, Murtuza Zabuawala <
> murtuza.zabuaw...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> PFA updated patch.
>>
>
> OK, that's looking better. I just found a couple of smaller issue this
> time:
>
> - Why can't I select a foreground colour unless I select a non-white
> background? That seems inconvenient and unnecessary
>
 ​Because we can only pass CSS classes
 
 to aciTree node which it stores in html element and we are passing bg & fg
 colors as additional classes like   ,
 When we fetch the class list from html element, we get array of
 classes, so if we have any value at index 1 then it is bgcolor and we have
 value at index 2 then it is fgcolor, and using these css colors then we
 create dynamic style tag for the acitree node which inject at runtime in
 DOM.

 So we can only identify them by index, so we have disabled the fgcolor
 field if bgcolor field is not provided.

>>>
>>> Implementation details like this are really not a good reason to confuse
>>> the user. Why can't we just default the background colour to white if
>>> unspecified (which it will be anyway), thus ensuring there is always the
>>> expected number of elements? Then, the user can specify (for example) red
>>> on white - which I suspect would be a popular choice (or variations
>>> thereof).
>>>
>>>

 - If I set a foreground and background colour, and then later set the
> background to a new colour and the foreground to "no colour", the
> background change takes effect immediately, but the foreground change
> requires a refresh (changing to a different foreground colour seems to 
> work
> fine though).
>
 ​Fixed, Older style tag was not cleaning up properly and it was
 pickking up color from previous style tag.​


>
>
>
>>
>> On Mon, Nov 20, 2017 at 6:48 PM, Dave Page  wrote:
>>
>>> Hi
>>>
>>> On Fri, Nov 17, 2017 at 9:30 AM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
 Hi Dave,

 PFA updated patch.

 On Thu, Nov 16, 2017 at 6:34 PM, Dave Page 
 wrote:

> Hi
>
> Looks good. A few changes/suggestions:
>
> - There seem to be some debugger calls left in the code, e.g. in
> editors.js
>
 ​Fixed

> - Instead of bgcolor and font_color, lets use bgcolor and fgcolor
> (foreground).
>
 ​Fixed​


> - The docs are (technically) en_US, so we should use color not
> colour in them.
>
 ​Fixed​


> - If the colours have been set for a server, I think we should
> also colour the title bar in the query tool. The only possible problem
> there is that the current default colours are reversed in comparison 
> to the
> treeview (e.g. the treeview defaults to black text, whilst the query 
> tool
> title bar is white on blue. Not sure if that is really an issue or 
> not.
>
 What do you think?
>
 ​I have added logic to set the background & foreground colour in
 query tool & datagrid title bar.
 - Default title bar colours, b
 ackground
 ​: blue
 foreground
 ​: white
  [
 ​w​
 hat we have right now]
 - When user has custom background colour for the server​,
 b
 ackground
 ​: <
 custom background colour
 >
 foreground
 ​: black
 - When user has custom background colour as well as foreground
 colour for the server​,
 b
 ackground
 ​: <
 custom background colour
 >
 foreground
 ​:
 <
 custom
 ​foreground
  colour
 >

>>>
>>> I think this looks good now for the most part, except:
>>>
>>> - The default colours for the title bar on the query tool seem to be
>>> black on white. See the first screenshot.
>>>
>> ​Fixed​
>>
>>
>>>
>>> - If I

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

2017-11-22 Thread Khushboo Vashi
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.

Thanks,
Khushboo
diff --git a/web/pgadmin/static/css/bootstrap.overrides.css b/web/pgadmin/static/css/bootstrap.overrides.css
index 73b4fc7..a64e85b 100755
--- a/web/pgadmin/static/css/bootstrap.overrides.css
+++ b/web/pgadmin/static/css/bootstrap.overrides.css
@@ -1177,7 +1177,7 @@ form[name="change_password_form"] .help-block {
 .user_management {
   margin: 0 10px !important;
   width: calc(100% - 20px);
-  height: 100%;
+  height: calc(100% - 40px);
   overflow: hidden;
 }
 
@@ -1187,7 +1187,7 @@ form[name="change_password_form"] .help-block {
 
 .user_management table {
   display: block;
-  height: 100%;
+  height: calc(100% - 10px);
   overflow: auto;
   border: 0 none;
 }
diff --git a/web/pgadmin/tools/user_management/static/js/user_management.js b/web/pgadmin/tools/user_management/static/js/user_management.js
index ffdf8b2..ee8701a 100644
--- a/web/pgadmin/tools/user_management/static/js/user_management.js
+++ b/web/pgadmin/tools/user_management/static/js/user_management.js
@@ -386,6 +386,7 @@ define([
 // clear our backform model/view
 this.view.remove({data: true, internal: true, silent: true});
 this.$content.remove();
+this.$footer.remove();
   }
 }
   },
@@ -404,9 +405,9 @@ define([
   '',
 '',
   '',
-''].join("\n")),
-  $footer = $(footerTpl()),
-  $statusBar = $footer.find('.pg-prop-status-bar'),
+''].join("\n"));
+  self.$footer = $(footerTpl());
+  var $statusBar = self.$footer.find('.pg-prop-status-bar'),
   UserRow = Backgrid.Row.extend({
 userInvalidColor: "lightYellow",
 
@@ -558,12 +559,14 @@ define([
 
 this.$content = $("").append(
 headerTpl(data)).append($gridBody
-).append($footer);
+);
 
 $(this.elements.body.childNodes[0]).addClass(
   'alertify_tools_dialog_backgrid_properties');
 
 this.elements.content.appendChild(this.$content[0]);
+this.elements.content.appendChild(this.$footer[0]);
+
 
 // Render Search Filter
 $('.search_users').append(


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]: 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']),
-  

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

2017-11-26 Thread Khushboo Vashi
Hi Dave,

On Fri, Nov 24, 2017 at 3:21 PM, Dave Page  wrote:

>
>
> On Thu, Nov 23, 2017 at 10:43 AM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>>
>>
>> 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.
>>
>
> Right, but we also can't have that space left blank like that. Can't we
> extend the scroll range of the grid? In other words, always include space
> for an extra row or so, so it can scroll above the error message, when, and
> only when a message is shown?
>
>
Please find the attached screen-shot, If we always include an extra row.
Suggestion please.

-- 
> 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-27 Thread Khushboo Vashi
On Mon, Nov 27, 2017 at 2:20 PM, Dave Page  wrote:

>
>
> On Mon, Nov 27, 2017 at 5:25 AM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> On Fri, Nov 24, 2017 at 3:21 PM, Dave Page  wrote:
>>
>>>
>>>
>>> On Thu, Nov 23, 2017 at 10:43 AM, Khushboo Vashi <
>>> khushboo.va...@enterprisedb.com> wrote:
>>>
>>>>
>>>>
>>>> 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.
>>>>
>>>
>>> Right, but we also can't have that space left blank like that. Can't we
>>> extend the scroll range of the grid? In other words, always include space
>>> for an extra row or so, so it can scroll above the error message, when, and
>>> only when a message is shown?
>>>
>>>
>> Please find the attached screen-shot, If we always include an extra row.
>> Suggestion please.
>>
>
> I think that's much better, though still not ideal. What if we made the
> error messages closable like other notifications?
>
> The error-messages in pgAdmin 4 are not closable, so it will not go with
the flow.

>
> --
> 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-27 Thread Khushboo Vashi
On Mon, Nov 27, 2017 at 2:59 PM, Dave Page  wrote:

>
>
> On Mon, Nov 27, 2017 at 9:19 AM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>>
>>
>> On Mon, Nov 27, 2017 at 2:20 PM, Dave Page  wrote:
>>
>>>
>>>
>>> On Mon, Nov 27, 2017 at 5:25 AM, Khushboo Vashi <
>>> khushboo.va...@enterprisedb.com> wrote:
>>>
>>>> Hi Dave,
>>>>
>>>> On Fri, Nov 24, 2017 at 3:21 PM, Dave Page  wrote:
>>>>
>>>>>
>>>>>
>>>>> On Thu, Nov 23, 2017 at 10:43 AM, Khushboo Vashi <
>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> 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.
>>>>>>
>>>>>
>>>>> Right, but we also can't have that space left blank like that. Can't
>>>>> we extend the scroll range of the grid? In other words, always include
>>>>> space for an extra row or so, so it can scroll above the error message,
>>>>> when, and only when a message is shown?
>>>>>
>>>>>
>>>> Please find the attached screen-shot, If we always include an extra
>>>> row.
>>>> Suggestion please.
>>>>
>>>
>>> I think that's much better, though still not ideal. What if we made the
>>> error messages closable like other notifications?
>>>
>>> The error-messages in pgAdmin 4 are not closable, so it will not go with
>> the flow.
>>
>
> I meant to do it globally.
>
> Should I create the separate case for this?

>
> --
> 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-27 Thread Khushboo Vashi
On Mon, Nov 27, 2017 at 4:13 PM, Dave Page  wrote:

>
>
> On Mon, Nov 27, 2017 at 10:39 AM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>>
>>
>> On Mon, Nov 27, 2017 at 2:59 PM, Dave Page  wrote:
>>
>>>
>>>
>>> On Mon, Nov 27, 2017 at 9:19 AM, Khushboo Vashi <
>>> khushboo.va...@enterprisedb.com> wrote:
>>>
>>>>
>>>>
>>>> On Mon, Nov 27, 2017 at 2:20 PM, Dave Page  wrote:
>>>>
>>>>>
>>>>>
>>>>> On Mon, Nov 27, 2017 at 5:25 AM, Khushboo Vashi <
>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>
>>>>>> Hi Dave,
>>>>>>
>>>>>> On Fri, Nov 24, 2017 at 3:21 PM, Dave Page  wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Nov 23, 2017 at 10:43 AM, Khushboo Vashi <
>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> 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.
>>>>>>>>
>>>>>>>
>>>>>>> Right, but we also can't have that space left blank like that. Can't
>>>>>>> we extend the scroll range of the grid? In other words, always include
>>>>>>> space for an extra row or so, so it can scroll above the error message,
>>>>>>> when, and only when a message is shown?
>>>>>>>
>>>>>>>
>>>>>> Please find the attached screen-shot, If we always include an extra
>>>>>> row.
>>>>>> Suggestion please.
>>>>>>
>>>>>
>>>>> I think that's much better, though still not ideal. What if we made
>>>>> the error messages closable like other notifications?
>>>>>
>>>>> The error-messages in pgAdmin 4 are not closable, so it will not go
>>>> with the flow.
>>>>
>>>
>>> I meant to do it globally.
>>>
>>> Should I create the separate case for this?
>>
>
> No, I don't think there's any need for that.
>
> Does it seem like it would solve the problem appropriately?
>
>
It would lead us to more complexity
1. How can we keep track of the closed error messages for multiple fields?
2. We have validated backbone model on focus out/change, so we need to
change the basic error model.


I have attached the patch for the RM #2859.

Thanks,
Khushboo

-- 
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/static/css/bootstrap.overrides.css b/web/pgadmin/static/css/bootstrap.overrides.css
index b894021..6e3e580 100755
--- a/web/pgadmin/static/css/bootstrap.overrides.css
+++ b/web/pgadmin/static/css/bootstrap.overrides.css
@@ -1218,6 +1218,11 @@ height: calc(100% - 35px);
   line-height: 16px;
 }
 
+.user_management table tbody tr.blank_row {
+  visibility: hidden;
+  height: 35px;
+}
+
 .pg-panel-statistics-container >table.backgrid.table

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

2017-11-27 Thread Khushboo Vashi
On Mon, Nov 27, 2017 at 4:47 PM, Dave Page  wrote:

>
>
> On Mon, Nov 27, 2017 at 11:03 AM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>>
>>
>> On Mon, Nov 27, 2017 at 4:13 PM, Dave Page  wrote:
>>
>>>
>>>
>>> On Mon, Nov 27, 2017 at 10:39 AM, Khushboo Vashi <
>>> khushboo.va...@enterprisedb.com> wrote:
>>>
>>>>
>>>>
>>>> On Mon, Nov 27, 2017 at 2:59 PM, Dave Page  wrote:
>>>>
>>>>>
>>>>>
>>>>> On Mon, Nov 27, 2017 at 9:19 AM, Khushboo Vashi <
>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, Nov 27, 2017 at 2:20 PM, Dave Page  wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Nov 27, 2017 at 5:25 AM, Khushboo Vashi <
>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>
>>>>>>>> Hi Dave,
>>>>>>>>
>>>>>>>> On Fri, Nov 24, 2017 at 3:21 PM, Dave Page 
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Thu, Nov 23, 2017 at 10:43 AM, Khushboo Vashi <
>>>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> 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.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Right, but we also can't have that space left blank like that.
>>>>>>>>> Can't we extend the scroll range of the grid? In other words, always
>>>>>>>>> include space for an extra row or so, so it can scroll above the error
>>>>>>>>> message, when, and only when a message is shown?
>>>>>>>>>
>>>>>>>>>
>>>>>>>> Please find the attached screen-shot, If we always include an extra
>>>>>>>> row.
>>>>>>>> Suggestion please.
>>>>>>>>
>>>>>>>
>>>>>>> I think that's much better, though still not ideal. What if we made
>>>>>>> the error messages closable like other notifications?
>>>>>>>
>>>>>>> The error-messages in pgAdmin 4 are not closable, so it will not go
>>>>>> with the flow.
>>>>>>
>>>>>
>>>>> I meant to do it globally.
>>>>>
>>>>> Should I create the separate case for this?
>>>>
>>>
>>> No, I don't think there's any need for that.
>>>
>>> Does it seem like it would solve the problem appropriately?
>>>
>>>
>> It would lead us to more complexity
>> 1. How can we keep track of the closed error messages for multiple fields?
>>
>
> Do we need to?
>
>
>> 2. We have validated backbone model on focus out/change, so we need to
>> change the basic error model.
>>
>
> I'm not sure why. Can't we just have an X button on the error panel that
> will hide it? If another error occurs (e.g. because the user changes
> focus), just re-display it.
>
>
This means, if the error message is displayed for the field 1 and after
closing if we go ahead without filling up the valid data, on the focus out;
the same error message will be shown.

I was thinking; if we have closed the error message for the field 1, then
it will not display any kind of message for that particular field. So, I
have mentioned about the complexity.

>
>> I have attached the patch for the RM #2859.
>>
>> Thanks,
>> Khushboo
>>
>> --
>>> 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
>


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

2017-11-27 Thread Khushboo Vashi
On Mon, Nov 27, 2017 at 4:58 PM, Dave Page  wrote:

>
>
> On Mon, Nov 27, 2017 at 11:26 AM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>>
>>
>> On Mon, Nov 27, 2017 at 4:47 PM, Dave Page  wrote:
>>
>>>
>>>
>>> On Mon, Nov 27, 2017 at 11:03 AM, Khushboo Vashi <
>>> khushboo.va...@enterprisedb.com> wrote:
>>>
>>>>
>>>>
>>>> On Mon, Nov 27, 2017 at 4:13 PM, Dave Page  wrote:
>>>>
>>>>>
>>>>>
>>>>> On Mon, Nov 27, 2017 at 10:39 AM, Khushboo Vashi <
>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, Nov 27, 2017 at 2:59 PM, Dave Page  wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Nov 27, 2017 at 9:19 AM, Khushboo Vashi <
>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Mon, Nov 27, 2017 at 2:20 PM, Dave Page 
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Mon, Nov 27, 2017 at 5:25 AM, Khushboo Vashi <
>>>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>>>
>>>>>>>>>> Hi Dave,
>>>>>>>>>>
>>>>>>>>>> On Fri, Nov 24, 2017 at 3:21 PM, Dave Page 
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Thu, Nov 23, 2017 at 10:43 AM, Khushboo Vashi <
>>>>>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> 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.
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Right, but we also can't have that space left blank like that.
>>>>>>>>>>> Can't we extend the scroll range of the grid? In other words, always
>>>>>>>>>>> include space for an extra row or so, so it can scroll above the 
>>>>>>>>>>> error
>>>>>>>>>>> message, when, and only when a message is shown?
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> Please find the attached screen-shot, If we always include an
>>>>>>>>>> extra row.
>>>>>>>>>> Suggestion please.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> I think that's much better, though still not ideal. What if we
>>>>>>>>> made the error messages closable like other notifications?
>>>>>>>>>
>>>>>>>>> The error-messages in pgAdmin 4 are not closable, so it will not
>>>>>>>> go with the flow.
>>>>>>>>
>>>>>>>
>>>>>>> I meant to do it globally.
>>>>>>>
>>>>>>> Should I create the separate case for this?
>>>>>>
>>>>>
>>>>> No, I don't think there's any need for that.
>>>>>
>>>>> Does it seem like it would solve the problem appropriately?
>>>>>
>>>>>
>>>> It would lead us to more complexity
>>>> 1. How can we keep track of the closed error messages for multiple
>>>> fields?
>>>>
>>>
>>> Do we need to?
>>>
>>>
>>>> 2. We have validated backbone model on focus out/change, so we need to
>>>> change the basic error model.
>>>>
>>>
>>> I'm not sure why. Can't we just have an X button on the error panel that
>>> will hide it? If another error occurs (e.g. because the user changes
>>> focus), just re-display it.
>>>
>>>
>> This means, if the error message is displayed for the field 1 and after
>> closing if we go ahead without filling up the valid data, on the focus out;
>> the same error message will be shown.
>>
>
> Yes.
>
>
>>
>> I was thinking; if we have closed the error message for the field 1, then
>> it will not display any kind of message for that particular field. So, I
>> have mentioned about the complexity.
>>
>
> I'm not convinced we need that level of complexity.
>
> Can you whip up a PoC so we can see how it behaves?
>
> Sure.

>
>

>>>> I have attached the patch for the RM #2859.
>>>>
>>>> Thanks,
>>>> Khushboo
>>>>
>>>> --
>>>>> 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
>>>
>>
>>
>
>
> --
> 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-27 Thread Khushboo Vashi
On Mon, Nov 27, 2017 at 5:01 PM, Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

>
>
> On Mon, Nov 27, 2017 at 4:58 PM, Dave Page  wrote:
>
>>
>>
>> On Mon, Nov 27, 2017 at 11:26 AM, Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>>
>>>
>>> On Mon, Nov 27, 2017 at 4:47 PM, Dave Page  wrote:
>>>
>>>>
>>>>
>>>> On Mon, Nov 27, 2017 at 11:03 AM, Khushboo Vashi <
>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>
>>>>>
>>>>>
>>>>> On Mon, Nov 27, 2017 at 4:13 PM, Dave Page  wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, Nov 27, 2017 at 10:39 AM, Khushboo Vashi <
>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Nov 27, 2017 at 2:59 PM, Dave Page 
>>>>>>> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Mon, Nov 27, 2017 at 9:19 AM, Khushboo Vashi <
>>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Mon, Nov 27, 2017 at 2:20 PM, Dave Page 
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Mon, Nov 27, 2017 at 5:25 AM, Khushboo Vashi <
>>>>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi Dave,
>>>>>>>>>>>
>>>>>>>>>>> On Fri, Nov 24, 2017 at 3:21 PM, Dave Page 
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Thu, Nov 23, 2017 at 10:43 AM, Khushboo Vashi <
>>>>>>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> 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.
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Right, but we also can't have that space left blank like that.
>>>>>>

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

2017-11-28 Thread Khushboo Vashi
On Tue, Nov 28, 2017 at 3:40 PM, Dave Page  wrote:

>
>
> On Tue, Nov 28, 2017 at 7:10 AM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>>
>>
>> On Mon, Nov 27, 2017 at 5:01 PM, Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>>
>>>
>>> On Mon, Nov 27, 2017 at 4:58 PM, Dave Page  wrote:
>>>
>>>>
>>>>
>>>> On Mon, Nov 27, 2017 at 11:26 AM, Khushboo Vashi <
>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>
>>>>>
>>>>>
>>>>> On Mon, Nov 27, 2017 at 4:47 PM, Dave Page  wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, Nov 27, 2017 at 11:03 AM, Khushboo Vashi <
>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Nov 27, 2017 at 4:13 PM, Dave Page 
>>>>>>> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Mon, Nov 27, 2017 at 10:39 AM, Khushboo Vashi <
>>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Mon, Nov 27, 2017 at 2:59 PM, Dave Page 
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Mon, Nov 27, 2017 at 9:19 AM, Khushboo Vashi <
>>>>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Mon, Nov 27, 2017 at 2:20 PM, Dave Page 
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Mon, Nov 27, 2017 at 5:25 AM, Khushboo Vashi <
>>>>>>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Hi Dave,
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Fri, Nov 24, 2017 at 3:21 PM, Dave Page 
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Thu, Nov 23, 2017 at 10:43 AM, Khushboo Vashi <
>>>>>>>>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Thu, Nov 23, 2017 at 2:58 PM, Dave Page <
>>>>>>>>>>>>>>> dp...@pgadmin.org> 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 th

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

2017-11-28 Thread Khushboo Vashi
Hi Dave,

Please find the attached updated patch, which includes:

- The fix for this RM
- Close button for the error message, which is applicable globally

Thanks,
Khushboo

On Tue, Nov 28, 2017 at 4:18 PM, Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

>
>
> On Tue, Nov 28, 2017 at 3:40 PM, Dave Page  wrote:
>
>>
>>
>> On Tue, Nov 28, 2017 at 7:10 AM, Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>>
>>>
>>> On Mon, Nov 27, 2017 at 5:01 PM, Khushboo Vashi <
>>> khushboo.va...@enterprisedb.com> wrote:
>>>
>>>>
>>>>
>>>> On Mon, Nov 27, 2017 at 4:58 PM, Dave Page  wrote:
>>>>
>>>>>
>>>>>
>>>>> On Mon, Nov 27, 2017 at 11:26 AM, Khushboo Vashi <
>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, Nov 27, 2017 at 4:47 PM, Dave Page  wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Nov 27, 2017 at 11:03 AM, Khushboo Vashi <
>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Mon, Nov 27, 2017 at 4:13 PM, Dave Page 
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Mon, Nov 27, 2017 at 10:39 AM, Khushboo Vashi <
>>>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Mon, Nov 27, 2017 at 2:59 PM, Dave Page 
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Mon, Nov 27, 2017 at 9:19 AM, Khushboo Vashi <
>>>>>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Mon, Nov 27, 2017 at 2:20 PM, Dave Page 
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Mon, Nov 27, 2017 at 5:25 AM, Khushboo Vashi <
>>>>>>>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hi Dave,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Fri, Nov 24, 2017 at 3:21 PM, Dave Page >>>>>>>>>>>>> > wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Thu, Nov 23, 2017 at 10:43 AM, Khushboo Vashi <
>>>>>>>>>>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> On Thu, Nov 23, 2017 at 2:58 PM, Dave Page <
>>>>>>>>>>>>>>>> dp...@pgadmin.org> 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
>>>>>>>

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

2017-11-30 Thread Khushboo Vashi
Hi,

Please find the attached updated patch.

On Mon, Nov 27, 2017 at 5:15 PM, Dave Page  wrote:

> Hi
>
> On Thu, Nov 23, 2017 at 1:28 PM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Please find the attached patch for RM #2849: Allow editing of data on
>> tables with OIDs but no primary key.
>>
>
> I like that if I add a new row or rows and hit Save, the OIDs are fetched
> immediately. However;
>
> - It marks the row as read-only. We do that currently because we don't
> return the key info on Save, and thus require a Refresh before any further
> editing. However, if we have the OID, we can edit again immediately.
>
> Fixed

> - If we can return the new OIDs on Save, can't we do the same for primary
> key values? That would be consistent with OIDs, and would remove the need
> to disable rows, leading to a much nicer use experience I think.
>
> Implemented

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

Thanks,
Khushboo
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 8dcb444..363d6f8 100644
--- a/web/pgadmin/tools/sqleditor/__init__.py
+++ b/web/pgadmin/tools/sqleditor/__init__.py
@@ -433,6 +433,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()
 
@@ -444,6 +447,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
@@ -655,6 +662,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)
@@ -680,6 +689,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_k

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

2017-12-03 Thread Khushboo Vashi
On Sat, Dec 2, 2017 at 10:42 AM, Dave Page  wrote:

> Hi
>
> On Thursday, November 30, 2017, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Please find the attached updated patch.
>>
>> On Mon, Nov 27, 2017 at 5:15 PM, Dave Page  wrote:
>>
>>> Hi
>>>
>>> On Thu, Nov 23, 2017 at 1:28 PM, Khushboo Vashi <
>>> khushboo.va...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Please find the attached patch for RM #2849: Allow editing of data on
>>>> tables with OIDs but no primary key.
>>>>
>>>
>>> I like that if I add a new row or rows and hit Save, the OIDs are
>>> fetched immediately. However;
>>>
>>> - It marks the row as read-only. We do that currently because we don't
>>> return the key info on Save, and thus require a Refresh before any further
>>> editing. However, if we have the OID, we can edit again immediately.
>>>
>>> Fixed
>>
>>> - If we can return the new OIDs on Save, can't we do the same for
>>> primary key values? That would be consistent with OIDs, and would remove
>>> the need to disable rows, leading to a much nicer use experience I think.
>>>
>>> Implemented
>>
>
> This looks great, however there is one small issue I spotted; it looks
> like we're inserting rows in a random order. For example, in the screenshot
> attached, the last 5 rows were added in the order seen in the key1 column,
> and then I hit Save and got the id values returned. Is that caused by
> something we're doing, or the database server?
>
> The root cause of the issue is, Python dictionary does not preserve the
order. To fix this issue I have manually sorted the added rows index and
stored it into OrderedDict.
Please find the attached updated patch.

> Thanks!
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
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 8dcb444..363d6f8 100644
--- a/web/pgadmin/tools/sqleditor/__init__.py
+++ b/web/pgadmin/tools/sqleditor/__init__.py
@@ -433,6 +433,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()
 
@@ -444,6 +447,10 @@ def start_view_data(trans_id):
 
 # Store the primary keys to the session object
 session_obj['primary_keys'] = primary_keys
+
+# Store the OIDs sta

[pgAdmin4][Patch]: Fixed RM #2779 - Lost field size

2017-12-05 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix RM #2779: Lost field size.

While editing the table column, if we change collate then, the length and
the precision are lost.
Also, while changing column type, it does not honour the length and
precision.

Thanks,
Khushboo
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/static/js/column.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/static/js/column.js
index 90c3f8f..a239a6b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/static/js/column.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/static/js/column.js
@@ -416,7 +416,7 @@ define('pgadmin.node.column', [
   _.each(m.datatypes, function(o) {
 if ( of_type == o.value ) {
   if(o.precision) {
-m.set('min_val', o.min_val, {silent: true});
+m.set('min_val', 0, {silent: true});
 m.set('max_val', o.max_val, {silent: true});
 flag = false;
   }
@@ -446,7 +446,7 @@ define('pgadmin.node.column', [
   _.each(m.datatypes, function(o) {
 if ( of_type == o.value ) {
   if(o.precision) {
-m.set('min_val', o.min_val, {silent: true});
+m.set('min_val', 0, {silent: true});
 m.set('max_val', o.max_val, {silent: true});
 flag = true;
   }
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql
index 385e40e..569cab5 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql
@@ -9,7 +9,7 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
 
 {% endif %}
 {###  Alter column type and collation ###}
-{% if (data.cltype and data.cltype != o_data.cltype) or (data.attlen is defined and data.attlen != o_data.attlen) or (data.attprecision is defined and data.attprecision != o_data.attprecision) %}
+{% if (data.cltype and data.cltype != o_data.cltype) or (data.attlen is defined and data.attlen != o_data.attlen) or (data.attprecision is defined and data.attprecision != o_data.attprecision) or (data.collspcname and data.collspcname != o_data.collspcname)%}
 ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
 ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} TYPE {{ GET_TYPE.UPDATE_TYPE_SQL(conn, data, o_data) }}{% if data.collspcname and data.collspcname != o_data.collspcname %}
  COLLATE {{data.collspcname}}{% endif %};
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/update.sql
index 6b17481..bb283f8 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/update.sql
@@ -9,7 +9,7 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
 
 {% endif %}
 {###  Alter column type and collation ###}
-{% if (data.cltype and data.cltype != o_data.cltype) or (data.attlen is defined and data.attlen != o_data.attlen) or (data.attprecision is defined and data.attprecision != o_data.attprecision) %}
+{% if (data.cltype and data.cltype != o_data.cltype) or (data.attlen is defined and data.attlen != o_data.attlen) or (data.attprecision is defined and data.attprecision != o_data.attprecision)  or (data.collspcname and data.collspcname != o_data.collspcname) %}
 ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
 ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} TYPE {{ GET_TYPE.UPDATE_TYPE_SQL(conn, data, o_data) }}{% if data.collspcname and data.collspcname != o_data.collspcname %}
  COLLATE {{data.collspcname}}{% endif %};
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py
index d9b69ec..c7127e6 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py
@@ -1691,32 +1691,37 @@ class BaseTableView(PGChildNodeView):
 
 length = False
 precision = False
-if 'elemoid' in c:
+
+# If the column data type 

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

2017-12-06 Thread Khushboo Vashi
Hi Dave,

On Tue, Dec 5, 2017 at 9:43 AM, Dave Page  wrote:

> Hi
>
> On Mon, Dec 4, 2017 at 4:01 PM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>>
>>
>> On Sat, Dec 2, 2017 at 10:42 AM, Dave Page  wrote:
>>
>>> Hi
>>>
>>> On Thursday, November 30, 2017, Khushboo Vashi <
>>> khushboo.va...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Please find the attached updated patch.
>>>>
>>>> On Mon, Nov 27, 2017 at 5:15 PM, Dave Page  wrote:
>>>>
>>>>> Hi
>>>>>
>>>>> On Thu, Nov 23, 2017 at 1:28 PM, Khushboo Vashi <
>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Please find the attached patch for RM #2849: Allow editing of data on
>>>>>> tables with OIDs but no primary key.
>>>>>>
>>>>>
>>>>> I like that if I add a new row or rows and hit Save, the OIDs are
>>>>> fetched immediately. However;
>>>>>
>>>>> - It marks the row as read-only. We do that currently because we don't
>>>>> return the key info on Save, and thus require a Refresh before any further
>>>>> editing. However, if we have the OID, we can edit again immediately.
>>>>>
>>>>> Fixed
>>>>
>>>>> - If we can return the new OIDs on Save, can't we do the same for
>>>>> primary key values? That would be consistent with OIDs, and would remove
>>>>> the need to disable rows, leading to a much nicer use experience I think.
>>>>>
>>>>> Implemented
>>>>
>>>
>>> This looks great, however there is one small issue I spotted; it looks
>>> like we're inserting rows in a random order. For example, in the screenshot
>>> attached, the last 5 rows were added in the order seen in the key1 column,
>>> and then I hit Save and got the id values returned. Is that caused by
>>> something we're doing, or the database server?
>>>
>>> The root cause of the issue is, Python dictionary does not preserve the
>> order. To fix this issue I have manually sorted the added rows index and
>> stored it into OrderedDict.
>> Please find the attached updated patch.
>>
>
> Thanks Khushboo. My apologies, but I found something else when testing.
> Instead of just returning and updating the values for the key columns, we
> should do it for all columns. This would have 2 benefits (and I suspect,
> might actually make the code a little more simple):
>
> Done

> 1) We'd see the values for columns with default values.
>
> 2) We'd see the formatted values for other columns - e.g. with a JSONB
> column, you'll immediately see what the re-generated JSON looks like.
>
> I assume it's straightforward to update all columns rather than just the
> key columns?
>
The approach is same. Before I was just updating the primary keys/oids, now
I update all the columns of a row.

Please find the attached updated patch.

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

Thanks,
Khushboo
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/dat

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

2017-12-06 Thread Khushboo Vashi
Please find the attached updated patch with some code cleanup.

On Wed, Dec 6, 2017 at 2:34 PM, Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

> Hi Dave,
>
> On Tue, Dec 5, 2017 at 9:43 AM, Dave Page  wrote:
>
>> Hi
>>
>> On Mon, Dec 4, 2017 at 4:01 PM, Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>>
>>>
>>> On Sat, Dec 2, 2017 at 10:42 AM, Dave Page  wrote:
>>>
>>>> Hi
>>>>
>>>> On Thursday, November 30, 2017, Khushboo Vashi <
>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> Please find the attached updated patch.
>>>>>
>>>>> On Mon, Nov 27, 2017 at 5:15 PM, Dave Page  wrote:
>>>>>
>>>>>> Hi
>>>>>>
>>>>>> On Thu, Nov 23, 2017 at 1:28 PM, Khushboo Vashi <
>>>>>> khushboo.va...@enterprisedb.com> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> Please find the attached patch for RM #2849: Allow editing of data
>>>>>>> on tables with OIDs but no primary key.
>>>>>>>
>>>>>>
>>>>>> I like that if I add a new row or rows and hit Save, the OIDs are
>>>>>> fetched immediately. However;
>>>>>>
>>>>>> - It marks the row as read-only. We do that currently because we
>>>>>> don't return the key info on Save, and thus require a Refresh before any
>>>>>> further editing. However, if we have the OID, we can edit again 
>>>>>> immediately.
>>>>>>
>>>>>> Fixed
>>>>>
>>>>>> - If we can return the new OIDs on Save, can't we do the same for
>>>>>> primary key values? That would be consistent with OIDs, and would remove
>>>>>> the need to disable rows, leading to a much nicer use experience I think.
>>>>>>
>>>>>> Implemented
>>>>>
>>>>
>>>> This looks great, however there is one small issue I spotted; it looks
>>>> like we're inserting rows in a random order. For example, in the screenshot
>>>> attached, the last 5 rows were added in the order seen in the key1 column,
>>>> and then I hit Save and got the id values returned. Is that caused by
>>>> something we're doing, or the database server?
>>>>
>>>> The root cause of the issue is, Python dictionary does not preserve the
>>> order. To fix this issue I have manually sorted the added rows index and
>>> stored it into OrderedDict.
>>> Please find the attached updated patch.
>>>
>>
>> Thanks Khushboo. My apologies, but I found something else when testing.
>> Instead of just returning and updating the values for the key columns, we
>> should do it for all columns. This would have 2 benefits (and I suspect,
>> might actually make the code a little more simple):
>>
>> Done
>
>> 1) We'd see the values for columns with default values.
>>
>> 2) We'd see the formatted values for other columns - e.g. with a JSONB
>> column, you'll immediately see what the re-generated JSON looks like.
>>
>> I assume it's straightforward to update all columns rather than just the
>> key columns?
>>
> The approach is same. Before I was just updating the primary keys/oids,
> now I update all the columns of a row.
>
> Please find the attached updated patch.
>
>> Thanks!
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
> Thanks,
> Khushboo
>
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 

Re: [pgAdmin4][Patch]: Fixed RM #2779 - Lost field size

2017-12-11 Thread Khushboo Vashi
On Mon, Dec 11, 2017 at 5:40 PM, Dave Page  wrote:

> Hi
>
> On Wed, Dec 6, 2017 at 5:45 AM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Please find the attached patch to fix RM #2779: Lost field size.
>>
>> While editing the table column, if we change collate then, the length and
>> the precision are lost.
>> Also, while changing column type, it does not honour the length and
>> precision.
>>
>
> Now it loses the collation if you edit the length.
>
> I have tested it, it's not loosing the collation.
Please let me know the steps to reproduce this.

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


Re: [pgAdmin4][Patch]: Fixed RM #2779 - Lost field size

2017-12-11 Thread Khushboo Vashi
On Mon, Dec 11, 2017 at 5:45 PM, Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

>
>
> On Mon, Dec 11, 2017 at 5:40 PM, Dave Page  wrote:
>
>> Hi
>>
>> On Wed, Dec 6, 2017 at 5:45 AM, Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> Please find the attached patch to fix RM #2779: Lost field size.
>>>
>>> While editing the table column, if we change collate then, the length
>>> and the precision are lost.
>>> Also, while changing column type, it does not honour the length and
>>> precision.
>>>
>>
>> Now it loses the collation if you edit the length.
>>
>> I have tested it, it's not loosing the collation.
> Please let me know the steps to reproduce this.
>
Reproduced. Will send the patch.

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


Re: [pgAdmin4][Patch]: Fixed RM #2779 - Lost field size

2017-12-11 Thread Khushboo Vashi
On Mon, Dec 11, 2017 at 6:03 PM, Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

>
>
> On Mon, Dec 11, 2017 at 5:45 PM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>>
>>
>> On Mon, Dec 11, 2017 at 5:40 PM, Dave Page  wrote:
>>
>>> Hi
>>>
>>> On Wed, Dec 6, 2017 at 5:45 AM, Khushboo Vashi <
>>> khushboo.va...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Please find the attached patch to fix RM #2779: Lost field size.
>>>>
>>>> While editing the table column, if we change collate then, the length
>>>> and the precision are lost.
>>>> Also, while changing column type, it does not honour the length and
>>>> precision.
>>>>
>>>
>>> Now it loses the collation if you edit the length.
>>>
>>> Fixed.
Please find the attached patch.

> I have tested it, it's not loosing the collation.
>> Please let me know the steps to reproduce this.
>>
> Reproduced. Will send the patch.
>
>> :-(
>>>
>>>
>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogspot.com
>>> Twitter: @pgsnake
>>>
>>> EnterpriseDB UK: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>
>>
>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/static/js/column.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/static/js/column.js
index 90c3f8f..a239a6b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/static/js/column.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/static/js/column.js
@@ -416,7 +416,7 @@ define('pgadmin.node.column', [
   _.each(m.datatypes, function(o) {
 if ( of_type == o.value ) {
   if(o.precision) {
-m.set('min_val', o.min_val, {silent: true});
+m.set('min_val', 0, {silent: true});
 m.set('max_val', o.max_val, {silent: true});
 flag = false;
   }
@@ -446,7 +446,7 @@ define('pgadmin.node.column', [
   _.each(m.datatypes, function(o) {
 if ( of_type == o.value ) {
   if(o.precision) {
-m.set('min_val', o.min_val, {silent: true});
+m.set('min_val', 0, {silent: true});
 m.set('max_val', o.max_val, {silent: true});
 flag = true;
   }
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql
index 385e40e..d7b9d7e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql
@@ -9,10 +9,10 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
 
 {% endif %}
 {###  Alter column type and collation ###}
-{% if (data.cltype and data.cltype != o_data.cltype) or (data.attlen is defined and data.attlen != o_data.attlen) or (data.attprecision is defined and data.attprecision != o_data.attprecision) %}
+{% if (data.cltype and data.cltype != o_data.cltype) or (data.attlen is defined and data.attlen != o_data.attlen) or (data.attprecision is defined and data.attprecision != o_data.attprecision) or (data.collspcname and data.collspcname != o_data.collspcname)%}
 ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
 ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} TYPE {{ GET_TYPE.UPDATE_TYPE_SQL(conn, data, o_data) }}{% if data.collspcname and data.collspcname != o_data.collspcname %}
- COLLATE {{data.collspcname}}{% endif %};
+ COLLATE {{data.collspcname}}{% elif o_data.collspcname %} COLLATE {{o_data.collspcname}}{% endif %};
 {% endif %}
 {###  Alter column default value ###}
 {% if data.defval is defined and data.defval is not none and data.defval != '' and data.defval != o_data.defval %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/update.sql
index 6b17481..6814445 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/default/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/t

Re: pgAdmin 4 - Update for Server dialog

2017-12-13 Thread Khushboo Vashi
Hi susan,

I am getting an error while applying the patch, attached the screen-shot
for the same.

Thanks,
Khushboo


On Wed, Dec 13, 2017 at 11:20 PM, Susan Douglas <
susan.doug...@enterprisedb.com> wrote:

>
> Hi All,
>
> I've attached a patch that (hopefully) updates the documented behaviors of
> the Server dialog.  If you could look it over, and apply it, I'd appreciate
> it!
>
> As always, let me know if there are problems - Thanks!
>
> -- Susan
>
> PS - I've attached the .rst and .png files that were updated in this patch
> below as well...
>
>
>
>
>
>


Re: [pgAdmin4][Patch]: Add basic Tab navigation - Debugger

2017-12-14 Thread Khushboo Vashi
On Thu, Dec 14, 2017 at 2:07 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Yes, we can commit this code, It will add basic button navigation via Tab
> key.
>
> I think we should hold till our final design gets ready.

> I will keep the RM open until we add Tab navigation :)
>
>
> On Wed, Dec 13, 2017 at 9:33 PM, Dave Page  wrote:
>
>> Hi,
>>
>> On Wed, Dec 13, 2017 at 7:55 AM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> PFA patch to add basic Tab key navigation in debugger window, where user
>>> will be able to navigate buttons using Tab key.
>>> RM#2897
>>>
>>> TODO:// Need to work on Debugger window Panel navigation.
>>>
>>
>> Given our conversation this morning, do we still want to apply this at
>> this time?
>>
>> (for the benefit of the list, Murtuza, Khushboo, Harshal and I were
>> discussing a keyboard navigation strategy for the whole application).
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>


[pgAdmin4][Patch]: RM #2964 - [Desktop Runtime] pgAdmin4 crash if user download query as CVS

2017-12-18 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix the RM #2964:  [Desktop Runtime]
pgAdmin4 crash if user download query as CVS.

Patch by Neel Patel.

Thanks,
Khushboo
diff --git a/runtime/BrowserWindow.cpp b/runtime/BrowserWindow.cpp
index 2dd5b49..38982c7 100644
--- a/runtime/BrowserWindow.cpp
+++ b/runtime/BrowserWindow.cpp
@@ -662,7 +662,7 @@ void BrowserWindow::downloadFileProgress(qint64 readData, qint64 totalData)
 }
 
 // Check if download is finished without readyRead signal then write the data.
-if(m_reply->isFinished() && !is_readyReadSignaled)
+if(m_reply && m_reply->isFinished() && !is_readyReadSignaled)
 {
 // Write data to file
 m_file->write(m_reply->read(readData));
@@ -691,7 +691,7 @@ void BrowserWindow::downloadFileProgress(qint64 readData, qint64 totalData)
   m_reply = NULL;
 }
 
-if(m_reply->isFinished() && readData == totalData)
+if(m_reply && m_reply->isFinished() && readData == totalData)
 m_readBytes = 0;
  }
 }


[pgAdmin4][Patch]: RM #2949 : [Web Based] Complete sql should displayed for fts directory in sql pane

2017-12-20 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix RM #2949 : [Web Based] Complete sql
should displayed for fts directory in sql pane.

Thanks,
Khushboo
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py
index 658a7bf..6b1d348 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py
@@ -799,6 +799,14 @@ class FtsDictionaryView(PGChildNodeView):
   data=res['rows'][0],
   conn=self.conn, is_displaying=True)
 
+sql_header = u"""-- Text Search Dictionary: {0}
+
+-- DROP TEXT SEARCH DICTIONARY {0};
+
+""".format(self.qtIdent(self.conn, res['rows'][0]['schema'], res['rows'][0]['name']))
+
+sql = sql_header + sql
+
 return ajax_response(response=sql.strip('\n'))
 
 @check_precondition


[pgAdmin4][Patch]: RM #2933 - Add support for transition tables in Postgres 10 triggers

2017-12-22 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix RM #2933 - Add support for transition
tables in Postgres 10 triggers.

Thanks,
Khushboo
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/create.sql
new file mode 100644
index 000..b26ab41
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/create.sql
@@ -0,0 +1,36 @@
+{### Set a flag which allows us to put OR between events ###}
+{% set or_flag = False %}
+{% if data.lanname == 'edbspl' or data.tfunction == 'Inline EDB-SPL' %}
+CREATE OR REPLACE TRIGGER {{ conn|qtIdent(data.name) }}
+{% else %}
+CREATE{% if data.is_constraint_trigger %} CONSTRAINT{% endif %} TRIGGER {{ conn|qtIdent(data.name) }}
+{% endif %}
+{{data.fires}} {% if data.evnt_insert %}INSERT{% set or_flag = True %}
+{% endif %}{% if data.evnt_delete %}
+{% if or_flag %} OR {% endif %}DELETE{% set or_flag = True %}
+{% endif %}{% if data.evnt_truncate %}
+{% if or_flag %} OR {% endif %}TRUNCATE{% set or_flag = True %}
+{% endif %}{% if data.evnt_update %}
+{% if or_flag %} OR {% endif %}UPDATE {% if data.columns|length > 0 %}OF {% for c in data.columns %}{% if loop.index != 1 %}, {% endif %}{{ conn|qtIdent(c) }}{% endfor %}{% endif %}
+{% endif %}
+
+ON {{ conn|qtIdent(data.schema, data.table) }}
+{% if data.tgdeferrable %}
+DEFERRABLE{% if data.tginitdeferred %} INITIALLY DEFERRED{% endif %}
+{% endif %}
+{% if data.tgoldtable or data.tgnewtable %}
+REFERENCING{% if data.tgnewtable %} NEW TABLE AS {{ conn|qtIdent(data.tgnewtable) }}{% endif %}{% if data.tgoldtable %} OLD TABLE AS {{ conn|qtIdent(data.tgoldtable) }}{% endif %}
+
+{% endif %}
+FOR EACH{% if data.is_row_trigger %} ROW{% else %} STATEMENT{% endif %}
+{% if data.whenclause %}
+
+WHEN {{ data.whenclause }}{% endif %}
+
+{% if data.prosrc is defined and
+(data.lanname == 'edbspl' or data.tfunction == 'Inline EDB-SPL') %}{{ data.prosrc }}{% else %}EXECUTE PROCEDURE {{ data.tfunction }}{% if data.tgargs %}({{ data.tgargs }}){% else %}(){% endif%}{% endif%};
+
+{% if data.description %}
+COMMENT ON TRIGGER {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
+IS {{data.description|qtLiteral}};
+{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/properties.sql
new file mode 100644
index 000..1a7da0f
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/properties.sql
@@ -0,0 +1,25 @@
+SELECT t.oid,t.tgname AS name, t.xmin, t.*, relname, CASE WHEN relkind = 'r' THEN TRUE ELSE FALSE END AS parentistable,
+nspname, des.description, l.lanname, p.prosrc, p.proname AS tfunction,
+COALESCE(substring(pg_get_triggerdef(t.oid), 'WHEN (.*) EXECUTE PROCEDURE'),
+substring(pg_get_triggerdef(t.oid), 'WHEN (.*)  \\$trigger')) AS whenclause,
+-- We need to convert tgargs column bytea datatype to array datatype
+(string_to_array(encode(tgargs, 'escape'), '\000')::text[])[1:tgnargs] AS custom_tgargs,
+{% if datlastsysoid %}
+(CASE WHEN t.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_trigger,
+{% endif %}
+(CASE WHEN tgconstraint != 0::OID THEN true ElSE false END) AS is_constarint,
+(CASE WHEN tgenabled = 'O' THEN true ElSE false END) AS is_enable_trigger,
+tgoldtable,
+tgnewtable
+FROM pg_trigger t
+JOIN pg_class cl ON cl.oid=tgrelid
+JOIN pg_namespace na ON na.oid=relnamespace
+LEFT OUTER JOIN pg_description des ON (des.objoid=t.oid AND des.classoid='pg_trigger'::regclass)
+LEFT OUTER JOIN pg_proc p ON p.oid=t.tgfoid
+LEFT OUTER JOIN pg_language l ON l.oid=p.prolang
+WHERE NOT tgisinternal
+AND tgrelid = {{tid}}::OID
+{% if trid %}
+AND t.oid = {{trid}}::OID
+{% endif %}
+ORDER BY tgname;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
index 843ff11..351682f 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
@@ -467,6 +467,18 @@ define('pgadmin.node.trigger', [
  return true;
 }
 },{
+id: 'tgoldtable', label: gettext('Old table'),
+type: 'text', group: gettext('Transition'),
+cell: 'string', mode: ['create', 'edit', 'properties'],
+deps: ['fires', 'is_constraint_trigger', 'evnt_insert', 'evnt_update', 'evnt_delete', 'columns'],
+   

[pgAdmin4][Patch]: RM #2956 - pgAdmin 2.0 Preferences: User language drop down remains on screen if not collapsed

2017-12-22 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix RM # 2956 - pgAdmin 2.0 Preferences:
User language drop down remains on screen if not collapsed.

Thanks,
Khushboo
diff --git a/web/pgadmin/preferences/static/js/preferences.js b/web/pgadmin/preferences/static/js/preferences.js
index ca22a4c..635a6b7 100644
--- a/web/pgadmin/preferences/static/js/preferences.js
+++ b/web/pgadmin/preferences/static/js/preferences.js
@@ -91,16 +91,18 @@ define('pgadmin.preferences', [
  * Clear the existing html in the preferences content
  */
 var content = $container.find('.preferences_content');
-content.empty();
-
 /*
  * We should clean up the existing controls.
  */
 if (controls) {
   _.each(controls, function(c) {
+if ('$sel' in c) {
+  if (c.$sel.data('select2').isOpen()) c.$sel.data('select2').close();
+}
 c.remove();
   });
 }
+content.empty();
 controls = [];
 
 /*


[pgAdmin4][Patch]: RM #2945 - [Web based] Message "can't execute an empty query" displayed if user Click Yes on constrains trigger for view trigger

2017-12-24 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix RM #2945 :  [Web based] Message
"can't execute an empty query" displayed if user Click Yes on constrains
trigger for view trigger

Fixed issues:

1. Disable "Constraint trigger?" option in View node
2. Disable "Constraint trigger?" option  in edit mode for all the
applicable nodes
3. Merged "Constraint trigger?" and "Constraint?" on the properties tab as
both were for the same purpose but the "Constraint trigger?" was not
showing correct data.

Thanks,
Khushboo
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/properties.sql
index 76f0a25..8b3ddc1 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/properties.sql
@@ -7,7 +7,7 @@ SELECT t.oid,t.tgname AS name, t.xmin, t.*, relname, CASE WHEN relkind = 'r' THE
 {% if datlastsysoid %}
 (CASE WHEN t.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_trigger,
 {% endif %}
-(CASE WHEN tgconstraint != 0::OID THEN true ElSE false END) AS is_constarint,
+(CASE WHEN tgconstraint != 0::OID THEN true ElSE false END) AS is_constraint_trigger,
 (CASE WHEN tgenabled = 'O' THEN true ElSE false END) AS is_enable_trigger
 FROM pg_trigger t
 JOIN pg_class cl ON cl.oid=tgrelid
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
index 843ff11..04f9a41 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
@@ -249,8 +249,9 @@ define('pgadmin.node.trigger', [
   group: gettext('Definition'),
   disabled: function(m) {
 // Disabled if table is a partitioned table.
-if (_.has(m, 'node_info') && _.has(m.node_info, 'table') &&
-_.has(m.node_info.table, 'is_partitioned') && m.node_info.table.is_partitioned)
+if ((_.has(m, 'node_info') && _.has(m.node_info, 'table') &&
+_.has(m.node_info.table, 'is_partitioned') && m.node_info.table.is_partitioned) ||
+ _.indexOf(Object.keys(m.node_info), 'view') != -1)
 {
   setTimeout(function(){
   m.set('is_constraint_trigger', false);
@@ -258,6 +259,8 @@ define('pgadmin.node.trigger', [
 
   return true;
 }
+
+return m.inSchemaWithModelCheck.apply(this, [m]);
   }
 },{
   id: 'tgdeferrable', label: gettext('Deferrable?'),
@@ -487,10 +490,6 @@ define('pgadmin.node.trigger', [
   id: 'is_sys_trigger', label: gettext('System trigger?'), cell: 'string',
   type: 'switch', disabled: 'inSchemaWithModelCheck', mode: ['properties']
 },{
-  id: 'is_constarint', label: gettext('Constraint?'), cell: 'string',
-  type: 'switch', disabled: 'inSchemaWithModelCheck', mode: ['properties'],
-  group: gettext('Definition')
-},{
   id: 'description', label: gettext('Comment'), cell: 'string',
   type: 'multiline', mode: ['properties', 'create', 'edit'],
   disabled: 'inSchema'


Re: [pgAdmin4][Patch]: RM #2933 - Add support for transition tables in Postgres 10 triggers

2017-12-24 Thread Khushboo Vashi
Hi,

Please find the attached updated patch. One small change made in the SQL
file due to fix for RM #2945.

Thanks,
Khushboo

On Fri, Dec 22, 2017 at 3:14 PM, Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

> Hi,
>
> Please find the attached patch to fix RM #2933 - Add support for
> transition tables in Postgres 10 triggers.
>
> Thanks,
> Khushboo
>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/create.sql
new file mode 100644
index 000..b26ab41
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/create.sql
@@ -0,0 +1,36 @@
+{### Set a flag which allows us to put OR between events ###}
+{% set or_flag = False %}
+{% if data.lanname == 'edbspl' or data.tfunction == 'Inline EDB-SPL' %}
+CREATE OR REPLACE TRIGGER {{ conn|qtIdent(data.name) }}
+{% else %}
+CREATE{% if data.is_constraint_trigger %} CONSTRAINT{% endif %} TRIGGER {{ conn|qtIdent(data.name) }}
+{% endif %}
+{{data.fires}} {% if data.evnt_insert %}INSERT{% set or_flag = True %}
+{% endif %}{% if data.evnt_delete %}
+{% if or_flag %} OR {% endif %}DELETE{% set or_flag = True %}
+{% endif %}{% if data.evnt_truncate %}
+{% if or_flag %} OR {% endif %}TRUNCATE{% set or_flag = True %}
+{% endif %}{% if data.evnt_update %}
+{% if or_flag %} OR {% endif %}UPDATE {% if data.columns|length > 0 %}OF {% for c in data.columns %}{% if loop.index != 1 %}, {% endif %}{{ conn|qtIdent(c) }}{% endfor %}{% endif %}
+{% endif %}
+
+ON {{ conn|qtIdent(data.schema, data.table) }}
+{% if data.tgdeferrable %}
+DEFERRABLE{% if data.tginitdeferred %} INITIALLY DEFERRED{% endif %}
+{% endif %}
+{% if data.tgoldtable or data.tgnewtable %}
+REFERENCING{% if data.tgnewtable %} NEW TABLE AS {{ conn|qtIdent(data.tgnewtable) }}{% endif %}{% if data.tgoldtable %} OLD TABLE AS {{ conn|qtIdent(data.tgoldtable) }}{% endif %}
+
+{% endif %}
+FOR EACH{% if data.is_row_trigger %} ROW{% else %} STATEMENT{% endif %}
+{% if data.whenclause %}
+
+WHEN {{ data.whenclause }}{% endif %}
+
+{% if data.prosrc is defined and
+(data.lanname == 'edbspl' or data.tfunction == 'Inline EDB-SPL') %}{{ data.prosrc }}{% else %}EXECUTE PROCEDURE {{ data.tfunction }}{% if data.tgargs %}({{ data.tgargs }}){% else %}(){% endif%}{% endif%};
+
+{% if data.description %}
+COMMENT ON TRIGGER {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
+IS {{data.description|qtLiteral}};
+{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/properties.sql
new file mode 100644
index 000..bd37378
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/properties.sql
@@ -0,0 +1,25 @@
+SELECT t.oid,t.tgname AS name, t.xmin, t.*, relname, CASE WHEN relkind = 'r' THEN TRUE ELSE FALSE END AS parentistable,
+nspname, des.description, l.lanname, p.prosrc, p.proname AS tfunction,
+COALESCE(substring(pg_get_triggerdef(t.oid), 'WHEN (.*) EXECUTE PROCEDURE'),
+substring(pg_get_triggerdef(t.oid), 'WHEN (.*)  \\$trigger')) AS whenclause,
+-- We need to convert tgargs column bytea datatype to array datatype
+(string_to_array(encode(tgargs, 'escape'), '\000')::text[])[1:tgnargs] AS custom_tgargs,
+{% if datlastsysoid %}
+(CASE WHEN t.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_trigger,
+{% endif %}
+(CASE WHEN tgconstraint != 0::OID THEN true ElSE false END) AS is_constraint_trigger,
+(CASE WHEN tgenabled = 'O' THEN true ElSE false END) AS is_enable_trigger,
+tgoldtable,
+tgnewtable
+FROM pg_trigger t
+JOIN pg_class cl ON cl.oid=tgrelid
+JOIN pg_namespace na ON na.oid=relnamespace
+LEFT OUTER JOIN pg_description des ON (des.objoid=t.oid AND des.classoid='pg_trigger'::regclass)
+LEFT OUTER JOIN pg_proc p ON p.oid=t.tgfoid
+LEFT OUTER JOIN pg_language l ON l.oid=p.prolang
+WHERE NOT tgisinternal
+AND tgrelid = {{tid}}::OID
+{% if trid %}
+AND t.oid = {{trid}}::OID
+{% endif %}
+ORDER BY tgname;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
index 843ff11..351682f 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
@@ -467,6 +467,18 @

[pgAdmin4][Patch]: RM #2963 - Backup database, Restore database and Maintenance Database failed for é object.

2017-12-25 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix RM #2963: Backup database, Restore
database and Maintenance Database failed for é object.

Thanks,
Khushboo
diff --git a/web/pgadmin/misc/bgprocess/processes.py b/web/pgadmin/misc/bgprocess/processes.py
index 209c2a1..a5d2655 100644
--- a/web/pgadmin/misc/bgprocess/processes.py
+++ b/web/pgadmin/misc/bgprocess/processes.py
@@ -164,12 +164,13 @@ class BatchProcess(object):
 csv_writer.writerow(_args)
 
 args_val = args_csv_io.getvalue().strip(str('\r\n'))
+desc_str = dumps(self.desc)
 
 j = Process(
 pid=int(id), command=_cmd,
-arguments=args_val.decode('utf-8', 'replace') if IS_PY2 and hasattr(args_val, 'decode') \
-else args_val,
-logdir=log_dir, desc=dumps(self.desc), user_id=current_user.id
+arguments=args_val.decode('utf-8', 'replace') if IS_PY2 and hasattr(args_val, 'decode') else args_val,
+logdir=log_dir, desc=desc_str.decode('utf-8', 'replace') if IS_PY2 and hasattr(desc_str, 'decode')
+else desc_str, user_id=current_user.id
 )
 db.session.add(j)
 db.session.commit()


Re: [pgAdmin4][Patch]: RM #2963 - Backup database, Restore database and Maintenance Database failed for é object.

2018-01-09 Thread Khushboo Vashi
On Wed, Jan 3, 2018 at 8:54 PM, Dave Page  wrote:

> Hi
>
> On Mon, Dec 25, 2017 at 11:03 AM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Please find the attached patch to fix RM #2963: Backup database, Restore
>> database and Maintenance Database failed for é object.
>>
>
> With the patch applied, I get:
>
> 2018-01-03 15:23:00,110: INFO pgadmin: Executing the process executor
> with the arguments: ['/Users/dpage/.virtualenvs/pgadmin4/bin/python',
> '/Users/dpage/git/pgadmin4/web/pgadmin/misc/bgprocess/process_executor.py',
> '/usr/local/pgsql/bin/pg_dump', u'--file', u'/Users/dpage/e.sql',
> u'--host', u'localhost', u'--port', '5432', u'--username', u'postgres',
> u'--no-password', u'--verbose', u'--format=c', u'--blobs', u'\xe9']
> 2018-01-03 15:23:00,117: INFO werkzeug: 127.0.0.1 - - [03/Jan/2018
> 15:23:00] "POST /backup/job/1/object HTTP/1.1" 200 -
> Exception in thread Thread-6:
> Traceback (most recent call last):
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
> line 810, in __bootstrap_inner
> self.run()
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
> line 763, in run
> self.__target(*self.__args, **self.__kwargs)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/
> lib/python2.7/SocketServer.py", line 602, in process_request_thread
> self.handle_error(request, client_address)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/
> lib/python2.7/SocketServer.py", line 599, in process_request_thread
> self.finish_request(request, client_address)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/
> lib/python2.7/SocketServer.py", line 334, in finish_request
> self.RequestHandlerClass(request, client_address, self)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/
> lib/python2.7/SocketServer.py", line 655, in __init__
> self.handle()
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
> line 200, in handle
> rv = BaseHTTPRequestHandler.handle(self)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/
> lib/python2.7/BaseHTTPServer.py", line 340, in handle
> self.handle_one_request()
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
> line 235, in handle_one_request
> return self.run_wsgi()
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
> line 177, in run_wsgi
> execute(self.server.app)
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py",
> line 165, in execute
> application_iter = app(environ, start_response)
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 2000, in __call__
> return self.wsgi_app(environ, start_response)
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1991, in wsgi_app
> response = self.make_response(self.handle_exception(e))
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1567, in handle_exception
> reraise(exc_type, exc_value, tb)
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1988, in wsgi_app
> response = self.full_dispatch_request()
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1641, in full_dispatch_request
> rv = self.handle_user_exception(e)
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1544, in handle_user_exception
> reraise(exc_type, exc_value, tb)
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1639, in full_dispatch_request
> rv = self.dispatch_request()
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1625, in dispatch_request
> return self.view_functions[rule.endpoint](**req.view_args)
>   File 
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask_login.py",
> line 792, in decorated_view
> return

[pgAdmin4][Patch]: RM #2993 : - [Web Based] User can not view data for View and MATERIALIZED View object.

2018-01-10 Thread Khushboo Vashi
Hi,

Please find the patch to fix RM #2993 : [Web Based] User can not view data
for View and MATERIALIZED View object.

Thanks,
Khushboo
diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py
index 84c98d3..aeca5cc 100644
--- a/web/pgadmin/tools/sqleditor/__init__.py
+++ b/web/pgadmin/tools/sqleditor/__init__.py
@@ -434,8 +434,10 @@ 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)
+has_oids = False
+if trans_obj.object_type == 'table':
+# Fetch OIDs status
+has_oids = trans_obj.has_oids(default_conn)
 
 # Fetch the applied filter.
 filter_applied = trans_obj.is_filter_applied()


[pgAdmin4][Patch]: RM #2904: As a visually impaired user I need all buttons in the application to have appropriate tooltips for my screen reader to interpret

2018-01-15 Thread Khushboo Vashi
Hi,

Please find the attached patch for RM # 2904: As a visually impaired user I
need all buttons in the application to have appropriate tooltips for my
screen reader to interpret.

Thanks,
Khushboo
diff --git a/web/pgadmin/about/static/js/about.js b/web/pgadmin/about/static/js/about.js
index 1e72c91..1a6446a 100644
--- a/web/pgadmin/about/static/js/about.js
+++ b/web/pgadmin/about/static/js/about.js
@@ -20,7 +20,8 @@ define(
   },
   setup: function() {
 return {
-  buttons:[{ text: gettext('OK'), key: 27, className: 'btn btn-primary' }],
+  buttons:[{ text: gettext('OK'), key: 27, className: 'btn btn-primary',
+   attrs: {'title': gettext('OK')}}],
   options: {
 modal: false,
 resizable: true,
diff --git a/web/pgadmin/browser/static/js/wizard.js b/web/pgadmin/browser/static/js/wizard.js
index 56b1edf..a95f702 100644
--- a/web/pgadmin/browser/static/js/wizard.js
+++ b/web/pgadmin/browser/static/js/wizard.js
@@ -128,14 +128,18 @@ define([
   '  ' +
   '  ' +
   '' +
-  '  >' +
+  '  ' +
+  '   title = "' + gettext('Back') + '">' +
   '' + gettext('Back') + '' +
-  '  >' +
+  '  ' +
+  '   title = "' + gettext('Next') + '" >' +
   '' + gettext('Next') +
   '' +
-  '  >' +
+  '  ' +
+  '  title = "' + gettext('Cancel') + '">' +
   '' + gettext('Cancel') + '' +
-  '  >' +
+  '  ' +
+  'title = "' + gettext('Finish') + '">' +
   '' + gettext('Finish') + '' +
   '' +
   '  ' +
diff --git a/web/pgadmin/preferences/static/js/preferences.js b/web/pgadmin/preferences/static/js/preferences.js
index d025be1..dfa3b2c 100644
--- a/web/pgadmin/preferences/static/js/preferences.js
+++ b/web/pgadmin/preferences/static/js/preferences.js
@@ -401,10 +401,12 @@ define('pgadmin.preferences', [
 text: gettext('OK'),
 key: 13,
 className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button',
+attrs: {'title': gettext('OK')}
   }, {
 text: gettext('Cancel'),
 key: 27,
 className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button',
+attrs: {'title': gettext('Cancel')}
   }],
   focus: {
 element: 0,
diff --git a/web/pgadmin/settings/static/js/settings.js b/web/pgadmin/settings/static/js/settings.js
index 634368c..0402b5c 100644
--- a/web/pgadmin/settings/static/js/settings.js
+++ b/web/pgadmin/settings/static/js/settings.js
@@ -51,7 +51,7 @@ define('pgadmin.settings', [
 function() {
   // Do nothing as user canceled the operation.
 }
-  );
+  )
 },
   };
 
diff --git a/web/pgadmin/static/js/alertify.pgadmin.defaults.js b/web/pgadmin/static/js/alertify.pgadmin.defaults.js
index 3129ecc..9b815f5 100644
--- a/web/pgadmin/static/js/alertify.pgadmin.defaults.js
+++ b/web/pgadmin/static/js/alertify.pgadmin.defaults.js
@@ -369,5 +369,11 @@ define([
 },
   });
 
+  // Confirm dialogue: Set title tag
+  alertify.confirm().set({onshow:function() {
+$(this.__internal.buttons[0].element).attr('title', gettext('OK'));
+$(this.__internal.buttons[1].element).attr('title', gettext('Cancel'));
+  }});
+
   return alertify;
 });
diff --git a/web/pgadmin/tools/backup/static/js/backup.js b/web/pgadmin/tools/backup/static/js/backup.js
index 367f354..c20b98e 100644
--- a/web/pgadmin/tools/backup/static/js/backup.js
+++ b/web/pgadmin/tools/backup/static/js/backup.js
@@ -604,6 +604,7 @@ define([
 type: 'button',
 url: 'backup.html',
 label: gettext('Backup'),
+title: gettext('Backup')
   },
 }, {
   text: '',
@@ -616,17 +617,24 @@ define([
 url: url_for('help.static', {
   'filename': 'backup_dialog.html',
 }),
+title: gettext('Backup')
   },
 }, {
   text: gettext('Backup'),
   key: 13,
   className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button',
   'data-btn-name': 'backup',
+  attrs: {
+title: gettext('Backup')
+  }
 }, {
   text: gettext('Cancel'),
   key: 27,
   className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button',
   'data-btn-name': 'cancel',
+  attrs: {
+ 

Re: [pgAdmin4][Patch]: RM #2904: As a visually impaired user I need all buttons in the application to have appropriate tooltips for my screen reader to interpret

2018-01-16 Thread Khushboo Vashi
On Mon, Jan 15, 2018 at 10:39 PM, Dave Page  wrote:

> Hi
>
> On Mon, Jan 15, 2018 at 10:23 AM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Please find the attached patch for RM # 2904: As a visually impaired user
>> I need all buttons in the application to have appropriate tooltips for my
>> screen reader to interpret.
>>
>
> Unfortunately I think there's been a misunderstanding with this patch,
> most likely my fault for not being clearer;
>
> - There is no need to add tooltips to buttons that already have text,
> unless we want to add additional information. For example, on the OK
> button, we might have a tooltip that says "Apply the changes and close the
> dialog". That really is optional though, as screen readers could already
> read the button text (but we should be consistent).
>
> - We do need to add tooltips to buttons that don't have any text. For
> example;
>  * dialogue title-bar buttons
>  * the "close tab" and "move tabs left"/"move tabs right" buttons that
> may appear in tab bars
>  * the add row button at the top of a subnode control (e.g. to add a
> column definition)
>  * the delete and expand row buttons in subnode grid rows
>
> Sorry for not being clearer about the requirements.
>
> Thanks for the clarification.
Please find the attached updated patch.

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


Re: [pgAdmin4][Patch]: RM #2904: As a visually impaired user I need all buttons in the application to have appropriate tooltips for my screen reader to interpret

2018-01-16 Thread Khushboo Vashi
On Wed, Jan 17, 2018 at 12:23 PM, Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

>
>
> On Mon, Jan 15, 2018 at 10:39 PM, Dave Page  wrote:
>
>> Hi
>>
>> On Mon, Jan 15, 2018 at 10:23 AM, Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> Please find the attached patch for RM # 2904: As a visually impaired
>>> user I need all buttons in the application to have appropriate tooltips for
>>> my screen reader to interpret.
>>>
>>
>> Unfortunately I think there's been a misunderstanding with this patch,
>> most likely my fault for not being clearer;
>>
>> - There is no need to add tooltips to buttons that already have text,
>> unless we want to add additional information. For example, on the OK
>> button, we might have a tooltip that says "Apply the changes and close the
>> dialog". That really is optional though, as screen readers could already
>> read the button text (but we should be consistent).
>>
>> - We do need to add tooltips to buttons that don't have any text. For
>> example;
>>  * dialogue title-bar buttons
>>  * the "close tab" and "move tabs left"/"move tabs right" buttons
>> that may appear in tab bars
>>  * the add row button at the top of a subnode control (e.g. to add a
>> column definition)
>>  * the delete and expand row buttons in subnode grid rows
>>
>> Sorry for not being clearer about the requirements.
>>
>> Thanks for the clarification.
> Please find the attached updated patch.
>
Missed attachment. Please find it attached.

> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/variable.js b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
index 5dca9f5..2c5bb07 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/variable.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
@@ -330,7 +330,7 @@ define([
 titleTmpl = _.template([
   '',
   '<%-label%>',
-  '>',
+  '>',
   ''].join('\n')),
 $gridBody =
 $('').append(
diff --git a/web/pgadmin/static/js/alertify.pgadmin.defaults.js b/web/pgadmin/static/js/alertify.pgadmin.defaults.js
index 3129ecc..d2c1591 100644
--- a/web/pgadmin/static/js/alertify.pgadmin.defaults.js
+++ b/web/pgadmin/static/js/alertify.pgadmin.defaults.js
@@ -190,6 +190,8 @@ define([
   alertify.pgDialogBuild = function() {
 this.set('onshow', function() {
   this.elements.dialog.classList.add('pg-el-container');
+  $(this.elements.commands.close).attr('title', gettext('Close'));
+  $(this.elements.commands.maximize).attr('title', gettext('Maximize'));
   alertifyDialogResized.apply(this, arguments);
 });
 this.set('onresize', alertifyDialogStartResizing.bind(this, true));
@@ -369,5 +371,11 @@ define([
 },
   });
 
+  // Confirm dialogue: Set title attribute
+  alertify.confirm().set({onshow:function() {
+$(this.elements.commands.close).attr('title', gettext('Close'));
+$(this.elements.commands.maximize).attr('title', gettext('Maximize'));
+  }});
+
   return alertify;
 });
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 4f3b144..6ac80d8 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -983,7 +983,7 @@ define([
 gridHeader = _.template([
   '',
   '  <%-label%>',
-  '  ><%-add_label%>',
+  '   title="' + _('Add new row') + '"><%-add_label%>',
   '',
 ].join('\n')),
 gridBody = $('').append(
@@ -1024,7 +1024,7 @@ define([
   // Insert Edit Cell into Grid
   if (data.disabled == false && data.canEdit) {
 var editCell = Backgrid.Extension.ObjectCell.extend({
-  schema: gridSchema.schema,
+  schema: gridSchema.schema
 });
 
 gridSchema.columns.unshift({
@@ -1246,7 +1246,7 @@ define([
   var self = this,
 gridHeader = ['',
   '  ' + data.label + '',
-  '  ',
+  '  ',
   '',
   

Re: "Fetching all records..."

2018-01-21 Thread Khushboo Vashi
On Fri, Jan 19, 2018 at 8:19 PM, microsys.gr microsys.gr <
microsys...@gmail.com> wrote:

> Version 2.0
> Copyright Copyright 2013 - 2017, The pgAdmin Development
> Team
> Python Version2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19)
> [MSC v.1500 32 bit (Intel)]
> Flask Version   0.11.1
> Application Mode Desktop
> Current User   pgadm...@pgadmin.org
>
> When open form for the first time or re-run from 'Execute/Refresh(F5)'
> button everything looks fine.
> Same good result when run SELECT script.
>
> My table shows:
> Messages
> Successfully run. Total query runtime: 5 secs.
> 210930 rows affected.
>
> (Table's record size appx. 2700 bytes)
>
> - When clicking on the leftmost header cell (Image Region 1) crashes on
> trying "Fetching all records"
> - When clicking on any header cell for the first time (Image Region 2),
> the behaviour is like clicking on the leftmost header cell (Image Region
> 1), fetching all records before selecting the whole row.
>
> The bug is in the onclick event code of the grid header.
> It seems that when click the header, the SELECT script is re-executed with
> bug behaviour.
>
>
>
Logged the bug. Please track with https://redmine.postgresql.org/issues/3035
One suggestion, please upgrade your pgAdmin 4, the latest version is 2.1.

Always keep pgadmin-hack...@postgresql.org in loop while reporting a bug.

>
> 2018-01-19 8:02 GMT+02:00 Khushboo Vashi 
> :
>
>> Hi,
>>
>> Please log your bug at https://redmine.postgresql.org/projects/pgadmin4
>>
>> Provide pgAdmin 4 version and screen shot of the bug , to understand the
>> issue easily.
>>
>> Thanks,
>> Khushboo
>>
>> On Thu, Jan 18, 2018 at 8:44 PM, microsys.gr microsys.gr <
>> microsys...@gmail.com> wrote:
>>
>>> OS Windows 10 64-bit
>>> Python Version 2.7.11
>>> Flask Version 0.11.1
>>> Application Mode Desktop
>>> -
>>>
>>> 1. View/Edit Data -> All Rows
>>>   Speed is almost perfect - Well done.
>>>
>>> Bug:
>>> When clicking on top-left corner of grid to fetch all records,
>>> on large tables pgAdmin4 crashes on  "Fetching all records..."  screen.
>>>
>>>
>>>
>>
>


Re: Table Properties... > [Columns tab] very slow

2018-01-23 Thread Khushboo Vashi
Hi,

Please log your bug at https://redmine.postgresql.org/projects/pgadmin4

Thanks,
Khushboo

On Tue, Jan 23, 2018 at 7:10 PM, microsys.gr microsys.gr <
microsys...@gmail.com> wrote:

> Version 2.1
> Python Version 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59)
> Flask Version 0.12.2
> Application Mode Desktop
>
>
> On tables with a lot of fields (table tested with 217 columns),
> the table [Properties...] [Columns tab]  form is useless slow.
> It takes more than 100 seconds to complete the green/blue switches.
> The same table needs only 5 secs to [View All Rows]
>
>
>
>


Re: suggestion: discard python2.x venv

2018-02-05 Thread Khushboo Vashi
Hi Loseph,


On Tue, Feb 6, 2018 at 9:21 AM, Ioseph Kim  wrote:

> Hi,
>
> I used pgadmin4 since 2 month.
>
> pgadmin4 is a good application for PostgreSQL. that is true!
>
> but, in multibytes environment, python2 + pgadmin4 is not good choice.
>
>
> if table name or column name is multibytes, export, import is not working,
> because  python2 unicode processing is ugly.
>
> and, if server message is multibytes, pgadmin4 does not display that,  and
> there are many other problems so.
>
> Many users have logged bugs in this area and the pgAdmin development team
have been fixing those issues.
Please report your bug @ https://redmine.postgresql.org/projects/pgadmin4 ,
if it's not yet logged.

>
> I changed venv to python3, most problems of multibytes have been resolved
> smoothly as expected.
>
>
> we need to narrow its focus.
>
>
> Regards Ioseph
>
>
> Thanks,
Khushboo


[pgAdmin4][Patch]: RM #2899: Provide access keys/shortcuts to all commonly used menu options in the main window.

2018-02-07 Thread Khushboo Vashi
Hi,

Please find the attached patch for RM #2899: Provide access keys/shortcuts
to all commonly used menu options in the main window.

Shortcuts provided in this patch:

Alt+Shift+Q Open the query tool
Alt+Shift+V View data
Alt+Shift+C Open the context menu
Alt+Shift+N Create an object
Alt+Shift+E Edit the object properties
Alt+Shift+D Delete the object
Alt+Shift+G Direct debugging


Thanks,
Khushboo
diff --git a/docs/en_US/keyboard_shortcuts.rst b/docs/en_US/keyboard_shortcuts.rst
index fe0737c..01edf0e 100644
--- a/docs/en_US/keyboard_shortcuts.rst
+++ b/docs/en_US/keyboard_shortcuts.rst
@@ -48,7 +48,20 @@ When using main browser window, the following keyboard shortcuts are available:
 | Alt+Shift+[   | Move tabbed panel backward/forward |
 | Alt+Shift+]   ||
 +---++
-
+| Alt+Shift+Q   | Open the query tool|
++---++
+| Alt+Shift+V   | View data  |
++---++
+| Alt+Shift+C   | Open the context menu  |
++---++
+| Alt+Shift+N   | Create an object   |
++---++
+| Alt+Shift+E   | Edit the object properties |
++---++
+| Alt+Shift+D   | Delete the object  |
++---++
+| Alt+Shift+G   | Direct debugging   |
++---++
 
 **SQL Editors**
 
diff --git a/web/pgadmin/browser/__init__.py b/web/pgadmin/browser/__init__.py
index d3df084..04065f5 100644
--- a/web/pgadmin/browser/__init__.py
+++ b/web/pgadmin/browser/__init__.py
@@ -324,6 +324,112 @@ class BrowserModule(PgAdminModule):
 category_label=gettext('Keyboard shortcuts'),
 fields=fields
 )
+
+self.preference.register(
+'keyboard_shortcuts',
+'sub_menu_query_tool',
+gettext('Open query tool'),
+'keyboardshortcut',
+{
+'alt': True,
+'shift': True,
+'control': False,
+'key': {'key_code': 81, 'char': 'q'}
+},
+category_label=gettext('Keyboard shortcuts'),
+fields=fields
+)
+
+self.preference.register(
+'keyboard_shortcuts',
+'sub_menu_view_data',
+gettext('View data'),
+'keyboardshortcut',
+{
+'alt': True,
+'shift': True,
+'control': False,
+'key': {'key_code': 86, 'char': 'v'}
+},
+category_label=gettext('Keyboard shortcuts'),
+fields=fields
+)
+
+self.preference.register(
+'keyboard_shortcuts',
+'sub_menu_create',
+gettext('Create object'),
+'keyboardshortcut',
+{
+'alt': True,
+'shift': True,
+'control': False,
+'key': {'key_code': 78, 'char': 'n'}
+},
+category_label=gettext('Keyboard shortcuts'),
+fields=fields
+)
+
+self.preference.register(
+'keyboard_shortcuts',
+'sub_menu_properties',
+gettext('Edit object properties'),
+'keyboardshortcut',
+{
+'alt': True,
+'shift': True,
+'control': False,
+'key': {'key_code': 69, 'char': 'e'}
+},
+category_label=gettext('Keyboard shortcuts'),
+fields=fields
+)
+
+self.preference.register(
+'keyboard_shortcuts',
+'sub_menu_delete',
+gettext('Delete object'),
+'keyboardshortcut',
+{
+'alt': True,
+'shift': True,
+'control': False,
+'key': {'key_code': 68, 'char': 'd'}
+},
+category_label=gettext('Keyboard shortcuts'),
+fields=fields
+)
+
+self.preference.register(
+'keyboard_shortcuts',
+'context_menu',
+gettext('Open context menu'),
+  

Re: [pgAdmin4][Patch]: RM #2899: Provide access keys/shortcuts to all commonly used menu options in the main window.

2018-02-08 Thread Khushboo Vashi
Hi Joao,

On Thu, Feb 8, 2018 at 7:57 PM, Joao De Almeida Pereira <
jdealmeidapere...@pivotal.io> wrote:

> Hello Khushboo,
> We were looking into the your patch and have some questions.
>
>   - What is the reason being the front end shortcuts being registered in
> the python code? There is already some precedent in the code, but this
> looks like a concern of the front end.
>

We have given customisable keyboard shortcuts through preferences dialogue
and to do so we need to register them first.

>   - Didn't saw any tests around this, did you create them?
>

Added feature test for the keyboard shortcuts in my previous patch which
was committed.

>
> While testing it out, in the Mac, when I press Option + Shift + E while
> selecting 'Tables' node, no information is given to the user that the
> object as no properties, like Option + Shift + V does, is this
> intentional?(Same with Option + Shift + D)
>
>
They are collection nodes and it is quite obvious that they can not be
edited, so as per me, no need for extra information.

> In which situation can Direct debugging be used?
>

Just provided the shortcut for it, the detailed information can be found @
https://www.pgadmin.org/docs/pgadmin4/2.x/debugger.html

> Should the documentation specify the Shortcuts for Mac as well?
>
>
Shortcuts are not specific to the platform, they are common for all the
platforms and the document also specify the same.

>
> Thanks
> Joao
>
> Thanks,
Khushboo

> On Thu, Feb 8, 2018 at 2:08 AM Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Please find the attached patch for RM #2899: Provide access
>> keys/shortcuts to all commonly used menu options in the main window.
>>
>> Shortcuts provided in this patch:
>>
>> Alt+Shift+Q Open the query tool
>> Alt+Shift+V View data
>> Alt+Shift+C Open the context menu
>> Alt+Shift+N Create an object
>> Alt+Shift+E Edit the object properties
>> Alt+Shift+D Delete the object
>> Alt+Shift+G Direct debugging
>>
>>
>> Thanks,
>> Khushboo
>>
>


[pgAdmin4][Patch]: RM 3081- Reverse engineered SQL for Sequences missing comment header and drop statement

2018-02-18 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix RM #3081 : Reverse engineered SQL for
Sequences missing comment header and drop statement

Thanks,
Khushboo
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
index a6d6e21..25722d6 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
@@ -141,15 +141,19 @@ class SequenceView(PGChildNodeView):
 @wraps(f)
 def wrapped(self, *args, **kwargs):
 
-self.manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(kwargs['sid'])
+driver = get_driver(PG_DEFAULT_DRIVER)
+self.manager = driver.connection_manager(kwargs['sid'])
+
 if action and action in ["drop"]:
 self.conn = self.manager.connection()
 elif 'did' in kwargs:
 self.conn = self.manager.connection(did=kwargs['did'])
 else:
 self.conn = self.manager.connection()
+
 self.template_path = 'sequence/sql/#{0}#'.format(self.manager.version)
 self.acl = ['r', 'w', 'U']
+self.qtIdent = driver.qtIdent
 
 return f(self, *args, **kwargs)
 return wrapped
@@ -625,6 +629,15 @@ class SequenceView(PGChildNodeView):
 if not isinstance(SQL, (str, unicode)):
 return SQL
 SQL = SQL.strip('\n').strip(' ')
+
+sql_header = u"""-- SEQUENCE: {0}
+
+-- DROP SEQUENCE {0};
+
+""".format(self.qtIdent(self.conn, result['schema'], result['name']))
+
+SQL = sql_header + SQL
+
 return ajax_response(response=SQL)
 
 def _formatter(self, data, scid, seid):


[pgAdmin4][Patch]: RM #3066 - Create script doesn't add quotation marks to column names for the "add index" functions

2018-02-18 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix RM #3066 -  Create script doesn't add
quotation marks to column names for the "add index" functions


Thanks,
Khushboo
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index/sql/default/create.sql
index b7bfa52..26921b8 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index/sql/default/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index/sql/default/create.sql
@@ -7,7 +7,7 @@ CREATE {% if data.indisunique %}UNIQUE {% endif %}INDEX {% if data.isconcurrent
 FIRST{% else %}LAST{% endif %}{% endif %}{% endif %}{% endfor %})
 {% else %}
 {## We will get indented data from postgres for column ##}
-({% for c in data.columns %}{% if loop.index != 1 %}, {% endif %}{{c.colname}}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.op_class %}
+({% for c in data.columns %}{% if loop.index != 1 %}, {% endif %}{{conn|qtIdent(c.colname)}}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.op_class %}
  {{c.op_class}}{% endif %}{% if c.sort_order is defined %}{% if c.sort_order %} DESC{% else %} ASC{% endif %}{% endif %}{% if c.nulls is defined %} NULLS {% if c.nulls %}
 FIRST{% else %}LAST{% endif %}{% endif %}{% endfor %})
 {% endif %}


Re: [pgAdmin4][Patch]: RM #3066 - Create script doesn't add quotation marks to column names for the "add index" functions

2018-02-19 Thread Khushboo Vashi
On Mon, Feb 19, 2018 at 5:19 PM, Dave Page  wrote:

> Hi
>
> On Mon, Feb 19, 2018 at 7:56 AM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Please find the attached patch to fix RM #3066 -  Create script doesn't
>> add quotation marks to column names for the "add index" functions
>>
>
> This causes additional quoting on regular tables. Please see the generated
> SQL for the index below:
>
> Please find the attached updated patch.


> -- Table: public."CamelCase"
>
> -- DROP TABLE public."CamelCase";
>
> CREATE TABLE public."CamelCase"
> (
> "ID" bigint NOT NULL DEFAULT nextval('"CamelCase_ID_seq"'::regclass),
> "SomeColumn" text COLLATE pg_catalog."default",
> b boolean,
> CONSTRAINT "CamelCase_pkey" PRIMARY KEY ("ID")
> )
> WITH (
> OIDS = FALSE
> )
> TABLESPACE pg_default;
>
> ALTER TABLE public."CamelCase"
> OWNER to postgres;
>
> -- Index: MixedCase_IDX
>
> -- DROP INDEX public."MixedCase_IDX";
>
> CREATE INDEX "MixedCase_IDX"
> ON public."CamelCase" USING btree
> ("""ID""")
> TABLESPACE pg_default;
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
index 0ead9db..2c51f14 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
@@ -776,7 +776,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
 
 # We need all data as collection for ColumnsModel
 cols_data = {
-'colname': row['attdef'].strip('"'),
+'colname': row['attdef'],
 'collspcname': row['collnspname'],
 'op_class': row['opcname'],
 }


[pgAdmin4][Patch]: RM #3077 - ERROR: invalid byte sequence for encoding "LATIN1":0x00

2018-02-20 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix RM #3077 : ERROR: invalid byte
sequence for encoding "LATIN1":0x00

Thanks,
Khushboo
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/properties.sql
index bd37378..28d10ad 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/properties.sql
@@ -3,7 +3,7 @@ SELECT t.oid,t.tgname AS name, t.xmin, t.*, relname, CASE WHEN relkind = 'r' THE
 COALESCE(substring(pg_get_triggerdef(t.oid), 'WHEN (.*) EXECUTE PROCEDURE'),
 substring(pg_get_triggerdef(t.oid), 'WHEN (.*)  \\$trigger')) AS whenclause,
 -- We need to convert tgargs column bytea datatype to array datatype
-(string_to_array(encode(tgargs, 'escape'), '\000')::text[])[1:tgnargs] AS custom_tgargs,
+(string_to_array(encode(tgargs, 'escape'), E'\\000')::text[])[1:tgnargs] AS custom_tgargs,
 {% if datlastsysoid %}
 (CASE WHEN t.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_trigger,
 {% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/properties.sql
index 8b3ddc1..2d34acc 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/properties.sql
@@ -3,7 +3,7 @@ SELECT t.oid,t.tgname AS name, t.xmin, t.*, relname, CASE WHEN relkind = 'r' THE
 COALESCE(substring(pg_get_triggerdef(t.oid), 'WHEN (.*) EXECUTE PROCEDURE'),
 substring(pg_get_triggerdef(t.oid), 'WHEN (.*)  \\$trigger')) AS whenclause,
 -- We need to convert tgargs column bytea datatype to array datatype
-(string_to_array(encode(tgargs, 'escape'), '\000')::text[])[1:tgnargs] AS custom_tgargs,
+(string_to_array(encode(tgargs, 'escape'), E'\\000')::text[])[1:tgnargs] AS custom_tgargs,
 {% if datlastsysoid %}
 (CASE WHEN t.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_trigger,
 {% endif %}


Re: [pgAdmin4][Patch]: RM #3077 - ERROR: invalid byte sequence for encoding "LATIN1":0x00

2018-02-21 Thread Khushboo Vashi
On Wed, Feb 21, 2018 at 10:51 PM, Dave Page  wrote:

>
>
> On Wed, Feb 21, 2018 at 3:45 PM, Joao De Almeida Pereira <
> jdealmeidapere...@pivotal.io> wrote:
>
>> Hi
>> The patch looks good, do we have any example error that we can test in
>> order to ensure the problem no longer shows up in the future?
>> If they could be Unit Tests instead of Feature tests that would be
>> awesome, because Feature tests are much more expensive then Unit.
>>
>
> I think we need to consider a couple of options here:
>
> 1) Make sure that many/all of our tests use non-ASCII names.
>
> +1

> 2) Consider adding a mechanism to allow running the regression tests with
> overridden GUC values. For example, a parameter in the test config file
> that gives a set of GUCs to change upon connection.
>
> The downside of 2 of course, is that it adds a huge amount of possible
> environment combinations to test.
>
> We should implement this as it would be very helpful in reducing the
testing efforts.
But as you said there will be large set of combinations, so first we need
to come up with the possible combinations which we would like to include
first.

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


[pgAdmin4][Patch]: Remove webpack plugin hardSourceWebpackPlugin from the production environment

2018-02-21 Thread Khushboo Vashi
Hi,

Please find the attached patch to remove webpack plugin
hardSourceWebpackPlugin from the production environment.

Thanks,
Khushboo
diff --git a/web/webpack.config.js b/web/webpack.config.js
index b989a4c..84f8466 100644
--- a/web/webpack.config.js
+++ b/web/webpack.config.js
@@ -324,7 +324,6 @@ module.exports = {
 uglifyPlugin,
 optimizeAssetsPlugin,
 definePlugin,
-hardSourceWebpackPlugin,
 sourceMapDevToolPlugin,
   ]: [
 extractSass,


Re: [pgAdmin4][Patch]: RM #3077 - ERROR: invalid byte sequence for encoding "LATIN1":0x00

2018-02-22 Thread Khushboo Vashi
On Thu, Feb 22, 2018 at 5:32 PM, Dave Page  wrote:

>
>
> On Thu, Feb 22, 2018 at 4:11 AM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>>
>>
>> On Wed, Feb 21, 2018 at 10:51 PM, Dave Page  wrote:
>>
>>>
>>>
>>> On Wed, Feb 21, 2018 at 3:45 PM, Joao De Almeida Pereira <
>>> jdealmeidapere...@pivotal.io> wrote:
>>>
>>>> Hi
>>>> The patch looks good, do we have any example error that we can test in
>>>> order to ensure the problem no longer shows up in the future?
>>>> If they could be Unit Tests instead of Feature tests that would be
>>>> awesome, because Feature tests are much more expensive then Unit.
>>>>
>>>
>>> I think we need to consider a couple of options here:
>>>
>>> 1) Make sure that many/all of our tests use non-ASCII names.
>>>
>>> +1
>>
>>> 2) Consider adding a mechanism to allow running the regression tests
>>> with overridden GUC values. For example, a parameter in the test config
>>> file that gives a set of GUCs to change upon connection.
>>>
>>> The downside of 2 of course, is that it adds a huge amount of possible
>>> environment combinations to test.
>>>
>>> We should implement this as it would be very helpful in reducing the
>> testing efforts.
>> But as you said there will be large set of combinations, so first we need
>> to come up with the possible combinations which we would like to include
>> first.
>>
>
> Well, we could just update the framework to include a list of GUCs and
> values in the JSON config, then we can test in different configs as needed.
>
> Sure. I will create one ticket for the same.

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


Re: [pgAdmin4][Patch]: RM #3077 - ERROR: invalid byte sequence for encoding "LATIN1":0x00

2018-02-22 Thread Khushboo Vashi
On Fri, Feb 23, 2018 at 9:45 AM, Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

>
>
> On Thu, Feb 22, 2018 at 5:32 PM, Dave Page  wrote:
>
>>
>>
>> On Thu, Feb 22, 2018 at 4:11 AM, Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>>
>>>
>>> On Wed, Feb 21, 2018 at 10:51 PM, Dave Page  wrote:
>>>
>>>>
>>>>
>>>> On Wed, Feb 21, 2018 at 3:45 PM, Joao De Almeida Pereira <
>>>> jdealmeidapere...@pivotal.io> wrote:
>>>>
>>>>> Hi
>>>>> The patch looks good, do we have any example error that we can test in
>>>>> order to ensure the problem no longer shows up in the future?
>>>>> If they could be Unit Tests instead of Feature tests that would be
>>>>> awesome, because Feature tests are much more expensive then Unit.
>>>>>
>>>>
>>>> I think we need to consider a couple of options here:
>>>>
>>>> 1) Make sure that many/all of our tests use non-ASCII names.
>>>>
>>>> +1
>>>
>>>> 2) Consider adding a mechanism to allow running the regression tests
>>>> with overridden GUC values. For example, a parameter in the test config
>>>> file that gives a set of GUCs to change upon connection.
>>>>
>>>> The downside of 2 of course, is that it adds a huge amount of possible
>>>> environment combinations to test.
>>>>
>>>> We should implement this as it would be very helpful in reducing the
>>> testing efforts.
>>> But as you said there will be large set of combinations, so first we
>>> need to come up with the possible combinations which we would like to
>>> include first.
>>>
>>
>> Well, we could just update the framework to include a list of GUCs and
>> values in the JSON config, then we can test in different configs as needed.
>>
>> Sure. I will create one ticket for the same.
>
>>
>> Created the ticket #3144.

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


Re: PoC electron and pgAdmin4

2018-02-25 Thread Khushboo Vashi
On Sat, Feb 24, 2018 at 1:44 AM, Joao De Almeida Pereira <
jdealmeidapere...@pivotal.io> wrote:

> Hi Hackers,
> After the removal of the Webkit environment we gave a shot to add electron
> as our runtime environment. We were able to do it with some degree of
> success.
> The links to get a version running with electron are:
> Windows: https://storage.googleapis.com/pgadmin-
> binaries/releases/pgAdmin%204%20Setup%203.0.0.exe
> Mac: https://storage.googleapis.com/pgadmin-binaries/releases/pgAdmin%204-
> 3.0.0.dmg
> Ubuntu: https://storage.googleapis.com/pgadmin-
> binaries/releases/pgAdmin4_3.0.0_amd64.deb
> RPM: https://storage.googleapis.com/pgadmin-binaries/releases/pgAdmin4-3.
> 0.0.x86_64.rpm
>
> After successful installation on my Ubuntu machine, the app couldn't
started.

> What did we accomplish:
>  - Use Electron as a runtime and packaging solution for the application
>  - Support opening new windows when the preferences ask for them
>  - Make the application generally work
>  - Use Chrome as a default browser for the application
>  - Building scripts for all platforms using `yarn`, please review Readme
>  - The packaged Python version is 3.6 to Mac and Linux, and 3.4 to Windows
>  - In our point of view it is a simpler way to generate the installers
>
> Work in progress:
>  - No random port for the server, so you can only start 1 instance per
> machine
>  - Tab support, there is no native support for tabs in Electron. It is
> possible to do that, and eventually you will see a option in the menu to
> create a new tab, but for this PoC we decided to disable the creation of
> tabs. Tabs need to be implemented using HTML and cannot be ripped of from
> the current window, like in Chrome
>  - Did not test in CentOS, but tested in Ubuntu and it is working (We
> tried but the electron required GLIBC 2.25 that was not on the version of
> CentOS that we had)
>  - In Linux despite the fact that we close the window, the application is
> still running and need to be killed by hand
>  - We didn't test Debigger opening in new window
>  - Loading screen has no reference to pgAdmin
>  - No logging file for the runtime
>  - Windows we are using python 3.4 and using prior version of psycopg2
> 2.5.6 and pycrypto 2.6.1 (The version of psycopg2 is not the correct one,
> this is because we couldn't find a precompile version of psycopg2)
>  - This is just a spike and the code looks pretty messy. This need to be
> changed in order to make it more readable and have some tests around it
>
> Please give it a try and let us know what you think about it. If you find
> any problem let us know as well.
> This is just a Proof Of Concept, where the majority of the application
> should be running correctly but there might be some glitches,
>
> You can find the code in: https://github.com/greenplum-db/pgadmin4/tree/
> electron-over-master
> Readme: https://github.com/greenplum-db/pgadmin4/blob/
> electron-over-master/electron/README.md
>
> Thanks
> Joao
>


[pgAdmin4][Patch]: RM #3094 - Notices from query n are shown in messages from query n+1

2018-02-26 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix the RM #3094: Notices from query n
are shown in messages from query n+1

Thanks,
Khushboo
diff --git a/web/pgadmin/utils/driver/abstract.py b/web/pgadmin/utils/driver/abstract.py
index 32e1c97..1722e21 100644
--- a/web/pgadmin/utils/driver/abstract.py
+++ b/web/pgadmin/utils/driver/abstract.py
@@ -168,6 +168,7 @@ class BaseConnection(object):
 ASYNC_WRITE_TIMEOUT = 3
 ASYNC_NOT_CONNECTED = 4
 ASYNC_EXECUTION_ABORTED = 5
+ASYNC_TIMEOUT = 0.2
 
 @abstractmethod
 def connect(self, **kwargs):
diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py b/web/pgadmin/utils/driver/psycopg2/__init__.py
index 81442e4..a412153 100644
--- a/web/pgadmin/utils/driver/psycopg2/__init__.py
+++ b/web/pgadmin/utils/driver/psycopg2/__init__.py
@@ -110,7 +110,7 @@ class Connection(BaseConnection):
   - This method is used to wait for asynchronous connection. This is a
 blocking call.
 
-* _wait_timeout(conn, time)
+* _wait_timeout(conn)
   - This method is used to wait for asynchronous connection with timeout.
 This is a non blocking call.
 
@@ -1261,51 +1261,27 @@ Failed to reset the connection to the server due to following error:
 
 Args:
 conn: connection object
-time: wait time
 """
-
-state = conn.poll()
-if state == psycopg2.extensions.POLL_OK:
-return self.ASYNC_OK
-elif state == psycopg2.extensions.POLL_WRITE:
-# Wait for the given time and then check the return status
-# If three empty lists are returned then the time-out is reached.
-timeout_status = select.select([], [conn.fileno()], [], 0)
-if timeout_status == ([], [], []):
-return self.ASYNC_WRITE_TIMEOUT
-
-# poll again to check the state if it is still POLL_WRITE
-# then return ASYNC_WRITE_TIMEOUT else return ASYNC_OK.
+while 1:
 state = conn.poll()
-if state == psycopg2.extensions.POLL_WRITE:
-return self.ASYNC_WRITE_TIMEOUT
-return self.ASYNC_OK
-elif state == psycopg2.extensions.POLL_READ:
-# Wait for the given time and then check the return status
-# If three empty lists are returned then the time-out is reached.
-timeout_status = select.select([conn.fileno()], [], [], 0)
-if timeout_status == ([], [], []):
-return self.ASYNC_READ_TIMEOUT
-
-# select.select timeout option works only if we provide
-#  empty [] [] [] file descriptor in select.select() function
-# and that also works only on UNIX based system, it do not support
-# Windows Hence we have wrote our own pooling mechanism to read
-# data fast each call conn.poll() reads chunks of data from
-# connection object more we poll more we read data from connection
-cnt = 0
-while cnt < 1000:
-# poll again to check the state if it is still POLL_READ
-# then return ASYNC_READ_TIMEOUT else return ASYNC_OK.
-state = conn.poll()
-if state == psycopg2.extensions.POLL_OK:
-return self.ASYNC_OK
-cnt += 1
-return self.ASYNC_READ_TIMEOUT
-else:
-raise psycopg2.OperationalError(
-"poll() returned %s from _wait_timeout function" % state
-)
+if state == psycopg2.extensions.POLL_OK:
+return self.ASYNC_OK
+elif state == psycopg2.extensions.POLL_WRITE:
+# Wait for the given time and then check the return status
+# If three empty lists are returned then the time-out is reached.
+timeout_status = select.select([], [conn.fileno()], [], self.ASYNC_TIMEOUT)
+if timeout_status == ([], [], []):
+return self.ASYNC_WRITE_TIMEOUT
+elif state == psycopg2.extensions.POLL_READ:
+# Wait for the given time and then check the return status
+# If three empty lists are returned then the time-out is reached.
+timeout_status = select.select([conn.fileno()], [], [], self.ASYNC_TIMEOUT)
+if timeout_status == ([], [], []):
+return self.ASYNC_READ_TIMEOUT
+else:
+raise psycopg2.OperationalError(
+"poll() returned %s from _wait_timeout function" % state
+)
 
 def poll(self, formatted_exception_msg=False, no_result=False):
 """


[pgAdmin4][Patch]: PEP-8 issue fixes

2018-02-26 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix PEP-8 issues in the below modules:

1. about
2. feature_tests
3. misc
4. utils

Thanks,
Khushboo
diff --git a/web/pgadmin/about/__init__.py b/web/pgadmin/about/__init__.py
index 98a4dd6..6d1e0b2 100644
--- a/web/pgadmin/about/__init__.py
+++ b/web/pgadmin/about/__init__.py
@@ -8,7 +8,6 @@
 ##
 
 """A blueprint module implementing the about box."""
-MODULE_NAME = 'about'
 
 import sys
 from flask import Response, render_template, __version__, url_for
@@ -18,6 +17,8 @@ from pgadmin.utils import PgAdminModule
 from pgadmin.utils.menu import MenuItem
 import config
 
+MODULE_NAME = 'about'
+
 
 class AboutModule(PgAdminModule):
 def get_own_menuitems(self):
diff --git a/web/pgadmin/feature_tests/keyboard_shortcut_test.py b/web/pgadmin/feature_tests/keyboard_shortcut_test.py
index b83457c..443eff6 100644
--- a/web/pgadmin/feature_tests/keyboard_shortcut_test.py
+++ b/web/pgadmin/feature_tests/keyboard_shortcut_test.py
@@ -65,7 +65,8 @@ class KeyboardShortcutFeatureTest(BaseFeatureTest):
 Keys.ALT
 ).perform()
 
-print("Executing shortcut: " + self.new_shortcuts[s]['locator'] + "...", file=sys.stderr, end="")
+print("Executing shortcut: " + self.new_shortcuts[s]['locator'] +
+  "...", file=sys.stderr, end="")
 
 self.wait.until(
 EC.presence_of_element_located(
diff --git a/web/pgadmin/feature_tests/view_data_dml_queries.py b/web/pgadmin/feature_tests/view_data_dml_queries.py
index aa75b6e..12e4295 100644
--- a/web/pgadmin/feature_tests/view_data_dml_queries.py
+++ b/web/pgadmin/feature_tests/view_data_dml_queries.py
@@ -100,7 +100,7 @@ CREATE TABLE public.defaults_{0}
 test_utils.create_database(self.server, "acceptance_test_db")
 
 # Create pre-requisite table
-for k, v in { 1: 'id', 2:'"ID"' }.items():
+for k, v in {1: 'id', 2: '"ID"'}.items():
 test_utils.create_table_with_query(
 self.server,
 "acceptance_test_db",
@@ -114,7 +114,7 @@ CREATE TABLE public.defaults_{0}
 self.page.add_server(self.server)
 self._tables_node_expandable()
 # iterate on both tables
-for cnt in (1,2):
+for cnt in (1, 2):
 self.page.select_tree_item('defaults_{0}'.format(str(cnt)))
 # Open Object -> View/Edit data
 self._view_data_grid()
diff --git a/web/pgadmin/misc/bgprocess/processes.py b/web/pgadmin/misc/bgprocess/processes.py
index 0c4112a..02b953d 100644
--- a/web/pgadmin/misc/bgprocess/processes.py
+++ b/web/pgadmin/misc/bgprocess/processes.py
@@ -21,10 +21,6 @@ from subprocess import Popen
 
 from pgadmin.utils import IS_PY2, u, file_quote, fs_encoding
 
-if IS_PY2:
-from StringIO import StringIO
-else:
-from io import StringIO
 import pytz
 from dateutil import parser
 from flask import current_app
@@ -33,6 +29,10 @@ from flask_security import current_user
 
 import config
 from pgadmin.model import Process, db
+if IS_PY2:
+from StringIO import StringIO
+else:
+from io import StringIO
 
 
 def get_current_time(format='%Y-%m-%d %H:%M:%S.%f %z'):
diff --git a/web/pgadmin/utils/__init__.py b/web/pgadmin/utils/__init__.py
index 198553e..5f81e09 100644
--- a/web/pgadmin/utils/__init__.py
+++ b/web/pgadmin/utils/__init__.py
@@ -7,6 +7,8 @@
 #
 ##
 
+import os
+import sys
 from collections import defaultdict
 from operator import attrgetter
 
@@ -152,9 +154,6 @@ class PgAdminModule(Blueprint):
 return res
 
 
-import os
-import sys
-
 IS_PY2 = (sys.version_info[0] == 2)
 IS_WIN = (os.name == 'nt')
 
diff --git a/web/pgadmin/utils/compile_template_name.py b/web/pgadmin/utils/compile_template_name.py
index 28b5bf8..49c7b6a 100644
--- a/web/pgadmin/utils/compile_template_name.py
+++ b/web/pgadmin/utils/compile_template_name.py
@@ -9,8 +9,14 @@
 import os
 
 
-def compile_template_name(template_prefix, template_file_name, server_type, version):
-return os.path.join(compile_template_path(template_prefix, server_type, version), template_file_name)
+def compile_template_name(
+template_prefix,
+template_file_name,
+server_type, version
+):
+return os.path.join(
+compile_template_path(template_prefix, server_type, version),
+template_file_name)
 
 
 def compile_template_path(template_prefix, server_type, version):
diff --git a/web/pgadmin/utils/javascript/tests/test_javascript_bundler.py b/web/pgadmin/utils/javascript/tests/test_javascript_bundler.py
index f946cb8..7030703 100644
--- a/web/pgadmin/utils/javascript/tests/test_javascript_bundler.py
+++ b/web/pgadmin/utils/javascript/tests/test_javascript_bundler.py
@@ -9,16 +9,15 @@
 
 
 import sys
+from pgadmin.utils.route import BaseTestGenerator
+from pgadmin.utils.javascript.javascript_bundler imp

Re: [pgAdmin4][Patch]: PEP-8 issue fixes

2018-02-27 Thread Khushboo Vashi
On Mon, Feb 26, 2018 at 9:19 PM, Dave Page  wrote:

> Can you rebase this please? It doesn't apply against master.
>
> Please find the updated patch excluding utils module as it is already
done.

> On Mon, Feb 26, 2018 at 12:04 PM, Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Please find the attached patch to fix PEP-8 issues in the below modules:
>>
>> 1. about
>> 2. feature_tests
>> 3. misc
>> 4. utils
>>
>> Thanks,
>> Khushboo
>>
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/about/__init__.py b/web/pgadmin/about/__init__.py
index 98a4dd6..6d1e0b2 100644
--- a/web/pgadmin/about/__init__.py
+++ b/web/pgadmin/about/__init__.py
@@ -8,7 +8,6 @@
 ##
 
 """A blueprint module implementing the about box."""
-MODULE_NAME = 'about'
 
 import sys
 from flask import Response, render_template, __version__, url_for
@@ -18,6 +17,8 @@ from pgadmin.utils import PgAdminModule
 from pgadmin.utils.menu import MenuItem
 import config
 
+MODULE_NAME = 'about'
+
 
 class AboutModule(PgAdminModule):
 def get_own_menuitems(self):
diff --git a/web/pgadmin/feature_tests/keyboard_shortcut_test.py b/web/pgadmin/feature_tests/keyboard_shortcut_test.py
index b83457c..443eff6 100644
--- a/web/pgadmin/feature_tests/keyboard_shortcut_test.py
+++ b/web/pgadmin/feature_tests/keyboard_shortcut_test.py
@@ -65,7 +65,8 @@ class KeyboardShortcutFeatureTest(BaseFeatureTest):
 Keys.ALT
 ).perform()
 
-print("Executing shortcut: " + self.new_shortcuts[s]['locator'] + "...", file=sys.stderr, end="")
+print("Executing shortcut: " + self.new_shortcuts[s]['locator'] +
+  "...", file=sys.stderr, end="")
 
 self.wait.until(
 EC.presence_of_element_located(
diff --git a/web/pgadmin/feature_tests/view_data_dml_queries.py b/web/pgadmin/feature_tests/view_data_dml_queries.py
index aa75b6e..12e4295 100644
--- a/web/pgadmin/feature_tests/view_data_dml_queries.py
+++ b/web/pgadmin/feature_tests/view_data_dml_queries.py
@@ -100,7 +100,7 @@ CREATE TABLE public.defaults_{0}
 test_utils.create_database(self.server, "acceptance_test_db")
 
 # Create pre-requisite table
-for k, v in { 1: 'id', 2:'"ID"' }.items():
+for k, v in {1: 'id', 2: '"ID"'}.items():
 test_utils.create_table_with_query(
 self.server,
 "acceptance_test_db",
@@ -114,7 +114,7 @@ CREATE TABLE public.defaults_{0}
 self.page.add_server(self.server)
 self._tables_node_expandable()
 # iterate on both tables
-for cnt in (1,2):
+for cnt in (1, 2):
 self.page.select_tree_item('defaults_{0}'.format(str(cnt)))
 # Open Object -> View/Edit data
 self._view_data_grid()
diff --git a/web/pgadmin/misc/bgprocess/processes.py b/web/pgadmin/misc/bgprocess/processes.py
index 0c4112a..02b953d 100644
--- a/web/pgadmin/misc/bgprocess/processes.py
+++ b/web/pgadmin/misc/bgprocess/processes.py
@@ -21,10 +21,6 @@ from subprocess import Popen
 
 from pgadmin.utils import IS_PY2, u, file_quote, fs_encoding
 
-if IS_PY2:
-from StringIO import StringIO
-else:
-from io import StringIO
 import pytz
 from dateutil import parser
 from flask import current_app
@@ -33,6 +29,10 @@ from flask_security import current_user
 
 import config
 from pgadmin.model import Process, db
+if IS_PY2:
+from StringIO import StringIO
+else:
+from io import StringIO
 
 
 def get_current_time(format='%Y-%m-%d %H:%M:%S.%f %z'):
diff --git a/web/pgadmin/utils/__init__.py b/web/pgadmin/utils/__init__.py
index 631e981..c87a045 100644
--- a/web/pgadmin/utils/__init__.py
+++ b/web/pgadmin/utils/__init__.py
@@ -7,6 +7,8 @@
 #
 ##
 
+import os
+import sys
 from collections import defaultdict
 from operator import attrgetter
 
@@ -153,9 +155,6 @@ class PgAdminModule(Blueprint):
 return res
 
 
-import os
-import sys
-
 IS_PY2 = (sys.version_info[0] == 2)
 IS_WIN = (os.name == 'nt')
 
@@ -316,4 +315,3 @@ SHORTCUT_FIELDS = [
 'label': gettext('Alt/Option')
 }
 ]
-
diff --git a/web/pgadmin/utils/javascript/tests/test_javascript_bundler.py b/web/pgadmin/utils/javascript/tests/test_javascript_bundler.py
index f946cb8..7030703 100644
--- a/web/pgadmin/utils/javascript/tests/

Re: pgAdmin 4 commit: Ensure we pick up the messages from the current query

2018-02-28 Thread Khushboo Vashi
On Mon, Feb 26, 2018 at 10:02 PM, Dave Page  wrote:

> Argh, I ran some tests, but didn't spot any lost messages in the tests I
> ran. I'll revert the patch.
>
> Khushboo;
>
> Please look at the following:
>
> - Fix the patch so it doesn't drop messages.
>
Fixed.
By default, the notice attribute of the connection object of psycopg 2 only
stores 50 notices. Once it reaches to 50 it starts from 1 again.
To fix this I have changed the notice attribute from list to deque to
append more messages. Currently I have kept the maximum limit at a time of
the notice attribute is 10 (in a single poll).

> - Add regression tests to make sure it doesn't break in the future. This
> may require creating one or more functions the spew out a whole lot of
> notices, and then running a couple of queries and checking the output.
>
Added. With this regression test, the current code is failing which has
been taken care in this patch.

> - Check the messages panel on the history tab. I just noticed it seems to
> only be showing an even smaller subset of the messages.
>
Tested and no issues found.

>
>
Thanks.
>
> On Mon, Feb 26, 2018 at 4:23 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Sent bit early,
>>
>> You can run 'VACUUM FULL VERBOSE' in query tool and verify the populated
>> messages (pgAdmin3 vs. pgAdmin4).
>>
>>
>> On Mon, Feb 26, 2018 at 9:48 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi Khushboo/Dave,
>>>
>>> With given commit, I'm again seeing the issue raised in
>>> https://redmine.postgresql.org/issues/1523 :(
>>>
>>>
>>>
>>>
>>> --
>>> Regards,
>>> Murtuza Zabuawala
>>> EnterpriseDB: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>>
>>> On Mon, Feb 26, 2018 at 7:49 PM, Dave Page  wrote:
>>>
>>>> Ensure we pick up the messages from the current query and not a
>>>> previous one. Fixes #3094
>>>>
>>>> Branch
>>>> --
>>>> master
>>>>
>>>> Details
>>>> ---
>>>> https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdif
>>>> f;h=08b3ccc01a4d57e8ea3657f8882a53dcd1b99386
>>>> Author: Khushboo Vashi 
>>>>
>>>> Modified Files
>>>> --
>>>> web/pgadmin/utils/driver/abstract.py  |  1 +
>>>> web/pgadmin/utils/driver/psycopg2/__init__.py | 64
>>>> +--
>>>> 2 files changed, 21 insertions(+), 44 deletions(-)
>>>>
>>>>
>>>
>>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/feature_tests/keyboard_shortcut_test.py b/web/pgadmin/feature_tests/keyboard_shortcut_test.py
index b83457c..f751211 100644
--- a/web/pgadmin/feature_tests/keyboard_shortcut_test.py
+++ b/web/pgadmin/feature_tests/keyboard_shortcut_test.py
@@ -62,7 +62,9 @@ class KeyboardShortcutFeatureTest(BaseFeatureTest):
 ).key_down(
 key_combo[2]
 ).key_up(
-Keys.ALT
+key_combo[0]
+).key_up(
+key_combo[1]
 ).perform()
 
 print("Executing shortcut: " + self.new_shortcuts[s]['locator'] + "...", file=sys.stderr, end="")
diff --git a/web/pgadmin/tools/sqleditor/tests/test_poll_query_tool.py b/web/pgadmin/tools/sqleditor/tests/test_poll_query_tool.py
new file mode 100644
index 000..61655e7
--- /dev/null
+++ b/web/pgadmin/tools/sqleditor/tests/test_poll_query_tool.py
@@ -0,0 +1,109 @@
+##
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2018, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##
+
+import json
+
+from pgadmin.browser.server_groups.servers.databases.tests import utils as \
+database_utils
+from pgadmin.utils.route import BaseTestGenerator
+from regression import parent_node_dict
+from regression.python_test_utils import test_utils as utils
+
+
+class TestPollQueryTool(BaseTestGenerator):
+""" This class will test the query tool polling. """
+scenarios = [
+('When query tool polling returns messages with result data-set',
+ dict(
+ sql="""
+DROP TABLE

Re: pgAdmin 4 commit: Ensure we pick up the messages from the current query

2018-02-28 Thread Khushboo Vashi
Hi Joao,

Thanks for reviewing.

On Wed, Feb 28, 2018 at 8:55 PM, Joao De Almeida Pereira <
jdealmeidapere...@pivotal.io> wrote:

> Hello Khushboo,
> After reviewing the patch I have the gut feeling that we do not have
> enough test coverage on this issue, specially due to the intricate while
> loop and conditions around the polling.
> I think that this deserve Unit tests around it, When I say Unit Test I am
> not talking about executing queries against the database, but do some
> stubbing of the database so that we can control the flow that we want.
>
You are right. It needs more unit testing. I have checked below scenarios:
1. Returns 2 notices with data output
2. Returns 1000 notices with data output
3. No notices with data output

By running above, I have checked, each time returned notices are accurate,
no old notices are getting appended, it does not affect with the amount of
messages (few, none or more).  Also, with the updated patch, I have made
sure that all these queries run with the single transaction id (same
connection).

So, please let me know if you think I can add more things to this.

>
>
It is a temptation to try to always do a Feature Test to test what we want
> because it is "easier" to write and ultimately it is what users see, but
> while 1 Feature Test runs we can run 200 Unit Tests that give us much more
> confidence that the code is doing what we expect it to do.
>
> Right, so added regression tests instead of feature tests.

This being said, I run the tests on the CI Pipeline and all tests pass.
> Running pycodestyle fails due to some line sizes on the
> psycopg2/__init__py. I believe that it is not what you changed, but since
> you were changing the file it can be fixed it is just:
>
> pgadmin/utils/driver/psycopg2/__init__.py:1276: [E501] line too long (81
> > 79 characters)
> pgadmin/utils/driver/psycopg2/__init__.py:1277: [E501] line too long (91
> > 79 characters)
> pgadmin/utils/driver/psycopg2/__init__.py:1282: [E501] line too long (81
> > 79 characters)
> pgadmin/utils/driver/psycopg2/__init__.py:1283: [E501] line too long (91
> > 79 characters)
> 4   E501 line too long (81 > 79 characters)
>
> Fixed. Thanks for pointing out.

>
> Thanks
> Joao
>
>
> On Wed, Feb 28, 2018 at 6:49 AM Khushboo Vashi <
> khushboo.va...@enterprisedb.com> wrote:
>
>> On Mon, Feb 26, 2018 at 10:02 PM, Dave Page  wrote:
>>
>>> Argh, I ran some tests, but didn't spot any lost messages in the tests I
>>> ran. I'll revert the patch.
>>>
>>> Khushboo;
>>>
>>> Please look at the following:
>>>
>>> - Fix the patch so it doesn't drop messages.
>>>
>> Fixed.
>> By default, the notice attribute of the connection object of psycopg 2
>> only stores 50 notices. Once it reaches to 50 it starts from 1 again.
>> To fix this I have changed the notice attribute from list to deque to
>> append more messages. Currently I have kept the maximum limit at a time of
>> the notice attribute is 10 (in a single poll).
>>
>>> - Add regression tests to make sure it doesn't break in the future. This
>>> may require creating one or more functions the spew out a whole lot of
>>> notices, and then running a couple of queries and checking the output.
>>>
>> Added. With this regression test, the current code is failing which has
>> been taken care in this patch.
>>
>>> - Check the messages panel on the history tab. I just noticed it seems
>>> to only be showing an even smaller subset of the messages.
>>>
>> Tested and no issues found.
>>
>>>
>>>
>> Thanks.
>>>
>>> On Mon, Feb 26, 2018 at 4:23 PM, Murtuza Zabuawala >> enterprisedb.com> wrote:
>>>
>>>> Sent bit early,
>>>>
>>>> You can run 'VACUUM FULL VERBOSE' in query tool and verify the
>>>> populated messages (pgAdmin3 vs. pgAdmin4).
>>>>
>>>>
>>>> On Mon, Feb 26, 2018 at 9:48 PM, Murtuza Zabuawala >>> enterprisedb.com> wrote:
>>>>
>>>>> Hi Khushboo/Dave,
>>>>>
>>>>> With given commit, I'm again seeing the issue raised in
>>>>> https://redmine.postgresql.org/issues/1523 :(
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Regards,
>>>>> Murtuza Zabuawala
>>>>> EnterpriseDB: http://www.enterprisedb.com
>>>>> The Enterprise PostgreSQL Company
>>>>>
>>>>>
>>>>> On Mon, Feb 

  1   2   3   4   5   6   7   8   >